I am making a Survival game. In it, I plan to define Mana as Energy. Every 3 Hours, Player loses "10%" of Energy so you have to constantly eat and drink to recover Energy, Every day. How do I declare this through events on Main Map ?
From what i notice, I can only remove a set amount of HP/MP from Event Commands, This is not helpful at all since i also plan to have Gear that add or remove Energy (Mana) so a "Flat" amount won't work, I need a way to "Remove % of MP".
I'll just note the Length of a Day & Night Cycle in my Game and make sure I get the timing right for every 3 Hours, So all I'm asking for is help with just "Removing % of MP" through events, Not asking for help with synchronizing Day and Night cycle with this event.
Set a variable to the character's Current MP (or to the character's Maximum MP if you are actually trying to remove a % of their Max MP, which makes more sense to me if you are trying to encourage consistent consumption of food). Divide that variable by 10. Then, remove that much MP from the character by choosing Lose MP -> choose that Variable.
Um... Can you guys show me an example with a line or two of the code if possible ? I'm sorry I'm a beginner when it comes to event-ing and I'm not so good with math or declaring variables linked to a math function.
I just know the basics of declaring a Variable, That's about it 😅
OK, then to the basics.
First you need to keep in mind that the engine always cuts of partial numbers, so any mathematical operation has to have the division or decimal multiplication last to keep the error from growing.
That said, it is a relatively simple series of control variable commands - which is an extremely versatile command.
It is also good to reserve some variables for temporary operations, never storing a value there long-term.
control variable HPcost = actorXY's HP (can be selected under game data, the line that defaults to map id but has a lot more behind it)
control variable HPcost *= 0.10 (multiply by 0.10, this would give 10% of the original value, and this is where you have to know percentage mathematics - as ozubon said above you need to know what to multiply the value with to get the correct other value)
change HP: actorXY (or possible "entire party" for your game), decrease, variable HPcost
That is a series of three event commands that in combination do what you want.
If you have problems with percentage mathematics you can ask us here for help, but I strongly advice to brush up on your schoolbooks in such a case as a "survival" type game will require the developer to know his mathematics for balancing.
I also suggest you follow the link to the "starting point" in my signature. It lists a lot of tutorials and specifically a tutorial game called "variables gude" that you should play before going on with game development