Game Modding | Call of Duty: Black Ops 3 | Scripting
Abnormal202:
ABNORMAL202 SCRIPTING TUTORIAL 5: SCRIPT-RADIANT RELATION
See ALL Tutorials
DESCRIPTION
We've done a lot of talking about script theory, but how can we actually apply this to our maps? There are a lot of cool tricks as well as simple essentials to know about how we can use radiant and our GSC together.
KVPS
You've no doubt heard of or used KVPs before, for example for making zombie_door's or setting up your zones. A KVP is a very simple but very powerful tool. It's simply two peices of data paired together: a key and a value.
These can be set in radiant on pretty much everything. You can access an entity's KVPs by pressing "n" while having it selected.
It should be noted that if you want to use a model in script, in radiant it should be a script_model, and if you want to use a brushmodel in script, in radiant it should be a script_brushmodel.
When you make something a script_model or script_brushmodel, you'll notice it already starts out with some KVPs:
We can access these KVP's in script. But first we must grab the entity in script.
The most common way to grab an entity in script is to give it a custom value for the targetname (in radiant) and then use GetEnt() (in script):
there are other keys that also work with GetEnt, such as script_noteworthy, target, classname, or script_string. Not all keys work with GetEnt() however. But that doesn't mean we can't use our custom keys in script.
PROPERTIES
When we get an entity from radiant in script, it stores all the values on that entity into properties based on the keys of the KVPs it has. For example, if I set a custom KVP in radiant such as:
the value is stored just like this, automatically in script:
this is great for If Statements. We could use it like this:
or another common usage, storing vectors:
ORIGINS/ANGLES
All entities start out with an origin key and angles key. While they aren't particularly special, they are used quite a lot so I wanted to make a quick section about them.
The origin is the XYZ coordinates of where the entity's origin is located in the map. You'll notice as you move the object in radiant, the value for origin changes automatically in the KVPs.
it's important to note it is specifically the entity's origin. You can see each entity's origin as a hollow blue cube in the 3D view:
For the most part, the origin is located somewhere in the middle of the object, or where it would touch the ground.
The angles are the Roll, Pitch, and Yaw rotation of the entity that will change as you rotate the entity.
the roll changes as you rotate around the X-Axis, the pitch if you rotate around the Y-Axis, and the Yaw if you rotate around the Z-Axis.
Knowing the object's angles/origin is often important for using functions such as:
which are very commonly used.
RADIANT'S AUTO-TARGETING SYSTEM
You may have noticed in making zombie_doors that you can have certain entities "target" other entities, by giving the targeting entity the key "target" with the value of that key being the targetname of the entity being targeted.
As you can see, when an entity is targeting another, a red line appears between the two with the arrow pointing towards the entity being targeted.
this makes accessing the targeted entity simple in script if you already have the targeting entity:
notice I only typed in one actual targetname, "dead_soldier". The other targetname was gathered through using the target of the other entity.
This brings me to Radiant's automatic targeting system. If you select two entities then press "w" it will make the first entity target the second, assigning an auto-targetname for the targeted entity that looks like this:
the number will change each time you do it, so no two entities using the auto-target system share the same targetname.
Other things to note: