# Triggering common event every time a variable increases/decreases by x amount?

#### Amarok

##### Veteran
So im trying to add a bit of strategy to my game by using a turn based system on the overworld. (Think the total war games or Civilization)
I already know how to trigger events and change things when X turn is reached. But i also need certain events to trigger after every 3 turns pass, for example (with turns being a variable)

Basically in the conditional branch page i can set the event to activate once the variable turns reach a certain amount, like turn 2, 10, etc... Now i only need to make it trigger every time the variable goes up 3 times for example.
Is there a way to do this?

#### Poryg

##### Dark Lord of the Castle of Javascreeps
goes up 3 times like increase-increase-increase with values completely irrelevant:
have a variable track the amount of times a variable has increased.

Variable goes up 3 times (variable = 3*variable):
if - script - \$gameVariables.value(1) == 3*\$gameVariables.value(1)

#### Amarok

##### Veteran
goes up 3 times like increase-increase-increase with values completely irrelevant:
have a variable track the amount of times a variable has increased.

Variable goes up 3 times (variable = 3*variable):
if - script - \$gameVariables.value(1) == 3*\$gameVariables.value(1)
So its possible awesome! thank you but im such a noob with these things, so im not sure if i understood correctly what you wrote, how can i make the variable track the amount of times it has increased?' i used the code you wrote, but now the event triggers as soon as the switch of the parallel common event gets on. :S

#### Poryg

##### Dark Lord of the Castle of Javascreeps
simple.
You have common event increasing variable 1, which symbolizes passed days.

Instead of the common event only doing
variable operations: 0001, +1

do this:

variable operations: 0001, +1
variable operations: 0002, +1
if (0002 is equal to 3)
trigger switch 0001 on
variable operations: 0002, = 0
and that switch 0001 is the trigger switch for your parallel process common event that is supposed to activate after 3 days passed. And every 3 days the switch 0001 turns on and the parallel process activates.

There are many ways to do this, depending on what you exactly want to do.

#### Amarok

##### Veteran
@Poryg it worked! thank you so much mate! i will have to keep tinkering it to make it work the exact way it want but this is an awesome starting point.

#### Poryg

##### Dark Lord of the Castle of Javascreeps
You're welcome
Yup, playing with it is the best way to learn I have spent 3 years playing with RM2003 (never really created a serious project :'( )

#### Bex

##### Veteran
You could also use the Modulo Function in Control Variable Eventcommand.
It gives the left overs of something (sorry my english is lacking).

10 modulo 3 = 1 ( 3+3+3 = 9 and the Leftover is 1)

Variable?? = VariableTurn Count
Variable?? modulo 3
conditional branch variable?? equals 0
if yes show textbox: You did it .

If the leftover is 0 its 3 turns pass ^^ if its 1 or 2than the condition is false.
That means every 3 turns this condition would be true.

#### Poryg

##### Dark Lord of the Castle of Javascreeps
This would only work under the assumption that the op would increase the variable always by 1 though, so I opted to give the more general answer.

#### Bex

##### Veteran
He mentioned in his first post that he knows how to let something happen at a certain turn in the fight,
thats why i assumed he uses inbuild variable or counter to keep track of that. i also just wanted to mention this as extra angle for solution ways.

#### Amarok

##### Veteran
@Bex thanks! the example poryg provided was enough to do what i wanted, though i need more knowledge to make it exactly the way i want, i will also take a look at your solution since indeed the variable will only be increased by 1 each time.

#### Bex

##### Veteran
ah i made a mistake in the code, it would activate at turn 0, to prevent that the pseudo code would be:

Conditional Branch "Variable for Turn Count" more then 0 ?
if yes
-Variable?? = VariableTurn Count
-Variable?? modulo 3
-conditional branch variable?? equals 0
-if yes show textbox: You did it .
else
nothing

Edit: I reread first post and iam sorry my english aint the best. i partialy missread the problem. And poryg also allready posted modulo in his first answer with the scriptline ^^.
Have to take more time reading next time.

Edit2: what exactly are you building in terms of mechanic? iam just curious.

Last edited:

#### Amarok

##### Veteran
@Bex just a simple turn based system like the one games like the total war series has. Basically, most of the game takes place on the worldmap/overworld and every time the players does something, like a quest, seeing an event, conquering a province, etc one turn passes.

The reason why i need certain events to trigger every x turns is to simulate the ability of whatever factions you are at war with to try and strike back at you, by retaking their provinces or attacking yours.

I guess the most simple way to achieve this would be the best.

### Latest Profile Posts

Damian Floyd increased the grand prize for the Driftwood Jam to a \$75 steam GC!!! Thank you Damion!
Is everybody using their imagination?
The character designer for my game is using my character for her class work lol
Why the frick frack snick snack is Pokemon Black & White so expensive now?! \$99 on Amazon? \$9999 ON EBAY!? WHAT?!