Variables
Variables are a powerful way to change or affect the battle
The current use for them are as conditions to behaviors or drawings
Setting a variable
To set a variable, use the Variable behavior, when this behavior activates it will update the variable
You need to provide a name for the variable that will be used in other places
An example is blaster_activation_counter
Set it to shared to be able to access it from other objects
Set the operator to ADD a value for example
Then set the value you want to in this case ADD
- Variable name: The name of the variable
- Operator: The operation to do with the variable
- Value: The value to use in the operation
- Shared: If the variable is shared between objects
So if you do the following
- Variable name: blaster_activation_counter
- Operator: ADD
- Value: 1
- Shared: true
That means that each time this behavior activates the variable blaster_activation_counter will be incremented by one
Checking variables
To check a variable the condition Variable is used
Name of the variable should be the same as you set before
Value is what you want to compare to
Comparator is how we should check the value
- Variable name: The name of the variable
- Comparator: The comparison to do with the variable
- Value: The value to compare to
So to check if the previously set variable is larger then 5 so we can activate something we do
- Variable name: blaster_activation_counter
- Comparator: GREATER_THAN
- Value: 5
Now when the variable blaster_activation_counter reaches 6(greater than 5) this condition will activate
System variables
There is also some predefined variables that you can access
Those are:
- sys-player-hp: The current health of the player
- sys-player-hp-max: The maximum health of the player
- sys-player-hp-percentage: The percentage of health the player has
- sys-player-heals: The amount of heals the player has
- sys-boss-hp: The current health of the boss
- sys-boss-hp-max: The maximum health of the boss
- sys-boss-hp-percentage: The percentage of health the boss has
- sys-boss-score: The score(if active)
- sys-boss-turns: The current turn
These variables will be updated automatically and can be used as conditions
Example condition when boss hp is less then 50%
- Variable name: sys-boss-hp-percentage
- Comparator: LESS_THAN
- Value: 50
Shared vs not shared
What does that mean?
Not shared
A variable that is not shared means that only the projectile or spawner that have the behavior can use it
A good example could be a fireball that have a variable called "grow", after 2 seconds that behavior activates and sets "grow" to 1
In that fireball we have 2 drawings, small fireball and large fireball. the small fireball have a stop condition if "grow" equals 1, the large drawing have a start condition of the same
If the variable would have been shared all fireballs would have updated when one reaches the condition
Shared
A shared variable is global between all projectiles and spawners and persist between attacks
One example could be that you have a spawner that every 60 frames updated "harder" with 1
Then in another spawner you check if this have reached larger than 6 and then activates another spawner, making the attack harder
Or maybe you want after some time all fireballs should use the larger version instead of the small