✨ General: Local Variables and Percentages

A local variable is essentially just a regular variable, but it's specific to an event. This approach helps avoid the need to create 100 variables for 100 enemies, which would be exhausting. Moreover, if you spawn events from a template map, using the same regular variables could lead to those variables being shared across all spawned events, potentially causing the game to malfunction.

Using a local variable with Action Combat is quite simple. For example, if you want to check if the local variable of the current event is greater than 5 to make the event jump, here's how you can do it:



Firstly, let's select the Control Local Variable command and set the Value to 5. That's it.

Now, to check if the local variable of the current event is greater than 5, we use a conditional branch:

localVariable(this._eventId) >= 5

Done and done. That's easy but you'll find yourself using it a lot!


Multiple Local Variable


The downside of the previous method is that, while it's simple, you can only have one local variable per event. If you use another Control Local Variable command to set a different value, you'll just overwrite the existing one.

To manage multiple local variables, specify a unique name for each variable in the Name ID field.


This will create a local variable named Fire with a value of 5. If you want to create another local variable, just write a different name, such as Water. This way, you'll have two local variables, Fire and Water. This approach is slightly more complex but becomes extremely useful when you're building more advanced systems.

Now, to check these variables using a conditional branch, you would use something like this:

localVariable(this._eventId,  'Fire') >= 5 or localVariable(this._eventId,  'Water') >= 5

Random Value

Assigning random value with Regular Variable

With regular variables, you can assign a random value to the variable using the method above. The same applies to local variables; you can assign random values to them as well.

Assigning random value with Local Variable


When you enter a value in Random Max Number, the Value field becomes the minimum, and Random Max Number becomes the maximum. This setup will generate a random value between 1 and 50.



5 RPG Maker Action Combat Manual: ✨ General: Local Variables and Percentages A local variable is essentially just a regular variable, but it's specific to an event. This approach helps avoid the need to create 100...
< >