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 FPSC Scripting Guide - Master Thread

Author
Message
The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 12th Jan 2013 04:53 Edited at: 15th Jan 2013 01:32
Hi,
a small while ago, I made a bunch of scripting tutorials. They're mostly dead threads now, and I decided to continue making them, and combining them all into this one thread.

These tutorials are based around versions 1.19 and 1.20

Tutorial 1: Introduction and Your First Script

Ok, first off, I'll tell you the basics. Every line of a script starts with a colon ":" followed by conditions, another colon and actions. A condition is basically what it says right out of the tin, a condition. When this condition is met, all the actions after the second colon will happen. For example:

:state=0:coloff,state=1

Would mean, if the entity's state is set to zero, turn off collision and set the state to one. States are basically user defined conditions, here is a list of basic actions and what they do:

ColOff: Collision off
Suspend: Basically disables the entity
LinkToPlr: Makes the entity always be at the player's position, good for player body etc.
FreeFromPlr: Undoes what LinkToPlr does.
ColOn: Collision on
State=X: Change the state of an entity to X.

Those are some basic actions. Throughout this tutorial you will learn a few more. Every action in a script is separated by a comma "," and the same goes for conditions. Here are some basic conditions:

Always: This basically makes all the actions for this line always happen.
Never: Opposite of always
State=X: Makes the actions happen if the entity's current state is X.
KeyPressed=X Y: check whether keycode X is pressed (Y=1) or not pressed (Y=0)
ScanCodeKeyPressed=X: Basically the same as KeyPressed, only you can only check if the button is being pressed, this function is not recommended, just use KeyPressed.
PlrUsingAction=X: Check whether the player is pressing the use key or not (0\1)
MouseState=X: Check whether mouse button X is pressed.

1 = Left Mouse
2 = Right Mouse
3 = Left + Right Mouse
4 = Middle Mouse
5 = Left + Middle Mouse
6 = Right + Middle Mouse
7 = Left + Right + Middle Mouse
8 = Mouse 4
9 = Left + Mouse 4
10 = Right + Mouse 4
11 = Left + Right + Mouse 4
12 = Middle + Mouse 4
13 = Left + Middle + Mouse 4
14 = Right + Middle + Mouse 4
15 = Left + Right + Middle + Mouse 4


So, for example, to check if the entity's state is 5, AND the player is pressing the "T" key (code number 20), and change the state to 6 and then turn off collision if this is true, you would do this:

:state=5,keypressed=20 1:state=6,coloff

To help you out, here is the complete list of scancodes:



To start you off, we'll be making a simple, "middle mouse button to use" script.
Here is a script template, use it to start off all of your scripts:



All of your scripting will go inbetween "Triggers" and "End of Script". To edit and make scripts, you can use either "notepad" or "FPI EditPad", I recommend the latter for newbie scripters. You should also note that any line that has a semicolon ";" ANYWHERE on that line, it will be treated as a comment. Comments are never really needed, but are very handy and make your scripts look cleaner and more attractive.

First off, we'll want to check if the middle mouse button is pressed, so use this for that:

:mousestate=4:

FPI EditPad may give you an error when you use some of the new commands that came with the v1.19 update, this is easy fixed though. Simply download the definitions update by Pyrate Mike

Now we want the player to "use" whatever is in front of them, for this, we'll use the PlrAction command.

PlrAction=X: Forces the player to do one of 11 actions

X = 1 – Fires current weapon,
X = 2 – Zooms current weapon,
X = 3 – Reloads current weapon,
X = 4 – Crouches player,
X = 5 – Jumps players,
X = 6 – Peeks player left,
X = 7 – Peeks player rights,
X = 8 – Forces “Use” key,
X = 9 – Forces left mouse click,
X = 10 - Forces right mouse click,
X = 11 – Jams current weapon of player.

We want to force the "use" key, so we will use the number "8".
So now, your script should look something like this:



Save this as MidMouse_ToUse.fpi in your scriptbank, which is usually located in "C:\Program Files\The Game Creators\FPS Creator\Files\scriptbank", or if you own a 64-bit computer, it will be in "C:\Program Files (x86)\The Game Creators\FPS Creator\Files\scriptbank"

Now simply make a new map and assign this script to the "main" section of a trigger zone, and now the mouse3 button should work just like the use key!
Well done!, you've just made your first script.
If you wish to learn more actions and conditions, I suggest checking out Ched80's Script Syntax List

Tutorial 2: Using Variables

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!

