Mission-Counter-Script (EM4)

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

Information: The EMERGENCY community board is completely free and is financed by advertisement. Please deactivate adblocker if you use this site. Thank you!

  • Sample script to use the mission counter in EMERGENCY 4.

    Table Of Contents

    Mission-Counter-Script

    This script is an example of application of the counter in missions. With counters you can query certain parameters, so that a predefined event occurs. Thus, for example, missions can be declared as won or lost.

    In this sample script all the injured have to be removed and all fires have to be extinguished, so that the mission is set as won.

    Source Code

    1. // This script can be freely used if this comment is included.
    2. // Missionsscript by rusticus und Bass-ti
    3. // Idea by HH-EM4
    4. const char OBJECTIVE_A[] = "Extinguish all fires!";
    5. const char OBJECTIVE_B[] = "Bring all injured and dead persons to the hospital!";
    6. object Mission01 : MissionScript
    7. {
    8. Mission01()
    9. {}
    10. ~Mission01()
    11. {}
    12. void Start()
    13. {
    14. Mission::AddObjective(OBJECTIVE_A);
    15. Mission::SetObjectiveAccomplished(OBJECTIVE_A, false);
    16. Mission::AddObjective(OBJECTIVE_B);
    17. Mission::SetObjectiveAccomplished(OBJECTIVE_B, false);
    18. }
    19. MissionState GetMissionState()
    20. {
    21. if (Mission::GetCounter("Burning Objects") + Mission::GetCounter("Burning Houses") == 0)
    22. {
    23. if (!Mission::IsObjectiveAccomplished(OBJECTIVE_A))
    24. {
    25. Mission::SetObjectiveAccomplished(OBJECTIVE_A, true);
    26. } else
    27. {
    28. Mission::SetObjectiveAccomplished(OBJECTIVE_A, false);
    29. }
    30. }
    31. if (Mission::GetCounter("Injured Persons") + Mission::GetCounter("Dead Persons") == 0)
    32. {
    33. if (!Mission::IsObjectiveAccomplished(OBJECTIVE_B))
    34. {
    35. Mission::SetObjectiveAccomplished(OBJECTIVE_B, true);
    36. } else
    37. {
    38. Mission::SetObjectiveAccomplished(OBJECTIVE_B, false);
    39. }
    40. if (Mission::IsObjectiveAccomplished(OBJECTIVE_A) && Mission::IsObjectiveAccomplished(OBJECTIVE_B))
    41. return MISSION_SUCCEEDED;
    42. return MISSION_RUNNING;
    43. }
    44. };
    Display All

    701 times viewed