Well I made this system recently for someone but I guess plenty of people is looking for this kind of system.
"I want to make something like when the player moves, he recovers some MP, like 5 MP per step."
Plenty of people would say:
"Just make a conditional branch, and check if the player is pressing an arrow button."
But, the problem would be when the player is pressing the arrow button, but the player actually not moving,
like colliding with a wall or in a cut scene.
So, I made this simple system for recovering 5 MP for each true step the player does, only if the player actually moves.
Download:http://www.4shared.com/file/76803623/69bbd..._Project38.htmlTutorial:To be used:
1 common event [parallel process], 4 variables, and 1 switch.
Variables names:
PX.
PY.
X.
Y.
Switches names:
001: Changed?
System:
CODE
If switch 001: Changed? is ON
X = Player Map X.
Y = Player Map Y.
If X == PX
Do nothing.
Else
Change Player MP + 5.
Control Switches 001: Changed? turn OFF.
End
If Y == PY
Do nothing.
Else
Change Player MP + 5.
Control Switches 001: Changed? turn OFF.
End
Else
PX = Player Map X.
PY = Player Map Y.
Control Switches 001: Changed? turn ON.
End
Tutorial Explained.So, first we check if the switch 001: Changed? is ON.
By default, it is OFF.
We see in the system, that if that switch isn't ON (Else), something happens, that something is
setting the variables PX and PY a value, what value? The value if the player map X and Y.
PX = Player Map X.
PY = Player Map Y.
After doing so, we turn the switch 001: Changed? ON, so, the conditional branch will notice so,
and will run the other part of the system.
In this part, we set another pair of values, X and Y.
X = Player Map X.
Y = Player Map Y.
I know, this makes not much sense right now, why to set the same value to those variables than the PX and PY values?
Well, soon you will see.
After doing so, we will check if the variable X is equal to the variable PX.
And now, you may think that this doesn't makes sense, too, but you will see soon.
If the value is equal, we don't really do something because it means that the player is in the same X position.
But, if the value isn't equal, it means the player is in a different X position.
If that's the case, it means the player as moved to the left or to the right.
Well, we know that the player moved, so we will heal him 5 MP and then turn the switch 001: Changed? OFF,
so that the system repeats.
The same thing with the Y and the PY variables.
Ok, that thing which made non sense at first, is explained now:
The system is a parallel process, so once the system as set the PX and PY values,
turn the switch ON, right? Doing so, the system will set the values X and Y, and check if they
are equal to their past, PX and PY.
If they are equal, the system basically ends... But no in this case, the system is a parallel process,
so it will repeat that piece of commands until X and Y are different than PX and PY, will over and over
check that, until the player moves.
Once the player moves, the system is able to heal him 5 MP and then turn the switch OFF, for repeating
the whole thing.
Note, PX and PY basically means Past X and Past Y in the system.
I hope this helped you guys.
Enjoy.
Omegas7.