Advertisement
Guest User

Untitled

a guest
Mar 18th, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 102.95 KB | None | 0 0
  1. //******************************************************************************************
  2. // #Version 1.2#
  3. //
  4. // Includes: Call commands for the battalion chief.
  5. //
  6. // - PcmdCallAmbulance
  7. // - PcmdCallAmbulance1
  8. // - PcmdCallAmbulance2
  9. // - PcmdCallEngine1
  10. // - PcmdCallEngine2
  11. // - PcmdCallLightForce
  12. // - PcmdCallUSARSquad
  13. // - PcmdCallHazmat
  14. // - DummyVehicleCalled
  15. //
  16. // Script by Hoppah
  17. // Mofied by Xplorer4x4
  18. //
  19. // Usage of this script in other mods is NOT allowed without permission of Hoppah
  20. //
  21. //******************************************************************************************
  22.  
  23. const char CMD_SIREN[] = "VcmdSiren";
  24. const char CMD_AUTOSIREN_OFF[] = "VcmdAutoSirenOff";
  25. const char CMD_WARNINGLIGHTS_OFF[] = "VcmdWarningLightsOff";
  26. const char CMD_WARNINGLIGHTS_ON[] = "VcmdWarningLightsOn";
  27. const char CMD_FLOODLIGHTS_OFF[] = "VcmdFloodLightsOff";
  28. const char CMD_FLOODLIGHTS_ON[] = "VcmdFloodLightsOn";
  29. const char CMD_STANDBY_ON[] = "VcmdStandbyOn";
  30. const char CMD_STANDBY_OFF[] = "VcmdStandbyOff";
  31.  
  32. const char DUMMY_HASSIREN[] = "DummyHasSiren";
  33. const char DUMMY_PATROL[] = "DummyPatrol";
  34. const char DUMMY_CALLCREW[] = "DummyCallCrew";
  35. const char DUMMY_GATES[] = "DummyGates";
  36. const char DUMMY_ALARM[] = "DummyAlarm";
  37. const char DUMMY_VCALLED[] = "DummyVehicleCalled";
  38. const char DUMMY_CALLVEHICLE[] = "DummyCallVehicle";
  39. const char DUMMY_HOSESON[] = "DummyHosesAreOn";
  40.  
  41. const char HINT_DISPATCHED[] = "Vehicle dispatched!";
  42. const char HINT_NOAMBULANCE[] = "No ambulance available!";
  43. const char HINT_NOUSAR[] = "No USAR squad available!";
  44. const char HINT_NOLADDER[] = "No light force available!";
  45. const char HINT_NOENGINE[] = "No fire engine available!";
  46. const char HINT_NOHAZMAT[] = "No HAZMAT squad available!";
  47. const char HINT_ALSAMBUBOUGHT[] = "ALS Ambulance bought for $1200 and dispatched!";
  48. const char HINT_BLSAMBUBOUGHT[] = "BLS Ambulance bought for $900 and dispatched!";
  49. const char HINT_ALSENGINEBOUGHT[] = "ALS Engine bought for $4000 and dispatched!";
  50. const char HINT_BLSENGINEBOUGHT[] = "BLS Engine bought for $4000 and dispatched!";
  51. const char HINT_USARBOUGHT[] = "USAR squad bought for $3500 and dispatched!";
  52. const char HINT_HAZMATBOUGHT[] = "HAZMAT squad bought for $4000 and dispatched!";
  53. const char HINT_LADDERBOUGHT[] = "Aerial ladder bought for $4000 and dispatched!";
  54. const char HINT_LIGHTFORCEBOUGHT[] = "Light force bought for $8000 and dispatched!";
  55.  
  56. const char VO_HAZMAT[] = "fs_hazmat";
  57. const char VO_BATTALION[] = "fs_battalion";
  58. const char VO_AMBULANCE01[] = "fs_ambulance01";
  59. const char VO_AMBULANCE02[] = "fs_ambulance02";
  60. const char VO_AMBULANCE03[] = "fs_ambulance03";
  61. const char VO_AMBULANCE04[] = "fs_ambulance04";
  62. const char VO_USAR[] = "fs_usar";
  63. const char VO_LRA[] = "fs_lra";
  64. const char VO_LADDER[] = "fs_ladder";
  65. const char VO_TILLER[] = "fs_tiller";
  66. const char VO_ENGINE01[] = "fs_engine01";
  67. const char VO_ENGINE02[] = "fs_engine02";
  68. const char VO_ENGINE03[] = "fs_engine03";
  69. const char VO_ENGINE04[] = "fs_engine04";
  70. const char VO_ENGINE05[] = "fs_engine05";
  71.  
  72. const char OBJ_GATE01A[] = "fs_gate01a";
  73. const char OBJ_GATE02A[] = "fs_gate02a";
  74. const char OBJ_GATE03A[] = "fs_gate03a";
  75. const char OBJ_GATE04A[] = "fs_gate04a";
  76. const char OBJ_GATE05A[] = "fs_gate05a";
  77. const char OBJ_GATE06A[] = "fs_gate06a";
  78. const char OBJ_GATE07A[] = "fs_gate07a";
  79. const char OBJ_GATE08A[] = "fs_gate08a";
  80.  
  81. const char PATH_PATROL01[] = "patrolpath01";
  82. const char PATH_PATROL02[] = "patrolpath02";
  83. const char PATH_PATROL03[] = "patrolpath03";
  84.  
  85. const char OBJ_AMBULANCE01[] = "mod:Prototypes/Vehicles/01 LA Ambulance/ambulance01.e4p";
  86. const char OBJ_AMBULANCE02[] = "mod:Prototypes/Vehicles/01 LA Ambulance/ambulance02.e4p";
  87. const char OBJ_AMBULANCE03[] = "mod:Prototypes/Vehicles/01 LA Ambulance/ambulance03.e4p";
  88. const char OBJ_AMBULANCE04[] = "mod:Prototypes/Vehicles/01 LA Ambulance/ambulance04.e4p";
  89. const char OBJ_ENGINE01[] = "mod:Prototypes/Vehicles/02 LA Fire Department/fire_engine1.e4p";
  90. const char OBJ_ENGINE03[] = "mod:Prototypes/Vehicles/02 LA Fire Department/fire_engine3.e4p";
  91. const char OBJ_ENGINE02[] = "mod:Prototypes/Vehicles/02 LA Fire Department/fire_engine2.e4p";
  92. const char OBJ_ENGINE04[] = "mod:Prototypes/Vehicles/02 LA Fire Department/fire_engine4.e4p";
  93. const char OBJ_ENGINE17[] = "mod:Prototypes/Vehicles/02 LA Fire Department/fire_engine17.e4p";
  94. const char OBJ_LADDER[] = "mod:Prototypes/Vehicles/02 LA Fire Department/aerial_ladder.e4p";
  95. const char OBJ_TILLER[] = "mod:Prototypes/Vehicles/02 LA Fire Department/tiller_cabin.e4p";
  96. const char OBJ_HAZMAT[] = "mod:Prototypes/Vehicles/02 LA Fire Department/hazmat_squad.e4p";
  97. const char OBJ_RESCUE7[] = "mod:Prototypes/Vehicles/01 LA Ambulance/large_rescue_ambulance.e4p";
  98. const char OBJ_USAR[] = "mod:Prototypes/Vehicles/02 LA Fire Department/usar_squad.e4p";
  99. const char OBJ_PM[] = "mod:Prototypes/Persons/01 LA Ambulance/ff_paramedic.e4p";
  100. const char OBJ_EMT[] = "mod:Prototypes/Persons/02 LA Fire Department/ff_emt.e4p";
  101. const char OBJ_PM_STRETCHER[] = "mod:Prototypes/Persons/01 LA Ambulance/ff_paramedic_stretcher.e4p";
  102. const char OBJ_EMT_STRETCHER[] = "mod:Prototypes/Persons/02 LA Fire Department/ff_emt_stretcher.e4p";
  103. const char OBJ_HAZMATFF[] = "mod:Prototypes/Persons/02 LA Fire Department/ff_hazmat.e4p";
  104. const char OBJ_USARFF[] = "mod:Prototypes/Persons/02 LA Fire Department/usar_ff.e4p";
  105.  
  106. const char OBJ_BATTALION_CHIEF[] = "mod:Prototypes/Persons/02 LA Fire Department/battalion_chief.e4p";
  107. const char OBJ_EMS_CAPTAIN[] = "mod:Prototypes/Persons/01 LA Ambulance/ems_paramedic_captain.e4p";
  108. const char SND_BATALS[] = "mod:Audio/FX/radio/bat_als.wav";
  109. const char SND_BATALSE[] = "mod:Audio/FX/radio/bat_alse.wav";
  110. const char SND_BATBLS[] = "mod:Audio/FX/radio/bat_bls.wav";
  111. const char SND_BATBLSE[] = "mod:Audio/FX/radio/bat_blse.wav";
  112. const char SND_BATHAZMAT[] = "mod:Audio/FX/radio/bat_hazmat.wav";
  113. const char SND_BATLIGHTFORCE[] = "mod:Audio/FX/radio/bat_lightforce.wav";
  114. const char SND_BATMEDFLIGHT[] = "mod:Audio/FX/radio/bat_medflight.wav";
  115. const char SND_BATPD[] = "mod:Audio/FX/radio/bat_pd.wav";
  116. const char SND_BATUSAR[] = "mod:Audio/FX/radio/bat_usar.wav";
  117. const char SND_EMSALS[] = "mod:Audio/FX/radio/ems_als.wav";
  118. const char SND_EMSALSE[] = "mod:Audio/FX/radio/ems_alse.wav";
  119. const char SND_EMSBLS[] = "mod:Audio/FX/radio/ems_bls.wav";
  120. const char SND_EMSBLSE[] = "mod:Audio/FX/radio/ems_blse.wav";
  121. const char SND_EMSHAZMAT[] = "mod:Audio/FX/radio/ems_hazmat.wav";
  122. const char SND_EMSLIGHTFORCE[] = "mod:Audio/FX/radio/ems_lightforce.wav";
  123. const char SND_EMSMEDFLIGHT[] = "mod:Audio/FX/radio/ems_medflight.wav";
  124. const char SND_EMSPD[] = "mod:Audio/FX/radio/ems_pd.wav";
  125. const char SND_EMSUSAR[] = "mod:Audio/FX/radio/ems_usar.wav";
  126. const char SND_PDEMS[] = "mod:Audio/FX/radio/pd_ems.wav";
  127.  
  128. const char NAME_CONTROLPANEL[] = "fire_station_controlpanel";
  129. const char NAME_CONTROLPANEL2[] = "fire_station_controlpanel2";
  130.  
  131. const char VO_SQUAD01[] = "fs_squad01";
  132. const char VO_SQUADFS2[] = "fs_squadFS2";
  133. const char VO_SQUAD02[] = "fs_squad02";
  134.  
  135. const char VO_SPAWN_ALL[] = "spawn_all";
  136. const char VO_SPAWN_AMBU[] = "spawn_ambu";
  137. const char VO_SPAWN_FD[] = "spawn_firedept";
  138. const char VO_SPAWN_ALLR[] = "spawn_allr";
  139. const char VO_SPAWN_AMBUR[] = "spawn_ambur";
  140. const char VO_SPAWN_FDR[] = "spawn_firedeptr";
  141. const char UNNAMED[] = "Unnamed";
  142.  
  143. object PcmdCallAmbulance : CommandScript
  144. {
  145. PcmdCallAmbulance()
  146. {
  147. SetIcon("callambulance1");
  148. SetCursor("callassistance");
  149. SetValidTargets(ACTOR_FLOOR | ACTOR_VIRTUAL);
  150. SetDeselectCaller(false);
  151. SetSelfClickActivation(true);
  152. SetHighlightingEnabled(false);
  153. SetGroupID(CGROUP_GETEQUIPMENT);
  154. SetGroupLeader(true);
  155. }
  156.  
  157. bool CheckPossible(GameObject *Caller)
  158. {
  159. GameObjectList SelectPer = Game::GetSelectedGameObjects();
  160. if (SelectPer.GetNumObjects() != 1)
  161. return false;
  162.  
  163. Person p(Caller);
  164. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  165. return false;
  166.  
  167. if (p.IsCurrentAction("EActionTreatPerson"))
  168. return false;
  169.  
  170. if (!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
  171. return false;
  172.  
  173. return true;
  174. }
  175.  
  176. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  177. {
  178. if(!Caller->IsValid() || Caller->GetID() == Target->GetID())
  179. return false;
  180.  
  181. if (Caller->GetType() != ACTOR_PERSON)
  182. return false;
  183.  
  184. Person p(Caller);
  185. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  186. return false;
  187.  
  188. if (p.IsCurrentAction("EActionTreatPerson"))
  189. return false;
  190.  
  191. return true;
  192. }
  193.  
  194. void PushActions(GameObject *Caller, Actor *Target, int ChildID)
  195. {
  196. Vector CmdPos = Game::GetCommandPos();
  197. Caller->PushActionTurnTo(ACTION_NEWLIST, CmdPos);
  198. Caller->PushActionSwitchAnim(ACTION_APPEND, "talkmike");
  199. Caller->PushActionWait(ACTION_APPEND, 3.5f);
  200. Caller->PushActionSwitchAnim(ACTION_APPEND, "idle");
  201. Audio::PlaySample3D(SND_PDEMS, Caller->GetPosition());
  202.  
  203. Vehicle *theCar = NULL;
  204. float bestCar = 0.;
  205. VehicleList patrolCars(VT_AMBULANCE_RTW, VT_AMBULANCE_RTW);
  206. for (int i = 0; i < patrolCars.GetNumVehicles(); i++)
  207. {
  208. Vehicle *aCar = patrolCars.GetVehicle(i);
  209. if (aCar->GetPlayerMP() == Caller->GetPlayerMP() && !aCar->HasCommand(DUMMY_VCALLED) && (aCar->HasCommand(CMD_STANDBY_OFF) || aCar->HasCommand(DUMMY_PATROL) || aCar->IsCollidingWithVirtualObject(VO_SQUAD01) || aCar->IsCollidingWithVirtualObject(VO_SQUAD02)))
  210. {
  211. float distCurrCar = Math::dist(CmdPos.x, CmdPos.y, aCar->GetPosition().x, aCar->GetPosition().y);
  212. if (distCurrCar < bestCar || bestCar == 0.)
  213. {
  214. theCar = aCar;
  215. bestCar = distCurrCar;
  216. }
  217. }
  218. }
  219. if (theCar)
  220. {
  221. bool VehicleCalled = false;
  222. if (theCar->HasCommand(CMD_STANDBY_OFF) || theCar->HasObjectPath(NULL))
  223. {
  224. theCar->PushActionWait(ACTION_NEWLIST, 0.3f);
  225. if (theCar->HasCommand(DUMMY_PATROL))
  226. theCar->PushActionExecuteCommand(ACTION_APPEND, DUMMY_PATROL, theCar, 1, false);
  227. theCar->PushActionMove(ACTION_APPEND, CmdPos);
  228. if (!theCar->HasCommand(DUMMY_HASSIREN) && theCar->HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  229. Game::ExecuteCommand(CMD_SIREN, theCar, theCar);
  230. if (theCar->HasCommand(CMD_STANDBY_OFF))
  231. {
  232. theCar->RemoveCommand(CMD_STANDBY_OFF);
  233. theCar->AssignCommand(CMD_STANDBY_ON);
  234. }
  235. if (theCar->HasCommand(CMD_WARNINGLIGHTS_OFF))
  236. {
  237. theCar->EnableBlinker(BLT_NONE);
  238. theCar->RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  239. theCar->AssignCommand(CMD_WARNINGLIGHTS_ON);
  240. }
  241. if (theCar->HasCommand(CMD_FLOODLIGHTS_OFF))
  242. {
  243. theCar->EnableSpecialLights(false);
  244. theCar->RemoveCommand(CMD_FLOODLIGHTS_OFF);
  245. theCar->AssignCommand(CMD_FLOODLIGHTS_ON);
  246. }
  247. Mission::PlayHint(HINT_DISPATCHED);
  248. return;
  249. }
  250. else if (theCar->IsCollidingWithVirtualObject(VO_SQUAD01))
  251. {
  252. bool Ambulance02 = false;
  253. bool Ambulance03 = false;
  254. if (!VehicleCalled)
  255. {
  256. GameObjectList l1;
  257. Game::CollectObstaclesOnVirtualObject(VO_AMBULANCE01, l1, ACTOR_VEHICLE);
  258. if(l1.GetNumObjects() > 0)
  259. {
  260. Vehicle v = l1.GetObject(0);
  261. if (!v.HasCommand(DUMMY_VCALLED))
  262. {
  263. v.AssignCommand(DUMMY_VCALLED);
  264. VehicleCalled = true;
  265. } else
  266. Ambulance02 = true;
  267. } else
  268. Ambulance02 = true;
  269. }
  270. if (!VehicleCalled && Ambulance02)
  271. {
  272. GameObjectList l2;
  273. Game::CollectObstaclesOnVirtualObject(VO_AMBULANCE02, l2, ACTOR_VEHICLE);
  274. if(l2.GetNumObjects() > 0)
  275. {
  276. Vehicle v = l2.GetObject(0);
  277. if (!v.HasCommand(DUMMY_VCALLED))
  278. {
  279. v.AssignCommand(DUMMY_VCALLED);
  280. VehicleCalled = true;
  281. } else
  282. Ambulance03 = true;
  283. } else
  284. Ambulance03 = true;
  285. }
  286. if (!VehicleCalled && Ambulance03)
  287. {
  288. GameObjectList l3;
  289. Game::CollectObstaclesOnVirtualObject(VO_AMBULANCE03, l3, ACTOR_VEHICLE);
  290. if(l3.GetNumObjects() > 0)
  291. {
  292. Vehicle v = l3.GetObject(0);
  293. if (!v.HasCommand(DUMMY_VCALLED))
  294. {
  295. v.AssignCommand(DUMMY_VCALLED);
  296. VehicleCalled = true;
  297. }
  298. }
  299. }
  300. }
  301. else if (theCar->IsCollidingWithVirtualObject(VO_SQUAD02))
  302. {
  303. GameObjectList l4;
  304. Game::CollectObstaclesOnVirtualObject(VO_AMBULANCE04, l4, ACTOR_VEHICLE);
  305. if(l4.GetNumObjects() > 0)
  306. {
  307. Vehicle v = l4.GetObject(0);
  308. if (!v.HasCommand(DUMMY_VCALLED))
  309. {
  310. v.AssignCommand(DUMMY_VCALLED);
  311. VehicleCalled = true;
  312. }
  313. }
  314. }
  315. if (VehicleCalled)
  316. {
  317. if (v.IsBlueLightEnabled() && (Input::LShiftPressed() || Input::RShiftPressed()))
  318. v.EnableBlueLights(false);
  319. else if (!v.IsBlueLightEnabled() && !Input::LShiftPressed() && !Input::RShiftPressed())
  320. v.EnableBlueLights(true);
  321. bool Station1 = false;
  322. if(v.IsCollidingWithVirtualObject(VO_SQUAD01))
  323. {
  324. Station1 = true;
  325. GameObjectList gate01a = Game::GetGameObjects(OBJ_GATE01A);
  326. for(int i=0; i < gate01a.GetNumObjects(); i++)
  327. GameObject *gate = gate01a.GetObject(i);
  328. }
  329. else if(v.IsCollidingWithVirtualObject(VO_SQUAD02))
  330. {
  331. GameObjectList gate08a = Game::GetGameObjects(OBJ_GATE08A);
  332. for(int i=0; i < gate08a.GetNumObjects(); i++)
  333. GameObject *gate = gate08a.GetObject(i);
  334. }
  335. PersonList passengers = v.GetPassengers();
  336. if (passengers.GetNumPersons() == 0)
  337. {
  338. if (StrCompare(v.GetPrototypeFileName(), OBJ_AMBULANCE01) == 0)
  339. {
  340. v.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_CALLCREW, Caller, 7, false);
  341. //v.PushActionWait(ACTION_APPEND, 0.5f);
  342. //v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 3, false);
  343. v.PushActionWait(ACTION_APPEND, 6.f);
  344. }
  345. else
  346. {
  347. //v.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_CALLCREW, Caller, 1, false);
  348. //v.PushActionWait(ACTION_APPEND, 0.5f);
  349. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 2, false);
  350. v.PushActionWait(ACTION_APPEND, 12.5f);
  351. }
  352. }
  353.  
  354. if (gate->GetUserData() == 0)
  355. {
  356. if(v.IsCollidingWithVirtualObject(VO_SQUAD01))
  357. {
  358. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  359. float dx = 1050.f, dy = 0.f, dz = 0.f;
  360. }
  361. else
  362. {
  363. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 6, false);
  364. float dx = 500.f, dy = 0.f, dz = 0.f;
  365. }
  366. Vector Move = v.GetPosition();
  367. float r[9];
  368. float childr[9];
  369. v.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
  370. Math::RotateVector(dx, dy, dz, r);
  371. Math::EulerToMatrix(0.0f, 0.f, 0.f, childr);
  372. Math::MultiplyMatrices(childr, r);
  373. Move = Move + Vector(dx, dy, 0);
  374. v.PushActionWait(ACTION_APPEND, 1.2f);
  375. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  376. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  377. v.PushActionMove(ACTION_APPEND, Move);
  378. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  379. if(Station1)
  380. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  381. else
  382. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 6, false);
  383. v.PushActionMove(ACTION_APPEND, CmdPos);
  384. } else
  385. {
  386. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  387. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  388. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  389. v.PushActionMove(ACTION_APPEND, CmdPos);
  390. }
  391. if (v.HasCommand(CMD_STANDBY_OFF))
  392. {
  393. v.RemoveCommand(CMD_STANDBY_OFF);
  394. v.AssignCommand(CMD_STANDBY_ON);
  395. }
  396. if (v.HasCommand(CMD_WARNINGLIGHTS_OFF))
  397. {
  398. v.EnableBlinker(BLT_NONE);
  399. v.RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  400. v.AssignCommand(CMD_WARNINGLIGHTS_ON);
  401. }
  402. Mission::PlayHint(HINT_DISPATCHED);
  403. return;
  404. }
  405. }
  406. Vector Spawn;
  407. Vector Rotate;
  408. ActorList l1 = Game::GetActors(VO_SPAWN_ALL);
  409. ActorList l2 = Game::GetActors(VO_SPAWN_AMBU);
  410. ActorList l3 = Game::GetActors(VO_SPAWN_ALLR);
  411. ActorList l4 = Game::GetActors(VO_SPAWN_AMBUR);
  412. if(l1.GetNumActors() > 0)
  413. {
  414. Spawn = l1.GetActor(0)->GetPosition();
  415. Rotate = l3.GetActor(0)->GetPosition();
  416. }
  417. else if(l2.GetNumActors() > 0)
  418. {
  419. Spawn = l2.GetActor(0)->GetPosition();
  420. Rotate = l4.GetActor(0)->GetPosition();
  421. }
  422. else
  423. {
  424. Mission::PlayHint(HINT_NOAMBULANCE);
  425. return;
  426. }
  427. System::Log("Buy ALS ambulance");
  428. int Money = Mission::GetMoneyLeft();
  429. if (Money <= 1200)
  430. {
  431. Mission::PlayHint(HINT_NOAMBULANCE);
  432. return;
  433. }
  434. int NewMoney = Money - 1200;
  435. Mission::SetMoney(NewMoney);
  436. Vehicle n;
  437. Person p1;
  438. Person p2;
  439. n = Game::CreateVehicle(OBJ_AMBULANCE02, UNNAMED);
  440. n.SetSpeed(12.0f);
  441. p1 = Game::CreatePerson(OBJ_PM, UNNAMED);
  442. p2 = Game::CreatePerson(OBJ_PM_STRETCHER, UNNAMED);
  443. p1.SetEquipment(EQUIP_EMERGENCY_CASE);
  444. n.SetPlayerMP(Caller->GetPlayerMP());
  445. p1.SetPlayerMP(Caller->GetPlayerMP());
  446. p2.SetPlayerMP(Caller->GetPlayerMP());
  447. p1.SetUpgradeLevel(3);
  448. p2.SetUpgradeLevel(3);
  449. n.SetMaxPassengers(2);
  450. n.SetMaxTransports(1);
  451. n.AddPassenger(&p1);
  452. n.AddPassenger(&p2);
  453. n.SetPosition(Spawn);
  454. n.UpdatePlacement();
  455. n.Hide();
  456. n.PushActionTurnTo(ACTION_NEWLIST, Rotate);
  457. n.PushActionWait(ACTION_APPEND, 2.5f);
  458. n.PushActionShowHide(ACTION_APPEND, false);
  459. n.PushActionMove(ACTION_APPEND, CmdPos);
  460. if (Game::IsMission())
  461. {
  462. n.RemoveCommand("VcmdToFireStation");
  463. n.RemoveCommand("VcmdToHospital");
  464. n.RemoveCommand("VcmdPatrolAmbulance");
  465. }
  466.  
  467. if (!n.HasCommand(DUMMY_HASSIREN) && n.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  468. Game::ExecuteCommand(CMD_SIREN, &n, &n);
  469.  
  470. Mission::PlayHint(HINT_ALSAMBUBOUGHT);
  471. }
  472. };
  473.  
  474. object PcmdCallAmbulance1 : CommandScript
  475. {
  476. PcmdCallAmbulance1()
  477. {
  478. SetIcon("callambulance1");
  479. SetCursor("callassistance");
  480. SetValidTargets(ACTOR_FLOOR | ACTOR_VIRTUAL);
  481. SetDeselectCaller(false);
  482. SetSelfClickActivation(true);
  483. SetHighlightingEnabled(false);
  484. SetGroupID(CGROUP_GETEQUIPMENT);
  485. SetGroupLeader(true);
  486. }
  487.  
  488. bool CheckPossible(GameObject *Caller)
  489. {
  490. GameObjectList SelectPer = Game::GetSelectedGameObjects();
  491. if (SelectPer.GetNumObjects() != 1)
  492. return false;
  493.  
  494. Person p(Caller);
  495. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  496. return false;
  497.  
  498. if (p.IsCurrentAction("EActionTreatPerson"))
  499. return false;
  500.  
  501. if (!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
  502. return false;
  503.  
  504. return true;
  505. }
  506.  
  507. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  508. {
  509. if(!Caller->IsValid() || Caller->GetID() == Target->GetID())
  510. return false;
  511.  
  512. if (Caller->GetType() != ACTOR_PERSON)
  513. return false;
  514.  
  515. Person p(Caller);
  516. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  517. return false;
  518.  
  519. if (p.IsCurrentAction("EActionTreatPerson"))
  520. return false;
  521.  
  522. return true;
  523. }
  524.  
  525. void PushActions(GameObject *Caller, Actor *Target, int ChildID)
  526. {
  527. Vector CmdPos = Game::GetCommandPos();
  528. Caller->PushActionTurnTo(ACTION_NEWLIST, CmdPos);
  529. Caller->PushActionSwitchAnim(ACTION_APPEND, "talkmike");
  530. Caller->PushActionWait(ACTION_APPEND, 3.5f);
  531. Caller->PushActionSwitchAnim(ACTION_APPEND, "idle");
  532. if(StrCompare(Caller->GetPrototypeFileName(), OBJ_BATTALION_CHIEF) == 0)
  533. Audio::PlaySample3D(SND_BATBLS, Caller->GetPosition());
  534. else if(StrCompare(Caller->GetPrototypeFileName(), OBJ_EMS_CAPTAIN) == 0)
  535. Audio::PlaySample3D(SND_EMSBLS, Caller->GetPosition());
  536.  
  537. Vehicle *theCar = NULL;
  538. float bestCar = 0.;
  539. VehicleList patrolCars(VT_AMBULANCE_RTW, VT_AMBULANCE_RTW);
  540. for (int i = 0; i < patrolCars.GetNumVehicles(); i++)
  541. {
  542. Vehicle *aCar = patrolCars.GetVehicle(i);
  543. if (StrCompare(aCar->GetPrototypeFileName(), OBJ_AMBULANCE01) == 0 && aCar->GetPlayerMP() == Caller->GetPlayerMP() && !aCar->HasCommand(DUMMY_VCALLED) && (aCar->HasCommand(CMD_STANDBY_OFF) || aCar->HasCommand(DUMMY_PATROL) || aCar->IsCollidingWithVirtualObject(VO_SQUAD02)))
  544. {
  545. float distCurrCar = Math::dist(CmdPos.x, CmdPos.y, aCar->GetPosition().x, aCar->GetPosition().y);
  546. if (distCurrCar < bestCar || bestCar == 0.)
  547. {
  548. theCar = aCar;
  549. bestCar = distCurrCar;
  550. }
  551. }
  552. }
  553.  
  554. if (theCar)
  555. {
  556. bool VehicleCalled = false;
  557. if (theCar->HasCommand(CMD_STANDBY_OFF) || theCar->HasObjectPath(NULL))
  558. {
  559. theCar->PushActionWait(ACTION_NEWLIST, 0.3f);
  560. if (theCar->HasObjectPath(NULL))
  561. theCar->PushActionExecuteCommand(ACTION_APPEND, DUMMY_PATROL, theCar, 1, false);
  562. theCar->PushActionMove(ACTION_APPEND, CmdPos);
  563. if (!theCar->HasCommand(DUMMY_HASSIREN) && theCar->HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  564. Game::ExecuteCommand(CMD_SIREN, theCar, theCar);
  565. if (theCar->HasCommand(CMD_STANDBY_OFF))
  566. {
  567. theCar->RemoveCommand(CMD_STANDBY_OFF);
  568. theCar->AssignCommand(CMD_STANDBY_ON);
  569. }
  570. if (theCar->HasCommand(CMD_WARNINGLIGHTS_OFF))
  571. {
  572. theCar->EnableBlinker(BLT_NONE);
  573. theCar->RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  574. theCar->AssignCommand(CMD_WARNINGLIGHTS_ON);
  575. }
  576. if (theCar->HasCommand(CMD_FLOODLIGHTS_OFF))
  577. {
  578. theCar->EnableSpecialLights(false);
  579. theCar->RemoveCommand(CMD_FLOODLIGHTS_OFF);
  580. theCar->AssignCommand(CMD_FLOODLIGHTS_ON);
  581. }
  582. Mission::PlayHint(HINT_DISPATCHED);
  583. return;
  584. }
  585. else if (theCar->IsCollidingWithVirtualObject(VO_SQUAD02))
  586. {
  587. GameObjectList l4;
  588. Game::CollectObstaclesOnVirtualObject(VO_AMBULANCE04, l4, ACTOR_VEHICLE);
  589. if(l4.GetNumObjects() > 0)
  590. {
  591. Vehicle v = l4.GetObject(0);
  592. if (!v.HasCommand(DUMMY_VCALLED))
  593. {
  594. v.AssignCommand(DUMMY_VCALLED);
  595. VehicleCalled = true;
  596. }
  597. }
  598. }
  599. if (VehicleCalled)
  600. {
  601. if (v.IsBlueLightEnabled() && (Input::LShiftPressed() || Input::RShiftPressed()))
  602. v.EnableBlueLights(false);
  603. else if (!v.IsBlueLightEnabled() && !Input::LShiftPressed() && !Input::RShiftPressed())
  604. v.EnableBlueLights(true);
  605.  
  606. GameObjectList gate08a = Game::GetGameObjects(OBJ_GATE08A);
  607. for(int i=0; i < gate08a.GetNumObjects(); i++)
  608. GameObject *gate = gate08a.GetObject(i);
  609.  
  610. PersonList passengers = v.GetPassengers();
  611. if (passengers.GetNumPersons() == 0)
  612. {
  613. v.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_CALLCREW, Caller, 7, false);
  614. //v.PushActionWait(ACTION_APPEND, 0.5f);
  615. //v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 3, false);
  616. v.PushActionWait(ACTION_APPEND, 6.f);
  617. }
  618. if (gate->GetUserData() == 0)
  619. {
  620. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 6, false);
  621. float dx = 1050.f, dy = 0.f, dz = 0.f;
  622. Vector Move = v.GetPosition();
  623. float r[9];
  624. float childr[9];
  625. v.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
  626. Math::RotateVector(dx, dy, dz, r);
  627. Math::EulerToMatrix(0.0f, 0.f, 0.f, childr);
  628. Math::MultiplyMatrices(childr, r);
  629. Move = Move + Vector(dx, dy, 0);
  630. v.PushActionWait(ACTION_APPEND, 1.2f);
  631. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  632. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  633. v.PushActionMove(ACTION_APPEND, Move);
  634. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  635. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 6, false);
  636. v.PushActionMove(ACTION_APPEND, CmdPos);
  637. } else
  638. {
  639. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  640. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  641. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  642. v.PushActionMove(ACTION_APPEND, CmdPos);
  643. }
  644. if (v.HasCommand(CMD_STANDBY_OFF))
  645. {
  646. v.RemoveCommand(CMD_STANDBY_OFF);
  647. v.AssignCommand(CMD_STANDBY_ON);
  648. }
  649. if (v.HasCommand(CMD_WARNINGLIGHTS_OFF))
  650. {
  651. v.EnableBlinker(BLT_NONE);
  652. v.RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  653. v.AssignCommand(CMD_WARNINGLIGHTS_ON);
  654. }
  655. Mission::PlayHint(HINT_DISPATCHED);
  656. return;
  657. }
  658.  
  659. }
  660. Vector Spawn;
  661. Vector Rotate;
  662. ActorList l1 = Game::GetActors(VO_SPAWN_ALL);
  663. ActorList l2 = Game::GetActors(VO_SPAWN_AMBU);
  664. ActorList l3 = Game::GetActors(VO_SPAWN_ALLR);
  665. ActorList l4 = Game::GetActors(VO_SPAWN_AMBUR);
  666. if(l1.GetNumActors() > 0)
  667. {
  668. Spawn = l1.GetActor(0)->GetPosition();
  669. Rotate = l3.GetActor(0)->GetPosition();
  670. }
  671. else if(l2.GetNumActors() > 0)
  672. {
  673. Spawn = l2.GetActor(0)->GetPosition();
  674. Rotate = l4.GetActor(0)->GetPosition();
  675. }
  676. else
  677. {
  678. Mission::PlayHint(HINT_NOAMBULANCE);
  679. return;
  680. }
  681. System::Log("Buy BLS ambulance");
  682. int Money = Mission::GetMoneyLeft();
  683. if (Money <= 900)
  684. {
  685. Mission::PlayHint(HINT_NOAMBULANCE);
  686. return;
  687. }
  688. int NewMoney = Money - 900;
  689. Mission::SetMoney(NewMoney);
  690. Vehicle n;
  691. Person p1;
  692. n = Game::CreateVehicle(OBJ_AMBULANCE01, UNNAMED);
  693. n.SetSpeed(12.0f);
  694. p1 = Game::CreatePerson(OBJ_EMT_STRETCHER, UNNAMED);
  695. n.SetPlayerMP(Caller->GetPlayerMP());
  696. p1.SetPlayerMP(Caller->GetPlayerMP());
  697. p1.SetUpgradeLevel(3);
  698. n.SetMaxPassengers(2);
  699. n.SetMaxTransports(1);
  700. n.AddPassenger(&p1);
  701. n.SetPosition(Spawn);
  702. n.UpdatePlacement();
  703. n.Hide();
  704. n.PushActionTurnTo(ACTION_NEWLIST, Rotate);
  705. n.PushActionWait(ACTION_APPEND, 2.5f);
  706. n.PushActionShowHide(ACTION_APPEND, false);
  707. n.PushActionMove(ACTION_APPEND, CmdPos);
  708. if (Game::IsMission())
  709. {
  710. n.RemoveCommand("VcmdToFireStation");
  711. n.RemoveCommand("VcmdToHospital");
  712. //n.RemoveCommand("VcmdPatrolAmbulance");
  713. }
  714.  
  715. if (!n.HasCommand(DUMMY_HASSIREN) && n.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  716. Game::ExecuteCommand(CMD_SIREN, &n, &n);
  717.  
  718. Mission::PlayHint(HINT_BLSAMBUBOUGHT);
  719. }
  720. };
  721.  
  722. object PcmdCallAmbulance2 : CommandScript
  723. {
  724. PcmdCallAmbulance2()
  725. {
  726. SetIcon("callambulance2");
  727. SetCursor("callassistance");
  728. SetValidTargets(ACTOR_FLOOR | ACTOR_VIRTUAL);
  729. SetDeselectCaller(false);
  730. SetSelfClickActivation(true);
  731. SetHighlightingEnabled(false);
  732. SetGroupID(CGROUP_GETEQUIPMENT);
  733. SetGroupLeader(true);
  734. }
  735.  
  736. bool CheckPossible(GameObject *Caller)
  737. {
  738. GameObjectList SelectPer = Game::GetSelectedGameObjects();
  739. if (SelectPer.GetNumObjects() != 1)
  740. return false;
  741.  
  742. Person p(Caller);
  743. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  744. return false;
  745.  
  746. if (p.IsCurrentAction("EActionTreatPerson"))
  747. return false;
  748.  
  749. if (!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
  750. return false;
  751.  
  752. return true;
  753. }
  754.  
  755. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  756. {
  757. if(!Caller->IsValid() || Caller->GetID() == Target->GetID())
  758. return false;
  759.  
  760. if (Caller->GetType() != ACTOR_PERSON)
  761. return false;
  762.  
  763. Person p(Caller);
  764. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  765. return false;
  766.  
  767. if (p.IsCurrentAction("EActionTreatPerson"))
  768. return false;
  769.  
  770. return true;
  771. }
  772.  
  773. void PushActions(GameObject *Caller, Actor *Target, int ChildID)
  774. {
  775. Vector CmdPos = Game::GetCommandPos();
  776. Caller->PushActionTurnTo(ACTION_NEWLIST, CmdPos);
  777. Caller->PushActionSwitchAnim(ACTION_APPEND, "talkmike");
  778. Caller->PushActionWait(ACTION_APPEND, 3.5f);
  779. Caller->PushActionSwitchAnim(ACTION_APPEND, "idle");
  780. if(StrCompare(Caller->GetPrototypeFileName(), OBJ_BATTALION_CHIEF) == 0)
  781. Audio::PlaySample3D(SND_BATALS, Caller->GetPosition());
  782. else if(StrCompare(Caller->GetPrototypeFileName(), OBJ_EMS_CAPTAIN) == 0)
  783. Audio::PlaySample3D(SND_EMSALS, Caller->GetPosition());
  784.  
  785. Vehicle *theCar = NULL;
  786. float bestCar = 0.;
  787. VehicleList patrolCars(VT_AMBULANCE_RTW, VT_AMBULANCE_RTW);
  788. for (int i = 0; i < patrolCars.GetNumVehicles(); i++)
  789. {
  790. Vehicle *aCar = patrolCars.GetVehicle(i);
  791. if (StrCompare(aCar->GetPrototypeFileName(), OBJ_AMBULANCE02) == 0 && aCar->GetPlayerMP() == Caller->GetPlayerMP() && !aCar->HasCommand(DUMMY_VCALLED) && (aCar->HasCommand(CMD_STANDBY_OFF) || aCar->HasCommand(DUMMY_PATROL) || aCar->IsCollidingWithVirtualObject(VO_SQUAD01)))
  792. {
  793. float distCurrCar = Math::dist(CmdPos.x, CmdPos.y, aCar->GetPosition().x, aCar->GetPosition().y);
  794. if (distCurrCar < bestCar || bestCar == 0.)
  795. {
  796. theCar = aCar;
  797. bestCar = distCurrCar;
  798. }
  799. }
  800. }
  801.  
  802. if (theCar)
  803. {
  804. bool VehicleCalled = false;
  805. if (theCar->HasCommand(CMD_STANDBY_OFF) || theCar->HasObjectPath(NULL))
  806. {
  807. theCar->PushActionWait(ACTION_NEWLIST, 0.3f);
  808. if (theCar->HasObjectPath(NULL))
  809. theCar->PushActionExecuteCommand(ACTION_APPEND, DUMMY_PATROL, theCar, 1, false);
  810. theCar->PushActionMove(ACTION_APPEND, CmdPos);
  811. if (!theCar->HasCommand(DUMMY_HASSIREN) && theCar->HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  812. Game::ExecuteCommand(CMD_SIREN, theCar, theCar);
  813. if (theCar->HasCommand(CMD_STANDBY_OFF))
  814. {
  815. theCar->RemoveCommand(CMD_STANDBY_OFF);
  816. theCar->AssignCommand(CMD_STANDBY_ON);
  817. }
  818. if (theCar->HasCommand(CMD_WARNINGLIGHTS_OFF))
  819. {
  820. theCar->EnableBlinker(BLT_NONE);
  821. theCar->RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  822. theCar->AssignCommand(CMD_WARNINGLIGHTS_ON);
  823. }
  824. if (theCar->HasCommand(CMD_FLOODLIGHTS_OFF))
  825. {
  826. theCar->EnableSpecialLights(false);
  827. theCar->RemoveCommand(CMD_FLOODLIGHTS_OFF);
  828. theCar->AssignCommand(CMD_FLOODLIGHTS_ON);
  829. }
  830. Mission::PlayHint(HINT_DISPATCHED);
  831. return;
  832. }
  833. else if (theCar->IsCollidingWithVirtualObject(VO_SQUAD01))
  834. {
  835. bool Ambulance02 = false;
  836. bool Ambulance03 = false;
  837. if (!VehicleCalled)
  838. {
  839. GameObjectList l1;
  840. Game::CollectObstaclesOnVirtualObject(VO_AMBULANCE01, l1, ACTOR_VEHICLE);
  841. if(l1.GetNumObjects() > 0)
  842. {
  843. Vehicle v = l1.GetObject(0);
  844. if (!v.HasCommand(DUMMY_VCALLED))
  845. {
  846. v.AssignCommand(DUMMY_VCALLED);
  847. VehicleCalled = true;
  848. } else
  849. Ambulance02 = true;
  850. } else
  851. Ambulance02 = true;
  852. }
  853. if (!VehicleCalled && Ambulance02)
  854. {
  855. GameObjectList l2;
  856. Game::CollectObstaclesOnVirtualObject(VO_AMBULANCE02, l2, ACTOR_VEHICLE);
  857. if(l2.GetNumObjects() > 0)
  858. {
  859. Vehicle v = l2.GetObject(0);
  860. if (!v.HasCommand(DUMMY_VCALLED))
  861. {
  862. v.AssignCommand(DUMMY_VCALLED);
  863. VehicleCalled = true;
  864. } else
  865. Ambulance03 = true;
  866. } else
  867. Ambulance03 = true;
  868. }
  869. if (!VehicleCalled && Ambulance03)
  870. {
  871. GameObjectList l3;
  872. Game::CollectObstaclesOnVirtualObject(VO_AMBULANCE03, l3, ACTOR_VEHICLE);
  873. if(l3.GetNumObjects() > 0)
  874. {
  875. Vehicle v = l3.GetObject(0);
  876. if (!v.HasCommand(DUMMY_VCALLED))
  877. {
  878. v.AssignCommand(DUMMY_VCALLED);
  879. VehicleCalled = true;
  880. }
  881. }
  882. }
  883. }
  884. if (VehicleCalled)
  885. {
  886. if (v.IsBlueLightEnabled() && (Input::LShiftPressed() || Input::RShiftPressed()))
  887. v.EnableBlueLights(false);
  888. else if (!v.IsBlueLightEnabled() && !Input::LShiftPressed() && !Input::RShiftPressed())
  889. v.EnableBlueLights(true);
  890.  
  891. GameObjectList gate01a = Game::GetGameObjects(OBJ_GATE01A);
  892. for(int i=0; i < gate01a.GetNumObjects(); i++)
  893. GameObject *gate = gate01a.GetObject(i);
  894.  
  895. PersonList passengers = v.GetPassengers();
  896. if (passengers.GetNumPersons() == 0)
  897. {
  898. //v.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_CALLCREW, Caller, 1, false);
  899. //v.PushActionWait(ACTION_APPEND, 0.5f);
  900. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 2, false);
  901. v.PushActionWait(ACTION_APPEND, 12.5f);
  902. }
  903. if (gate->GetUserData() == 0)
  904. {
  905. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  906. float dx = 500.f, dy = 0.f, dz = 0.f;
  907. Vector Move = v.GetPosition();
  908. float r[9];
  909. float childr[9];
  910. v.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
  911. Math::RotateVector(dx, dy, dz, r);
  912. Math::EulerToMatrix(0.0f, 0.f, 0.f, childr);
  913. Math::MultiplyMatrices(childr, r);
  914. Move = Move + Vector(dx, dy, 0);
  915. v.PushActionWait(ACTION_APPEND, 1.2f);
  916. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  917. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  918. v.PushActionMove(ACTION_APPEND, Move);
  919. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  920. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  921. v.PushActionMove(ACTION_APPEND, CmdPos);
  922. } else
  923. {
  924. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  925. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  926. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  927. v.PushActionMove(ACTION_APPEND, CmdPos);
  928. }
  929. if (v.HasCommand(CMD_STANDBY_OFF))
  930. {
  931. v.RemoveCommand(CMD_STANDBY_OFF);
  932. v.AssignCommand(CMD_STANDBY_ON);
  933. }
  934. if (v.HasCommand(CMD_WARNINGLIGHTS_OFF))
  935. {
  936. v.EnableBlinker(BLT_NONE);
  937. v.RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  938. v.AssignCommand(CMD_WARNINGLIGHTS_ON);
  939. }
  940. Mission::PlayHint(HINT_DISPATCHED);
  941. return;
  942. }
  943.  
  944. }
  945. Vector Spawn;
  946. Vector Rotate;
  947. ActorList l1 = Game::GetActors(VO_SPAWN_ALL);
  948. ActorList l2 = Game::GetActors(VO_SPAWN_AMBU);
  949. ActorList l3 = Game::GetActors(VO_SPAWN_ALLR);
  950. ActorList l4 = Game::GetActors(VO_SPAWN_AMBUR);
  951. if(l1.GetNumActors() > 0)
  952. {
  953. Spawn = l1.GetActor(0)->GetPosition();
  954. Rotate = l3.GetActor(0)->GetPosition();
  955. }
  956. else if(l2.GetNumActors() > 0)
  957. {
  958. Spawn = l2.GetActor(0)->GetPosition();
  959. Rotate = l4.GetActor(0)->GetPosition();
  960. }
  961. else
  962. {
  963. Mission::PlayHint(HINT_NOAMBULANCE);
  964. return;
  965. }
  966. System::Log("Buy ALS ambulance");
  967. int Money = Mission::GetMoneyLeft();
  968. if (Money <= 1200)
  969. {
  970. Mission::PlayHint(HINT_NOAMBULANCE);
  971. return;
  972. }
  973. int NewMoney = Money - 1200;
  974. Mission::SetMoney(NewMoney);
  975. Vehicle n;
  976. Person p1;
  977. Person p2;
  978. n = Game::CreateVehicle(OBJ_AMBULANCE02, UNNAMED);
  979. n.SetSpeed(12.0f);
  980. p1 = Game::CreatePerson(OBJ_PM, UNNAMED);
  981. p2 = Game::CreatePerson(OBJ_PM_STRETCHER, UNNAMED);
  982. p1.SetEquipment(EQUIP_EMERGENCY_CASE);
  983. n.SetPlayerMP(Caller->GetPlayerMP());
  984. p1.SetPlayerMP(Caller->GetPlayerMP());
  985. p2.SetPlayerMP(Caller->GetPlayerMP());
  986. p1.SetUpgradeLevel(3);
  987. p2.SetUpgradeLevel(3);
  988. n.SetMaxPassengers(2);
  989. n.SetMaxTransports(1);
  990. n.AddPassenger(&p1);
  991. n.AddPassenger(&p2);
  992. n.SetPosition(Spawn);
  993. n.UpdatePlacement();
  994. n.Hide();
  995. n.PushActionTurnTo(ACTION_NEWLIST, Rotate);
  996. n.PushActionWait(ACTION_APPEND, 2.5f);
  997. n.PushActionShowHide(ACTION_APPEND, false);
  998. n.PushActionMove(ACTION_APPEND, CmdPos);
  999. if (Game::IsMission())
  1000. {
  1001. n.RemoveCommand("VcmdToFireStation");
  1002. n.RemoveCommand("VcmdToHospital");
  1003. n.RemoveCommand("VcmdPatrolAmbulance");
  1004. }
  1005.  
  1006. if (!n.HasCommand(DUMMY_HASSIREN) && n.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  1007. Game::ExecuteCommand(CMD_SIREN, &n, &n);
  1008.  
  1009. Mission::PlayHint(HINT_ALSAMBUBOUGHT);
  1010. }
  1011. };
  1012.  
  1013. object PcmdCallEngine1 : CommandScript
  1014. {
  1015. PcmdCallEngine1()
  1016. {
  1017. SetIcon("callengine1");
  1018. SetCursor("callassistance");
  1019. SetValidTargets(ACTOR_FLOOR | ACTOR_VIRTUAL);
  1020. SetDeselectCaller(false);
  1021. SetSelfClickActivation(true);
  1022. SetHighlightingEnabled(false);
  1023. SetGroupID(CGROUP_GETEQUIPMENT);
  1024. SetGroupLeader(true);
  1025. }
  1026.  
  1027. bool CheckPossible(GameObject *Caller)
  1028. {
  1029. GameObjectList SelectPer = Game::GetSelectedGameObjects();
  1030. if (SelectPer.GetNumObjects() != 1)
  1031. return false;
  1032.  
  1033. Person p(Caller);
  1034. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  1035. return false;
  1036.  
  1037. if (p.IsCurrentAction("EActionTreatPerson"))
  1038. return false;
  1039.  
  1040. if (!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
  1041. return false;
  1042.  
  1043. return true;
  1044. }
  1045.  
  1046. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  1047. {
  1048. if(!Caller->IsValid() || Caller->GetID() == Target->GetID())
  1049. return false;
  1050.  
  1051. if (Caller->GetType() != ACTOR_PERSON)
  1052. return false;
  1053.  
  1054. Person p(Caller);
  1055. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  1056. return false;
  1057.  
  1058. if (p.IsCurrentAction("EActionTreatPerson"))
  1059. return false;
  1060.  
  1061. return true;
  1062. }
  1063.  
  1064. void PushActions(GameObject *Caller, Actor *Target, int ChildID)
  1065. {
  1066. Vector CmdPos = Game::GetCommandPos();
  1067. Caller->PushActionTurnTo(ACTION_NEWLIST, CmdPos);
  1068. Caller->PushActionSwitchAnim(ACTION_APPEND, "talkmike");
  1069. Caller->PushActionWait(ACTION_APPEND, 3.5f);
  1070. Caller->PushActionSwitchAnim(ACTION_APPEND, "idle");
  1071. if(StrCompare(Caller->GetPrototypeFileName(), OBJ_BATTALION_CHIEF) == 0)
  1072. Audio::PlaySample3D(SND_BATALSE, Caller->GetPosition());
  1073. else if(StrCompare(Caller->GetPrototypeFileName(), OBJ_EMS_CAPTAIN) == 0)
  1074. Audio::PlaySample3D(SND_EMSALSE, Caller->GetPosition());
  1075.  
  1076. bool VehicleCalled = false;
  1077. bool Engine01 = false;
  1078. bool Engine03 = false;
  1079. bool Engine05 = false;
  1080.  
  1081. GameObjectList cpl1 = Game::GetGameObjects(NAME_CONTROLPANEL);
  1082. if(cpl1.GetNumObjects() > 0)
  1083. GameObject cp1 = cpl1.GetObject(0);
  1084. GameObjectList cpl2 = Game::GetGameObjects(NAME_CONTROLPANEL2);
  1085. if(cpl2.GetNumObjects() > 0)
  1086. GameObject cp2 = cpl2.GetObject(0);
  1087. if (Math::dist(CmdPos.x, CmdPos.y, cp1.GetPosition().x, cp1.GetPosition().y) < Math::dist(CmdPos.x, CmdPos.y, cp2.GetPosition().x, cp2.GetPosition().y))
  1088. Engine01 = true;
  1089. else
  1090. Engine05 = true;
  1091.  
  1092. if (!VehicleCalled && Engine05)
  1093. {
  1094. GameObjectList l1;
  1095. Game::CollectObstaclesOnVirtualObject(VO_ENGINE05, l1, ACTOR_VEHICLE);
  1096. if(l1.GetNumObjects() > 0)
  1097. {
  1098. Vehicle v = l1.GetObject(0);
  1099. if (!v.HasCommand(DUMMY_VCALLED))
  1100. {
  1101. v.AssignCommand(DUMMY_VCALLED);
  1102. VehicleCalled = true;
  1103. } else
  1104. Engine01 = true;
  1105. } else
  1106. Engine01 = true;
  1107. }
  1108.  
  1109. if (!VehicleCalled && Engine01)
  1110. {
  1111. GameObjectList l1;
  1112. Game::CollectObstaclesOnVirtualObject(VO_ENGINE01, l1, ACTOR_VEHICLE);
  1113. if(l1.GetNumObjects() > 0)
  1114. {
  1115. Vehicle v = l1.GetObject(0);
  1116. if (!v.HasCommand(DUMMY_VCALLED))
  1117. {
  1118. v.AssignCommand(DUMMY_VCALLED);
  1119. VehicleCalled = true;
  1120. } else
  1121. Engine03 = true;
  1122. } else
  1123. Engine03 = true;
  1124. }
  1125.  
  1126. if (!VehicleCalled && Engine03)
  1127. {
  1128. GameObjectList l1;
  1129. Game::CollectObstaclesOnVirtualObject(VO_ENGINE03, l1, ACTOR_VEHICLE);
  1130. if(l1.GetNumObjects() > 0)
  1131. {
  1132. Vehicle v = l1.GetObject(0);
  1133. if (!v.HasCommand(DUMMY_VCALLED))
  1134. {
  1135. v.AssignCommand(DUMMY_VCALLED);
  1136. VehicleCalled = true;
  1137. } else
  1138. Engine05 = true;
  1139. } else
  1140. Engine05 = true;
  1141. }
  1142.  
  1143. if (!VehicleCalled && Engine01 && Engine03 && Engine05)
  1144. {
  1145. Mission::PlayHint(HINT_NOENGINE);
  1146. return;
  1147. }
  1148.  
  1149. if (VehicleCalled)
  1150. {
  1151. if (v.IsBlueLightEnabled() && (Input::LShiftPressed() || Input::RShiftPressed()))
  1152. v.EnableBlueLights(false);
  1153. else if (!v.IsBlueLightEnabled() && !Input::LShiftPressed() && !Input::RShiftPressed())
  1154. v.EnableBlueLights(true);
  1155. bool Station1 = false;
  1156. if(v.IsCollidingWithVirtualObject(VO_SQUAD01))
  1157. {
  1158. Station1 = true;
  1159. GameObjectList gate05a = Game::GetGameObjects(OBJ_GATE05A);
  1160. for(int i=0; i < gate05a.GetNumObjects(); i++)
  1161. GameObject *gate = gate05a.GetObject(i);
  1162. } else
  1163. {
  1164. GameObjectList gate07a = Game::GetGameObjects(OBJ_GATE07A);
  1165. for(int i=0; i < gate07a.GetNumObjects(); i++)
  1166. GameObject *gate = gate07a.GetObject(i);
  1167. }
  1168. PersonList passengers = v.GetPassengers();
  1169. if (passengers.GetNumPersons() == 0)
  1170. {
  1171. v.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_CALLCREW, Caller, 1, false);
  1172. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 3, false);
  1173. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 3, false);
  1174. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 3, false);
  1175. v.PushActionWait(ACTION_APPEND, 9.f);
  1176. }
  1177. if (gate->GetUserData() == 0)
  1178. {
  1179. if(Station1)
  1180. {
  1181. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  1182. float dx = 1050.f, dy = 0.f, dz = 0.f;
  1183. } else
  1184. {
  1185. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 6, false);
  1186. float dx = 470.f, dy = 0.f, dz = 0.f;
  1187. }
  1188. Vector Move = v.GetPosition();
  1189. float r[9];
  1190. float childr[9];
  1191. v.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
  1192. Math::RotateVector(dx, dy, dz, r);
  1193. Math::EulerToMatrix(0.0f, 0.f, 0.f, childr);
  1194. Math::MultiplyMatrices(childr, r);
  1195. Move = Move + Vector(dx, dy, 0);
  1196. v.PushActionWait(ACTION_APPEND, 1.2f);
  1197. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  1198. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  1199. v.PushActionMove(ACTION_APPEND, Move);
  1200. if(Station1)
  1201. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  1202. else
  1203. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 6, false);
  1204. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  1205. v.PushActionMove(ACTION_APPEND, CmdPos);
  1206. } else
  1207. {
  1208. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  1209. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  1210. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  1211. v.PushActionMove(ACTION_APPEND, CmdPos);
  1212. }
  1213. if (v.HasCommand(CMD_WARNINGLIGHTS_OFF))
  1214. {
  1215. v.EnableBlinker(BLT_NONE);
  1216. v.RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  1217. v.AssignCommand(CMD_WARNINGLIGHTS_ON);
  1218. }
  1219. if (v.HasCommand(CMD_FLOODLIGHTS_OFF))
  1220. {
  1221. v.EnableSpecialLights(false);
  1222. v.RemoveCommand(CMD_FLOODLIGHTS_OFF);
  1223. v.AssignCommand(CMD_FLOODLIGHTS_ON);
  1224. }
  1225. Mission::PlayHint(HINT_DISPATCHED);
  1226. return;
  1227. }
  1228. }
  1229. };
  1230.  
  1231. object PcmdCallEngine2 : CommandScript
  1232. {
  1233. PcmdCallEngine2()
  1234. {
  1235. SetIcon("callengine2");
  1236. SetCursor("callassistance");
  1237. SetValidTargets(ACTOR_FLOOR | ACTOR_VIRTUAL);
  1238. SetDeselectCaller(false);
  1239. SetSelfClickActivation(true);
  1240. SetHighlightingEnabled(false);
  1241. SetGroupID(CGROUP_GETEQUIPMENT);
  1242. SetGroupLeader(true);
  1243. }
  1244.  
  1245. bool CheckPossible(GameObject *Caller)
  1246. {
  1247. GameObjectList SelectPer = Game::GetSelectedGameObjects();
  1248. if (SelectPer.GetNumObjects() != 1)
  1249. return false;
  1250.  
  1251. Person p(Caller);
  1252. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  1253. return false;
  1254.  
  1255. if (p.IsCurrentAction("EActionTreatPerson"))
  1256. return false;
  1257.  
  1258. if (!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
  1259. return false;
  1260.  
  1261. return true;
  1262. }
  1263.  
  1264. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  1265. {
  1266. if(!Caller->IsValid() || Caller->GetID() == Target->GetID())
  1267. return false;
  1268.  
  1269. if (Caller->GetType() != ACTOR_PERSON)
  1270. return false;
  1271.  
  1272. Person p(Caller);
  1273. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  1274. return false;
  1275.  
  1276. if (p.IsCurrentAction("EActionTreatPerson"))
  1277. return false;
  1278.  
  1279. return true;
  1280. }
  1281.  
  1282. void PushActions(GameObject *Caller, Actor *Target, int ChildID)
  1283. {
  1284. Vector CmdPos = Game::GetCommandPos();
  1285. Caller->PushActionTurnTo(ACTION_NEWLIST, CmdPos);
  1286. Caller->PushActionSwitchAnim(ACTION_APPEND, "talkmike");
  1287. Caller->PushActionWait(ACTION_APPEND, 3.5f);
  1288. Caller->PushActionSwitchAnim(ACTION_APPEND, "idle");
  1289. if(StrCompare(Caller->GetPrototypeFileName(), OBJ_BATTALION_CHIEF) == 0)
  1290. Audio::PlaySample3D(SND_BATBLSE, Caller->GetPosition());
  1291. else if(StrCompare(Caller->GetPrototypeFileName(), OBJ_EMS_CAPTAIN) == 0)
  1292. Audio::PlaySample3D(SND_EMSBLSE, Caller->GetPosition());
  1293.  
  1294. bool VehicleCalled = false;
  1295. bool Engine04 = false;
  1296.  
  1297. if (!VehicleCalled)
  1298. {
  1299. GameObjectList l1;
  1300. Game::CollectObstaclesOnVirtualObject(VO_ENGINE02, l1, ACTOR_VEHICLE);
  1301. if(l1.GetNumObjects() > 0)
  1302. {
  1303. Vehicle v = l1.GetObject(0);
  1304. if (!v.HasCommand(DUMMY_VCALLED))
  1305. {
  1306. v.AssignCommand(DUMMY_VCALLED);
  1307. VehicleCalled = true;
  1308. } else
  1309. Engine04 = true;
  1310. } else
  1311. Engine04 = true;
  1312. }
  1313.  
  1314. if (!VehicleCalled && Engine04)
  1315. {
  1316. GameObjectList l1;
  1317. Game::CollectObstaclesOnVirtualObject(VO_ENGINE04, l1, ACTOR_VEHICLE);
  1318. if(l1.GetNumObjects() > 0)
  1319. {
  1320. Vehicle v = l1.GetObject(0);
  1321. if (!v.HasCommand(DUMMY_VCALLED))
  1322. {
  1323. v.AssignCommand(DUMMY_VCALLED);
  1324. VehicleCalled = true;
  1325. }
  1326. }
  1327. }
  1328.  
  1329. if (!VehicleCalled && Engine04)
  1330. {
  1331. Mission::PlayHint(HINT_NOENGINE);
  1332. return;
  1333. }
  1334.  
  1335. if (VehicleCalled)
  1336. {
  1337. if (v.IsBlueLightEnabled() && (Input::LShiftPressed() || Input::RShiftPressed()))
  1338. v.EnableBlueLights(false);
  1339. else if (!v.IsBlueLightEnabled() && !Input::LShiftPressed() && !Input::RShiftPressed())
  1340. v.EnableBlueLights(true);
  1341.  
  1342. GameObjectList gate04a = Game::GetGameObjects(OBJ_GATE04A);
  1343. for(int i=0; i < gate04a.GetNumObjects(); i++)
  1344. GameObject *gate = gate04a.GetObject(i);
  1345.  
  1346. PersonList passengers = v.GetPassengers();
  1347. if (passengers.GetNumPersons() == 0)
  1348. {
  1349. v.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_CALLCREW, Caller, 3, false);
  1350. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 3, false);
  1351. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 3, false);
  1352. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 3, false);
  1353. v.PushActionWait(ACTION_APPEND, 7.f);
  1354. }
  1355. if (gate->GetUserData() == 0)
  1356. {
  1357. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  1358. Vector Move = v.GetPosition();
  1359. float r[9];
  1360. float childr[9];
  1361. v.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
  1362. float dx = 1050.f, dy = 0.f, dz = 0.f;
  1363. Math::RotateVector(dx, dy, dz, r);
  1364. Math::EulerToMatrix(0.0f, 0.f, 0.f, childr);
  1365. Math::MultiplyMatrices(childr, r);
  1366. Move = Move + Vector(dx, dy, 0);
  1367. v.PushActionWait(ACTION_APPEND, 1.2f);
  1368. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  1369. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  1370. v.PushActionMove(ACTION_APPEND, Move);
  1371. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  1372. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  1373. v.PushActionMove(ACTION_APPEND, CmdPos);
  1374. } else
  1375. {
  1376. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  1377. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  1378. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  1379. v.PushActionMove(ACTION_APPEND, CmdPos);
  1380. }
  1381. if (v.HasCommand(CMD_WARNINGLIGHTS_OFF))
  1382. {
  1383. v.EnableBlinker(BLT_NONE);
  1384. v.RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  1385. v.AssignCommand(CMD_WARNINGLIGHTS_ON);
  1386. }
  1387. if (v.HasCommand(CMD_FLOODLIGHTS_OFF))
  1388. {
  1389. v.EnableSpecialLights(false);
  1390. v.RemoveCommand(CMD_FLOODLIGHTS_OFF);
  1391. v.AssignCommand(CMD_FLOODLIGHTS_ON);
  1392. }
  1393. Mission::PlayHint(HINT_DISPATCHED);
  1394. return;
  1395. }
  1396. }
  1397. };
  1398.  
  1399.  
  1400. object PcmdCallLightForce : CommandScript
  1401. {
  1402. PcmdCallLightForce()
  1403. {
  1404. SetIcon("calllightforce1");
  1405. SetCursor("callassistance");
  1406. SetValidTargets(ACTOR_FLOOR | ACTOR_VIRTUAL);
  1407. SetDeselectCaller(false);
  1408. SetSelfClickActivation(true);
  1409. SetHighlightingEnabled(false);
  1410. SetGroupID(CGROUP_GETEQUIPMENT);
  1411. SetGroupLeader(true);
  1412. }
  1413.  
  1414. bool CheckPossible(GameObject *Caller)
  1415. {
  1416. GameObjectList SelectPer = Game::GetSelectedGameObjects();
  1417. if (SelectPer.GetNumObjects() != 1)
  1418. return false;
  1419.  
  1420. Person p(Caller);
  1421. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  1422. return false;
  1423.  
  1424. if (p.IsCurrentAction("EActionTreatPerson"))
  1425. return false;
  1426.  
  1427. if (!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
  1428. return false;
  1429.  
  1430. return true;
  1431. }
  1432.  
  1433. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  1434. {
  1435. if(!Caller->IsValid() || Caller->GetID() == Target->GetID())
  1436. return false;
  1437.  
  1438. if (Caller->GetType() != ACTOR_PERSON)
  1439. return false;
  1440.  
  1441. Person p(Caller);
  1442. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  1443. return false;
  1444.  
  1445. if (p.IsCurrentAction("EActionTreatPerson"))
  1446. return false;
  1447.  
  1448. return true;
  1449. }
  1450.  
  1451. void PushActions(GameObject *Caller, Actor *Target, int ChildID)
  1452. {
  1453. Vector CmdPos = Game::GetCommandPos();
  1454. Caller->PushActionTurnTo(ACTION_NEWLIST, CmdPos);
  1455. Caller->PushActionSwitchAnim(ACTION_APPEND, "talkmike");
  1456. Caller->PushActionWait(ACTION_APPEND, 3.5f);
  1457. Caller->PushActionSwitchAnim(ACTION_APPEND, "idle");
  1458. if(StrCompare(Caller->GetPrototypeFileName(), OBJ_BATTALION_CHIEF) == 0)
  1459. Audio::PlaySample3D(SND_BATLIGHTFORCE, Caller->GetPosition());
  1460. else if(StrCompare(Caller->GetPrototypeFileName(), OBJ_EMS_CAPTAIN) == 0)
  1461. Audio::PlaySample3D(SND_EMSLIGHTFORCE, Caller->GetPosition());
  1462.  
  1463. Vehicle *theCar = NULL;
  1464. float bestCar = 0.;
  1465. VehicleList patrolCars(VT_FIREFIGHTERS_DLK, VT_FIREFIGHTERS_RW);
  1466. for (int i = 0; i < patrolCars.GetNumVehicles(); i++)
  1467. {
  1468. Vehicle *aCar = patrolCars.GetVehicle(i);
  1469. if ((StrCompare(aCar->GetPrototypeFileName(), OBJ_TILLER) == 0) && aCar->GetPlayerMP() == Caller->GetPlayerMP() && !aCar->HasCommand(DUMMY_VCALLED) && !aCar->IsInstalled() && (aCar->HasCommand(CMD_STANDBY_OFF) || aCar->IsCollidingWithVirtualObject(VO_SQUAD01)))
  1470. {
  1471. float distCurrCar = Math::dist(CmdPos.x, CmdPos.y, aCar->GetPosition().x, aCar->GetPosition().y);
  1472. if (distCurrCar < bestCar || bestCar == 0.)
  1473. {
  1474. theCar = aCar;
  1475. bestCar = distCurrCar;
  1476. }
  1477. }
  1478. }
  1479. if (theCar)
  1480. {
  1481. bool VehicleCalled = false;
  1482. if (theCar->HasCommand(CMD_STANDBY_OFF))
  1483. {
  1484. theCar->PushActionWait(ACTION_NEWLIST, 0.3f);
  1485. theCar->PushActionMove(ACTION_APPEND, CmdPos);
  1486. if (!theCar->HasCommand(DUMMY_HASSIREN) && theCar->HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  1487. Game::ExecuteCommand(CMD_SIREN, theCar, theCar);
  1488. if (theCar->HasCommand(CMD_STANDBY_OFF))
  1489. {
  1490. theCar->RemoveCommand(CMD_STANDBY_OFF);
  1491. theCar->AssignCommand(CMD_STANDBY_ON);
  1492. }
  1493. if (theCar->HasCommand(CMD_WARNINGLIGHTS_OFF))
  1494. {
  1495. theCar->EnableBlinker(BLT_NONE);
  1496. theCar->RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  1497. theCar->AssignCommand(CMD_WARNINGLIGHTS_ON);
  1498. }
  1499. if (theCar->HasCommand(CMD_FLOODLIGHTS_OFF))
  1500. {
  1501. theCar->EnableSpecialLights(false);
  1502. theCar->RemoveCommand(CMD_FLOODLIGHTS_OFF);
  1503. theCar->AssignCommand(CMD_FLOODLIGHTS_ON);
  1504. }
  1505. Mission::PlayHint(HINT_DISPATCHED);
  1506. return;
  1507. }
  1508. else if (theCar->IsCollidingWithVirtualObject(VO_SQUAD01))
  1509. {
  1510. GameObjectList ppc;
  1511. Game::CollectObstaclesOnVirtualObject(VO_TILLER, ppc, ACTOR_VEHICLE);
  1512. for (int i = 0; i < ppc.GetNumObjects(); i++)
  1513. {
  1514. Vehicle v = ppc.GetObject(i);
  1515. if (!v.HasCommand(DUMMY_VCALLED))
  1516. {
  1517. v.AssignCommand(DUMMY_VCALLED);
  1518. VehicleCalled = true;
  1519. }
  1520. }
  1521. }
  1522. if (VehicleCalled)
  1523. {
  1524. if (v.IsBlueLightEnabled() && (Input::LShiftPressed() || Input::RShiftPressed()))
  1525. v.EnableBlueLights(false);
  1526. else if (!v.IsBlueLightEnabled() && !Input::LShiftPressed() && !Input::RShiftPressed())
  1527. v.EnableBlueLights(true);
  1528. GameObjectList gate03a = Game::GetGameObjects(OBJ_GATE03A);
  1529. for(int i=0; i < gate03a.GetNumObjects(); i++)
  1530. GameObject *gate = gate03a.GetObject(i);
  1531.  
  1532. PersonList passengers = v.GetPassengers();
  1533. if (passengers.GetNumPersons() == 0)
  1534. {
  1535. v.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_CALLCREW, Caller, 3, false);
  1536. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 3, false);
  1537. v.PushActionWait(ACTION_APPEND, 10.f);
  1538. }
  1539. if (gate->GetUserData() == 0)
  1540. {
  1541. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  1542. Vector Move = v.GetPosition();
  1543. float r[9];
  1544. float childr[9];
  1545. v.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
  1546. float dx = 750.f, dy = 0.f, dz = 0.f;
  1547. Math::RotateVector(dx, dy, dz, r);
  1548. Math::EulerToMatrix(0.0f, 0.f, 0.f, childr);
  1549. Math::MultiplyMatrices(childr, r);
  1550. Move = Move + Vector(dx, dy, 0);
  1551. v.PushActionWait(ACTION_APPEND, 1.2f);
  1552. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  1553. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  1554. v.PushActionMove(ACTION_APPEND, Move);
  1555. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  1556. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  1557. v.PushActionMove(ACTION_APPEND, CmdPos);
  1558. } else
  1559. {
  1560. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  1561. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  1562. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  1563. v.PushActionMove(ACTION_APPEND, CmdPos);
  1564. }
  1565. if (v.HasCommand(CMD_STANDBY_OFF))
  1566. {
  1567. v.RemoveCommand(CMD_STANDBY_OFF);
  1568. v.AssignCommand(CMD_STANDBY_ON);
  1569. }
  1570. if (v.HasCommand(CMD_WARNINGLIGHTS_OFF))
  1571. {
  1572. v.EnableBlinker(BLT_NONE);
  1573. v.RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  1574. v.AssignCommand(CMD_WARNINGLIGHTS_ON);
  1575. }
  1576. if (v.HasCommand(CMD_FLOODLIGHTS_OFF))
  1577. {
  1578. v.EnableSpecialLights(false);
  1579. v.RemoveCommand(CMD_FLOODLIGHTS_OFF);
  1580. v.AssignCommand(CMD_FLOODLIGHTS_ON);
  1581. }
  1582. Mission::PlayHint(HINT_DISPATCHED);
  1583.  
  1584. if (Input::LCtrlPressed() || Input::RCtrlPressed())
  1585. return;
  1586.  
  1587. bool Vehicle2Called = false;
  1588. bool Engine04 = false;
  1589. if (!Vehicle2Called)
  1590. {
  1591. GameObjectList l1;
  1592. Game::CollectObstaclesOnVirtualObject(VO_ENGINE02, l1, ACTOR_VEHICLE);
  1593. if(l1.GetNumObjects() > 0)
  1594. {
  1595. Vehicle e = l1.GetObject(0);
  1596. if (!e.HasCommand(DUMMY_VCALLED))
  1597. {
  1598. e.AssignCommand(DUMMY_VCALLED);
  1599. Vehicle2Called = true;
  1600. } else
  1601. Engine04 = true;
  1602. } else
  1603. Engine04 = true;
  1604. }
  1605. if (!Vehicle2Called && Engine04)
  1606. {
  1607. GameObjectList l1;
  1608. Game::CollectObstaclesOnVirtualObject(VO_ENGINE04, l1, ACTOR_VEHICLE);
  1609. if(l1.GetNumObjects() > 0)
  1610. {
  1611. Vehicle e = l1.GetObject(0);
  1612. if (!e.HasCommand(DUMMY_VCALLED))
  1613. {
  1614. e.AssignCommand(DUMMY_VCALLED);
  1615. Vehicle2Called = true;
  1616. }
  1617. }
  1618. }
  1619. if (!Vehicle2Called && Engine04)
  1620. {
  1621. Mission::PlayHint(HINT_NOENGINE);
  1622. return;
  1623. }
  1624. if (Vehicle2Called)
  1625. {
  1626. if (e.IsBlueLightEnabled() && (Input::LShiftPressed() || Input::RShiftPressed()))
  1627. e.EnableBlueLights(false);
  1628. else if (!e.IsBlueLightEnabled() && !Input::LShiftPressed() && !Input::RShiftPressed())
  1629. e.EnableBlueLights(true);
  1630.  
  1631. GameObjectList gate05a = Game::GetGameObjects(OBJ_GATE04A);
  1632. for(int i=0; i < gate05a.GetNumObjects(); i++)
  1633. GameObject *gate = gate05a.GetObject(i);
  1634.  
  1635. PersonList passengers = e.GetPassengers();
  1636. if (passengers.GetNumPersons() == 0)
  1637. {
  1638. e.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_CALLCREW, Caller, 3, false);
  1639. e.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 3, false);
  1640. e.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 3, false);
  1641. e.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 3, false);
  1642. e.PushActionWait(ACTION_APPEND, 7.f);
  1643. }
  1644. if (gate->GetUserData() == 0)
  1645. {
  1646. e.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  1647. Vector Move = e.GetPosition();
  1648. float r[9];
  1649. float childr[9];
  1650. e.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
  1651. float dx = 1050.f, dy = 0.f, dz = 0.f;
  1652. Math::RotateVector(dx, dy, dz, r);
  1653. Math::EulerToMatrix(0.0f, 0.f, 0.f, childr);
  1654. Math::MultiplyMatrices(childr, r);
  1655. Move = Move + Vector(dx, dy, 0);
  1656. e.PushActionWait(ACTION_APPEND, 1.2f);
  1657. if (!e.HasCommand(DUMMY_HASSIREN) && e.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  1658. e.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  1659. e.PushActionMove(ACTION_APPEND, Move);
  1660. e.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  1661. e.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  1662. e.PushActionMove(ACTION_APPEND, CmdPos);
  1663. } else
  1664. {
  1665. if (!e.HasCommand(DUMMY_HASSIREN) && e.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  1666. e.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  1667. e.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  1668. e.PushActionMove(ACTION_APPEND, CmdPos);
  1669. }
  1670. if (e.HasCommand(CMD_STANDBY_OFF))
  1671. {
  1672. e.RemoveCommand(CMD_STANDBY_OFF);
  1673. e.AssignCommand(CMD_STANDBY_ON);
  1674. }
  1675. if (e.HasCommand(CMD_WARNINGLIGHTS_OFF))
  1676. {
  1677. e.EnableBlinker(BLT_NONE);
  1678. e.RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  1679. e.AssignCommand(CMD_WARNINGLIGHTS_ON);
  1680. }
  1681. if (e.HasCommand(CMD_FLOODLIGHTS_OFF))
  1682. {
  1683. e.EnableSpecialLights(false);
  1684. e.RemoveCommand(CMD_FLOODLIGHTS_OFF);
  1685. e.AssignCommand(CMD_FLOODLIGHTS_ON);
  1686. }
  1687. return;
  1688. }
  1689. }
  1690. }
  1691. Vector Spawn;
  1692. Vector Rotate;
  1693. ActorList l1 = Game::GetActors(VO_SPAWN_ALL);
  1694. ActorList l2 = Game::GetActors(VO_SPAWN_FD);
  1695. ActorList l3 = Game::GetActors(VO_SPAWN_ALLR);
  1696. ActorList l4 = Game::GetActors(VO_SPAWN_FDR);
  1697. if(l1.GetNumActors() > 0)
  1698. {
  1699. Spawn = l1.GetActor(0)->GetPosition();
  1700. Rotate = l3.GetActor(0)->GetPosition();
  1701. }
  1702. else if(l2.GetNumActors() > 0)
  1703. {
  1704. Spawn = l2.GetActor(0)->GetPosition();
  1705. Rotate = l4.GetActor(0)->GetPosition();
  1706. }
  1707. else
  1708. {
  1709. Mission::PlayHint(HINT_NOLADDER);
  1710. return;
  1711. }
  1712.  
  1713. System::Log("Buy light force engine");
  1714. bool BuyAerialOnly = false;
  1715. int Money = Mission::GetMoneyLeft();
  1716. if (Money <= 4000)
  1717. {
  1718. Mission::PlayHint(HINT_NOLADDER);
  1719. return;
  1720. }
  1721. else if (Input::LCtrlPressed() || Input::RCtrlPressed())
  1722. BuyAerialOnly = true;
  1723. else if (Money <= 8000)
  1724. BuyAerialOnly = true;
  1725. if (BuyAerialOnly)
  1726. int NewMoney = Money - 4000;
  1727. else
  1728. int NewMoney = Money - 8000;
  1729. Mission::SetMoney(NewMoney);
  1730.  
  1731. Vehicle n;
  1732. Person p1;
  1733. Person p2;
  1734. n = Game::CreateVehicle(OBJ_LADDER, UNNAMED);
  1735. n.SetSpeed(9.0f);
  1736. p1 = Game::CreatePerson(OBJ_EMT, UNNAMED);
  1737. p2 = Game::CreatePerson(OBJ_EMT, UNNAMED);
  1738. n.SetPlayerMP(Caller->GetPlayerMP());
  1739. p1.SetPlayerMP(Caller->GetPlayerMP());
  1740. p2.SetPlayerMP(Caller->GetPlayerMP());
  1741. p1.SetUpgradeLevel(3);
  1742. p2.SetUpgradeLevel(3);
  1743. n.SetMaxPassengers(6);
  1744. n.SetMaxTransports(0);
  1745. n.AddPassenger(&p1);
  1746. n.AddPassenger(&p2);
  1747. n.SetPosition(Spawn);
  1748. n.UpdatePlacement();
  1749. n.Hide();
  1750. n.PushActionTurnTo(ACTION_NEWLIST, Rotate);
  1751. n.PushActionWait(ACTION_APPEND, 3.5f);
  1752. n.PushActionShowHide(ACTION_APPEND, false);
  1753. n.PushActionMove(ACTION_APPEND, CmdPos);
  1754. if (Game::IsMission())
  1755. n.RemoveCommand("VcmdToFireStation");
  1756.  
  1757. if (!n.HasCommand(DUMMY_HASSIREN) && n.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  1758. Game::ExecuteCommand(CMD_SIREN, &n, &n);
  1759.  
  1760. if (BuyAerialOnly)
  1761. Mission::PlayHint(HINT_LADDERBOUGHT);
  1762. else if (!BuyAerialOnly)
  1763. {
  1764. Vehicle m;
  1765. Person p3;
  1766. Person p4;
  1767. Person p5;
  1768. Person p6;
  1769. m = Game::CreateVehicle(OBJ_ENGINE02, UNNAMED);
  1770. m.SetSpeed(9.0f);
  1771. p3 = Game::CreatePerson(OBJ_EMT, UNNAMED);
  1772. p4 = Game::CreatePerson(OBJ_EMT, UNNAMED);
  1773. p5 = Game::CreatePerson(OBJ_EMT, UNNAMED);
  1774. p6 = Game::CreatePerson(OBJ_EMT, UNNAMED);
  1775. m.SetPlayerMP(Caller->GetPlayerMP());
  1776. p3.SetPlayerMP(Caller->GetPlayerMP());
  1777. p4.SetPlayerMP(Caller->GetPlayerMP());
  1778. p5.SetPlayerMP(Caller->GetPlayerMP());
  1779. p6.SetPlayerMP(Caller->GetPlayerMP());
  1780. p3.SetUpgradeLevel(3);
  1781. p4.SetUpgradeLevel(3);
  1782. p5.SetUpgradeLevel(3);
  1783. p6.SetUpgradeLevel(3);
  1784. m.SetMaxPassengers(6);
  1785. m.SetMaxTransports(0);
  1786. m.AddPassenger(&p3);
  1787. m.AddPassenger(&p4);
  1788. m.AddPassenger(&p5);
  1789. m.AddPassenger(&p6);
  1790. m.SetPosition(Spawn);
  1791. m.UpdatePlacement();
  1792. m.Hide();
  1793. m.PushActionTurnTo(ACTION_NEWLIST, Rotate);
  1794. m.PushActionWait(ACTION_APPEND, 1.0f);
  1795. m.PushActionShowHide(ACTION_APPEND, false);
  1796. m.PushActionMove(ACTION_APPEND, CmdPos);
  1797. if (Game::IsMission())
  1798. m.RemoveCommand("VcmdToFireStation");
  1799.  
  1800. if (!m.HasCommand(DUMMY_HASSIREN) && m.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  1801. Game::ExecuteCommand(CMD_SIREN, &m, &m);
  1802.  
  1803. Mission::PlayHint(HINT_LIGHTFORCEBOUGHT);
  1804. }
  1805. }
  1806. };
  1807.  
  1808. object PcmdCallTowerLightForce : CommandScript
  1809. {
  1810. PcmdCallTowerLightForce()
  1811. {
  1812. SetIcon("calllightforce2");
  1813. SetCursor("callassistance");
  1814. SetValidTargets(ACTOR_FLOOR | ACTOR_VIRTUAL);
  1815. SetDeselectCaller(false);
  1816. SetSelfClickActivation(true);
  1817. SetHighlightingEnabled(false);
  1818. SetGroupID(CGROUP_GETEQUIPMENT);
  1819. SetGroupLeader(true);
  1820. }
  1821.  
  1822. bool CheckPossible(GameObject *Caller)
  1823. {
  1824. GameObjectList SelectPer = Game::GetSelectedGameObjects();
  1825. if (SelectPer.GetNumObjects() != 1)
  1826. return false;
  1827.  
  1828. Person p(Caller);
  1829. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  1830. return false;
  1831.  
  1832. if (p.IsCurrentAction("EActionTreatPerson"))
  1833. return false;
  1834.  
  1835. if (!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
  1836. return false;
  1837.  
  1838. return true;
  1839. }
  1840.  
  1841. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  1842. {
  1843. if(!Caller->IsValid() || Caller->GetID() == Target->GetID())
  1844. return false;
  1845.  
  1846. if (Caller->GetType() != ACTOR_PERSON)
  1847. return false;
  1848.  
  1849. Person p(Caller);
  1850. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  1851. return false;
  1852.  
  1853. if (p.IsCurrentAction("EActionTreatPerson"))
  1854. return false;
  1855.  
  1856. return true;
  1857. }
  1858.  
  1859. void PushActions(GameObject *Caller, Actor *Target, int ChildID)
  1860. {
  1861. Vector CmdPos = Game::GetCommandPos();
  1862. Caller->PushActionTurnTo(ACTION_NEWLIST, CmdPos);
  1863. Caller->PushActionSwitchAnim(ACTION_APPEND, "talkmike");
  1864. Caller->PushActionWait(ACTION_APPEND, 3.5f);
  1865. Caller->PushActionSwitchAnim(ACTION_APPEND, "idle");
  1866. if(StrCompare(Caller->GetPrototypeFileName(), OBJ_BATTALION_CHIEF) == 0)
  1867. Audio::PlaySample3D(SND_BATLIGHTFORCE, Caller->GetPosition());
  1868. else if(StrCompare(Caller->GetPrototypeFileName(), OBJ_EMS_CAPTAIN) == 0)
  1869. Audio::PlaySample3D(SND_EMSLIGHTFORCE, Caller->GetPosition());
  1870.  
  1871. Vehicle *theCar = NULL;
  1872. float bestCar = 0.;
  1873. VehicleList patrolCars(VT_FIREFIGHTERS_DLK, VT_FIREFIGHTERS_RW);
  1874. for (int i = 0; i < patrolCars.GetNumVehicles(); i++)
  1875. {
  1876. Vehicle *aCar = patrolCars.GetVehicle(i);
  1877. if ((StrCompare(aCar->GetPrototypeFileName(), OBJ_LADDER) == 0) && aCar->GetPlayerMP() == Caller->GetPlayerMP() && !aCar->HasCommand(DUMMY_VCALLED) && !aCar->IsInstalled() && (aCar->HasCommand(CMD_STANDBY_OFF) || aCar->IsCollidingWithVirtualObject(VO_SQUAD02)))
  1878. {
  1879. float distCurrCar = Math::dist(CmdPos.x, CmdPos.y, aCar->GetPosition().x, aCar->GetPosition().y);
  1880. if (distCurrCar < bestCar || bestCar == 0.)
  1881. {
  1882. theCar = aCar;
  1883. bestCar = distCurrCar;
  1884. }
  1885. }
  1886. }
  1887. if (theCar)
  1888. {
  1889. bool VehicleCalled = false;
  1890. if (theCar->HasCommand(CMD_STANDBY_OFF))
  1891. {
  1892. theCar->PushActionWait(ACTION_NEWLIST, 0.3f);
  1893. theCar->PushActionMove(ACTION_APPEND, CmdPos);
  1894. if (!theCar->HasCommand(DUMMY_HASSIREN) && theCar->HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  1895. Game::ExecuteCommand(CMD_SIREN, theCar, theCar);
  1896. if (theCar->HasCommand(CMD_STANDBY_OFF))
  1897. {
  1898. theCar->RemoveCommand(CMD_STANDBY_OFF);
  1899. theCar->AssignCommand(CMD_STANDBY_ON);
  1900. }
  1901. if (theCar->HasCommand(CMD_WARNINGLIGHTS_OFF))
  1902. {
  1903. theCar->EnableBlinker(BLT_NONE);
  1904. theCar->RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  1905. theCar->AssignCommand(CMD_WARNINGLIGHTS_ON);
  1906. }
  1907. Mission::PlayHint(HINT_DISPATCHED);
  1908. return;
  1909. }
  1910. else if (theCar->IsCollidingWithVirtualObject(VO_SQUAD02))
  1911. {
  1912. GameObjectList ppc;
  1913. Game::CollectObstaclesOnVirtualObject(VO_LADDER, ppc, ACTOR_VEHICLE);
  1914. for (int i = 0; i < ppc.GetNumObjects(); i++)
  1915. {
  1916. Vehicle v = ppc.GetObject(i);
  1917. if (!v.HasCommand(DUMMY_VCALLED))
  1918. {
  1919. v.AssignCommand(DUMMY_VCALLED);
  1920. VehicleCalled = true;
  1921. }
  1922. }
  1923. }
  1924. if (VehicleCalled)
  1925. {
  1926. if (v.IsBlueLightEnabled() && (Input::LShiftPressed() || Input::RShiftPressed()))
  1927. v.EnableBlueLights(false);
  1928. else if (!v.IsBlueLightEnabled() && !Input::LShiftPressed() && !Input::RShiftPressed())
  1929. v.EnableBlueLights(true);
  1930. GameObjectList gate06a = Game::GetGameObjects(OBJ_GATE06A);
  1931. for(int i=0; i < gate06a.GetNumObjects(); i++)
  1932. GameObject *gate = gate06a.GetObject(i);
  1933.  
  1934. PersonList passengers = v.GetPassengers();
  1935. if (passengers.GetNumPersons() == 0)
  1936. {
  1937. v.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_CALLCREW, Caller, 3, false);
  1938. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 3, false);
  1939. v.PushActionWait(ACTION_APPEND, 10.f);
  1940. }
  1941. if (gate->GetUserData() == 0)
  1942. {
  1943. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  1944. Vector Move = v.GetPosition();
  1945. float r[9];
  1946. float childr[9];
  1947. v.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
  1948. float dx = 750.f, dy = 0.f, dz = 0.f;
  1949. Math::RotateVector(dx, dy, dz, r);
  1950. Math::EulerToMatrix(0.0f, 0.f, 0.f, childr);
  1951. Math::MultiplyMatrices(childr, r);
  1952. Move = Move + Vector(dx, dy, 0);
  1953. v.PushActionWait(ACTION_APPEND, 1.2f);
  1954. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  1955. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  1956. v.PushActionMove(ACTION_APPEND, Move);
  1957. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  1958. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  1959. v.PushActionMove(ACTION_APPEND, CmdPos);
  1960. } else
  1961. {
  1962. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  1963. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  1964. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  1965. v.PushActionMove(ACTION_APPEND, CmdPos);
  1966. }
  1967. if (v.HasCommand(CMD_WARNINGLIGHTS_OFF))
  1968. {
  1969. v.EnableBlinker(BLT_NONE);
  1970. v.RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  1971. v.AssignCommand(CMD_WARNINGLIGHTS_ON);
  1972. }
  1973. if (v.HasCommand(CMD_FLOODLIGHTS_OFF))
  1974. {
  1975. v.EnableSpecialLights(false);
  1976. v.RemoveCommand(CMD_FLOODLIGHTS_OFF);
  1977. v.AssignCommand(CMD_FLOODLIGHTS_ON);
  1978. }
  1979. Mission::PlayHint(HINT_DISPATCHED);
  1980.  
  1981. if (Input::LCtrlPressed() || Input::RCtrlPressed())
  1982. return;
  1983.  
  1984. bool Vehicle2Called = false;
  1985. bool Engine04 = false;
  1986.  
  1987. if (!Vehicle2Called)
  1988. {
  1989. GameObjectList l1;
  1990. Game::CollectObstaclesOnVirtualObject(VO_ENGINE05, l1, ACTOR_VEHICLE);
  1991. if(l1.GetNumObjects() > 0)
  1992. {
  1993. Vehicle e = l1.GetObject(0);
  1994. if (!e.HasCommand(DUMMY_VCALLED))
  1995. {
  1996. e.AssignCommand(DUMMY_VCALLED);
  1997. Vehicle2Called = true;
  1998. } else
  1999. Engine04 = true;
  2000. } else
  2001. Engine04 = true;
  2002. }
  2003.  
  2004. if (!Vehicle2Called && Engine04)
  2005. {
  2006. GameObjectList l1;
  2007. Game::CollectObstaclesOnVirtualObject(VO_ENGINE01, l1, ACTOR_VEHICLE);
  2008. if(l1.GetNumObjects() > 0)
  2009. {
  2010. Vehicle e = l1.GetObject(0);
  2011. if (!e.HasCommand(DUMMY_VCALLED))
  2012. {
  2013. e.AssignCommand(DUMMY_VCALLED);
  2014. Vehicle2Called = true;
  2015. }
  2016. }
  2017. }
  2018.  
  2019. if (!Vehicle2Called && Engine04)
  2020. {
  2021. GameObjectList l1;
  2022. Game::CollectObstaclesOnVirtualObject(VO_ENGINE03, l1, ACTOR_VEHICLE);
  2023. if(l1.GetNumObjects() > 0)
  2024. {
  2025. Vehicle e = l1.GetObject(0);
  2026. if (!e.HasCommand(DUMMY_VCALLED))
  2027. {
  2028. e.AssignCommand(DUMMY_VCALLED);
  2029. Vehicle2Called = true;
  2030. }
  2031. }
  2032. else
  2033. {
  2034. Mission::PlayHint(HINT_NOENGINE);
  2035. return;
  2036. }
  2037. }
  2038.  
  2039.  
  2040.  
  2041. if (Vehicle2Called)
  2042. {
  2043. if (e.IsBlueLightEnabled() && (Input::LShiftPressed() || Input::RShiftPressed()))
  2044. e.EnableBlueLights(false);
  2045. else if (!e.IsBlueLightEnabled() && !Input::LShiftPressed() && !Input::RShiftPressed())
  2046. e.EnableBlueLights(true);
  2047.  
  2048. if(v.IsCollidingWithVirtualObject(VO_SQUAD01))
  2049. {
  2050. Station1 = true;
  2051. GameObjectList gate05a = Game::GetGameObjects(OBJ_GATE05A);
  2052. for(int i=0; i < gate05a.GetNumObjects(); i++)
  2053. GameObject *gate = gate05a.GetObject(i);
  2054. }
  2055. else if(v.IsCollidingWithVirtualObject(VO_SQUAD02))
  2056. {
  2057. GameObjectList gate07a = Game::GetGameObjects(OBJ_GATE07A);
  2058. for(int i=0; i < gate07a.GetNumObjects(); i++)
  2059. GameObject *gate = gate07a.GetObject(i);
  2060. }
  2061.  
  2062. PersonList passengers = e.GetPassengers();
  2063. if (passengers.GetNumPersons() == 0)
  2064. {
  2065. e.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_CALLCREW, Caller, 1, false);
  2066. e.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 3, false);
  2067. e.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 3, false);
  2068. e.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 3, false);
  2069. e.PushActionWait(ACTION_APPEND, 7.f);
  2070. }
  2071. if (gate->GetUserData() == 0)
  2072. {
  2073. e.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  2074. Vector Move = e.GetPosition();
  2075. float r[9];
  2076. float childr[9];
  2077. e.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
  2078. float dx = 1050.f, dy = 0.f, dz = 0.f;
  2079. Math::RotateVector(dx, dy, dz, r);
  2080. Math::EulerToMatrix(0.0f, 0.f, 0.f, childr);
  2081. Math::MultiplyMatrices(childr, r);
  2082. Move = Move + Vector(dx, dy, 0);
  2083. e.PushActionWait(ACTION_APPEND, 1.2f);
  2084. if (!e.HasCommand(DUMMY_HASSIREN) && e.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  2085. e.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  2086. e.PushActionMove(ACTION_APPEND, Move);
  2087. e.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  2088. e.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  2089. e.PushActionMove(ACTION_APPEND, CmdPos);
  2090. } else
  2091. {
  2092. if (!e.HasCommand(DUMMY_HASSIREN) && e.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  2093. e.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  2094. e.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  2095. e.PushActionMove(ACTION_APPEND, CmdPos);
  2096. }
  2097. if (e.HasCommand(CMD_WARNINGLIGHTS_OFF))
  2098. {
  2099. e.EnableBlinker(BLT_NONE);
  2100. e.RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  2101. e.AssignCommand(CMD_WARNINGLIGHTS_ON);
  2102. }
  2103. if (e.HasCommand(CMD_FLOODLIGHTS_OFF))
  2104. {
  2105. e.EnableSpecialLights(false);
  2106. e.RemoveCommand(CMD_FLOODLIGHTS_OFF);
  2107. e.AssignCommand(CMD_FLOODLIGHTS_ON);
  2108. }
  2109. Mission::PlayHint(HINT_DISPATCHED);
  2110. return;
  2111. }
  2112. }
  2113. }
  2114. Vector Spawn;
  2115. Vector Rotate;
  2116. ActorList l1 = Game::GetActors(VO_SPAWN_ALL);
  2117. ActorList l2 = Game::GetActors(VO_SPAWN_FD);
  2118. ActorList l3 = Game::GetActors(VO_SPAWN_ALLR);
  2119. ActorList l4 = Game::GetActors(VO_SPAWN_FDR);
  2120. if(l1.GetNumActors() > 0)
  2121. {
  2122. Spawn = l1.GetActor(0)->GetPosition();
  2123. Rotate = l3.GetActor(0)->GetPosition();
  2124. }
  2125. else if(l2.GetNumActors() > 0)
  2126. {
  2127. Spawn = l2.GetActor(0)->GetPosition();
  2128. Rotate = l4.GetActor(0)->GetPosition();
  2129. }
  2130. else
  2131. {
  2132. Mission::PlayHint(HINT_NOLADDER);
  2133. return;
  2134. }
  2135.  
  2136. System::Log("Buy light force engine");
  2137. bool BuyAerialOnly = false;
  2138. int Money = Mission::GetMoneyLeft();
  2139. if (Money <= 4000)
  2140. {
  2141. Mission::PlayHint(HINT_NOLADDER);
  2142. return;
  2143. }
  2144. else if (Input::LCtrlPressed() || Input::RCtrlPressed())
  2145. BuyAerialOnly = true;
  2146. else if (Money <= 8000)
  2147. BuyAerialOnly = true;
  2148. if (BuyAerialOnly)
  2149. int NewMoney = Money - 4000;
  2150. else
  2151. int NewMoney = Money - 8000;
  2152. Mission::SetMoney(NewMoney);
  2153.  
  2154. Vehicle n;
  2155. Person p1;
  2156. Person p2;
  2157. n = Game::CreateVehicle(OBJ_LADDER, UNNAMED);
  2158. n.SetSpeed(9.0f);
  2159. p1 = Game::CreatePerson(OBJ_EMT, UNNAMED);
  2160. p2 = Game::CreatePerson(OBJ_EMT, UNNAMED);
  2161. n.SetPlayerMP(Caller->GetPlayerMP());
  2162. p1.SetPlayerMP(Caller->GetPlayerMP());
  2163. p2.SetPlayerMP(Caller->GetPlayerMP());
  2164. p1.SetUpgradeLevel(3);
  2165. p2.SetUpgradeLevel(3);
  2166. n.SetMaxPassengers(6);
  2167. n.SetMaxTransports(0);
  2168. n.AddPassenger(&p1);
  2169. n.AddPassenger(&p2);
  2170. n.SetPosition(Spawn);
  2171. n.UpdatePlacement();
  2172. n.Hide();
  2173. n.PushActionTurnTo(ACTION_NEWLIST, Rotate);
  2174. n.PushActionWait(ACTION_APPEND, 3.5f);
  2175. n.PushActionShowHide(ACTION_APPEND, false);
  2176. n.PushActionMove(ACTION_APPEND, CmdPos);
  2177. if (Game::IsMission())
  2178. n.RemoveCommand("VcmdToFireStation");
  2179.  
  2180. if (!n.HasCommand(DUMMY_HASSIREN) && n.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  2181. Game::ExecuteCommand(CMD_SIREN, &n, &n);
  2182.  
  2183. if (BuyAerialOnly)
  2184. Mission::PlayHint(HINT_LADDERBOUGHT);
  2185. else if (!BuyAerialOnly)
  2186. {
  2187. Vehicle m;
  2188. Person p3;
  2189. Person p4;
  2190. Person p5;
  2191. Person p6;
  2192. m = Game::CreateVehicle(OBJ_ENGINE17, UNNAMED);
  2193. m.SetSpeed(9.0f);
  2194. p3 = Game::CreatePerson(OBJ_PM, UNNAMED);
  2195. p4 = Game::CreatePerson(OBJ_EMT, UNNAMED);
  2196. p5 = Game::CreatePerson(OBJ_EMT, UNNAMED);
  2197. p6 = Game::CreatePerson(OBJ_EMT, UNNAMED);
  2198. m.SetPlayerMP(Caller->GetPlayerMP());
  2199. p3.SetPlayerMP(Caller->GetPlayerMP());
  2200. p4.SetPlayerMP(Caller->GetPlayerMP());
  2201. p5.SetPlayerMP(Caller->GetPlayerMP());
  2202. p6.SetPlayerMP(Caller->GetPlayerMP());
  2203. p3.SetUpgradeLevel(3);
  2204. p4.SetUpgradeLevel(3);
  2205. p5.SetUpgradeLevel(3);
  2206. p6.SetUpgradeLevel(3);
  2207. m.SetMaxPassengers(6);
  2208. m.SetMaxTransports(0);
  2209. m.AddPassenger(&p3);
  2210. m.AddPassenger(&p4);
  2211. m.AddPassenger(&p5);
  2212. m.AddPassenger(&p6);
  2213. m.SetPosition(Spawn);
  2214. m.UpdatePlacement();
  2215. m.Hide();
  2216. m.PushActionTurnTo(ACTION_NEWLIST, Rotate);
  2217. m.PushActionWait(ACTION_APPEND, 1.0f);
  2218. m.PushActionShowHide(ACTION_APPEND, false);
  2219. m.PushActionMove(ACTION_APPEND, CmdPos);
  2220. if (Game::IsMission())
  2221. m.RemoveCommand("VcmdToFireStation");
  2222.  
  2223. if (!m.HasCommand(DUMMY_HASSIREN) && m.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  2224. Game::ExecuteCommand(CMD_SIREN, &m, &m);
  2225.  
  2226. Mission::PlayHint(HINT_LIGHTFORCEBOUGHT);
  2227. }
  2228. }
  2229. };
  2230.  
  2231. object PcmdCallUSARSquad : CommandScript
  2232. {
  2233. PcmdCallUSARSquad()
  2234. {
  2235. SetIcon("callusarsquad");
  2236. SetCursor("callassistance");
  2237. SetValidTargets(ACTOR_FLOOR | ACTOR_VIRTUAL);
  2238. SetDeselectCaller(false);
  2239. SetSelfClickActivation(true);
  2240. SetHighlightingEnabled(false);
  2241. SetGroupID(CGROUP_GETEQUIPMENT);
  2242. SetGroupLeader(true);
  2243. }
  2244.  
  2245. bool CheckPossible(GameObject *Caller)
  2246. {
  2247. GameObjectList SelectPer = Game::GetSelectedGameObjects();
  2248. if (SelectPer.GetNumObjects() != 1)
  2249. return false;
  2250.  
  2251. Person p(Caller);
  2252. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  2253. return false;
  2254.  
  2255. if (p.IsCurrentAction("EActionTreatPerson"))
  2256. return false;
  2257.  
  2258. if (!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
  2259. return false;
  2260.  
  2261. return true;
  2262. }
  2263.  
  2264. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  2265. {
  2266. if(!Caller->IsValid() || Caller->GetID() == Target->GetID())
  2267. return false;
  2268.  
  2269. if (Caller->GetType() != ACTOR_PERSON)
  2270. return false;
  2271.  
  2272. Person p(Caller);
  2273. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  2274. return false;
  2275.  
  2276. if (p.IsCurrentAction("EActionTreatPerson"))
  2277. return false;
  2278.  
  2279. return true;
  2280. }
  2281.  
  2282. void PushActions(GameObject *Caller, Actor *Target, int ChildID)
  2283. {
  2284. Vector CmdPos = Game::GetCommandPos();
  2285. Caller->PushActionTurnTo(ACTION_NEWLIST, CmdPos);
  2286. Caller->PushActionSwitchAnim(ACTION_APPEND, "talkmike");
  2287. Caller->PushActionWait(ACTION_APPEND, 3.5f);
  2288. Caller->PushActionSwitchAnim(ACTION_APPEND, "idle");
  2289. if(StrCompare(Caller->GetPrototypeFileName(), OBJ_BATTALION_CHIEF) == 0)
  2290. Audio::PlaySample3D(SND_BATUSAR, Caller->GetPosition());
  2291. else if(StrCompare(Caller->GetPrototypeFileName(), OBJ_EMS_CAPTAIN) == 0)
  2292. Audio::PlaySample3D(SND_EMSUSAR, Caller->GetPosition());
  2293.  
  2294. Vehicle *theCar = NULL;
  2295. float bestCar = 0.;
  2296. VehicleList patrolCars(VT_FIREFIGHTERS_RW, VT_FIREFIGHTERS_RW);
  2297. for (int i = 0; i < patrolCars.GetNumVehicles(); i++)
  2298. {
  2299. Vehicle *aCar = patrolCars.GetVehicle(i);
  2300. if (StrCompare(aCar->GetPrototypeFileName(), OBJ_USAR) == 0 && aCar->GetPlayerMP() == Caller->GetPlayerMP() && !aCar->HasCommand(DUMMY_VCALLED) && (aCar->HasCommand(CMD_STANDBY_OFF) || aCar->IsCollidingWithVirtualObject(VO_SQUAD01)))
  2301. {
  2302. float distCurrCar = Math::dist(CmdPos.x, CmdPos.y, aCar->GetPosition().x, aCar->GetPosition().y);
  2303. if (distCurrCar < bestCar || bestCar == 0.)
  2304. {
  2305. theCar = aCar;
  2306. bestCar = distCurrCar;
  2307. }
  2308. }
  2309. }
  2310.  
  2311. if (theCar)
  2312. {
  2313. bool VehicleCalled = false;
  2314. if (theCar->HasCommand(CMD_STANDBY_OFF))
  2315. {
  2316. theCar->PushActionWait(ACTION_NEWLIST, 0.3f);
  2317. theCar->PushActionMove(ACTION_APPEND, CmdPos);
  2318. if (!theCar->HasCommand(DUMMY_HASSIREN) && theCar->HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  2319. Game::ExecuteCommand(CMD_SIREN, theCar, theCar);
  2320. if (theCar->HasCommand(CMD_STANDBY_OFF))
  2321. {
  2322. theCar->RemoveCommand(CMD_STANDBY_OFF);
  2323. theCar->AssignCommand(CMD_STANDBY_ON);
  2324. }
  2325. if (theCar->HasCommand(CMD_WARNINGLIGHTS_OFF))
  2326. {
  2327. theCar->EnableBlinker(BLT_NONE);
  2328. theCar->RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  2329. theCar->AssignCommand(CMD_WARNINGLIGHTS_ON);
  2330. }
  2331. if (theCar->HasCommand(CMD_FLOODLIGHTS_OFF))
  2332. {
  2333. theCar->EnableSpecialLights(false);
  2334. theCar->RemoveCommand(CMD_FLOODLIGHTS_OFF);
  2335. theCar->AssignCommand(CMD_FLOODLIGHTS_ON);
  2336. }
  2337. Mission::PlayHint(HINT_DISPATCHED);
  2338. return;
  2339. }
  2340. else if (theCar->IsCollidingWithVirtualObject(VO_SQUAD01))
  2341. {
  2342. GameObjectList ppc;
  2343. Game::CollectObstaclesOnVirtualObject(VO_USAR, ppc, ACTOR_VEHICLE);
  2344. for (int i = 0; i < ppc.GetNumObjects(); i++)
  2345. {
  2346. Vehicle v = ppc.GetObject(i);
  2347. if (!v.HasCommand(DUMMY_VCALLED))
  2348. {
  2349. v.AssignCommand(DUMMY_VCALLED);
  2350. VehicleCalled = true;
  2351. }
  2352. }
  2353. }
  2354. if (VehicleCalled)
  2355. {
  2356. if (v.IsBlueLightEnabled() && (Input::LShiftPressed() || Input::RShiftPressed()))
  2357. v.EnableBlueLights(false);
  2358. else if (!v.IsBlueLightEnabled() && !Input::LShiftPressed() && !Input::RShiftPressed())
  2359. v.EnableBlueLights(true);
  2360. GameObjectList gate02a = Game::GetGameObjects(OBJ_GATE02A);
  2361. for(int i=0; i < gate02a.GetNumObjects(); i++)
  2362. GameObject *gate = gate02a.GetObject(i);
  2363.  
  2364. PersonList passengers = v.GetPassengers();
  2365. if (passengers.GetNumPersons() == 0)
  2366. {
  2367. v.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_CALLCREW, Caller, 6, false);
  2368. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 6, false);
  2369. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 6, false);
  2370. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 6, false);
  2371. v.PushActionWait(ACTION_APPEND, 11.f);
  2372. }
  2373. if (gate->GetUserData() == 0)
  2374. {
  2375. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  2376. Vector Move = v.GetPosition();
  2377. float r[9];
  2378. float childr[9];
  2379. v.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
  2380. float dx = 750.f, dy = 0.f, dz = 0.f;
  2381. Math::RotateVector(dx, dy, dz, r);
  2382. Math::EulerToMatrix(0.0f, 0.f, 0.f, childr);
  2383. Math::MultiplyMatrices(childr, r);
  2384. Move = Move + Vector(dx, dy, 0);
  2385. v.PushActionWait(ACTION_APPEND, 1.2f);
  2386. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  2387. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  2388. v.PushActionMove(ACTION_APPEND, Move);
  2389. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  2390. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  2391. v.PushActionMove(ACTION_APPEND, CmdPos);
  2392. } else
  2393. {
  2394. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  2395. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  2396. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  2397. v.PushActionMove(ACTION_APPEND, CmdPos);
  2398. }
  2399. if (v.HasCommand(CMD_STANDBY_OFF))
  2400. {
  2401. v.RemoveCommand(CMD_STANDBY_OFF);
  2402. v.AssignCommand(CMD_STANDBY_ON);
  2403. }
  2404. if (v.HasCommand(CMD_WARNINGLIGHTS_OFF))
  2405. {
  2406. v.EnableBlinker(BLT_NONE);
  2407. v.RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  2408. v.AssignCommand(CMD_WARNINGLIGHTS_ON);
  2409. }
  2410. if (v.HasCommand(CMD_FLOODLIGHTS_OFF))
  2411. {
  2412. v.EnableSpecialLights(false);
  2413. v.RemoveCommand(CMD_FLOODLIGHTS_OFF);
  2414. v.AssignCommand(CMD_FLOODLIGHTS_ON);
  2415. }
  2416. Mission::PlayHint(HINT_DISPATCHED);
  2417. return;
  2418. }
  2419. }
  2420. Vector Spawn;
  2421. Vector Rotate;
  2422. ActorList l1 = Game::GetActors(VO_SPAWN_ALL);
  2423. ActorList l2 = Game::GetActors(VO_SPAWN_FD);
  2424. ActorList l3 = Game::GetActors(VO_SPAWN_ALLR);
  2425. ActorList l4 = Game::GetActors(VO_SPAWN_FDR);
  2426. if(l1.GetNumActors() > 0)
  2427. {
  2428. Spawn = l1.GetActor(0)->GetPosition();
  2429. Rotate = l3.GetActor(0)->GetPosition();
  2430. }
  2431. else if(l2.GetNumActors() > 0)
  2432. {
  2433. Spawn = l2.GetActor(0)->GetPosition();
  2434. Rotate = l4.GetActor(0)->GetPosition();
  2435. }
  2436. else
  2437. {
  2438. Mission::PlayHint(HINT_NOUSAR);
  2439. return;
  2440. }
  2441. System::Log("Buy USAR squad");
  2442. int Money = Mission::GetMoneyLeft();
  2443. if (Money <= 3500)
  2444. {
  2445. Mission::PlayHint(HINT_NOUSAR);
  2446. return;
  2447. }
  2448. int NewMoney = Money - 3500;
  2449. Mission::SetMoney(NewMoney);
  2450. Vehicle n;
  2451. Person p1;
  2452. Person p2;
  2453. n = Game::CreateVehicle(OBJ_USAR, UNNAMED);
  2454. n.SetSpeed(9.0f);
  2455. p1 = Game::CreatePerson(OBJ_USARFF, UNNAMED);
  2456. p2 = Game::CreatePerson(OBJ_USARFF, UNNAMED);
  2457. n.SetPlayerMP(Caller->GetPlayerMP());
  2458. p1.SetPlayerMP(Caller->GetPlayerMP());
  2459. p2.SetPlayerMP(Caller->GetPlayerMP());
  2460. p1.SetUpgradeLevel(3);
  2461. p2.SetUpgradeLevel(3);
  2462. n.SetMaxPassengers(4);
  2463. n.SetMaxTransports(0);
  2464. n.AddPassenger(&p1);
  2465. n.AddPassenger(&p2);
  2466. n.SetPosition(Spawn);
  2467. n.UpdatePlacement();
  2468. n.Hide();
  2469. n.PushActionTurnTo(ACTION_NEWLIST, Rotate);
  2470. n.PushActionWait(ACTION_APPEND, 2.5f);
  2471. n.PushActionShowHide(ACTION_APPEND, false);
  2472. n.PushActionMove(ACTION_APPEND, CmdPos);
  2473. if (Game::IsMission())
  2474. n.RemoveCommand("VcmdToFireStation");
  2475.  
  2476. if (!n.HasCommand(DUMMY_HASSIREN) && n.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  2477. Game::ExecuteCommand(CMD_SIREN, &n, &n);
  2478.  
  2479. Mission::PlayHint(HINT_USARBOUGHT);
  2480. }
  2481. };
  2482.  
  2483. object PcmdCallRescue7 : CommandScript
  2484. {
  2485. PcmdCallRescue7()
  2486. {
  2487. SetIcon("callrescue7");
  2488. SetCursor("callassistance");
  2489. SetValidTargets(ACTOR_FLOOR | ACTOR_VIRTUAL);
  2490. SetDeselectCaller(false);
  2491. SetSelfClickActivation(true);
  2492. SetHighlightingEnabled(false);
  2493. SetGroupID(CGROUP_GETEQUIPMENT);
  2494. SetGroupLeader(true);
  2495. }
  2496.  
  2497. bool CheckPossible(GameObject *Caller)
  2498. {
  2499. GameObjectList SelectPer = Game::GetSelectedGameObjects();
  2500. if (SelectPer.GetNumObjects() != 1)
  2501. return false;
  2502.  
  2503. Person p(Caller);
  2504. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  2505. return false;
  2506.  
  2507. if (p.IsCurrentAction("EActionTreatPerson"))
  2508. return false;
  2509.  
  2510. if (!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
  2511. return false;
  2512.  
  2513. return true;
  2514. }
  2515.  
  2516. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  2517. {
  2518. if(!Caller->IsValid() || Caller->GetID() == Target->GetID())
  2519. return false;
  2520.  
  2521. if (Caller->GetType() != ACTOR_PERSON)
  2522. return false;
  2523.  
  2524. Person p(Caller);
  2525. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  2526. return false;
  2527.  
  2528. if (p.IsCurrentAction("EActionTreatPerson"))
  2529. return false;
  2530.  
  2531. return true;
  2532. }
  2533.  
  2534. void PushActions(GameObject *Caller, Actor *Target, int ChildID)
  2535. {
  2536. Vector CmdPos = Game::GetCommandPos();
  2537. Caller->PushActionTurnTo(ACTION_NEWLIST, CmdPos);
  2538. Caller->PushActionSwitchAnim(ACTION_APPEND, "talkmike");
  2539. Caller->PushActionWait(ACTION_APPEND, 3.5f);
  2540. Caller->PushActionSwitchAnim(ACTION_APPEND, "idle");
  2541. if(StrCompare(Caller->GetPrototypeFileName(), OBJ_BATTALION_CHIEF) == 0)
  2542. Audio::PlaySample3D(SND_BATUSAR, Caller->GetPosition());
  2543. else if(StrCompare(Caller->GetPrototypeFileName(), OBJ_EMS_CAPTAIN) == 0)
  2544. Audio::PlaySample3D(SND_EMSUSAR, Caller->GetPosition());
  2545.  
  2546. Vehicle *theCar = NULL;
  2547. float bestCar = 0.;
  2548. VehicleList patrolCars(VT_FIREFIGHTERS_RW, VT_FIREFIGHTERS_RW);
  2549. for (int i = 0; i < patrolCars.GetNumVehicles(); i++)
  2550. {
  2551. Vehicle *aCar = patrolCars.GetVehicle(i);
  2552. if (StrCompare(aCar->GetPrototypeFileName(), OBJ_RESCUE7) == 0 && aCar->GetPlayerMP() == Caller->GetPlayerMP() && !aCar->HasCommand(DUMMY_VCALLED) && (aCar->HasCommand(CMD_STANDBY_OFF) || aCar->IsCollidingWithVirtualObject(VO_LRA)))
  2553. {
  2554. float distCurrCar = Math::dist(CmdPos.x, CmdPos.y, aCar->GetPosition().x, aCar->GetPosition().y);
  2555. if (distCurrCar < bestCar || bestCar == 0.)
  2556. {
  2557. theCar = aCar;
  2558. bestCar = distCurrCar;
  2559. }
  2560. }
  2561. }
  2562.  
  2563. if (theCar)
  2564. {
  2565. bool VehicleCalled = false;
  2566. if (theCar->HasCommand(CMD_STANDBY_OFF))
  2567. {
  2568. theCar->PushActionWait(ACTION_NEWLIST, 0.3f);
  2569. theCar->PushActionMove(ACTION_APPEND, CmdPos);
  2570. if (!theCar->HasCommand(DUMMY_HASSIREN) && theCar->HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  2571. Game::ExecuteCommand(CMD_SIREN, theCar, theCar);
  2572. if (theCar->HasCommand(CMD_STANDBY_OFF))
  2573. {
  2574. theCar->RemoveCommand(CMD_STANDBY_OFF);
  2575. theCar->AssignCommand(CMD_STANDBY_ON);
  2576. }
  2577. if (theCar->HasCommand(CMD_WARNINGLIGHTS_OFF))
  2578. {
  2579. theCar->EnableBlinker(BLT_NONE);
  2580. theCar->RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  2581. theCar->AssignCommand(CMD_WARNINGLIGHTS_ON);
  2582. }
  2583. if (theCar->HasCommand(CMD_FLOODLIGHTS_OFF))
  2584. {
  2585. theCar->EnableSpecialLights(false);
  2586. theCar->RemoveCommand(CMD_FLOODLIGHTS_OFF);
  2587. theCar->AssignCommand(CMD_FLOODLIGHTS_ON);
  2588. }
  2589. Mission::PlayHint(HINT_DISPATCHED);
  2590. return;
  2591. }
  2592. else if (theCar->IsCollidingWithVirtualObject(VO_LRA))
  2593. {
  2594. GameObjectList ppc;
  2595. Game::CollectObstaclesOnVirtualObject(VO_LRA, ppc, ACTOR_VEHICLE);
  2596. for (int i = 0; i < ppc.GetNumObjects(); i++)
  2597. {
  2598. Vehicle v = ppc.GetObject(i);
  2599. if (!v.HasCommand(DUMMY_VCALLED))
  2600. {
  2601. v.AssignCommand(DUMMY_VCALLED);
  2602. VehicleCalled = true;
  2603. }
  2604. }
  2605. }
  2606. if (VehicleCalled)
  2607. {
  2608. if (v.IsBlueLightEnabled() && (Input::LShiftPressed() || Input::RShiftPressed()))
  2609. v.EnableBlueLights(false);
  2610. else if (!v.IsBlueLightEnabled() && !Input::LShiftPressed() && !Input::RShiftPressed())
  2611. v.EnableBlueLights(true);
  2612. PersonList passengers = v.GetPassengers();
  2613. if (passengers.GetNumPersons() == 0)
  2614. {
  2615. v.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_CALLCREW, Caller, 1, false);
  2616. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 1, false);
  2617. v.PushActionWait(ACTION_APPEND, 11.0f);
  2618. }
  2619. {
  2620. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  2621. Vector Move = v.GetPosition();
  2622. float r[9];
  2623. float childr[9];
  2624. v.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
  2625. float dx = 750.f, dy = 0.f, dz = 0.f;
  2626. Math::RotateVector(dx, dy, dz, r);
  2627. Math::EulerToMatrix(0.0f, 0.f, 0.f, childr);
  2628. Math::MultiplyMatrices(childr, r);
  2629. Move = Move + Vector(dx, dy, 0);
  2630. v.PushActionWait(ACTION_APPEND, 1.2f);
  2631. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  2632. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  2633. v.PushActionMove(ACTION_APPEND, Move);
  2634. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 5, false);
  2635. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  2636. v.PushActionMove(ACTION_APPEND, CmdPos);
  2637. } else
  2638. {
  2639. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  2640. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  2641. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  2642. v.PushActionMove(ACTION_APPEND, CmdPos);
  2643. }
  2644. if (v.HasCommand(CMD_STANDBY_OFF))
  2645. {
  2646. v.RemoveCommand(CMD_STANDBY_OFF);
  2647. v.AssignCommand(CMD_STANDBY_ON);
  2648. }
  2649. if (v.HasCommand(CMD_WARNINGLIGHTS_OFF))
  2650. {
  2651. v.EnableBlinker(BLT_NONE);
  2652. v.RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  2653. v.AssignCommand(CMD_WARNINGLIGHTS_ON);
  2654. }
  2655. if (v.HasCommand(CMD_FLOODLIGHTS_OFF))
  2656. {
  2657. v.EnableSpecialLights(false);
  2658. v.RemoveCommand(CMD_FLOODLIGHTS_OFF);
  2659. v.AssignCommand(CMD_FLOODLIGHTS_ON);
  2660. }
  2661. Mission::PlayHint(HINT_DISPATCHED);
  2662. return;
  2663. }
  2664. }
  2665. Vector Spawn;
  2666. Vector Rotate;
  2667. ActorList l1 = Game::GetActors(VO_SPAWN_ALL);
  2668. ActorList l2 = Game::GetActors(VO_SPAWN_FD);
  2669. ActorList l3 = Game::GetActors(VO_SPAWN_ALLR);
  2670. ActorList l4 = Game::GetActors(VO_SPAWN_FDR);
  2671. if(l1.GetNumActors() > 0)
  2672. {
  2673. Spawn = l1.GetActor(0)->GetPosition();
  2674. Rotate = l3.GetActor(0)->GetPosition();
  2675. }
  2676. else if(l2.GetNumActors() > 0)
  2677. {
  2678. Spawn = l2.GetActor(0)->GetPosition();
  2679. Rotate = l4.GetActor(0)->GetPosition();
  2680. }
  2681. else
  2682. {
  2683. Mission::PlayHint(HINT_NOUSAR);
  2684. return;
  2685. }
  2686. System::Log("Buy Rescue 7");
  2687. int Money = Mission::GetMoneyLeft();
  2688. if (Money <= 600)
  2689. {
  2690. Mission::PlayHint(HINT_NOUSAR);
  2691. return;
  2692. }
  2693. int NewMoney = Money - 600;
  2694. Mission::SetMoney(NewMoney);
  2695. Vehicle n;
  2696. Person p1;
  2697. Person p2;
  2698. n = Game::CreateVehicle(OBJ_RESCUE7, UNNAMED);
  2699. n.SetSpeed(9.0f);
  2700. p1 = Game::CreatePerson(OBJ_PM, UNNAMED);
  2701. p2 = Game::CreatePerson(OBJ_PM, UNNAMED);
  2702. n.SetPlayerMP(Caller->GetPlayerMP());
  2703. p1.SetPlayerMP(Caller->GetPlayerMP());
  2704. p2.SetPlayerMP(Caller->GetPlayerMP());
  2705. p1.SetUpgradeLevel(3);
  2706. p2.SetUpgradeLevel(3);
  2707. n.SetMaxPassengers(4);
  2708. n.SetMaxTransports(0);
  2709. n.AddPassenger(&p1);
  2710. n.AddPassenger(&p2);
  2711. n.SetPosition(Spawn);
  2712. n.UpdatePlacement();
  2713. n.Hide();
  2714. n.PushActionTurnTo(ACTION_NEWLIST, Rotate);
  2715. n.PushActionWait(ACTION_APPEND, 2.5f);
  2716. n.PushActionShowHide(ACTION_APPEND, false);
  2717. n.PushActionMove(ACTION_APPEND, CmdPos);
  2718. if (Game::IsMission())
  2719. n.RemoveCommand("VcmdToFireStation");
  2720.  
  2721. if (!n.HasCommand(DUMMY_HASSIREN) && n.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  2722. Game::ExecuteCommand(CMD_SIREN, &n, &n);
  2723.  
  2724. Mission::PlayHint(HINT_USARBOUGHT);
  2725. }
  2726. };
  2727.  
  2728. object PcmdCallHazmat : CommandScript
  2729. {
  2730. PcmdCallHazmat()
  2731. {
  2732. SetIcon("callhazmatsquad");
  2733. SetCursor("callassistance");
  2734. SetValidTargets(ACTOR_FLOOR | ACTOR_VIRTUAL);
  2735. SetDeselectCaller(false);
  2736. SetSelfClickActivation(true);
  2737. SetHighlightingEnabled(false);
  2738. SetGroupID(CGROUP_GETEQUIPMENT);
  2739. SetGroupLeader(true);
  2740. }
  2741.  
  2742. bool CheckPossible(GameObject *Caller)
  2743. {
  2744. GameObjectList SelectPer = Game::GetSelectedGameObjects();
  2745. if (SelectPer.GetNumObjects() != 1)
  2746. return false;
  2747.  
  2748. Person p(Caller);
  2749. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  2750. return false;
  2751.  
  2752. if (p.IsCurrentAction("EActionTreatPerson"))
  2753. return false;
  2754.  
  2755. if (!Caller->IsValid() || Caller->GetType() != ACTOR_PERSON)
  2756. return false;
  2757.  
  2758. return true;
  2759. }
  2760.  
  2761. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  2762. {
  2763. if(!Caller->IsValid() || Caller->GetID() == Target->GetID())
  2764. return false;
  2765.  
  2766. if (Caller->GetType() != ACTOR_PERSON)
  2767. return false;
  2768.  
  2769. Person p(Caller);
  2770. if(p.IsValid() && (p.IsLinkedWithPerson() || p.IsCarryingPerson() || p.IsEquipped() || p.IsPulling() || p.GetFirehoseID()!=0 || p.GetEnteredCarID() != -1))
  2771. return false;
  2772.  
  2773. if (p.IsCurrentAction("EActionTreatPerson"))
  2774. return false;
  2775.  
  2776. return true;
  2777. }
  2778.  
  2779. void PushActions(GameObject *Caller, Actor *Target, int ChildID)
  2780. {
  2781. Vector CmdPos = Game::GetCommandPos();
  2782. Caller->PushActionTurnTo(ACTION_NEWLIST, CmdPos);
  2783. Caller->PushActionSwitchAnim(ACTION_APPEND, "talkmike");
  2784. Caller->PushActionWait(ACTION_APPEND, 3.5f);
  2785. Caller->PushActionSwitchAnim(ACTION_APPEND, "idle");
  2786. if(StrCompare(Caller->GetPrototypeFileName(), OBJ_BATTALION_CHIEF) == 0)
  2787. Audio::PlaySample3D(SND_BATHAZMAT, Caller->GetPosition());
  2788. else if(StrCompare(Caller->GetPrototypeFileName(), OBJ_EMS_CAPTAIN) == 0)
  2789. Audio::PlaySample3D(SND_EMSHAZMAT, Caller->GetPosition());
  2790.  
  2791. Vehicle *theCar = NULL;
  2792. float bestCar = 0.;
  2793. VehicleList patrolCars(VT_FIREFIGHTERS_DEKONP, VT_FIREFIGHTERS_DEKONP);
  2794. for (int i = 0; i < patrolCars.GetNumVehicles(); i++)
  2795. {
  2796. Vehicle *aCar = patrolCars.GetVehicle(i);
  2797. if (StrCompare(aCar->GetPrototypeFileName(), OBJ_HAZMAT) == 0 && !aCar->IsDecontaminating() && aCar->GetPlayerMP() == Caller->GetPlayerMP() && !aCar->HasCommand(DUMMY_VCALLED) && (aCar->HasCommand(CMD_STANDBY_OFF) || aCar->IsCollidingWithVirtualObject(VO_SQUAD02)))
  2798. {
  2799. float distCurrCar = Math::dist(CmdPos.x, CmdPos.y, aCar->GetPosition().x, aCar->GetPosition().y);
  2800. if (distCurrCar < bestCar || bestCar == 0.)
  2801. {
  2802. theCar = aCar;
  2803. bestCar = distCurrCar;
  2804. }
  2805. }
  2806. }
  2807.  
  2808. if (theCar)
  2809. {
  2810. bool VehicleCalled = false;
  2811. if (theCar->HasCommand(CMD_STANDBY_OFF))
  2812. {
  2813. theCar->PushActionWait(ACTION_NEWLIST, 0.3f);
  2814. theCar->PushActionMove(ACTION_APPEND, CmdPos);
  2815. if (!theCar->HasCommand(DUMMY_HASSIREN) && theCar->HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  2816. Game::ExecuteCommand(CMD_SIREN, theCar, theCar);
  2817. if (theCar->HasCommand(CMD_STANDBY_OFF))
  2818. {
  2819. theCar->RemoveCommand(CMD_STANDBY_OFF);
  2820. theCar->AssignCommand(CMD_STANDBY_ON);
  2821. }
  2822. if (theCar->HasCommand(CMD_WARNINGLIGHTS_OFF))
  2823. {
  2824. theCar->EnableBlinker(BLT_NONE);
  2825. theCar->RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  2826. theCar->AssignCommand(CMD_WARNINGLIGHTS_ON);
  2827. }
  2828. if (theCar->HasCommand(CMD_FLOODLIGHTS_OFF))
  2829. {
  2830. theCar->EnableSpecialLights(false);
  2831. theCar->RemoveCommand(CMD_FLOODLIGHTS_OFF);
  2832. theCar->AssignCommand(CMD_FLOODLIGHTS_ON);
  2833. }
  2834. Mission::PlayHint(HINT_DISPATCHED);
  2835. return;
  2836. }
  2837. else if (theCar->IsCollidingWithVirtualObject(VO_SQUAD02))
  2838. {
  2839. GameObjectList ppc;
  2840. Game::CollectObstaclesOnVirtualObject(VO_HAZMAT, ppc, ACTOR_VEHICLE);
  2841. for (int i = 0; i < ppc.GetNumObjects(); i++)
  2842. {
  2843. Vehicle v = ppc.GetObject(i);
  2844. if (!v.HasCommand(DUMMY_VCALLED))
  2845. {
  2846. v.AssignCommand(DUMMY_VCALLED);
  2847. VehicleCalled = true;
  2848. }
  2849. }
  2850. }
  2851. if (VehicleCalled)
  2852. {
  2853. if (v.IsBlueLightEnabled() && (Input::LShiftPressed() || Input::RShiftPressed()))
  2854. v.EnableBlueLights(false);
  2855. else if (!v.IsBlueLightEnabled() && !Input::LShiftPressed() && !Input::RShiftPressed())
  2856. v.EnableBlueLights(true);
  2857. GameObjectList gate06a = Game::GetGameObjects(OBJ_GATE06A);
  2858. for(int i=0; i < gate06a.GetNumObjects(); i++)
  2859. GameObject *gate = gate06a.GetObject(i);
  2860. PersonList passengers = v.GetPassengers();
  2861. if (passengers.GetNumPersons() == 0)
  2862. {
  2863. v.PushActionExecuteCommand(ACTION_NEWLIST, DUMMY_CALLCREW, Caller, 5, false);
  2864. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 5, false);
  2865. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 5, false);
  2866. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_CALLCREW, Caller, 5, false);
  2867. v.PushActionWait(ACTION_APPEND, 9.0f);
  2868. }
  2869. if (gate->GetUserData() == 0)
  2870. {
  2871. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 6, false);
  2872. Vector Move = v.GetPosition();
  2873. float r[9];
  2874. float childr[9];
  2875. v.GetRotation(r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7], r[8]);
  2876. float dx = 650.f, dy = 0.f, dz = 0.f;
  2877. Math::RotateVector(dx, dy, dz, r);
  2878. Math::EulerToMatrix(0.0f, 0.f, 0.f, childr);
  2879. Math::MultiplyMatrices(childr, r);
  2880. Move = Move + Vector(dx, dy, 0);
  2881. v.PushActionWait(ACTION_APPEND, 1.2f);
  2882. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  2883. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  2884. v.PushActionMove(ACTION_APPEND, Move);
  2885. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_GATES, Caller, 6, false);
  2886. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  2887. v.PushActionMove(ACTION_APPEND, CmdPos);
  2888. } else
  2889. {
  2890. if (!v.HasCommand(DUMMY_HASSIREN) && v.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  2891. v.PushActionExecuteCommand(ACTION_APPEND, CMD_SIREN, Caller, 0, false);
  2892. v.PushActionExecuteCommand(ACTION_APPEND, DUMMY_VCALLED, Caller, 0, false);
  2893. v.PushActionMove(ACTION_APPEND, CmdPos);
  2894. }
  2895. if (v.HasCommand(CMD_STANDBY_OFF))
  2896. {
  2897. v.RemoveCommand(CMD_STANDBY_OFF);
  2898. v.AssignCommand(CMD_STANDBY_ON);
  2899. }
  2900. if (v.HasCommand(CMD_WARNINGLIGHTS_OFF))
  2901. {
  2902. v.EnableBlinker(BLT_NONE);
  2903. v.RemoveCommand(CMD_WARNINGLIGHTS_OFF);
  2904. v.AssignCommand(CMD_WARNINGLIGHTS_ON);
  2905. }
  2906. if (v.HasCommand(CMD_FLOODLIGHTS_OFF))
  2907. {
  2908. v.EnableSpecialLights(false);
  2909. v.RemoveCommand(CMD_FLOODLIGHTS_OFF);
  2910. v.AssignCommand(CMD_FLOODLIGHTS_ON);
  2911. }
  2912. Mission::PlayHint(HINT_DISPATCHED);
  2913. return;
  2914. }
  2915. }
  2916. Vector Spawn;
  2917. Vector Rotate;
  2918. ActorList l1 = Game::GetActors(VO_SPAWN_ALL);
  2919. ActorList l2 = Game::GetActors(VO_SPAWN_FD);
  2920. ActorList l3 = Game::GetActors(VO_SPAWN_ALLR);
  2921. ActorList l4 = Game::GetActors(VO_SPAWN_FDR);
  2922. if(l1.GetNumActors() > 0)
  2923. {
  2924. Spawn = l1.GetActor(0)->GetPosition();
  2925. Rotate = l3.GetActor(0)->GetPosition();
  2926. }
  2927. else if(l2.GetNumActors() > 0)
  2928. {
  2929. Spawn = l2.GetActor(0)->GetPosition();
  2930. Rotate = l4.GetActor(0)->GetPosition();
  2931. }
  2932. else
  2933. {
  2934. Mission::PlayHint(HINT_NOHAZMAT);
  2935. return;
  2936. }
  2937. System::Log("Buy HAZMAT squad");
  2938. int Money = Mission::GetMoneyLeft();
  2939. if (Money <= 4000)
  2940. {
  2941. Mission::PlayHint(HINT_NOHAZMAT);
  2942. return;
  2943. }
  2944. int NewMoney = Money - 4000;
  2945. Mission::SetMoney(NewMoney);
  2946. Vehicle n;
  2947. Person p1;
  2948. Person p2;
  2949. Person p3;
  2950. Person p4;
  2951. n = Game::CreateVehicle(OBJ_HAZMAT, UNNAMED);
  2952. n.SetSpeed(9.0f);
  2953. p1 = Game::CreatePerson(OBJ_HAZMATFF, UNNAMED);
  2954. p2 = Game::CreatePerson(OBJ_HAZMATFF, UNNAMED);
  2955. p3 = Game::CreatePerson(OBJ_HAZMATFF, UNNAMED);
  2956. p4 = Game::CreatePerson(OBJ_HAZMATFF, UNNAMED);
  2957. n.SetPlayerMP(Caller->GetPlayerMP());
  2958. p1.SetPlayerMP(Caller->GetPlayerMP());
  2959. p2.SetPlayerMP(Caller->GetPlayerMP());
  2960. p3.SetPlayerMP(Caller->GetPlayerMP());
  2961. p4.SetPlayerMP(Caller->GetPlayerMP());
  2962. p1.SetUpgradeLevel(3);
  2963. p2.SetUpgradeLevel(3);
  2964. p3.SetUpgradeLevel(3);
  2965. p4.SetUpgradeLevel(3);
  2966. n.SetMaxPassengers(4);
  2967. n.SetMaxTransports(2);
  2968. n.AddPassenger(&p1);
  2969. n.AddPassenger(&p2);
  2970. n.AddPassenger(&p3);
  2971. n.AddPassenger(&p4);
  2972. n.SetPosition(Spawn);
  2973. n.UpdatePlacement();
  2974. n.Hide();
  2975. n.PushActionTurnTo(ACTION_NEWLIST, Rotate);
  2976. n.PushActionWait(ACTION_APPEND, 2.5f);
  2977. n.PushActionShowHide(ACTION_APPEND, false);
  2978. n.PushActionMove(ACTION_APPEND, CmdPos);
  2979. if (Game::IsMission())
  2980. n.RemoveCommand("VcmdToFireStation");
  2981.  
  2982. if (!n.HasCommand(DUMMY_HASSIREN) && n.HasCommand(CMD_AUTOSIREN_OFF) && !Input::LShiftPressed() && !Input::RShiftPressed())
  2983. Game::ExecuteCommand(CMD_SIREN, &n, &n);
  2984.  
  2985. Mission::PlayHint(HINT_HAZMATBOUGHT);
  2986. }
  2987. };
  2988.  
  2989. object DummyVehicleCalled : CommandScript
  2990. {
  2991. DummyVehicleCalled()
  2992. {
  2993. SetGroupID(20);
  2994. }
  2995.  
  2996. bool CheckTarget(GameObject *Caller, Actor *Target, int childID)
  2997. {
  2998. }
  2999.  
  3000. void PushActions(GameObject *Caller, Actor *Target, int ChildID)
  3001. {
  3002. Vehicle v(Caller);
  3003. if (v.HasCommand(DUMMY_VCALLED))
  3004. v.RemoveCommand(DUMMY_VCALLED);
  3005. }
  3006. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement