Editor-Scripts (EM4)

Information: The EMERGENCY community board is completely free and is financed by advertisement. Please deactivate adblocker if you use this site. Thank you!
Note about the webdisk: Downloading larger files is possible broken. Our Service-Provider is still working on the problem.
  • Information about editor scripts for EMERGENCY 4.

    1 Editor-Scripts

    Similar 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!

    1.1 Basic Structure

    The basic structure of an editor script is similar to that of mission and command scripts:

    An object, which is derived from the class Editor Script and in this case is called "Example", whereby the name is of course freely selectable. However, it does not have to be unique, the script is identified by its file path. The example shows all definable functions, but of course not all have to be defined.

    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.

    1.2 Specific functions, classes, and enums

    In 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.

    1.2.1 Terminate the editor script

    Editor Scripts are not terminated automatically, but via the Process „Process::Kill()“.

    An example:

    object DeleteVehicles : EditorScript
    	void OnThink()
    		GameObjectList l(TYPE_VEHICLE);
    		for(int i = 0; i < l.GetNumObjects(); i++)

    Process::Kill()“ prevents the script from running in the background and deletes it immediately when a new vehicle is set.

    1.2.2 Place objects

    It 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();
    GameObject mouseObject(&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