Basic Scripting Here are a few basic guidelines/tips for understanding simple scripting in COD WAW. I have tried to address frequently asked questions and some basic things I have learned. - Where to thread an initial function, call a gsc, or include a gsc - Calling a function vs threading a function - Self - Arrays - Passing variables and level variables
DISCLAIMER at the bottom
Where to thread an initial function or call a gsc The following will be done from your nazi_zombie_mapname.gsc, in your mods/nazi_zombie_mapname/maps/ folder - Thread an intial function - Call another gsc - Include another gsc ___________________________________ Thread an initial function - find, in your nazi_zombie_mapname.gsc, the following: and add your function thread like this: ___________________________________ Call a gsc - You can call another gsc by finding the following and put maps\name_of_your_gsc::name_of_function_to_call(); under it like this: ___________________________________ Include a gsc Note: This will include all functions from your gsc as if they are in this gsc, threadable/callable without the path to it in each line. - Add this at the top of your nazi_zombie_mapname.gsc:
Calling a function vs threading a function: - If you call a function it will wait until the function you call is finished before moving on. - If you thread a function it will continue immediately to the next line in the function you threaded it from.
Note: All Examples can be tested by threading the first function of each, in your nazi_zombie_mapname.gsc
___________________________________ Calling the function: The above code will print "Call the function", wait 5 seconds, then print "I just waited 5 seconds, I will wait 5 more", then wait 5 seconds, and print "Done with the function" ___________________________________ Threading the function: The above code will print "Call the function", then print "I am not waiting, the function is running now", then wait 5 seconds, then print "I just waited 5 seconds, I will wait 5 more", then wait 5 more seconds.
Self - what is it and what does it mean? - When you thread/call a function on an entity you are telling that function that self means me, the entity
Note: in the following code you must have a script_brushmodel or script_model with the kvp> targetname : ent, in radiant
___________________________________ Threading a function on an entity: Read the notes in the functions above to see what the code will do
Arrays- How can I use them with things that have a lot in common? - Arrays are very useful when you have sets of entities with the same action, like doors, and shootable EE's
Note: the following example assumes you have sets of a trigger_damage and a script entity in radiant. Each trigger will have kvps> targetname : shoot, and target : "this will be different for each one". Each script entity will have it's triggers target as it's targetname: "this will be different for each one"
___________________________________ Collecting an array and threading a single function on each Read the notes in the functions above to see what the code will do
Passing variables and level variables - Passing variables can be useful in many situations. The example below simply passes the size of the array (the number of entities with that targetname). You can also pass entities (not shown). Passing variables and entities is a great way to make one function serve the purpose, where many would be used/needed otherwise. Level variables are a way to keep track of things between functions, even after a function has ran.
Note - Use the entities and triggers from the Array example above.
___________________________________ Passing variables and level variables Read the notes in the functions above to see what the code will do
DISCLAIMER I am not a programmer by profession. These are simple guidelines I follow from my experiences writing scripts for this game, for fun. There are no practical uses for the functions above other than examples. Corrections are welcome.
Last Edit: June 05, 2015, 03:51:21 pm by MakeCents