Not really the most amazing example script, as it doesn't really do much, but this is just an example

Tutorial 3: Flakscripts - What Are They and How Do You Use Them?

First off, flakscripts are basically what the name suggests, flak scripts. Ever since the camera functions that came with the v1.19 update, you can do some amazing things with flakscripts. Think of the effect when you snipe someone at long-range in Max Payne, that kind of effect, now before you drool, listen to this: That sniping effect can be done with ONE COMMAND. Sweet eh?

So, for the first part of this tutorial I will tell you how to get a flakscript up and running, and then we'll make a script for your flak. Before following this tutorial make a backup of your "gamecore\flak\modernday\law" folder, since we'll be modifying it, unless you wish to copy it and it's corresponding weapon to their own folders and edit the files to make a separate weapon.

Okay, open up your "gamecore\flak\modernday\law" folder located in your "Files" folder which is located in your FPSCreator directory.

64bit systems: C:\Program Files (x86)\The Game Creators\FPS Creator
32bit systems: C:\Program Files\The Game Creators\FPS Creator

if you have a 32bit system, then you will not have a "Program Files (x86)" folder, so that's just an easy way to find out what type of computer you have.

Now open that file called "flakspec.txt" and add this line to it:

script = flakscripts\sniper_effect.fpi

This defines what script this flak will use, if any script at all. Now we must create this script, open your scriptbank and make a new folder called "flakscripts"
Now open notepad and we'll begin scripting

The command we'll use is
EntityCam -- Attaches the camera to the object

So, after you have your usual script set up, you should have something like this:



Save this as "sniper_effect.fpi" in the "flakscripts" folder you made. Now simply open FPSCreator and give your character the "law" weapon, and fire it, and voila, you will be amazed!

-TZK

Corno_1
14
Years of Service
User Offline
Joined: 3rd Nov 2010
Location:
Posted: 13th Jan 2013 13:22
Hey, this is a great tutorial. Can I get the permission that I add this to my Scripting Tutorial(If I will write this). This is perfect for advanced scripts!!!

Corno_1


The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 15th Jan 2013 01:28
@Corno_1
Sure, go ahead. I don't mind.

-TZK

unfamillia
14
Years of Service
User Offline
Joined: 26th Jul 2010
Location: Preston, Lancashire
Posted: 20th Jan 2013 00:24
@TZK,

I can't quite get the flak camera working properly. I don't know where i am going wrong.

I have the weapon, 'unarmed_1' from MP9 (I use this in my game Impuzzable) I would love to get the camera assigned to the flak, but, i can't quite get it to work. When i shoot, the camera becomes attached to the flak - as it should do - but, then just drops to the floor and smoothly, but, slowly glides along the floor just bouncing off walls, until it gets stuck then stops. I can't get off the flak and it doesn't cause any damage or destroy itself.

Could you point me in the right direction please.

Unfamillia

The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 20th Jan 2013 09:38
@Unfamillia
This was a problem I noticed after I wrote the guide. Flak scripts seem to disable the flak's motion. Try adding ::movefore=100 to the script, we if that works.

-TZK

unfamillia
14
Years of Service
User Offline
Joined: 26th Jul 2010
Location: Preston, Lancashire
Posted: 21st Jan 2013 00:32
I tried to add movefore=100 and it does propel the flak forwards, but, it glides along the floor and doesn't destroy itself when it hits a wall or an entity.

I really wanted this to work as i feel it would be a great addition.

Unfamillia

The Zombie Killer
13
Years of Service
User Offline
Joined: 27th Mar 2011
Location: Gold Coast, Australia
Posted: 21st Jan 2013 01:03
@Unfamillia
Try adding NoGravity as well and I'll see if I can mess around with the ray cast commands for the explosion.

-TZK

s4real
VIP Member
18
Years of Service
User Offline
Joined: 22nd Jul 2006
Location:
Posted: 24th Jan 2013 20:55
EntityCam command not designed to work like this because you going to have physic and collision problems with it connected to a flak, hence the problem with it near the floor.

Flak is not a entity so don't use the same collision's or physics.

A new command in the source needs to be added to get the effect you want.

hope you find a method to do this.

best s4real

Pack ya games with vishnu packer its free. Vishnu game launcher is now released.
Help keep vishnu free by pledging now :- http://vishnu.chipin.com/vishnu

Login to post a reply

Server time is: 2024-11-23 16:57:05
Your offset time is: 2024-11-23 16:57:05