Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / The FPSCreator Scripting Guide Part 2: Using Variables

Author
Message
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 1st Jul 2012 04:35 Edited at: 1st Jul 2012 05:10
If you haven't read part 1 of the scripting guide, then please read it

For these tutorials to work, you should use either FPSC v1.19 or v1.20 (recommended)

Variables are basically strings (pieces of text) that hold values. For example, you could make a script that works together with another script by using variables. The first script would maybe set variable "playerstoodhere" to "1" and then the other script would check if it was 1, and if it was it would then do something. You can however make it so that a variable can only be read and edited by one entity by setting it as local.

NOTE: I will not be covering using variables without varnames.
eg setvar=HasKey,addvar=1
I will not be covering setup vars either

NOTE: You must have "Full Shader Effects" on in preferences and PostProcessing set to 1 in setup.ini for the script to look right.

First off, I'll tell you the conditions that you use for variables:
VarEqual=X Y -- Checks whether variable X is equal to Y
VarGreater=X Y -- Checks whether variable X's value is larger than Y
VarLess=X Y -- Checks whether variable X's value is less than Y
VarNotEqual=X Y -- Checks whether variable X is not equal to Y

And now the actions:
AddVar=X Y -- Adds Y to variable X's value
Cos=X Y -- Sets variable X to the cosine of Y degrees
DimLocalVar=X -- Sets variable X to local, this means that only the current entity can edit and read this variable
DimVar=X -- Sets variable X to global, this can be read and edited by any entity
DivVar=X Y -- Divides variable X by Y
ModVar=X Y -- Performs a modulus operation on variable X. This command is similar to the WrapVar action, but instead you can define the wrap around point with Y
MulVar=X Y -- Multiplies variable X by Y
SetVar=X Y -- Sets variable X's value to Y
SetVarRnd=X Y -- Sets variable X to a random number between 0 and Y
Sin=X Y -- This sets variable X to the sine of Y degrees
SubVar=X Y -- This subtracts Y from variable X's value
WrapVar=X -- This performs a modulus operation of variable X by 360
AddRawVar=X -- This adds variable X's value to the currently displayed on-screen text that is displayed by "FPGCRawText"

Next up are the internal variables, these are set by FPSC, and some can be modified. These hold things like the location of the current entity, or the player's health etc. For example, to set the camera angle on the X axis to 90, you would go SetVar=$CAX 90

$PH – Player’s health
$PL – Player’s lives
$RA – Player’s total ammo in right-hand
$A - Player’s total ammo
$RCA - Player’s ammo in right-hand gun
$CA - Player’s ammo in gun
$EH - Entity’s health
$EA - Entity’s ammo in gun (there is no total ammo for entities as they have unlimited ammo)
$EPX - Entity’s position in x-axis
$EPY - Entity’s position in y-axis
$EPZ - Entity’s position in z-axis
$EAX - Entity’s angle around x-axis
$EAY - Entity’s angle around y-axis
$EAZ - Entity’s angle around z-axis
$CPX - Camera’s position in x-axis
$CPY - Camera’s position in y-axis
$CPZ - Camera’s position in z-axis
$CAX - Camera’s angle around x-axis
$CAY - Camera’s angle around y-axis
$CAZ - Camera’s angle around z-axis
$MMX – Mouse movement in x direction
$MMY – Mouse movement in y direction
$AIR – Amount of air, or air level
$ARM – Amount of armour, or armour level
$DIF – Distance from player in feet (read-only)
$DIM – Distance from player in meters (read-only)
$DIS – The distance between the entity and the player (read only)
$FPS – Frame rate (read-only)
$MAX – Number of weapon slots
$WAT – Water height

NOTE: If a variable is "read-only", you cannot modify it.

For this tutorial, we will make a script for a "key". This key will be a poisonous object, that will poison the player, make them drop all of their weapons, lower their health to 10 and make the view all weird. Plus an optional motionsickness effect.

To start off, we'll begin with the default script:



First off, we want to set all of our required variables:



Now we want to set it so that if the player touches the object (basically if you're within 40% of a segment of the object), it will be picked up, and Active will be set to 1



Once this is done, we want to make all that cool stuff happen when Active is 1



Now for the optional "motion sickness" effect:



So your script should look something like this:



Now let me explain a few of the commands:

CamFov=X -- Sets the field-of-vision of the player to X
RemoveCurrentWeapon -- Removes the current weapon the player is using
CamShake=X -- Shakes the camera with a strength of X
PlayerTake -- Makes the player take the object

And you're done! Assign this script to an object and watch how your player becomes poisoned!

-TZK

BlackFox
FPSC Master
16
Years of Service
User Offline
Joined: 5th May 2008
Location: Knight to Queens Bishop 3
Posted: 1st Jul 2012 04:42 Edited at: 1st Jul 2012 04:44
Good detailed explanation on variable usage. My only thing is that you may want to specify the version of FPSC this will work for. I know this will work for v1.19 and up (although a few of the variables will work in v1.18 and up) but new users may not and if they are running an old version, they become discouraged when their script does not work. You might consider marking what variables work in what version (ex: dimvar- v1.18+, etc).

Otherwise, I'd like to add these tutorial links to the "General Scripting Information" thread I'm working on so they won't be lost.


Twitter: @NFoxMedia
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 1st Jul 2012 04:45
@BlackFox
Yeah, I'll do that now.

Quote: "I'd like to add these tutorial links to the "General Scripting Information" thread I'm working on so they won't be lost."


That'd be great! It'd be an honor to have one of my thread's mentioned by you!

-TZK

angusm3
15
Years of Service
User Offline
Joined: 6th Mar 2009
Location: Right behind you...
Posted: 1st Jul 2012 23:28
this makes me want to restart the dynamic injury project, thanks for the inspiration zombie killer

http://www.youtube.com/watch?v=AfFa6uPv_8o
I appear to have burst into flames...
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 2nd Jul 2012 04:29
@angusm3
No problem

@All
The next tutorial will most likely be on flakscripts
"The FPSCreator Scripting Guide Part 3: Flakscripts - What Are They and How Do You Use Them?"

-TZK

Login to post a reply

Server time is: 2024-11-24 01:10:24
Your offset time is: 2024-11-24 01:10:24