Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.76 KB | None | 0 0
  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.  
  17. // Hier kann man den Namen eines Icons f�r die Commandleiste angeben.
  18. // Wird automatisch aus den Ordnern UI/Game/Icons/Command/ und UI/Game/Icons/Cursor genommen.
  19. const char IMG[] = "sosi";
  20.  
  21. const char EACTION_FINDPATH[] = "EActionFindPath";
  22.  
  23. const char DUMMY_HASSIREN[] = "DUMMYHasSiren";
  24. const char DUMMY_UPDATEPOS[] = "DUMMYUpdatePos";
  25. const char DUMMY_FINDPATH[] = "DUMMYFindPath";
  26.  
  27. const char CMD_MOVETO[] = "MoveTo";
  28.  
  29. const char NAME_DUMMYOBJECT[] = "HelpingObjekt_Roger";
  30.  
  31. // Hier die Pfade von Ihren Fahrzeugen angeben!
  32. const char PROTO_RW[] = "mod:Prototypes/Vehicles/Fire Department/rw.e4p";
  33.  
  34. int DummyGroup = 20;
  35.  
  36. // 01.0
  37. object VCmdSiren : CommandScript
  38. {
  39. VCmdSiren()
  40. {
  41. SetIcon(IMG);
  42. SetCursor(IMG);
  43. SetRestrictions(RESTRICT_SELFEXECUTE);
  44. }
  45.  
  46. bool CheckPossible(GameObject *Caller)
  47. {
  48. if (!Caller->IsValid())
  49. return false;
  50.  
  51. if (Caller->GetType() == ACTOR_VEHICLE)
  52. {
  53. return true;
  54. }
  55.  
  56. return false;
  57. }
  58.  
  59. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  60. {
  61. if (!Target->IsValid() || Target->GetID() != Caller->GetID())
  62. return false;
  63.  
  64. if (!Caller->HasCommand(CMD_MOVETO) || Caller->GetType() != ACTOR_VEHICLE)
  65. return false;
  66.  
  67. return true;
  68. }
  69.  
  70. void PushActions(GameObject *Caller, Actor *Target, int childID)
  71. {
  72. Vehicle v(Caller);
  73. if (!v.HasCommand(DUMMY_HASSIREN) && (childID != 2 && childID != 1))
  74. {
  75.  
  76. int soundID;
  77. v.EnableBlueLights(true);
  78. Vector CarPos = v.GetPosition();
  79.  
  80. // Hier die const char Namen von oben eintragen wie in den beiden Beispielen unten.
  81. if (StrCompare(v.GetPrototypeFileName(), PROTO_RW) == 0)
  82. {
  83. // Hier muss ein valider Link zu einem Sirensound stehen, in 'mono' codiert!
  84. soundID = Audio::PlaySample3D("mod:Audio/FX/Sirens/Emsiren01.wav", CarPos, true);
  85. }
  86.  
  87. GameObject mDummy = Game::CreateObject("mod:Prototypes/Objects/Misc/empty.e4p", NAME_DUMMYOBJECT);
  88.  
  89. mDummy.Hide();
  90. mDummy.SetPosition(CarPos);
  91. mDummy.SetUserData(soundID);
  92. mDummy.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_UPDATEPOS, &v, soundID, false);
  93. v.SetUserData(soundID);
  94. v.AssignCommand(DUMMY_HASSIREN);
  95.  
  96. return;
  97. }
  98.  
  99. if (v.HasCommand(DUMMY_HASSIREN))
  100. {
  101. if (childID == 1)
  102. {
  103. v.EnableBlueLights(false);
  104. }
  105.  
  106. if (v.HasCommand(DUMMY_HASSIREN))
  107. {
  108. int ref = Caller->GetUserData();
  109. Audio::StopSample(ref);
  110.  
  111. GameObjectList list = Game::GetGameObjects(NAME_DUMMYOBJECT);
  112. for(int i=0; i<list.GetNumObjects(); i++)
  113. {
  114. GameObject *obj = list.GetObject(i);
  115. if (obj->GetUserData() == ref)
  116. {
  117. int mSirTest = i;
  118. }
  119. }
  120.  
  121. GameObject *obj = list.GetObject(mSirTest);
  122. obj->PushActionDeleteOwner(ACTION_NEWLIST);
  123. v.RemoveCommand(DUMMY_HASSIREN);
  124. }
  125.  
  126. return;
  127. }
  128. }
  129. };
  130.  
  131. // 01.1
  132. object DUMMYUpdatePos : CommandScript
  133. {
  134. DUMMYUpdatePos()
  135. {
  136. SetGroupID(DummyGroup);
  137. }
  138.  
  139. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  140. {
  141. }
  142.  
  143. void PushActions(GameObject *Caller, Actor *Target, int childID)
  144. {
  145. Vehicle v(Target);
  146. GameObject mDummy(Caller);
  147. Vector CarPos = v.GetPosition();
  148.  
  149. if (v.IsDestroyed() || !v.IsValid())
  150. {
  151. int ref = mDummy.GetUserData();
  152. Audio::StopSample(ref);
  153.  
  154. mDummy.PushActionDeleteOwner(ACTION_NEWLIST);
  155. } else
  156. {
  157. mDummy.SetPosition(CarPos);
  158. Audio::UpdatePos(childID, CarPos, true);
  159. if (v.IsCurrentAction(EACTION_FINDPATH))
  160. {
  161. if (!v.HasCommand(DUMMY_FINDPATH))
  162. {
  163. v.AssignCommand(DUMMY_FINDPATH);
  164. }
  165. }
  166. mDummy.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_UPDATEPOS, Target, childID, false);
  167. }
  168.  
  169. if (v.HasCommand(DUMMY_FINDPATH))
  170. {
  171. if (!v.IsCurrentAction(EACTION_FINDPATH) && v.GetNumActions() == 0)
  172. {
  173. v.RemoveCommand(DUMMY_HASSIREN);
  174. v.RemoveCommand(DUMMY_FINDPATH);
  175.  
  176. int ref = Caller->GetUserData();
  177. Audio::StopSample(ref);
  178.  
  179. GameObjectList list = Game::GetGameObjects(NAME_DUMMYOBJECT);
  180. for(int i = 0; i < list.GetNumObjects(); i++)
  181. {
  182. GameObject *obj = list.GetObject(i);
  183. if (obj->GetUserData() == ref)
  184. {
  185. int mSirTest = i;
  186.  
  187. GameObject *obj = list.GetObject(mSirTest);
  188. obj->PushActionDeleteOwner(ACTION_NEWLIST);
  189. v.RemoveCommand(DUMMY_HASSIREN);
  190. if (v.HasCommand(DUMMY_FINDPATH))
  191. {
  192. v.RemoveCommand(DUMMY_FINDPATH);
  193. }
  194. }
  195. }
  196. }
  197. }
  198. }
  199. };
  200.  
  201. // 01.2
  202. object DUMMYDisableSiren : CommandScript
  203. {
  204. DUMMYDisableSiren()
  205. {
  206. SetGroupID(DummyGroup);
  207. }
  208.  
  209. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  210. {
  211. }
  212.  
  213. void PushActions(GameObject *Caller, Actor *Target, int childID)
  214. {
  215. Vehicle v(Caller);
  216.  
  217. if (childID == 1)
  218. {
  219. v.EnableBlueLights(false);
  220. }
  221.  
  222. int ref = Caller->GetUserData();
  223. Audio::StopSample(ref);
  224.  
  225. GameObjectList list = Game::GetGameObjects(NAME_DUMMYOBJECT);
  226. for(int i = 0; i < list.GetNumObjects(); i++)
  227. {
  228. GameObject *obj = list.GetObject(i);
  229. if (obj->GetUserData() == ref)
  230. {
  231. int mSirTest = i;
  232.  
  233. GameObject *obj = list.GetObject(mSirTest);
  234. obj->PushActionDeleteOwner(ACTION_NEWLIST);
  235. v.RemoveCommand(DUMMY_HASSIREN);
  236. if (v.HasCommand(DUMMY_FINDPATH))
  237. {
  238. v.RemoveCommand(DUMMY_FINDPATH);
  239. }
  240. }
  241. }
  242. }
  243. };
  244.  
  245. // 01.3
  246. object DUMMYFindPath : CommandScript
  247. {
  248. DUMMYFindPath()
  249. {
  250. SetGroupID(DummyGroup);
  251. }
  252.  
  253. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  254. {
  255. return false;
  256. }
  257.  
  258. void PushActions(GameObject *Caller, Actor *Target, int childID)
  259. {
  260. }
  261. };
  262.  
  263. // 01.4
  264. object DUMMYHasSiren : CommandScript
  265. {
  266. DUMMYHasSiren()
  267. {
  268. SetGroupID(DummyGroup);
  269. }
  270.  
  271. bool CheckGroupVisibility(GameObject *Caller)
  272. {
  273. return false;
  274. }
  275.  
  276. bool CheckPossible(GameObject *Caller)
  277. {
  278. return false;
  279. }
  280.  
  281.  
  282. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  283. {
  284. return false;
  285. }
  286.  
  287. void PushActions(GameObject *Caller, Actor *Target, int childID)
  288. {
  289. }
  290. };
  291. // ## Blaulichtscript
  292. // ##
  293. // ## Schaltet Blaulichter an und aus
  294. // ##
  295. // ## Script von feuerflo112.
  296. // ##
  297. // ## Um dieses Script zu nutzen, ist eine Lizens n�tig, welche im Emergency FanForum in dem passendem Thread zu erbitten ist.
  298.  
  299.  
  300. const char IMG[] = "Blaulicht";
  301.  
  302. object VCmdBlaulicht : CommandScript
  303. {
  304. VCmdBlaulicht()
  305. {
  306. SetIcon(IMG);
  307. SetCursor(IMG);
  308. SetRestrictions(RESTRICT_SELFEXECUTE);
  309. }
  310.  
  311. bool CheckPossible(GameObject *Caller)
  312. {
  313. if (!Caller->IsValid())
  314. return false;
  315.  
  316. if (Caller->GetType() == ACTOR_VEHICLE)
  317. {
  318. return true;
  319. }
  320.  
  321. return false;
  322. }
  323.  
  324. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  325. {
  326. if (!Caller->IsValid() || !Target->IsValid() || Target->GetID() != Caller->GetID())
  327. return false;
  328.  
  329. if (Caller->GetType() == ACTOR_VEHICLE)
  330. {
  331. return true;
  332. }
  333.  
  334. return true;
  335. }
  336.  
  337. void PushActions(GameObject *Caller, Actor *Target, int childID)
  338. {
  339. Vehicle v(Caller);
  340.  
  341. if (v.IsBlueLightEnabled())
  342. {
  343. v.EnableBlueLights(false);
  344. return;
  345. }
  346.  
  347. if (!v.IsBlueLightEnabled())
  348. {
  349. v.EnableBlueLights(true);
  350. return;
  351. }
  352. }
  353. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement