Editor-ScriptsSimilar to command and mission scripts, the EMERGENCY 4 editor also has an interface for loading scripts. Here, it is possible to perform various functions in the editor.
Editor scripts must be saved in the Data folder to be recognized by EMERGENCY. Therefore, make sure that all changes are made in the editor script folder! This documentation may be incomplete and / or flawed because it is not based on the official script SDK, but was developed by reverse engineering!
Basic StructureThe basic structure of an editor script is similar to that of mission and command scripts:
- object Example : EditorScript
- Example() //constructor
- ~Example() //destructor
- void OnThink() //Is called repeatedly (once per frame?)
- ScriptResult OnPlaceObject(float x, float y, float z) //Invoked when the user places an object
- ScriptResult OnObjectPlaced() //Invoked when the user has placed an object (the mouse button is released after placing)
- OnFloorClicked(float x, float y, float z) //Invoked when the user clicks on the ground
Editor scripts must be saved as "Data/Scripts/Editor/Category/Name.script", with the category and name freely selectable. They are executed in the editor under Scripts → Category → Name.
Specific functions, classes, and enumsIn principle, editor scripts naturally use the same script system, such as command and mission scripts, and can therefore use all elements of the known SDK.
Please note, however, that not everything in the editor is possible, as some functions (e.g. the „PushAction“-functions of the „GameObject“-class) depend on the running game.
Terminate the editor scriptEditor Scripts are not terminated automatically, but via the Process „Process::Kill()“.
Place objectsIt is also possible to create objects with „Game::CreateObject()“, „Game::CreatePerson()“ or „Game::CreateVehicle()“!
To query the currently selected (mouse-hanging) prototypes, you can use the „GetMousePrototype()“ function that returns a pointer of unknown type. This can be stored in a variable of type "void *":
void *mousePrototype = GetMousePrototype();
It is also possible to query object that has not yet been placed with „GetMouseObject()“ . The function returns an "Actor", which can also be converted to a "GameObject":
Actor mouseActor = GetMouseObject();
To place an object, the „PlaceObject(void *prototype_, float x, float.y, float.z, float yaw, float pitch, float roll)“ function is used. For example, an object can be positioned precisely in the center of the map:
PlaceObject(mousePrototype, 0, 0, 0, 0, 0, 0); //Variable is from previous code examples
PlaceObject(GetMousePrototype(), 0, 0, 0, 0, 0, 0); //Short form without variable
550 mal gelesen