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

  • Example script for the realization of a signal in EMERGENCY 4.

    Signal-Script

    The signal script is used to control the signal from emergency vehicles. For this purpose every emergency vehicle has assigned a control button and a sound file via a script.

    Necessary adjustments

    In order to get the script working, some changes to the respective script files must be performed manually. In the following lines, the paths of the prototype to the vehicles must be specified. For each vehicle its own sound file is played.

    Source Code

    1. // Here specify the paths of your vehicles!
    2. const char PROTO_FF_RW[] = "mod:Prototypes/Vehicles/Fire Department/rw.e4p";
    3. const char PROTO_FF_TLF[] = "mod:Prototypes/Vehicles/Fire Department/tlf.e4p";
    4. const char PROTO_FF_DLK[] = "mod:Prototypes/Vehicles/Fire Department/dlk.e4p";


    In the following lines, the strings above ("PROTO_XX_XXX") must be entered. Also the paths to the respective sound files are defined here.

    Source Code

    1. // Here the stringID of the above used name should be set. In my case PROTO_FF_RW!
    2. if (StrCompare(v.GetPrototypeFileName(), PROTO_FF_RW) == 0)
    3. {
    4. // Here you must enter a valid link to a Siren Sound, in 'mono' coded!
    5. soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/tatuetata_rw_loop.wav", CarPos, true);
    6. }
    7. if (StrCompare(v.GetPrototypeFileName(), PROTO_FF_TLF) == 0)
    8. {
    9. // Here you must enter a valid link to a Siren Sound, in 'mono' coded!
    10. soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/tatuetata_tlf_loop.wav", CarPos, true);
    11. }
    12. if (StrCompare(v.GetPrototypeFileName(), PROTO_FF_DLK) == 0)
    13. {
    14. // Here you must enter a valid link to a Siren Sound, in 'mono' coded!
    15. soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/tatuetata_dlk_loop.wav", CarPos, true);
    Display All


    Script

    The script is offered as a download, as well as a code directly from this page. (sosi.rar)

    Includes: - Continuous signal ccript - all necessary dummies.

    Features: - Players can enable and disable signal manually - Continuous signal goes off automatically when the vehicle has arrived or begins to extinguish / install itself (DLK).

    Fixes in V.2.0: - Continuous signal ends when a vehicle is driven to the base - Continuous signal ends when a vehicle has been sent directly from the base to a certain point.

    Explanations of the script: I'm sorry, but the fact that some problems have set, I am no longer able to explain the script amateur justice - it has become rather complicated. However, for direct questions I am able to help.

    Source Code

    1. //**************************************************************************************************
    2. // #Version 2.0# ****
    3. // ****
    4. // Includes: all Sirens ****
    5. // ****
    6. // 1.0| VCmdSiren ****
    7. // 1.1| DUMMYUpdatePos ****
    8. // 1.2| DUMMYDisableSiren ****
    9. // 1.3| DUMMYFindPath ****
    10. // 1.4| DUMMYHasSiren ****
    11. // ****
    12. // childID 1 for disabling bluelights. ****
    13. // ****
    14. // ****
    15. // **************************************************************************************************
    16. // Here you can specify the name of an icon for the button bar.
    17. // Automatically taken from the folders UI/Game/Icons/Command/ and UI/Game/icons/cursors.
    18. const char IMG[] = "horn";
    19. const char EACTION_FINDPATH[] = "EActionFindPath";
    20. const char DUMMY_HASSIREN[] = "DUMMYHasSiren";
    21. const char DUMMY_UPDATEPOS[] = "DUMMYUpdatePos";
    22. const char DUMMY_FINDPATH[] = "DUMMYFindPath";
    23. const char CMD_MOVETO[] = "MoveTo";
    24. const char NAME_DUMMYOBJECT[] = "HelpingObjekt_Roger";
    25. const char PROTO_BFW_LF[] = "mod:Prototypes/Vehicles/Fire Department/gtf.e4p";
    26. const char PROTO_BFW_TLF[] = "mod:Prototypes/Vehicles/Fire Department/tlf.e4p";
    27. int DummyGroup = 20;
    28. // 01.0
    29. object VCmdSiren : CommandScript
    30. {
    31. VCmdSiren()
    32. {
    33. SetIcon(IMG);
    34. SetCursor(IMG);
    35. SetRestrictions(RESTRICT_SELFEXECUTE);
    36. }
    37. bool CheckPossible(GameObject *Caller)
    38. {
    39. if (!Caller->IsValid())
    40. return false;
    41. if (Caller->GetType() == ACTOR_VEHICLE)
    42. {
    43. return true;
    44. }
    45. return false;
    46. }
    47. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
    48. {
    49. if (!Target->IsValid() || Target->GetID() != Caller->GetID())
    50. return false;
    51. if (!Caller->HasCommand(CMD_MOVETO) || Caller->GetType() != ACTOR_VEHICLE)
    52. return false;
    53. return true;
    54. }
    55. void PushActions(GameObject *Caller, Actor *Target, int childID)
    56. {
    57. Vehicle v(Caller);
    58. if (!v.HasCommand(DUMMY_HASSIREN) && (childID != 2 && childID != 1))
    59. {
    60. int soundID;
    61. v.EnableBlueLights(true);
    62. Vector CarPos = v.GetPosition();
    63. // Here, enter the const char name from above as in the two examples below.
    64. if (StrCompare(v.GetPrototypeFileName(), PROTO_BFW_LF) == 0)
    65. {
    66. // Here the path of the sound file must be available.
    67. soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/feuerwehr1_loop.wav", CarPos, true);
    68. }
    69. if (StrCompare(v.GetPrototypeFileName(), PROTO_BFW_TLF) == 0)
    70. {
    71. soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/feuerwehr2_loop.wav", CarPos, true);
    72. }
    73. GameObject mDummy = Game::CreateObject("mod:Prototypes/Objects/Misc/empty.e4p", NAME_DUMMYOBJECT);
    74. mDummy.Hide();
    75. mDummy.SetPosition(CarPos);
    76. mDummy.SetUserData(soundID);
    77. mDummy.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_UPDATEPOS, &v, soundID, false);
    78. v.SetUserData(soundID);
    79. v.AssignCommand(DUMMY_HASSIREN);
    80. return;
    81. }
    82. if (v.HasCommand(DUMMY_HASSIREN))
    83. {
    84. if (childID == 1)
    85. {
    86. v.EnableBlueLights(false);
    87. }
    88. if (v.HasCommand(DUMMY_HASSIREN))
    89. {
    90. int ref = Caller->GetUserData();
    91. Audio::StopSample(ref);
    92. GameObjectList list = Game::GetGameObjects(NAME_DUMMYOBJECT);
    93. for(int i=0; i<list.GetNumObjects(); i++)
    94. {
    95. GameObject *obj = list.GetObject(i);
    96. if (obj->GetUserData() == ref)
    97. {
    98. int mSirTest = i;
    99. GameObject *obj = list.GetObject(mSirTest);
    100. obj->PushActionDeleteOwner(ACTION_NEWLIST);
    101. v.RemoveCommand(DUMMY_HASSIREN);
    102. }
    103. }
    104. }
    105. return;
    106. }
    107. }
    108. };
    109. // 01.1
    110. object DUMMYUpdatePos : CommandScript
    111. {
    112. DUMMYUpdatePos()
    113. {
    114. SetGroupID(DummyGroup);
    115. }
    116. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
    117. {
    118. }
    119. void PushActions(GameObject *Caller, Actor *Target, int childID)
    120. {
    121. Vehicle v(Target);
    122. GameObject mDummy(Caller);
    123. Vector CarPos = v.GetPosition();
    124. if (v.IsDestroyed() || !v.IsValid())
    125. {
    126. int ref = mDummy.GetUserData();
    127. Audio::StopSample(ref);
    128. mDummy.PushActionDeleteOwner(ACTION_NEWLIST);
    129. } else
    130. {
    131. mDummy.SetPosition(CarPos);
    132. Audio::UpdatePos(childID, CarPos, true);
    133. if (v.IsCurrentAction(EACTION_FINDPATH))
    134. {
    135. if (!v.HasCommand(DUMMY_FINDPATH))
    136. {
    137. v.AssignCommand(DUMMY_FINDPATH);
    138. }
    139. }
    140. mDummy.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_UPDATEPOS, Target, childID, false);
    141. }
    142. if (v.HasCommand(DUMMY_FINDPATH))
    143. {
    144. if (!v.IsCurrentAction(EACTION_FINDPATH) && v.GetNumActions() == 0)
    145. {
    146. v.RemoveCommand(DUMMY_HASSIREN);
    147. v.RemoveCommand(DUMMY_FINDPATH);
    148. int ref = Caller->GetUserData();
    149. Audio::StopSample(ref);
    150. GameObjectList list = Game::GetGameObjects(NAME_DUMMYOBJECT);
    151. for(int i = 0; i < list.GetNumObjects(); i++)
    152. {
    153. GameObject *obj = list.GetObject(i);
    154. if (obj->GetUserData() == ref)
    155. {
    156. int mSirTest = i;
    157. GameObject *obj = list.GetObject(mSirTest);
    158. obj->PushActionDeleteOwner(ACTION_NEWLIST);
    159. v.RemoveCommand(DUMMY_HASSIREN);
    160. if (v.HasCommand(DUMMY_FINDPATH))
    161. {
    162. v.RemoveCommand(DUMMY_FINDPATH);
    163. }
    164. }
    165. }
    166. }
    167. }
    168. }
    169. };
    170. // 01.2
    171. object DUMMYDisableSiren : CommandScript
    172. {
    173. DUMMYDisableSiren()
    174. {
    175. SetGroupID(DummyGroup);
    176. }
    177. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
    178. {
    179. }
    180. void PushActions(GameObject *Caller, Actor *Target, int childID)
    181. {
    182. Vehicle v(Caller);
    183. if (childID == 1)
    184. {
    185. v.EnableBlueLights(false);
    186. }
    187. int ref = Caller->GetUserData();
    188. Audio::StopSample(ref);
    189. GameObjectList list = Game::GetGameObjects(NAME_DUMMYOBJECT);
    190. for(int i = 0; i < list.GetNumObjects(); i++)
    191. {
    192. GameObject *obj = list.GetObject(i);
    193. if (obj->GetUserData() == ref)
    194. {
    195. int mSirTest = i;
    196. GameObject *obj = list.GetObject(mSirTest);
    197. obj->PushActionDeleteOwner(ACTION_NEWLIST);
    198. v.RemoveCommand(DUMMY_HASSIREN);
    199. if (v.HasCommand(DUMMY_FINDPATH))
    200. {
    201. v.RemoveCommand(DUMMY_FINDPATH);
    202. }
    203. }
    204. }
    205. }
    206. };
    207. // 01.3
    208. object DUMMYFindPath : CommandScript
    209. {
    210. DUMMYFindPath()
    211. {
    212. SetGroupID(DummyGroup);
    213. }
    214. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
    215. {
    216. return false;
    217. }
    218. void PushActions(GameObject *Caller, Actor *Target, int childID)
    219. {
    220. }
    221. };
    222. // 01.4
    223. object DUMMYHasSiren : CommandScript
    224. {
    225. DUMMYHasSiren()
    226. {
    227. SetGroupID(DummyGroup);
    228. }
    229. bool CheckGroupVisibility(GameObject *Caller)
    230. {
    231. return false;
    232. }
    233. bool CheckPossible(GameObject *Caller)
    234. {
    235. return false;
    236. }
    237. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
    238. {
    239. return false;
    240. }
    241. void PushActions(GameObject *Caller, Actor *Target, int childID)
    242. {
    243. }
    244. };
    Display All


    Adaptation to other scripts

    To disable the signal automatically, we need a small piece of code in each script the following list:
    • Cool.script
    • Deinstall.script
    • Emptycar.script
    • Extinguish.script
    • GoHome.script
    • Install.script
    • Move.script
    For correct function, the code must be within the "void Push Action (GameObject * Caller, Actor * Target, int childID)" - but possibly at the end!

    The code must be as follows:

    Source Code

    1. if (Caller->GetType() == ACTOR_VEHICLE)
    2. {
    3. Vehicle v(Caller);
    4. v.PushActionExecuteCommand(ACTION_APPEND, "VCmdSiren", Caller, 2, false);
    5. }

    Below an explanation of each function:

    Vehicle v(Caller); - Transfers the caller, so the performing part of the script is a vehicle v (v = the "Name").
    PushActionExecuteCommand - Executes a command in order.
    ACTION_APPEND - The specification of the order (here ACTION_APPEND for the inserting to the end of the existing list).
    VCmdSiren - The name of the performing comands.
    Caller - Here, the target for the executed command is passed, in this case, the caller itself.
    2 - Is a so-called child ID, here there are 2 options!
    1 → The vehicle turns off the signal the blue lights are turned off.
    2 → The vehicle runs the blue lights.
    false - Specifies whether to be tested in the executed command if the command is possible (we in this case dont care, so false for "no").

    Alternatively, the modified source files are also available for download. In addition, there is subsequently a revised sample script.

    Example script: „deinstall.script“

    Source Code

    1. object Deinstall: CommandScript
    2. {
    3. Deinstall()
    4. {
    5. SetValidTargets(ACTOR_VEHICLE);
    6. SetGroupID(CGROUP_INSTALL);
    7. SetRestrictions(RESTRICT_SELFEXECUTE);
    8. }
    9. bool CheckGroupVisibility(GameObject *Caller)
    10. {
    11. if(!Caller->IsValid() || Caller->GetType() != ACTOR_VEHICLE)
    12. return false;
    13. Vehicle v(Caller);
    14. return v.IsInstalled();
    15. }
    16. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
    17. {
    18. if(!Caller->IsValid() || !Target->IsValid() || Caller->GetID() != Target->GetID() || Caller->GetType() != ACTOR_VEHICLE)
    19. return false;
    20. Vehicle v(Caller);
    21. if (!v.IsInstalled() || v.IsUplifted() || v.IsUplifting() || !v.IsBasketEmpty())
    22. return false;
    23. return true;
    24. }
    25. void PushActions(GameObject *Caller, Actor *Target, int childID)
    26. {
    27. Caller->PushActionDeinstall(ACTION_NEWLIST);
    28. if (Caller->GetType() == ACTOR_VEHICLE)
    29. {
    30. Vehicle v(Caller);
    31. v.PushActionExecuteCommand(ACTION_APPEND, "VCmdSiren", Caller, 2, false);
    32. }
    33. }
    34. };
    Display All


    Troubleshooting

    If error messages and problems occur, the author of the script can be contacted. For this, a detailed description of the fault and, optimally, a log file is to be added.

    Author: Bass-ti
    Contact: Bass-ti@ddr-mod.de
    Script name: SoSi.script
    Script version: V.2.0 Datum: 24.04.2006
    Note: This script uses a DUMMY-Command which normally should not see as a player. To hide it, it is necessary that the hazard lights script is used.

    3,675 times viewed