In World at War, functions could be written simply by writing the name of the function followed by any parameters you wish the function to have. In Black Ops 3, you simply need to add the "function" keyword before every function declaration you make:
Function parameters have had a small boost in ability since WaW. The main change to function parameters is that you are now able to set a parameter default. That looks like this:
The above code shows that if you where to call upon the variable "myPram" within the "testingFunction" without having declared what myPram is within the function call then it would fall back to its parameter default, of which in this instance is "false".
Now that Namespaces are open to us, we've also been given acces to function scopes. If you don't know what a function scope is then: A function can have a specific scope. Let's say we made a function with a private scope. this would mean we would only be able to use that function within our current .gsc file. If you have a global scope function the you would be able to call it externally ( from another .gsc file ).
As well as being given function scopes with namespaces. We've also now got a way to declare duplicate function names. This means in one namespace we can have a function called "init()" and then in a different namespace we could have the same function name ( "init()" ) because of the namespaces these functions will not confict. Here's an example to better show the system off:
You can include an external script into your current script by doing:
You can then call any function from that script by using the filename as a prefix:
Calling External Functions
Storing Functions in a Variable (pointers)
flag_init(), flag_set, flag(), and flag_clear have been moved to flag_shared
GetStruct() and GetStructArray()
Weapon System (Giving, Getting, Switching, etc)
BO3 now treats weapons as entities instead of just strings. In order to do any weapon operations, you must first initialize a weapon variable from the string name:
Weapon Stats are now stored as fields of the weapon entitiy instead of obtained from engine functions:
The Callbacks System
A much more elegant way of getting your scripts threaded into the level at the right time (preload, post load, post load with specific requirements). You can see a full explanation of this feature on the dedicated page: BO3 | Callbacks System
enable_trigger() & disable_trigger()
These functions have been replaced with:
where passing true will enable the trigger and false will disable it.