Editor-Scripts (EM4)

Wir verwenden Cookies, um Inhalte und Anzeigen zu personalisieren, Dienste bereitzustellen und die Zugriffe auf unsere Website zu analysieren. Außerdem werden durch unsere Partner Informationen zu Ihrer Nutzung für soziale Medien, Werbung und Analysen erfasst. Weitere Informationen

  • Information about editor scripts for EMERGENCY 4.


    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!

    Basic Structure

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


    1. object Example : EditorScript
    2. {
    3. Example() //constructor
    4. {
    5. }
    6. ~Example() //destructor
    7. {
    8. }
    9. void OnThink() //Is called repeatedly (once per frame?)
    10. {
    11. }
    12. ScriptResult OnPlaceObject(float x, float y, float z) //Invoked when the user places an object
    13. {
    14. }
    15. ScriptResult OnObjectPlaced() //Invoked when the user has placed an object (the mouse button is released after placing)
    16. {
    17. }
    18. OnFloorClicked(float x, float y, float z) //Invoked when the user clicks on the ground
    19. {
    20. }
    21. };
    Alles anzeigen
    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.

    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.

    Terminate the editor script

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

    An example:


    1. object DeleteVehicles : EditorScript
    2. {
    3. void OnThink()
    4. {
    5. GameObjectList l(TYPE_VEHICLE);
    6. for(int i = 0; i < l.GetNumObjects(); i++)
    7. Game::RemoveGameObject(l.GetObject(i));
    8. Process::Kill();
    9. }
    10. };
    Process::Kill()“ prevents the script from running in the background and deletes it immediately when a new vehicle is set.

    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

    218 mal gelesen