Assigning entity names
Versions: You must be logged in to view history.
Learn how to assign entity names.
We are not going to do anything complicated in this lesson
This is hopefully going to help you understand the assigning of entity names in a script
To illustrate this - let us imagine we have a map created in which the player has just reached a door
We want the door to open automatically and on the other side of the door is an enemy guy with a shotgun
In the map...
We will use a nyc bot so put in the map worldpawn...
key=ainame
value=tsr1
Instead of this you can put the ainame into the map title - calling the map something like...
coop_downtown_ger3.bsp
or...
Frozen_sib1.bsp
etc
The enemy guy is set to be "trigger_spawned" in his entity properties box. He has a targetname of "guy1"
We also have the door - in the map we have given it a targetname of "doorX"
In front of the door we have a trigger_once which is pointed / targetted at a script_runner
In the properties of the script runner, we have to tell it what script we are using - for the moment let us put
script = door/guy1
We can compile the map now...
-------------------------------------------------
All scripts for any map should be in a folder in user/ds or base/ds. A script runner will always "look" in the ds folder for it's scripts
Because we have pointed the script_runner in the map to door/guy1, we need a folder called user/ds/door to put our script in
When we make our script in Notepad, we will save it as guy1.ds and compile it into guy1.os and put it in the user/ds/door folder
--------------------------------------------------
OK - we are ready to make a simple script to carry out our desired actions
Use the blank script as described in Lesson 1
So - we already have the first 2 lines in our script which are...
#include "../common/header.ds"
output "C://sample/ds/test"
These lines will be present in all scripts unless you change the name of your output folder
Each script is split into 3 sections after this -
1.Declaration of variables (entities)
2.Assigning variables
3.Script proper (= animation bit)
Now - what do these mean?
Section 1 - Declaring - we are making up names for the entities to use IN THE SCRIPT - ie NOT IN THE MAP
For example - We have 2 entities that we want to manipulate - the guy and the door
In this script we only use what is called a "Local" entity (explained later)
For the script only - we will call him punk1 (remember in the map this has targetname of "guy1")
Also for the script we will call the door simply - "door" (remember in the map this has targetname of "doorX"
The names are given to make the script easier to understand - some scripts are very long and complicated
Even if you have targetnames in the MAP such as t1234 etc - these can be called more meaningful names for the script
The script looks like this now....
#include "../common/header.ds"
output "C://sample/ds/test"
local entity punk1
local entity door
So the script knows now that we have 2 items to manipulate - 2 "local entities"
We now have to tell the script what these entities are in the map. This is the assigning bit....
punk1 = find entity with targetname "guy1"
door = find entity with targetname "doorX"
Now - every time we refer to punk1 or door in our script - it (the script) will know that we are talking about the guy1 and doorX in the map
Now for some scripting proper...
Use entity punk1
This is the simplest command and can be used to "fire" anything in the map. Because we have "used" an enemy entity that is trigger_spawned - he appears in the map now - As soon as the trigger_once in the map is touched, the enemy bot will appear behind the door
Next line....
use entity door
This triggers the door the same as if it had been triggered by a button etc so the door just opens. Let us add a simple "wait" command between the guy appearing and the door opening - only 2 seconds or so. The line would be
wait 2 seconds
So far our complete script looks like this...
--------------------------------------------------
#include "../common/header.ds"
output "C://sample/ds/test"
local entity punk1
local entity door
punk1 = find entity with targetname "guy1"
door = find entity with targetname "doorX"
use entity punk1
wait 2 seconds
use entity door
--------------------------------------------------
We can save this now as guy1.ds and compile it - put it in the ds/door folder and run the map....
Try it...
You will notice that the door opens and the guy just stands there - this is because he is "tied" to the script and is waiting for another command- we need to "release" him to go about his business (of killing you)
So we use a special command that will be explained in more detail later
For now just add the line...
animate entity punk1 performing action SCRIPT_RELEASE
Since this script is only used once in the map - we can "exit" the script now with the simple command...
exit
So our completed script is now...
----------------------------------------------------------
#include "../common/header.ds"
output "C://sample/ds/test"
local entity punk1
local entity door
punk1 = find entity with targetname "guy1"
door = find entity with targetname "doorX"
use entity punk1
wait 2 seconds
use entity door
animate entity punk1 performing action SCRIPT_RELEASE
exit
---------------------------------------------------------
Compile this and replace the script in the ds/door folder and run the map again
After a 2 second delay, the door will open and the guy will be on the other side and will immediately attack you
Notice the beauty of scripting here - you can change things and try many different scripts without changing the map at all - you only need to alter the script and reload the same map. Also - many maps can point a script runner to the same script - ie you only need 1 script to try the same effect in many maps
Try making a script that triggers 4 guys - don't worry about making many doors
If you have understood things so far it should now be easy for you to trigger events with time delays etc
Maybe you would like to trigger a sound then open a door and 5 enemy run in a room and start shooting....etc etc etc
Many things are possible with just these basic commands
To understand better, look at some of the declare/assign sections of tsr1 scripts (included in SoFSDK/sample/ds/tsr1 folder)
Try to follow through some of the scripts and figure out what they do
You - like me - will find many commands to try and copy/paste into your own scripts
Indeed - understanding just the script runners can add to your maps
You may find - for example - a script in sof that makes a thunder sound
All you need is the pathname to the script
You do not need to know how the script is written to use it
In your map you would only need to trigger the same script with a trigger + script runner and Voila! Thunder in your map...
Hope this helps...
Demise RDAM
|
|
mp_TempleCall of Duty: Mods: Multiplayer (624.12Kb)
|