Lesson from Script Pack 10 - Nazi Zombies:
http://forum.thegamecreators.com/?m=forum_view&b=23&t=212254&p=0
Read\Download PDF online:
https://yadi.sk/i/Bsj63MNQh2nQm
SHOTDAMAGE=X for Player
Intro
FPS Creator has fpi command SHOTDAMAGE = X, which means: "If the entity \ character takes damage, it perform the action ...." But the list of commands fpi you will not find a similar command to the player. BUT you can realize it with the help of internal variables «internal». You will need a variable «$ PH» (Player Health), which shows the level of health of the player. The main principle of our commands is as follows: "If the player's health has changed (not equal to the current value), then perform the action ...."
Creating this condition
First you need to create a new local variable. That we need to compare the current health of the player:
:state=0:dimlocalvar=H,setvar=H $PH,state=1
dimlocalvar=H – the name of the new variable (it can be anything, for convenience, I use the H (Health);
setvar=H $PH – assign our variable "H" value «$ PH», that is Our variable has a value equal to the current health of the players (the default is 500 hp).
Now you need to create a comparison of these variables. We will write the script for this algorithm, "if the value of the variable $ PH is less than the value of the variable H, then ..."
How to do it? Very simple! We will use the «PLRHEALTHLESS = X». The second line of the script would look like:
:state=1,plrhealthless=%H:state=2
The icon "%" means that fpi command «plrhealthless» takes a value in our variable "H" (remember that the value of the variable H is equal to the current health of player - 500 hp).
But there is not enough of another fpi command after the second a colon, namely the renovation of our variable "H". When the player's health has changed, we need to update our variable "H" and assign it a new value of the current health of the player. So we finish the second line of the script action:
:state=1,plrhealthless=%H:setvar=H $PH,state=2
Now what happens? Once a player has changed the level of health, our condition is triggered «plrhealthless =% H» and updated value of the variable "H" to a new level of current health. It's too hard? Here's a simple example:
The player has 500 hp, it fell from a great height and his health declined by 50 hp. Since Variable H = 500, then just our condition can write:
plrhealthless=500
After this condition is updated value of the variable "H":
setvar=H $PH
Now the variable H = 450. As you have seen, we have introduced an additional variable to the script has been universal, that we do not have to register multiple «plrhealthless = x» in each case.
Conclusion
With this condition greatly expanded range of possibilities FPS Creator! Now it is possible to implement many ideas related to the health of the player. For example, as implemented in the script pack №10, heartbeat and blood drops on the screen when critical injuries. Earlier this script took lots and lots of strings to react to the slightest change in health. Now is responsible for it all one line! We just do the assignment of the value of one variable to another, such as the programming language of a higher level:
a = 500
b = a
if a < b then
…
As you can see something like that can be implemented and FPS Creator.