Advertisement
eLeKaeMe

gta 6 leak 001

Sep 18th, 2022
523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 398.67 KB | None | 0 0
  1. #include "fwanimation/animmanager.h"
  2. #include "fwanimation/directorcomponentsyncedscene.h"
  3. #include "fwscene/stores/networkdefstore.h"
  4. #include "fwscene/stores/framefilterdictionarystore.h"
  5. #include "script/commands_task.h"
  6. #include "script/wrapper.h"
  7. #include "script/thread.h"
  8. //Game headers
  9. #include "ai/debug/system/AIDebugLogManager.h"
  10. #include "animation/AnimDefines.h"
  11. #include "animation/Move.h"
  12. #include "control/WaypointRecording.h"
  13. #include "control/replay/replay.h"
  14. #include "event/EventShocking.h"
  15. #include "event/EventWeapon.h"
  16. #include "event/ShockingEvents.h"
  17. #include "game/ModelIndices.h"
  18. #include "math/angmath.h"
  19. #include "network/NetworkInterface.h"
  20. #include "network/Events/NetworkEventTypes.h"
  21. #include "peds/PedFactory.h"
  22. #include "peds/PedHelmetComponent.h"
  23. #include "peds/PedIntelligence.h"
  24. #include "peds/Pedpopulation.h"
  25. #include "peds/PedTaskRecord.h"
  26. #include "peds/Ped.h"
  27. #include "peds/WildlifeManager.h"
  28. #include "physics/WorldProbe/worldprobe.h"
  29. #include "physics/RagdollConstraints.h"
  30. #include "pickups/Pickup.h"
  31. #include "pickups/PickupPlacement.h"
  32. #include "scene/world/GameWorld.h"
  33. #include "fwpheffects/ropemanager.h"
  34. #include "fwscene/search/SearchVolumes.h"
  35. #include "script/Handlers/GameScriptEntity.h"
  36. #include "script/Handlers/GameScriptResources.h"
  37. #include "script/Handlers/GameScriptMgr.h"
  38. #include "script/scrchannel.h"
  39. #include "script/script.h"
  40. #include "script/script_cars_and_peds.h"
  41. #include "script/script_helper.h"
  42. #include "script/ScriptTaskTypes.h"
  43. #include "script/commands_waypoint.h"
  44. #include "script/commands_entity.h"
  45. #include "streaming/streaming.h"
  46. #include "Task/Animation/TaskMoveScripted.h"
  47. #include "Task/Combat/Cover/Cover.h"
  48. #include "Task/Combat/TaskNewCombat.h"
  49. #include "Task/Combat/Cover/TaskCover.h"
  50. #include "Task/Combat/Cover/TaskSeekCover.h"
  51. #include "Task/Combat/Cover/TaskStayInCover.h"
  52. #include "Task/Combat/Subtasks/TaskDraggingToSafety.h"
  53. #include "Task/Combat/Subtasks/TaskHeliChase.h"
  54. #include "Task/Combat/Subtasks/TaskPlaneChase.h"
  55. #include "Task/Combat/Subtasks/TaskStealth.h"
  56. #include "Task/Combat/Subtasks/TaskVehicleChase.h"
  57. #include "Task/Combat/Subtasks/TaskVehicleCombat.h"
  58. #include "task/Combat/TaskCombat.h"
  59. #include "task/Combat/TaskCombatMelee.h"
  60. #include "Task/Combat/TaskDamageDeath.h"
  61. #include "Task/Combat/TaskInvestigate.h"
  62. #include "Task/Combat/TaskReact.h"
  63. #include "Task/Combat/TaskSearch.h"
  64. #include "Task/Combat/TaskSharkAttack.h"
  65. #include "Task/Combat/TaskThreatResponse.h"
  66. #include "Task/Combat/TaskWrithe.h"
  67. #include "Task/Default/AmbientAnimationManager.h"
  68. #include "Task/Default/Patrol/PatrolRoutes.h"
  69. #include "Task/Default/Patrol/TaskPatrol.h"
  70. #include "Task/Default/TaskArrest.h"
  71. #include "Task/Default/ArrestHelpers.h"
  72. #include "Task/Default/TaskChat.h"
  73. #include "Task/Default/TaskCuffed.h"
  74. #include "Task/Default/TaskPlayer.h"
  75. #include "Task/Default/TaskWander.h"
  76. #include "Task/General/TaskBasic.h"
  77. #include "Task/General/TaskGeneralSweep.h"
  78. #include "Task/General/Phone/TaskMobilePhone.h"
  79. #include "Task/Scenario/info/ScenarioInfoManager.h"
  80. #include "Task/General/TaskSecondary.h"
  81. #include "Task/Motion/Locomotion/TaskMotionPed.h"
  82. #include "Task/Movement/Climbing/TaskGoToAndClimbLadder.h"
  83. #include "Task/Movement/Climbing/TaskRappel.h"
  84. #include "Task/Movement/Jumping/TaskJump.h"
  85. #include "Task/Movement/TaskFall.h"
  86. #include "Task/Movement/TaskSlideToCoord.h"
  87. #include "Task/Movement/TaskCollisionResponse.h"
  88. #include "Task/Movement/TaskFollowWaypointRecording.h"
  89. #include "Task/Movement/TaskGoto.h"
  90. #include "Task/Movement/TaskGoToPointAiming.h"
  91. #include "Task/Movement/TaskMoveFollowEntityOffset.h"
  92. #include "Task/Movement/TaskParachute.h"
  93. #include "Task/Movement/TaskJetpack.h"
  94. #include "Task/Movement/TaskSeekEntity.h"
  95. #include "Task/Physics/TaskAnimatedAttach.h"
  96. #include "Task/Physics/TaskNM.h"
  97. #include "Task/Physics/TaskNMBindPose.h"
  98. #include "Task/Physics/TaskNMElectrocute.h"
  99. #include "Task/Physics/TaskNMDangle.h"
  100. #include "Task/Physics/TaskNMHighFall.h"
  101. #include "Task/Physics/TaskNMSlungOverShoulder.h"
  102. //#include "Task/Physics/TaskNMStumble.h"
  103. #include "Task/Response/TaskAgitated.h"
  104. #include "Task/Response/TaskConfront.h"
  105. #include "Task/Response/TaskFlee.h"
  106. #include "Task/Response/TaskGangs.h"
  107. #include "task/Response/TaskReactAndFlee.h"
  108. #include "Task/Response/TaskShockingEvents.h"
  109. #include "Task/Scenario/Info/ScenarioInfo.h"
  110. #include "Task/Scenario/ScenarioManager.h"
  111. #include "Task/Scenario/ScenarioPointManager.h"
  112. #include "Task/Scenario/Types/TaskParkedVehicleScenario.h"
  113. #include "Task/Scenario/Types/TaskUseScenario.h"
  114. #include "Task/Service/Police/TaskPolicePatrol.h"
  115. #include "Task/Service/Swat/TaskSwat.h"
  116. #include "Task/System/Task.h"
  117. #include "Task/Animation/TaskAnims.h"
  118. #include "Task/Animation/TaskScriptedAnimation.h"
  119. #include "Task/System/TaskManager.h"
  120. #include "Task/Vehicle/TaskCar.h"
  121. #include "Task/Vehicle/TaskCarAccessories.h"
  122. #include "Task/Vehicle/TaskCarUtils.h"
  123. #include "Task/Vehicle/TaskEnterVehicle.h"
  124. #include "Task/Vehicle/TaskExitVehicle.h"
  125. #include "Task/Vehicle/TaskMountAnimal.h"
  126. #include "Task/Vehicle/TaskRideTrain.h"
  127. #include "Task/Vehicle/TaskVehicleWeapon.h"
  128. #include "Task/Weapons/Gun/TaskGun.h"
  129. #include "Task/Weapons/Gun/TaskAimGunScripted.h"
  130. #include "Task/Weapons/Gun/TaskReloadGun.h"
  131. #include "Task/Weapons/Gun/Metadata/ScriptedGunTaskInfo.h"
  132. #include "Task/Weapons/Gun/Metadata/ScriptedGunTaskInfoMetadataMgr.h"
  133. #include "Task/Weapons/Gun/TaskVehicleDriveBy.h"
  134. #include "Task/Weapons/TaskBomb.h"
  135. #include "Task/Weapons/TaskProjectile.h"
  136. #include "Task/Weapons/TaskSwapWeapon.h"
  137. #include "Task/Weapons/WeaponController.h"
  138. #include "debug/DebugScene.h"
  139. #include "vehicleAi/vehicleintelligence.h"
  140. #include "vehicleAi/Task/TaskVehicleGoTo.h"
  141. #include "vehicleAi/Task/TaskVehicleGotoAutomobile.h"
  142. #include "vehicleAi/Task/TaskVehicleGoToHelicopter.h"
  143. #include "vehicleAi/Task/TaskVehicleGoToPlane.h"
  144. #include "vehicleAi/Task/TaskVehicleGoToSubmarine.h"
  145. #include "vehicleAi/Task/TaskVehicleAttack.h"
  146. #include "vehicleAi/Task/TaskVehicleBlock.h"
  147. #include "vehicleAi/Task/TaskVehicleCircle.h"
  148. #include "vehicleAi/Task/TaskVehicleCruise.h"
  149. #include "vehicleAi/Task/TaskVehicleDeadDriver.h"
  150. #include "vehicleAi/Task/TaskVehicleEscort.h"
  151. #include "vehicleAi/Task/TaskVehicleFlying.h"
  152. #include "vehicleAi/Task/TaskVehicleFollowRecording.h"
  153. #include "vehicleAi/Task/TaskVehicleGoToLongRange.h"
  154. #include "vehicleAi/Task/TaskVehicleHeliProtect.h"
  155. #include "vehicleAi/Task/TaskVehiclePark.h"
  156. #include "vehicleAi/Task/TaskVehiclePoliceBehaviour.h"
  157. #include "vehicleAi/Task/TaskVehicleTempAction.h"
  158. #include "vehicleAi/Task/TaskVehicleThreePointTurn.h"
  159. #include "vehicleAi/task/TaskVehicleAnimation.h"
  160. #include "vehicleAi/task/TaskVehiclePursue.h"
  161. #include "vehicleAi/task/TaskVehicleLandPlane.h"
  162. #include "vehicles/Metadata/VehicleEntryPointInfo.h"
  163. #include "vehicles/Planes.h"
  164. #include "Weapons/Info/WeaponInfoManager.h"
  165.  
  166. //Rage headers
  167. #include "script/wrapper.h"
  168.  
  169. SCRIPT_OPTIMISATIONS ()
  170. AI_OPTIMISATIONS()
  171. AI_VEHICLE_OPTIMISATIONS()
  172.  
  173. namespace task_commands
  174. {
  175. void UpdatePedRagdollBoundsForScriptActivation(CPed* pPed)
  176. {
  177. // only need to do this if we're in the viewport, not in ragdoll already and our capsule physics isn't active
  178. if (pPed && pPed->GetIsVisibleInSomeViewportThisFrame() && !pPed->GetUsingRagdoll())
  179. {
  180. pPed->UpdateRagdollRootTransformFromAnimatedSkel();
  181. pPed->UpdateRagdollBoundsFromAnimatedSkel();
  182. }
  183. }
  184.  
  185.  
  186. void CommandTaskToggleDuck( int PedIndex, s32 iToggleType )
  187. {
  188. if (SCRIPT_VERIFY(CGameConfig::Get().AllowCrouchedMovement(), "TASK_TOGGLE_DUCK - Crouch is disabled" ))
  189. {
  190. CTask* pTask = rage_new CTaskCrouchToggle(iToggleType);
  191. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_TOGGLE_DUCK, "TASK_TOGGLE_DUCK");
  192. }
  193. }
  194.  
  195. void CommandTaskPause(int PedIndex, int Time)
  196. {
  197. CTask* pTask=rage_new CTaskPause(Time);
  198. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_PAUSE, "TASK_PAUSE");
  199. }
  200.  
  201. void CommandTaskStandStill(int PedIndex, int StandStillTime)
  202. {
  203. if (SCRIPT_VERIFY((StandStillTime == -1) || (StandStillTime > 0) ,"TASK_STAND_STILL - Time must be -1 for infinite, otherwise > 0" ))
  204. {
  205. const int numFramesToRun = 0; // no frame limit
  206. const bool bMakeMountStandStill = true;
  207. const bool bEnableTimeslicing = (StandStillTime == -1);
  208. CTask* pTask = rage_new CTaskDoNothing(StandStillTime, numFramesToRun, bMakeMountStandStill, bEnableTimeslicing);
  209. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_STAND_STILL, "TASK_STAND_STILL");
  210. }
  211. }
  212.  
  213. void CommandTaskJump(int PedIndex, bool UNUSED_PARAM(UsePlayerLaunchForce), bool DoSuperJump, bool UseFullSuperJumpForce)
  214. {
  215. s32 nFlags = JF_DisableVault;
  216.  
  217. if (DoSuperJump)
  218. nFlags |= JF_SuperJump | JF_BeastJump;
  219.  
  220. if (UseFullSuperJumpForce)
  221. nFlags |= JF_AIUseFullForceBeastJump;
  222.  
  223. CTask* pTask=rage_new CTaskJumpVault(nFlags);
  224.  
  225. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_JUMP, "TASK_JUMP");
  226. }
  227.  
  228. void CommandTaskCower(int PedIndex, int Time)
  229. {
  230. if (SCRIPT_VERIFY((Time == -1) || (Time > 0) ,"TASK_COWER - Time must be -1 for infinite and > 0" ))
  231. {
  232. CTask* pTask=rage_new CTaskCower(Time);
  233. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_COWER, "TASK_COWER");
  234. }
  235. }
  236.  
  237. void CommandTaskHandsUp(int PedIndex, int Time, int PedToFaceIndex, int TimeToFacePed, int Flags)
  238. {
  239. if (SCRIPT_VERIFY((Time == -1) || (Time > 0) ,"TASK_HANDS_UP - Time must be -1 for infinite and > 0" ))
  240. {
  241. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedToFaceIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES_NO_DEAD_CHECK ^ CTheScripts::GUID_ASSERT_FLAG_ENTITY_EXISTS);
  242. CTask* pTask=rage_new CTaskHandsUp(Time, pPed, TimeToFacePed, Flags);
  243. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_HANDS_UP, "TASK_HANDS_UP");
  244. }
  245. }
  246.  
  247. void CommandUpdateTaskHandsUpDuration(int PedIndex, int Time)
  248. {
  249. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  250. if (pPed && pPed->GetPedIntelligence())
  251. {
  252. CTaskHandsUp* pTaskHandsUp = static_cast<CTaskHandsUp*>(pPed->GetPedIntelligence()->FindTaskByType(CTaskTypes::TASK_HANDS_UP));
  253. if (SCRIPT_VERIFY (pTaskHandsUp, "UPDATE_TASK_HANDS_UP_DURATION - task is not running!"))
  254. {
  255. pTaskHandsUp->SetDuration(Time);
  256. }
  257. }
  258. }
  259.  
  260. void CommandTaskDuck(int PedIndex, int Time)
  261. {
  262. if (SCRIPT_VERIFY(CGameConfig::Get().AllowCrouchedMovement(), "TASK_DUCK - Crouch is disabled" ))
  263. {
  264. if (SCRIPT_VERIFY((Time == -1) || (Time > 0) ,"TASK_DUCK - Time must be -1 for infinite and > 0" ))
  265. {
  266. CTask* pTask;
  267.  
  268. if(-1==Time)
  269. {
  270. pTask=rage_new CTaskCrouch(0);
  271. }
  272. else
  273. {
  274. pTask=rage_new CTaskCrouch(Time);
  275. }
  276. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_DUCK, "TASK_DUCK");
  277. }
  278. }
  279. }
  280.  
  281. void ScriptPassengerTask( int iPedID, CVehicle *pVehicle, int iTime, SeatRequestType requestType, int iSeat, int UNUSED_PARAM(EnterStatus), float fMoveBlendRatio, VehicleEnterExitFlags iScriptFlags, fwMvClipSetId overrideClipsetId, const char* commandName)
  282. {
  283. float fTime = (float)iTime;
  284.  
  285. fTime/=1000.0f;
  286.  
  287. if( -1==iTime )
  288. {
  289. fTime = 0.0f;
  290. }
  291. else if( iTime > 0 )
  292. {
  293. iScriptFlags.BitSet().Set(CVehicleEnterExitFlags::WarpAfterTime);
  294. }
  295.  
  296. // Convert the time into seconds
  297. CTask* pTask = rage_new CTaskEnterVehicle(pVehicle, requestType, iSeat, iScriptFlags, fTime, fMoveBlendRatio, NULL, overrideClipsetId);
  298. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_ENTER_VEHICLE, commandName);
  299. }
  300.  
  301. void ScriptDriverTask( int iPedID, CVehicle *pVehicle, int iTime, int UNUSED_PARAM(EnterStatus), VehicleEnterExitFlags iScriptFlags, float fMoveBlendRatio, fwMvClipSetId overrideClipsetId, const char* commandName)
  302. {
  303. s32 seat = pVehicle->GetDriverSeat();
  304.  
  305. float fTime = (float)iTime;
  306.  
  307. if( -1==iTime )
  308. {
  309. fTime = 0.0f;
  310. }
  311. else if( iTime >= 0 )
  312. {
  313. iScriptFlags.BitSet().Set(CVehicleEnterExitFlags::WarpAfterTime);
  314. }
  315.  
  316. // Convert the time into seconds
  317. fTime/=1000.0f;
  318.  
  319. CScriptPeds::GivePedScriptedTask( iPedID, rage_new CTaskEnterVehicle(pVehicle, SR_Specific, seat, iScriptFlags, fTime, fMoveBlendRatio, NULL, overrideClipsetId), SCRIPT_TASK_ENTER_VEHICLE, commandName);
  320. }
  321.  
  322. void CommandTaskOpenVehicleDoor( int iPedID, int iVehicleID, int iTime, int iSeat, float fMoveBlendRatio)
  323. {
  324. SeatRequestType seatRequestType = SR_Specific;
  325. s32 iSeatRequest = iSeat+1;
  326. if( iSeat == -2 )
  327. {
  328. seatRequestType = SR_Any;
  329. }
  330.  
  331. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0) ,"TASK_OPEN_VEHICLE_DOOR - Time must be -1 for infinite and > 0" ))
  332. {
  333. CVehicle *pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  334. if (pVehicle)
  335. {
  336. VehicleEnterExitFlags vehicleFlags;
  337. vehicleFlags.BitSet().Set(CVehicleEnterExitFlags::JustOpenDoor);
  338. if (iSeatRequest != 0)
  339. {
  340. if (SCRIPT_VERIFY(iSeatRequest < pVehicle->GetSeatManager()->GetMaxSeats(), "TASK_OPEN_VEHICLE_DOOR - seat doesn't exist"))
  341. {
  342. ScriptPassengerTask(iPedID, pVehicle, iTime, seatRequestType, iSeatRequest, 0, fMoveBlendRatio, vehicleFlags, CLIP_SET_ID_INVALID, "TASK_OPEN_VEHICLE_DOOR");
  343. }
  344. }
  345. else
  346. {
  347. if (SCRIPT_VERIFY (!pVehicle->GetDriver(), "TASK_OPEN_VEHICLE_DOOR - Vehicle already has a driver"))
  348. {
  349. ScriptDriverTask(iPedID, pVehicle, iTime, 0, vehicleFlags, fMoveBlendRatio, CLIP_SET_ID_INVALID, "TASK_OPEN_VEHICLE_DOOR");
  350. }
  351. }
  352. }
  353. }
  354. }
  355.  
  356.  
  357. void CommandTaskEnterVehicle( int iPedID, int iVehicleID, int iTime, int iSeat, float fMoveBlendRatio, const int iScriptFlags, const char* szOverrideEntryClipsetName )
  358. {
  359. VehicleEnterExitFlags iFlags;
  360. CTaskVehicleFSM::SetScriptedVehicleEntryExitFlags(iFlags, iScriptFlags);
  361.  
  362. SeatRequestType seatRequestType = SR_Specific;
  363. s32 iSeatRequest = iSeat+1;
  364. if( iSeat == -2 )
  365. {
  366. seatRequestType = SR_Any;
  367. }
  368.  
  369. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0) ,"TASK_ENTER_VEHICLE - Time must be -1 for infinite and > 0" ))
  370. {
  371. CVehicle *pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  372. if (pVehicle)
  373. {
  374. #if __ASSERT
  375. const bool bIsTrailerLarge = MI_TRAILER_TRAILERLARGE.IsValid() && pVehicle->GetModelIndex() == MI_TRAILER_TRAILERLARGE;
  376. if (bIsTrailerLarge)
  377. {
  378. AI_LOG_WITH_ARGS("Ped with index %i is being placed into the trailerlarge from %s", iPedID, CTheScripts::GetCurrentScriptNameAndProgramCounter());
  379. AI_LOG_STACK_TRACE(8);
  380. }
  381. #endif // __ASSERT
  382. fwMvClipSetId overrideClipsetId = CLIP_SET_ID_INVALID;
  383.  
  384. //look for an clip set with this name
  385. if (szOverrideEntryClipsetName)
  386. {
  387. if (fwClipSetManager::GetClipSet(fwMvClipSetId(szOverrideEntryClipsetName)))
  388. {
  389. overrideClipsetId.SetFromString(szOverrideEntryClipsetName);
  390. #if __ASSERT
  391. scriptAssertf(fwClipSetManager::IsStreamedIn_DEPRECATED(overrideClipsetId), "TASK_ENTER_VEHICLE - Clip set %s is not loaded yet:", szOverrideEntryClipsetName);
  392. #endif // __ASSERT
  393. }
  394. #if __ASSERT
  395. else
  396. {
  397. scriptAssertf(0, "Couldn't find clipset with name %s", szOverrideEntryClipsetName);
  398. }
  399. #endif // __ASSERT
  400. }
  401.  
  402. if (iSeatRequest != 0)
  403. {
  404. if (SCRIPT_VERIFY(iSeatRequest < pVehicle->GetSeatManager()->GetMaxSeats(), "TASK_ENTER_VEHICLE - seat doesn't exist"))
  405. {
  406. ScriptPassengerTask(iPedID, pVehicle, iTime, seatRequestType, iSeatRequest, 0, fMoveBlendRatio, iFlags, overrideClipsetId, "TASK_ENTER_VEHICLE");
  407. }
  408. }
  409. else
  410. {
  411. // See if the vehicle has a driver already, if they are still running the enter vehicle task then they must be shuffling
  412. // so discount them
  413. CPed* pDriver = pVehicle->GetDriver();
  414. if (pDriver && pDriver->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_ENTER_VEHICLE))
  415. {
  416. pDriver = NULL;
  417. }
  418.  
  419. //driver seat
  420. if (SCRIPT_VERIFY(!pDriver || (iFlags.BitSet().IsSet(CVehicleEnterExitFlags::JackIfOccupied)), "TASK_ENTER_VEHICLE - Vehicle already has a driver"))
  421. {
  422. ScriptDriverTask(iPedID, pVehicle, iTime, 0, iFlags, fMoveBlendRatio, overrideClipsetId, "TASK_ENTER_VEHICLE");
  423. }
  424. }
  425. }
  426. }
  427.  
  428. }
  429.  
  430. void CommandTaskLeaveVehicle( int iPedID, int iVehicleID, s32 iScriptFlags )
  431. {
  432. CVehicle *pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  433. if (pVehicle)
  434. {
  435. VehicleEnterExitFlags vehicleFlags;
  436. CTaskVehicleFSM::SetScriptedVehicleEntryExitFlags(vehicleFlags, iScriptFlags);
  437. vehicleFlags.BitSet().Set(CVehicleEnterExitFlags::DontJackAnyone);
  438. CTask* pTask=rage_new CTaskExitVehicle(pVehicle,vehicleFlags);
  439. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_LEAVE_VEHICLE, "TASK_LEAVE_VEHICLE");
  440. }
  441. }
  442.  
  443. void CommandTaskVehicleDriveToCoord_Intern( int iPedID, int iVehicleID, const Vector3 &VecCoors_, float CruiseSpeed, int iMode, int UNUSED_PARAM(VehicleModelHashKey), int iDrivingFlags, float TargetRadius, float StraightLineDist)
  444. {
  445. Vector3 VecCoors = VecCoors_;
  446.  
  447. TUNE_GROUP_BOOL(RACING_AI, RACING_actuallyGoFast, false);
  448. TUNE_GROUP_FLOAT(RACING_AI, RACING_actuallyGoFastSpeed, 50.0f, 0.0, 100.0f, 0.1f);
  449. if(RACING_actuallyGoFast)
  450. {
  451. CruiseSpeed = RACING_actuallyGoFastSpeed;
  452. }
  453.  
  454. CTask* pTask = NULL;
  455. CVehicle *pVehicle = NULL;
  456.  
  457. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  458. if (!pVehicle)
  459. {
  460. return;
  461. }
  462.  
  463. if (VecCoors.z <= INVALID_MINIMUM_WORLD_Z)
  464. {
  465. VecCoors.z = WorldProbe::FindGroundZForCoord(TOP_SURFACE, VecCoors.x, VecCoors.y);
  466. }
  467.  
  468. if (StraightLineDist < 0.0f)
  469. {
  470. StraightLineDist = sVehicleMissionParams::DEFAULT_SWITCH_TO_STRAIGHT_LINE_DIST;
  471. }
  472.  
  473. // The old driving styles are still present in the script headers, until we remove them this will
  474. // At least make drivingstyle reversing work.
  475. if( iMode == 2 )
  476. {
  477. iDrivingFlags |= DF_DriveInReverse;
  478. }
  479.  
  480. aiTask *pVehicleTask = CVehicleIntelligence::GetGotoTaskForVehicle(pVehicle, NULL, &VecCoors, iDrivingFlags, TargetRadius, StraightLineDist, CruiseSpeed);
  481. pTask = rage_new CTaskControlVehicle(pVehicle, pVehicleTask );
  482.  
  483. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_VEHICLE_DRIVE_TO_COORD, "TASK_VEHICLE_DRIVE_TO_COORD");
  484. }
  485.  
  486. void CommandTaskVehicleDriveToCoord( int iPedID, int iVehicleID, const scrVector & scrVecCoors, float CruiseSpeed, int iMode, int VehicleModelHashKey, int iDrivingFlags, float TargetRadius, float StraightLineDist )
  487. {
  488. Vector3 VecCoors = Vector3 (scrVecCoors);
  489.  
  490. CommandTaskVehicleDriveToCoord_Intern( iPedID, iVehicleID, VecCoors, CruiseSpeed, iMode, VehicleModelHashKey, iDrivingFlags, TargetRadius, StraightLineDist );
  491. }
  492.  
  493. void CommandTaskVehicleDriveToCoordLongRange(int iPedID, int iVehicleID, const scrVector & scrVecCoors, float CruiseSpeed, int iDrivingFlags, float TargetRadius)
  494. {
  495. Vector3 VecCoors = Vector3(scrVecCoors);
  496.  
  497. CTask* pTask = NULL;
  498. CVehicle *pVehicle = NULL;
  499.  
  500. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  501. if (!pVehicle)
  502. {
  503. return;
  504. }
  505.  
  506. if (VecCoors.z <= INVALID_MINIMUM_WORLD_Z)
  507. {
  508. VecCoors.z = WorldProbe::FindGroundZForCoord(TOP_SURFACE, VecCoors.x, VecCoors.y);
  509. }
  510.  
  511. //aiTask *pVehicleTask = CVehicleIntelligence::GetGotoTaskForVehicle(pVehicle, NULL, &VecCoors, iDrivingFlags, TargetRadius, StraightLineDist, CruiseSpeed);
  512. sVehicleMissionParams params;
  513. params.SetTargetPosition(VecCoors);
  514. params.m_iDrivingFlags = iDrivingFlags;
  515. params.m_fTargetArriveDist = TargetRadius;
  516. params.m_fCruiseSpeed = CruiseSpeed;
  517.  
  518. CTask* pVehicleTask = rage_new CTaskVehicleGotoLongRange(params);
  519. pTask = rage_new CTaskControlVehicle(pVehicle, pVehicleTask );
  520.  
  521. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE, "TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE");
  522. }
  523.  
  524. #if ENABLE_HORSE
  525.  
  526. void CommandTaskMountAnimal( int iPedID, int iMountID, int iTime, int iSeat, float fMoveBlendRatio, const int iFlags )
  527. {
  528. s32 iSeatRequest = iSeat+1;
  529.  
  530. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0) ,"TASK_MOUNT_ANIMAL - Time must be -1 for infinite and > 0" ))
  531. {
  532. // if this task is being added to a sequence, don't do a clone check on the mount
  533. unsigned assertFlags = (iPedID == NULL_IN_SCRIPTING_LANGUAGE) ? CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES : CTheScripts::GUID_ASSERT_FLAGS_ALL;
  534.  
  535. CPed *pMount = CTheScripts::GetEntityToModifyFromGUID<CPed>(iMountID, assertFlags);
  536. if (pMount)
  537. {
  538. if (iSeatRequest != 0)
  539. {
  540. scriptAssertf(false, "Non-driver's on mounts not yet supported by TASK_MOUNT_ANIMAL");
  541. }
  542. else
  543. {
  544. VehicleEnterExitFlags vehicleFlags;
  545. CTaskVehicleFSM::SetScriptedVehicleEntryExitFlags(vehicleFlags, iFlags);
  546.  
  547. //driver seat
  548. if (SCRIPT_VERIFY(!pMount->GetSeatManager()->GetDriver() || vehicleFlags.BitSet().IsSet(CVehicleEnterExitFlags::JackIfOccupied), "TASK_MOUNT_ANIMAL - Mount already has a driver"))
  549. {
  550. s32 seat = pMount->GetPedModelInfo()->GetModelSeatInfo()->GetDriverSeat();
  551.  
  552. float fTime = (float)iTime;
  553. if( -1==iTime )
  554. {
  555. fTime = 0.0f;
  556. }
  557. else if( iTime >= 0 )
  558. {
  559. vehicleFlags.BitSet().Set(CVehicleEnterExitFlags::WarpAfterTime);
  560. }
  561. // Convert the time into seconds
  562. fTime/=1000.0f;
  563.  
  564. CScriptPeds::GivePedScriptedTask( iPedID, rage_new CTaskMountAnimal(pMount, SR_Specific, seat, vehicleFlags, fTime, fMoveBlendRatio), SCRIPT_TASK_MOUNT_ANIMAL, "TASK_MOUNT_ANIMAL");
  565. }
  566. }
  567. }
  568. }
  569. }
  570.  
  571. void CommandTaskDismountAnimal( int iPedID, s32 iScriptFlags )
  572. {
  573. CPed *pMount = NULL;
  574. if(iPedID != NULL_IN_SCRIPTING_LANGUAGE) {
  575. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  576. if (pPed)
  577. {
  578. pMount = pPed->GetMyMount();
  579. if (!pMount)
  580. {
  581. return;
  582. }
  583. }
  584. }
  585.  
  586. VehicleEnterExitFlags vehicleFlags;
  587. CTaskVehicleFSM::SetScriptedVehicleEntryExitFlags(vehicleFlags, iScriptFlags);
  588. vehicleFlags.BitSet().Set(CVehicleEnterExitFlags::DontJackAnyone);
  589. CTask* pTask=rage_new CTaskDismountAnimal(vehicleFlags);
  590. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_DISMOUNT_ANIMAL, "TASK_DISMOUNT_ANIMAL");
  591. }
  592.  
  593. #else
  594.  
  595. void CommandTaskMountAnimal( int UNUSED_PARAM(iPedID), int UNUSED_PARAM(iMountID), int UNUSED_PARAM(iTime), int UNUSED_PARAM(iSeat), float UNUSED_PARAM(fMoveBlendRatio), const int UNUSED_PARAM(iFlags) )
  596. {
  597. }
  598.  
  599. void CommandTaskDismountAnimal( int UNUSED_PARAM(iPedID), s32 UNUSED_PARAM(iScriptFlags) )
  600. {
  601. }
  602.  
  603. #endif
  604.  
  605. void CommandTaskVehicleDriveWander( int iPedID, int iVehicleID, float fSpeed, int iDrivingFlags )
  606. {
  607. CVehicle *pVehicle = NULL;
  608. if(iVehicleID != NULL_IN_SCRIPTING_LANGUAGE)
  609. {
  610. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  611. }
  612.  
  613. if (!SCRIPT_VERIFY(pVehicle, "TASK_VEHICLE_DRIVE_WANDER needs a valid vehicle"))
  614. {
  615. return;
  616. }
  617.  
  618. // cap cruise speed to the maximum
  619. float fCruiseSpeed = rage::Min(fSpeed, CTaskVehicleMissionBase::MAX_CRUISE_SPEED);
  620.  
  621. CTask* pTask=rage_new CTaskCarDriveWander(pVehicle, iDrivingFlags, fCruiseSpeed);
  622. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_VEHICLE_DRIVE_WANDER, "TASK_VEHICLE_DRIVE_WANDER");
  623. }
  624.  
  625. void CommandTaskGoStraightToCoord(int PedIndex, const scrVector &scrVecCoors, float MoveBlendRatio, int Time, const float fTargetHeading, const float fInTargetRadius)
  626. {
  627. if (SCRIPT_VERIFY((Time == -1) || (Time > 0) ,"TASK_GO_STRAIGHT_TO_COORD - Time must be -1 for infinite and > 0" ))
  628. {
  629. CTask* pTask;
  630.  
  631. Vector3 vTarget(scrVecCoors);
  632.  
  633. const float fTargetRadius = fInTargetRadius;//CTaskMoveGoToPointAndStandStill::ms_fTargetRadius;
  634. const float fSlowDownDistance = CTaskMoveGoToPointAndStandStill::ms_fSlowDownDistance;
  635. float fMainTaskTimer = 0.0f;
  636. if(-1==Time)
  637. {
  638. pTask=rage_new CTaskMoveGoToPointAndStandStill(MoveBlendRatio,vTarget,fTargetRadius,fSlowDownDistance,false,true, fTargetHeading<DEFAULT_NAVMESH_FINAL_HEADING ? DtoR * fTargetHeading : fTargetHeading);
  639. }
  640. else
  641. {
  642. fMainTaskTimer = (float)Time/1000.0f;
  643. if( fMainTaskTimer > 0.0f )
  644. fMainTaskTimer += 2.0f;
  645.  
  646. int iTime = Max(CTaskComplexGoToPointAndStandStillTimed::ms_iTime, Time);
  647. pTask=rage_new CTaskComplexGoToPointAndStandStillTimed(MoveBlendRatio,vTarget,fTargetRadius,fSlowDownDistance, iTime, true, fTargetHeading<DEFAULT_NAVMESH_FINAL_HEADING ? DtoR * fTargetHeading : fTargetHeading);
  648. }
  649.  
  650. pTask = rage_new CTaskComplexControlMovement( pTask, NULL, CTaskComplexControlMovement::TerminateOnMovementTask, fMainTaskTimer );
  651. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_GO_STRAIGHT_TO_COORD, "TASK_GO_STRAIGHT_TO_COORD");
  652. }
  653. }
  654.  
  655. void CommandTaskGoStraightToCoordRelativeToEntity(int PedIndex, int EntityIndex, const scrVector & scrVecCoors, float MoveBlendRatio, int Time)
  656. {
  657. Vector3 vLocalTarget(scrVecCoors);
  658. const float fTargetRadius = CTaskMoveGoToPointAndStandStill::ms_fTargetRadius;
  659.  
  660. if (SCRIPT_VERIFY((Time == -1) || (Time > 0) ,"TASK_GO_STRAIGHT_TO_COORD_RELATIVE_TO_ENTITY - Time must be -1 for infinite and > 0" ))
  661. {
  662. const CEntity *pEntity = CTheScripts::GetEntityToQueryFromGUID<CEntity>(EntityIndex);
  663. if (pEntity)
  664. {
  665. CTaskMoveGoToPointRelativeToEntityAndStandStill * pMoveTask = rage_new CTaskMoveGoToPointRelativeToEntityAndStandStill(
  666. pEntity,
  667. MoveBlendRatio,
  668. vLocalTarget,
  669. fTargetRadius,
  670. Time
  671. );
  672.  
  673. CTask * pTask = rage_new CTaskComplexControlMovement( pMoveTask );
  674. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_GO_STRAIGHT_TO_COORD_RELATIVE_TO_ENTITY, "TASK_GO_STRAIGHT_TO_COORD_RELATIVE_TO_ENTITY");
  675. }
  676. }
  677. }
  678.  
  679. void CommandTaskAchieveHeading(int PedIndex, float fHeadingDegrees, int iTime)
  680. {
  681. float fTime;
  682. if(iTime < 0)
  683. {
  684. fTime = -1.0f;
  685. }
  686. else if(iTime == 0)
  687. {
  688. fTime = 0.0f;
  689. }
  690. else
  691. {
  692. fTime = ((float)iTime)/1000.0f;
  693. }
  694. const float fHeadingRadians=( DtoR * fHeadingDegrees);
  695. CTask* pTask=rage_new CTaskMoveAchieveHeading(fHeadingRadians, CTaskMoveAchieveHeading::ms_fHeadingChangeRateFrac, CTaskMoveAchieveHeading::ms_fHeadingTolerance, fTime);
  696. pTask = rage_new CTaskComplexControlMovement( pTask );
  697. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_ACHIEVE_HEADING, "TASK_ACHIEVE_HEADING");
  698. }
  699.  
  700. void CommandFlushRoute()
  701. {
  702. CTaskMoveFollowPointRoute::ms_pointRoute.Clear();
  703. }
  704.  
  705. void CommandExtendRoute(const scrVector & scrVecCoors)
  706. {
  707. Vector3 vTarget(scrVecCoors);
  708. if (CTaskMoveFollowPointRoute::ms_pointRoute.Add(vTarget) == false)
  709. {
  710. scriptAssertf(0, "%s:EXTEND_ROUTE - too many points in this route ", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  711. }
  712. }
  713.  
  714. void CommandTaskFollowToOffsetOfEntity(int PedIndex, int EntityIndex, const scrVector & scrVecOffset, float MoveBlendRatio, int Time, float Radius, bool RelativeOffset)
  715. {
  716. Vector3 Offset(scrVecOffset);
  717. const CPhysical* pEntity = CTheScripts::GetEntityToQueryFromGUID<CPhysical>(EntityIndex);
  718.  
  719. if (pEntity)
  720. {
  721. if (SCRIPT_VERIFY((Time == -1) || (Time > 0) ,"TASK_FOLLOW_TO_OFFSET_OF_PED - Time must be -1 for infinite and > 0" ))
  722. {
  723. CTask* pTask= rage_new CTaskComplexControlMovement(rage_new CTaskMoveFollowEntityOffset(pEntity, MoveBlendRatio, Radius, Offset, Time, RelativeOffset));
  724. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_FOLLOW_TO_OFFSET_OF_ENTITY, "TASK_FOLLOW_TO_OFFSET_OF_ENTITY");
  725. }
  726. }
  727. }
  728.  
  729.  
  730. void CommandTaskFollowToOffsetOfPickup(int PedIndex, int PickupID, const scrVector & scrVecOffset, float MoveBlendRatio, int Time, float Radius, bool RelativeOffset)
  731. {
  732. if (SCRIPT_VERIFY((Time == -1) || (Time > 0) ,"TASK_FOLLOW_TO_OFFSET_OF_PICKUP - Time must be -1 for infinite and > 0" ))
  733. {
  734. if (scriptVerify(CTheScripts::GetCurrentGtaScriptHandler()))
  735. {
  736. scriptHandlerObject* pScriptHandlerObject = CTheScripts::GetCurrentGtaScriptHandler()->GetScriptObject(PickupID);
  737.  
  738. if (scriptVerifyf(pScriptHandlerObject, "%s: TASK_FOLLOW_TO_OFFSET_OF_PICKUP - failed to find script handler object for pickup ID", CTheScripts::GetCurrentScriptNameAndProgramCounter()))
  739. {
  740. if (scriptVerifyf(static_cast<CGameScriptHandlerObject*>(pScriptHandlerObject)->GetType() == SCRIPT_HANDLER_OBJECT_TYPE_PICKUP, "%s: TASK_FOLLOW_TO_OFFSET_OF_PICKUP - This is not a pickup id", CTheScripts::GetCurrentScriptNameAndProgramCounter()))
  741. {
  742. CPickupPlacement* pPlacement = static_cast<CPickupPlacement*>(pScriptHandlerObject);
  743.  
  744. if (SCRIPT_VERIFY(pPlacement,"TASK_FOLLOW_TO_OFFSET_OF_PICKUP - Pickup does not exist"))
  745. {
  746. if (SCRIPT_VERIFY(!pPlacement->GetIsCollected(), "TASK_FOLLOW_TO_OFFSET_OF_PICKUP - pickup has already been collected"))
  747. {
  748. if (SCRIPT_VERIFY(!pPlacement->GetHasPickupBeenDestroyed(), "TASK_FOLLOW_TO_OFFSET_OF_PICKUP - pickup has been destroyed"))
  749. {
  750. const CPickup *pPickup = pPlacement->GetPickup();
  751. if (SCRIPT_VERIFY(pPickup, "TASK_FOLLOW_TO_OFFSET_OF_PICKUP - pickup object for this pickup placement is NULL"))
  752. {
  753. Vector3 Offset(scrVecOffset);
  754. CTask* pTask= rage_new CTaskComplexControlMovement(rage_new CTaskMoveFollowEntityOffset(pPickup, MoveBlendRatio, Radius, Offset, Time, RelativeOffset));
  755. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_FOLLOW_TO_OFFSET_OF_PICKUP, "TASK_FOLLOW_TO_OFFSET_OF_PICKUP");
  756. }
  757. }
  758. }
  759. }
  760. }
  761. }
  762. }
  763. }
  764. }
  765.  
  766.  
  767. void CommandTaskFollowPointRoute(int PedIndex, float MoveBlendRatio, int Mode)
  768. {
  769. if (SCRIPT_VERIFY (((CTaskMoveFollowPointRoute::TICKET_SINGLE==Mode) ||
  770. (CTaskMoveFollowPointRoute::TICKET_RETURN==Mode) ||
  771. (CTaskMoveFollowPointRoute::TICKET_SEASON==Mode) ||
  772. (CTaskMoveFollowPointRoute::TICKET_LOOP==Mode)),
  773. "TASK_FOLLOW_POINT_ROUTE - invalid mode"))
  774. {
  775. CTask* pTask=rage_new CTaskMoveFollowPointRoute(MoveBlendRatio,CTaskMoveFollowPointRoute::ms_pointRoute,Mode);
  776. pTask = rage_new CTaskComplexControlMovement( pTask );
  777. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_FOLLOW_POINT_ROUTE, "TASK_FOLLOW_POINT_ROUTE");
  778. }
  779. }
  780.  
  781. // Please keep this in sync with the enumeration in "commands_task.sch"
  782. enum EGOTO_ENTITY_SCRIPT_FLAGS
  783. {
  784. EGOTO_ENTITY_NEVER_SLOW_FOR_PATH_LENGTH = 0x01,
  785. };
  786.  
  787. void CommandTaskGoToEntity(int PedIndex, int EntityIndex, int Time, float SeekRadius, float MoveBlendRatio, float fSlowDownDistance, int iFlags)
  788. {
  789. const CEntity* pEntity = CTheScripts::GetEntityToQueryFromGUID<CEntity>(EntityIndex);
  790.  
  791. if (pEntity)
  792. {
  793. if (SCRIPT_VERIFY((Time == -1) || (Time > 0) ,"TASK_GOTO_ENTITY - Time must be -1 for infinite and > 0" ))
  794. {
  795. if (NetworkInterface::IsGameInProgress() && (!pEntity->GetIsDynamic() || !((CDynamicEntity*)pEntity)->GetNetworkObject()))
  796. {
  797. scriptAssertf(0, "%s:TASK_GOTO_ENTITY; the entity must be networked or this ped will not be able to migrate properly", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  798. }
  799.  
  800. CTask* pMoveTask=rage_new TTaskMoveSeekEntityStandard(pEntity, Time, TTaskMoveSeekEntityStandard::ms_iPeriod, SeekRadius);
  801. ((TTaskMoveSeekEntityStandard*)pMoveTask)->SetMoveBlendRatio(MoveBlendRatio);
  802. // scripted seek entity, so we use larger search extents
  803. ((TTaskMoveSeekEntityStandard*)pMoveTask)->SetUseLargerSearchExtents(true);
  804. ((TTaskMoveSeekEntityStandard*)pMoveTask)->SetUseAdaptiveUpdateFreq(true);
  805. ((TTaskMoveSeekEntityStandard*)pMoveTask)->SetSlowDownDistance(fSlowDownDistance);
  806.  
  807. if((iFlags & EGOTO_ENTITY_NEVER_SLOW_FOR_PATH_LENGTH)!=0)
  808. {
  809. ((TTaskMoveSeekEntityStandard*)pMoveTask)->SetNeverSlowDownForPathLength(true);
  810. }
  811.  
  812. CTask* pTask = rage_new CTaskComplexControlMovement( pMoveTask );
  813.  
  814. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_GO_TO_ENTITY, "TASK_GOTO_ENTITY");
  815. }
  816. }
  817. }
  818.  
  819. void CommandTaskSmartFleeCoord(int PedIndex, const scrVector & scrVecCoors, float SafeDistance, int Time, bool UNUSED_PARAM(bPreferPavements), bool bQuitIfOutOfRange)
  820. {
  821. if (SCRIPT_VERIFY((Time == -1) || (Time > 0) ,"TASK_SMART_FLEE_POINT - Time must be -1 for infinite and > 0" ))
  822. {
  823. if (SCRIPT_VERIFY(SafeDistance >= 0.0f ,"TASK_SMART_FLEE_POINT - SafeDistance must be >= 0.0" ))
  824. {
  825. Vector3 vTarget(scrVecCoors);
  826. CTaskSmartFlee* pTask = rage_new CTaskSmartFlee(CAITarget(vTarget),SafeDistance,Time);
  827. // scripted flee task, so we use larger search extents
  828. pTask->SetUseLargerSearchExtents(true);
  829. pTask->SetQuitIfOutOfRange(bQuitIfOutOfRange);
  830.  
  831. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_SMART_FLEE_POINT, "TASK_SMART_FLEE_POINT");
  832. }
  833. }
  834. }
  835.  
  836. void CommandTaskSmartFleePed(int PedIndex, int OtherPedIndex, float SafeDistance, int Time, bool UNUSED_PARAM(bPreferPavements), bool UNUSED_PARAM(bUpdateToNearestHatedPed))
  837. {
  838. if (SCRIPT_VERIFY((Time == -1) || (Time > 0) ,"TASK_SMART_FLEE_PED - Time must be -1 for infinite and > 0" ))
  839. {
  840. if (SCRIPT_VERIFY(SafeDistance >= 0.0f ,"TASK_SMART_FLEE_PED - SafeDistance must be >= 0.0" ))
  841. {
  842. const CPed* pOtherPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(OtherPedIndex);
  843. if (pOtherPed)
  844. {
  845. CTaskSmartFlee* pTask = rage_new CTaskSmartFlee(CAITarget(pOtherPed), // Target to flee from
  846. SafeDistance, // Distance to stop at
  847. Time, // Time to flee for
  848. CTaskSmartFlee::ms_uiEntityPosCheckPeriod,
  849. 0.0f, /*CTaskSmartFlee::ms_fEntityPosChangeThreshold*/
  850. false);
  851.  
  852. // scripted flee task, so we use larger search extents
  853. pTask->SetUseLargerSearchExtents(true);
  854. pTask->SetConsiderRunStartForPathLookAhead(true);
  855.  
  856. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_SMART_FLEE_PED, "TASK_SMART_FLEE_PED");
  857. }
  858. }
  859. }
  860. }
  861.  
  862. void CommandTaskReactAndFleeCoord(int PedIndex, const scrVector & scrVecCoors)
  863. {
  864. Vector3 vTarget(scrVecCoors);
  865. CTaskReactAndFlee* pTask = rage_new CTaskReactAndFlee(CAITarget(vTarget), CTaskReactAndFlee::BA_Gunfire);
  866.  
  867. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_REACT_AND_FLEE_COORD, "TASK_REACT_AND_FLEE_COORD");
  868. }
  869.  
  870. void CommandTaskReactAndFleePed(int PedIndex, int OtherPedIndex)
  871. {
  872. const CPed* pOtherPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(OtherPedIndex);
  873. if(pOtherPed)
  874. {
  875. CTaskReactAndFlee* pTask = rage_new CTaskReactAndFlee(CAITarget(pOtherPed), CTaskReactAndFlee::BA_Gunfire);
  876.  
  877. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_REACT_AND_FLEE_PED, "TASK_REACT_AND_FLEE_PED");
  878. }
  879. }
  880.  
  881. CEventShocking* GetShockingEventFromIDInternal(int EventIndex)
  882. {
  883. CEventGroupGlobal& global = *GetEventGlobalGroup();
  884. int num = global.GetNumEvents();
  885. for(int j = 0; j < num; j++)
  886. {
  887. fwEvent* ev = global.GetEventByIndex(j);
  888. if(!ev || !static_cast<CEvent*>(ev)->IsShockingEvent())
  889. {
  890. continue;
  891. }
  892.  
  893. CEventShocking* pShocking = static_cast<CEventShocking*>(ev);
  894.  
  895. // Check if we've found the event we're looking for.
  896. // Note: GetCreatedByScript() is here in case a script-created event timed out by itself,
  897. // and then a code-created one reused the same ID (which would require a wraparound, so it's
  898. // unlikely anyway). Since there are currently no commands to give scripts the ID numbers
  899. // of code-created shocking events, the only valid use of this command is for script-created
  900. // events.
  901. if(EventIndex == (int)pShocking->GetId() && pShocking->GetCreatedByScript())
  902. {
  903. return pShocking;
  904. }
  905. }
  906. return NULL;
  907. }
  908.  
  909. void CommandTaskShockingEventBackAway(int PedIndex, int EventIndex)
  910. {
  911. CEventShocking* pEvent = GetShockingEventFromIDInternal(EventIndex);
  912.  
  913. if (SCRIPT_VERIFY(pEvent, "Invalid event specified to react to!"))
  914. {
  915. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  916. if (SCRIPT_VERIFY(pPed, "Invalid PedIndex!"))
  917. {
  918. CTask* pTask = rage_new CTaskShockingEventBackAway(pEvent, CTaskShockingEventBackAway::GetDefaultBackAwayPositionForPed(*pPed));
  919.  
  920. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_SHOCKING_EVENT_BACK_AWAY, "TASK_SHOCKING_EVENT_BACK_AWAY");
  921. }
  922. }
  923. }
  924.  
  925. void CommandTaskShockingEventHurryAway(int PedIndex, int EventIndex)
  926. {
  927. CEventShocking* pEvent = GetShockingEventFromIDInternal(EventIndex);
  928.  
  929. if (SCRIPT_VERIFY(pEvent, "Invalid event specified to react to!"))
  930. {
  931. CTask* pTask = rage_new CTaskShockingEventHurryAway(pEvent);
  932.  
  933. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_SHOCKING_EVENT_HURRY_AWAY, "TASK_SHOCKING_EVENT_HURRY_AWAY");
  934. }
  935. }
  936.  
  937. void CommandTaskShockingEventReact(int PedIndex, int EventIndex)
  938. {
  939. CEventShocking* pEvent = GetShockingEventFromIDInternal(EventIndex);
  940.  
  941. if (SCRIPT_VERIFY(pEvent, "Invalid event specified to react to!"))
  942. {
  943. CTask* pTask = rage_new CTaskShockingEventReact(pEvent);
  944.  
  945. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_SHOCKING_EVENT_REACT, "TASK_SHOCKING_EVENT_REACT");
  946. }
  947. }
  948.  
  949. void CommandTaskWanderInArea(int PedIndex, const scrVector & scvCenter, float fRadius, float fMinWaitTime, float fMaxWaitTime)
  950. {
  951. if (SCRIPT_VERIFY(fMinWaitTime <= fMaxWaitTime, "MinWaitTime was greater than MaxWaitTime"))
  952. {
  953. Vec3V vCenter(scvCenter);
  954. CTask* pTask = rage_new CTaskWanderInArea(MOVEBLENDRATIO_WALK, fRadius, VEC3V_TO_VECTOR3(vCenter), fMinWaitTime, fMaxWaitTime);
  955. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_WANDER_IN_AREA, "TASK_WANDER_IN_AREA");
  956. }
  957. }
  958.  
  959. void CommandTaskWanderStandard(int PedIndex, float fHeading, int iFlags)
  960. {
  961. float fWanderHeading = (IsClose(fHeading, DEFAULT_NAVMESH_FINAL_HEADING, 0.1f) ? fwRandom::GetRandomNumberInRange(0.0f, TWO_PI) : fHeading* DtoR);
  962. CTaskWander * pTask = rage_new CTaskWander(MOVEBLENDRATIO_WALK, fWanderHeading);
  963.  
  964. if((iFlags & EWDR_KEEP_MOVING_WHILST_WAITING_FOR_PATH)!=0)
  965. {
  966. pTask->KeepMovingWhilstWaitingForFirstPath(NULL);
  967. }
  968.  
  969. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_WANDER_STANDARD, "TASK_WANDER_STANDARD");
  970. }
  971.  
  972. void CommandTaskWanderSpecific(int PedIndex, const char* CondtionalAnimGroupStr, const char* ConditonalAnimStr, float fHeading)
  973. {
  974. // Find the conditionalAnimsGroup
  975. const CConditionalAnimsGroup* pConditionalAnimGroup = CONDITIONALANIMSMGR.GetConditionalAnimsGroup(atHashString(CondtionalAnimGroupStr));
  976. if (scriptVerifyf(pConditionalAnimGroup, "TASK_WANDER_SPECIFIC called with invalid ConditionalAnimGroup name, (%s)", CondtionalAnimGroupStr))
  977. {
  978. // Search for the specified conditionalAnim
  979. atHashString conditionalAnimHash(ConditonalAnimStr);
  980. for (int scan = 0; scan < pConditionalAnimGroup->GetNumAnims(); ++scan)
  981. {
  982. const CConditionalAnims* pAnims = pConditionalAnimGroup->GetAnims(scan);
  983. if (pAnims && pAnims->GetNameHash() == conditionalAnimHash)
  984. {
  985. float fWanderHeading = (IsClose(fHeading, DEFAULT_NAVMESH_FINAL_HEADING, 0.1f) ? fwRandom::GetRandomNumberInRange(0.0f, TWO_PI) : fHeading* DtoR);
  986. CTask* pTask = rage_new CTaskWander(MOVEBLENDRATIO_WALK, fWanderHeading, pConditionalAnimGroup, scan);
  987. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_WANDER_SPECIFIC, "TASK_WANDER_SPECIFIC");
  988. return;
  989. }
  990. }
  991. // If you get here, we failed to find the specified conditional anim.
  992. scriptAssertf(0, "TASK_WANDER_SPECIFIC could not find ConditionalAnim name (%s) in ConditionalAnimGroup (%s)", ConditonalAnimStr, CondtionalAnimGroupStr);
  993. }
  994. }
  995.  
  996. void CommandTaskCombat( int iPedID, int iOtherPedID, const int iCombatFlags, const int iThreatResponseFlags )
  997. {
  998. // NULL peds are valid since this task can run in a sequence
  999. const CPed *pPed = NULL;
  1000. if(iPedID != NULL_IN_SCRIPTING_LANGUAGE)
  1001. pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  1002.  
  1003. const CPed *pSecondPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iOtherPedID);
  1004.  
  1005. if (pSecondPed)
  1006. {
  1007. SCRIPT_ASSERT((!pPed || !pPed->GetPedIntelligence()->IsFriendlyWith(*pSecondPed)), "TASK_COMBAT_PED - Ped told to attack friendly ped!");
  1008. SCRIPT_ASSERT(!pSecondPed->GetPedResetFlag(CPED_RESET_FLAG_CannotBeTargeted), "TASK_COMBAT_PED - Ped told to attack ped with flag PRF_CannotBeTargetedByAI!");
  1009.  
  1010. CTaskThreatResponse* pTask= rage_new CTaskThreatResponse(pSecondPed);
  1011. pTask->GetConfigFlags().SetAllFlags((u8)iThreatResponseFlags);
  1012. pTask->GetConfigFlagsForCombat().SetAllFlags(iCombatFlags);
  1013.  
  1014. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_COMBAT, "TASK_COMBAT_PED");
  1015. }
  1016. }
  1017.  
  1018.  
  1019. void CommandTaskCombatHatedTargetsInArea( int PedIndex, const scrVector & scvCentre, float Radius, const int iCombatFlags )
  1020. {
  1021. if(NetworkInterface::IsGameInProgress())
  1022. {
  1023. SCRIPT_ASSERT(Radius < CClonedCombatClosestTargetInAreaInfo::MAX_AREA, "Radius is greater than max allowed (300.0m)");
  1024. Radius = rage::Clamp( Radius, 0.0f, CClonedCombatClosestTargetInAreaInfo::MAX_AREA );
  1025. }
  1026.  
  1027. Vector3 vCentre = scvCentre;
  1028. CTask* pTask=rage_new CTaskCombatClosestTargetInArea(vCentre,Radius, false, CTaskCombatClosestTargetInArea::INVALID_OVERALL_TIME, iCombatFlags);
  1029. CScriptPeds::GivePedScriptedTask( PedIndex, pTask, SCRIPT_TASK_COMBAT_HATED_TARGETS_IN_AREA, "TASK_COMBAT_HATED_PED_IN_AREA" );
  1030. }
  1031.  
  1032. void CommandTaskCombatHatedTargetsAroundPed( int PedIndex, float Radius, const int iCombatFlags )
  1033. {
  1034. if(NetworkInterface::IsGameInProgress())
  1035. {
  1036. SCRIPT_ASSERT(Radius < CClonedCombatClosestTargetInAreaInfo::MAX_AREA, "Radius is greater than max allowed (300.0m)");
  1037. Radius = rage::Clamp( Radius, 0.0f, CClonedCombatClosestTargetInAreaInfo::MAX_AREA );
  1038. }
  1039.  
  1040. CTask* pTask=rage_new CTaskCombatClosestTargetInArea(Vector3(0.0f, 0.0f, 0.0f),Radius, true, CTaskCombatClosestTargetInArea::INVALID_OVERALL_TIME, iCombatFlags);
  1041. CScriptPeds::GivePedScriptedTask( PedIndex, pTask, SCRIPT_TASK_COMBAT_HATED_TARGETS_AROUND_PED, "TASK_COMBAT_HATED_TARGETS_AROUND_PED" );
  1042. }
  1043.  
  1044. void CommandTaskCombatHatedTargetsAroundPedTimed( int PedIndex, float Radius, int iTime, const int iCombatFlags )
  1045. {
  1046. if(NetworkInterface::IsGameInProgress())
  1047. {
  1048. SCRIPT_ASSERT(Radius < CClonedCombatClosestTargetInAreaInfo::MAX_AREA, "Radius is greater than max allowed (300.0m)");
  1049. Radius = rage::Clamp( Radius, 0.0f, CClonedCombatClosestTargetInAreaInfo::MAX_AREA );
  1050. }
  1051.  
  1052. float fTime = ((float) iTime) / 1000.0f ;
  1053.  
  1054. CTask* pTask=rage_new CTaskCombatClosestTargetInArea(Vector3(0.0f, 0.0f, 0.0f),Radius, true, fTime, iCombatFlags );
  1055. CScriptPeds::GivePedScriptedTask( PedIndex, pTask, SCRIPT_TASK_COMBAT_HATED_TARGETS_AROUND_PED_TIMED, "TASK_COMBAT_HATED_TARGETS_AROUND_PED_TIMED" );
  1056. }
  1057.  
  1058. void CommandTaskCombatTimed( int PedIndex, int iOtherPedID, s32 iTime, const int iFlags )
  1059. {
  1060. CPed *pSecondPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iOtherPedID);
  1061. if (pSecondPed)
  1062. {
  1063. if(NULL_IN_SCRIPTING_LANGUAGE!=PedIndex)
  1064. {
  1065. const CPed *pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  1066. if( pPed )
  1067. {
  1068. if(!SCRIPT_VERIFY(!pPed->GetPedIntelligence()->IsFriendlyWith(*pSecondPed), "TASK_COMBAT_TIMED - Ped told to attack friendly ped!"))
  1069. return;
  1070. }
  1071. }
  1072.  
  1073. float fTime = ((float) iTime) / 1000.0f ;
  1074. CTaskThreatResponse* pTask=rage_new CTaskThreatResponse(pSecondPed, fTime);
  1075. pTask->GetConfigFlags().SetFlag(CTaskThreatResponse::CF_CanFightArmedPedsWhenNotArmed);
  1076. pTask->GetConfigFlagsForCombat().SetAllFlags(iFlags);
  1077.  
  1078. CScriptPeds::GivePedScriptedTask( PedIndex, pTask, SCRIPT_TASK_COMBAT_TIMED, "TASK_COMBAT_TIMED" );
  1079. }
  1080. }
  1081.  
  1082. void CommandTaskThrowProjectile( int PedIndex, const scrVector & scrVecTarget, int IgnoreCollisionEntityIndex, bool CreateInvincibleProjectile)
  1083. {
  1084. CEntity* pIgnoreCollisionEntity = NULL;
  1085.  
  1086. if (IgnoreCollisionEntityIndex != NULL_IN_SCRIPTING_LANGUAGE)
  1087. {
  1088. pIgnoreCollisionEntity = CTheScripts::GetEntityToModifyFromGUID<CEntity>(IgnoreCollisionEntityIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES_NO_DEAD_CHECK);
  1089.  
  1090. #if __BANK
  1091. if (!pIgnoreCollisionEntity)
  1092. {
  1093. scriptAssertf(0,"TASK_THROW_PROJECTILE - IgnoreCollisionEntityIndex is not null (%i), but could not find the entity in the world!", IgnoreCollisionEntityIndex);
  1094. }
  1095. #endif
  1096. }
  1097.  
  1098. // Create vectors needed for getting the start position, trajectory, velocity.
  1099. CTaskAimAndThrowProjectile* pTask = rage_new CTaskAimAndThrowProjectile( CWeaponTarget( scrVecTarget ), pIgnoreCollisionEntity, CreateInvincibleProjectile );
  1100. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_THROW_PROJECTILE, "TASK_THROW_PROJECTILE");
  1101. }
  1102.  
  1103. //*************************************************************************************************************************
  1104.  
  1105.  
  1106.  
  1107. CTaskMoveFollowNavMesh * CreateNavigateTask(const int iPedIndex, const Vector3 &vTarget, const float fMoveBlendRatio, int iTime, const float fTargetRadius, const float fTargetHeading = DEFAULT_NAVMESH_FINAL_HEADING)
  1108. {
  1109. //*************************************************************
  1110. // Assert that scripters aren't trying to do "crazy shit"(tm)
  1111.  
  1112. if(iPedIndex != NULL_IN_SCRIPTING_LANGUAGE)
  1113. {
  1114. CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  1115.  
  1116. if (!pPed)
  1117. return NULL;
  1118. }
  1119.  
  1120. //********************************
  1121. // Sanity-check for comedy values
  1122.  
  1123. ASSERT_ONLY(static const float fStupidlyLargeValue = 10000.0f);
  1124. scriptAssertf(rage::FPIsFinite(vTarget.x) && rage::FPIsFinite(vTarget.y) && rage::FPIsFinite(vTarget.z), "script \'%s\'\nNAVIGATE_TO_COORD - Ped %i's target (%.2f, %.2f, %.2f) is duff.", CTheScripts::GetCurrentScriptNameAndProgramCounter(), iPedIndex, vTarget.x, vTarget.y, vTarget.z);
  1125. scriptAssertf((vTarget.x > -fStupidlyLargeValue && vTarget.y > -fStupidlyLargeValue && vTarget.z > -fStupidlyLargeValue && vTarget.x < fStupidlyLargeValue && vTarget.y < fStupidlyLargeValue && vTarget.z < fStupidlyLargeValue), "script \'%s\'\nNAVIGATE_TO_COORD - Ped %i's target (%.2f, %.2f, %.2f) is outside of the world.", CTheScripts::GetCurrentScriptNameAndProgramCounter(), iPedIndex, vTarget.x, vTarget.y, vTarget.z);
  1126.  
  1127. //***************************************************************
  1128. // Translate iTime into a value meaningful to the navmesh task
  1129.  
  1130. //-1 is assumed as to be infinite -2, will assert legacy used to be infinite
  1131.  
  1132. //*********************************************************
  1133. // Create the CTaskMoveFollowNavMesh task
  1134. // Set up the task according to the passed-in parameters
  1135.  
  1136. CTaskMoveFollowNavMesh* pTaskFollowNavMesh = rage_new CTaskMoveFollowNavMesh(
  1137. fMoveBlendRatio,
  1138. vTarget,
  1139. fTargetRadius,
  1140. CTaskMoveFollowNavMesh::ms_fSlowDownDistance,
  1141. iTime,
  1142. true,
  1143. false,
  1144. NULL,
  1145. fTargetRadius);
  1146.  
  1147. //***********************************************
  1148. // This is always set for scripted navmesh tasks
  1149.  
  1150. pTaskFollowNavMesh->SetIsScriptedRoute(true);
  1151.  
  1152. pTaskFollowNavMesh->SetTargetStopHeading(fTargetHeading);
  1153.  
  1154. return pTaskFollowNavMesh;
  1155. }
  1156.  
  1157. void CommandTaskFollowNavMeshToCoord(const int iPedIndex, const scrVector & vScrTarget, const float fMoveBlendRatio, const int iTime, const float fTargetRadius, const int iFlags, const float fTargetHeading)
  1158. {
  1159. Assertf(fMoveBlendRatio >= MOVEBLENDRATIO_STILL && fMoveBlendRatio <= MOVEBLENDRATIO_SPRINT, "Invalid 'fMoveBlendRatio' specified in TASK_FOLLOW_NAVMESH_TO_COORD. Must be in range (%.1f to %.1f) inclusive. You've passed in %.1f", MOVEBLENDRATIO_STILL, MOVEBLENDRATIO_SPRINT, fMoveBlendRatio);
  1160.  
  1161. CTaskMoveFollowNavMesh * pTaskFollowNavMesh = CreateNavigateTask(iPedIndex, vScrTarget, fMoveBlendRatio, iTime, fTargetRadius, fTargetHeading<DEFAULT_NAVMESH_FINAL_HEADING ? DtoR * fTargetHeading : fTargetHeading);
  1162.  
  1163. if (iTime < -1)
  1164. {
  1165. scriptAssertf(0, "%s:TASK_FOLLOW_NAVMESH_TO_COORD - Time must be -1 for infinite ", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  1166. return;
  1167. }
  1168. else if (iTime == 0)
  1169. {
  1170. scriptAssertf(0, "%s:TASK_FOLLOW_NAVMESH_TO_COORD - You cannot give a task 0 time", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  1171. return;
  1172. }
  1173.  
  1174. if(!pTaskFollowNavMesh)
  1175. return;
  1176.  
  1177. #if __ASSERT
  1178. if (fTargetHeading<DEFAULT_NAVMESH_FINAL_HEADING && ((iFlags & ENAV_SUPPRESS_EXACT_STOP)!=0))
  1179. {
  1180. Assertf(false, "You cannot specify 'ENAV_SUPPRESS_EXACT_STOP' and have a target-heading");
  1181. }
  1182. #endif
  1183.  
  1184. pTaskFollowNavMesh->SetScriptBehaviourFlags(iFlags, NULL);
  1185.  
  1186. //*****************************************************************************************************
  1187. // The 'fMainTaskTimer' value is used to warp the ped via the parent CTaskComplexControlMovement task
  1188.  
  1189. float fMainTaskTimer = ((float)iTime)/1000.0f;
  1190. if(fMainTaskTimer > 0.0f)
  1191. fMainTaskTimer += 2.0f;
  1192.  
  1193. //**********************************************************************************
  1194. // Now wrap the task in the CTaskComplexControlMovement parent, and give to the ped
  1195.  
  1196. CTask * pTask = rage_new CTaskComplexControlMovement( pTaskFollowNavMesh, NULL, CTaskComplexControlMovement::TerminateOnMovementTask, fMainTaskTimer );
  1197. CScriptPeds::GivePedScriptedTask(iPedIndex, pTask, SCRIPT_TASK_FOLLOW_NAV_MESH_TO_COORD, "TASK_FOLLOW_NAVMESH_TO_COORD");
  1198. }
  1199.  
  1200. void CommandTaskFollowNavMeshToCoordAdvanced(const int iPedIndex, const Vector3 &vTarget, const float fMoveBlendRatio, const int iTime, const float fTargetRadius, const int iFlags, TNavMeshScriptStruct * pNavData, const float fTargetHeading )
  1201. {
  1202. Assertf(fMoveBlendRatio >= MOVEBLENDRATIO_STILL && fMoveBlendRatio <= MOVEBLENDRATIO_SPRINT, "Invalid 'fMoveBlendRatio' specified in TASK_FOLLOW_NAVMESH_TO_COORD_ADVANCED. Must be in range (%.1f to %.1f) inclusive. You've passed in %.1f", MOVEBLENDRATIO_STILL, MOVEBLENDRATIO_SPRINT, fMoveBlendRatio);
  1203.  
  1204. //********************
  1205. // Create the task
  1206.  
  1207. if (iTime < -1)
  1208. {
  1209. scriptAssertf(0, "%s:TASK_FOLLOW_NAVMESH_TO_COORD_ADVANCED - Time must be -1 for infinite ", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  1210. return;
  1211. }
  1212. else if (iTime == 0)
  1213. {
  1214. scriptAssertf(0, "%s:TASK_FOLLOW_NAVMESH_TO_COORD_ADVANCED - You cannot give a task 0 time", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  1215. return;
  1216. }
  1217.  
  1218.  
  1219. CTaskMoveFollowNavMesh * pTaskFollowNavMesh = CreateNavigateTask(iPedIndex, vTarget, fMoveBlendRatio, iTime, fTargetRadius, fTargetHeading<DEFAULT_NAVMESH_FINAL_HEADING ? DtoR * fTargetHeading: fTargetHeading);
  1220.  
  1221. if(!pTaskFollowNavMesh)
  1222. return;
  1223.  
  1224. pTaskFollowNavMesh->SetScriptBehaviourFlags(iFlags, pNavData);
  1225.  
  1226. //*****************************************************************************************************
  1227. // The 'fMainTaskTimer' value is used to warp the ped via the parent CTaskComplexControlMovement task
  1228.  
  1229. float fMainTaskTimer = ((float)iTime)/1000.0f;
  1230. if(fMainTaskTimer > 0.0f)
  1231. fMainTaskTimer += 2.0f;
  1232.  
  1233. //**********************************************************************************
  1234. // Now wrap the task in the CTaskComplexControlMovement parent, and give to the ped
  1235.  
  1236. CTask * pTask = rage_new CTaskComplexControlMovement( pTaskFollowNavMesh, NULL, CTaskComplexControlMovement::TerminateOnMovementTask, fMainTaskTimer);
  1237. CScriptPeds::GivePedScriptedTask(iPedIndex, pTask, SCRIPT_TASK_FOLLOW_NAVMESH_TO_COORD_ADVANCED, "TASK_FOLLOW_NAVMESH_TO_COORD_ADVANCED");
  1238. }
  1239.  
  1240. //***********************************************************
  1241. // CommandTaskNavigateToCoordAdvanced - parameter list:
  1242. //
  1243. // int iPedIndex
  1244. // const scrVector & vScrTarget
  1245. // float fMoveBlendRatio
  1246. // int iTime
  1247. // float fTargetRadius
  1248. // int iFlags
  1249. // TNavMeshScriptStruct navStruct
  1250. //
  1251.  
  1252. void CommandTaskFollowNavMeshToCoordAdvanced_ScrStruct(scrThread::Info & info)
  1253. {
  1254. //**********************************************************************
  1255. // Extract the parameters from the scrThread::Info structure. This
  1256. // is necessary as the way of passing structures into script functions
  1257.  
  1258. ASSERT_ONLY(static const int iNumParams = 12);
  1259. scriptAssertf(info.ParamCount == iNumParams, "script \'%s\'\nTASK_FOLLOW_NAV_MESH_TO_COORD_ADVANCED - You have passed in the wrong num arguments (%i instead of %i)", CTheScripts::GetCurrentScriptNameAndProgramCounter(), info.ParamCount, iNumParams);
  1260.  
  1261. // Get the ped index
  1262. const int iPedIndex = info.Params[0].Int;
  1263. // Get the target position
  1264. //const float * pFloat = &info.Params[1].Reference->Float;
  1265. const Vector3 vTarget(info.Params[1].Float, info.Params[2].Float, info.Params[3].Float);
  1266. // Get the move blend ratio
  1267. const float fMoveBlendRatio = info.Params[4].Float;
  1268. // Get the time
  1269. int iTime = info.Params[5].Int;
  1270. // Get the target radius
  1271. const float fTargetRadius = info.Params[6].Float;
  1272. // Get the bit-flags
  1273. const int iFlags = info.Params[7].Int;
  1274. // Get the nav data structure
  1275. //void * pStructData = info.Params[6].Reference;
  1276. //TNavMeshScriptStruct * pNavStruct = (TNavMeshScriptStruct*)pStructData;
  1277. TNavMeshScriptStruct NavStruct;
  1278. NavStruct.m_fSlideToCoordHeading = info.Params[8].Float;
  1279. NavStruct.m_fMaxSlopeNavigable = info.Params[9].Float;
  1280. NavStruct.m_fClampMaxSearchDistance = info.Params[10].Float;
  1281.  
  1282. // Final heading
  1283. const float fTargetHeading = info.Params[11].Float;
  1284.  
  1285. CommandTaskFollowNavMeshToCoordAdvanced(iPedIndex, vTarget, fMoveBlendRatio, iTime, fTargetRadius, iFlags, &NavStruct, fTargetHeading);
  1286. }
  1287.  
  1288. // Sets the path-style for this ped, so that they will use climb-overs or not during pathfinding
  1289. void CommandSetPedPathCanUseClimbOvers(int PedIndex, bool Flag)
  1290. {
  1291. CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  1292. if (pPed)
  1293. {
  1294. CPedIntelligence * pPedAI = pPed->GetPedIntelligence();
  1295. pPedAI->GetNavCapabilities().SetFlag(CPedNavCapabilityInfo::FLAG_MAY_CLIMB, Flag);
  1296. }
  1297. }
  1298.  
  1299. // Sets the path-style for this ped, so that they will use ladders or not during pathfinding
  1300. void CommandSetPedPathCanUseLadders(int PedIndex, bool Flag)
  1301. {
  1302. CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  1303. if (pPed)
  1304. {
  1305. CPedIntelligence * pPedAI = pPed->GetPedIntelligence();
  1306. pPedAI->GetNavCapabilities().SetFlag(CPedNavCapabilityInfo::FLAG_MAY_USE_LADDERS, Flag);
  1307. }
  1308. }
  1309.  
  1310. // Sets the path-style for this ped, so that they will use high drop-downs or not during pathfinding
  1311. void CommandSetPedPathCanDropFromHeight(int PedIndex, bool Flag)
  1312. {
  1313. CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  1314. if (pPed)
  1315. {
  1316. CPedIntelligence * pPedAI = pPed->GetPedIntelligence();
  1317. pPedAI->GetNavCapabilities().SetFlag(CPedNavCapabilityInfo::FLAG_MAY_DROP, Flag);
  1318. }
  1319. }
  1320.  
  1321. // Sets the path-style for this ped, so designers can modify how likely it is for a ped to use a climb during navigation
  1322. void CommandSetPedPathClimbCostModifier(int PedIndex, float fModifier)
  1323. {
  1324. fModifier = Clamp(fModifier, 0.0f, 10.0f);
  1325.  
  1326. CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  1327. if (pPed)
  1328. {
  1329. CPedIntelligence * pPedAI = pPed->GetPedIntelligence();
  1330. pPedAI->GetNavCapabilities().SetClimbCostModifier(fModifier);
  1331. }
  1332. }
  1333.  
  1334. //
  1335. void CommandSetPedToMayEnterWater(int PedIndex, bool Flag)
  1336. {
  1337. CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  1338. if (pPed)
  1339. {
  1340. CPedIntelligence * pPedAI = pPed->GetPedIntelligence();
  1341. pPedAI->GetNavCapabilities().SetFlag(CPedNavCapabilityInfo::FLAG_MAY_ENTER_WATER, Flag);
  1342. }
  1343. }
  1344.  
  1345. // Sets the path-style for this ped, so that they will use prefer to avoid water or not during pathfinding
  1346. void CommandSetPedPreferToAvoidWater(int PedIndex, bool Flag)
  1347. {
  1348. CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  1349. if (pPed)
  1350. {
  1351. CPedIntelligence * pPedAI = pPed->GetPedIntelligence();
  1352. pPedAI->GetNavCapabilities().SetFlag(CPedNavCapabilityInfo::FLAG_PREFER_TO_AVOID_WATER, Flag);
  1353. }
  1354. }
  1355.  
  1356. // Sets the path-style for this ped, so that they will use prefer to avoid fire during pathfinding
  1357. void CommandSetPedPathAvoidFire(int PedIndex, bool Flag)
  1358. {
  1359. CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  1360. if (pPed)
  1361. {
  1362. CPedIntelligence * pPedAI = pPed->GetPedIntelligence();
  1363. pPedAI->GetNavCapabilities().SetFlag(CPedNavCapabilityInfo::FLAG_AVOID_FIRE, Flag);
  1364. }
  1365. }
  1366.  
  1367. // Needs to be called each frame or it will reset.
  1368. void CommandSetGlobalMinBirdFlightHeight(float fHeight)
  1369. {
  1370. CWildlifeManager::GetInstance().SetScriptMinBirdHeight(fHeight);
  1371. }
  1372.  
  1373. //****************************************************************************
  1374. // Retrieves the remaining distance to the target, if a ped is following
  1375. // a navmesh route in their primary slot. Returns enumeration value to
  1376. // indicate whether the navmesh task was found.
  1377.  
  1378. int CommandGetNavMeshRouteDistanceRemaining(int PedIndex, float & fOutDistanceRemaining, int & bThisIsLastRouteSection)
  1379. {
  1380. fOutDistanceRemaining = 0.0f;
  1381. bThisIsLastRouteSection = false;
  1382.  
  1383. const CPed * pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  1384. if(pPed)
  1385. {
  1386. CPedIntelligence * pPedAI = pPed->GetPedIntelligence();
  1387. aiTask * pTask = pPedAI->FindTaskActiveMovementByType(CTaskTypes::TASK_MOVE_FOLLOW_NAVMESH);
  1388. if(pTask)
  1389. {
  1390. CTaskMoveFollowNavMesh * pNavTask = (CTaskMoveFollowNavMesh*)pTask;
  1391.  
  1392. bThisIsLastRouteSection = pNavTask->GetLastRoutePointIsTarget();
  1393.  
  1394. if(pNavTask->IsFollowingNavMeshRoute() && !pNavTask->GetIsFleeing())
  1395. {
  1396. fOutDistanceRemaining = pNavTask->GetDistanceLeftOnCurrentRouteSection(pPed);
  1397. return NAVMESHROUTE_ROUTE_FOUND;
  1398. }
  1399. else
  1400. {
  1401. return NAVMESHROUTE_ROUTE_NOT_FOUND;
  1402. }
  1403. }
  1404. }
  1405. return NAVMESHROUTE_TASK_NOT_FOUND;
  1406. }
  1407.  
  1408.  
  1409. int CommandGetNavMeshRouteResult(int PedIndex)
  1410. {
  1411. const CPed * pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  1412. if(pPed)
  1413. {
  1414. CPedIntelligence * pPedAI = pPed->GetPedIntelligence();
  1415.  
  1416. // Script task priority must be active
  1417. if(pPedAI->GetTaskManager()->GetTree(PED_TASK_TREE_PRIMARY)->GetActiveTaskPriority()==PED_TASK_PRIORITY_PRIMARY)
  1418. {
  1419. // The movement task tree must be running its general movement task
  1420. if(pPedAI->GetTaskManager()->GetTree(PED_TASK_TREE_MOVEMENT)->GetActiveTaskPriority()==PED_TASK_MOVEMENT_GENERAL)
  1421. {
  1422. // A control movement task must be found
  1423. CTaskComplexControlMovement * pControlMovementTask = (CTaskComplexControlMovement*) pPedAI->FindTaskPrimaryByType(CTaskTypes::TASK_COMPLEX_CONTROL_MOVEMENT);
  1424. // The control movement must have a running movement task
  1425. if(pControlMovementTask && pControlMovementTask->GetRunningMovementTask(pPed))
  1426. {
  1427. CTaskMoveFollowNavMesh * pNavTask = (CTaskMoveFollowNavMesh*)pPedAI->GetTaskManager()->GetTree(PED_TASK_TREE_MOVEMENT)->FindTaskByTypeActive(CTaskTypes::TASK_MOVE_FOLLOW_NAVMESH);
  1428. if(pNavTask)
  1429. {
  1430. if(pNavTask->GetState()==CTaskNavBase::NavBaseState_FollowingPath)
  1431. {
  1432. return NAVMESHROUTE_ROUTE_FOUND;
  1433. }
  1434. else if(pNavTask->IsUnableToFindRoute())
  1435. {
  1436. return NAVMESHROUTE_ROUTE_NOT_FOUND;
  1437. }
  1438. else
  1439. {
  1440. return NAVMESHROUTE_ROUTE_NOT_YET_TRIED;
  1441. }
  1442. }
  1443. }
  1444. }
  1445. }
  1446. }
  1447. return NAVMESHROUTE_TASK_NOT_FOUND;
  1448. }
  1449.  
  1450. bool CommandIsControlledVehicleUnableToGetToRoad(int PedIndex)
  1451. {
  1452. const CPed * pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  1453. if(pPed)
  1454. {
  1455. CPedIntelligence * pPedAI = pPed->GetPedIntelligence();
  1456.  
  1457. // Script task priority must be active
  1458. if(pPedAI->GetTaskManager()->GetTree(PED_TASK_TREE_PRIMARY)->GetActiveTaskPriority()==PED_TASK_PRIORITY_PRIMARY)
  1459. {
  1460. // A control vehicle task must be found
  1461. CTaskControlVehicle* pControlVehicleTask = (CTaskControlVehicle*) pPedAI->FindTaskPrimaryByType(CTaskTypes::TASK_CONTROL_VEHICLE);
  1462. if(pControlVehicleTask)
  1463. {
  1464. return pControlVehicleTask->IsVehicleTaskUnableToGetToRoad();
  1465. }
  1466. }
  1467. }
  1468.  
  1469. return false;
  1470. }
  1471.  
  1472. void CommandTaskGoToCoordAnyMeans( int PedIndex, const scrVector & scrVecCoors, float fMoveBlendRatio, int iVehicleID, bool bUseLongRangeVehiclePathing, s32 iDrivingFlags, float fMaxRangeToShootTargets)
  1473. {
  1474. Vector3 vTarget(scrVecCoors);
  1475. CVehicle *pVehicle=NULL;
  1476. if(iVehicleID != NULL_IN_SCRIPTING_LANGUAGE)
  1477. {
  1478. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  1479. if(!pVehicle)
  1480. return;
  1481. }
  1482. CTask* pTask=rage_new CTaskGoToPointAnyMeans(fMoveBlendRatio,vTarget,pVehicle, CTaskGoToPointAnyMeans::ms_fTargetRadius, -1, bUseLongRangeVehiclePathing, iDrivingFlags, fMaxRangeToShootTargets);
  1483. CScriptPeds::GivePedScriptedTask( PedIndex, pTask, SCRIPT_TASK_GO_TO_COORD_ANY_MEANS, "TASK_GO_TO_COORD_ANY_MEANS");
  1484. }
  1485.  
  1486. void CommandTaskGoToCoordAnyMeansExtraParams( int PedIndex, const scrVector & scrVecCoors, float fMoveBlendRatio, int iVehicleID, bool bUseLongRangeVehiclePathing, s32 iDrivingFlags, float fMaxRangeToShootTargets, float fExtraVehToTargetDistToPreferVe, float fDriveStraightLineDistance, s32 iExtraFlags, float fWarpTimerMS)
  1487. {
  1488. Vector3 vTarget(scrVecCoors);
  1489. CVehicle *pVehicle=NULL;
  1490. if(iVehicleID != NULL_IN_SCRIPTING_LANGUAGE)
  1491. {
  1492. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  1493. if(!pVehicle)
  1494. return;
  1495. }
  1496. CTask* pTask=rage_new CTaskGoToPointAnyMeans(fMoveBlendRatio,vTarget,pVehicle, CTaskGoToPointAnyMeans::ms_fTargetRadius, -1, bUseLongRangeVehiclePathing, iDrivingFlags, fMaxRangeToShootTargets, fExtraVehToTargetDistToPreferVe, fDriveStraightLineDistance, static_cast<u16>(iExtraFlags), -1.0f, fWarpTimerMS);
  1497. CScriptPeds::GivePedScriptedTask( PedIndex, pTask, SCRIPT_TASK_GO_TO_COORD_ANY_MEANS_EXTRA_PARAMS, "SCRIPT_TASK_GO_TO_COORD_ANY_MEANS_EXTRA_PARAMS");
  1498. }
  1499.  
  1500. void CommandTaskGoToCoordAnyMeansExtraParamsWithCruiseSpeed( int PedIndex, const scrVector & scrVecCoors, float fMoveBlendRatio, int iVehicleID, bool bUseLongRangeVehiclePathing, s32 iDrivingFlags, float fMaxRangeToShootTargets, float fExtraVehToTargetDistToPreferVe, float fDriveStraightLineDistance, s32 iExtraFlags, float fCruiseSpeed, float fTargetArriveDist)
  1501. {
  1502. Vector3 vTarget(scrVecCoors);
  1503. CVehicle *pVehicle=NULL;
  1504. if(iVehicleID != NULL_IN_SCRIPTING_LANGUAGE)
  1505. {
  1506. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  1507. if(!pVehicle)
  1508. return;
  1509. }
  1510. CTask* pTask=rage_new CTaskGoToPointAnyMeans(fMoveBlendRatio,vTarget,pVehicle, CTaskGoToPointAnyMeans::ms_fTargetRadius, -1, bUseLongRangeVehiclePathing, iDrivingFlags, fMaxRangeToShootTargets, fExtraVehToTargetDistToPreferVe, fDriveStraightLineDistance, static_cast<u16>(iExtraFlags), fCruiseSpeed, -1.0f, fTargetArriveDist);
  1511. CScriptPeds::GivePedScriptedTask( PedIndex, pTask, SCRIPT_TASK_GO_TO_COORD_ANY_MEANS_EXTRA_PARAMS_WITH_CRUISE_SPEED, "TASK_GO_TO_COORD_ANY_MEANS_EXTRA_PARAMS_WITH_CRUISE_SPEED");
  1512. }
  1513.  
  1514. #if __BANK
  1515. bool VerifyDictAndAnim(atHashString dictionaryHash, atHashString animHash, const char * ASSERT_ONLY(scriptName))
  1516. {
  1517. strLocalIndex dictIndex = fwAnimManager::FindSlotFromHashKey(dictionaryHash.GetHash());
  1518.  
  1519. if (scriptVerifyf(dictIndex.Get()>-1, "%s - The dictionary name '%s' is not recognised.", scriptName, dictionaryHash.TryGetCStr()))
  1520. {
  1521. strIndex index = strStreamingEngine::GetInfo().GetModuleMgr().GetModule(fwAnimManager::GetStreamingModuleId())->GetStreamingIndex(dictIndex);
  1522. if (scriptVerifyf(strStreamingEngine::GetInfo().GetStreamingInfo(index)->GetStatus() == STRINFO_LOADED, "%s - The dictionary '%s' is not streamed in.", scriptName, dictionaryHash.TryGetCStr()))
  1523. {
  1524. const crClip* pClip = fwAnimManager::GetClipIfExistsByDictIndex(dictIndex.Get(), animHash.GetHash());
  1525.  
  1526. if (scriptVerifyf(pClip, "%s - The clip '%s' does not exist in dictionary '%s'", scriptName, animHash.TryGetCStr(), dictionaryHash.TryGetCStr()))
  1527. {
  1528. return true;
  1529. }
  1530. }
  1531. }
  1532.  
  1533. return false;
  1534. }
  1535.  
  1536. #endif //__BANK
  1537.  
  1538. CTaskScriptedAnimation::ePlaybackPriority GetPriorityFromControlFlags(s32 nControlFlags)
  1539. {
  1540. // TODO - convert to support the new anim priority flags
  1541. CTaskScriptedAnimation::ePlaybackPriority priority = CTaskScriptedAnimation::kPriorityLow;
  1542.  
  1543. if (nControlFlags == AF_PRIORITY_MEDIUM)
  1544. {
  1545. priority = CTaskScriptedAnimation::kPriorityMid;
  1546. }
  1547. else if (nControlFlags == AF_PRIORITY_HIGH)
  1548. {
  1549. priority = CTaskScriptedAnimation::kPriorityHigh;
  1550. }
  1551. return priority;
  1552. }
  1553.  
  1554. void PlayAnimScriptCommand(int CurrCommand, int PedIndex, const char *pAnimName, const char *pAnimDictNameStr, float fBlendInDelta, float fBlendOutDelta, int nTimeToPlay, int nControlFlags, int nIkFlags, bool bAdvanced, const Vector3 &initialPosition, const Vector3 &initialOrientation, float fStartPhase, EulerAngleOrder RotationOrder, bool phaseControlled, bool bAllowOverrideCloneUpdate)
  1555. {
  1556. eScriptedAnimFlagsBitSet flags;
  1557. flags.BitSet().SetBits(nControlFlags);
  1558.  
  1559. if(!SCRIPT_VERIFY(pAnimName, "TASK_PLAY_ANIM - Animation name is null"))
  1560. {
  1561. return;
  1562. }
  1563.  
  1564. if(!SCRIPT_VERIFY(pAnimDictNameStr, "TASK_PLAY_ANIM - Animation dictionary name is null"))
  1565. {
  1566. return;
  1567. }
  1568.  
  1569. if (bAllowOverrideCloneUpdate && !NetworkInterface::IsGameInProgress())
  1570. {
  1571. bAllowOverrideCloneUpdate = false;
  1572. SCRIPT_ASSERT(0, "Don't expect bAllowOverrideCloneUpdate to be set true in SP. Clearing this bool.");
  1573. }
  1574.  
  1575. const strStreamingObjectName pAnimDictName( pAnimDictNameStr );
  1576.  
  1577. CPed *pPed = NULL;
  1578. if(NULL_IN_SCRIPTING_LANGUAGE!=PedIndex)
  1579. {
  1580. pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  1581. if(!pPed)
  1582. {
  1583. return;
  1584. }
  1585.  
  1586. if(pPed->GetIsAttached())
  1587. {
  1588. SCRIPT_ASSERT(!flags.BitSet().IsSet(AF_OVERRIDE_PHYSICS), "TASK_PLAY_ANIM - Cannot use AF_OVERRIDE_PHYSICS when ped is attached!");
  1589. SCRIPT_ASSERT(!flags.BitSet().IsSet(AF_TURN_OFF_COLLISION), "TASK_PLAY_ANIM - Cannot set CTaskScriptedAnimation::AF_TURN_OFF_COLLISION when ped is attached!");
  1590. SCRIPT_ASSERT(!flags.BitSet().IsSet(AF_IGNORE_GRAVITY), "TASK_PLAY_ANIM - Cannot set CTaskScriptedAnimation::AF_IGNORE_GRAVITY when ped is attached!");
  1591. }
  1592. }
  1593. else if(bAllowOverrideCloneUpdate)
  1594. {
  1595. SCRIPT_ASSERT(0, "In MP don't expect bAllowOverrideCloneUpdate to be set true with null PedIndex!");
  1596. return;
  1597. }
  1598.  
  1599. bool bPartOfASequence = (PedIndex == NULL_IN_SCRIPTING_LANGUAGE);
  1600.  
  1601. //scriptAssertf(strlen(pAnimName)<ANIM_NAMELEN, "%s:TASK_PLAY_ANIM - Animation name is null : %s", CTheScripts::GetCurrentScriptNameAndProgramCounter(), pAnimName);
  1602.  
  1603. if(!bPartOfASequence)
  1604. {
  1605. BANK_ONLY(VerifyDictAndAnim(pAnimDictName, pAnimName, "TASK_PLAY_ANIM");)
  1606. }
  1607.  
  1608. u32 iBoneMask = BONEMASK_ALL;
  1609.  
  1610. eIkControlFlagsBitSet& ikFlags = reinterpret_cast<eIkControlFlagsBitSet&>(nIkFlags);
  1611.  
  1612. if (flags.BitSet().IsSet(AF_UPPERBODY))
  1613. {
  1614. iBoneMask = BONEMASK_UPPERONLY;
  1615. }
  1616.  
  1617. // Currently, always extract the mover and the initial offset when using override physics mode
  1618. if (flags.BitSet().IsSet(AF_OVERRIDE_PHYSICS) )
  1619. {
  1620. flags.BitSet().Set(AF_USE_MOVER_EXTRACTION, true);
  1621. flags.BitSet().Set(AF_EXTRACT_INITIAL_OFFSET, true);
  1622. }
  1623.  
  1624. CTask* pTask;
  1625.  
  1626. if (nTimeToPlay<0)
  1627. nTimeToPlay = -1;
  1628.  
  1629. if (bAdvanced)
  1630. {
  1631. Quaternion rotationQuaternion;
  1632. CScriptEulers::QuaternionFromEulers(rotationQuaternion, initialOrientation, RotationOrder);
  1633. pTask = rage_new CTaskScriptedAnimation(pAnimDictName, pAnimName, CTaskScriptedAnimation::kPriorityLow, iBoneMask, fwAnimHelpers::CalcBlendDuration(fBlendInDelta), fwAnimHelpers::CalcBlendDuration(fBlendOutDelta), nTimeToPlay, flags, fStartPhase, initialPosition, rotationQuaternion, false, phaseControlled, ikFlags, bAllowOverrideCloneUpdate, bPartOfASequence);
  1634. }
  1635. else
  1636. {
  1637. pTask = rage_new CTaskScriptedAnimation(pAnimDictName, pAnimName, CTaskScriptedAnimation::kPriorityLow, iBoneMask, fwAnimHelpers::CalcBlendDuration(fBlendInDelta), fwAnimHelpers::CalcBlendDuration(fBlendOutDelta), nTimeToPlay, flags, fStartPhase, false, phaseControlled, ikFlags, bAllowOverrideCloneUpdate, bPartOfASequence);
  1638. }
  1639.  
  1640. #if !__FINAL
  1641. if(NetworkInterface::IsGameInProgress())
  1642. {
  1643. scriptDebugf1("PlayAnimScriptCommand PedIndex %d, pPed %s, pAnimName %s, pAnimDictNameStr %s nControlFlags 0x%x, pTask [ %p ]",
  1644. PedIndex,
  1645. pPed?(pPed->GetNetworkObject()?pPed->GetNetworkObject()->GetLogName():pPed->GetModelName() ):"Null pPed",
  1646. pAnimName,
  1647. pAnimDictNameStr,
  1648. nControlFlags,
  1649. pTask);
  1650. }
  1651. #endif
  1652.  
  1653. if (flags.BitSet().IsSet(AF_USE_ALTERNATIVE_FP_ANIM))
  1654. {
  1655. static const char * s_fpsClipSuffixHash = "_FP";
  1656. u32 fpsClipHash = atPartialStringHash(s_fpsClipSuffixHash, atPartialStringHash(pAnimName));
  1657. atHashString finalFpsHash(atFinalizeHash(fpsClipHash));
  1658. static_cast<CTaskScriptedAnimation*>(pTask)->SetFPSClipHash(finalFpsHash);
  1659. if(!bPartOfASequence)
  1660. {
  1661. BANK_ONLY(VerifyDictAndAnim(pAnimDictName, finalFpsHash, "TASK_PLAY_ANIM");)
  1662. }
  1663. }
  1664.  
  1665. if(bAllowOverrideCloneUpdate)
  1666. {
  1667. scriptAssertf( !flags.BitSet().IsSet(AF_LOOPING) && !flags.BitSet().IsSet(AF_HOLD_LAST_FRAME), "Don't support AF_LOOPING or AF_HOLD_LAST_FRAME with bAllowOverrideCloneUpdate %d",nControlFlags);
  1668.  
  1669. CTaskScriptedAnimation* pTaskScriptedAnimation = static_cast<CTaskScriptedAnimation*>(pTask);
  1670. if(pPed->IsNetworkClone())
  1671. {
  1672. pPed->GetPedIntelligence()->AddLocalCloneTask(pTaskScriptedAnimation, PED_TASK_PRIORITY_PRIMARY);
  1673. }
  1674. else
  1675. {
  1676. int iEventPriority = E_PRIORITY_GIVE_PED_TASK;
  1677. CEventGivePedTask event(PED_TASK_PRIORITY_PRIMARY,pTaskScriptedAnimation,false,iEventPriority);
  1678. pPed->GetPedIntelligence()->AddEvent(event);
  1679. }
  1680. return;
  1681. }
  1682.  
  1683. // Nb/ PedIndex == NULL_IN_SCRIPTING_LANGUAGE if the task is part of a sequence
  1684. bool bSecondary = flags.BitSet().IsSet(AF_SECONDARY);
  1685.  
  1686. if ( bPartOfASequence && bSecondary )
  1687. {
  1688. CTask* pTaskSecond=pTask;
  1689. pTask=rage_new CTaskAffectSecondaryBehaviour(true,PED_TASK_SECONDARY_PARTIAL_ANIM,pTaskSecond);
  1690. }
  1691. else if (bSecondary)
  1692. {
  1693. if(SCRIPT_VERIFY( !bPartOfASequence, "TASK_PLAY_ANIM_SECONDARY* Cant be used in a sequence!" ))
  1694. {
  1695. CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  1696. if(pPed)
  1697. {
  1698. pPed->GetPedIntelligence()->AddTaskSecondary( pTask, PED_TASK_SECONDARY_PARTIAL_ANIM );
  1699. }
  1700. }
  1701. return;
  1702. }
  1703.  
  1704. if (!bPartOfASequence && flags.BitSet().IsSet(AF_OVERRIDE_PHYSICS))
  1705. {
  1706. //force an ai update post camera so that the anim will be visible next frame (rather than waiting for the next task update)
  1707. CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  1708. if(pPed)
  1709. {
  1710. pPed->SetPedResetFlag( CPED_RESET_FLAG_ForcePostCameraAIUpdate, true );
  1711. }
  1712. }
  1713.  
  1714. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, CurrCommand, "TASK_PLAY_ANIM");
  1715. }
  1716.  
  1717. CTaskScriptedAnimation* FindPrimaryScriptedAnimTask(const CPed* pPed)
  1718. {
  1719. CTaskScriptedAnimation* pTask = static_cast<CTaskScriptedAnimation*>(pPed->GetPedIntelligence()->FindTaskPrimaryByType(CTaskTypes::TASK_SCRIPTED_ANIMATION));
  1720. return pTask;
  1721. }
  1722.  
  1723. CTaskScriptedAnimation* FindSecondaryScriptedAnimTask(const CPed* pPed)
  1724. {
  1725. CTask* pTask = pPed->GetPedIntelligence()->GetTaskSecondaryPartialAnim();
  1726. if (pTask && pTask->GetTaskType()==CTaskTypes::TASK_SCRIPTED_ANIMATION)
  1727. {
  1728. return static_cast<CTaskScriptedAnimation*>(pTask);
  1729. }
  1730. return NULL;
  1731. }
  1732.  
  1733. const crClip* FindClipForScriptCommand(const char * pDictName, const char * pClipName, const char * ASSERT_ONLY(pScriptName))
  1734. {
  1735. const crClip* pClip = fwAnimManager::GetClipIfExistsByName(pDictName, pClipName);
  1736.  
  1737. #if __ASSERT
  1738. if (!pClip)
  1739. {
  1740. const char * pFailReason;
  1741. strLocalIndex dictIndex = strLocalIndex(fwAnimManager::FindSlot(pDictName));
  1742. if (dictIndex.Get()<0)
  1743. {
  1744. pFailReason = " The dictionary does not exist.";
  1745. }
  1746. else
  1747. {
  1748. fwClipDictionaryDef* pDictDef = fwAnimManager::GetSlot(dictIndex);
  1749. if ( !pDictDef)
  1750. {
  1751. pFailReason = " The dictionary is not in the image!";
  1752. }
  1753. else if (!GET_OBJECT(pDictDef))
  1754. {
  1755. pFailReason = " The dictionary is not streamed in.";
  1756. }
  1757. else
  1758. {
  1759. pFailReason = " The clip is not in the dictionary";
  1760. }
  1761. }
  1762. animAssertf (pClip, "(%s) Unable to retrieve clip '%s' from dictionary '%s'.%s", pScriptName, pClipName, pDictName, pFailReason);
  1763. }
  1764. #endif // __ASSERT
  1765. return pClip;
  1766. }
  1767.  
  1768. void CommandTaskPlayAnim(int PedIndex, const char *pAnimDictName, const char *pAnimName, float fBlendInDelta, float fBlendOutDelta, int nTimeToPlay, int nFlags, float startPhase, bool phaseControlled, int ikFlags, bool bAllowOverrideCloneUpdate)
  1769. {
  1770. if (SCRIPT_VERIFY((nTimeToPlay == -1) || (nTimeToPlay > 0) ,"TASK_PLAY_ANIM - Time must be -1 for infinite or > 0" ))
  1771. {
  1772. PlayAnimScriptCommand(SCRIPT_TASK_PLAY_ANIM, PedIndex, pAnimName, pAnimDictName, fBlendInDelta, fBlendOutDelta, nTimeToPlay, nFlags, ikFlags, false, VEC3_ZERO, VEC3_ZERO, startPhase, EULER_YXZ, phaseControlled, bAllowOverrideCloneUpdate);
  1773. }
  1774. }
  1775.  
  1776. #if __BANK
  1777. void VerifySlotData(CTaskScriptedAnimation::ScriptInitSlotData* pData)
  1778. {
  1779. if (pData)
  1780. {
  1781. switch(pData->state.Int)
  1782. {
  1783. case CTaskScriptedAnimation::kStateSingleClip:
  1784. {
  1785. VerifyDictAndAnim(scrDecodeString(pData->dict0.String), scrDecodeString(pData->clip0.String), "TASK_SCRIPTED_ANIMATION");
  1786. }
  1787. break;
  1788. case CTaskScriptedAnimation::kStateBlend:
  1789. {
  1790. VerifyDictAndAnim(scrDecodeString(pData->dict0.String), scrDecodeString(pData->clip0.String), "TASK_SCRIPTED_ANIMATION");
  1791. VerifyDictAndAnim(scrDecodeString(pData->dict1.String), scrDecodeString(pData->clip1.String), "TASK_SCRIPTED_ANIMATION");
  1792. VerifyDictAndAnim(scrDecodeString(pData->dict2.String), scrDecodeString(pData->clip2.String), "TASK_SCRIPTED_ANIMATION");
  1793. }
  1794. break;
  1795. default:
  1796. {
  1797.  
  1798. }
  1799. break;
  1800. }
  1801. }
  1802. }
  1803. #endif //__BANK
  1804.  
  1805. void CommandTaskScriptedAnimation(int pedIndex, int& priorityLowData, int& priorityMidData, int& priorityHighData, float blendInDelta, float BlendOutDelta)
  1806. {
  1807. CTaskScriptedAnimation::ScriptInitSlotData* priorityLow = reinterpret_cast<CTaskScriptedAnimation::ScriptInitSlotData*>(&priorityLowData);
  1808. CTaskScriptedAnimation::ScriptInitSlotData* priorityMid = reinterpret_cast<CTaskScriptedAnimation::ScriptInitSlotData*>(&priorityMidData);
  1809. CTaskScriptedAnimation::ScriptInitSlotData* priorityHigh = reinterpret_cast<CTaskScriptedAnimation::ScriptInitSlotData*>(&priorityHighData);
  1810.  
  1811. #if __BANK
  1812. // verify the clips exist, etc
  1813. VerifySlotData(priorityLow);
  1814. VerifySlotData(priorityMid);
  1815. VerifySlotData(priorityHigh);
  1816. #endif //__BANK
  1817.  
  1818. bool bSecondaryTask = false;
  1819. u32 combinedBits = priorityLow->flags.Int | priorityMid->flags.Int | priorityHigh->flags.Int;
  1820. eScriptedAnimFlagsBitSet& combinedFlags = reinterpret_cast<eScriptedAnimFlagsBitSet&>(combinedBits);
  1821.  
  1822. if ( combinedFlags.BitSet().IsSet(AF_SECONDARY) )
  1823. {
  1824. bSecondaryTask = true;
  1825. }
  1826.  
  1827. #if __ASSERT
  1828. if (NetworkInterface::IsGameInProgress() )
  1829. {
  1830. if( (priorityMid->state.Int!=CTaskScriptedAnimation::kStateEmpty) || (priorityHigh->state.Int!=CTaskScriptedAnimation::kStateEmpty) )
  1831. {
  1832. scriptAssertf(false,"TASK_SCRIPTED_ANIMATION:: Network implementation only handles one slot data in ANIM_DATA& priorityLow. priorityMid %s, priorityHigh %s",
  1833. (priorityMid->state.Int!=CTaskScriptedAnimation::kStateEmpty)?"Valid":"Empty",
  1834. (priorityHigh->state.Int!=CTaskScriptedAnimation::kStateEmpty)?"Valid":"Empty");
  1835. }
  1836. scriptAssertf( (priorityLow->clip2.String==NULL || priorityLow->weight2.Float==0.0f),"TASK_SCRIPTED_ANIMATION:: Network blended anim implementation only handles first 2 weighted anims. weight2 = %.5f, clip =%s",
  1837. priorityLow->weight2.Float,
  1838. priorityLow->clip2.String?priorityLow->clip2.String:"Null clip string");
  1839. }
  1840. #endif
  1841. // Start the new task
  1842. CTask* pTask = rage_new CTaskScriptedAnimation(*priorityLow, *priorityMid, *priorityHigh, blendInDelta, BlendOutDelta);
  1843.  
  1844. // handle the automated FPS alternative clip
  1845. if (combinedFlags.BitSet().IsSet(AF_USE_ALTERNATIVE_FP_ANIM))
  1846. {
  1847. if (pTask && priorityLow->state.Int==CTaskScriptedAnimation::kStateSingleClip)
  1848. {
  1849. static const char * s_fpsClipSuffixHash = "_FP";
  1850. u32 fpsClipHash = atPartialStringHash(s_fpsClipSuffixHash, atPartialStringHash(priorityLow->clip0.String));
  1851. atHashString finalFpsHash(atFinalizeHash(fpsClipHash));
  1852. static_cast<CTaskScriptedAnimation*>(pTask)->SetFPSClipHash(finalFpsHash);
  1853. BANK_ONLY(VerifyDictAndAnim(scrDecodeString(priorityLow->dict0.String), finalFpsHash, "TASK_SCRIPTED_ANIMATION");)
  1854. }
  1855. }
  1856.  
  1857. bool bPartOfASequence = (pedIndex == NULL_IN_SCRIPTING_LANGUAGE);
  1858.  
  1859. if ( bPartOfASequence && bSecondaryTask )
  1860. {
  1861. CTask* pTaskSecond=pTask;
  1862. pTask=rage_new CTaskAffectSecondaryBehaviour(true,PED_TASK_SECONDARY_PARTIAL_ANIM,pTaskSecond);
  1863. }
  1864. else if (bSecondaryTask)
  1865. {
  1866. CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(pedIndex, bSecondaryTask ? CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES : CTheScripts::GUID_ASSERT_FLAGS_ALL);
  1867. if(pPed)
  1868. {
  1869. pPed->GetPedIntelligence()->AddTaskSecondary( pTask, PED_TASK_SECONDARY_PARTIAL_ANIM );
  1870. }
  1871. return;
  1872. }
  1873.  
  1874. if (!bPartOfASequence && combinedFlags.BitSet().IsSet(AF_OVERRIDE_PHYSICS))
  1875. {
  1876. //force an ai update post camera so that the anim will be visible next frame (rather than waiting for the next task update)
  1877. CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(pedIndex, bSecondaryTask ? CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES : CTheScripts::GUID_ASSERT_FLAGS_ALL);
  1878. if(pPed)
  1879. {
  1880. pPed->SetPedResetFlag( CPED_RESET_FLAG_ForcePostCameraAIUpdate, true );
  1881. }
  1882. }
  1883.  
  1884. CScriptPeds::GivePedScriptedTask(pedIndex, pTask, SCRIPT_TASK_PLAY_ANIM, "TASK_SCRIPTED_ANIMATION");
  1885. }
  1886.  
  1887. void CommandPlayEntityScriptedAnimation(int EntityIndex, int& priorityLowData, int& priorityMidData, int& priorityHighData, float blendInDelta, float BlendOutDelta)
  1888. {
  1889. CTaskScriptedAnimation::ScriptInitSlotData* priorityLow = reinterpret_cast<CTaskScriptedAnimation::ScriptInitSlotData*>(&priorityLowData);
  1890. CTaskScriptedAnimation::ScriptInitSlotData* priorityMid = reinterpret_cast<CTaskScriptedAnimation::ScriptInitSlotData*>(&priorityMidData);
  1891. CTaskScriptedAnimation::ScriptInitSlotData* priorityHigh = reinterpret_cast<CTaskScriptedAnimation::ScriptInitSlotData*>(&priorityHighData);
  1892.  
  1893. #if __BANK
  1894. // verify the clips exist, etc
  1895. VerifySlotData(priorityLow);
  1896. VerifySlotData(priorityMid);
  1897. VerifySlotData(priorityHigh);
  1898. #endif //__BANK
  1899.  
  1900. // Start the new task
  1901. CPhysical *pEntity = CTheScripts::GetEntityToModifyFromGUID< CPhysical >(EntityIndex);
  1902. if(pEntity)
  1903. {
  1904. CTask* pTask = rage_new CTaskScriptedAnimation(*priorityLow, *priorityMid, *priorityHigh, blendInDelta, BlendOutDelta);
  1905. if (pEntity->GetIsTypeObject())
  1906. {
  1907. CObject *pObject = static_cast<CObject*>(pEntity);
  1908. pObject->SetTask(pTask, CObjectIntelligence::OBJECT_TASK_TREE_SECONDARY, CObjectIntelligence::OBJECT_TASK_SECONDARY_ANIM);
  1909. }
  1910. else if(pEntity->GetIsTypeVehicle())
  1911. {
  1912. CVehicle *pVehicle = static_cast<CVehicle*>(pEntity);
  1913. pVehicle->GetIntelligence()->AddTask(VEHICLE_TASK_TREE_SECONDARY, pTask, VEHICLE_TASK_SECONDARY_ANIM, true);
  1914. }
  1915. else
  1916. {
  1917. delete pTask;
  1918. }
  1919. }
  1920. }
  1921.  
  1922. void CommandTaskPlayPhoneGestureAnimation(int PedIndex, const char* pAnimDictHash, const char* pAnimName, const char *pFilterName, float fBlendInDuration, float fBlendOutDuration, bool bIsLooping, bool bHoldLastFrame)
  1923. {
  1924. const CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  1925. if (SCRIPT_VERIFY(pPed && pPed->GetAnimDirector(), "TASK_PLAY_PHONE_GESTURE_ANIMATION - Invalid ped or ped has no anim director."))
  1926. {
  1927. // Look to see if secondary/phone task is running
  1928. CTaskMobilePhone *pTaskMobilePhone = static_cast<CTaskMobilePhone*>(pPed->GetPedIntelligence()->FindTaskSecondaryByType(CTaskTypes::TASK_MOBILE_PHONE));
  1929. if (SCRIPT_VERIFY(pTaskMobilePhone, "TASK_PLAY_PHONE_GESTURE_ANIMATION - Ped is not running mobile phone task."))
  1930. {
  1931. // Check if clip actually exists
  1932. u32 uDictHashkey = atHashString(pAnimDictHash);
  1933. s32 sAnimDictIndex = fwAnimManager::FindSlotFromHashKey(uDictHashkey).Get();
  1934. u32 uAnimHashKey = atHashString(pAnimName);
  1935. const crClip* pClip = fwAnimManager::GetClipIfExistsByDictIndex(sAnimDictIndex, uAnimHashKey);
  1936. scriptAssertf(pClip, "TASK_PLAY_PHONE_GESTURE_ANIMATION - Animation does not exist. Please ensure dictionary is streamed in! sAnimDictIndex: %d, uAnimHashKey: %d", sAnimDictIndex, uAnimHashKey);
  1937.  
  1938. if (pClip)
  1939. {
  1940. pTaskMobilePhone->RequestAdditionalSecondaryAnims(pAnimDictHash, pAnimName, pFilterName, fBlendInDuration, fBlendOutDuration, bIsLooping, bHoldLastFrame);
  1941. }
  1942. }
  1943. }
  1944. }
  1945.  
  1946. void CommandTaskStopPhoneGestureAnimation(int PedIndex, float fBlendOutOverride)
  1947. {
  1948. const CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  1949. if (SCRIPT_VERIFY(pPed && pPed->GetAnimDirector(), "TASK_STOP_PHONE_GESTURE_ANIMATION - Invalid ped or ped has no anim director."))
  1950. {
  1951. CTaskMobilePhone *pTaskMobilePhone = static_cast<CTaskMobilePhone*>(pPed->GetPedIntelligence()->FindTaskSecondaryByType(CTaskTypes::TASK_MOBILE_PHONE));
  1952. if (SCRIPT_VERIFY(pTaskMobilePhone, "TASK_STOP_PHONE_GESTURE_ANIMATION - Ped is not running mobile phone task."))
  1953. {
  1954. pTaskMobilePhone->ClearAdditionalSecondaryAnimation(fBlendOutOverride);
  1955. }
  1956. }
  1957. }
  1958.  
  1959. bool CommandIsPlayingPhoneGestureAnim(int PedIndex)
  1960. {
  1961. const CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  1962. if (SCRIPT_VERIFY(pPed && pPed->GetAnimDirector(), "(IS_PLAYING_PHONE_GESTURE_ANIM - Invalid ped or ped has no anim director."))
  1963. {
  1964. CTaskMobilePhone *pTaskMobilePhone = static_cast<CTaskMobilePhone*>(pPed->GetPedIntelligence()->FindTaskSecondaryByType(CTaskTypes::TASK_MOBILE_PHONE));
  1965. if (SCRIPT_VERIFY(pTaskMobilePhone, "(IS_PLAYING_PHONE_GESTURE_ANIM - Ped is not running mobile phone task."))
  1966. {
  1967. return pTaskMobilePhone->GetIsPlayingAdditionalSecondaryAnim();
  1968. }
  1969. }
  1970. return false;
  1971. }
  1972.  
  1973. float CommandGetPhoneGestureAnimCurrentTime(int PedIndex)
  1974. {
  1975. const CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  1976. if (SCRIPT_VERIFY(pPed && pPed->GetAnimDirector(), "GET_PHONE_GESTURE_ANIM_CURRENT_TIME - Invalid ped or ped has no anim director."))
  1977. {
  1978. CTaskMobilePhone *pTaskMobilePhone = static_cast<CTaskMobilePhone*>(pPed->GetPedIntelligence()->FindTaskSecondaryByType(CTaskTypes::TASK_MOBILE_PHONE));
  1979. if (SCRIPT_VERIFY(pTaskMobilePhone, "GET_PHONE_GESTURE_ANIM_CURRENT_TIME - Ped is not running mobile phone task."))
  1980. {
  1981. return pTaskMobilePhone->GetAdditionalSecondaryAnimPhase();
  1982. }
  1983. }
  1984. return -1.0f;
  1985. }
  1986.  
  1987. float CommandGetPhoneGestureAnimTotalTime(int PedIndex)
  1988. {
  1989. const CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  1990. if (SCRIPT_VERIFY(pPed && pPed->GetAnimDirector(), "GET_PHONE_GESTURE_ANIM_TOTAL_TIME - Invalid ped or ped has no anim director."))
  1991. {
  1992. CTaskMobilePhone *pTaskMobilePhone = static_cast<CTaskMobilePhone*>(pPed->GetPedIntelligence()->FindTaskSecondaryByType(CTaskTypes::TASK_MOBILE_PHONE));
  1993. if (SCRIPT_VERIFY(pTaskMobilePhone, "GET_PHONE_GESTURE_ANIM_TOTAL_TIME - Ped is not running mobile phone task."))
  1994. {
  1995. return pTaskMobilePhone->GetAdditionalSecondaryAnimDuration();
  1996. }
  1997. }
  1998. return -1.0f;
  1999. }
  2000.  
  2001. void CommandStartAnimPlayback(int EntityIndex, int& data, s32 priority)
  2002. {
  2003. CTaskScriptedAnimation::ScriptInitSlotData* slotData = reinterpret_cast<CTaskScriptedAnimation::ScriptInitSlotData*>(&data);
  2004.  
  2005. CPhysical *pPhysical = CTheScripts::GetEntityToModifyFromGUID<CPhysical>(EntityIndex);
  2006. if(pPhysical)
  2007. {
  2008. // look for an existing scripted animation task running on the ped
  2009. CTaskScriptedAnimation* pTask = NULL;
  2010.  
  2011. if (slotData->flags.Int & BIT(AF_SECONDARY))
  2012. {
  2013. pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true, false);
  2014. }
  2015. else
  2016. {
  2017. pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true);
  2018. }
  2019.  
  2020. if (SCRIPT_VERIFY(pTask, "START_ANIM_PLAYBACK: Anim task is not playing. Use TASK_SCRIPTED_ANIMATION to begin the task."))
  2021. {
  2022. CTaskScriptedAnimation::InitSlotData data(*slotData);
  2023. pTask->StartPlayback(data, GetPriorityFromControlFlags(priority));
  2024. }
  2025. }
  2026. }
  2027.  
  2028. void CommandStopAnimPlayback(int EntityIndex, s32 priority, bool secondary = false)
  2029. {
  2030. CPhysical *pPhysical = CTheScripts::GetEntityToModifyFromGUID<CPhysical>(EntityIndex);
  2031. if(pPhysical)
  2032. {
  2033. // look for an existing scripted animation task running on the ped
  2034. CTaskScriptedAnimation* pTask = NULL;
  2035.  
  2036. if (secondary)
  2037. {
  2038. pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true, false);
  2039. }
  2040. else
  2041. {
  2042. pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true);
  2043. }
  2044.  
  2045. if (SCRIPT_VERIFY(pTask, "STOP_ANIM_PLAYBACK: Anim task is not playing."))
  2046. {
  2047. pTask->StopPlayback(GetPriorityFromControlFlags(priority));
  2048. }
  2049. }
  2050. }
  2051.  
  2052. void CommandTaskClipSetClip(int EntityIndex, const char * pAnimDictName, const char * pAnimName, s32 priority, s32 index, bool secondary = false)
  2053. {
  2054. CPhysical *pPhysical = CTheScripts::GetEntityToModifyFromGUID<CPhysical>(EntityIndex);
  2055. if(pPhysical)
  2056. {
  2057. // look for an existing scripted animation task running on the ped
  2058. CTaskScriptedAnimation* pTask = NULL;
  2059.  
  2060. if (secondary)
  2061. {
  2062. pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true, false);
  2063. }
  2064. else
  2065. {
  2066. pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true);
  2067. }
  2068.  
  2069. if (SCRIPT_VERIFY(pTask, "TASK_CLIP_SET_CLIP: Anim task is not playing. Use TASK_ANIM_START_CLIP or TASK_ANIM_START_BLEND to begin the task."))
  2070. {
  2071. const crClip* pClip = FindClipForScriptCommand(pAnimDictName, pAnimName, "TASK_CLIP_SET_CLIP");
  2072.  
  2073. if (pClip)
  2074. {
  2075. pTask->SetClip(pClip, GetPriorityFromControlFlags(priority), (u8)index);
  2076. }
  2077. }
  2078. }
  2079. }
  2080.  
  2081. void CommandTaskClipSetBlendWeight(int EntityIndex, float weight, s32 priority, s32 index, bool secondary = false)
  2082. {
  2083. CPhysical *pPhysical = CTheScripts::GetEntityToModifyFromGUID<CPhysical>(EntityIndex);
  2084. if(pPhysical)
  2085. {
  2086. // look for an existing scripted animation task running on the ped
  2087. CTaskScriptedAnimation* pTask = NULL;
  2088.  
  2089. if (secondary)
  2090. {
  2091. pTask = pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true, false);
  2092. }
  2093. else
  2094. {
  2095. pTask = pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true);
  2096. }
  2097.  
  2098. if (SCRIPT_VERIFY(pTask, "TASK_CLIP_SET_BLEND_WEIGHT: Anim task is not playing. Use TASK_ANIM_START_BLEND to begin the task."))
  2099. {
  2100.  
  2101. pTask->SetBlend(weight, GetPriorityFromControlFlags(priority) , (u8)index);
  2102. }
  2103. }
  2104. }
  2105.  
  2106. void CommandTaskClipSetFilter(int EntityIndex, const char * pFilterName, s32 priority, bool secondary = false)
  2107. {
  2108. CPhysical *pPhysical = CTheScripts::GetEntityToModifyFromGUID<CPhysical>(EntityIndex);
  2109. if(pPhysical)
  2110. {
  2111. // look for an existing scripted animation task running on the ped
  2112. CTaskScriptedAnimation* pTask = NULL;
  2113.  
  2114. if (secondary)
  2115. {
  2116. pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true, false);
  2117. }
  2118. else
  2119. {
  2120. pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true);
  2121. }
  2122.  
  2123. if (SCRIPT_VERIFY(pTask, "TASK_CLIP_SET_FILTER: Anim task is not playing. Use TASK_ANIM_START_CLIP or TASK_ANIM_START_BLEND to begin the task."))
  2124. {
  2125. pTask->SetFilter(pFilterName, GetPriorityFromControlFlags(priority));
  2126. }
  2127. }
  2128. }
  2129.  
  2130. void CommandTaskClipSetPhase(int EntityIndex, float phase, s32 priority, bool secondary = false)
  2131. {
  2132. CPhysical *pPhysical = CTheScripts::GetEntityToModifyFromGUID<CPhysical>(EntityIndex);
  2133. if(pPhysical)
  2134. {
  2135. // look for an existing scripted animation task running on the ped
  2136. CTaskScriptedAnimation* pTask = NULL;
  2137.  
  2138. if (secondary)
  2139. {
  2140. pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true, false);
  2141. }
  2142. else
  2143. {
  2144. pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true);
  2145. }
  2146.  
  2147. if (SCRIPT_VERIFY(pTask, "TASK_CLIP_SET_PHASE: Anim task is not playing. Use TASK_ANIM_START_CLIP or TASK_ANIM_START_BLEND to begin the task."))
  2148. {
  2149. pTask->SetPhase(phase, GetPriorityFromControlFlags(priority));
  2150. }
  2151. }
  2152. }
  2153.  
  2154. void CommandTaskClipSetRate(int EntityIndex, float rate, s32 priority, bool secondary = false)
  2155. {
  2156. CPhysical *pPhysical = CTheScripts::GetEntityToModifyFromGUID<CPhysical>(EntityIndex);
  2157. if(pPhysical)
  2158. {
  2159. // look for an existing scripted animation task running on the ped
  2160. CTaskScriptedAnimation* pTask = NULL;
  2161.  
  2162. if (secondary)
  2163. {
  2164. pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true, false);
  2165. }
  2166. else
  2167. {
  2168. pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true);
  2169. }
  2170.  
  2171. if (SCRIPT_VERIFY(pTask, "TASK_CLIP_SET_RATE: Anim task is not playing. Use TASK_ANIM_START_CLIP or TASK_ANIM_START_BLEND to begin the task."))
  2172. {
  2173. pTask->SetRate(rate, GetPriorityFromControlFlags(priority));
  2174. }
  2175. }
  2176. }
  2177.  
  2178. void CommandTaskClipSetLooped(int EntityIndex, bool looped, s32 priority, bool secondary = false)
  2179. {
  2180. CPhysical *pPhysical = CTheScripts::GetEntityToModifyFromGUID<CPhysical>(EntityIndex);
  2181. if(pPhysical)
  2182. {
  2183. // look for an existing scripted animation task running on the ped
  2184. CTaskScriptedAnimation* pTask = NULL;
  2185.  
  2186. if (secondary)
  2187. {
  2188. pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true, false);
  2189. }
  2190. else
  2191. {
  2192. pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true);
  2193. }
  2194.  
  2195. if (SCRIPT_VERIFY(pTask, "TASK_CLIP_SET_LOOPED: Anim task is not playing. Use TASK_ANIM_START_CLIP or TASK_ANIM_START_BLEND to begin the task."))
  2196. {
  2197. pTask->SetLooped(looped, GetPriorityFromControlFlags(priority));
  2198. }
  2199. }
  2200. }
  2201.  
  2202. void CommandTaskPlayAnimAdvanced(int PedIndex, const char *pAnimDictName, const char *pAnimName, const scrVector & pos, const scrVector & rot, float fBlendInDelta, float fBlendOutDelta, int nTimeToPlay, int nFlags, float startPhase, int RotOrder, int ikFlags)
  2203. {
  2204. if (SCRIPT_VERIFY((nTimeToPlay == -1) || (nTimeToPlay > 0) ,"TASK_PLAY_ANIM - Time must be -1 for infinite or > 0" ))
  2205. {
  2206. // Transform the rotation into x = yaw, y = pitch, z = roll
  2207. // Convert from degrees to radians
  2208. Vector3 axisRot(DtoR*rot.x, DtoR*rot.y, DtoR*rot.z);
  2209.  
  2210. #if GTA_REPLAY
  2211. CPed *pPed = NULL;
  2212. if(NULL_IN_SCRIPTING_LANGUAGE!=PedIndex)
  2213. {
  2214. pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  2215. if(pPed)
  2216. {
  2217. CReplayMgr::RecordWarpedEntity(pPed);
  2218. }
  2219. }
  2220. #endif
  2221.  
  2222. PlayAnimScriptCommand(SCRIPT_TASK_PLAY_ANIM, PedIndex, pAnimName, pAnimDictName, fBlendInDelta, fBlendOutDelta, nTimeToPlay, nFlags, ikFlags, true, Vector3(pos), axisRot, startPhase, static_cast<EulerAngleOrder>(RotOrder), false, false);
  2223. }
  2224. }
  2225.  
  2226. void CommandStopAnimTask(int EntityIndex, const char *pAnimDictName, const char *pAnimName, float fBlendDelta)
  2227. {
  2228. // Check the object
  2229. CPhysical *pPhysical = CTheScripts::GetEntityToModifyFromGUID<CPhysical>(EntityIndex);
  2230. if(pPhysical)
  2231. {
  2232. // look for an existing scripted animation task running on the ped
  2233. CTaskScriptedAnimation* pTask = NULL;
  2234.  
  2235. pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true);
  2236.  
  2237. if (pTask && pTask->IsPlayingClip(pAnimDictName, pAnimName))
  2238. {
  2239. // nothing to see here
  2240. }
  2241. else
  2242. {
  2243. //check the secondary task tree
  2244. pTask = entity_commands::FindScriptedAnimTask(EntityIndex, true, false);
  2245. if (pTask && !pTask->IsPlayingClip(pAnimDictName,pAnimName))
  2246. {
  2247. pTask = NULL;
  2248. }
  2249. }
  2250.  
  2251. const CTaskSynchronizedScene* pTaskSynchronizedScene = NULL;
  2252. if (!pTask)
  2253. {
  2254. pTaskSynchronizedScene = entity_commands::FindSynchronizedSceneTask(EntityIndex, pAnimDictName, pAnimName);
  2255. if (!SCRIPT_VERIFY(pTaskSynchronizedScene == NULL, "STOP_ANIM_TASK - Entity is playing the anim through a synced scene, use STOP_SYNCHRONIZED_ENTITY_ANIM instead!"))
  2256. {
  2257. pTaskSynchronizedScene = NULL;
  2258. }
  2259. }
  2260. if(!pTaskSynchronizedScene)
  2261. {
  2262. if (SCRIPT_VERIFY(pTask, "STOP_ANIM_TASK - Entity isn't running the anim"))
  2263. {
  2264. scriptAssertf(fBlendDelta<0.0f, "Blend out delta must be less than 0.0");
  2265. pTask->BlendOut(fwAnimHelpers::CalcBlendDuration(fBlendDelta));
  2266. }
  2267. }
  2268. }
  2269. }
  2270.  
  2271. void CommandTaskSynchronizedScene(int PedIndex, int sceneId, const char *pAnimDictName, const char *pAnimName, float blendIn, float blendOut, int flags, int ragdollBlockingFlags, float moverBlendDelta, int ikFlags)
  2272. {
  2273. if (SCRIPT_VERIFY(PedIndex!=NULL_IN_SCRIPTING_LANGUAGE, "TASK_SYNCHRONIZED_SCENE cannot be used in a sequence!"))
  2274. {
  2275. if (SCRIPT_VERIFY(fwAnimDirectorComponentSyncedScene::IsValidSceneId((fwSyncedSceneId)sceneId), "TASK_SYNCHRONIZED_SCENE: Invalid scene id!"))
  2276. {
  2277. // Get the ped
  2278. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  2279. if(pPed)
  2280. {
  2281. scriptAssertf(blendIn>0.0f ,"TASK_SYNCHRONIZED_SCENE: blend in delta is (%f) should be > 0.0f. Changing to INSTANT_BLEND_IN_DELTA.", blendIn);
  2282. if (blendIn<=0.0f)
  2283. blendIn = INSTANT_BLEND_IN_DELTA;
  2284.  
  2285. scriptAssertf(blendOut<0.0f ,"TASK_SYNCHRONIZED_SCENE: blend out delta (%f) should be < 0.0. Changing to INSTANT_BLEND_OUT_DELTA.", blendOut);
  2286. if (blendOut>=0.0f)
  2287. blendOut = INSTANT_BLEND_OUT_DELTA;
  2288.  
  2289. scriptAssertf(moverBlendDelta>0.0f ,"TASK_SYNCHRONIZED_SCENE: mover blend delta (%f) should be > 0.0f. Changing to INSTANT_BLEND_IN_DELTA!", moverBlendDelta);
  2290. if (moverBlendDelta<=0.0f)
  2291. moverBlendDelta = INSTANT_BLEND_IN_DELTA;
  2292.  
  2293.  
  2294. if(pPed->GetIsAttached())
  2295. {
  2296. // If we are using CTaskUseScenario, it's probably not a problem if we are attached, because it's likely
  2297. // the task itself that has attached the ped.
  2298. CTaskUseScenario* pScenarioTask = static_cast<CTaskUseScenario*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_USE_SCENARIO));
  2299. if(pScenarioTask)
  2300. {
  2301. // It would have been expected to me that the running CTaskUseScenario would be aborted and
  2302. // clean up the detachment before CTaskSynchronizedScene starts, so that we would just need
  2303. // to find a way to bypass the attachment check below. For some reason, that doesn't seem to happen,
  2304. // but by calling MakeAbortable(), the task seems to clean up the attachment (and we can still
  2305. // check GetIsAttached() below), in case the abort failed or if there was some other reason the
  2306. // ped was attached. /FF
  2307. pScenarioTask->MakeAbortable(CTask::ABORT_PRIORITY_IMMEDIATE, NULL);
  2308. }
  2309. }
  2310.  
  2311. if (pPed->GetPedConfigFlag( CPED_CONFIG_FLAG_InVehicle ))
  2312. {
  2313.  
  2314. // Added by sorr in CL 6438528
  2315. if(pPed->IsLocalPlayer() && pPed->GetPedAudioEntity())
  2316. {
  2317. u32 animDictNameHash = atStringHash(pAnimDictName);
  2318. if(animDictNameHash == ATSTRINGHASH("mini@prostitutes@sexlow_veh_first_person", 0x3A68E23A) ||
  2319. animDictNameHash == ATSTRINGHASH("mini@prostitutes@sexnorm_veh_first_person", 0xF72790A8))
  2320. {
  2321. pPed->GetPedAudioEntity()->SetCachedBJVehicle(pPed->GetMyVehicle());
  2322. }
  2323. }
  2324. // Added by sorr in CL 6438528
  2325.  
  2326. Warningf("TASK_SYNCHRONIZED_SCENE: Ped was in vehicle, setting them out of it.");
  2327. pPed->SetPedOutOfVehicle(CPed::PVF_IgnoreSafetyPositionCheck|CPed::PVF_Warp);
  2328. }
  2329.  
  2330. const fwAttachmentEntityExtension *pExtension = pPed->GetAttachmentExtension();
  2331. if (pExtension)
  2332. {
  2333. fwEntity *entity = pExtension->GetAttachParent();
  2334. if (entity)
  2335. {
  2336. Warningf("TASK_SYNCHRONIZED_SCENE: Ped was attached. Detaching them.");
  2337. pPed->DetachFromParent(DETACH_FLAG_IGNORE_SAFE_POSITION_CHECK|DETACH_FLAG_SKIP_CURRENT_POSITION_CHECK);
  2338. }
  2339. }
  2340. scriptAssertf(!pPed->GetIsAttached(), "TASK_SYNCHRONIZED_SCENE: Ped is attached.");
  2341.  
  2342. const crClip* pClip = FindClipForScriptCommand(pAnimDictName, pAnimName, "TASK_SYNCHRONIZED_SCENE");
  2343. if (pClip)
  2344. {
  2345. eSyncedSceneFlagsBitSet& sceneFlags = reinterpret_cast<eSyncedSceneFlagsBitSet&>(flags);
  2346. eRagdollBlockingFlagsBitSet& ragdollFlags = reinterpret_cast<eRagdollBlockingFlagsBitSet&>(ragdollBlockingFlags);
  2347. eIkControlFlagsBitSet& ikControlFlags = reinterpret_cast<eIkControlFlagsBitSet&>(ikFlags);
  2348.  
  2349. CTaskSynchronizedScene* pTask = rage_new CTaskSynchronizedScene(static_cast<fwSyncedSceneId>(sceneId), atPartialStringHash(pAnimName), pAnimDictName, blendIn, blendOut, sceneFlags, ragdollFlags, moverBlendDelta, -1, ikControlFlags);
  2350.  
  2351. #if __DEV
  2352. fwAnimDirectorComponentSyncedScene::RegisterWithSyncedScene(static_cast<fwSyncedSceneId>(sceneId), pPed);
  2353. #endif //__DEV
  2354.  
  2355. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_SYNCHRONIZED_SCENE, "TASK_SYNCHRONIZED_SCENE");
  2356. animEntityDebugf(pPed, "TASK_SYNCHRONIZED_SCENE - %s starting synced scene task", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  2357.  
  2358. // make sure we do an ai update now to sync up next frame
  2359. pPed->SetPedResetFlag( CPED_RESET_FLAG_ForcePostCameraAIUpdate, true );
  2360. pPed->SetPedResetFlag( CPED_RESET_FLAG_AllowUpdateIfNoCollisionLoaded, true);
  2361. if (blendIn==INSTANT_BLEND_IN_DELTA)
  2362. {
  2363. animDebugf3("[%u:%u] TASK_SYNCHRONIZED_SCENE: forcing a post camera anim update ped %s(%p) for instant blend in of synced scene", fwTimer::GetTimeInMilliseconds(), fwTimer::GetFrameCount(), pPed->GetModelName(), pPed);
  2364. pPed->SetPedResetFlag( CPED_RESET_FLAG_ForcePostCameraAnimUpdate, true );
  2365. }
  2366. }
  2367. }
  2368. }
  2369. }
  2370. }
  2371.  
  2372. int GetActualSequenceId(int Sequence)
  2373. {
  2374. return CTheScripts::GetCurrentGtaScriptHandler()->GetResourceReferenceFromId(Sequence);
  2375. }
  2376.  
  2377. void CommandOpenSequenceTask(int &Sequence)
  2378. {
  2379. CScriptResource_SequenceTask sequenceResource;
  2380.  
  2381. Sequence = CTheScripts::GetCurrentGtaScriptHandler()->RegisterScriptResourceAndGetId(sequenceResource);
  2382. }
  2383.  
  2384. void CommandCloseSequenceTask(int Sequence)
  2385. {
  2386. const int iTaskID = GetActualSequenceId(Sequence);
  2387. if(SCRIPT_VERIFY(iTaskID>=0, "CLOSE_SEQUENCE_TASK - No free sequences left."))
  2388. {
  2389. if(SCRIPT_VERIFY(iTaskID<CTaskSequences::MAX_NUM_SEQUENCE_TASKS, "CLOSE_SEQUENCE_TASK - Sequence task ID too big"))
  2390. {
  2391. if(SCRIPT_VERIFY(CTaskSequences::ms_bIsOpened[iTaskID], "CLOSE_SEQUENCE_TASK - Sequence task is already closed"))
  2392. {
  2393. SCRIPT_ASSERT(!CTaskSequences::ms_TaskSequenceLists[iTaskID].IsEmpty(), "CLOSE_SEQUENCE_TASK - sequence is empty");
  2394.  
  2395. CTaskSequences::ms_bIsOpened[iTaskID]=false;
  2396. CTaskSequences::ms_iActiveSequence=-1;
  2397. }
  2398. }
  2399. }
  2400. }
  2401.  
  2402. void CommandTaskPerformSequence(int PedIndex, int Sequence)
  2403. {
  2404. const int iTaskID = GetActualSequenceId(Sequence);
  2405. if(SCRIPT_VERIFY(iTaskID >= 0 && iTaskID<CTaskSequences::MAX_NUM_SEQUENCE_TASKS, "TASK_PERFORM_SEQUENCE - not a valid Sequence task ID"))
  2406. {
  2407. if (SCRIPT_VERIFY(!CTaskSequences::ms_bIsOpened[iTaskID], "TASK_PERFORM_SEQUENCE - Sequence task is still open"))
  2408. {
  2409. if (SCRIPT_VERIFY(!CTaskSequences::ms_TaskSequenceLists[iTaskID].IsEmpty(), "TASK_PERFORM_SEQUENCE - sequence task empty"))
  2410. {
  2411. CTaskUseSequence* pSequenceTask=rage_new CTaskUseSequence(iTaskID, Sequence);
  2412.  
  2413. #if __ASSERT
  2414. //If assigning a sequence with a prop task in it, make sure the ped has an inventory.
  2415.  
  2416. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  2417.  
  2418. const CTaskList& taskList = pSequenceTask->GetTaskSequenceList()->GetTaskList();
  2419. for (int seqIndex = 0; seqIndex < taskList.GetNumTasks(); ++seqIndex)
  2420. {
  2421. const CTask* pTask = static_cast<const CTask*>(taskList.GetTask(seqIndex));
  2422. if (pTask && pTask->GetTaskType() == CTaskTypes::TASK_USE_SCENARIO)
  2423. {
  2424. const CTaskUseScenario* pScenarioTask = static_cast<const CTaskUseScenario*>(pTask);
  2425. scriptAssertf(!pScenarioTask->GetScenarioInfo().HasProp() || pPed->GetInventory(), "%s: Attempting to assign a ped a task sequence that includes a prop scenario (%s), but the ped(%s) has no inventory", CTheScripts::GetCurrentScriptNameAndProgramCounter(), pScenarioTask->GetScenarioInfo().GetName(), pPed->GetModelName());
  2426. }
  2427. }
  2428. #endif
  2429. CScriptPeds::GivePedScriptedTask(PedIndex, pSequenceTask, SCRIPT_TASK_PERFORM_SEQUENCE, "TASK_PERFORM_SEQUENCE");
  2430. }
  2431. }
  2432. }
  2433. }
  2434.  
  2435. void CommandTaskPerformSequenceLocally(int PedIndex, int Sequence)
  2436. {
  2437. const int iTaskID = GetActualSequenceId(Sequence);
  2438. if(SCRIPT_VERIFY(iTaskID >= 0 && iTaskID<CTaskSequences::MAX_NUM_SEQUENCE_TASKS, "TASK_PERFORM_SEQUENCE_LOCALLY - not a valid Sequence task ID"))
  2439. {
  2440. if(SCRIPT_VERIFY(!CTaskSequences::ms_bIsOpened[iTaskID], "TASK_PERFORM_SEQUENCE_LOCALLY - Sequence task is still open"))
  2441. {
  2442. if(SCRIPT_VERIFY(!CTaskSequences::ms_TaskSequenceLists[iTaskID].IsEmpty(), "TASK_PERFORM_SEQUENCE_LOCALLY - sequence task empty"))
  2443. {
  2444. CTaskUseSequence* pTask=rage_new CTaskUseSequence(iTaskID);
  2445. CScriptPeds::GivePedScriptedTask(PedIndex,pTask, SCRIPT_TASK_PERFORM_SEQUENCE_LOCALLY, "TASK_PERFORM_SEQUENCE_LOCALLY");
  2446. }
  2447. }
  2448. }
  2449. }
  2450.  
  2451. void CommandClearSequenceTask(int &Sequence)
  2452. {
  2453. CTheScripts::GetCurrentGtaScriptHandler()->RemoveScriptResource(Sequence, false, true, CGameScriptResource::SCRIPT_RESOURCE_SEQUENCE_TASK);
  2454. Sequence = 0;
  2455. }
  2456.  
  2457.  
  2458. void CommandSetSequenceToRepeat(int Sequence, int repeat)
  2459. {
  2460. const int iSequenceTaskID = GetActualSequenceId(Sequence);
  2461. const int iRepeatMode=repeat;
  2462.  
  2463. if(SCRIPT_VERIFY(iSequenceTaskID==CTaskSequences::ms_iActiveSequence, "SET_SEQUENCE_TO_REPEAT - Using wrong sequence ID"))
  2464. {
  2465. if(SCRIPT_VERIFY (iSequenceTaskID>=0 && iSequenceTaskID<CTaskSequences::MAX_NUM_SEQUENCE_TASKS, "SET_SEQUENCE_TO_REPEAT - Sequence task ID out of range"))
  2466. {
  2467. if(SCRIPT_VERIFY (CTaskSequences::ms_bIsOpened[iSequenceTaskID], "SET_SEQUENCE_TO_REPEAT - Sequence task needs to be open"))
  2468. {
  2469. CTaskSequences::ms_TaskSequenceLists[CTaskSequences::ms_iActiveSequence].SetRepeatMode(iRepeatMode);
  2470. }
  2471. }
  2472. }
  2473. }
  2474.  
  2475. void CommandSetSequencePreventMigration(int Sequence)
  2476. {
  2477. const int iSequenceTaskID = GetActualSequenceId(Sequence);
  2478.  
  2479. if(SCRIPT_VERIFY(iSequenceTaskID==CTaskSequences::ms_iActiveSequence, "SET_SEQUENCE_PREVENT_MIGRATION - Using wrong sequence ID"))
  2480. {
  2481. if(SCRIPT_VERIFY (iSequenceTaskID>=0 && iSequenceTaskID<CTaskSequences::MAX_NUM_SEQUENCE_TASKS, "SET_SEQUENCE_TO_REPEAT - Sequence task ID out of range"))
  2482. {
  2483. if(SCRIPT_VERIFY (CTaskSequences::ms_bIsOpened[iSequenceTaskID], "SET_SEQUENCE_PREVENT_MIGRATION - Sequence task needs to be open"))
  2484. {
  2485. CTaskSequences::ms_TaskSequenceLists[CTaskSequences::ms_iActiveSequence].PreventMigration();
  2486. }
  2487. }
  2488. }
  2489. }
  2490.  
  2491. int CommandGetSequenceProgress(int PedIndex)
  2492. {
  2493. int iProgress=-1;
  2494. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  2495. if (pPed)
  2496. {
  2497. if (SCRIPT_VERIFY(CPedScriptedTaskRecord::GetStatus(pPed, SCRIPT_TASK_PERFORM_SEQUENCE)>=0 ||
  2498. CPedScriptedTaskRecord::GetStatus(pPed, SCRIPT_TASK_PERFORM_SEQUENCE_FROM_PROGRESS)>=0,
  2499. "GET_SEQUENCE_PROGRESS - Ped isn't performing sequence"))
  2500. {
  2501. bool b=false;
  2502.  
  2503. const int iStage1=CPedScriptedTaskRecord::GetStatus(pPed, SCRIPT_TASK_PERFORM_SEQUENCE);
  2504. if(CPedScriptedTaskRecordData::EVENT_STAGE==iStage1)
  2505. {
  2506. b=true;
  2507. iProgress=-1;
  2508. }
  2509.  
  2510. const int iStage2=CPedScriptedTaskRecord::GetStatus(pPed, SCRIPT_TASK_PERFORM_SEQUENCE_FROM_PROGRESS);
  2511. if(CPedScriptedTaskRecordData::EVENT_STAGE==iStage2)
  2512. {
  2513. b=true;
  2514. iProgress=-1;
  2515. }
  2516.  
  2517. if(!b)
  2518. {
  2519. if( pPed->GetPedIntelligence()->GetQueriableInterface()->IsTaskPresentAtPriority( CTaskTypes::TASK_USE_SEQUENCE, PED_TASK_PRIORITY_PRIMARY ) )
  2520. {
  2521. iProgress = pPed->GetPedIntelligence()->GetQueriableInterface()->GetSequenceProgressForTaskType( 0, CTaskTypes::TASK_USE_SEQUENCE, PED_TASK_PRIORITY_PRIMARY );
  2522. }
  2523. else
  2524. {
  2525. scriptAssertf(false, "GET_SEQUENCE_PROGRESS- Ped doesn't have a the correct primary task");
  2526. }
  2527. }
  2528. }
  2529. }
  2530. return iProgress;
  2531. }
  2532.  
  2533.  
  2534. void CommandTaskGetOffBoat( int iPedID, int iTime )
  2535. {
  2536. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0) ,"TASK_GET_OFF_BOAT - Time must be -1 for infinite and > 0" ))
  2537. {
  2538. CTaskComplexGetOffBoat * pTaskGetOffBoat = rage_new CTaskComplexGetOffBoat(iTime);
  2539. CScriptPeds::GivePedScriptedTask( iPedID, pTaskGetOffBoat, SCRIPT_TASK_GET_OFF_BOAT, "TASK_GET_OFF_BOAT");
  2540. }
  2541. }
  2542.  
  2543. bool CommandGetIsTaskActive( int iPedID, int iCommandType )
  2544. {
  2545. const CPed *pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedID);
  2546. if (pPed)
  2547. {
  2548. if(pPed->GetPedIntelligence()->GetQueriableInterface()->IsTaskCurrentlyRunning(iCommandType, true))
  2549. {
  2550. return true;
  2551. }
  2552. }
  2553. return false;
  2554. }
  2555.  
  2556. int CommandGetActiveVehicleMissionType(int iVehID)
  2557. {
  2558. const CVehicle *pVehicle = CTheScripts::GetEntityToQueryFromGUID<CVehicle>(iVehID);
  2559. if (pVehicle)
  2560. {
  2561. sVehicleMissionParams params;
  2562. s32 iTaskType = CTaskTypes::TASK_INVALID_ID;
  2563. pVehicle->GetIntelligence()->GetActiveTaskInfo(iTaskType, params);
  2564.  
  2565. return CVehicleIntelligence::GetMissionIdentifierFromTaskType(iTaskType, params);
  2566. }
  2567.  
  2568. return MISSION_NONE;
  2569. }
  2570.  
  2571. int CommandGetScriptTaskStatus( int iPedID, int iCommandType)
  2572. {
  2573. #if __ASSERT
  2574. scriptAssertf(CTheScripts::GetScriptTaskName(iCommandType), "%s GET_SCRIPT_TASK_STATUS: Unknown command type (%d)", CTheScripts::GetCurrentScriptNameAndProgramCounter(), iCommandType);
  2575. #endif // __ASSERT
  2576. const CPed *pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedID);
  2577. if (pPed)
  2578. {
  2579. int iTaskStatus=CPedScriptedTaskRecord::GetStatus(pPed,iCommandType);
  2580. if (iTaskStatus == -1)
  2581. {
  2582. iTaskStatus = CPedScriptedTaskRecordData::MAX_NUM_STAGES;
  2583. }
  2584. return iTaskStatus;
  2585. }
  2586. return (CPedScriptedTaskRecordData::MAX_NUM_STAGES);
  2587. }
  2588.  
  2589. void CommandTaskLeaveAnyVehicle( int iPedID, int iDelayTime, int iFlags)
  2590. {
  2591. VehicleEnterExitFlags vehicleFlags;
  2592. CTaskVehicleFSM::SetScriptedVehicleEntryExitFlags(vehicleFlags, iFlags);
  2593. if (!vehicleFlags.BitSet().IsSet(CVehicleEnterExitFlags::DontDefaultWarpIfDoorBlocked))
  2594. {
  2595. vehicleFlags.BitSet().Set(CVehicleEnterExitFlags::WarpIfDoorBlocked);
  2596. }
  2597. CTask* pTask=rage_new CTaskLeaveAnyCar(iDelayTime, vehicleFlags);
  2598. AI_LOG_WITH_ARGS("[Script] - Script %s has created CTaskLeaveAnyCar from SCRIPT_TASK_LEAVE_ANY_VEHICLE at 0x%p for ped with id %i\n", CTheScripts::GetCurrentScriptName(), pTask, iPedID);
  2599. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_LEAVE_ANY_VEHICLE, "TASK_LEAVE_ANY_VEHICLE");
  2600. }
  2601.  
  2602. void CommandTaskAimGunScripted(int iPedID, int iGunTaskType, bool bDisableBlockingClip, bool bInstantBlendToAim)
  2603. {
  2604. const CScriptedGunTaskInfo* pScriptedGunTaskInfo = CScriptedGunTaskMetadataMgr::GetScriptedGunTaskInfoByHash((u32)iGunTaskType);
  2605.  
  2606. if (scriptVerifyf(pScriptedGunTaskInfo, "TASK_AIM_GUN_SCRIPTED - scripted gun task info (%u) didn't exist, check metadata", iGunTaskType))
  2607. {
  2608. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  2609. if (pPed)
  2610. {
  2611. SCRIPT_ASSERT(pPed->IsLocalPlayer(), "TASK_AIM_GUN_SCRIPTED - Only supported on the player ped");
  2612. //Position the default target position ahead of the player
  2613. Vector3 targetPos = VEC3V_TO_VECTOR3(pPed->GetTransform().GetPosition()) + (VEC3V_TO_VECTOR3(pPed->GetTransform().GetForward()) * 3.0f);
  2614. CTaskGun* pGunTask = rage_new CTaskGun(CWeaponController::WCT_Player, CTaskTypes::TASK_AIM_GUN_SCRIPTED, CWeaponTarget(targetPos));
  2615.  
  2616. if( bDisableBlockingClip )
  2617. pGunTask->GetGunFlags().SetFlag(GF_DisableBlockingClip);
  2618.  
  2619. if( bInstantBlendToAim )
  2620. pGunTask->GetGunFlags().SetFlag(GF_InstantBlendToAim);
  2621.  
  2622. pGunTask->GetGunFlags().SetFlag(GF_ForceAimState);
  2623. pGunTask->GetGunFlags().SetFlag(GF_DisableTorsoIk);
  2624. pGunTask->SetScriptedGunTaskInfoHash(pScriptedGunTaskInfo->GetName().GetHash());
  2625. CScriptPeds::GivePedScriptedTask( iPedID, pGunTask, SCRIPT_TASK_AIM_GUN_SCRIPTED, "TASK_AIM_GUN_SCRIPTED");
  2626. }
  2627. }
  2628. }
  2629.  
  2630. void CommandTaskAimGunScriptedWithTarget(int iPedID, int iTargetPedID, const scrVector & scrVecTargetOrOffset, int iGunTaskType, bool bDisableBlockingClip, bool bForceAim)
  2631. {
  2632. const CScriptedGunTaskInfo* pScriptedGunTaskInfo = CScriptedGunTaskMetadataMgr::GetScriptedGunTaskInfoByHash((u32)iGunTaskType);
  2633.  
  2634. if (scriptVerifyf(pScriptedGunTaskInfo, "TASK_AIM_GUN_SCRIPTED_WITH_TARGET - scripted gun task info (%u) didn't exist, check metadata", iGunTaskType))
  2635. {
  2636. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  2637. if (pPed)
  2638. {
  2639. CTaskGun* pGunTask;
  2640. Vec3V vTargetOrOffset(scrVecTargetOrOffset);
  2641. const CPed* pTargetPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iTargetPedID, CTheScripts::GUID_ASSERT_FLAG_DEAD_CHECK);
  2642.  
  2643. CWeaponController::WeaponControllerType controllerType = CWeaponController::WCT_Fire;
  2644. if(bForceAim)
  2645. {
  2646. controllerType = CWeaponController::WCT_Aim;
  2647. }
  2648.  
  2649. if(pTargetPed)
  2650. {
  2651. pGunTask = rage_new CTaskGun(controllerType, CTaskTypes::TASK_AIM_GUN_SCRIPTED, CWeaponTarget(pTargetPed, VEC3V_TO_VECTOR3(vTargetOrOffset)));
  2652. }
  2653. else
  2654. {
  2655. pGunTask = rage_new CTaskGun(controllerType, CTaskTypes::TASK_AIM_GUN_SCRIPTED, CWeaponTarget(VEC3V_TO_VECTOR3(vTargetOrOffset)));
  2656. }
  2657.  
  2658. if(pPed->IsLocalPlayer())
  2659. {
  2660. pGunTask->SetFiringPatternHash(FIRING_PATTERN_FULL_AUTO);
  2661. }
  2662.  
  2663. if( bDisableBlockingClip )
  2664. pGunTask->GetGunFlags().SetFlag(GF_DisableBlockingClip);
  2665.  
  2666. pGunTask->GetGunFlags().SetFlag(GF_ForceAimState);
  2667. pGunTask->SetScriptedGunTaskInfoHash(pScriptedGunTaskInfo->GetName().GetHash());
  2668. CScriptPeds::GivePedScriptedTask( iPedID, pGunTask, SCRIPT_TASK_AIM_GUN_SCRIPTED, "TASK_AIM_GUN_SCRIPTED_WITH_TARGET");
  2669. }
  2670. }
  2671. }
  2672.  
  2673. void CommmandUpdateTaskAimGunScriptedTarget(int iPedID, int iTargetPedID, const scrVector & scrVecTargetOrOffset, bool bDisableBlockingClip)
  2674. {
  2675. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  2676. if (pPed)
  2677. {
  2678. CTaskAimGunScripted* pAimGunTask = static_cast<CTaskAimGunScripted*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_AIM_GUN_SCRIPTED));
  2679.  
  2680. if(SCRIPT_VERIFY(pAimGunTask, "UPDATE_TASK_AIM_GUN_SCRIPTED_TARGET - Ped must be running TASK_AIM_GUN_SCRIPTED"))
  2681. {
  2682. if( bDisableBlockingClip )
  2683. {
  2684. pAimGunTask->GetGunFlags().SetFlag(GF_DisableBlockingClip);
  2685. }
  2686.  
  2687. pAimGunTask->GetGunFlags().SetFlag(GF_ForceAimState);
  2688.  
  2689. //Update the target on the gun task
  2690. CTaskGun* pGunTask = static_cast<CTaskGun*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_GUN));
  2691. if(SCRIPT_VERIFY(pGunTask, "UPDATE_TASK_AIM_GUN_SCRIPTED_TARGET - Ped must be running CTaskGun"))
  2692. {
  2693. Vec3V vTargetOrOffset(scrVecTargetOrOffset);
  2694. const CPed* pTargetPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iTargetPedID, CTheScripts::GUID_ASSERT_FLAG_DEAD_CHECK);
  2695.  
  2696. if(pTargetPed)
  2697. {
  2698. pGunTask->SetTarget( CWeaponTarget(pTargetPed, VEC3V_TO_VECTOR3(vTargetOrOffset)));
  2699. }
  2700. else
  2701. {
  2702. pGunTask->SetTarget( CWeaponTarget(VEC3V_TO_VECTOR3(vTargetOrOffset)));
  2703. }
  2704. }
  2705. }
  2706. }
  2707. }
  2708.  
  2709. const char * CommandGetClipSetForScriptedGunTask(s32 iGunTaskType)
  2710. {
  2711. const CScriptedGunTaskInfo* pScriptedGunTaskInfo = CScriptedGunTaskMetadataMgr::GetScriptedGunTaskInfoByHash((u32)iGunTaskType);
  2712. if (scriptVerifyf(pScriptedGunTaskInfo, "GET_CLIP_SET_FOR_SCRIPTED_GUN_TASK - Scripted gun task info %u didn't exist, check metadata", (u32)iGunTaskType))
  2713. {
  2714. return pScriptedGunTaskInfo->GetClipSetName().GetCStr();
  2715. }
  2716.  
  2717. return NULL;
  2718. }
  2719.  
  2720. void CommandSetRopeTrackEntityForGunTask(int iPedID, int iEntityID)
  2721. {
  2722. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedID);
  2723. if(SCRIPT_VERIFY(pPed, "SET_ROPE_TRACK_ENTITY_FOR_SCRIPTED_GUN_TASK - Invalid ped"))
  2724. {
  2725. CEntity* pEntity = const_cast<CEntity*>(CTheScripts::GetEntityToQueryFromGUID<CEntity>(iEntityID));
  2726. if(SCRIPT_VERIFY(pEntity, "SET_ROPE_TRACK_ENTITY_FOR_SCRIPTED_GUN_TASK - Invalid entity"))
  2727. {
  2728. CTaskAimGunScripted* pAimTask = static_cast<CTaskAimGunScripted*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_AIM_GUN_SCRIPTED));
  2729.  
  2730. if(SCRIPT_VERIFY(pAimTask, "SET_ROPE_TRACK_ENTITY_FOR_SCRIPTED_GUN_TASK - Ped must be running TASK_AIM_GUN_SCRIPTED"))
  2731. {
  2732. pAimTask->SetRopeOrientationEntity(pEntity);
  2733. }
  2734. }
  2735. }
  2736. }
  2737.  
  2738. void CommandTaskAimGunAtEntity(int iPedID, int iEntityID, int iTime, bool bInstantBlendToAim )
  2739. {
  2740. if (SCRIPT_VERIFY((iTime == -1) || (iTime >= 0) ,"TASK_AIM_GUN_AT_ENTITY - Time must be -1 for infinite" ))
  2741. {
  2742. const CEntity *pEntity = CTheScripts::GetEntityToQueryFromGUID<CEntity>(iEntityID);
  2743. if (pEntity)
  2744. {
  2745. CTaskGun* pTaskGun = rage_new CTaskGun(CWeaponController::WCT_Aim, CTaskTypes::TASK_AIM_GUN_ON_FOOT, CWeaponTarget(pEntity), ((float) iTime) / 1000.0f);
  2746.  
  2747. if(iTime == -1)
  2748. {
  2749. pTaskGun->GetGunFlags().SetFlag(GF_InfiniteDuration);
  2750. }
  2751. else if (iTime == 0)
  2752. {
  2753. pTaskGun->GetGunFlags().SetFlag(GF_DisableAiming);
  2754. }
  2755.  
  2756. if(bInstantBlendToAim)
  2757. {
  2758. pTaskGun->GetGunFlags().SetFlag(GF_InstantBlendToAim);
  2759. }
  2760.  
  2761. CScriptPeds::GivePedScriptedTask( iPedID, pTaskGun, SCRIPT_TASK_AIM_GUN_AT_ENTITY, "TASK_AIM_GUN_AT_ENTITY");
  2762. }
  2763. }
  2764. }
  2765.  
  2766. void CommandTaskTurnPedToFaceEntity( int iPedID, int iEntityID, int iTime )
  2767. {
  2768. const CEntity* pEntity = CTheScripts::GetEntityToQueryFromGUID<CEntity>(iEntityID, CTheScripts::GUID_ASSERT_FLAGS_NO_DEAD_CHECK);
  2769. if (pEntity)
  2770. {
  2771. float fTime;
  2772. if(iTime < 0)
  2773. {
  2774. fTime = -1.0f;
  2775. }
  2776. else if(iTime == 0)
  2777. {
  2778. fTime = 0.0f;
  2779. }
  2780. else
  2781. {
  2782. fTime = ((float)iTime)/1000.0f;
  2783. }
  2784. CTask* pTask=rage_new CTaskTurnToFaceEntityOrCoord(pEntity, CTaskMoveAchieveHeading::ms_fHeadingChangeRateFrac, CTaskMoveAchieveHeading::ms_fHeadingTolerance, fTime);
  2785. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_TURN_PED_TO_FACE_ENTITY, "TASK_TURN_PED_TO_FACE_ENTITY");
  2786. }
  2787. }
  2788.  
  2789. void CommandTaskAimGunAtCoord( int iPedID, const scrVector & scrVecCoors, int iTime, bool bInstantBlendToAim, bool bPlayAimIntro )
  2790. {
  2791. if (SCRIPT_VERIFY((iTime == -1) || (iTime >= 0) ,"TASK_AIM_GUN_AT_COORD - Time must be -1 for infinite and >= 0" ))
  2792. {
  2793. Vector3 vecAimTarget(scrVecCoors);
  2794. CTaskGun* pTaskGun = rage_new CTaskGun(CWeaponController::WCT_Aim, CTaskTypes::TASK_AIM_GUN_ON_FOOT, CWeaponTarget(vecAimTarget), ((float) iTime) / 1000.0f);
  2795.  
  2796. if(iTime == -1)
  2797. {
  2798. pTaskGun->GetGunFlags().SetFlag(GF_InfiniteDuration);
  2799. }
  2800. else if(iTime == 0)
  2801. {
  2802. pTaskGun->GetGunFlags().SetFlag(GF_DisableAiming);
  2803. }
  2804.  
  2805. if(bInstantBlendToAim)
  2806. {
  2807. pTaskGun->GetGunFlags().SetFlag(GF_InstantBlendToAim);
  2808. }
  2809.  
  2810. if(bPlayAimIntro)
  2811. {
  2812. pTaskGun->SetPlayAimIntro(true);
  2813. }
  2814.  
  2815. CScriptPeds::GivePedScriptedTask(iPedID, pTaskGun, SCRIPT_TASK_AIM_GUN_AT_COORD, "TASK_AIM_GUN_AT_COORD");
  2816. }
  2817. }
  2818.  
  2819. void CommandTaskShootAtCoord( int iPedID, const scrVector & scrVecCoors, int iTime, int iFiringPatternHash )
  2820. {
  2821. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0) ,"TASK_SHOOT_GUN_AT_COORD - Time must be -1 for infinite and > 0" ))
  2822. {
  2823. Vector3 TempCoors( scrVecCoors);
  2824. CTask* pTask = NULL;
  2825.  
  2826. if(iPedID != NULL_IN_SCRIPTING_LANGUAGE)
  2827. {
  2828. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  2829. if (pPed)
  2830. {
  2831. if(scriptVerifyf(pPed->GetWeaponManager(), "%s:TASK_SHOOT_GUN_AT_COORD - ped requires a weapon manager", CTheScripts::GetCurrentScriptNameAndProgramCounter()))
  2832. {
  2833. const CWeaponInfo* pWeaponInfo = CWeaponInfoManager::GetInfo<CWeaponInfo>(pPed->GetWeaponManager()->GetEquippedWeaponHash());
  2834.  
  2835. if(scriptVerifyf(pWeaponInfo, "%s:TASK_SHOOT_GUN_AT_COORD - pWeaponInfo NULL - ped has no equiped weapon info", CTheScripts::GetCurrentScriptNameAndProgramCounter())
  2836. && pWeaponInfo->GetIsThrownWeapon())
  2837. {
  2838. pTask = rage_new CTaskAimAndThrowProjectile( CWeaponTarget( TempCoors ) );
  2839. }
  2840. }
  2841. }
  2842. else
  2843. {
  2844. return;
  2845. }
  2846. }
  2847. if(pTask==NULL)
  2848. {
  2849. pTask = rage_new CTaskGun(CWeaponController::WCT_Fire, CTaskTypes::TASK_AIM_GUN_ON_FOOT, CWeaponTarget(TempCoors), ((float) iTime) / 1000.0f);
  2850.  
  2851. if(iFiringPatternHash)
  2852. {
  2853. static_cast<CTaskGun*>(pTask)->SetFiringPatternHash(iFiringPatternHash);
  2854. }
  2855.  
  2856. if(iTime == -1)
  2857. {
  2858. static_cast<CTaskGun*>(pTask)->GetGunFlags().SetFlag(GF_InfiniteDuration);
  2859. }
  2860.  
  2861. }
  2862. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_SHOOT_AT_COORD, "TASK_SHOOT_GUN_AT_COORD");
  2863. }
  2864. }
  2865.  
  2866. void CommandTaskShuffleToNextVehicleSeat( int iPedID, int iVehicleID, bool bUseAlternateShuffle)
  2867. {
  2868. CVehicle *pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  2869. CPed* pPed = NULL;
  2870. if(iPedID != NULL_IN_SCRIPTING_LANGUAGE)
  2871. {
  2872. pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  2873. if (pPed)
  2874. {
  2875. if (!SCRIPT_VERIFY(pPed->GetPedConfigFlag( CPED_CONFIG_FLAG_InVehicle ) && pPed->GetMyVehicle(), "Ped isn't in a vehicle, need to call IS_PED_IN_ANY_VEHICLE to verify ped is in one") ||
  2876. !SCRIPT_VERIFY(pPed->GetMyVehicle() == pVehicle, "Ped is not in the given vehicle - TASK_SHUFFLE_TO_NEXT_VEHICLE_SEAT"))
  2877. {
  2878. return;
  2879. }
  2880. }
  2881. }
  2882.  
  2883. if (pVehicle)
  2884. {
  2885. s32 iTargetSeatIndex = -1;
  2886. if (pPed && bUseAlternateShuffle && pVehicle->GetSeatManager() && pVehicle->GetVehicleModelInfo() && pVehicle->GetVehicleModelInfo()->GetModelSeatInfo())
  2887. {
  2888. const s32 iCurrentSeatIndex = pVehicle->GetSeatManager()->GetPedsSeatIndex(pPed);
  2889. const s32 iCurrentEntryPointIndex = pVehicle->GetVehicleModelInfo()->GetModelSeatInfo()->GetEntryPointIndexForSeat(iCurrentSeatIndex, pVehicle);
  2890. iTargetSeatIndex = pVehicle->GetVehicleModelInfo()->GetModelSeatInfo()->GetShuffleSeatForSeat(iCurrentEntryPointIndex, iCurrentSeatIndex, true);
  2891. }
  2892.  
  2893. CTask* pTask = rage_new CTaskInVehicleSeatShuffle(pVehicle,NULL, true, iTargetSeatIndex);
  2894. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_SHUFFLE_TO_NEXT_VEHICLE_SEAT, "TASK_SHUFFLE_TO_NEXT_VEHICLE_SEAT");
  2895. }
  2896. }
  2897.  
  2898. void CommandClearPedTasks(int iPedID)
  2899. {
  2900. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  2901. if (pPed)
  2902. {
  2903. if (SCRIPT_VERIFY(!pPed->IsInjured(), "Ped is injured, cannot clear all tasks!"))
  2904. {
  2905. if(pPed->IsNetworkClone())
  2906. {
  2907. bool bClearTasksImmediately = false;
  2908. CClearPedTasksEvent::Trigger(pPed, bClearTasksImmediately);
  2909. }
  2910. else
  2911. {
  2912. AI_LOG_WITH_ARGS_IF_SCRIPT_OR_PLAYER_PED(pPed, "[Script] - Ped %s has had tasks cleared by script %s\n", AILogging::GetDynamicEntityNameSafe(pPed), CTheScripts::GetCurrentScriptName());
  2913. pPed->GetPedIntelligence()->ClearTasks();
  2914. pPed->SetIsCrouching(false);
  2915. }
  2916. #if __DEV
  2917. // Record the task in the debug list
  2918. static char stringName[] = "CLEAR_PED_TASKS";
  2919. pPed->GetPedIntelligence()->AddScriptHistoryString(stringName, stringName, CTheScripts::GetCurrentScriptName(), CTheScripts::GetCurrentGtaScriptThread()->GetThreadPC());
  2920. #endif
  2921. }
  2922. }
  2923. }
  2924.  
  2925. void CommandClearPedScriptTaskIfRunningThreatResponseNonTempTask(int iPedID)
  2926. {
  2927. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  2928. if (pPed)
  2929. {
  2930. // If this ped is running a non temporary threat response task, clear their primary (script) task which is dormant
  2931. // [GTAV] B*1605087
  2932. CTask* pNonTempTask = pPed->GetPedIntelligence()->GetTaskAtPriority(PED_TASK_PRIORITY_EVENT_RESPONSE_NONTEMP);
  2933. if (pNonTempTask && pNonTempTask->GetTaskType() == CTaskTypes::TASK_THREAT_RESPONSE)
  2934. {
  2935. pPed->GetPedIntelligence()->ClearPrimaryTaskAtPriority(PED_TASK_PRIORITY_PRIMARY);
  2936. }
  2937. }
  2938. }
  2939.  
  2940. void CommandClearPedSecondaryTask(int iPedID)
  2941. {
  2942. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  2943. if (pPed)
  2944. {
  2945. pPed->GetPedIntelligence()->ClearTasks( false, true );
  2946. }
  2947. }
  2948.  
  2949. void CommandTaskEveryoneLeaveVehicle(int iVehicleID)
  2950. {
  2951. // this script command is not approved for use in network scripts
  2952. if (SCRIPT_VERIFY(!NetworkInterface::IsGameInProgress(), "%TASK_EVERYONE_LEAVE_VEHICLE - This script command is not allowed in network game scripts!"))
  2953. {
  2954. CVehicle *pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID);
  2955. if (SCRIPT_VERIFY(pVehicle, "TASK_EVERYONE_LEAVE_VEHICLE - Vehicle doesn't exist"))
  2956. {
  2957. for(int loop = 0;loop < pVehicle->GetSeatManager()->GetMaxSeats(); loop++)
  2958. {
  2959. CPed* pPedInSeat = pVehicle->GetSeatManager()->GetPedInSeat(loop);
  2960. if(pPedInSeat && !pPedInSeat->IsInjured() )
  2961. {
  2962. const int iDelay=(loop+1)*500+fwRandom::GetRandomNumberInRange(-100,100);
  2963. CTask* pTask=rage_new CTaskLeaveAnyCar(iDelay);
  2964. AI_LOG_WITH_ARGS("[Script] - Script %s has created CTaskLeaveAnyCar from SCRIPT_TASK_EVERYONE_LEAVE_VEHICLE at 0x%p for ped %s\n", CTheScripts::GetCurrentScriptName(), pTask, AILogging::GetDynamicEntityNameSafe(pPedInSeat));
  2965. const int iPedID=CTheScripts::GetGUIDFromEntity(*pPedInSeat);
  2966. CScriptPeds::GivePedScriptedTask( iPedID,pTask, SCRIPT_TASK_EVERYONE_LEAVE_VEHICLE, "TASK_EVERYONE_LEAVE_VEHICLE");
  2967. }
  2968. }
  2969. }
  2970. }
  2971. }
  2972.  
  2973. // Please keep this in sync with the enumeration in "commands_task.sch"
  2974. enum ESEEK_ENTITY_OFFSET_FLAGS
  2975. {
  2976. ESEEK_OFFSET_ORIENTATES_WITH_ENTITY = 0x01,
  2977. ESEEK_KEEP_TO_PAVEMENTS = 0x02
  2978. };
  2979.  
  2980. void CommandTaskGotoEntityOffset( int iPedID, int iEntityID, int iTime, float fSeekRadius, float fSeekAngleDeg, float fMoveBlendRatio, int iGotoEntityOffsetFlags )
  2981. {
  2982. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0), "TASK_GOTO_ENTITY_OFFSET - Time must be -1 for infinite and > 0" ))
  2983. {
  2984. const float fSeekAngle=( DtoR * fSeekAngleDeg);
  2985. const CEntity* pEntity = CTheScripts::GetEntityToQueryFromGUID<CEntity>(iEntityID);
  2986. if (pEntity)
  2987. {
  2988. if (NetworkInterface::IsGameInProgress() && (!pEntity->GetIsDynamic() || !((CDynamicEntity*)pEntity)->GetNetworkObject()))
  2989. {
  2990. scriptAssertf(0, "%s:TASK_GOTO_ENTITY_OFFSET; the entity must be networked or this ped will not be able to migrate properly", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  2991. }
  2992.  
  2993. CTask* pTask=rage_new TTaskMoveSeekEntityRadiusAngleOffset(pEntity,iTime);
  2994.  
  2995. CEntitySeekPosCalculatorRadiusAngleOffset seekPosCalculator(fSeekRadius,fSeekAngle);
  2996. ((TTaskMoveSeekEntityRadiusAngleOffset*)pTask)->SetEntitySeekPosCalculator(seekPosCalculator);
  2997. ((TTaskMoveSeekEntityRadiusAngleOffset*)pTask)->SetMoveBlendRatio(fMoveBlendRatio);
  2998.  
  2999. Assertf( (iGotoEntityOffsetFlags & ESEEK_OFFSET_ORIENTATES_WITH_ENTITY)==0, "Can't specify 'ESEEK_OFFSET_ORIENTATES_WITH_ENTITY' with TASK_GOTO_ENTITY_OFFSET, this task always orientates offset with target entity.");
  3000.  
  3001. if((iGotoEntityOffsetFlags & ESEEK_KEEP_TO_PAVEMENTS)!=0)
  3002. ((TTaskMoveSeekEntityRadiusAngleOffset*)pTask)->SetPreferPavements(true);
  3003.  
  3004. ((TTaskMoveSeekEntityRadiusAngleOffset*)pTask)->SetUseLargerSearchExtents(true);
  3005.  
  3006. CTaskComplexControlMovement* pSimpleControlMovement = rage_new CTaskComplexControlMovement(pTask);
  3007. CScriptPeds::GivePedScriptedTask( iPedID, pSimpleControlMovement, SCRIPT_TASK_GOTO_ENTITY_OFFSET, "TASK_GOTO_ENTITY_OFFSET");
  3008. }
  3009. }
  3010. }
  3011.  
  3012. void CommandTaskGotoEntityOffsetXY( int iPedID, int iEntityID, int iTime, float fTargetRadius, float fOffsetX, float fOffsetY, float fMoveBlendRatio, int iGotoEntityOffsetFlags )
  3013. {
  3014. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0), "TASK_GOTO_ENTITY_OFFSET_XY - Time must be -1 for infinite and > 0" ))
  3015. {
  3016. const CEntity* pEntity = CTheScripts::GetEntityToQueryFromGUID<CEntity>(iEntityID);
  3017. if (pEntity)
  3018. {
  3019. if (NetworkInterface::IsGameInProgress() && (!pEntity->GetIsDynamic() || !((CDynamicEntity*)pEntity)->GetNetworkObject()))
  3020. {
  3021. scriptAssertf(0, "%s:TASK_GOTO_ENTITY_OFFSET_XY; the entity must be networked or this ped will not be able to migrate properly", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3022. }
  3023.  
  3024. CTask * pTask;
  3025.  
  3026. if( (iGotoEntityOffsetFlags & ESEEK_OFFSET_ORIENTATES_WITH_ENTITY) != 0 )
  3027. {
  3028. pTask = rage_new TTaskMoveSeekEntityXYOffsetRotated(pEntity, iTime);
  3029. CEntitySeekPosCalculatorXYOffsetRotated seekPosCalculator( Vector3(fOffsetX, fOffsetY, 0.0f) );
  3030. ((TTaskMoveSeekEntityXYOffsetRotated*)pTask)->SetEntitySeekPosCalculator(seekPosCalculator);
  3031.  
  3032. ((TTaskMoveSeekEntityXYOffsetRotated*)pTask)->SetMoveBlendRatio(fMoveBlendRatio);
  3033. ((TTaskMoveSeekEntityXYOffsetRotated*)pTask)->SetTargetRadius(fTargetRadius);
  3034. if((iGotoEntityOffsetFlags & ESEEK_KEEP_TO_PAVEMENTS)!=0)
  3035. ((TTaskMoveSeekEntityXYOffsetRotated*)pTask)->SetPreferPavements(true);
  3036. ((TTaskMoveSeekEntityXYOffsetRotated*)pTask)->SetUseLargerSearchExtents(true);
  3037. }
  3038. else
  3039. {
  3040. pTask = rage_new TTaskMoveSeekEntityXYOffsetFixed(pEntity, iTime);
  3041. CEntitySeekPosCalculatorXYOffsetFixed seekPosCalculator( Vector3(fOffsetX, fOffsetY, 0.0f) );
  3042. ((TTaskMoveSeekEntityXYOffsetFixed*)pTask)->SetEntitySeekPosCalculator(seekPosCalculator);
  3043.  
  3044. ((TTaskMoveSeekEntityXYOffsetFixed*)pTask)->SetMoveBlendRatio(fMoveBlendRatio);
  3045. ((TTaskMoveSeekEntityXYOffsetFixed*)pTask)->SetTargetRadius(fTargetRadius);
  3046. if((iGotoEntityOffsetFlags & ESEEK_KEEP_TO_PAVEMENTS)!=0)
  3047. ((TTaskMoveSeekEntityXYOffsetFixed*)pTask)->SetPreferPavements(true);
  3048. ((TTaskMoveSeekEntityXYOffsetFixed*)pTask)->SetUseLargerSearchExtents(true);
  3049. }
  3050.  
  3051. CTaskComplexControlMovement* pSimpleControlMovement = rage_new CTaskComplexControlMovement(pTask);
  3052. CScriptPeds::GivePedScriptedTask( iPedID, pSimpleControlMovement, SCRIPT_TASK_GOTO_ENTITY_OFFSET, "TASK_GOTO_ENTITY_OFFSET_XY");
  3053. }
  3054. }
  3055. }
  3056.  
  3057. // Remember to update eScriptInvestigateFlags in commands_task.sch
  3058. enum eScriptInvestigateFlags
  3059. {
  3060. SIF_DONT_RETURN_TO_ORIGINAL_POSITION = 1,
  3061. };
  3062.  
  3063. void CommandTaskInvestigateCoords (int iPedID, const scrVector & vCoords, int timeToSpendAtSearchPointInMS, int investigateFlags)
  3064. {
  3065. Vector3 vInvestigationPosition(vCoords);
  3066.  
  3067. // As there's only one flag right now, I'm just passing in a bool to the constructor of CTaskInvestigate. [1/9/2013 mdawe]
  3068. const bool bReturnToPosition = !(investigateFlags & SIF_DONT_RETURN_TO_ORIGINAL_POSITION);
  3069. CTask* pTask = rage_new CTaskInvestigate(vInvestigationPosition, NULL, EVENT_SUSPICIOUS_ACTIVITY, timeToSpendAtSearchPointInMS, bReturnToPosition);
  3070. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_INVESTIGATE_COORDS, "TASK_INVESTIGATE");
  3071. }
  3072.  
  3073.  
  3074. // Remember to update the scripts if you change these flags
  3075. // eScriptLookAtFlags in commands_task.sch
  3076. // Please leave as numbers so its easy to compare with the flags in commands_task.sch
  3077. // i.e dont change 4 to (1<<2)
  3078. enum eScriptLookatFlags
  3079. {
  3080. SLF_SLOW_TURN_RATE = 1, // turn the head toward the target slowly
  3081. SLF_FAST_TURN_RATE = 2, // turn the head toward the target quickly
  3082. SLF_EXTEND_YAW_LIMIT = 4, // wide yaw head limits
  3083. SLF_EXTEND_PITCH_LIMIT = 8, // wide pitch head limit
  3084. SLF_WIDEST_YAW_LIMIT = 16, // widest yaw head limit
  3085. SLF_WIDEST_PITCH_LIMIT = 32, // widest pitch head limit
  3086. SLF_NARROW_YAW_LIMIT = 64, // narrow yaw head limits
  3087. SLF_NARROW_PITCH_LIMIT = 128, // narrow pitch head limit
  3088. SLF_NARROWEST_YAW_LIMIT = 256, // narrowest yaw head limit
  3089. SLF_NARROWEST_PITCH_LIMIT = 512, // narrowest pitch head limit
  3090. SLF_USE_TORSO = 1024, // use the torso aswell as the neck and head (currently disabled)
  3091. SLF_WHILE_NOT_IN_FOV = 2048, // keep tracking the target even if they are not in the hard coded FOV
  3092. SLF_USE_CAMERA_FOCUS = 4096, // use the camera as the target
  3093. SLF_USE_EYES_ONLY = 8192, // only track the target with the eyes
  3094. SLF_USE_LOOK_DIR = 16384, // use information in look dir DOF
  3095. SLF_FROM_SCRIPT = 32768, // internal use only
  3096. SLF_USE_REF_DIR_ABSOLUTE = 65536 // use absolute reference direction mode for solver
  3097. };
  3098.  
  3099. int ConvertScriptLookatFlags(int scriptFlags)
  3100. {
  3101. int lookatFlags = LF_FROM_SCRIPT;
  3102. scriptFlags & SLF_SLOW_TURN_RATE ? lookatFlags |= LF_SLOW_TURN_RATE : 0;
  3103. scriptFlags & SLF_FAST_TURN_RATE ? lookatFlags |= LF_FAST_TURN_RATE : 0;
  3104. scriptFlags & SLF_EXTEND_YAW_LIMIT ? lookatFlags |= LF_WIDEST_YAW_LIMIT : 0;
  3105. scriptFlags & SLF_EXTEND_PITCH_LIMIT ? lookatFlags |= LF_WIDEST_PITCH_LIMIT : 0;
  3106. scriptFlags & SLF_WIDEST_YAW_LIMIT ? lookatFlags |= LF_WIDEST_YAW_LIMIT : 0;
  3107. scriptFlags & SLF_WIDEST_PITCH_LIMIT ? lookatFlags |= LF_WIDEST_PITCH_LIMIT : 0;
  3108. scriptFlags & SLF_NARROW_YAW_LIMIT ? lookatFlags |= LF_NARROW_YAW_LIMIT : 0;
  3109. scriptFlags & SLF_NARROW_PITCH_LIMIT ? lookatFlags |= LF_NARROW_PITCH_LIMIT : 0;
  3110. scriptFlags & SLF_NARROWEST_YAW_LIMIT ? lookatFlags |= LF_NARROWEST_YAW_LIMIT : 0;
  3111. scriptFlags & SLF_NARROWEST_PITCH_LIMIT ? lookatFlags |= LF_NARROWEST_PITCH_LIMIT : 0;
  3112. scriptFlags & SLF_USE_TORSO ? lookatFlags |= LF_USE_TORSO : 0;
  3113. scriptFlags & SLF_WHILE_NOT_IN_FOV ? lookatFlags |= LF_WHILE_NOT_IN_FOV : 0;
  3114. scriptFlags & SLF_USE_CAMERA_FOCUS ? lookatFlags |= LF_USE_CAMERA_FOCUS : 0;
  3115. scriptFlags & SLF_USE_EYES_ONLY ? lookatFlags |= LF_USE_EYES_ONLY : 0;
  3116. scriptFlags & SLF_USE_LOOK_DIR ? lookatFlags |= LF_USE_LOOK_DIR : 0;
  3117. scriptFlags & SLF_USE_REF_DIR_ABSOLUTE ? lookatFlags |= LF_USE_REF_DIR_ABSOLUTE : 0;
  3118. return lookatFlags;
  3119. }
  3120.  
  3121. void CommandTaskLookAtCoord(int iPedID, const scrVector & scrVecCoors, int iTime, int flags, int priority)
  3122. {
  3123. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0), "TASK_LOOK_AT_COORD - Time must be -1 for infinite and > 0" ))
  3124. {
  3125. int lookatFlags = ConvertScriptLookatFlags(flags);
  3126.  
  3127. if(NULL_IN_SCRIPTING_LANGUAGE!=iPedID)
  3128. {
  3129. if (SCRIPT_VERIFY(-1==CTaskSequences::ms_iActiveSequence, "TASK_LOOK_AT_COORD - Sequence opened unexpectedly"))
  3130. {
  3131. CPed *pPed=CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  3132. if (pPed)
  3133. {
  3134. ikDebugf3("%u TASK_LOOK_AT_COORD(pPed %p %s, scrVecCoors %.3f,%.3f,%.3f, iTime %i, flags %i, priority %i) LookAt",
  3135. fwTimer::GetFrameCount(), pPed, pPed->GetModelName(), scrVecCoors.x, scrVecCoors.y, scrVecCoors.z, iTime, flags, priority);
  3136.  
  3137. // this script command is not approved for use in network scripts
  3138. Vector3 offset(scrVecCoors);
  3139. pPed->GetIkManager().LookAt(0, 0, iTime, BONETAG_INVALID, &offset, lookatFlags, 500, 500, (CIkManager::eLookAtPriority)priority);
  3140. }
  3141. else
  3142. {
  3143. ikDebugf3("%u TASK_LOOK_AT_COORD(iPedID %i, scrVecCoors %.3f,%.3f,%.3f, iTime %i, flags %i, priority %i) Could not find ped!\n%s",
  3144. fwTimer::GetFrameCount(), iPedID, scrVecCoors.x, scrVecCoors.y, scrVecCoors.z, iTime, flags, priority,
  3145. CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3146. }
  3147. }
  3148. else
  3149. {
  3150. ikDebugf3("%u TASK_LOOK_AT_COORD(iPedID %i, scrVecCoors %.3f,%.3f,%.3f, iTime %i, flags %i, priority %i) Sequence opened unexpectedly!\n%s",
  3151. fwTimer::GetFrameCount(), iPedID, scrVecCoors.x, scrVecCoors.y, scrVecCoors.z, iTime, flags, priority,
  3152. CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3153. }
  3154. }
  3155. else
  3156. {
  3157. Vector3 offset(scrVecCoors);
  3158.  
  3159. if (SCRIPT_VERIFY(CTaskSequences::ms_iActiveSequence >=0 && CTaskSequences::ms_iActiveSequence<CTaskSequences::MAX_NUM_SEQUENCE_TASKS, "TASK_LOOK_AT_COORD - Sequence task closed"))
  3160. {
  3161. if (SCRIPT_VERIFY(CTaskSequences::ms_bIsOpened[CTaskSequences::ms_iActiveSequence], "TASK_LOOK_AT_COORD - sequence task closed"))
  3162. {
  3163. ikDebugf3("%u TASK_LOOK_AT_COORD(iPedID %i, scrVecCoors %.3f,%.3f,%.3f, iTime %i, flags %i, priority %i) CTaskTriggerLookAt",
  3164. fwTimer::GetFrameCount(), iPedID, scrVecCoors.x, scrVecCoors.y, scrVecCoors.z, iTime, flags, priority);
  3165.  
  3166. CTask* pTask = rage_new CTaskTriggerLookAt(NULL, iTime, BONETAG_INVALID, offset, lookatFlags);
  3167. CTaskSequences::ms_TaskSequenceLists[CTaskSequences::ms_iActiveSequence].AddTask(pTask);
  3168. }
  3169. else
  3170. {
  3171. ikDebugf3("%u TASK_LOOK_AT_COORD(iPedID %i, scrVecCoors %.3f,%.3f,%.3f, iTime %i, flags %i, priority %i) Sequence task closed!\n%s",
  3172. fwTimer::GetFrameCount(), iPedID, scrVecCoors.x, scrVecCoors.y, scrVecCoors.z, iTime, flags, priority,
  3173. CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3174. }
  3175. }
  3176. else
  3177. {
  3178. ikDebugf3("%u TASK_LOOK_AT_COORD(iPedID %i, scrVecCoors %.3f,%.3f,%.3f, iTime %i, flags %i, priority %i) Sequence task closed!\n%s",
  3179. fwTimer::GetFrameCount(), iPedID, scrVecCoors.x, scrVecCoors.y, scrVecCoors.z, iTime, flags, priority,
  3180. CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3181. }
  3182. }
  3183. }
  3184. }
  3185.  
  3186. void CommandTaskLookAtEntity(int iPedID, int iEntityID, int iTime, int flags, int priority)
  3187. {
  3188. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0), "TASK_LOOK_AT_ENTITY - Time must be -1 for infinite and > 0" ))
  3189. {
  3190. int lookatFlags = ConvertScriptLookatFlags(flags);
  3191.  
  3192. const CEntity* pEntity = CTheScripts::GetEntityToQueryFromGUID<CEntity>(iEntityID, CTheScripts::GUID_ASSERT_FLAGS_NO_DEAD_CHECK);
  3193. if (pEntity)
  3194. {
  3195. eAnimBoneTag boneTag = BONETAG_INVALID;
  3196.  
  3197. // Use the head bone as the target (if possible)
  3198. if ( pEntity->GetIsTypePed() )
  3199. {
  3200. // Some animals e.g A_C_Stingray dont have a head fall back to the entity position
  3201. s32 boneIdx = -1;
  3202. if ( pEntity->GetSkeletonData().ConvertBoneIdToIndex((u16)BONETAG_HEAD, boneIdx) )
  3203. {
  3204. boneTag = BONETAG_HEAD;
  3205. }
  3206. }
  3207.  
  3208. if(NULL_IN_SCRIPTING_LANGUAGE!=iPedID)
  3209. {
  3210. if (SCRIPT_VERIFY(-1==CTaskSequences::ms_iActiveSequence, "TASK_LOOK_AT_ENTITY - Sequence opened unexpectedly"))
  3211. {
  3212. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID, CTheScripts::GUID_ASSERT_FLAGS_NO_DEAD_CHECK & CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  3213. if(pPed)
  3214. {
  3215. scriptAssertf(pPed != pEntity, "TASK_LOOK_AT_ENTITY - Target and source entities are the same (entityId = %d)", iPedID);
  3216. if(NetworkUtils::IsNetworkCloneOrMigrating(pPed))
  3217. {
  3218. if(SCRIPT_VERIFY(pEntity->GetIsDynamic(), "TASK_LOOK_AT_ENTITY - Entity for clone is not dynamic!"))
  3219. {
  3220. netObject* pNetObj = static_cast<const CDynamicEntity*>(pEntity)->GetNetworkObject();
  3221. if(SCRIPT_VERIFY(pNetObj, "TASK_LOOK_AT_ENTITY - Entity for clone is not networked!"))
  3222. {
  3223. ikDebugf3("%u TASK_LOOK_AT_ENTITY(pPed %p %s, pEntity %p %s, iTime %i, flags %i, priority %i) CSettingOfLookAtEntity",
  3224. fwTimer::GetFrameCount(), pPed, pPed->GetModelName(), pEntity, pEntity->GetModelName(), iTime, flags, priority);
  3225.  
  3226. CScriptEntityStateChangeEvent::CSettingOfLookAtEntity parameters(pNetObj, lookatFlags, iTime);
  3227. CScriptEntityStateChangeEvent::Trigger(pPed->GetNetworkObject(), parameters);
  3228. }
  3229. else
  3230. {
  3231. ikDebugf3("%u TASK_LOOK_AT_ENTITY(pPed %p %s, pEntity %p %s, iTime %i, flags %i, priority %i) Entity for clone is not networked!\n%s",
  3232. fwTimer::GetFrameCount(), pPed, pPed->GetModelName(), pEntity, pEntity->GetModelName(), iTime, flags, priority,
  3233. CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3234. }
  3235. }
  3236. else
  3237. {
  3238. ikDebugf3("%u TASK_LOOK_AT_ENTITY(pPed %p %s, pEntity %p %s, iTime %i, flags %i, priority %i) Entity for clone is not dynamic!\n%s",
  3239. fwTimer::GetFrameCount(), pPed, pPed->GetModelName(), pEntity, pEntity->GetModelName(), iTime, flags, priority,
  3240. CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3241. }
  3242. }
  3243. else
  3244. {
  3245. ikDebugf3("%u TASK_LOOK_AT_ENTITY(pPed %p %s, pEntity %p %s, iTime %i, flags %i, priority %i) LookAt",
  3246. fwTimer::GetFrameCount(), pPed, pPed->GetModelName(), pEntity, pEntity->GetModelName(), iTime, flags, priority);
  3247.  
  3248. pPed->GetIkManager().LookAt(0, pEntity, iTime, boneTag, NULL, lookatFlags, 500, 500, (CIkManager::eLookAtPriority)priority);
  3249. }
  3250. }
  3251. else
  3252. {
  3253. ikDebugf3("%u TASK_LOOK_AT_ENTITY(iPedID %i, pEntity %p %s, iTime %i, flags %i, priority %i) Entity for clone is not dynamic!\n%s",
  3254. fwTimer::GetFrameCount(), iPedID, pEntity, pEntity->GetModelName(), iTime, flags, priority,
  3255. CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3256. }
  3257. }
  3258. }
  3259. else
  3260. {
  3261. Vector3 offset(0,0,0);
  3262. if (SCRIPT_VERIFY(CTaskSequences::ms_iActiveSequence >=0 && CTaskSequences::ms_iActiveSequence<CTaskSequences::MAX_NUM_SEQUENCE_TASKS, "TASK_LOOK_AT_ENTITY - Sequence task closed"))
  3263. {
  3264. if (SCRIPT_VERIFY(CTaskSequences::ms_bIsOpened[CTaskSequences::ms_iActiveSequence], "TASK_LOOK_AT_ENTITY - sequence task closed"))
  3265. {
  3266. ikDebugf3("%u TASK_LOOK_AT_ENTITY(iPedID %i, pEntity %p %s, iTime %i, flags %i, priority %i) CTaskTriggerLookAt",
  3267. fwTimer::GetFrameCount(), iPedID, pEntity, pEntity->GetModelName(), iTime, flags, priority);
  3268.  
  3269. CTask* pTask = rage_new CTaskTriggerLookAt(pEntity, iTime, boneTag, offset, lookatFlags);
  3270. CTaskSequences::ms_TaskSequenceLists[CTaskSequences::ms_iActiveSequence].AddTask(pTask);
  3271. }
  3272. else
  3273. {
  3274. ikDebugf3("%u TASK_LOOK_AT_ENTITY(iPedID %i, pEntity %p %s, iTime %i, flags %i, priority %i) Sequence task closed!\n%s",
  3275. fwTimer::GetFrameCount(), iPedID, pEntity, pEntity->GetModelName(), iTime, flags, priority,
  3276. CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3277. }
  3278. }
  3279. else
  3280. {
  3281. ikDebugf3("%u TASK_LOOK_AT_ENTITY(iPedID %i, pEntity %p %s, iTime %i, flags %i, priority %i) Sequence task closed!\n%s",
  3282. fwTimer::GetFrameCount(), iPedID, pEntity, pEntity->GetModelName(), iTime, flags, priority,
  3283. CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3284. }
  3285. }
  3286. }
  3287. else
  3288. {
  3289. ikDebugf3("%u TASK_LOOK_AT_ENTITY(iPedID %i, iEntityID %i, iTime %i, flags %i, priority %i) Could not find entity!\n%s",
  3290. fwTimer::GetFrameCount(), iPedID, iEntityID, iTime, flags, priority,
  3291. CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3292. }
  3293. }
  3294. else
  3295. {
  3296. ikDebugf3("%u TASK_LOOK_AT_ENTITY(iPedID %i, iEntityID %i, iTime %i, flags %i, priority %i) Time must be -1 for infinite and > 0!\n%s",
  3297. fwTimer::GetFrameCount(), iPedID, iEntityID, iTime, flags, priority,
  3298. CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3299. }
  3300. }
  3301.  
  3302. void CommandClearLookAt(int iPedID)
  3303. {
  3304. if(NULL_IN_SCRIPTING_LANGUAGE!=iPedID)
  3305. {
  3306. if(SCRIPT_VERIFY(-1==CTaskSequences::ms_iActiveSequence, "TASK_CLEAR_LOOK_AT - Sequence opened unexpectedly"))
  3307. {
  3308. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  3309. if(pPed)
  3310. {
  3311. if(pPed->GetIkManager().IsLooking())
  3312. {
  3313. ikDebugf3("%u CLEAR_LOOK_AT(pPed %p %s) AbortLookAt(500)",
  3314. fwTimer::GetFrameCount(), pPed, pPed->GetModelName());
  3315.  
  3316. pPed->GetIkManager().AbortLookAt(500);
  3317. }
  3318. else
  3319. {
  3320. ikDebugf3("%u CLEAR_LOOK_AT(pPed %p %s) Ped is not looking!\n%s",
  3321. fwTimer::GetFrameCount(), pPed, pPed->GetModelName(),
  3322. CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3323. }
  3324. }
  3325. else
  3326. {
  3327. ikDebugf3("%u CLEAR_LOOK_AT(iPedID %i) Could not find ped!\n%s",
  3328. fwTimer::GetFrameCount(), iPedID,
  3329. CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3330. }
  3331. }
  3332. else
  3333. {
  3334. ikDebugf3("%u CLEAR_LOOK_AT(iPedID %i) Sequence opened unexpectedly!\n%s",
  3335. fwTimer::GetFrameCount(), iPedID,
  3336. CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3337. }
  3338. }
  3339. else
  3340. {
  3341. if(SCRIPT_VERIFY(CTaskSequences::ms_iActiveSequence >=0 && CTaskSequences::ms_iActiveSequence<CTaskSequences::MAX_NUM_SEQUENCE_TASKS, "CLEAR_LOOK_AT - Sequence task closed"))
  3342. {
  3343. if(SCRIPT_VERIFY(CTaskSequences::ms_bIsOpened[CTaskSequences::ms_iActiveSequence], "TASK_CLEAR_LOOK_AT - sequence task closed"))
  3344. {
  3345. ikDebugf3("%u CLEAR_LOOK_AT(iPedID %i) CTaskClearLookAt",
  3346. fwTimer::GetFrameCount(), iPedID);
  3347.  
  3348. CTask* pTask = rage_new CTaskClearLookAt();
  3349. CTaskSequences::ms_TaskSequenceLists[CTaskSequences::ms_iActiveSequence].AddTask(pTask);
  3350. }
  3351. else
  3352. {
  3353. ikDebugf3("%u CLEAR_LOOK_AT(iPedID %i) Sequence task closed!\n%s",
  3354. fwTimer::GetFrameCount(), iPedID,
  3355. CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3356. }
  3357. }
  3358. else
  3359. {
  3360. ikDebugf3("%u CLEAR_LOOK_AT(iPedID %i) Sequence task closed!\n%s",
  3361. fwTimer::GetFrameCount(), iPedID,
  3362. CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3363. }
  3364. }
  3365. }
  3366.  
  3367. static u32 giSearchModelIndex = fwModelId::MI_INVALID;
  3368. static CEntity* gpClosestEntity = NULL;
  3369. static float gfClosestDistSq = 0.0f;
  3370. static Vector3 gvSearchPos;
  3371.  
  3372. bool FindNearestEntityCB (CEntity* pEntity, void* UNUSED_PARAM(pData) )
  3373. {
  3374. C2dEffect* pSpawnPoint = pEntity->GetClosest2dEffect(ET_SPAWN_POINT, gvSearchPos);
  3375.  
  3376. if(!pSpawnPoint)
  3377. {
  3378. return true;
  3379. }
  3380.  
  3381. if( pEntity->GetModelIndex() == giSearchModelIndex ||
  3382. !CModelInfo::IsValidModelInfo(giSearchModelIndex))
  3383. {
  3384. float fDistSq = DistSquared(pEntity->GetTransform().GetPosition(), RCC_VEC3V(gvSearchPos)).Getf();
  3385.  
  3386. if(gpClosestEntity == NULL ||
  3387. gfClosestDistSq > fDistSq )
  3388. {
  3389. gpClosestEntity = pEntity;
  3390. gfClosestDistSq = fDistSq;
  3391. }
  3392. }
  3393. return true;
  3394. }
  3395.  
  3396. bool CommandIsPedInvestigatingWhistlingEvent( int iPedID )
  3397. {
  3398. const CPed *pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedID);
  3399. if(pPed)
  3400. {
  3401. CTaskInvestigate* pInvestigateTask = (CTaskInvestigate*) pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_INVESTIGATE);
  3402. if (pInvestigateTask && pInvestigateTask->IsInvestigatingWhistlingEvent())
  3403. {
  3404. return true;
  3405. }
  3406. }
  3407. return false;
  3408. }
  3409.  
  3410. void CommandSetInvestigationPosition( int iPedID, const scrVector & scrVecInvestigationPosition)
  3411. {
  3412. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  3413. if(pPed)
  3414. {
  3415. CTaskInvestigate* pInvestigateTask = (CTaskInvestigate*) pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_INVESTIGATE);
  3416. if (pInvestigateTask)
  3417. {
  3418. pInvestigateTask->SetInvestigationPos(scrVecInvestigationPosition);
  3419. }
  3420. }
  3421. }
  3422.  
  3423. void CommandTaskTurnPedToFaceCoord( int iPedID, const scrVector & scrVecCoors, int iTime )
  3424. {
  3425. float fTime;
  3426. if(iTime < 0)
  3427. {
  3428. fTime = -1.0f;
  3429. }
  3430. else if(iTime == 0)
  3431. {
  3432. fTime = 0.0f;
  3433. }
  3434. else
  3435. {
  3436. fTime = ((float)iTime)/1000.0f;
  3437. }
  3438. CTask* pTask = rage_new CTaskTurnToFaceEntityOrCoord(Vector3(scrVecCoors), CTaskMoveAchieveHeading::ms_fHeadingChangeRateFrac, CTaskMoveAchieveHeading::ms_fHeadingTolerance, fTime);
  3439. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_TURN_PED_TO_FACE_COORD, "TASK_TURN_PED_TO_FACE_COORD");
  3440. }
  3441.  
  3442. void CommandTaskDrivePointRoute( int iPedID, int iVehicleID, float fCruiseSpeed )
  3443. {
  3444. if(SCRIPT_VERIFY(CTaskMoveFollowPointRoute::ms_pointRoute.GetSize() > 0,"TASK_DRIVE_POINT_ROUTE: Point route didn't have any points in it."))
  3445. {
  3446. CTask* pTask;
  3447. CVehicle *pVehicle = NULL;
  3448. if(iVehicleID>=0)
  3449. {
  3450. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  3451. if(!pVehicle)
  3452. return;
  3453. }
  3454. pTask=rage_new CTaskDrivePointRoute(pVehicle,CTaskMoveFollowPointRoute::ms_pointRoute, fCruiseSpeed);
  3455. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_DRIVE_POINT_ROUTE, "TASK_DRIVE_POINT_ROUTE");
  3456. }
  3457. }
  3458.  
  3459. void GivePedGoToPointAimingTask(
  3460. int iPedID, const CAITarget& goToTarget, const CAITarget& aimAtTarget, float fMoveBlendRatio,
  3461. float TargetRadius, float SlowDistance, bool bShoot, bool bUseNavmesh, int iNavFlags, bool bInstantBlendToAim, int iFiringPatternHash,
  3462. int iScriptTaskType, const char* commandName, const int iTime )
  3463. {
  3464. #if __ASSERT
  3465. Vector3 vGoToPosition;
  3466. Vector3 vAimAtPosition;
  3467.  
  3468. if(goToTarget.GetPosition(vGoToPosition))
  3469. {
  3470. scriptAssertf(!vGoToPosition.IsClose(VEC3_ZERO, SMALL_FLOAT), "%s - Goto position is too close to the origin. %s", commandName, CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3471. }
  3472.  
  3473. if(aimAtTarget.GetPosition(vAimAtPosition))
  3474. {
  3475. scriptAssertf(!vAimAtPosition.IsClose(VEC3_ZERO, SMALL_FLOAT), "%s - Aim at position is too close to the origin. %s", commandName, CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3476. }
  3477. #endif
  3478.  
  3479. CTaskGoToPointAiming* pTask = rage_new CTaskGoToPointAiming(goToTarget, aimAtTarget, fMoveBlendRatio, bShoot, iTime);
  3480. pTask->SetTargetRadius(TargetRadius);
  3481. pTask->SetSlowDownDistance(SlowDistance);
  3482. pTask->SetUseNavmesh(bUseNavmesh);
  3483. pTask->SetScriptNavFlags(iNavFlags);
  3484. pTask->SetInstantBlendToAim(bInstantBlendToAim);
  3485.  
  3486. if(bShoot)
  3487. {
  3488. pTask->SetFiringPattern(iFiringPatternHash);
  3489. }
  3490.  
  3491. CScriptPeds::GivePedScriptedTask(iPedID, pTask, iScriptTaskType, commandName);
  3492. }
  3493.  
  3494. void CommandTaskGoToCoordWhileAimingAtCoord(
  3495. int iPedID, const scrVector & scrVecGoToCoord, const scrVector & scrVecAimAtCoord, float fMoveBlendRatio,
  3496. bool bShoot, float TargetRadius, float SlowDistance, bool bUseNavmesh, int iNavFlags, bool bInstantBlendToAim, int iFiringPatternHash )
  3497. {
  3498. GivePedGoToPointAimingTask(
  3499. iPedID, CAITarget(Vector3(scrVecGoToCoord)), CAITarget(Vector3(scrVecAimAtCoord)), fMoveBlendRatio,
  3500. TargetRadius, SlowDistance, bShoot, bUseNavmesh, iNavFlags, bInstantBlendToAim, iFiringPatternHash, SCRIPT_TASK_GO_TO_COORD_WHILE_AIMING_AT_COORD,
  3501. "TASK_GO_TO_COORD_WHILE_AIMING_AT_COORD", -1);
  3502. }
  3503.  
  3504. void CommandTaskGoToCoordWhileAimingAtEntity(
  3505. int iPedID, const scrVector & scrVecGoToCoord, int iAimAtEntityID, float fMoveBlendRatio,
  3506. bool bShoot, float TargetRadius, float SlowDistance, bool bUseNavmesh, int iNavFlags, bool bInstantBlendToAim, int iFiringPatternHash, const int iTime )
  3507. {
  3508. const CEntity* pAimAtEntity = CTheScripts::GetEntityToQueryFromGUID<CEntity>(iAimAtEntityID);
  3509. if(pAimAtEntity)
  3510. {
  3511. GivePedGoToPointAimingTask(
  3512. iPedID, CAITarget(Vector3(scrVecGoToCoord)), CAITarget(pAimAtEntity), fMoveBlendRatio,
  3513. TargetRadius, SlowDistance, bShoot, bUseNavmesh, iNavFlags, bInstantBlendToAim, iFiringPatternHash, SCRIPT_TASK_GO_TO_COORD_WHILE_AIMING_AT_ENTITY,
  3514. "TASK_GO_TO_COORD_WHILE_AIMING_AT_ENTITY", iTime);
  3515. }
  3516. }
  3517.  
  3518. void CommandTaskGoToCoordAndAimAtHatedEntitiesNearCoord(
  3519. int iPedID, const scrVector & scrVecGoToCoord, const scrVector & scrAimNearCoord, float fMoveBlendRatio,
  3520. bool bShoot, float TargetRadius, float SlowDistance, bool bUseNavmesh, int iNavFlags, int iTaskFlags, int iFiringPatternHash )
  3521. {
  3522. Vector3 vGoToPosition(scrVecGoToCoord);
  3523. scriptAssertf(!vGoToPosition.IsClose(VEC3_ZERO, SMALL_FLOAT), "TASK_GO_TO_COORD_AND_AIM_AT_HATED_ENTITIES_NEAR_COORD - Go to position is too close to the origin. %s", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3524.  
  3525. Vector3 vAimNearPosition(scrAimNearCoord);
  3526. scriptAssertf(!vAimNearPosition.IsClose(VEC3_ZERO, SMALL_FLOAT), "TASK_GO_TO_COORD_AND_AIM_AT_HATED_ENTITIES_NEAR_COORD - Aim near position is too close to the origin. %s", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  3527.  
  3528. CTaskGoToPointAiming* pTask = rage_new CTaskGoToPointAiming(CAITarget(vGoToPosition), CAITarget(vAimNearPosition), fMoveBlendRatio, bShoot);
  3529. pTask->SetTargetRadius(TargetRadius);
  3530. pTask->SetSlowDownDistance(SlowDistance);
  3531. pTask->SetUseNavmesh(bUseNavmesh);
  3532. pTask->SetAimAtHatedEntitiesNearAimCoord(true);
  3533. pTask->SetScriptNavFlags(iNavFlags);
  3534. pTask->SetConfigFlags(iTaskFlags);
  3535.  
  3536. if(bShoot)
  3537. {
  3538. pTask->SetFiringPattern(iFiringPatternHash);
  3539. }
  3540.  
  3541. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_GO_TO_COORD_AND_AIM_AT_HATED_ENTITIES_NEAR_COORD,
  3542. "TASK_GO_TO_COORD_AND_AIM_AT_HATED_ENTITIES_NEAR_COORD");
  3543. }
  3544.  
  3545. void CommandTaskGoToEntityWhileAimingAtCoord(
  3546. int iPedID, int iEntityID, const scrVector & scrVecAimAtCoord, float fMoveBlendRatio,
  3547. bool bShoot, float TargetRadius, float SlowDistance, bool bUseNavmesh, bool bInstantBlendToAim, int iFiringPatternHash )
  3548. {
  3549. const CEntity* pEntity = CTheScripts::GetEntityToQueryFromGUID<CEntity>(iEntityID);
  3550. if(pEntity)
  3551. {
  3552. GivePedGoToPointAimingTask(
  3553. iPedID, CAITarget(pEntity), CAITarget(Vector3(scrVecAimAtCoord)), fMoveBlendRatio,
  3554. TargetRadius, SlowDistance, bShoot, bUseNavmesh, 0, bInstantBlendToAim, iFiringPatternHash, SCRIPT_TASK_GO_TO_ENTITY_WHILE_AIMING_AT_COORD,
  3555. "TASK_GO_TO_ENTITY_WHILE_AIMING_AT_COORD", -1);
  3556. }
  3557. }
  3558.  
  3559. void CommandTaskGoToEntityWhileAimingAtEntity(
  3560. int iPedID, int iGoToEntityID, int iAimAtEntityID, float fMoveBlendRatio,
  3561. bool bShoot, float TargetRadius, float SlowDistance, bool bUseNavmesh, bool bInstantBlendToAim, int iFiringPatternHash )
  3562. {
  3563. const CEntity* pGoToEntity = CTheScripts::GetEntityToQueryFromGUID<CEntity>(iGoToEntityID);
  3564. const CEntity* pAimAtEntity = CTheScripts::GetEntityToQueryFromGUID<CEntity>(iAimAtEntityID);
  3565.  
  3566. if(pGoToEntity && pAimAtEntity)
  3567. {
  3568. GivePedGoToPointAimingTask(
  3569. iPedID, CAITarget(pGoToEntity), CAITarget(pAimAtEntity), fMoveBlendRatio,
  3570. TargetRadius, SlowDistance, bShoot, bUseNavmesh, 0, bInstantBlendToAim, iFiringPatternHash, SCRIPT_TASK_GO_TO_ENTITY_WHILE_AIMING_AT_ENTITY,
  3571. "TASK_GO_TO_ENTITY_WHILE_AIMING_AT_ENTITY", -1);
  3572. }
  3573. }
  3574.  
  3575. void CommandTaskVehicleTempAction( int iPedID, int iVehicleID, int iAction, int iTime )
  3576. {
  3577. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0) ,"TASK_VEHICLE_TEMP_ACTION - Time must be -1 for infinite and > 0" ))
  3578. {
  3579. CVehicle *pVehicle = 0;
  3580. CTask* pTask;
  3581. {
  3582. if(iVehicleID!=NULL_IN_SCRIPTING_LANGUAGE)
  3583. {
  3584. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  3585. if(!pVehicle)
  3586. return;
  3587. }
  3588.  
  3589. if(pVehicle)
  3590. {
  3591. if(iPedID!=NULL_IN_SCRIPTING_LANGUAGE)
  3592. {
  3593. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID, CTheScripts::GUID_ASSERT_FLAGS_NO_DEAD_CHECK & CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  3594. if(pPed && NetworkUtils::IsNetworkCloneOrMigrating(pPed))
  3595. {
  3596. netObject* pNetObj = pPed->GetNetworkObject();
  3597. if(pNetObj)
  3598. {
  3599. CScriptEntityStateChangeEvent::CSettingOfTaskVehicleTempAction parameters(pVehicle->GetNetworkObject(),iAction,iTime);
  3600. CScriptEntityStateChangeEvent::Trigger(pNetObj, parameters);
  3601. }
  3602. }
  3603. else
  3604. {
  3605. if (NetworkInterface::IsGameInProgress() && iPedID==NULL_IN_SCRIPTING_LANGUAGE)
  3606. {
  3607. scriptAssertf(0, "TASK_VEHICLE_TEMP_ACTION - temp actions cannot be added to a sequence in MP");
  3608. return;
  3609. }
  3610.  
  3611. pTask=rage_new CTaskCarSetTempAction(pVehicle,iAction,iTime);
  3612. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_VEHICLE_TEMP_ACTION, "TASK_VEHICLE_TEMP_ACTION");
  3613. }
  3614. }
  3615. }
  3616. }
  3617. }
  3618. }
  3619.  
  3620.  
  3621. void CommandTaskVehicleMission_Internal( int iPedID, int iVehicleID, int iTargetVehicleID,
  3622. int iMission, float fCruiseSpeed, int iDrivingStyle, float fTargetReached, float fStraightLineDistance, bool bAllowedToGoAgainstTraffic, Vector3* vTarget)
  3623. {
  3624. CVehicle *pVehicle=0;
  3625. if(NULL_IN_SCRIPTING_LANGUAGE!=iVehicleID)
  3626. {
  3627. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  3628. }
  3629.  
  3630. if(!SCRIPT_VERIFY(pVehicle, "TASK_VEHICLE_MISSION needs a valid vehicle!"))
  3631. return;
  3632.  
  3633. CVehicle *pTargetVehicle = NULL;
  3634. if (NULL_IN_SCRIPTING_LANGUAGE!=iTargetVehicleID)
  3635. {
  3636. pTargetVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iTargetVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  3637. if(!pTargetVehicle)
  3638. return;
  3639. }
  3640.  
  3641. if (fStraightLineDistance < 0.0f)
  3642. {
  3643. fStraightLineDistance = sVehicleMissionParams::DEFAULT_SWITCH_TO_STRAIGHT_LINE_DIST;
  3644. }
  3645. fStraightLineDistance = MIN(255.0f, fStraightLineDistance);
  3646.  
  3647. if (fTargetReached < 0.0f)
  3648. {
  3649. fTargetReached = sVehicleMissionParams::DEFAULT_TARGET_REACHED_DIST;
  3650. }
  3651.  
  3652. #if __ASSERT
  3653. if (iMission == MISSION_CRASH)
  3654. {
  3655. VehicleType vehicleType = pVehicle->GetVehicleType();
  3656. if (vehicleType != VEHICLE_TYPE_PLANE
  3657. && vehicleType != VEHICLE_TYPE_HELI
  3658. && vehicleType != VEHICLE_TYPE_BLIMP
  3659. && vehicleType != VEHICLE_TYPE_AUTOGYRO)
  3660. {
  3661. scriptErrorf("%s:%s Non PLANE, HELI, BLIMP or AUTOGYRO has been told to crash", CTheScripts::GetCurrentScriptNameAndProgramCounter(), "TASK_VEHICLE_MISSION");
  3662. }
  3663. }
  3664. #endif //__ASSERT
  3665.  
  3666. aiTask *pCarTask = CVehicleIntelligence::GetTaskFromMissionIdentifier(pVehicle, iMission, pTargetVehicle, vTarget, iDrivingStyle, fTargetReached, fStraightLineDistance, fCruiseSpeed, bAllowedToGoAgainstTraffic);
  3667.  
  3668. CTask* pTask = rage_new CTaskControlVehicle(pVehicle, pCarTask);
  3669. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_VEHICLE_MISSION, "TASK_VEHICLE_MISSION");
  3670. }
  3671.  
  3672.  
  3673.  
  3674. void CommandTaskVehicleMission( int iPedID, int iVehicleID, int iTargetVehicleID,
  3675. int iMission, float fCruiseSpeed, int iDrivingStyle, float fTargetReached, float fStraightLineDistance, bool bDriveAgainstTraffic)
  3676. {
  3677. CommandTaskVehicleMission_Internal(iPedID, iVehicleID, iTargetVehicleID, iMission, fCruiseSpeed, iDrivingStyle, fTargetReached, fStraightLineDistance, bDriveAgainstTraffic, NULL);
  3678. }
  3679.  
  3680.  
  3681. void CommandTaskVehicleMissionPedTarget_Internal( int iPedID, int iVehicleID, int iTargetPedID,
  3682. int iMission, float fCruiseSpeed, int iDrivingStyle, float fTargetReached, float fStraightLineDistance, bool bAllowedToGoAgainstTraffic)
  3683. {
  3684. CVehicle *pVehicle=0;
  3685. if(NULL_IN_SCRIPTING_LANGUAGE!=iVehicleID)
  3686. {
  3687. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  3688. if(!pVehicle)
  3689. return;
  3690. }
  3691.  
  3692. CPed *pTargetPed = NULL;
  3693. if (NULL_IN_SCRIPTING_LANGUAGE!=iTargetPedID)
  3694. {
  3695. pTargetPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iTargetPedID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  3696. if(!pTargetPed)
  3697. return;
  3698. }
  3699.  
  3700. if (fStraightLineDistance < 0.0f)
  3701. {
  3702. fStraightLineDistance = sVehicleMissionParams::DEFAULT_SWITCH_TO_STRAIGHT_LINE_DIST;
  3703. }
  3704. fStraightLineDistance = MIN(255.0f, fStraightLineDistance);
  3705.  
  3706. if (fTargetReached < 0.0f)
  3707. {
  3708. fTargetReached = sVehicleMissionParams::DEFAULT_TARGET_REACHED_DIST;
  3709. }
  3710.  
  3711. #if __ASSERT
  3712. if (iMission == MISSION_CRASH)
  3713. {
  3714. VehicleType vehicleType = pVehicle->GetVehicleType();
  3715. if (vehicleType != VEHICLE_TYPE_PLANE
  3716. && vehicleType != VEHICLE_TYPE_HELI
  3717. && vehicleType != VEHICLE_TYPE_BLIMP
  3718. && vehicleType != VEHICLE_TYPE_AUTOGYRO)
  3719. {
  3720. scriptErrorf("%s:%s Non PLANE, HELI, BLIMP or AUTOGYRO has been told to crash", CTheScripts::GetCurrentScriptNameAndProgramCounter(), "TASK_VEHICLE_MISSION_PED_TARGET");
  3721. }
  3722. }
  3723. #endif //__ASSERT
  3724.  
  3725. aiTask *pCarTask = CVehicleIntelligence::GetTaskFromMissionIdentifier(pVehicle, iMission, pTargetPed, NULL, iDrivingStyle, fTargetReached, fStraightLineDistance, fCruiseSpeed, bAllowedToGoAgainstTraffic);
  3726.  
  3727. CTask* pTask = rage_new CTaskControlVehicle(pVehicle, pCarTask);
  3728. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_VEHICLE_MISSION, "TASK_VEHICLE_MISSION_PED_TARGET");
  3729. }
  3730.  
  3731.  
  3732. void CommandTaskVehicleMissionPedTarget( int iPedID, int iVehicleID, int iTargetPedID,
  3733. int iMission, float fCruiseSpeed, int iDrivingStyle, float fTargetReached, float fStraightLineDistance, bool bDriveAgainstTraffic)
  3734. {
  3735. CommandTaskVehicleMissionPedTarget_Internal( iPedID, iVehicleID, iTargetPedID,
  3736. iMission, fCruiseSpeed, iDrivingStyle, fTargetReached, fStraightLineDistance, bDriveAgainstTraffic);
  3737. }
  3738.  
  3739. void CommandTaskVehicleMissionCoorsTarget( int iPedID, int iVehicleID, const scrVector & scrVecCoors,
  3740. int iMission, float fCruiseSpeed, int iDrivingStyle, float fTargetReached, float fStraightLineDistance, bool bDriveAgainstTraffic)
  3741. {
  3742. Vector3 VecCoors = Vector3 (scrVecCoors);
  3743.  
  3744. CommandTaskVehicleMission_Internal( iPedID, iVehicleID, NULL_IN_SCRIPTING_LANGUAGE,
  3745. iMission, fCruiseSpeed, iDrivingStyle, fTargetReached, fStraightLineDistance, bDriveAgainstTraffic, &VecCoors);
  3746. }
  3747.  
  3748. void AddVehicleSubtaskInternal(int iPedID, CTask* pSubTask, const char* ASSERT_ONLY(szTaskName))
  3749. {
  3750. if(NULL_IN_SCRIPTING_LANGUAGE!=iPedID)
  3751. {
  3752. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  3753. if( !pPed )
  3754. {
  3755. delete pSubTask;
  3756. return;
  3757. }
  3758.  
  3759. CEventScriptCommand* pEvent = static_cast<CEventScriptCommand*>(pPed->GetPedIntelligence()->GetEventOfType(EVENT_SCRIPT_COMMAND));
  3760. if( !scriptVerifyf(pEvent, "%s:%s - You must have previously given the ped a valid driving task!", CTheScripts::GetCurrentScriptNameAndProgramCounter(), szTaskName) )
  3761. {
  3762. delete pSubTask;
  3763. return;
  3764. }
  3765.  
  3766. aiTask* pTask = pEvent->GetTask();
  3767.  
  3768. if( !scriptVerifyf(pTask && (pTask->GetTaskType() == CTaskTypes::TASK_CONTROL_VEHICLE || pTask->GetTaskType() == CTaskTypes::TASK_CAR_DRIVE_POINT_ROUTE), "%s:%s - You must have previously given the ped a valid driving task!", CTheScripts::GetCurrentScriptNameAndProgramCounter(), szTaskName) )
  3769. {
  3770. delete pSubTask;
  3771. return;
  3772. }
  3773. if( pTask->GetTaskType() == CTaskTypes::TASK_CONTROL_VEHICLE )
  3774. {
  3775. CTaskControlVehicle* pVehicleTask = static_cast<CTaskControlVehicle*>(pTask);
  3776. pVehicleTask->SetDesiredSubtask(pSubTask);
  3777. }
  3778. else if( pTask->GetTaskType() == CTaskTypes::TASK_CAR_DRIVE_POINT_ROUTE )
  3779. {
  3780. CTaskDrivePointRoute* pVehicleTask = static_cast<CTaskDrivePointRoute*>(pTask);
  3781. pVehicleTask->SetDesiredSubtask(pSubTask);
  3782. }
  3783. else
  3784. {
  3785. #if __ASSERT
  3786. scriptErrorf( "%s:%s unknown task type", CTheScripts::GetCurrentScriptNameAndProgramCounter(), szTaskName);
  3787. #endif
  3788. delete pSubTask;
  3789. return;
  3790. }
  3791.  
  3792. }
  3793. // Add task to last sequence thats open
  3794. else
  3795. {
  3796. if( !scriptVerifyf(CTaskSequences::ms_iActiveSequence >=0 && CTaskSequences::ms_iActiveSequence<CTaskSequences::MAX_NUM_SEQUENCE_TASKS, "%s:%s Sequence task closed", CTheScripts::GetCurrentScriptNameAndProgramCounter(), szTaskName))
  3797. {
  3798. delete pSubTask;
  3799. return;
  3800. }
  3801. // Add task to sequence
  3802. if( !scriptVerifyf(CTaskSequences::ms_bIsOpened[CTaskSequences::ms_iActiveSequence], "%s:%s Sequence task closed", CTheScripts::GetCurrentScriptNameAndProgramCounter(), szTaskName) )
  3803. {
  3804. delete pSubTask;
  3805. return;
  3806. }
  3807.  
  3808. aiTask* pTask = CTaskSequences::ms_TaskSequenceLists[CTaskSequences::ms_iActiveSequence].GetLastAddedTask();
  3809. if( scriptVerifyf(pTask && (pTask->GetTaskType() == CTaskTypes::TASK_CONTROL_VEHICLE || pTask->GetTaskType() == CTaskTypes::TASK_CAR_DRIVE_POINT_ROUTE), "%s:%s Last task added to sequence not a valid driving task", CTheScripts::GetCurrentScriptNameAndProgramCounter(), szTaskName ) )
  3810. {
  3811. if( pTask->GetTaskType() == CTaskTypes::TASK_CONTROL_VEHICLE )
  3812. {
  3813. CTaskControlVehicle* pVehicleTask = static_cast<CTaskControlVehicle*>(pTask);
  3814. pVehicleTask->SetDesiredSubtask(pSubTask);
  3815. }
  3816. else if( pTask->GetTaskType() == CTaskTypes::TASK_CAR_DRIVE_POINT_ROUTE )
  3817. {
  3818. CTaskDrivePointRoute* pVehicleTask = static_cast<CTaskDrivePointRoute*>(pTask);
  3819. pVehicleTask->SetDesiredSubtask(pSubTask);
  3820. }
  3821. else
  3822. {
  3823. #if __ASSERT
  3824. scriptErrorf( "%s:%s unknown task type", CTheScripts::GetCurrentScriptNameAndProgramCounter(), szTaskName);
  3825. #endif
  3826. delete pSubTask;
  3827. return;
  3828. }
  3829. }
  3830. else
  3831. {
  3832. delete pSubTask;
  3833. }
  3834. }
  3835. }
  3836.  
  3837. void CommandAddVehicleSubtaskAttackCoord( int iPedID, const scrVector & scrVecCoors )
  3838. {
  3839. Vector3 vTarget(scrVecCoors);
  3840. CAITarget target(vTarget);
  3841. AddVehicleSubtaskInternal(iPedID, rage_new CTaskVehicleCombat(&target), "ADD_VEHICLE_SUBTASK_ATTACK_COORD");
  3842. }
  3843.  
  3844. void CommandAddVehicleSubtaskAttackPed( int iPedID, int iOtherPedID )
  3845. {
  3846. CPed* pOtherPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iOtherPedID);
  3847. if( !pOtherPed )
  3848. {
  3849. return;
  3850. }
  3851. CAITarget target(pOtherPed);
  3852. AddVehicleSubtaskInternal(iPedID, rage_new CTaskVehicleCombat(&target), "ADD_VEHICLE_SUBTASK_ATTACK_PED");
  3853. }
  3854.  
  3855.  
  3856. void CommandTaskHeliMission( int iPedID, int iVehicleID, int iTargetVehicleID, int iTargetPedID, const scrVector & scrVecCoors,
  3857. int iMission, float fCruiseSpeed, float fTargetReached, float fHeliOrientation, int iFlightHeight, int iMinHeightAboveTerrain, float fSlowDownDistance, int iHeliFlags)
  3858. {
  3859. CVehicle *pVehicle=0;
  3860. Vector3 VecTargetCoors = Vector3 (scrVecCoors);
  3861.  
  3862. if(SCRIPT_VERIFY(NULL_IN_SCRIPTING_LANGUAGE!=iVehicleID, "TASK_HELI_MISSION - You must specify a heli to be flown"))
  3863. {
  3864. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  3865. if(!pVehicle)
  3866. return;
  3867.  
  3868. if(!SCRIPT_VERIFY(pVehicle->GetVehicleType() == VEHICLE_TYPE_HELI, "TASK_HELI_MISSION - Vehicle to be used (2nd parameter) is not actually a heli"))
  3869. return;
  3870. }
  3871. else
  3872. {
  3873. return;
  3874. }
  3875.  
  3876. CPhysical* pPhysical = NULL;
  3877. const CVehicle *pTargetVehicle = NULL;
  3878. if (NULL_IN_SCRIPTING_LANGUAGE!=iTargetVehicleID)
  3879. {
  3880. pTargetVehicle = CTheScripts::GetEntityToQueryFromGUID<CVehicle>(iTargetVehicleID);
  3881. if(!pTargetVehicle)
  3882. return;
  3883.  
  3884. pPhysical = const_cast<CVehicle*>(pTargetVehicle);
  3885. }
  3886. const CPed *pTargetPed = NULL;
  3887. if (NULL_IN_SCRIPTING_LANGUAGE!=iTargetPedID)
  3888. {
  3889. pTargetPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iTargetPedID);
  3890. if(!pTargetPed)
  3891. return;
  3892.  
  3893. pPhysical = const_cast<CPed*>(pTargetPed);
  3894. }
  3895.  
  3896. if (fTargetReached < 0.0f)
  3897. {
  3898. fTargetReached = sVehicleMissionParams::DEFAULT_TARGET_REACHED_DIST;
  3899. }
  3900.  
  3901. if (fHeliOrientation < 0.0f)
  3902. {
  3903. fHeliOrientation = -1.0f;
  3904. }
  3905. else
  3906. {
  3907. fHeliOrientation = ( DtoR * fHeliOrientation);
  3908.  
  3909. // For whatever reason the helicopter AI treats the X axis as 0, so we have to rotate a Y axis heading request by 90
  3910. fHeliOrientation += 90.0f*DtoR;
  3911. }
  3912.  
  3913. aiTask *pHeliTask = CVehicleIntelligence::GetHeliTaskFromMissionIdentifier(pVehicle, iMission, pPhysical, &VecTargetCoors, fTargetReached, fCruiseSpeed, fHeliOrientation, iFlightHeight, iMinHeightAboveTerrain, fSlowDownDistance, iHeliFlags);
  3914.  
  3915. CTask* pTask = rage_new CTaskControlVehicle(pVehicle, pHeliTask);
  3916. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_VEHICLE_MISSION, "TASK_HELI_MISSION");
  3917. }
  3918.  
  3919. void CommandTaskHeliEscort( int iPedID, int iVehicleID, int iTargetVehicleID, const scrVector & offsetVec)
  3920. {
  3921. CVehicle *pVehicle=0;
  3922. CVehicle *pTargetVehicle=0;
  3923.  
  3924. if(SCRIPT_VERIFY(NULL_IN_SCRIPTING_LANGUAGE!=iVehicleID, "TASK_HELI_ESCORT_HELI - You must specify a heli to be flown"))
  3925. {
  3926. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  3927. if(!pVehicle)
  3928. return;
  3929.  
  3930. if(!SCRIPT_VERIFY(pVehicle->GetVehicleType() == VEHICLE_TYPE_HELI, "TASK_HELI_ESCORT_HELI - Vehicle to be used (2nd parameter) is not actually a heli"))
  3931. return;
  3932. }
  3933. else
  3934. {
  3935. return;
  3936. }
  3937.  
  3938. if(SCRIPT_VERIFY(NULL_IN_SCRIPTING_LANGUAGE!=iTargetVehicleID, "TASK_HELI_ESCORT_HELI - You must specify a heli to be targetted"))
  3939. {
  3940. pTargetVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iTargetVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  3941. if(!pTargetVehicle)
  3942. return;
  3943.  
  3944. if(!SCRIPT_VERIFY(pTargetVehicle->GetVehicleType() == VEHICLE_TYPE_HELI, "TASK_HELI_ESCORT_HELI - Vehicle to be targetted (2nd parameter) is not actually a heli"))
  3945. return;
  3946. }
  3947. else
  3948. {
  3949. return;
  3950. }
  3951.  
  3952. Vector3 vOffset(offsetVec);
  3953.  
  3954. sVehicleMissionParams params;
  3955. params.SetTargetEntity(pTargetVehicle);
  3956. params.SetTargetPosition(vOffset);
  3957.  
  3958. CTaskVehicleEscort *pHeliTask = rage_new CTaskVehicleEscort(params, CTaskVehicleEscort::VEHICLE_ESCORT_HELI);
  3959.  
  3960. CTask* pTask = rage_new CTaskControlVehicle(pVehicle, pHeliTask);
  3961. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_VEHICLE_MISSION, "TASK_HELI_ESCORT_HELI");
  3962. }
  3963.  
  3964. void CommandTaskPlaneMission( int iPedID, int iVehicleID, int iTargetVehicleID, int iTargetPedID, const scrVector & scrVecCoors,
  3965. int iMission, float fCruiseSpeed, float fTargetReached, float fOrientation, int iFlightHeight, int iMinHeightAboveTerrain, bool bPrecise)
  3966. {
  3967. CVehicle *pVehicle=0;
  3968. Vector3 VecTargetCoors = Vector3 (scrVecCoors);
  3969.  
  3970. if(SCRIPT_VERIFY(NULL_IN_SCRIPTING_LANGUAGE!=iVehicleID, "TASK_PLANE_MISSION - You must specify a plane to be flown"))
  3971. {
  3972. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  3973. if(!pVehicle)
  3974. return;
  3975.  
  3976. if(!SCRIPT_VERIFY(pVehicle->GetVehicleType() == VEHICLE_TYPE_PLANE, "TASK_PLANE_MISSION - Vehicle to be used (2nd parameter) is not actually a plane"))
  3977. return;
  3978. }
  3979. else
  3980. {
  3981. return;
  3982. }
  3983.  
  3984. CPhysical* pPhysical = NULL;
  3985. const CVehicle *pTargetVehicle = NULL;
  3986. if (NULL_IN_SCRIPTING_LANGUAGE!=iTargetVehicleID)
  3987. {
  3988. pTargetVehicle = CTheScripts::GetEntityToQueryFromGUID<CVehicle>(iTargetVehicleID);
  3989. if(!pTargetVehicle)
  3990. return;
  3991.  
  3992. pPhysical = const_cast<CVehicle*>(pTargetVehicle);
  3993. }
  3994. const CPed *pTargetPed = NULL;
  3995. if (NULL_IN_SCRIPTING_LANGUAGE!=iTargetPedID)
  3996. {
  3997. pTargetPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iTargetPedID);
  3998. if(!pTargetPed)
  3999. return;
  4000.  
  4001. pPhysical = const_cast<CPed*>(pTargetPed);
  4002. }
  4003.  
  4004. if (fTargetReached < 0.0f)
  4005. {
  4006. fTargetReached = sVehicleMissionParams::DEFAULT_TARGET_REACHED_DIST;
  4007. }
  4008.  
  4009. if (fOrientation < 0.0f)
  4010. {
  4011. fOrientation = -1.0f;
  4012. }
  4013. else
  4014. {
  4015. fOrientation = ( DtoR * fOrientation);
  4016. // For whatever reason the helicopter AI treats the X axis as 0, so we have to rotate a Y axis heading request by 90
  4017. fOrientation += 90.0f*DtoR;
  4018. }
  4019.  
  4020. aiTask *pPlaneTask = CVehicleIntelligence::GetPlaneTaskFromMissionIdentifier(pVehicle, iMission, pPhysical, &VecTargetCoors, fTargetReached, fCruiseSpeed, fOrientation, iFlightHeight, iMinHeightAboveTerrain, bPrecise);
  4021. if( pPlaneTask )
  4022. {
  4023. CTask* pTask = rage_new CTaskControlVehicle(pVehicle, pPlaneTask);
  4024. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_VEHICLE_MISSION, "TASK_PLANE_MISSION");
  4025. }
  4026. }
  4027.  
  4028. void CommandTaskPlaneTaxi(int iPedID, int iVehicleID, const scrVector& scrVecCoors, float fCruiseSpeed, float fTargetReached)
  4029. {
  4030. CVehicle *pVehicle=0;
  4031. Vector3 VecTargetCoors = Vector3 (scrVecCoors);
  4032.  
  4033. if(SCRIPT_VERIFY(NULL_IN_SCRIPTING_LANGUAGE!=iVehicleID, "TASK_PLANE_TAXI - You must specify a plane to taxi"))
  4034. {
  4035. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  4036. if(!pVehicle)
  4037. return;
  4038.  
  4039. if(!SCRIPT_VERIFY(pVehicle->GetVehicleType() == VEHICLE_TYPE_PLANE, "TASK_PLANE_TAXI - Vehicle to be used (2nd parameter) is not actually a plane"))
  4040. return;
  4041. }
  4042. else
  4043. {
  4044. return;
  4045. }
  4046.  
  4047. if (fTargetReached < 0.0f)
  4048. {
  4049. fTargetReached = sVehicleMissionParams::DEFAULT_TARGET_REACHED_DIST;
  4050. }
  4051.  
  4052. sVehicleMissionParams params;
  4053. params.SetTargetPosition(VecTargetCoors);
  4054. params.m_fTargetArriveDist = fTargetReached;
  4055. params.m_fCruiseSpeed = fCruiseSpeed;
  4056.  
  4057. aiTask* pGotoTask = rage_new CTaskVehicleGoToPointAutomobile(params);
  4058.  
  4059. if( pGotoTask )
  4060. {
  4061. CTask* pTask = rage_new CTaskControlVehicle(pVehicle, pGotoTask);
  4062. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_VEHICLE_MISSION, "TASK_PLANE_TAXI");
  4063. }
  4064. }
  4065.  
  4066. void CommandTaskBoatMission( int iPedID, int iVehicleID, int iTargetVehicleID, int iTargetPedID, const scrVector & scrVecCoors,
  4067. int iMission, float fCruiseSpeed, int iDrivingStyle, float fTargetReached, int iBoatFlags)
  4068. {
  4069. CVehicle *pVehicle=0;
  4070. Vector3 VecTargetCoors = Vector3 (scrVecCoors);
  4071.  
  4072. if(SCRIPT_VERIFY(NULL_IN_SCRIPTING_LANGUAGE!=iVehicleID, "TASK_BOAT_MISSION - You must specify a boat"))
  4073. {
  4074. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  4075. if(!pVehicle)
  4076. return;
  4077.  
  4078. if(!SCRIPT_VERIFY(pVehicle->GetVehicleType() == VEHICLE_TYPE_BOAT, "TASK_BOAT_MISSION - Vehicle to be used (2nd parameter) is not actually a boat"))
  4079. return;
  4080. }
  4081. else
  4082. {
  4083. return;
  4084. }
  4085.  
  4086. CPhysical* pPhysical = NULL;
  4087. const CVehicle *pTargetVehicle = NULL;
  4088. if (NULL_IN_SCRIPTING_LANGUAGE!=iTargetVehicleID)
  4089. {
  4090. pTargetVehicle = CTheScripts::GetEntityToQueryFromGUID<CVehicle>(iTargetVehicleID);
  4091. if(!pTargetVehicle)
  4092. return;
  4093.  
  4094. pPhysical = const_cast<CVehicle*>(pTargetVehicle);
  4095. }
  4096. const CPed *pTargetPed = NULL;
  4097. if (NULL_IN_SCRIPTING_LANGUAGE!=iTargetPedID)
  4098. {
  4099. pTargetPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iTargetPedID);
  4100. if(!pTargetPed)
  4101. return;
  4102.  
  4103. pPhysical = const_cast<CPed*>(pTargetPed);
  4104. }
  4105.  
  4106. if (fTargetReached < 0.0f)
  4107. {
  4108. fTargetReached = sVehicleMissionParams::DEFAULT_TARGET_REACHED_DIST;
  4109. }
  4110.  
  4111. aiTask *pBoatTask = CVehicleIntelligence::GetBoatTaskFromMissionIdentifier(pVehicle, iMission, pPhysical, &VecTargetCoors, iDrivingStyle, fTargetReached, fCruiseSpeed, iBoatFlags);
  4112. if( pBoatTask )
  4113. {
  4114. CTask* pTask = rage_new CTaskControlVehicle(pVehicle, pBoatTask);
  4115. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_VEHICLE_MISSION, "TASK_BOAT_MISSION");
  4116. }
  4117. }
  4118.  
  4119.  
  4120. void CommandTaskVehiclePark( int iPedID, int iVehicleID, const scrVector & vecMoveTarget, float HeadingDegrees, int ParkType, float ToleranceDegrees, bool bKeepLightsOn)
  4121. {
  4122. CVehicle* pVehicle = NULL;
  4123. Vector3 VecTargetCoors = Vector3 (vecMoveTarget);
  4124.  
  4125. if(SCRIPT_VERIFY(NULL_IN_SCRIPTING_LANGUAGE != iVehicleID, "TASK_VEHICLE_PARK - You must specify a vehicle to be parked"))
  4126. {
  4127. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  4128. }
  4129.  
  4130. if(!pVehicle)
  4131. {
  4132. return;
  4133. }
  4134.  
  4135. const float HeadingRadians = HeadingDegrees*DtoR;
  4136. Vector3 direction;
  4137.  
  4138. direction.x = -rage::Sinf(HeadingRadians);
  4139. direction.y = rage::Cosf(HeadingRadians);
  4140. direction.z = 0.0f;
  4141.  
  4142. sVehicleMissionParams params;
  4143. params.SetTargetPosition(VecTargetCoors);
  4144.  
  4145. CTaskVehicleParkNew* pParkTask = rage_new CTaskVehicleParkNew(params, direction, (CTaskVehicleParkNew::ParkType)ParkType, ToleranceDegrees*DtoR, bKeepLightsOn);
  4146.  
  4147. CTask* pTask = rage_new CTaskControlVehicle(pVehicle, pParkTask);
  4148. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_VEHICLE_PARK, "TASK_VEHICLE_PARK");
  4149. }
  4150.  
  4151. void CommandTaskStealthKill( int iPedID, int iTargetPedID, int iStealthKillActionResultId, float fDesiredMoveBlendRatio, int iStealthFlags )
  4152. {
  4153. if( iPedID != NULL_IN_SCRIPTING_LANGUAGE )
  4154. {
  4155. // Apparently sequence tasks rely on the iPedID to be NULL
  4156. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  4157. if( pPed )
  4158. {
  4159. // Check to make sure the ped has a weapon equipped
  4160. const CWeaponInfo* pEquippedWeaponInfo = pPed->GetWeaponManager()->GetEquippedWeaponInfo();
  4161. if( !SCRIPT_VERIFY( pEquippedWeaponInfo, "TASK_STEALTH_KILL - The ped doesn't have a weapon equipped. Please use GIVE_WEAPON_TO_PED" ) )
  4162. {
  4163. return;
  4164. }
  4165. }
  4166. }
  4167.  
  4168. // Ensure target ped is valid
  4169. CPed* pTargetPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iTargetPedID);
  4170. if( !SCRIPT_VERIFY( pTargetPed, "TASK_STEALTH_KILL - The target ped is invalid." ) )
  4171. {
  4172. return;
  4173. }
  4174.  
  4175. // Check to make sure the ped has a weapon equipped
  4176. const CWeaponInfo* pTargetEquippedWeaponInfo = pTargetPed->GetWeaponManager()->GetEquippedWeaponInfo();
  4177. if( !SCRIPT_VERIFY( pTargetEquippedWeaponInfo, "TASK_STEALTH_KILL - The target ped doesn't have a weapon equipped. Please use GIVE_WEAPON_TO_PED" ) )
  4178. {
  4179. return;
  4180. }
  4181.  
  4182. // Ensure the stealth kill id is valid
  4183. u32 uActionIdx = 0;
  4184. const CActionResult* pStealthKillActionResult = ACTIONMGR.FindActionResult( uActionIdx, (u32)iStealthKillActionResultId );
  4185. if( !SCRIPT_VERIFY( pStealthKillActionResult, "TASK_STEALTH_KILL - Invalid stealth kill action." ) )
  4186. {
  4187. return;
  4188. }
  4189.  
  4190. CTask* pTask = rage_new CTaskStealthKill( pTargetPed, pStealthKillActionResult, fDesiredMoveBlendRatio, iStealthFlags );
  4191. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_STEALTH_KILL, "TASK_STEALTH_KILL" );
  4192. }
  4193.  
  4194. void CommandTaskPlantBomb( int iPedID, const scrVector &, float )
  4195. {
  4196. if( iPedID != NULL_IN_SCRIPTING_LANGUAGE )
  4197. {
  4198. // Apparently sequence tasks rely on the iPedID to be NULL
  4199. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  4200. if( pPed )
  4201. {
  4202. // Check to make sure the ped has a weapon equipped
  4203. const CWeaponInfo* pEquippedWeaponInfo = pPed->GetWeaponManager()->GetEquippedWeaponInfo();
  4204. if( !SCRIPT_VERIFY( pEquippedWeaponInfo && pEquippedWeaponInfo->GetProjectileCanBePlaced(), "TASK_PLANT_BOMB - The ped doesn't have a weapon that can be placed. Please use GIVE_WEAPON_TO_PED" ) )
  4205. {
  4206. return;
  4207. }
  4208. }
  4209. }
  4210.  
  4211. CTask* pTask = rage_new CTaskBomb();
  4212. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_PLANT_BOMB, "TASK_PLANT_BOMB" );
  4213. }
  4214.  
  4215. void CommandTaskSharkCircleCoord(int iPedID, const scrVector & vCoord, float fMBR, float fRadius)
  4216. {
  4217. CAITarget aiTarget;
  4218. aiTarget.SetPosition(vCoord);
  4219. float fSpeed = CTaskSharkAttack::GetTunables().m_CirclingAngularSpeed;
  4220. CTask* pTask = rage_new CTaskComplexControlMovement(rage_new CTaskSharkCircle(fMBR, aiTarget, fRadius, fSpeed));
  4221. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_SHARK_CIRCLE_COORD, "TASK_SHARK_CIRCLE_COORD");
  4222. }
  4223.  
  4224. void CommandTaskSharkCirclePed(int iPedID, int iOtherPedID, float fMBR, float fRadius)
  4225. {
  4226. CAITarget aiTarget;
  4227. const CPed* pOtherPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iOtherPedID);
  4228. aiTarget.SetEntity(pOtherPed);
  4229. float fSpeed = CTaskSharkAttack::GetTunables().m_CirclingAngularSpeed;
  4230. CTask* pTask = rage_new CTaskComplexControlMovement(rage_new CTaskSharkCircle(fMBR, aiTarget, fRadius, fSpeed));
  4231. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_SHARK_CIRCLE_PED, "TASK_SHARK_CIRCLE_COORD");
  4232. }
  4233.  
  4234. void CommandTaskPlaneGotoPreciseVtol(int iPedID, int iVehicleID, const scrVector & vecMoveTarget, int iFlightHeight, int iMinHeightAboveTerrain, bool bUseDesiredOrientation, float fDesiredOrientation, bool bAutoPilot)
  4235. {
  4236. CVehicle* pVehicle = NULL;
  4237. Vector3 VecTargetCoors = Vector3 (vecMoveTarget);
  4238.  
  4239. if(SCRIPT_VERIFY(NULL_IN_SCRIPTING_LANGUAGE != iVehicleID, "TASK_PLANE_GOTO_PRECISE_VTOL - You must specify a vehicle to be parked"))
  4240. {
  4241. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID);
  4242. }
  4243.  
  4244. if(!pVehicle)
  4245. {
  4246. return;
  4247. }
  4248.  
  4249. if (!SCRIPT_VERIFY(pVehicle->InheritsFromPlane(), "TASK_PLANE_GOTO_PRECISE_VTOL - Must be used on a plane"))
  4250. {
  4251. return;
  4252. }
  4253.  
  4254. CPlane* pPlane = static_cast<CPlane*>(pVehicle);
  4255. if (!SCRIPT_VERIFY(pPlane->GetVerticalFlightModeAvaliable(), "TASK_PLANE_GOTO_PRECISE_VTOL - Plane must support VTOL (vertical takeoff and landing)"))
  4256. {
  4257. return;
  4258. }
  4259.  
  4260. sVehicleMissionParams params;
  4261. params.SetTargetPosition(VecTargetCoors);
  4262.  
  4263. fDesiredOrientation *= DtoR;
  4264. fDesiredOrientation += 90.0f*DtoR;
  4265.  
  4266. fDesiredOrientation = fwAngle::LimitRadianAngleSafe(fDesiredOrientation);
  4267.  
  4268. if (bAutoPilot)
  4269. {
  4270. params.m_iDrivingFlags.SetFlag(DF_DontTerminateTaskWhenAchieved);
  4271. }
  4272.  
  4273. CTaskVehicleGoToPlane* pPlaneTask = rage_new CTaskVehicleGoToPlane(params, iFlightHeight, iMinHeightAboveTerrain, true, bUseDesiredOrientation, fDesiredOrientation);
  4274.  
  4275. if (bAutoPilot)
  4276. {
  4277. // Apply task directly to the vehicle
  4278. pVehicle->GetIntelligence()->GetTaskManager()->SetTask(VEHICLE_TASK_TREE_PRIMARY, pPlaneTask, VEHICLE_TASK_PRIORITY_PRIMARY, false);
  4279. pVehicle->GetIntelligence()->SetUsingScriptAutopilot(true);
  4280.  
  4281. CVehicleNodeList * pNodeList = pVehicle->GetIntelligence()->GetNodeList();
  4282. if(pNodeList)
  4283. {
  4284. pNodeList->ClearPathNodes();
  4285. }
  4286.  
  4287. pVehicle->SwitchEngineOn(true);
  4288. }
  4289.  
  4290. else
  4291. {
  4292. // Apply task to the ped as part of CTaskControlVehicle
  4293. CTask* pTask = rage_new CTaskControlVehicle(pVehicle, pPlaneTask);
  4294. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_VEHICLE_MISSION, "TASK_PLANE_GOTO_PRECISE_VTOL");
  4295. }
  4296. }
  4297.  
  4298. void CommandTaskSubmarineGotoAndStop(int iPedID, int iVehicleID, const scrVector & vecMoveTarget, bool bAutoPilot)
  4299. {
  4300. CVehicle* pVehicle = NULL;
  4301. Vector3 VecTargetCoors = Vector3 (vecMoveTarget);
  4302.  
  4303. if(SCRIPT_VERIFY(NULL_IN_SCRIPTING_LANGUAGE != iVehicleID, "TASK_PLANE_GOTO_PRECISE_VTOL - You must specify a vehicle to be parked"))
  4304. {
  4305. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID);
  4306. }
  4307.  
  4308. if(!pVehicle)
  4309. {
  4310. return;
  4311. }
  4312.  
  4313. sVehicleMissionParams params;
  4314. params.SetTargetPosition(VecTargetCoors);
  4315.  
  4316. s32 subFlags = 0;
  4317. if (bAutoPilot)
  4318. {
  4319. params.m_iDrivingFlags.SetFlag(DF_DontTerminateTaskWhenAchieved);
  4320. subFlags = CTaskVehicleGoToSubmarine::SF_HoverAtEnd;
  4321. params.m_fTargetArriveDist = 30.0f;
  4322. }
  4323.  
  4324. CTaskVehicleGoToSubmarine* pSubTask = rage_new CTaskVehicleGoToSubmarine(params, subFlags);
  4325.  
  4326. if (bAutoPilot)
  4327. {
  4328. // Apply task directly to the vehicle
  4329. pVehicle->GetIntelligence()->GetTaskManager()->SetTask(VEHICLE_TASK_TREE_PRIMARY, pSubTask, VEHICLE_TASK_PRIORITY_PRIMARY, false);
  4330. pVehicle->GetIntelligence()->SetUsingScriptAutopilot(true);
  4331.  
  4332. CVehicleNodeList * pNodeList = pVehicle->GetIntelligence()->GetNodeList();
  4333. if(pNodeList)
  4334. {
  4335. pNodeList->ClearPathNodes();
  4336. }
  4337.  
  4338. pVehicle->SwitchEngineOn(true);
  4339. }
  4340.  
  4341. else
  4342. {
  4343. // Apply task to the ped as part of CTaskControlVehicle
  4344. CTask* pTask = rage_new CTaskControlVehicle(pVehicle, pSubTask);
  4345. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_VEHICLE_MISSION, "TASK_SUBMARINE_GOTO_AND_STOP");
  4346. }
  4347. }
  4348.  
  4349. void CommandClearDefaultPrimaryTask(int iPedID)
  4350. {
  4351. if (SCRIPT_VERIFY(NULL_IN_SCRIPTING_LANGUAGE != iPedID, "CLEAR_DEFAULT_PRIMARY_TASK - Can't have a NULL ped"))
  4352. {
  4353. if (CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID))
  4354. {
  4355. AI_LOG_WITH_ARGS("[Script] - Script %s has restarted the default primary task for ped %s", CTheScripts::GetCurrentScriptName(), AILogging::GetDynamicEntityNameSafe(pPed));
  4356. pPed->GetPedIntelligence()->AddTaskDefault(pPed->ComputeDefaultTask(*pPed));
  4357. }
  4358. }
  4359. }
  4360.  
  4361. void CommandClearPrimaryVehicleTask( int iVehicleID )
  4362. {
  4363. CVehicle* pVehicle = NULL;
  4364. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID);
  4365.  
  4366. if (SCRIPT_VERIFYF(pVehicle, "CLEAR_PRIMARY_VEHICLE_TASK - Could not find vehicle with provided ID %i", iVehicleID))
  4367. {
  4368. if (pVehicle->GetIntelligence() && pVehicle->GetIntelligence()->GetTaskManager())
  4369. {
  4370. pVehicle->GetIntelligence()->GetTaskManager()->ClearTask(VEHICLE_TASK_TREE_PRIMARY, VEHICLE_TASK_PRIORITY_PRIMARY);
  4371. }
  4372. }
  4373. }
  4374.  
  4375. void CommandClearVehicleCrashTask( int iVehicleID )
  4376. {
  4377. CVehicle* pVehicle = NULL;
  4378. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID);
  4379.  
  4380. if (SCRIPT_VERIFYF(pVehicle, "CLEAR_VEHICLE_CRASH_TASK - Could not find vehicle with provided ID %i", iVehicleID))
  4381. {
  4382. if (pVehicle->GetIntelligence() && pVehicle->GetIntelligence()->GetTaskManager())
  4383. {
  4384. pVehicle->GetIntelligence()->GetTaskManager()->ClearTask(VEHICLE_TASK_TREE_PRIMARY, VEHICLE_TASK_PRIORITY_CRASH);
  4385. }
  4386. }
  4387. }
  4388.  
  4389. void CommandTaskVehicleEscort( int iPedID, int iVehicleID, int iEscortEntityID, int iEscortType, float fCruiseSpeed, int iDrivingFlags, float fCustomOffset, int iMinHeightAboveTerrain, float fStraightLineDist)
  4390. {
  4391. CVehicle* pVehicle = NULL;
  4392.  
  4393. if(SCRIPT_VERIFY(NULL_IN_SCRIPTING_LANGUAGE != iVehicleID, "TASK_VEHICLE_ESCORT - You must specify a vehicle to drive"))
  4394. {
  4395. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  4396. }
  4397.  
  4398. if(!pVehicle)
  4399. {
  4400. return;
  4401. }
  4402.  
  4403. CEntity *pEntity = CTheScripts::GetEntityToModifyFromGUID<CEntity>(iEscortEntityID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  4404. if (!pEntity)
  4405. {
  4406. return;
  4407. }
  4408.  
  4409. sVehicleMissionParams params;
  4410. params.m_iDrivingFlags = iDrivingFlags;
  4411. params.SetTargetEntity(pEntity);
  4412. params.m_fCruiseSpeed = fCruiseSpeed;
  4413.  
  4414. if (iMinHeightAboveTerrain < 0)
  4415. {
  4416. iMinHeightAboveTerrain = CTaskVehicleGoToHelicopter::DEFAULT_MIN_HEIGHT_ABOVE_TERRAIN;
  4417. }
  4418. CTaskVehicleEscort* pEscortTask = rage_new CTaskVehicleEscort(params, (CTaskVehicleEscort::VehicleEscortType)iEscortType, fCustomOffset, iMinHeightAboveTerrain, fStraightLineDist);
  4419.  
  4420. CTask* pTask = rage_new CTaskControlVehicle(pVehicle, pEscortTask);
  4421. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_VEHICLE_MISSION, "TASK_VEHICLE_ESCORT");
  4422. }
  4423.  
  4424. void CommandTaskVehicleFollow( int iPedID, int iVehicleID, int iFollowEntityID, float fCruiseSpeed, int iDrivingFlags, int iFollowDistance)
  4425. {
  4426. CVehicle* pVehicle = NULL;
  4427.  
  4428. if(SCRIPT_VERIFY(NULL_IN_SCRIPTING_LANGUAGE != iVehicleID, "TASK_VEHICLE_FOLLOW - You must specify a vehicle to drive"))
  4429. {
  4430. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  4431. }
  4432.  
  4433. if(!pVehicle)
  4434. {
  4435. return;
  4436. }
  4437.  
  4438. CEntity *pEntity = CTheScripts::GetEntityToModifyFromGUID<CEntity>(iFollowEntityID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  4439. if (!pEntity)
  4440. {
  4441. return;
  4442. }
  4443.  
  4444. sVehicleMissionParams params;
  4445. params.m_iDrivingFlags = iDrivingFlags;
  4446. params.SetTargetEntity(pEntity);
  4447. params.m_fCruiseSpeed = fCruiseSpeed;
  4448.  
  4449. CTaskVehicleFollow* pFollowTask = rage_new CTaskVehicleFollow(params, iFollowDistance);
  4450.  
  4451. CTask* pTask = rage_new CTaskControlVehicle(pVehicle, pFollowTask);
  4452. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_VEHICLE_MISSION, "TASK_VEHICLE_FOLLOW");
  4453. }
  4454.  
  4455. void CommandTaskHeliProtect( int iPedID, int iVehicleID, int iEscortEntityID, float fCruiseSpeed, int iDrivingFlags, float fCustomOffset, int iMinHeightAboveTerrain, int iHeliFlags)
  4456. {
  4457. CVehicle* pVehicle = NULL;
  4458.  
  4459. if(SCRIPT_VERIFY(NULL_IN_SCRIPTING_LANGUAGE != iVehicleID, "TASK_VEHICLE_HELI_PROTECT - You must specify a vehicle to drive"))
  4460. {
  4461. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  4462. }
  4463.  
  4464. if(!pVehicle)
  4465. {
  4466. return;
  4467. }
  4468.  
  4469. CEntity *pEntity = CTheScripts::GetEntityToModifyFromGUID<CEntity>(iEscortEntityID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  4470. if (!pEntity)
  4471. {
  4472. return;
  4473. }
  4474.  
  4475. sVehicleMissionParams params;
  4476. params.m_iDrivingFlags = iDrivingFlags;
  4477. params.SetTargetEntity(pEntity);
  4478. params.m_fCruiseSpeed = fCruiseSpeed;
  4479.  
  4480. if (iMinHeightAboveTerrain < 0)
  4481. {
  4482. iMinHeightAboveTerrain = CTaskVehicleGoToHelicopter::DEFAULT_MIN_HEIGHT_ABOVE_TERRAIN;
  4483. }
  4484. CTask* pHeliTask = rage_new CTaskVehicleHeliProtect(params, fCustomOffset, iMinHeightAboveTerrain, iHeliFlags);
  4485. CTask* pTask = rage_new CTaskControlVehicle(pVehicle, pHeliTask);
  4486. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_VEHICLE_MISSION, "TASK_VEHICLE_HELI_PROTECT");
  4487. }
  4488.  
  4489. void CommandTaskVehicleChase(int iPedID, int iTargetID)
  4490. {
  4491. //Ensure the ped is valid.
  4492. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  4493. if(!SCRIPT_VERIFY(pPed, "TASK_VEHICLE_CHASE - The ped is invalid."))
  4494. {
  4495. return;
  4496. }
  4497.  
  4498. //Ensure the ped is in a vehicle.
  4499. if(!SCRIPT_VERIFY(pPed->GetVehiclePedInside(), "TASK_VEHICLE_CHASE - The ped is not in a vehicle."))
  4500. {
  4501. return;
  4502. }
  4503.  
  4504. //Ensure the target is valid.
  4505. CPed* pTarget = CTheScripts::GetEntityToModifyFromGUID<CPed>(iTargetID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  4506. if(!SCRIPT_VERIFY(pTarget, "TASK_VEHICLE_CHASE - The target is invalid."))
  4507. {
  4508. return;
  4509. }
  4510.  
  4511. //Ensure the target is in a vehicle.
  4512. if(!SCRIPT_VERIFY(pTarget->GetVehiclePedInside(), "TASK_VEHICLE_CHASE - The target is not in a vehicle."))
  4513. {
  4514. return;
  4515. }
  4516.  
  4517. //Create the task.
  4518. CTask* pTask = rage_new CTaskVehicleChase(pTarget);
  4519.  
  4520. //Give the task to the ped.
  4521. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_VEHICLE_CHASE, "TASK_VEHICLE_CHASE");
  4522. }
  4523.  
  4524. void CommandSetTaskVehicleChaseBehaviorFlag(int iPedID, int iFlag, bool bValue)
  4525. {
  4526. //Ensure the ped is valid.
  4527. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  4528. if(!SCRIPT_VERIFY(pPed, "SET_TASK_VEHICLE_CHASE_BEHAVIOR_FLAG - The ped is invalid."))
  4529. {
  4530. return;
  4531. }
  4532.  
  4533. //Ensure the vehicle chase task is valid.
  4534. CTaskVehicleChase* pTask = static_cast<CTaskVehicleChase *>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_VEHICLE_CHASE));
  4535. if(!SCRIPT_VERIFY(pTask, "SET_TASK_VEHICLE_CHASE_BEHAVIOR_FLAG - The task is invalid."))
  4536. {
  4537. return;
  4538. }
  4539.  
  4540. //Change the behavior flag.
  4541. pTask->ChangeBehaviorFlag(CTaskVehicleChase::Overrides::Script, (CTaskVehicleChase::BehaviorFlags)iFlag, bValue);
  4542. }
  4543.  
  4544. void CommandSetTaskVehicleChaseIdealPursuitDistance(int iPedID, float fIdealPursuitDistance)
  4545. {
  4546. //Ensure the ped is valid.
  4547. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  4548. if(!SCRIPT_VERIFY(pPed, "SET_TASK_VEHICLE_CHASE_IDEAL_PURSUIT_DISTANCE - The ped is invalid."))
  4549. {
  4550. return;
  4551. }
  4552.  
  4553. //Ensure the vehicle chase task is valid.
  4554. CTaskVehicleChase* pTask = static_cast<CTaskVehicleChase *>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_VEHICLE_CHASE));
  4555. if(!SCRIPT_VERIFY(pTask, "SET_TASK_VEHICLE_CHASE_IDEAL_PURSUIT_DISTANCE - The task is invalid."))
  4556. {
  4557. return;
  4558. }
  4559.  
  4560. //Set the ideal distance.
  4561. pTask->SetIdealDistanceForPursue(CTaskVehicleChase::Overrides::Script, fIdealPursuitDistance);
  4562. }
  4563.  
  4564.  
  4565. void CommandTaskPlaneChase(int iPedID, int iTargetID, const scrVector & vTargetOffset)
  4566. {
  4567. //Ensure the ped is valid.
  4568. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  4569. if(!SCRIPT_VERIFY(pPed, "TASK_PLANE_CHASE - The ped is invalid."))
  4570. {
  4571. return;
  4572. }
  4573.  
  4574. //Ensure the target is valid.
  4575. CEntity const* pTarget = CTheScripts::GetEntityToQueryFromGUID<CEntity>(iTargetID);
  4576. if(!SCRIPT_VERIFY(pTarget, "TASK_PLANE_CHASE - The target is invalid."))
  4577. {
  4578. return;
  4579. }
  4580.  
  4581. CAITarget target;
  4582. target.SetEntityAndOffsetUnlimited(pTarget, vTargetOffset);
  4583. CTask* pTask = rage_new CTaskPlaneChase(target);
  4584.  
  4585. //Give the task to the ped.
  4586. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_PLANE_CHASE, "TASK_PLANE_CHASE");
  4587. }
  4588.  
  4589.  
  4590. void CommandTaskPlaneLand(int iPedID, int iVehicleID, const scrVector & vRunWayStart, const scrVector & vRunWayEnd)
  4591. {
  4592. //Ensure the ped is valid.
  4593. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  4594. if(!SCRIPT_VERIFY(pPed, "TASK_PLANE_LAND - The ped is invalid."))
  4595. {
  4596. return;
  4597. }
  4598.  
  4599. CVehicle* pVehicle = NULL;
  4600. if(SCRIPT_VERIFY(NULL_IN_SCRIPTING_LANGUAGE != iVehicleID, "TASK_PLANE_LAND - You must specify a vehicle!"))
  4601. {
  4602. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID);
  4603. }
  4604.  
  4605. if(!pVehicle)
  4606. {
  4607. return;
  4608. }
  4609.  
  4610. //Create the task.
  4611. CTask* pTaskVehicleLandPlane = rage_new CTaskVehicleLandPlane((Vec3V)vRunWayStart, (Vec3V)vRunWayEnd);
  4612. CTask* pTask = rage_new CTaskControlVehicle(pVehicle, pTaskVehicleLandPlane);
  4613.  
  4614. //Give the task to the ped.
  4615. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_PLANE_LAND, "TASK_PLANE_CHASE");
  4616. }
  4617.  
  4618.  
  4619.  
  4620. void CommandTaskHeliChase(int iPedID, int iTargetID, const scrVector & vTargetOffset)
  4621. {
  4622. //Ensure the ped is valid.
  4623. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  4624. if(!SCRIPT_VERIFY(pPed, "TASK_HELI_CHASE - The ped is invalid."))
  4625. {
  4626. return;
  4627. }
  4628.  
  4629. //Ensure the target is valid.
  4630. const CEntity* pTarget = CTheScripts::GetEntityToQueryFromGUID<CEntity>(iTargetID);
  4631. if(!SCRIPT_VERIFY(pTarget, "TASK_HELI_CHASE - The target is invalid."))
  4632. {
  4633. return;
  4634. }
  4635.  
  4636. //Create the task.
  4637. CTask* pTask = rage_new CTaskHeliChase(CAITarget(pTarget), (Vec3V)vTargetOffset);
  4638.  
  4639. //Give the task to the ped.
  4640. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_HELI_CHASE, "TASK_HELI_CHASE");
  4641. }
  4642.  
  4643. void CommandSetTaskHeliChaseTargetOffset(int iPedID, const scrVector & vTargetOffset)
  4644. {
  4645. //Ensure the ped is valid.
  4646. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  4647. if(!SCRIPT_VERIFY(pPed, "SET_TASK_HELI_CHASE_TARGET_OFFSET - The ped is invalid."))
  4648. {
  4649. return;
  4650. }
  4651.  
  4652. //Ensure the vehicle chase task is valid.
  4653. CTaskHeliChase* pTask = static_cast<CTaskHeliChase *>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_HELI_CHASE));
  4654. if(!SCRIPT_VERIFY(pTask, "SET_TASK_HELI_CHASE_TARGET_OFFSET - The task is invalid."))
  4655. {
  4656. return;
  4657. }
  4658.  
  4659. //Set the target offset.
  4660. pTask->SetTargetOffset((Vec3V)vTargetOffset);
  4661. }
  4662.  
  4663. void CommandSetTaskHeliChaseTargetOffsetWorldSpace(int iPedID, bool bTargetOffsetWorldSpace)
  4664. {
  4665. //Ensure the ped is valid.
  4666. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  4667. if(!SCRIPT_VERIFY(pPed, "SET_TASK_HELI_CHASE_TARGET_OFFSET_WORLD_SPACE - The ped is invalid."))
  4668. {
  4669. return;
  4670. }
  4671.  
  4672. //Ensure the vehicle chase task is valid.
  4673. CTaskHeliChase* pTask = static_cast<CTaskHeliChase *>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_HELI_CHASE));
  4674. if(!SCRIPT_VERIFY(pTask, "SET_TASK_HELI_CHASE_TARGET_OFFSET_WORLD_SPACE - The task is invalid."))
  4675. {
  4676. return;
  4677. }
  4678.  
  4679. //Set the target offset.
  4680. pTask->SetTargetOffsetRelative(bTargetOffsetWorldSpace ? CTaskHeliChase::OffsetRelative_World : CTaskHeliChase::OffsetRelative_Local );
  4681. }
  4682.  
  4683. void CommandSetTaskHeliChaseOrientation(int iPedID, int iOrientationMode, int iOrientationRelative, float in_orientation)
  4684. {
  4685. //Ensure the ped is valid.
  4686. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  4687. if(!SCRIPT_VERIFY(pPed, "SET_TASK_HELI_CHASE_ORIENTATION - The ped is invalid."))
  4688. {
  4689. return;
  4690. }
  4691.  
  4692. //Ensure the vehicle chase task is valid.
  4693. CTaskHeliChase* pTask = static_cast<CTaskHeliChase *>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_HELI_CHASE));
  4694. if(!SCRIPT_VERIFY(pTask, "SET_TASK_HELI_CHASE_ORIENTATION - The task is invalid."))
  4695. {
  4696. return;
  4697. }
  4698.  
  4699. pTask->SetOrientationMode(static_cast<CTaskHeliChase::OrientationMode>(iOrientationMode));
  4700. pTask->SetOrientationRelative(static_cast<CTaskHeliChase::OrientationRelative>(iOrientationRelative));
  4701. pTask->SetOrientationOffset(in_orientation);
  4702. }
  4703.  
  4704. void CommandTaskWeaponRoll( int UNUSED_PARAM(iPedID), bool UNUSED_PARAM(bRight))
  4705. {
  4706. Assertf(false, "unsupported command TASK_WEAPON_ROLL");
  4707. MUST_FIX_THIS(anim missing);
  4708. }
  4709.  
  4710. bool CommandControlMountedWeapon( int iPedID )
  4711. {
  4712. if( SCRIPT_VERIFY( NULL_IN_SCRIPTING_LANGUAGE != iPedID, "CONTROL_MOUNTED_WEAPON - Can't have a NULL ped" ))
  4713. {
  4714. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  4715. if(pPed)
  4716. {
  4717. bool inVehicle = pPed->GetPedConfigFlag( CPED_CONFIG_FLAG_InVehicle );
  4718. if(SCRIPT_VERIFY(inVehicle , "CONTROL_MOUNTED_WEAPON: ped is not in vehicle!"))
  4719. {
  4720. if(CTaskVehicleMountedWeapon::IsTaskValid(pPed))
  4721. {
  4722. CTask* pControlVehicleTask = pPed->GetPedIntelligence()->FindTaskPrimaryByType( CTaskTypes::TASK_CONTROL_VEHICLE );
  4723. if( pControlVehicleTask )
  4724. {
  4725. CTaskControlVehicle* pTaskControlVehicle=static_cast<CTaskControlVehicle*>(pControlVehicleTask);
  4726. pTaskControlVehicle->SetDesiredSubtask(NULL);
  4727. return true;
  4728. }
  4729. }
  4730. }
  4731. }
  4732. }
  4733. return false;
  4734. }
  4735.  
  4736. void CommandSetMountedWeaponTarget(int iPedID, int iOtherPedID, int iTargetVehicleID, const scrVector & scrVecCoors, int TaskMode, bool bIgnoreTargetVehDeadCheck)
  4737. {
  4738. if( SCRIPT_VERIFY( NULL_IN_SCRIPTING_LANGUAGE != iPedID, "SET_MOUNTED_WEAPON_TARGET - Can't have a NULL ped" ) )
  4739. {
  4740. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>( iPedID );
  4741. if( pPed )
  4742. {
  4743. // Determine the type of target to updateSET_MOUNTED_WEAPON_TARGET
  4744. const CEntity *pTargetEntity = NULL;
  4745.  
  4746. // Ped target
  4747. if( iOtherPedID != NULL_IN_SCRIPTING_LANGUAGE )
  4748. {
  4749. if( !SCRIPT_VERIFY( iTargetVehicleID == NULL_IN_SCRIPTING_LANGUAGE, "SET_MOUNTED_WEAPON_TARGET - Can't have a target ped and a target car" ) )
  4750. return;
  4751.  
  4752. const CPed* pTargetPed = CTheScripts::GetEntityToQueryFromGUID<CPed>( iOtherPedID );
  4753. if( !SCRIPT_VERIFY( pTargetPed, "SET_MOUNTED_WEAPON_TARGET - Target ped doesn't exist" ) )
  4754. return;
  4755.  
  4756. pTargetEntity = pTargetPed;
  4757. }
  4758.  
  4759. // Vehicle target
  4760. if( iTargetVehicleID != NULL_IN_SCRIPTING_LANGUAGE )
  4761. {
  4762. const CVehicle *pTargetVehicle = CTheScripts::GetEntityToQueryFromGUID<CVehicle>( iTargetVehicleID, bIgnoreTargetVehDeadCheck ? CTheScripts::GUID_ASSERT_FLAGS_NO_DEAD_CHECK : CTheScripts::GUID_ASSERT_FLAGS_ALL );
  4763. if( !SCRIPT_VERIFY( pTargetVehicle, "SET_MOUNTED_WEAPON_TARGET - Target vehicle doesn't exist" ) )
  4764. return;
  4765.  
  4766. pTargetEntity = pTargetVehicle;
  4767. }
  4768.  
  4769. // Set the target
  4770. const Vector3 vTargetCoords( scrVecCoors );
  4771.  
  4772. aiTask* pMountedWeaponBase = pPed->GetPedIntelligence()->FindTaskActiveByType( CTaskTypes::TASK_VEHICLE_MOUNTED_WEAPON );
  4773. if( pMountedWeaponBase )
  4774. {
  4775. //Updated the mode
  4776. static_cast<CTaskVehicleMountedWeapon*>(pMountedWeaponBase)->SetMode((CTaskVehicleMountedWeapon::eTaskMode)TaskMode);
  4777.  
  4778. //Set the target
  4779. if( pTargetEntity )
  4780. static_cast<CTaskVehicleMountedWeapon*>(pMountedWeaponBase)->SetTarget( pTargetEntity, &vTargetCoords );
  4781. else
  4782. static_cast<CTaskVehicleMountedWeapon*>(pMountedWeaponBase)->SetTargetPosition( vTargetCoords );
  4783. }
  4784.  
  4785. Assertf( pMountedWeaponBase, "SET_MOUNTED_WEAPON_TARGET - Native function invoked but ped has no gun or vehicle gun task." );
  4786. }
  4787. }
  4788. }
  4789.  
  4790.  
  4791. void CommandClearMountedWeaponTaskUnderneathDrivingTask(int iPedID)
  4792. {
  4793.  
  4794. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  4795. if(pPed)
  4796. {
  4797. bool inVehicle = pPed->GetPedConfigFlag( CPED_CONFIG_FLAG_InVehicle );
  4798. if(SCRIPT_VERIFY(inVehicle , "CLEAR_MOUNTED_WEAPON_TASK_UNDERNEATH_DRIVING_TASK: ped is not in vehicle!"))
  4799. {
  4800. CTask* pCurrent=pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_CONTROL_VEHICLE );
  4801. if( pCurrent )
  4802. {
  4803. CTaskControlVehicle* pTaskControlVehicle=static_cast<CTaskControlVehicle*>(pCurrent);
  4804. if( scriptVerifyf( pTaskControlVehicle->GetDesiredSubtask() && pTaskControlVehicle->GetDesiredSubtask()->GetTaskType() == CTaskTypes::TASK_VEHICLE_MOUNTED_WEAPON, "CLEAR_MOUNTED_WEAPON_TASK_UNDERNEATH_DRIVING_TASK no mounted weapon task running, use IS_MOUNTED_WEAPON_TASK_UNDERNEATH_DRIVING_TASK" ) )
  4805. {
  4806. pTaskControlVehicle->SetDesiredSubtask(NULL);
  4807. }
  4808. }
  4809. }
  4810. }
  4811. }
  4812.  
  4813. bool CommandIsMountedWeaponTaskUnderneathDrivingTask(int iPedID)
  4814. {
  4815. const CPed *pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedID);
  4816. if(pPed)
  4817. {
  4818. bool inVehicle = pPed->GetPedConfigFlag( CPED_CONFIG_FLAG_InVehicle );
  4819. if(SCRIPT_VERIFY(inVehicle, "IS_MOUNTED_WEAPON_TASK_UNDERNEATH_DRIVING_TASK: ped is not in vehicle or on a mount!"))
  4820. {
  4821. CTask* pCurrent = pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_VEHICLE_MOUNTED_WEAPON);
  4822. if( pCurrent )
  4823. {
  4824. return true;
  4825. }
  4826. }
  4827. }
  4828. return false;
  4829. }
  4830.  
  4831.  
  4832. void CommandTaskDriveBy( int iPedID, int iOtherPedID, int iTargetVehicleID,
  4833. const scrVector & scrVecCoors, float fAbortRange, int iFrequencyPercentage, bool bPushUnderneathDrivingTaskIfDriving, int iFiringPatternHash )
  4834. {
  4835. Vector3 TempVec, CentreVec, VecDiff;
  4836. CPed *pPed;
  4837. const CPed *pSecondPed;
  4838. const CVehicle *pSecondVehicle;
  4839. CTask* pTask;
  4840.  
  4841. TempVec = Vector3(scrVecCoors);
  4842.  
  4843. if(!SCRIPT_VERIFY( (iFrequencyPercentage >= 0) && (iFrequencyPercentage <= 100), "TASK_DRIVE_BY - Frequency should be between 0 and 100"))
  4844. return;
  4845.  
  4846. const CEntity *pTargetEntity = NULL;
  4847. if (iOtherPedID != NULL_IN_SCRIPTING_LANGUAGE) // >= 0)
  4848. {
  4849. if(SCRIPT_VERIFY(iTargetVehicleID == NULL_IN_SCRIPTING_LANGUAGE, "TASK_DRIVE_BY - Can't have a target ped and a target car"))
  4850. {
  4851. pSecondPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iOtherPedID);
  4852. if(!pSecondPed)
  4853. return;
  4854.  
  4855. pTargetEntity = pSecondPed;
  4856. }
  4857. else
  4858. {
  4859. return;
  4860. }
  4861. }
  4862. else
  4863. {
  4864. pSecondPed = NULL;
  4865. }
  4866. if (iTargetVehicleID != NULL_IN_SCRIPTING_LANGUAGE) // >= 0)
  4867. {
  4868. if(SCRIPT_VERIFY(iOtherPedID == NULL_IN_SCRIPTING_LANGUAGE, "TASK_DRIVE_BY - Can't have a target ped and a target car"))
  4869. {
  4870. pSecondVehicle = CTheScripts::GetEntityToQueryFromGUID<CVehicle>(iTargetVehicleID);
  4871. if(!SCRIPT_VERIFY(pSecondVehicle, "TASK_DRIVE_BY - Target vehicle doesn't exist"))
  4872. return;
  4873.  
  4874. pTargetEntity = pSecondVehicle;
  4875. }
  4876. else
  4877. {
  4878. return;
  4879. }
  4880. }
  4881. else
  4882. {
  4883. pSecondVehicle = NULL;
  4884. }
  4885.  
  4886. // Set up the arguments
  4887. CAITarget target;
  4888. if( pTargetEntity )
  4889. {
  4890. target.SetEntityAndOffset(pTargetEntity,TempVec);
  4891. }
  4892. else
  4893. {
  4894. target.SetPosition(TempVec);
  4895. }
  4896. const u32 uFiringPattern = iFiringPatternHash != 0 ? (u32)iFiringPatternHash : ATSTRINGHASH("FIRING_PATTERN_BURST_FIRE_DRIVEBY", 0x0d31265f2);
  4897.  
  4898. bool bAlreadydoingDriveBy=false;
  4899. if(NULL_IN_SCRIPTING_LANGUAGE!=iPedID)
  4900. {
  4901. pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  4902. if(pPed)
  4903. {
  4904. bool inVehicle = pPed->GetPedConfigFlag( CPED_CONFIG_FLAG_InVehicle );
  4905. bool onMount = (pPed->GetMyMount() != NULL);
  4906. if(SCRIPT_VERIFY(inVehicle || onMount, "TASK_DRIVE_BY: char is not in vehicle or on a mount!"))
  4907. {
  4908. CTask* pControlVehicleTask = pPed->GetPedIntelligence()->FindTaskPrimaryByType( CTaskTypes::TASK_CONTROL_VEHICLE );
  4909. CTask* pCurrent=pPed->GetPedIntelligence()->GetTaskAtPriority(PED_TASK_PRIORITY_PRIMARY);
  4910. if(pCurrent && pCurrent->GetTaskType()==CTaskTypes::TASK_VEHICLE_GUN)
  4911. {
  4912. CTaskVehicleGun* pTaskDriveBy=(CTaskVehicleGun*)pCurrent;
  4913. if(pTaskDriveBy->GetTarget().GetEntity()==pSecondPed)
  4914. {
  4915. bAlreadydoingDriveBy=true;
  4916. }
  4917. }
  4918. else if( bPushUnderneathDrivingTaskIfDriving && pControlVehicleTask )
  4919. {
  4920. CTaskControlVehicle* pTaskControlVehicle=static_cast<CTaskControlVehicle*>(pControlVehicleTask);
  4921. pTask = rage_new CTaskVehicleGun(CTaskVehicleGun::Mode_Fire,uFiringPattern,&target,((float)iFrequencyPercentage)/100.0f,fAbortRange);
  4922. pTaskControlVehicle->SetDesiredSubtask(pTask);
  4923. bAlreadydoingDriveBy=true;
  4924. }
  4925. else if(onMount && bPushUnderneathDrivingTaskIfDriving)
  4926. {
  4927. CTaskComplexControlMovement* pControlTask = static_cast<CTaskComplexControlMovement*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_COMPLEX_CONTROL_MOVEMENT));
  4928. if(pControlTask)
  4929. {
  4930. const int existingSubTask = pControlTask->GetMainSubTaskType();
  4931. if(existingSubTask == CTaskTypes::TASK_NONE || existingSubTask == CTaskTypes::TASK_VEHICLE_GUN)
  4932. {
  4933. pTask = rage_new CTaskVehicleGun(CTaskVehicleGun::Mode_Fire,uFiringPattern,&target,((float)iFrequencyPercentage)/100.0f,fAbortRange);
  4934. pControlTask->SetNewMainSubtask(pTask);
  4935. bAlreadydoingDriveBy=true;
  4936. }
  4937. // Note: not entirely sure what to do in the case of there being a subtask that's something
  4938. // else than CTaskVehicleGun. Now, it would still give you the driveby task, but running as the
  4939. // main task. This seems consistent with the vehicle case and is probably acceptable.
  4940. }
  4941. }
  4942. }
  4943. }
  4944. }
  4945.  
  4946. if(!bAlreadydoingDriveBy)
  4947. {
  4948. pTask = rage_new CTaskVehicleGun(CTaskVehicleGun::Mode_Fire,uFiringPattern,&target,((float)iFrequencyPercentage)/100.0f,fAbortRange);
  4949. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_DRIVE_BY, "TASK_DRIVE_BY");
  4950. }
  4951. }
  4952.  
  4953. void CommandSetDriveByTarget(int iPedID, int iOtherPedID, int iTargetVehicleID, const scrVector & scrVecCoors)
  4954. {
  4955. if( SCRIPT_VERIFY( NULL_IN_SCRIPTING_LANGUAGE != iPedID, "SET_DRIVERBY_TASK_TARGET - Can't have a NULL ped" ) )
  4956. {
  4957. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>( iPedID );
  4958. if( pPed )
  4959. {
  4960. // Determine the type of target to update
  4961. const CEntity *pTargetEntity = NULL;
  4962.  
  4963. // Ped target
  4964. if( iOtherPedID != NULL_IN_SCRIPTING_LANGUAGE )
  4965. {
  4966. if( !SCRIPT_VERIFY( iTargetVehicleID == NULL_IN_SCRIPTING_LANGUAGE, "SET_DRIVERBY_TASK_TARGET - Can't have a target ped and a target car" ) )
  4967. return;
  4968.  
  4969. const CPed* pTargetPed = CTheScripts::GetEntityToQueryFromGUID<CPed>( iOtherPedID );
  4970. if( !SCRIPT_VERIFY( pTargetPed, "SET_DRIVERBY_TASK_TARGET - Target ped doesn't exist" ) )
  4971. return;
  4972.  
  4973. pTargetEntity = pTargetPed;
  4974. }
  4975.  
  4976. // Vehicle target
  4977. if( iTargetVehicleID != NULL_IN_SCRIPTING_LANGUAGE )
  4978. {
  4979. const CVehicle *pTargetVehicle = CTheScripts::GetEntityToQueryFromGUID<CVehicle>( iTargetVehicleID );
  4980. if( !SCRIPT_VERIFY( pTargetVehicle, "SET_DRIVERBY_TASK_TARGET - Target vehicle doesn't exist" ) )
  4981. return;
  4982.  
  4983. pTargetEntity = pTargetVehicle;
  4984. }
  4985.  
  4986. // Set the target
  4987. const Vector3 vTargetCoords( scrVecCoors );
  4988.  
  4989. // Check the gun task
  4990. aiTask* pGunTaskBase = pPed->GetPedIntelligence()->FindTaskActiveByType( CTaskTypes::TASK_GUN );
  4991. if( pGunTaskBase )
  4992. {
  4993. CWeaponTarget target;
  4994. if( pTargetEntity )
  4995. target.SetEntityAndOffset( pTargetEntity, vTargetCoords );
  4996. else
  4997. target.SetPosition( vTargetCoords );
  4998.  
  4999. static_cast<CTaskGun*>(pGunTaskBase)->SetTarget( target );
  5000. }
  5001.  
  5002. // Check vehicle gun task just in case
  5003. aiTask* pVehicleGunTaskBase = pPed->GetPedIntelligence()->FindTaskActiveByType( CTaskTypes::TASK_VEHICLE_GUN );
  5004. if( pVehicleGunTaskBase )
  5005. {
  5006. if( pTargetEntity )
  5007. static_cast<CTaskVehicleGun*>(pVehicleGunTaskBase)->SetTarget( pTargetEntity, &vTargetCoords );
  5008. else
  5009. static_cast<CTaskVehicleGun*>(pVehicleGunTaskBase)->SetTargetPosition( vTargetCoords );
  5010. }
  5011.  
  5012. Assertf( pGunTaskBase || pVehicleGunTaskBase, "SET_DRIVERBY_TASK_TARGET - Native function invoked but ped has no gun or vehicle gun task." );
  5013. }
  5014. }
  5015. }
  5016.  
  5017. void CommandClearDrivebyTaskUnderneathDrivingTask(int iPedID)
  5018. {
  5019.  
  5020. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  5021. if(pPed)
  5022. {
  5023. bool inVehicle = pPed->GetPedConfigFlag( CPED_CONFIG_FLAG_InVehicle );
  5024. bool onMount = (pPed->GetMyMount() != NULL);
  5025. if(SCRIPT_VERIFY(inVehicle || onMount, "CLEAR_DRIVEBY_TASK_UNDERNEATH_DRIVING_TASK: char is not in vehicle or on a mount!"))
  5026. {
  5027. CTask* pCurrent=pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_CONTROL_VEHICLE );
  5028. if( pCurrent )
  5029. {
  5030. CTaskControlVehicle* pTaskControlVehicle=static_cast<CTaskControlVehicle*>(pCurrent);
  5031. if( scriptVerifyf( pTaskControlVehicle->GetDesiredSubtask() && pTaskControlVehicle->GetDesiredSubtask()->GetTaskType() == CTaskTypes::TASK_VEHICLE_GUN, "CLEAR_DRIVEBY_TASK_UNDERNEATH_DRIVING_TASK no driveby task running, use IS_DRIVEBY_TASK_UNDERNEATH_DRIVING_TASK" ) )
  5032. {
  5033. pTaskControlVehicle->SetDesiredSubtask(NULL);
  5034. }
  5035. }
  5036. else if(onMount)
  5037. {
  5038. CTaskComplexControlMovement* pControlTask = static_cast<CTaskComplexControlMovement*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_COMPLEX_CONTROL_MOVEMENT));
  5039. if(pControlTask)
  5040. {
  5041. const int existingSubTask = pControlTask->GetMainSubTaskType();
  5042. if(existingSubTask == CTaskTypes::TASK_VEHICLE_GUN)
  5043. {
  5044. pControlTask->SetNewMainSubtask(NULL);
  5045. }
  5046. }
  5047. }
  5048. }
  5049. }
  5050. }
  5051.  
  5052. bool CommandIsDrivebyTaskUnderneathDrivingTask(int iPedID)
  5053. {
  5054. const CPed *pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedID);
  5055. if(pPed)
  5056. {
  5057. bool inVehicle = pPed->GetPedConfigFlag( CPED_CONFIG_FLAG_InVehicle );
  5058. bool onMount = (pPed->GetMyMount() != NULL);
  5059. if(SCRIPT_VERIFY(inVehicle || onMount, "IS_DRIVEBY_TASK_UNDERNEATH_DRIVING_TASK: char is not in vehicle or on a mount!"))
  5060. {
  5061. CTask* pCurrent=pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_CONTROL_VEHICLE);
  5062. if( pCurrent )
  5063. {
  5064. CTaskControlVehicle* pTaskControlVehicle=static_cast<CTaskControlVehicle*>(pCurrent);
  5065. return (pTaskControlVehicle->GetDesiredSubtask() && pTaskControlVehicle->GetDesiredSubtask()->GetTaskType() == CTaskTypes::TASK_VEHICLE_GUN);
  5066. }
  5067. else if(onMount)
  5068. {
  5069. CTaskComplexControlMovement* pControlTask = static_cast<CTaskComplexControlMovement*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_COMPLEX_CONTROL_MOVEMENT));
  5070. if(pControlTask)
  5071. {
  5072. const int existingSubTask = pControlTask->GetMainSubTaskType();
  5073. return existingSubTask == CTaskTypes::TASK_VEHICLE_GUN;
  5074. }
  5075. }
  5076. }
  5077. }
  5078. return false;
  5079. }
  5080.  
  5081. void CommandTaskUseMobilePhone( int iPedID, bool bUsePhone, int eDesiredPhoneMode )
  5082. {
  5083. if (bUsePhone)
  5084. {
  5085. if (NULL_IN_SCRIPTING_LANGUAGE != iPedID)
  5086. {
  5087. // pulled inside due to the NULL check
  5088. bool bShouldCreatePhoneTask = true;
  5089. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  5090. if (pPed)
  5091. {
  5092. CTask* pTask = (bShouldCreatePhoneTask ? pPed->GetPedIntelligence()->FindTaskActiveByTreeAndType(PED_TASK_TREE_SECONDARY, CTaskTypes::TASK_MOBILE_PHONE) : NULL);
  5093. if (pTask)
  5094. {
  5095. CTaskMobilePhone* pTaskMobilePhone = static_cast<CTaskMobilePhone*>(pTask);
  5096. pTaskMobilePhone->PutUpToEar();
  5097. bShouldCreatePhoneTask = false;
  5098. }
  5099.  
  5100. pTask = (bShouldCreatePhoneTask ? pPed->GetPedIntelligence()->FindTaskByType(CTaskTypes::TASK_MOTION_IN_COVER) : NULL);
  5101. if (pTask && pTask->GetTaskType() == CTaskTypes::TASK_MOTION_IN_COVER)
  5102. {
  5103. CTaskMotionInCover* pTaskCover = (CTaskMotionInCover*)pTask;
  5104. pTaskCover->ProcessUseMobilePhone(true); // Pick up phone
  5105. bShouldCreatePhoneTask = false;
  5106. }
  5107. }
  5108. if (bShouldCreatePhoneTask)
  5109. {
  5110. CTask* pTask = rage_new CTaskMobilePhone(CTaskMobilePhone::PhoneMode(eDesiredPhoneMode));
  5111. pPed->GetPedIntelligence()->AddTaskSecondary(pTask, PED_TASK_SECONDARY_PARTIAL_ANIM);
  5112. }
  5113. }
  5114. else
  5115. {
  5116. // We still have to try and send the task if this is called from script in a sequence.
  5117. CTask* pTask = rage_new CTaskMobilePhone(CTaskMobilePhone::PhoneMode(eDesiredPhoneMode), -1, false);
  5118. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_USE_MOBILE_PHONE, "TASK_USE_MOBILE_PHONE");
  5119. }
  5120. }
  5121. else
  5122. {
  5123. if(SCRIPT_VERIFY( NULL_IN_SCRIPTING_LANGUAGE != iPedID, "TASK_USE_MOBILE_PHONE( ped, FALSE ) Cannot be used in a sequence"))
  5124. {
  5125. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  5126. if (pPed)
  5127. {
  5128. CTask* pTask = pPed->GetPedIntelligence()->FindTaskActiveByTreeAndType(PED_TASK_TREE_SECONDARY, CTaskTypes::TASK_MOBILE_PHONE);
  5129. if (pTask)
  5130. {
  5131. CTaskMobilePhone* pTaskPhone = (CTaskMobilePhone*)pTask;
  5132. pTaskPhone->PutDownToPrevState();
  5133. }
  5134.  
  5135. // Make sure any mobile phone tasks in the event queue are removed.
  5136. for (s32 i = 0; i < pPed->GetPedIntelligence()->GetNumEventsInQueue(); i++)
  5137. {
  5138. CEvent* pEvent = pPed->GetPedIntelligence()->GetEventByIndex(i);
  5139. if (pEvent && pEvent->GetEventType() == EVENT_SCRIPT_COMMAND)
  5140. {
  5141. CEventScriptCommand* pEventScript = static_cast<CEventScriptCommand*>(pEvent);
  5142. if (pEventScript->GetTask() && pEventScript->GetTask()->GetTaskType() == CTaskTypes::TASK_MOBILE_PHONE)
  5143. {
  5144. pPed->GetPedIntelligence()->RemoveEvent(pEvent);
  5145. }
  5146. }
  5147. }
  5148. }
  5149. }
  5150. }
  5151. }
  5152.  
  5153. void CommandAddFollowNavmeshToPhoneTask( int iPedID, const scrVector & svTargetPos, float fMoveBlendRatio )
  5154. {
  5155. Assert(fMoveBlendRatio >= MOVEBLENDRATIO_WALK && fMoveBlendRatio <= MOVEBLENDRATIO_SPRINT);
  5156.  
  5157. Vector3 vTargetPos = svTargetPos;
  5158.  
  5159. if(SCRIPT_VERIFY( NULL_IN_SCRIPTING_LANGUAGE != iPedID, "ADD_FOLLOW_NAVMESH_TO_PHONE_TASK Cannot be used in a sequence"))
  5160. {
  5161. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  5162. if (pPed)
  5163. {
  5164. CTask* pTaskSecondary = pPed->GetPedIntelligence()->FindTaskActiveByTreeAndType(PED_TASK_TREE_SECONDARY, CTaskTypes::TASK_MOBILE_PHONE);
  5165. if(pTaskSecondary)
  5166. {
  5167. CTaskComplexControlMovement* pControlTask = static_cast<CTaskComplexControlMovement*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_COMPLEX_CONTROL_MOVEMENT));
  5168. if(pControlTask)
  5169. {
  5170. CTaskMoveFollowNavMesh * pNavMeshTask = rage_new CTaskMoveFollowNavMesh(fMoveBlendRatio, vTargetPos);
  5171. pNavMeshTask->SetIsScriptedRoute(true);
  5172. pControlTask->SetNewMoveTask(pNavMeshTask);
  5173. }
  5174. }
  5175. }
  5176. }
  5177. }
  5178.  
  5179. void CommandTaskUseMobilePhoneTimed( int iPedID, int iTime )
  5180. {
  5181. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0) ,"TASK_USE_MOBILE_PHONE_TIMED - Time must be -1 for infinite and > 0" ))
  5182. {
  5183. if (NULL_IN_SCRIPTING_LANGUAGE != iPedID)
  5184. {
  5185. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  5186.  
  5187. CTask* pTask = pPed->GetPedIntelligence()->FindTaskActiveByTreeAndType(PED_TASK_TREE_SECONDARY, CTaskTypes::TASK_MOBILE_PHONE);
  5188. if (!pTask)
  5189. {
  5190. pTask = rage_new CTaskMobilePhone(CTaskMobilePhone::Mode_ToCall, iTime);
  5191. pPed->GetPedIntelligence()->AddTaskSecondary(pTask, PED_TASK_SECONDARY_PARTIAL_ANIM);
  5192. }
  5193. else
  5194. {
  5195. // we already have one, just reset it
  5196. CTaskMobilePhone* pTaskMobilePhone = static_cast<CTaskMobilePhone*>(pTask);
  5197. pTaskMobilePhone->ResetTaskMobilePhone(CTaskMobilePhone::Mode_ToCall, iTime);
  5198. }
  5199. }
  5200. else
  5201. {
  5202. // We still have to try and send the task if this is called from script in a sequence.
  5203. CTask* pTask = rage_new CTaskMobilePhone(CTaskMobilePhone::Mode_ToCall, iTime, false);
  5204. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_USE_MOBILE_PHONE, "TASK_USE_MOBILE_PHONE_TIMED");
  5205. }
  5206. }
  5207. }
  5208.  
  5209. void CommandTaskUseWalkieTalkie( int UNUSED_PARAM(iPedID), const char* UNUSED_PARAM(szContext) )
  5210. {
  5211. scriptAssertf(0, "TASK_USE_WALKIE_TALKIE has been deprecated");
  5212. }
  5213.  
  5214. void CommandTaskCapturePed(int UNUSED_PARAM(iPedID), int UNUSED_PARAM(iOtherPedID), float UNUSED_PARAM(fCaptureTime), float UNUSED_PARAM(fTimeToQuestion))
  5215. {
  5216. scriptAssertf(0, "TASK_CAPTURE_PED is deprecated");
  5217. }
  5218.  
  5219. void CommandTaskAdvanceToTargetInLine(int iPedID, int iOtherPedID, const scrVector & svTargetLocation, float fDesiredDist, float fTimeToHoldAtEnd, int iFlags)
  5220. {
  5221. // If we aren't running this in a sequence, assert on the peds group
  5222. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedID);
  5223. if(pPed)
  5224. {
  5225. Assertf(pPed->GetPedsGroup(), "Ped running TASK_ADVANCE_TO_TARGET_IN_LINE must have a valid group");
  5226. }
  5227.  
  5228. // Get the other ped or location or both to determine the target type
  5229. CPed* pOtherPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iOtherPedID);
  5230. Vector3 vTargetLoc = svTargetLocation;
  5231.  
  5232. Assertf(pOtherPed || vTargetLoc.IsNonZero(), "Target must be a valid ped or a non-origin position");
  5233.  
  5234. CAITarget target;
  5235. if(pOtherPed)
  5236. {
  5237. target = vTargetLoc.IsZero() ? CAITarget(pOtherPed) : CAITarget(pOtherPed, vTargetLoc);
  5238. }
  5239. else
  5240. {
  5241. target = CAITarget(vTargetLoc);
  5242. }
  5243.  
  5244. // Create our new task and give it to the ped
  5245. CTask* pTask = rage_new CTaskSwatFollowInLine(target, fDesiredDist, fTimeToHoldAtEnd, iFlags);
  5246. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_ADVANCE_TO_TARGET_IN_LINE, "TASK_ADVANCE_TO_TARGET_IN_LINE");
  5247. }
  5248.  
  5249. void CommandSetChargeTargetEnabled(bool bEnabled)
  5250. {
  5251. CTaskCombat::ms_Tunables.m_ChargeTuning.m_bChargeTargetEnabled = bEnabled;
  5252. }
  5253.  
  5254. void CommandSetMaxNumActiveChargers(int iMaxActiveChargers)
  5255. {
  5256. if( SCRIPT_VERIFY(iMaxActiveChargers >= 0, "SET_MAX_NUM_ACTIVE_CHARGERS -- negative MAX_NUM_ACTIVE_CHARGERS requested") )
  5257. {
  5258. CTaskCombat::ms_Tunables.m_ChargeTuning.m_uMaxNumActiveChargers = (u8)iMaxActiveChargers;
  5259. }
  5260. }
  5261.  
  5262. void CommandSetMinTimeBetweenChargesAtSameTarget(float fMinTimeSeconds)
  5263. {
  5264. if( SCRIPT_VERIFY(fMinTimeSeconds >= 0.0f, "SET_MIN_TIME_BETWEEN_CHARGES_AT_SAME_TARGET -- negative MIN_TIME_SECONDS requested") )
  5265. {
  5266. CTaskCombat::ms_Tunables.m_ChargeTuning.m_uMinTimeBetweenChargesAtSameTargetMS = (u32)(fMinTimeSeconds * 1000.0f);
  5267. }
  5268. }
  5269.  
  5270. void CommandTaskChatToPed(int iPedID, int iOtherPedID, int iFlags, const scrVector & vGoToPos, float fHeadingDegs, float fIdleTime)
  5271. {
  5272. CPed* pOtherPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iOtherPedID);
  5273. if (pOtherPed)
  5274. {
  5275. // Convert the heading to radians, in the -PI..PI range.
  5276. float fHeading = CanonicalizeAngle(fHeadingDegs*DtoR);
  5277.  
  5278. CTask* pTask = rage_new CTaskChat(pOtherPed, iFlags, vGoToPos, fHeading, fIdleTime);
  5279. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_CHAT_TO_PED, "TASK_CHAT_TO_PED");
  5280. }
  5281. }
  5282.  
  5283. bool CommandIsChattingPedInPosition(int iPedID)
  5284. {
  5285. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedID);
  5286.  
  5287. if(pPed)
  5288. {
  5289. CTask* pTask = pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_CHAT);
  5290. if (pTask && static_cast<CTaskChat*>(pTask)->IsInPosition())
  5291. {
  5292. return true;
  5293. }
  5294. }
  5295. return false;
  5296. }
  5297.  
  5298. bool CommandIsChattingPedPlayingAnim(int iPedID)
  5299. {
  5300. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedID);
  5301.  
  5302. if(pPed)
  5303. {
  5304. CTask* pTask = pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_CHAT);
  5305. if (pTask && static_cast<CTaskChat*>(pTask)->IsPlayingClip())
  5306. {
  5307. return true;
  5308. }
  5309. }
  5310. return false;
  5311. }
  5312.  
  5313. void CommandMakeChattingPedPlayAnim(int UNUSED_PARAM(iPedID), const char *UNUSED_PARAM(pAnimDictName), const char *UNUSED_PARAM(pAnimName), float UNUSED_PARAM(fBlendInDelta), int UNUSED_PARAM(nTimeToPlay), int UNUSED_PARAM(nControlFlags))
  5314. {
  5315. // GSALES - killing this so I can get rid of the old anim control flag stuff. It doesn't seem to be used anywhere any more.
  5316. scriptAssertf(0, "MAKE_CHATTING_PED_PLAY_ANIM - This command is deprecated. See an animation programmer.");
  5317. }
  5318.  
  5319. void CommandMakeChattingPedLeave(int iPedID, bool bPlayGoodByeGestures)
  5320. {
  5321. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  5322.  
  5323. if(pPed)
  5324. {
  5325. CTask* pTask = pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_CHAT);
  5326. if (pTask)
  5327. {
  5328. static_cast<CTaskChat*>(pTask)->LeaveChat(bPlayGoodByeGestures);
  5329. }
  5330. }
  5331. }
  5332.  
  5333. enum {
  5334. MOBILE_SUB_TASK_PHONE_IN,
  5335. MOBILE_SUB_TASK_PHONE_TALK,
  5336. MOBILE_SUB_TASK_PHONE_OUT,
  5337. MOBILE_SUB_TASK_PHONE_OTHER
  5338. };
  5339.  
  5340. bool CommandGetMobilePhoneTaskSubTask( int iPedID, int &ReturnSubTask)
  5341. {
  5342. const CPed *pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedID);
  5343. if(pPed)
  5344. {
  5345. ReturnSubTask = MOBILE_SUB_TASK_PHONE_IN;
  5346. CTaskComplexUseMobilePhone *pTaskUseMobile = (CTaskComplexUseMobilePhone*)pPed->GetPedIntelligence()->FindTaskByType(CTaskTypes::TASK_COMPLEX_USE_MOBILE_PHONE);
  5347.  
  5348. // Assertf(pTaskUseMobile, "%s:GET_MOBILE_PHONE_TASK_SUB_TASK - ped is not performing the mobile phone task", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  5349. if (pTaskUseMobile)
  5350. {
  5351. CTask *pSubTask = pTaskUseMobile->GetSubTask();
  5352.  
  5353. if (pSubTask)
  5354. {
  5355. switch (pSubTask->GetTaskType())
  5356. {
  5357. case CTaskTypes::TASK_SIMPLE_PHONE_IN:
  5358. ReturnSubTask = MOBILE_SUB_TASK_PHONE_IN;
  5359. break;
  5360. case CTaskTypes::TASK_SIMPLE_PHONE_TALK:
  5361. ReturnSubTask = MOBILE_SUB_TASK_PHONE_TALK;
  5362. break;
  5363. case CTaskTypes::TASK_SIMPLE_PHONE_OUT:
  5364. ReturnSubTask = MOBILE_SUB_TASK_PHONE_OUT;
  5365. break;
  5366. default: // return the same value for all other sub task types?
  5367. ReturnSubTask = MOBILE_SUB_TASK_PHONE_OTHER;
  5368. break;
  5369. }
  5370. }
  5371.  
  5372. return true;
  5373. }
  5374.  
  5375. // if the ped isn't performing TASK_COMPLEX_USE_MOBILE_PHONE then ReturnSubTask will be MOBILE_SUB_TASK_PHONE_IN
  5376. }
  5377. return false;
  5378. }
  5379.  
  5380. void CommandTaskWarpPedIntoVehicle( int iPedID, int iVehicleID, int iSeat )
  5381. {
  5382. scriptAssertf(!NetworkInterface::IsGameInProgress(), "%s:TASK_WARP_PED_INTO_VEHICLE is not safe in network games! Use TASK_ENTER_VEHICLE with the warp flag set instead!", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  5383.  
  5384. CVehicle *pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID);
  5385.  
  5386. if(pVehicle)
  5387. {
  5388. s32 iSeatIndex = iSeat+1;
  5389.  
  5390. if( iSeatIndex == -1 )
  5391. {
  5392. // If -2 is passed in, we should put the ped into any passenger seat
  5393. for (s32 seatIndex=1; seatIndex<pVehicle->GetSeatManager()->GetMaxSeats(); seatIndex++)
  5394. {
  5395. if (!pVehicle->GetSeatManager()->GetPedInSeat(seatIndex))
  5396. {
  5397. iSeatIndex = seatIndex;
  5398. break;
  5399. }
  5400. }
  5401.  
  5402. if (!SCRIPT_VERIFY(iSeatIndex != -1, "TASK_WARP_PED_INTO_VEHICLE - Couldn't find free passenger seat to put ped in"))
  5403. return;
  5404. }
  5405.  
  5406. if( iSeatIndex != -1 )
  5407. {
  5408. if(!SCRIPT_VERIFY((iSeatIndex < pVehicle->GetSeatManager()->GetMaxSeats()), "TASK_WARP_PED_INTO_VEHICLE - Seat number is too large"))
  5409. return;
  5410.  
  5411. if(!SCRIPT_VERIFY(!pVehicle->GetSeatManager()->GetPedInSeat(iSeatIndex), "TASK_WARP_PED_INTO_VEHICLE - Vehicle already has a passenger in the specified seat"))
  5412. return;
  5413. }
  5414.  
  5415. CTaskSetPedInVehicle* pTask=rage_new CTaskSetPedInVehicle(pVehicle, iSeatIndex, CPed::PVF_Warp);
  5416. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_WARP_PED_INTO_VEHICLE, "TASK_WARP_PED_INTO_VEHICLE");
  5417. }
  5418. }
  5419.  
  5420. // Warps a ped to a position on an entity with defined combination of limbs attached and sets the ped to ragdoll.
  5421. void CommandTaskNMAttachPedToEntity(int iPedID, int iEntityID, int iAttachParentBone, const scrVector & vOffset, const scrVector & vRotation, int iAttachFlags, const char* pAnimDict, const char * pGetOnAnimName, const char* pIdleAnimName, int RotOrder)
  5422. {
  5423. s32 animDictIndex;
  5424.  
  5425. CPhysical* pEntity = CTheScripts::GetEntityToModifyFromGUID<CPhysical>(iEntityID);
  5426.  
  5427. if(scriptVerifyf(!NetworkInterface::IsGameInProgress(), "TASK_NM_ATTACH_PED_TO_ENTITY - This script command is not allowed in network game scripts!"))
  5428. {
  5429. if(pEntity)
  5430. {
  5431. if(scriptVerifyf(fwAnimManager::GetClipIfExistsByName(pAnimDict, pGetOnAnimName), "Check that the dictionary: %s is loaded and the anim: %s is contained with the dictionary",pAnimDict ,pGetOnAnimName ))
  5432. {
  5433. if(scriptVerifyf(fwAnimManager::GetClipIfExistsByName(pAnimDict, pIdleAnimName), "Check that the dictionary: %s is loaded and the anim: %s is contained with the dictionary",pAnimDict ,pIdleAnimName))
  5434. {
  5435. animDictIndex = fwAnimManager::FindSlot(pAnimDict).Get();
  5436.  
  5437. Quaternion rotationQuaternion;
  5438. CScriptEulers::QuaternionFromEulers(rotationQuaternion, vRotation, static_cast<EulerAngleOrder>(RotOrder));
  5439.  
  5440. CTaskAnimatedAttach* pTaskAttach=rage_new CTaskAnimatedAttach(pEntity, iAttachParentBone, vOffset, rotationQuaternion, iAttachFlags, animDictIndex, atStringHash(pGetOnAnimName), atStringHash(pIdleAnimName) );
  5441. CScriptPeds::GivePedScriptedTask( iPedID, pTaskAttach, SCRIPT_TASK_NM_ATTACH_TO_VEHICLE, "TASK_NM_ATTACH_PED_TO_ENTITY");
  5442. }
  5443. }
  5444. }
  5445. }
  5446. }
  5447.  
  5448. void CommandTaskShootAtEntity( int iPedID, int iEntityID, int iTime, int iFiringPatternHash )
  5449. {
  5450. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0) ,"TASK_SHOOT_AT_ENTITY - Time must be -1 for infinite and > 0" ))
  5451. {
  5452. const CEntity *pEntity = CTheScripts::GetEntityToQueryFromGUID<CEntity>(iEntityID);
  5453. if(pEntity)
  5454. {
  5455. CTaskGun* pTaskGun = rage_new CTaskGun(CWeaponController::WCT_Fire, CTaskTypes::TASK_AIM_GUN_ON_FOOT, CWeaponTarget(pEntity), ((float) iTime) / 1000.0f);
  5456. pTaskGun->SetAllowRestartAfterAbort(true);
  5457. if(iFiringPatternHash)
  5458. {
  5459. pTaskGun->SetFiringPatternHash(iFiringPatternHash);
  5460. }
  5461. CScriptPeds::GivePedScriptedTask(iPedID, pTaskGun, SCRIPT_TASK_SHOOT_AT_ENTITY, "TASK_SHOOT_AT_ENTITY");
  5462.  
  5463. #if 0
  5464. // This block of code is an attempt to make this task work for a mounted ped, left in
  5465. // for reference. Was hoping that we could just use CTaskGun with CTaskAimGunVehicleDriveBy,
  5466. // but there were some complications. Basically, if we bypass CTaskVehicleGun, there is nothing
  5467. // streaming in the animations that CTaskAimGunVehicleDriveBy needs. If on the other hand
  5468. // we create a CTaskVehicleGun instead of CTaskGun, we probably won't have support for
  5469. // the time parameter. /FF
  5470.  
  5471. CTaskTypes::eTaskType aimTaskType = CTaskTypes::TASK_AIM_GUN_ON_FOOT;
  5472. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedID);
  5473. if(pPed && pPed->GetMyMount())
  5474. {
  5475. aimTaskType = CTaskTypes::TASK_AIM_GUN_VEHICLE_DRIVE_BY;
  5476. }
  5477.  
  5478. CTaskGun* pTaskGun = rage_new CTaskGun(CWeaponController::WCT_Fire, aimTaskType, CWeaponTarget(pEntity), ((float) iTime) / 1000.0f);
  5479.  
  5480. if(aimTaskType == CTaskTypes::TASK_AIM_GUN_VEHICLE_DRIVE_BY)
  5481. {
  5482. const CVehicleDriveByInfo* pDrivebyInfo = CVehicleMetadataMgr::GetVehicleDriveByInfoFromPed(pPed);
  5483. taskAssert(pDrivebyInfo);
  5484. const CVehicleDriveByAnimInfo* pAnimInfo = CVehicleMetadataMgr::GetDriveByAnimInfoForWeapon(pPed, pPed->GetWeaponManager()->GetEquippedWeaponHash());
  5485. pTaskGun->SetOverrideClipSetId(pAnimInfo->GetClipSet());
  5486. }
  5487. #endif
  5488. }
  5489. }
  5490. }
  5491.  
  5492. void CommandTaskClimb( int iPedID, bool UNUSED_PARAM(bUsePlayerLaunchForce) )
  5493. {
  5494. CTask* pTask = rage_new CTaskJumpVault(JF_ForceVault);
  5495. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_CLIMB, "TASK_CLIMB" );
  5496. }
  5497.  
  5498. void CommandTaskClimbLadder( int iPedID, bool bFast )
  5499. {
  5500. CTask *pTask=rage_new CTaskClimbLadderFully(bFast);
  5501. CScriptPeds::GivePedScriptedTask( iPedID,pTask, SCRIPT_TASK_CLIMB_LADDER, "TASK_CLIMB_LADDER");
  5502. }
  5503.  
  5504. void CommandTaskRappelDownWall( int iPedID, const scrVector & scrVecStartPos, const scrVector & scrVecRopeAnchorPos, float fDestinationHeight, int ropeID )
  5505. {
  5506. ropeManager* pRopeManager = CPhysics::GetRopeManager();
  5507. if( SCRIPT_VERIFY(pRopeManager, "Rope Manager doesn't exist or is damaged!") )
  5508. {
  5509. ropeInstance* pRope = pRopeManager->FindRope( ropeID );
  5510. if( scriptVerifyf(pRope, "Rope with ID: %d, doesn't exist or is damaged!", ropeID) )
  5511. {
  5512. Vector3 vStartPos(scrVecStartPos);
  5513. Vector3 vAnchorPos(scrVecRopeAnchorPos);
  5514. CTask *pTask = rage_new CTaskRappel(fDestinationHeight, vStartPos, vAnchorPos, ropeID, CLIP_SET_ID_INVALID);
  5515. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_RAPPEL_DOWN_WALL, "TASK_RAPPEL_DOWN_WALL");
  5516. }
  5517. }
  5518. }
  5519.  
  5520. void CommandTaskRappelDownWallUsingClipsetOverride(int iPedID, const scrVector & scrVecStartPos, const scrVector & scrVecRopeAnchorPos, float fDestinationHeight, int ropeID, const char* szOverrideRappelClipset, bool bSkipClimbOverWall)
  5521. {
  5522. ropeManager* pRopeManager = CPhysics::GetRopeManager();
  5523. if (SCRIPT_VERIFY(pRopeManager, "Rope Manager doesn't exist or is damaged!"))
  5524. {
  5525. ropeInstance* pRope = pRopeManager->FindRope(ropeID);
  5526. if (scriptVerifyf(pRope, "Rope with ID: %d, doesn't exist or is damaged!", ropeID))
  5527. {
  5528. if (szOverrideRappelClipset)
  5529. {
  5530. fwMvClipSetId setId(szOverrideRappelClipset);
  5531. if (SCRIPT_VERIFYF(fwClipSetManager::GetClipSet(setId) != NULL, "ClipSet %s did not exist. Are you sure it is in clip_sets.xml?", szOverrideRappelClipset))
  5532. {
  5533. Vector3 vStartPos(scrVecStartPos);
  5534. Vector3 vAnchorPos(scrVecRopeAnchorPos);
  5535. CTask *pTask = rage_new CTaskRappel(fDestinationHeight, vStartPos, vAnchorPos, ropeID, setId, bSkipClimbOverWall);
  5536. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_RAPPEL_DOWN_WALL, "TASK_RAPPEL_DOWN_WALL");
  5537. }
  5538. }
  5539. }
  5540. }
  5541. }
  5542.  
  5543. int CommandsGetTaskRappelDownWallState( int iPedID )
  5544. {
  5545. const CPed *pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedID);
  5546. if(pPed && pPed->GetPedIntelligence()->GetQueriableInterface()->IsTaskCurrentlyRunning(CTaskTypes::TASK_RAPPEL))
  5547. {
  5548. return pPed->GetPedIntelligence()->GetQueriableInterface()->GetStateForTaskType(CTaskTypes::TASK_RAPPEL);
  5549. }
  5550.  
  5551. return -1;
  5552. }
  5553.  
  5554. void CommandClearPedTasksImmediately(int iPedID)
  5555. {
  5556. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  5557.  
  5558. if(pPed)
  5559. {
  5560. pPed->SetPedResetFlag(CPED_RESET_FLAG_ScriptClearingPedTasks, true);
  5561. if(pPed->IsNetworkClone())
  5562. {
  5563. bool bClearTasksImmediately = true;
  5564. CClearPedTasksEvent::Trigger(pPed, bClearTasksImmediately);
  5565. }
  5566. else
  5567. {
  5568. AI_LOG_WITH_ARGS_IF_SCRIPT_OR_PLAYER_PED(pPed, "[Script] - Ped %s has had tasks cleared immediately by script %s\n", AILogging::GetDynamicEntityNameSafe(pPed), CTheScripts::GetCurrentScriptName());
  5569.  
  5570. // instantly blend out any remaining animation before the flush
  5571. pPed->GetMovePed().SwitchToAnimated(0, false, true);
  5572.  
  5573. pPed->GetPedIntelligence()->FlushImmediately(true);
  5574. pPed->SetIsCrouching(false);
  5575. pPed->StopAllMotion(true);
  5576.  
  5577. // B*2979918 - too late to change for SP, but don't clear the helmet in MP when clearing tasks. It should be managed separately
  5578. if (!NetworkInterface::IsGameInProgress())
  5579. {
  5580. if (pPed->GetHelmetComponent())
  5581. pPed->GetHelmetComponent()->DisableHelmet();
  5582. }
  5583.  
  5584. pPed->SetPedResetFlag( CPED_RESET_FLAG_IsDrowning, false );
  5585. }
  5586. pPed->SetTimeSincePedInWater(60.0f); //B* 1150689
  5587.  
  5588. #if __DEV
  5589. // Record the task in the debug list
  5590. static char stringName[] = "CLEAR_PED_TASKS_IMMEDIATELY";
  5591. pPed->GetPedIntelligence()->AddScriptHistoryString(stringName, stringName, CTheScripts::GetCurrentScriptName(), CTheScripts::GetCurrentGtaScriptThread()->GetThreadPC());
  5592. #endif
  5593. }
  5594. }
  5595.  
  5596. void CommandTaskPerformSequenceFromProgress( int iPedID, int iTaskIndex, int iProgress1, int iProgress2 )
  5597. {
  5598. const int iTaskID = GetActualSequenceId(iTaskIndex);
  5599. if(SCRIPT_VERIFY(iTaskID>=0 && iTaskID<CTaskSequences::MAX_NUM_SEQUENCE_TASKS, "TASK_PERFORM_SEQUENCE_FROM_PROGRESS - Sequence task ID too big"))
  5600. {
  5601. if(SCRIPT_VERIFY(!CTaskSequences::ms_bIsOpened[iTaskID], "TASK_PERFORM_SEQUENCE_FROM_PROGRESS - Sequence task is still open"))
  5602. {
  5603. if(SCRIPT_VERIFY(!CTaskSequences::ms_TaskSequenceLists[iTaskID].IsEmpty(), "TASK_PERFORM_SEQUENCE_FROM_PROGRESS - sequence task empty"))
  5604. {
  5605. if(SCRIPT_VERIFY(iProgress1>=0 && iProgress1<CTaskList::MAX_LIST_SIZE, "TASK_PERFORM_SEQUENCE_FROM_PROGRESS - Sequence task ID too big"))
  5606. {
  5607. if(SCRIPT_VERIFY(iProgress2<CTaskList::MAX_LIST_SIZE, "TASK_PERFORM_SEQUENCE_FROM_PROGRESS - Sequence task ID too big"))
  5608. {
  5609. CTaskUseSequence* pTask=rage_new CTaskUseSequence(iTaskID, iTaskIndex);
  5610. pTask->SetProgress((u32)iProgress1,iProgress2);
  5611. CScriptPeds::GivePedScriptedTask( iPedID,pTask, SCRIPT_TASK_PERFORM_SEQUENCE_FROM_PROGRESS, "TASK_PERFORM_SEQUENCE_FROM_PROGRESS");
  5612. }
  5613. }
  5614. }
  5615. }
  5616. }
  5617. }
  5618.  
  5619. float CommandGetPedDesiredMoveBlendRatio( int iPedIndex )
  5620. {
  5621. const CPed *pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex);
  5622.  
  5623. if (pPed)
  5624. {
  5625. return pPed->GetMotionData()->GetDesiredMbrY();
  5626. }
  5627. return 0;
  5628. }
  5629.  
  5630. void CommandSetNextDesiredMoveState( float /*NextMoveState*/ )
  5631. {
  5632. scriptAssertf(0, "%s:SET_NEXT_DESIRED_MOVE_STATE - Function is deprecated - do not use anymore", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  5633. }
  5634.  
  5635. void CommandSetPedDesiredMoveBlendRatio( int iPedID, float fNewMoveBlendRatio )
  5636. {
  5637. if(!scriptVerifyf(fNewMoveBlendRatio >= MOVEBLENDRATIO_STILL && fNewMoveBlendRatio <= MOVEBLENDRATIO_SPRINT, "SET_PED_DESIRED_MOVE_BLEND_RATIO - move blend ratio %f out of range (%.2f:%.2f)", fNewMoveBlendRatio, MOVEBLENDRATIO_STILL, MOVEBLENDRATIO_SPRINT))
  5638. {
  5639. fNewMoveBlendRatio = Clamp(fNewMoveBlendRatio, MOVEBLENDRATIO_STILL, MOVEBLENDRATIO_SPRINT);
  5640. }
  5641.  
  5642. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  5643.  
  5644. if(pPed)
  5645. {
  5646. //Assertf(fMoveBlendRatio >= MOVEBLENDRATIO_STILL && fMoveBlendRatio <= MOVEBLENDRATIO_SPRINT, "MODIFY_PED_MOVE_BLEND_RATIO - Ratio must be between 0..3 inclusive");
  5647.  
  5648. // Generally speaking we will want to look for the control-movement task in the primary (script) slot.
  5649. // However there's an exception to this rule : if the ped is in a group, they may be entering a vehicle
  5650. // via a task which has been given them in response to CEventLeaderEnteredCarAsDriver (etc), in which
  5651. // case we will want to find the control movement in the TASK_PRIORITY_EVENT_RESPONSE_NONTEMP slot.
  5652. CTaskComplexControlMovement * pCtrlMove = NULL;
  5653.  
  5654. CPedIntelligence * pPedAi = pPed->GetPedIntelligence();
  5655. const int iTaskPriority = pPedAi->GetTaskManager()->GetActiveTaskPriority(PED_TASK_TREE_PRIMARY);
  5656.  
  5657. if(pPed->GetPedsGroup()!=NULL && iTaskPriority==PED_TASK_PRIORITY_EVENT_RESPONSE_NONTEMP
  5658. && pPedAi->GetCurrentEventType()==EVENT_LEADER_ENTERED_CAR_AS_DRIVER)
  5659. {
  5660. pCtrlMove = (CTaskComplexControlMovement*)pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_COMPLEX_CONTROL_MOVEMENT);
  5661. }
  5662. else
  5663. {
  5664. pCtrlMove = (CTaskComplexControlMovement*)pPed->GetPedIntelligence()->FindTaskPrimaryByType(CTaskTypes::TASK_COMPLEX_CONTROL_MOVEMENT);
  5665. }
  5666. if(!pCtrlMove)
  5667. {
  5668. return;
  5669. }
  5670.  
  5671. CTask * pRunningMoveTask = pCtrlMove->GetRunningMovementTask(pPed);
  5672. CTask * pBackUpMoveTask = pCtrlMove->GetBackupCopyOfMovementSubtask();
  5673.  
  5674. if(pRunningMoveTask)
  5675. {
  5676. Assert(pRunningMoveTask->IsMoveTask());
  5677. pRunningMoveTask->PropagateNewMoveSpeed(fNewMoveBlendRatio);
  5678. }
  5679. if(pBackUpMoveTask)
  5680. {
  5681. Assert(pBackUpMoveTask->IsMoveTask());
  5682. pBackUpMoveTask->PropagateNewMoveSpeed(fNewMoveBlendRatio);
  5683. }
  5684. }
  5685. }
  5686.  
  5687. void CommandTaskGotoEntityAiming( int iPedID, int iEntityID, float fSeekRadius, float fAimRadius )
  5688. {
  5689. CTask *pTask;
  5690. const CEntity* pEntity = CTheScripts::GetEntityToQueryFromGUID<CEntity>(iEntityID);
  5691. if(pEntity)
  5692. {
  5693. Assert(fAimRadius>=fSeekRadius);
  5694. pTask=rage_new CTaskSeekEntityAiming(pEntity,fSeekRadius,fAimRadius);
  5695. CScriptPeds::GivePedScriptedTask( iPedID,pTask, SCRIPT_TASK_GOTO_ENTITY_AIMING, "TASK_GOTO_ENTITY_AIMING");
  5696. }
  5697. }
  5698.  
  5699. void CommandTaskSetDecisionMaker( int iPedID, int iDecisionMakerId )
  5700. {
  5701. if(SCRIPT_VERIFY(iDecisionMakerId != NULL_IN_SCRIPTING_LANGUAGE, "TASK_SET_DECISION_MAKER - NULL passed for decision maker, or variable not initialised"))
  5702. {
  5703. if(NULL_IN_SCRIPTING_LANGUAGE!=iPedID)
  5704. {
  5705. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  5706. if(pPed)
  5707. {
  5708. if(SCRIPT_VERIFY(pPed->IsPlayer() == false, "TASK_SET_PED_DECISION_MAKER - Can't change a player's decision maker"))
  5709. {
  5710. pPed->GetPedIntelligence()->SetDecisionMakerId(iDecisionMakerId);
  5711. }
  5712. }
  5713. }
  5714. else
  5715. {
  5716. CTask* pTask=rage_new CTaskSetCharDecisionMaker(iDecisionMakerId);
  5717. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_SET_PED_DECISION_MAKER, "TASK_SET_DECISION_MAKER");
  5718. }
  5719. }
  5720. }
  5721.  
  5722. void SetPedDefensiveIfNeeded( CPed* pPed )
  5723. {
  5724. if(pPed)
  5725. {
  5726. // If our ped is set as will advance movement then change it to defensive
  5727. CCombatBehaviour& pedCombatBehaviour = pPed->GetPedIntelligence()->GetCombatBehaviour();
  5728. if(pedCombatBehaviour.GetCombatMovement() == CCombatData::CM_WillAdvance)
  5729. {
  5730. pedCombatBehaviour.SetCombatMovement(CCombatData::CM_Defensive);
  5731. }
  5732. }
  5733. }
  5734.  
  5735. void CommandTaskSetSphereDefensiveArea(int iPedID, const scrVector & scrVecCenter, float fRadius )
  5736. {
  5737. Vector3 vCenter(scrVecCenter);
  5738.  
  5739. if(NULL_IN_SCRIPTING_LANGUAGE != iPedID)
  5740. {
  5741. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  5742. if (pPed)
  5743. {
  5744. pPed->GetPedIntelligence()->GetDefensiveAreaManager()->GetPrimaryDefensiveArea()->SetAsSphere( vCenter, fRadius, NULL );
  5745. SetPedDefensiveIfNeeded(pPed);
  5746. }
  5747. }
  5748. else
  5749. {
  5750. CTask* pTask = rage_new CTaskSetPedDefensiveArea(vCenter, fRadius);
  5751. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_SET_PED_DEFENSIVE_AREA, "TASK_SET_PED_SPHERE_DEFENSIVE_AREA");
  5752. }
  5753. }
  5754.  
  5755. void CommandTaskClearDefensiveArea(int iPedID)
  5756. {
  5757. bool bGivePedTask = true;
  5758.  
  5759. if(NULL_IN_SCRIPTING_LANGUAGE != iPedID)
  5760. {
  5761. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  5762. if (pPed && !pPed->IsNetworkClone())
  5763. {
  5764. pPed->GetPedIntelligence()->GetDefensiveAreaManager()->GetPrimaryDefensiveArea()->Reset();
  5765. bGivePedTask = false;
  5766. }
  5767. }
  5768.  
  5769. if(bGivePedTask)
  5770. {
  5771. CTask* pTask = rage_new CTaskSetPedDefensiveArea();
  5772. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_SET_PED_DEFENSIVE_AREA, "TASK_CLEAR_DEFENSIVE_AREA");
  5773. }
  5774. }
  5775.  
  5776. void CommandTaskPedSlideToCoordWithHeadingChangeRate(int iPedID, const scrVector & scrVecCoors, float fHeadingDegs, float fSpeed, float fHdgChangeRate)
  5777. {
  5778. while(fHeadingDegs < 0.0f) fHeadingDegs += 360.0f;
  5779. while(fHeadingDegs >= 360.0f) fHeadingDegs -= 360.0f;
  5780. const float heading=( DtoR * fHeadingDegs);
  5781. float speed=fSpeed;
  5782. if(speed<0)
  5783. {
  5784. speed=0.1f;
  5785. }
  5786. Vector3 v(scrVecCoors);
  5787.  
  5788. #if __DEV
  5789. if(NULL_IN_SCRIPTING_LANGUAGE != iPedID)
  5790. {
  5791. const CPed *pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedID);
  5792. if(pPed)
  5793. scriptAssertf(DistSquared(RCC_VEC3V(v), pPed->GetTransform().GetPosition()).Getf() < 100.0f, "TASK_PED_SLIDE_TO_COORD_HDG_RATE is moving a ped over 10m.");
  5794. }
  5795. #endif
  5796.  
  5797. static dev_float fTargetRadius = 0.125f; //CTaskMoveGoToPointAndStandStill::ms_fTargetRadius;
  5798.  
  5799. CTaskSequenceList* pTaskList = rage_new CTaskSequenceList();
  5800. CTaskMoveGoToPointAndStandStill * pGotoTask = rage_new CTaskMoveGoToPointAndStandStill(MOVEBLENDRATIO_WALK, v, fTargetRadius);
  5801. pTaskList->AddTask(rage_new CTaskComplexControlMovement(pGotoTask));
  5802.  
  5803. CTaskSlideToCoord * pTaskSlide = rage_new CTaskSlideToCoord(v,heading,speed);
  5804. pTaskSlide->SetHeadingIncrement( ( DtoR * fHdgChangeRate) );
  5805. pTaskList->AddTask(pTaskSlide);
  5806. CScriptPeds::GivePedScriptedTask( iPedID, pTaskList, SCRIPT_TASK_PED_SLIDE_TO_COORD, "TASK_PED_SLIDE_TO_COORD_HDG_RATE");
  5807. }
  5808.  
  5809. void CommandTaskPedSlideToCoord(int iPedID, const scrVector & scrVecCoors, float fHeadingDegs, float fSpeed)
  5810. {
  5811. CommandTaskPedSlideToCoordWithHeadingChangeRate(iPedID, scrVecCoors, fHeadingDegs, fSpeed, 0.0f);
  5812. }
  5813.  
  5814. //This command is not called by any include_command.sch but needs to be incorporated into CommandTaskPedSlideToCoordAndPlayAnim
  5815. void CommandTaskPedSlideToCoordAndPlayAnimWithHeadingChangeRate( int iPedID,
  5816. const scrVector & scrVecCoors,
  5817. float fHeadingDegrees, float fSpeed,
  5818. const char* AnimName, const char* AnimDictName,
  5819. float fBlendDelta,
  5820. bool bLooped, bool bExtractBackwardsVelocity, bool bExtractSidewaysVelocity, bool bHoldOnLastFrame,
  5821. int iTime, float fHdgChangeRate)
  5822. {
  5823. while(fHeadingDegrees < 0.0f) fHeadingDegrees += 360.0f;
  5824. while(fHeadingDegrees >= 360.0f) fHeadingDegrees -= 360.0f;
  5825. const float heading=( DtoR * fHeadingDegrees);
  5826. float speed=fSpeed;
  5827. if(speed<0)
  5828. {
  5829. speed=0.1f;
  5830. }
  5831. s32 flags = 0;
  5832. if ( bLooped || (iTime > 0) )
  5833. {
  5834. flags |= APF_ISLOOPED;
  5835. }
  5836. if (bExtractBackwardsVelocity)
  5837. {
  5838. //flags |= APF_CANEXTRACTYVELOCITY; //These flags no longer exist: GS 09/12/2009
  5839. }
  5840. if (bHoldOnLastFrame == false)
  5841. {
  5842. flags |= APF_ISFINISHAUTOREMOVE;
  5843. }
  5844. if (bExtractSidewaysVelocity)
  5845. {
  5846. //scriptAssertf(bExtractBackwardsVelocity, "%s:TASK_PLAY_ANIM - If you want to extract sideways velocity you have to extract forwards velocity too", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  5847. //flags |= APF_CANEXTRACTXVELOCITY; //These flags no longer exist: GS 09/12/2009
  5848. }
  5849. bool bRunInSequence=false;
  5850. if(CTaskSequences::ms_iActiveSequence>=0)
  5851. {
  5852. bRunInSequence=true;
  5853. }
  5854. Vector3 v(scrVecCoors);
  5855.  
  5856. #if __DEV
  5857. const CPed *pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedID);
  5858. if(pPed)
  5859. scriptAssertf(DistSquared(RCC_VEC3V(v), pPed->GetTransform().GetPosition()).Getf() < 100.0f, "TASK_PED_SLIDE_TO_COORD_HDG_RATE is moving a ped over 10m.");
  5860. #endif
  5861.  
  5862. static dev_float fTargetRadius = 0.125f; //CTaskMoveGoToPointAndStandStill::ms_fTargetRadius;
  5863.  
  5864. CTaskSequenceList* pTaskList = rage_new CTaskSequenceList();
  5865.  
  5866. // JB: Slightly larger target radius, since peds were occasionally overshooting their target & then sliding back
  5867. CTaskMoveGoToPointAndStandStill * pTaskGoto = rage_new CTaskMoveGoToPointAndStandStill(MOVEBLENDRATIO_WALK, v, fTargetRadius);
  5868. pTaskList->AddTask(rage_new CTaskComplexControlMovement(pTaskGoto) );
  5869.  
  5870. CTaskSlideToCoord * pTaskSlide;
  5871.  
  5872. if (iTime > 0)
  5873. {
  5874. pTaskSlide = rage_new CTaskSlideToCoord(v,heading,speed,AnimName,AnimDictName,flags,fBlendDelta,bRunInSequence,iTime);
  5875. }
  5876. else
  5877. {
  5878. pTaskSlide = rage_new CTaskSlideToCoord(v,heading,speed,AnimName,AnimDictName,flags,fBlendDelta,bRunInSequence);
  5879. }
  5880. pTaskSlide->SetHeadingIncrement( ( DtoR * fHdgChangeRate) );
  5881.  
  5882. pTaskList->AddTask(pTaskSlide);
  5883.  
  5884. CScriptPeds::GivePedScriptedTask( iPedID, pTaskList, SCRIPT_TASK_PED_SLIDE_TO_COORD_AND_PLAY_ANIM, "TASK_PED_SLIDE_TO_COORD_AND_PLAY_ANIM_HDG_RATE");
  5885. }
  5886.  
  5887. void CommandTaskPedSlideToCoordAndPlayAnim(
  5888. int iPedID,
  5889. const scrVector & scrVecCoors,
  5890. float fHeadingDegrees, float fSpeed,
  5891. const char* AnimName, const char* AnimDictName,
  5892. float fBlendDelta,
  5893. bool bLooped, bool bExtractBackwardsVelocity, bool bExtractSidewaysVelocity, bool bHoldOnLastFrame,
  5894. int iTime)
  5895. {
  5896. CommandTaskPedSlideToCoordAndPlayAnimWithHeadingChangeRate(
  5897. iPedID, scrVecCoors, fHeadingDegrees, fSpeed, AnimName, AnimDictName, fBlendDelta, bLooped,
  5898. bExtractBackwardsVelocity, bExtractSidewaysVelocity, bHoldOnLastFrame, iTime, 0.0f);
  5899. }
  5900.  
  5901. void CommandTaskDrivePointRouteAdvanced( int iPedID, int iVehicleID, float fCruiseSpeed, int iMode, int VehicleModelHashKey, int iDrivingStyle)
  5902. {
  5903. CVehicle* pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  5904.  
  5905. if(pVehicle)
  5906. {
  5907. fwModelId VehicleModelId;
  5908. if (VehicleModelHashKey != DUMMY_ENTRY_IN_MODEL_ENUM_FOR_SCRIPTING_LANGUAGE)
  5909. {
  5910. CModelInfo::GetBaseModelInfoFromHashKey((u32) VehicleModelHashKey, &VehicleModelId); // ignores return value
  5911. scriptAssertf( VehicleModelId.IsValid(), "%s:TASK_DRIVE_POINT_ROUTE_ADVANCED - this is not a valid model index", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  5912. }
  5913. CTask* pTask=rage_new CTaskDrivePointRoute(pVehicle,CTaskMoveFollowPointRoute::ms_pointRoute,fCruiseSpeed,iMode,VehicleModelId.GetModelIndex(),7.0f,iDrivingStyle); // 7.0 was -1.0 (finished radius)
  5914. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_DRIVE_POINT_ROUTE_ADVANCED, "TASK_DRIVE_POINT_ROUTE_ADVANCED");
  5915. }
  5916. }
  5917.  
  5918.  
  5919. void CommandTaskGuardAssignedDefensiveArea(int iPedIndex, const scrVector & vDefendPosition, float fHeading, float fMaxPatrolProximity, int nTimer)
  5920. {
  5921. if (SCRIPT_VERIFY((nTimer == -1) || (nTimer > 0) ,"TASK_GUARD_ASSIGNED_DEFENSIVE_AREA - Time must be -1 for infinite and > 0" ))
  5922. {
  5923. Vector3 vDefendPosV3 = vDefendPosition;
  5924. float fNewPedHeading = fHeading;
  5925. float fTimer = ((float) nTimer)/1000.0f;
  5926.  
  5927. while (fNewPedHeading < 0.0f)
  5928. {
  5929. fNewPedHeading += 360.0f;
  5930. }
  5931. while (fNewPedHeading > 360.0f)
  5932. {
  5933. fNewPedHeading -= 360.0f;
  5934. }
  5935.  
  5936. CTask* pTask = rage_new CTaskStandGuard( vDefendPosV3, ( DtoR * fNewPedHeading), fMaxPatrolProximity, GM_PatrolDefensiveArea, fTimer);
  5937. CScriptPeds::GivePedScriptedTask(iPedIndex, pTask, SCRIPT_TASK_GUARD_DEFENSIVE_AREA, "TASK_GUARD_ASSIGNED_DEFENSIVE_AREA");
  5938. }
  5939. }
  5940.  
  5941.  
  5942. void CommandTaskGuardAngledDefensiveArea(int iPedIndex, const scrVector & vDefendPosition, float fHeading, float fMaxPatrolProximity, int iTime, const scrVector & sv1, const scrVector & sv2, float fDefensiveAreaWidth)
  5943. {
  5944. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0) ,"TASK_GUARD_ANGLED_DEFENSIVE_AREA - Time must be -1 for infinite and > 0" ))
  5945. {
  5946. scriptAssertf(fDefensiveAreaWidth >= CDefensiveArea::GetMinRadius(), "TASK_GUARD_ANGLED_DEFENSIVE_AREA - defensive area radius should be at least %.2f, but passed in - %.2f",CDefensiveArea::GetMinRadius(),fDefensiveAreaWidth);
  5947.  
  5948. Vector3 vDefendPosV3 = vDefendPosition;
  5949. float fNewPedHeading = fHeading;
  5950. float fTimer = ((float) iTime)/1000.0f;
  5951.  
  5952. if (fNewPedHeading < 0.0f)
  5953. {
  5954. fNewPedHeading += 360.0f;
  5955. }
  5956. if (fNewPedHeading > 360.0f)
  5957. {
  5958. fNewPedHeading -= 360.0f;
  5959. }
  5960.  
  5961. Vector3 v1 = sv1;
  5962. Vector3 v2 = sv2;
  5963.  
  5964. CDefensiveArea area;
  5965. area.Set(v1, v2, fDefensiveAreaWidth);
  5966.  
  5967. CTask* pTask = rage_new CTaskSetAndGuardArea( vDefendPosV3, ( DtoR * fNewPedHeading), fMaxPatrolProximity, GM_PatrolDefensiveArea, fTimer, area );
  5968. CScriptPeds::GivePedScriptedTask(iPedIndex, pTask, SCRIPT_TASK_GUARD_ANGLED_DEFENSIVE_AREA, "TASK_GUARD_ANGLED_DEFENSIVE_AREA");
  5969. }
  5970. }
  5971.  
  5972. void CommandTaskGuardSphereDefensiveArea(int iPedIndex, const scrVector & vDefendPosition, float fHeading, float fMaxPatrolProximity, int iTime, const scrVector & sv1, float fDefensiveAreaRadius)
  5973. {
  5974. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0) ,"TASK_GUARD_SPHERE_DEFENSIVE_AREA - Time must be -1 for infinite and > 0" ))
  5975. {
  5976. Vector3 v1 = sv1;
  5977.  
  5978. Vector3 vDefendPosV3 = vDefendPosition;
  5979. float fNewPedHeading = fHeading;
  5980. float fTimer = ((float) iTime)/1000.0f;
  5981.  
  5982. scriptAssertf(!vDefendPosV3.IsClose(VEC3_ZERO, SMALL_FLOAT), "TASK_GUARD_SPHERE_DEFENSIVE_AREA is tasking a ped to defend the origin. This is is very likely an error.");
  5983.  
  5984. scriptAssertf(fDefensiveAreaRadius >= CDefensiveArea::GetMinRadius(),"TASK_GUARD_SPHERE_DEFENSIVE_AREA - defensive area radius should be at least %.2f, but passed in - %.2f",CDefensiveArea::GetMinRadius(),fDefensiveAreaRadius);
  5985.  
  5986. if (fNewPedHeading < 0.0f)
  5987. {
  5988. fNewPedHeading += 360.0f;
  5989. }
  5990. if (fNewPedHeading > 360.0f)
  5991. {
  5992. fNewPedHeading -= 360.0f;
  5993. }
  5994.  
  5995. CDefensiveArea area;
  5996. area.SetAsSphere(v1, fDefensiveAreaRadius);
  5997.  
  5998. CTask* pTask = rage_new CTaskSetAndGuardArea( vDefendPosV3, ( DtoR * fNewPedHeading), fMaxPatrolProximity, GM_PatrolDefensiveArea, fTimer, area );
  5999. CScriptPeds::GivePedScriptedTask(iPedIndex, pTask, SCRIPT_TASK_GUARD_SPHERE_DEFENSIVE_AREA, "TASK_GUARD_SPHERE_DEFENSIVE_AREA");
  6000. }
  6001. }
  6002.  
  6003. void CommandTaskGuardCurrentPosition(int iPedIndex, float fMaxPatrolProximity, float fDefensiveAreaRadius, bool bSetDefensiveArea)
  6004. {
  6005. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex);
  6006.  
  6007. if (SCRIPT_VERIFY(pPed, "Invalid ped tasked with TASK_GUARD_CURRENT_POSITION"))
  6008. {
  6009. scriptAssertf(fDefensiveAreaRadius >= CDefensiveArea::GetMinRadius(),"TASK_GUARD_CURRENT_POSITION - defensive area radius should be at least %.2f, but passed in - %.2f",CDefensiveArea::GetMinRadius(),fDefensiveAreaRadius);
  6010.  
  6011. Vector3 vDefendPosV3 = VEC3V_TO_VECTOR3(pPed->GetTransform().GetPosition());
  6012. CDefensiveArea area;
  6013. area.SetAsSphere(vDefendPosV3, fDefensiveAreaRadius);
  6014. float fTimer = -1.0f;
  6015.  
  6016. eGuardMode guardMode = bSetDefensiveArea ? GM_PatrolDefensiveArea : GM_PatrolProximity;
  6017.  
  6018. CTask* pTask = rage_new CTaskSetAndGuardArea( vDefendPosV3, pPed->GetCurrentHeading(), fMaxPatrolProximity, guardMode, fTimer, area, true, bSetDefensiveArea );
  6019. CScriptPeds::GivePedScriptedTask(iPedIndex, pTask, SCRIPT_TASK_GUARD_CURRENT_POSITION, "TASK_GUARD_CURRENT_POSITION");
  6020. }
  6021. }
  6022.  
  6023. // Stand guard at a position
  6024. void CommandTaskStandGuard(int iPedIndex, const scrVector & vDefendPosition, float fHeading, const char* szContext)
  6025. {
  6026. Vector3 vDefendPosV3 = vDefendPosition;
  6027. float fNewPedHeading = fHeading;
  6028.  
  6029. fwAngle::LimitDegreeAngle(fNewPedHeading);
  6030.  
  6031. if (strcmp(szContext,"Default") == 0)
  6032. {
  6033. CTask* pTask = rage_new CTaskStandGuardFSM( vDefendPosV3, ( DtoR * fNewPedHeading));
  6034. CScriptPeds::GivePedScriptedTask(iPedIndex, pTask, SCRIPT_TASK_STAND_GUARD, "TASK_STAND_GUARD");
  6035. }
  6036. else
  6037. {
  6038.  
  6039. s32 scenarioType = CScenarioManager::GetScenarioTypeFromHashKey(atStringHash(szContext));
  6040. CTask* pTask = rage_new CTaskStandGuardFSM( vDefendPosV3, ( DtoR * fNewPedHeading),scenarioType);
  6041. CScriptPeds::GivePedScriptedTask(iPedIndex, pTask, SCRIPT_TASK_STAND_GUARD, "TASK_STAND_GUARD");
  6042. }
  6043. }
  6044.  
  6045. // Add a scripted cover point
  6046. int CommandAddCoverPoint( const scrVector & scrVecCoors, float fDirection, s32 iUsage, s32 iHeight, s32 iArc, bool bIsPriority)
  6047. {
  6048. AI_LOG_WITH_ARGS("[Script] - Script %s is adding a coverpoint at position (%.2f, %.2f, %.2f)", CTheScripts::GetCurrentScriptName(), scrVecCoors.x, scrVecCoors.y, scrVecCoors.z);
  6049. AI_LOG_STACK_TRACE(8);
  6050.  
  6051. CScriptResource_Coverpoint coverPoint(Vector3(scrVecCoors), fDirection, iUsage, iHeight, iArc, bIsPriority);
  6052.  
  6053. return CTheScripts::GetCurrentGtaScriptHandler()->RegisterScriptResourceAndGetRef(coverPoint);
  6054. }
  6055.  
  6056. // Remove a scripted cover point
  6057. void CommandRemoveCoverPoint( int iIdentifier )
  6058. {
  6059. AI_LOG_WITH_ARGS("[Script] - Script %s is removing a cover point with ID %d", CTheScripts::GetCurrentScriptName(), iIdentifier);
  6060. AI_LOG_STACK_TRACE(8);
  6061.  
  6062. CTheScripts::GetCurrentGtaScriptHandler()->RemoveScriptResource(CGameScriptResource::SCRIPT_RESOURCE_COVERPOINT, iIdentifier);
  6063. }
  6064.  
  6065. bool CommandDoesScriptedCoverPointExistAtCoords( const scrVector & scrVecCoors )
  6066. {
  6067. CCoverPoint* pOverlappingCoverPoint = NULL;
  6068. if (!CCoverPointsContainer::CheckIfNoOverlapAndGetGridCell(scrVecCoors, CCoverPoint::COVTYPE_SCRIPTED, NULL, pOverlappingCoverPoint, false))
  6069. {
  6070. return true;
  6071. }
  6072. else
  6073. {
  6074. return false;
  6075. }
  6076. }
  6077.  
  6078. scrVector CommandGetScriptedCoverPointCoords( int iIdentifier )
  6079. {
  6080. CScriptedCoverPoint* pScriptedCoverPoint = CTheScripts::GetScriptedCoverPointToModifyFromGUID(iIdentifier);
  6081. if (SCRIPT_VERIFY(pScriptedCoverPoint ,"GET_SCRIPTED_COVER_POINT_COORDS - Identifier is invalid" ))
  6082. {
  6083. CCoverPoint* pCoverPoint = CCover::FindCoverPointWithIndex(pScriptedCoverPoint->GetScriptIndex());
  6084. if (scriptVerifyf(pCoverPoint, "GET_SCRIPTED_COVER_POINT_COORDS - Cover Point %i Doesn't Exist", iIdentifier))
  6085. {
  6086. Vector3 vCoverPos(Vector3::ZeroType);
  6087. if (scriptVerifyf(pCoverPoint->GetCoverPointPosition(vCoverPos), "GET_SCRIPTED_COVER_POINT_COORDS - Couldn't get cover point coords for cover point with index %i", iIdentifier))
  6088. {
  6089. return vCoverPos;
  6090. }
  6091. }
  6092. }
  6093. return VEC3_ZERO;
  6094. }
  6095.  
  6096. // Add a scripted cover area which will be appended to the streamed cover area array
  6097. void CommandAddScriptedCoverArea(const scrVector & scrVecCoors, const float fRadius)
  6098. {
  6099. if (CPed* pPlayer = CGameWorld::FindLocalPlayer())
  6100. {
  6101. Vector3 vFrom(scrVecCoors);
  6102.  
  6103. Vector3 vDistance = VEC3V_TO_VECTOR3(pPlayer->GetTransformPtr()->GetPosition()) - vFrom;
  6104. float fDistance2 = vDistance.Mag2();
  6105.  
  6106. if (scriptVerifyf(fDistance2 < rage::square(200), "ADD_SCRIPTED_COVER_AREA - Scripted Area Cover distance from player is %fm, it must be within 200m to add.", vDistance.Mag()))
  6107. {
  6108. AI_LOG_WITH_ARGS("[Script] - Script %s is adding a scripted cover area at position (%.2f, %.2f, %.2f) with a radius of %.2f", CTheScripts::GetCurrentScriptName(), scrVecCoors.x, scrVecCoors.y, scrVecCoors.z, fRadius);
  6109.  
  6110. CCover::AddNewScriptedCoverArea(scrVecCoors, fRadius);
  6111. }
  6112. }
  6113. }
  6114.  
  6115. /*int CommandGetScriptedCoverPointStatus( int iIdentifier )
  6116. {
  6117. CScriptedCoverPoint* pScriptedCoverPoint = CTheScripts::GetScriptedCoverPointToModifyFromGUID(iIdentifier);
  6118. if (scriptVerifyf(pScriptedCoverPoint, "GET_SCRIPTED_COVER_POINT_STATUS - Cover Point %i Doesn't Exist", iIdentifier))
  6119. {
  6120. CCoverPoint* pCoverPoint = CCover::FindCoverPointWithIndex(pScriptedCoverPoint->GetScriptIndex());
  6121. if (scriptVerifyf(pCoverPoint, "GET_SCRIPTED_COVER_POINT_STATUS - Cover Point %i Doesn't Exist", iIdentifier))
  6122. {
  6123. return pCoverPoint->GetStatus();
  6124. }
  6125. }
  6126. return CCoverPoint::COVSTATUS_Invalid;
  6127. }*/
  6128.  
  6129. // Seek cover from the given position
  6130. void CommandTaskSeekCoverFromPos( int PedIndex, const scrVector & scrVecCoors, int iTime, bool bAllowPeekingAndFiring )
  6131. {
  6132. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0) ,"TASK_SEEK_COVER_FROM_POS - Time must be -1 for infinite and > 0" ))
  6133. {
  6134. float fTime = ( ( float )iTime ) / 1000.0f;
  6135.  
  6136. Vector3 vFrom(scrVecCoors);
  6137.  
  6138. CTaskCover* pCoverTask = rage_new CTaskCover(CAITarget(vFrom), bAllowPeekingAndFiring ? 0 : CTaskCover::CF_DisableAimingAndPeeking);
  6139. pCoverTask->SetSearchFlags(CTaskCover::CF_SeekCover | CTaskCover::CF_CoverSearchAny | CTaskCover::CF_ScriptedSeekCover);
  6140. pCoverTask->SetTimeInCover(fTime);
  6141.  
  6142. CScriptPeds::GivePedScriptedTask(PedIndex, pCoverTask, SCRIPT_TASK_SEEK_COVER_FROM_POS, "TASK_SEEK_COVER_FROM_POS");
  6143. }
  6144. }
  6145.  
  6146. // Seek cover from the given ped
  6147. void CommandTaskSeekCoverFromPed( int iPedIndex, int iOtherPedIndex, int iTime, bool bAllowPeekingAndFiring )
  6148. {
  6149. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0) ,"TASK_SEEK_COVER_FROM_PED - Time must be -1 for infinite and > 0" ))
  6150. {
  6151. float fTime = ( ( float )iTime ) / 1000.0f;
  6152.  
  6153. const CPed *pOtherPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iOtherPedIndex);
  6154.  
  6155. if(!pOtherPed)
  6156. return;
  6157.  
  6158. CTaskCover* pCoverTask = rage_new CTaskCover(CAITarget(pOtherPed), bAllowPeekingAndFiring ? 0 : CTaskCover::CF_DisableAimingAndPeeking);
  6159. pCoverTask->SetSearchFlags(CTaskCover::CF_SeekCover | CTaskCover::CF_CoverSearchAny | CTaskCover::CF_ScriptedSeekCover);
  6160. pCoverTask->SetTimeInCover(fTime);
  6161.  
  6162. CScriptPeds::GivePedScriptedTask(iPedIndex, pCoverTask, SCRIPT_TASK_SEEK_COVER_FROM_PED, "TASK_SEEK_COVER_FROM_PED");
  6163. }
  6164. }
  6165.  
  6166. // Seek cover to the given cover point, away from the position specified
  6167. void CommandTaskSeekCoverToCoverPoint( int iPedIndex, int iIdentifier, const scrVector & scrVecCoors, int iTime, bool bAllowPeekingAndFiring )
  6168. {
  6169. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0) ,"TASK_SEEK_COVER_TO_COVER_POINT - Time must be -1 for infinite and > 0" ))
  6170. {
  6171.  
  6172. float fTime = ( ( float )iTime ) / 1000.0f;
  6173.  
  6174. CScriptedCoverPoint* pScriptedCoverPoint = CTheScripts::GetScriptedCoverPointToModifyFromGUID(iIdentifier, "TASK_SEEK_COVER_TO_COVER_POINT");
  6175.  
  6176. if (scriptVerifyf(pScriptedCoverPoint, "Cover point with id %i didn't exist", iIdentifier))
  6177. {
  6178. s32 iCoverIndex = pScriptedCoverPoint->GetScriptIndex();
  6179.  
  6180. // Find the cover point specified by the identifier
  6181. #if __ASSERT
  6182.  
  6183. CCoverPoint* pCoverPoint = CCover::FindCoverPointWithIndex( iCoverIndex );
  6184. scriptAssertf(pCoverPoint, "%s:TASK_SEEK_COVER_TO_COVER_POINT - Invalid cover point specified", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  6185. Assert( pCoverPoint->GetType() == CCoverPoint::COVTYPE_SCRIPTED );
  6186. #endif
  6187. Vector3 vFrom(scrVecCoors);
  6188.  
  6189. CTaskCover* pCoverTask = rage_new CTaskCover(CAITarget(vFrom), bAllowPeekingAndFiring ? 0 : CTaskCover::CF_DisableAimingAndPeeking);
  6190. pCoverTask->SetSearchFlags(CTaskCover::CF_SeekCover | CTaskCover::CF_CoverSearchScripted | CTaskCover::CF_ScriptedSeekCover);
  6191. pCoverTask->SetScriptedCoverIndex(iCoverIndex);
  6192. pCoverTask->SetTimeInCover(fTime);
  6193.  
  6194. CScriptPeds::GivePedScriptedTask(iPedIndex, pCoverTask, SCRIPT_TASK_SEEK_COVER_TO_COVER_POINT, "TASK_SEEK_COVER_TO_COVER_POINT");
  6195. }
  6196. }
  6197. }
  6198.  
  6199. // Seek cover to the given coords, away from the position specified
  6200. void CommandTaskSeekCoverToCoords( int iPedIndex, const scrVector & scrVecCoverCoors, const scrVector & scrVecFromCoors, int iTime, bool bAllowPeekingAndFiring )
  6201. {
  6202. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0) ,"TASK_SEEK_COVER_TO_COVER_COORD - Time must be -1 for infinite and > 0" ))
  6203. {
  6204. float fTime = ( ( float )iTime ) / 1000.0f;
  6205.  
  6206. Vector3 vCover(scrVecCoverCoors);
  6207. Vector3 vFrom(scrVecFromCoors);
  6208.  
  6209. CTaskCover* pCoverTask = rage_new CTaskCover(CAITarget(vFrom), bAllowPeekingAndFiring ? 0 : CTaskCover::CF_DisableAimingAndPeeking);
  6210. pCoverTask->SetSearchFlags(CTaskCover::CF_SeekCover | CTaskCover::CF_CoverSearchByPos | CTaskCover::CF_ScriptedSeekCover);
  6211. pCoverTask->SetSearchPosition(vCover);
  6212. pCoverTask->SetTimeInCover(fTime);
  6213.  
  6214. CScriptPeds::GivePedScriptedTask(iPedIndex, pCoverTask, SCRIPT_TASK_SEEK_COVER_TO_COORDS, "TASK_SEEK_COVER_TO_COVER_COORD");
  6215. }
  6216. }
  6217.  
  6218. CTaskCover* CreatePutPedDirectlyIntoCoverTask( const scrVector & vscStart, const CAITarget& aiTarget, int iTime, bool bAllowPeekingAndFiring, float fBlendInDuration, bool bForceInitialFacingDirection, bool bForceFaceLeft, int iIdentifier, bool bDoEntry )
  6219. {
  6220. scriptAssertf(fBlendInDuration < 10.0f, "Setting a long blend in duration (%.2f) are you sure you want the anims to blend in this slowly?", fBlendInDuration);
  6221. float fTime = ( ( float )iTime ) / 1000.0f;
  6222. Vector3 vStart = vscStart;
  6223.  
  6224. s32 iCoverFlags = bAllowPeekingAndFiring ? CTaskCover::CF_PutPedDirectlyIntoCover : CTaskCover::CF_PutPedDirectlyIntoCover | CTaskCover::CF_DisableAimingAndPeeking;
  6225.  
  6226. if (bForceInitialFacingDirection)
  6227. {
  6228. aiDisplayf("TASK_PUT_PED_DIRECTLY_INTO_COVER called forcing ped to face %s at <<%.2f,%.2f,%.2f>>", bForceFaceLeft ? "Left" : "Right", vscStart.x, vscStart.y, vscStart.z);
  6229. iCoverFlags |= CTaskCover::CF_SpecifyInitialHeading;
  6230. if (bForceFaceLeft)
  6231. {
  6232. iCoverFlags |= CTaskCover::CF_FacingLeft;
  6233. }
  6234. }
  6235.  
  6236. // Set whether we want to skip the cover entry anims
  6237. if (!bDoEntry)
  6238. {
  6239. iCoverFlags |= CTaskCover::CF_SkipIdleCoverTransition;
  6240. }
  6241.  
  6242. CTaskCover* pCoverTask = rage_new CTaskCover(aiTarget, iCoverFlags);
  6243.  
  6244. CScriptedCoverPoint* pScriptedCoverPoint = NULL;
  6245.  
  6246. if (iIdentifier != NULL_IN_SCRIPTING_LANGUAGE)
  6247. {
  6248. pScriptedCoverPoint = CTheScripts::GetScriptedCoverPointToModifyFromGUID(iIdentifier, "TASK_PUT_PED_DIRECTLY_INTO_COVER");
  6249. }
  6250.  
  6251. if (pScriptedCoverPoint)
  6252. {
  6253. s32 iCoverIndex = pScriptedCoverPoint->GetScriptIndex();
  6254. #if __ASSERT
  6255. // Find the cover point specified by the identifier
  6256. CCoverPoint* pCoverPoint = CCover::FindCoverPointWithIndex( iCoverIndex );
  6257. scriptAssertf(pCoverPoint, "%s:TASK_SEEK_COVER_TO_COVER_POINT - Invalid cover point specified", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  6258. Assert( pCoverPoint->GetType() == CCoverPoint::COVTYPE_SCRIPTED );
  6259. #endif
  6260. pCoverTask->SetSearchFlags(CTaskCover::CF_CoverSearchScripted | CTaskCover::CF_ScriptedSeekCover);
  6261. pCoverTask->SetScriptedCoverIndex(iCoverIndex);
  6262. }
  6263. else
  6264. {
  6265. pCoverTask->SetSearchFlags(CTaskCover::CF_FindClosestPointAtStart | CTaskCover::CF_ScriptedSeekCover);
  6266. }
  6267.  
  6268. pCoverTask->SetBlendInDuration(fBlendInDuration);
  6269. pCoverTask->SetSearchPosition(vStart);
  6270. pCoverTask->SetTimeInCover(fTime);
  6271. return pCoverTask;
  6272. }
  6273.  
  6274. // Seek cover from the given position
  6275. void CommandTaskPutPedDirectlyIntoCover( int iPedIndex, const scrVector & vscStart, int iTime, bool bAllowPeekingAndFiring, float fBlendInDuration, bool bForceInitialFacingDirection, bool bForceFaceLeft, int iIdentifier, bool bDoEntry )
  6276. {
  6277. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0) ,"TASK_PUT_PED_DIRECTLY_INTO_COVER - Time must be -1 for infinite and > 0" ))
  6278. {
  6279. CTaskCover* pCoverTask = CreatePutPedDirectlyIntoCoverTask(vscStart, CAITarget(), iTime, bAllowPeekingAndFiring, fBlendInDuration, bForceInitialFacingDirection, bForceFaceLeft, iIdentifier, bDoEntry);
  6280. CScriptPeds::GivePedScriptedTask(iPedIndex, pCoverTask, SCRIPT_TASK_PUT_PED_DIRECTLY_INTO_COVER, "TASK_PUT_PED_DIRECTLY_INTO_COVER" );
  6281. }
  6282. }
  6283.  
  6284. bool GetAiTarget(CAITarget& target, int iOtherPedIndex, int iTargetVehicleIndex, const scrVector & vscTargetCoords)
  6285. {
  6286. Vector3 TempVec, CentreVec, VecDiff;
  6287. const CPed *pSecondPed;
  6288. const CVehicle *pSecondVehicle;
  6289.  
  6290. TempVec = Vector3(vscTargetCoords);
  6291.  
  6292. const CEntity *pTargetEntity = NULL;
  6293. if (iOtherPedIndex != NULL_IN_SCRIPTING_LANGUAGE) // >= 0)
  6294. {
  6295. if(SCRIPT_VERIFY(iTargetVehicleIndex == NULL_IN_SCRIPTING_LANGUAGE, "TASK_PUT_PED_DIRECTLY_INTO_COVER_FROM_TARGET - Can't have a target ped and a target car"))
  6296. {
  6297. pSecondPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iOtherPedIndex);
  6298. if(!pSecondPed)
  6299. return false;
  6300.  
  6301. pTargetEntity = pSecondPed;
  6302. }
  6303. else
  6304. {
  6305. return false;
  6306. }
  6307. }
  6308. else
  6309. {
  6310. pSecondPed = NULL;
  6311. }
  6312. if (iTargetVehicleIndex != NULL_IN_SCRIPTING_LANGUAGE) // >= 0)
  6313. {
  6314. if(SCRIPT_VERIFY(iOtherPedIndex == NULL_IN_SCRIPTING_LANGUAGE, "TASK_PUT_PED_DIRECTLY_INTO_COVER_FROM_TARGET - Can't have a target ped and a target car"))
  6315. {
  6316. pSecondVehicle = CTheScripts::GetEntityToQueryFromGUID<CVehicle>(iTargetVehicleIndex);
  6317. if(!SCRIPT_VERIFY(pSecondVehicle, "TASK_PUT_PED_DIRECTLY_INTO_COVER_FROM_TARGET - Target vehicle doesn't exist"))
  6318. return false;
  6319.  
  6320. pTargetEntity = pSecondVehicle;
  6321. }
  6322. else
  6323. {
  6324. return false;
  6325. }
  6326. }
  6327. else
  6328. {
  6329. pSecondVehicle = NULL;
  6330. }
  6331.  
  6332. // Set up the arguments
  6333. if (pTargetEntity)
  6334. {
  6335. target.SetEntityAndOffset(pTargetEntity,TempVec);
  6336. }
  6337. else
  6338. {
  6339. target.SetPosition(TempVec);
  6340. }
  6341. return true;
  6342. }
  6343.  
  6344. // Seek cover from the given position
  6345. void CommandTaskPutPedDirectlyIntoCoverFromTarget( int iPedIndex, int iOtherPedIndex, int iTargetVehicleIndex, const scrVector & vscTargetCoords, const scrVector & vscStart, int iTime, bool bAllowPeekingAndFiring, float fBlendInDuration, bool bForceInitialFacingDirection, bool bForceFaceLeft, int iIdentifier, bool bDoEntry )
  6346. {
  6347. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0) ,"TASK_PUT_PED_DIRECTLY_INTO_COVER_FROM_TARGET - Time must be -1 for infinite and > 0" ))
  6348. {
  6349. CAITarget target;
  6350. if (GetAiTarget(target, iOtherPedIndex, iTargetVehicleIndex, vscTargetCoords))
  6351. {
  6352. CTaskCover* pCoverTask = CreatePutPedDirectlyIntoCoverTask(vscStart, target, iTime, bAllowPeekingAndFiring, fBlendInDuration, bForceInitialFacingDirection, bForceFaceLeft, iIdentifier, bDoEntry);
  6353. CScriptPeds::GivePedScriptedTask(iPedIndex, pCoverTask, SCRIPT_TASK_PUT_PED_DIRECTLY_INTO_COVER_FROM_TARGET, "TASK_PUT_PED_DIRECTLY_INTO_COVER" );
  6354. }
  6355. }
  6356. }
  6357.  
  6358. void CommandTaskWarpPedDirectlyIntoCover(const int iPedIndex, const int iTime, const bool bAllowPeekingAndFiring, const bool bForceInitialFacingDirection, const bool bForceFaceLeft, const int iIdentifier)
  6359. {
  6360. if (SCRIPT_VERIFY((iTime == -1) || (iTime > 0), "TASK_WARP_PED_DIRECTLY_INTO_COVER - Time must be -1 for infinite and > 0") &&
  6361. SCRIPT_VERIFY(NULL_IN_SCRIPTING_LANGUAGE != iPedIndex, "TASK_WARP_PED_DIRECTLY_INTO_COVER - Can't warp a NULL ped"))
  6362. {
  6363. if (CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES))
  6364. {
  6365. Vector3 vPedPosition = VEC3V_TO_VECTOR3(pPed->GetTransform().GetPosition());
  6366.  
  6367. CTaskCover* pCoverTask = CreatePutPedDirectlyIntoCoverTask(vPedPosition, CAITarget(), iTime, bAllowPeekingAndFiring, 0.0f, bForceInitialFacingDirection, bForceFaceLeft, iIdentifier, false);
  6368. pCoverTask->SetCoverFlag(CTaskCover::CF_WarpPedToCoverPosition);
  6369. CScriptPeds::GivePedScriptedTask(iPedIndex, pCoverTask, SCRIPT_TASK_WARP_PED_DIRECTLY_INTO_COVER, "TASK_WARP_PED_DIRECTLY_INTO_COVER");
  6370. }
  6371. }
  6372. }
  6373.  
  6374. void CommandSetCoverTarget(int iPedIndex, int iOtherPedIndex, int iTargetVehicleIndex, const scrVector & vscTargetCoords)
  6375. {
  6376. if( SCRIPT_VERIFY( NULL_IN_SCRIPTING_LANGUAGE != iPedIndex, "SET_COVER_TARGET - Can't have a NULL ped" ) )
  6377. {
  6378. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>( iPedIndex );
  6379. if( pPed && SCRIPT_VERIFY(!pPed->IsNetworkClone(), "SET_COVER_TARGET - Can't call this command on a network clone!"))
  6380. {
  6381. CAITarget aiTarget;
  6382. if (GetAiTarget(aiTarget, iOtherPedIndex, iTargetVehicleIndex, vscTargetCoords))
  6383. {
  6384. CTaskCover* pCoverTask = static_cast<CTaskCover*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_COVER));
  6385. if( pCoverTask )
  6386. {
  6387. CWeaponTarget& weaponTarget = pCoverTask->GetWeaponTarget();
  6388. const CEntity* pEntity = aiTarget.GetEntity();
  6389. if( pEntity )
  6390. {
  6391. Vector3 vOffset(Vector3::ZeroType);
  6392. if (aiTarget.GetPositionOffset(vOffset))
  6393. {
  6394. weaponTarget.SetEntityAndOffset(pEntity, vOffset);
  6395. }
  6396. else
  6397. {
  6398. weaponTarget.SetEntity(pEntity);
  6399. }
  6400. }
  6401. else
  6402. {
  6403. Vector3 vPosition(Vector3::ZeroType);
  6404. if (aiTarget.GetPosition(vPosition))
  6405. {
  6406. weaponTarget.SetPosition(vPosition);
  6407. }
  6408. }
  6409. }
  6410. }
  6411. }
  6412. }
  6413. }
  6414.  
  6415. // Exit cover
  6416. void CommandTaskExitCover( int iPedIndex, int iExitType, const scrVector & vscTargetCoords )
  6417. {
  6418. s32 iFlags = 0;
  6419. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>( iPedIndex, 0 );
  6420. if (pPed)
  6421. {
  6422. // Early out if called on network clone or ped doesn't have a cover point
  6423. if (!SCRIPT_VERIFY(!pPed->IsNetworkClone(), "SCRIPT_TASK_EXIT_COVER - Cannot call on network clone"))
  6424. {
  6425. return;
  6426. }
  6427.  
  6428. if (!SCRIPT_VERIFY(pPed->GetCoverPoint(), "SCRIPT_TASK_EXIT_COVER - Called on a ped without a cover point"))
  6429. {
  6430. return;
  6431. }
  6432.  
  6433. if (pPed->GetPedResetFlag(CPED_RESET_FLAG_InCoverFacingLeft))
  6434. {
  6435. iFlags |= CTaskCover::CF_FacingLeft;
  6436. }
  6437. }
  6438.  
  6439. CAITarget target;
  6440.  
  6441. if (iExitType == CTaskCover::FE_Aim)
  6442. {
  6443. target.SetPosition(vscTargetCoords);
  6444. }
  6445.  
  6446. // Maybe given as part of a sequence, can't detect if ped will be in cover now if this is the case
  6447. CScriptPeds::GivePedScriptedTask(iPedIndex, rage_new CTaskCover(target, iFlags, (CTaskCover::eForcedExit) iExitType), SCRIPT_TASK_EXIT_COVER, "SCRIPT_TASK_EXIT_COVER");
  6448. }
  6449.  
  6450. // Seek cover from the given position
  6451. void CommandTaskPutPedDirectlyIntoMelee( int iPedIndex, int iTargetIndex, float fBlendInDuration, float fTimeInMelee, float fStrafePhaseSync, const int iAiCombatFlags )
  6452. {
  6453. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex);
  6454. if( pPed )
  6455. {
  6456. // Force the default unarmed weapon
  6457. CPedWeaponManager* pWeaponManager = pPed->GetWeaponManager();
  6458. if( pWeaponManager )
  6459. {
  6460. const CWeaponInfo* pWeaponInfo = pWeaponManager->GetEquippedWeaponInfo();
  6461. if( pWeaponInfo && !pWeaponInfo->GetIsMelee() )
  6462. pWeaponManager->EquipWeapon( pPed->GetDefaultUnarmedWeaponHash(), -1, true );
  6463. }
  6464.  
  6465. CTaskMotionPed* pCurrentMotionTask = static_cast<CTaskMotionPed*>(pPed->GetPedIntelligence()->GetTaskManager()->FindTaskByTypeActive(PED_TASK_TREE_MOTION, CTaskTypes::TASK_MOTION_PED));
  6466. if( pCurrentMotionTask )
  6467. {
  6468. pCurrentMotionTask->SetTaskFlag( CTaskMotionPed::PMF_SkipStrafeIntroAnim );
  6469. pCurrentMotionTask->SetInstantStrafePhaseSync( fStrafePhaseSync );
  6470. pCurrentMotionTask->SetStrafeDurationOverride( fBlendInDuration );
  6471. }
  6472.  
  6473. CPed* pTargetPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iTargetIndex);
  6474.  
  6475. aiTask* pCombatTask = NULL;
  6476. if( pPed->IsAPlayerPed() )
  6477. {
  6478. u32 uMeleeFlags = CTaskMelee::MF_ShouldBeInMeleeMode | CTaskMelee::MF_AllowStrafeMode;
  6479.  
  6480. // Would the invoker like to keep the player in strafe?
  6481. // NOTE: they also need to set CPED_RESET_FLAG_ForcePedToStrafe
  6482. if( fTimeInMelee < 0.0f )
  6483. uMeleeFlags |= CTaskMelee::MF_ForceStrafe;
  6484.  
  6485. pCombatTask = rage_new CTaskMelee( NULL, pTargetPed, uMeleeFlags, CSimpleImpulseTest::ImpulseNone, (s32)( fTimeInMelee * 1000.0f ) );
  6486. }
  6487. else
  6488. {
  6489. CTaskThreatResponse* pTask = rage_new CTaskThreatResponse( pTargetPed );
  6490. pTask->SetThreatResponseOverride( CTaskThreatResponse::TR_Fight );
  6491. pTask->SetConfigFlagsForCombat( CTaskCombat::ComF_DisableAimIntro | CTaskCombat::ComF_MeleeAnimPhaseSync | iAiCombatFlags );
  6492. pTask->SetConfigFlags( CTaskThreatResponse::CF_CanFightArmedPedsWhenNotArmed );
  6493. pCombatTask = pTask;
  6494. }
  6495.  
  6496. CScriptPeds::GivePedScriptedTask( iPedIndex, pCombatTask, SCRIPT_TASK_PUT_PED_DIRECTLY_INTO_MELEE, "SCRIPT_TASK_PUT_PED_DIRECTLY_INTO_MELEE" );
  6497. }
  6498. }
  6499.  
  6500.  
  6501. void CommandSetDriveTaskCruiseSpeed(int iPedIndex, float CruiseSpeed )
  6502. {
  6503. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex, CTheScripts::GUID_ASSERT_FLAGS_NO_DEAD_CHECK & CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  6504.  
  6505. if(pPed)
  6506. {
  6507. if(SCRIPT_VERIFY(pPed->GetMyVehicle() && pPed->GetPedConfigFlag( CPED_CONFIG_FLAG_InVehicle ), "SET_DRIVE_TASK_CRUISE_SPEED - Ped is not in car"))
  6508. {
  6509. if(SCRIPT_VERIFY(pPed->GetMyVehicle()->GetDriver() == pPed, "SET_DRIVE_TASK_CRUISE_SPEED - Ped is not driver of car"))
  6510. {
  6511. if(NetworkUtils::IsNetworkCloneOrMigrating(pPed))
  6512. {
  6513. CScriptEntityStateChangeEvent::CSettingOfDriveTaskCruiseSpeed parameters(CruiseSpeed);
  6514. CScriptEntityStateChangeEvent::Trigger(pPed->GetNetworkObject(), parameters);
  6515. }
  6516. else
  6517. {
  6518. CTaskVehicleMissionBase *pCarTask = pPed->GetMyVehicle()->GetIntelligence()->GetActiveTask();
  6519. if(pCarTask)
  6520. {
  6521. pCarTask->SetCruiseSpeed(CruiseSpeed);
  6522. }
  6523. }
  6524. }
  6525. }
  6526. }
  6527. }
  6528.  
  6529. void CommandSetDriveTaskMaxCruiseSpeed(int iPedIndex, float MaxCruiseSpeed )
  6530. {
  6531. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex);
  6532.  
  6533. if(pPed)
  6534. {
  6535. if(SCRIPT_VERIFY(pPed->GetMyVehicle() && pPed->GetPedConfigFlag( CPED_CONFIG_FLAG_InVehicle ), "SET_DRIVE_TASK_MAX_CRUISE_SPEED - Ped is not in car"))
  6536. {
  6537. if(SCRIPT_VERIFY(pPed->GetMyVehicle()->GetDriver() == pPed, "SET_DRIVE_TASK_MAX_CRUISE_SPEED - Ped is not driver of car"))
  6538. {
  6539. CTaskVehicleMissionBase *pCarTask = pPed->GetMyVehicle()->GetIntelligence()->GetActiveTask();
  6540. if(pCarTask)
  6541. pCarTask->SetMaxCruiseSpeed((u8) MaxCruiseSpeed);
  6542. }
  6543. }
  6544. }
  6545. }
  6546.  
  6547. void CommandSetDriveTaskDrivingStyle(int iPedIndex, int iDrivingFlags)
  6548. {
  6549. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex);
  6550.  
  6551. if(pPed)
  6552. {
  6553. if(SCRIPT_VERIFY(pPed->GetMyVehicle() && pPed->GetPedConfigFlag( CPED_CONFIG_FLAG_InVehicle ), "SET_DRIVE_TASK_DRIVING_STYLE - Ped is not in car"))
  6554. {
  6555. if(SCRIPT_VERIFY(pPed->GetMyVehicle()->GetDriver() == pPed, "SET_DRIVE_TASK_DRIVING_STYLE - Ped is not driver of car"))
  6556. {
  6557. CTaskVehicleMissionBase *pCarTask = pPed->GetMyVehicle()->GetIntelligence()->GetActiveTask();
  6558. if(pCarTask)
  6559. pCarTask->SetDrivingFlags(iDrivingFlags);
  6560. }
  6561. }
  6562. }
  6563. }
  6564.  
  6565. void CommandSetPursueTaskIdealDistance(int iPedIndex, float fIdealDistance)
  6566. {
  6567. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex);
  6568.  
  6569. if(pPed)
  6570. {
  6571. if(SCRIPT_VERIFY(pPed->GetMyVehicle() && pPed->GetPedConfigFlag( CPED_CONFIG_FLAG_InVehicle ), "SET_PURSUE_TASK_IDEAL_DISTANCE - Ped is not in car"))
  6572. {
  6573. if(SCRIPT_VERIFY(pPed->GetMyVehicle()->GetDriver() == pPed, "SET_PURSUE_TASK_IDEAL_DISTANCE - Ped is not driver of car"))
  6574. {
  6575. CTaskVehiclePursue* pPursueTask = static_cast<CTaskVehiclePursue*>(pPed->GetMyVehicle()->GetIntelligence()->GetTaskManager()->FindTaskByTypeActive(VEHICLE_TASK_TREE_PRIMARY, CTaskTypes::TASK_VEHICLE_PURSUE));
  6576. if(SCRIPT_VERIFY(pPursueTask, "SET_PURSUE_TASK_IDEAL_DISTANCE - Vehicle is not running TASK_VEHICLE_PURSUE"))
  6577. {
  6578. pPursueTask->SetIdealDistance(fIdealDistance);
  6579. }
  6580. }
  6581. }
  6582. }
  6583. }
  6584.  
  6585. // Add a cover blocking area
  6586. void CommandAddCoverBlockingArea( const scrVector & vStart, const scrVector & vEnd, bool bBlockObjects, bool bBlockVehicles, bool bBlockMap, bool bBlockPlayer )
  6587. {
  6588. Vector3 vStartV3 = vStart;
  6589. Vector3 vEndV3 = vEnd;
  6590. CCover::AddCoverBlockingArea( vStartV3, vEndV3, bBlockObjects, bBlockVehicles, bBlockMap, bBlockPlayer );
  6591. }
  6592.  
  6593. // Add a scripted cover point
  6594. void CommandFlushCoverBlockingAreas()
  6595. {
  6596. CCover::FlushCoverBlockingAreas();
  6597. }
  6598.  
  6599. // Remove any scripted cover points that contain the specified position.
  6600. void CommandRemoveCoverBlockingAreasAtPosition(const scrVector &vPosition)
  6601. {
  6602. Vector3 vPositionV3 = vPosition;
  6603. CCover::RemoveCoverBlockingAreasAtPosition(vPositionV3);
  6604. }
  6605.  
  6606. // Remove any scripter cover points that have the specified params.
  6607. void CommandRemoveSpecificCoverBlockingAreas(const scrVector & vStart, const scrVector & vEnd, bool bBlockObjects, bool bBlockVehicles, bool bBlockMap, bool bBlockPlayer)
  6608. {
  6609. Vector3 vStartV3 = vStart;
  6610. Vector3 vEndV3 = vEnd;
  6611. CCover::RemoveSpecificCoverBlockingArea( vStartV3, vEndV3, bBlockObjects, bBlockVehicles, bBlockMap, bBlockPlayer );
  6612. }
  6613.  
  6614. void CommandTaskStartScenarioInPlace( int PedIndex, const char* szScenario, int iTimeToLeave, bool playIntro)
  6615. {
  6616. s32 type = CScenarioManager::GetScenarioTypeFromName(szScenario);
  6617.  
  6618. if (scriptVerifyf(type!=Scenario_Invalid, "TASK_START_SCENARIO_IN_PLACE: Unknown scenario type (%s)", szScenario ))
  6619. {
  6620. int flags = CTaskUseScenario::SF_StartInCurrentPosition;
  6621. if (!playIntro)
  6622. {
  6623. flags |= CTaskUseScenario::SF_SkipEnterClip;
  6624. }
  6625. if (iTimeToLeave < 0)
  6626. {
  6627. flags |= CTaskUseScenario::SF_IdleForever;
  6628. }
  6629. CTaskUseScenario* pTask = rage_new CTaskUseScenario(type, flags );
  6630.  
  6631. #if __ASSERT
  6632. //If assigning a task with a prop, make sure the ped has an inventory
  6633. if (PedIndex != NULL_IN_SCRIPTING_LANGUAGE)
  6634. {
  6635. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  6636. scriptAssertf(!pTask->GetScenarioInfo().HasProp() || pPed->GetInventory(), "%s: Attempting to assign a ped a scenario (%s) that has a prop, but the ped(%s) has no inventory", CTheScripts::GetCurrentScriptNameAndProgramCounter(), pTask->GetScenarioInfo().GetName(), pPed->GetModelName());
  6637. }
  6638. #endif
  6639.  
  6640. if( iTimeToLeave > 0 )
  6641. {
  6642. float fTimeToLeave = (float) iTimeToLeave;
  6643. pTask->SetTimeToLeave(fTimeToLeave/1000.0f);
  6644. }
  6645. pTask->CreateProp();
  6646. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_START_SCENARIO_IN_PLACE, "TASK_START_SCENARIO_IN_PLACE");
  6647. }
  6648. }
  6649.  
  6650. void CommandTaskStartScenarioAtPosition( int iPedIndex, const char* szScenario, const scrVector & svScenarioPlace, float fHeading, int iTimeToLeave, bool playIntro, bool bWarp)
  6651. {
  6652. Vector3 vScenarioPoint = svScenarioPlace;
  6653. s32 type = CScenarioManager::GetScenarioTypeFromName(szScenario);
  6654. if (scriptVerifyf(type!=Scenario_Invalid, "TASK_START_SCENARIO_AT_POSITION: Unknown scenario type (%s)", szScenario ))
  6655. {
  6656. int flags = 0;
  6657. if (bWarp)
  6658. {
  6659. flags |= CTaskUseScenario::SF_Warp;
  6660. }
  6661. if (!playIntro)
  6662. {
  6663. flags |= CTaskUseScenario::SF_SkipEnterClip;
  6664. }
  6665. if (iTimeToLeave < 0)
  6666. {
  6667. flags |= CTaskUseScenario::SF_IdleForever;
  6668. }
  6669. CTaskUseScenario* pTask = rage_new CTaskUseScenario(type, vScenarioPoint, fwAngle::LimitRadianAngle( (DtoR * fHeading) ), flags );
  6670. if( iTimeToLeave > 0 )
  6671. {
  6672. float fTimeToLeave = (float) iTimeToLeave;
  6673. pTask->SetTimeToLeave(fTimeToLeave/1000.0f);
  6674. }
  6675. pTask->CreateProp();
  6676. CScriptPeds::GivePedScriptedTask(iPedIndex, pTask, SCRIPT_TASK_START_SCENARIO_AT_POSITION, "TASK_START_SCENARIO_AT_POSITION");
  6677. }
  6678. }
  6679.  
  6680. void CommandTaskStartVehicleScenario( int iPedIndex, int iVehicleIndex, const char* szScenario, bool bWarp )
  6681. {
  6682. if( iPedIndex != NULL_IN_SCRIPTING_LANGUAGE && iVehicleIndex != NULL_IN_SCRIPTING_LANGUAGE)
  6683. {
  6684. CVehicle* pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleIndex);
  6685. if(!pVehicle)
  6686. return;
  6687.  
  6688. s32 type = CScenarioManager::GetScenarioTypeFromName(szScenario);
  6689. if (scriptVerifyf(type!=Scenario_Invalid, "TASK_START_VEHICLE_SCENARIO: Unknown scenario type (%s)", szScenario ))
  6690. {
  6691. scriptAssertf(SCENARIOINFOMGR.GetScenarioInfoByIndex(type) && SCENARIOINFOMGR.GetScenarioInfoByIndex(type)->GetIsClass<CScenarioParkedVehicleInfo>(), "Invalid Vehicle Scenario");
  6692. CTaskParkedVehicleScenario* pTask = rage_new CTaskParkedVehicleScenario(type, pVehicle, bWarp);
  6693. CScriptPeds::GivePedScriptedTask(iPedIndex, pTask, SCRIPT_TASK_START_VEHICLE_SCENARIO, "TASK_START_VEHICLE_SCENARIO");
  6694. }
  6695. }
  6696. }
  6697.  
  6698. bool CommandDoesScenarioExistInArea( const scrVector & svScenarioPlace, float fMaxRange, bool bMustBeFree )
  6699. {
  6700. Vector3 vScenarioPoint = svScenarioPlace;
  6701. CPedPopulation::GetScenarioPointInAreaArgs args(RCC_VEC3V(vScenarioPoint), fMaxRange);
  6702. args.m_MustBeFree = bMustBeFree;
  6703. args.m_CheckPopulation = bMustBeFree;
  6704. CScenarioPoint* pScenarioPoint = NULL;
  6705.  
  6706. if(!CPedPopulation::GetScenarioPointInArea(args, &pScenarioPoint))
  6707. {
  6708. return false;
  6709. }
  6710. return true;
  6711. }
  6712.  
  6713. bool CommandDoesScenarioOfTypeExistInArea ( const scrVector & svScenarioPlace, const char* szScenario, float fMaxRange, bool bMustBeFree )
  6714. {
  6715. Vector3 vScenarioPoint = svScenarioPlace;
  6716. CPedPopulation::GetScenarioPointInAreaArgs args(RCC_VEC3V(vScenarioPoint), fMaxRange);
  6717. args.m_MustBeFree = bMustBeFree;
  6718. args.m_CheckPopulation = bMustBeFree;
  6719. args.m_NumTypes = 1;
  6720. s32 type = CScenarioManager::GetScenarioTypeFromName(szScenario);
  6721. args.m_Types = &type;
  6722.  
  6723. scriptAssertf(type!=Scenario_Invalid, "DOES_SCENARIO_OF_TYPE_EXIST_IN_AREA: Unknown scenario type (%s)", szScenario );
  6724.  
  6725. CScenarioPoint* pScenarioPoint = NULL;
  6726. if(!CPedPopulation::GetScenarioPointInArea(args, &pScenarioPoint))
  6727. {
  6728. return false;
  6729. }
  6730. return true;
  6731. }
  6732.  
  6733. bool CommandIsScenarioOccupied(const scrVector & svScenarioPlace, float fMaxRange, bool onlyUsersActuallyAtScenario)
  6734. {
  6735. Vector3 vScenarioPoint = svScenarioPlace;
  6736. CScenarioPoint* pScenarioPoint = NULL;
  6737.  
  6738. CPedPopulation::GetScenarioPointInAreaArgs args(RCC_VEC3V(vScenarioPoint), fMaxRange);
  6739. args.m_MustBeFree = false;
  6740. args.m_CheckPopulation = false;
  6741.  
  6742. if(!CPedPopulation::GetScenarioPointInArea(args, &pScenarioPoint))
  6743. {
  6744. return false;
  6745. }
  6746.  
  6747. // If onlyUsersActuallyAtScenario is set, we need to loop over the peds later.
  6748. bool needToCheckPeds = onlyUsersActuallyAtScenario;
  6749.  
  6750. // Note: CPedPopulation::IsEffectInUse() is a bit unfortunate in how it always
  6751. // returns true if the scenario is attached to anything but a CObject. This is
  6752. // different than how the check is done in GetScenarioPointInArea()
  6753. // and GeneratePedsFromScenarioPointList(), where a scenario attached to something
  6754. // else is considered not in use. Thus, we check the type here.
  6755. if(!pScenarioPoint->GetEntity() || pScenarioPoint->GetEntity()->GetIsTypeObject())
  6756. {
  6757. if(!CPedPopulation::IsEffectInUse(*pScenarioPoint))
  6758. {
  6759. return false;
  6760. }
  6761. }
  6762. else if(pScenarioPoint->GetEntity() && !pScenarioPoint->GetEntity()->GetIsTypeObject())
  6763. {
  6764. // Since we don't keep track of use for non-CObject entities,
  6765. // we need to check the ped tasks.
  6766. needToCheckPeds = true;
  6767. }
  6768.  
  6769. if(needToCheckPeds)
  6770. {
  6771. int scenarioTypeFoundInLocation = pScenarioPoint->GetScenarioTypeVirtualOrReal();
  6772.  
  6773. bool isVirtual = SCENARIOINFOMGR.IsVirtualIndex(scenarioTypeFoundInLocation);
  6774.  
  6775. bool foundNearby = false;
  6776.  
  6777. CPed::Pool* pool = CPed::GetPool();
  6778. const int maxPeds = pool->GetSize();
  6779. for(int i = 0; i < maxPeds; i++)
  6780. {
  6781. CPed* pPed = pool->GetSlot(i);
  6782. if(!pPed)
  6783. {
  6784. continue;
  6785. }
  6786.  
  6787. // Note: for virtual scenario types, we won't ever match GetScenarioType(). We could loop over
  6788. // all the real types, but the code below looks like it may work well enough without that.
  6789. if(!isVirtual && scenarioTypeFoundInLocation != CPed::GetScenarioType(*pPed))
  6790. {
  6791. continue;
  6792. }
  6793.  
  6794. const CTaskUseScenario* pTaskUseScenario = static_cast<const CTaskUseScenario*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_USE_SCENARIO));
  6795. if(pTaskUseScenario)
  6796. {
  6797. if (pTaskUseScenario->GetScenarioPoint() != pScenarioPoint)
  6798. {
  6799. continue;
  6800. }
  6801.  
  6802. const int taskState = pTaskUseScenario->GetState();
  6803. if(onlyUsersActuallyAtScenario && (taskState == CTaskUseScenario::State_Start || taskState == CTaskUseScenario::State_GoToStartPosition))
  6804. {
  6805. // In this case, we certainly appear to have found the ped that's considered the user
  6806. // of the scenario point, but it hasn't actually arrived yet. In that case, we don't consider
  6807. // the scenario occupied, so we return false.
  6808. return false;
  6809. }
  6810. else
  6811. {
  6812. // Found the true user of this scenario.
  6813. return true;
  6814. }
  6815. }
  6816. else if(!foundNearby && !isVirtual)
  6817. {
  6818. // Somehow, according to CPed::GetScenarioType(), we are using a scenario of the type we are looking for,
  6819. // but we can't find the CTaskUseScenario. It might be possible for this to happen for some scenario that's
  6820. // using a different task, or perhaps in some networking situation, so we try to fall back on a distance
  6821. // check.
  6822.  
  6823. static float s_DistThresholdSq = square(1.0f); // MAGIC!
  6824.  
  6825. const Vec3V scenarioWorldPosV = pScenarioPoint->GetPosition();
  6826. const Vec3V pedPosV = pPed->GetTransform().GetPosition();
  6827. const ScalarV distThresholdSqV = LoadScalar32IntoScalarV(s_DistThresholdSq);
  6828. const ScalarV distSqV = DistSquared(scenarioWorldPosV, pedPosV);
  6829. if(IsLessThanAll(distSqV, distThresholdSqV))
  6830. {
  6831. // This ped is close, set this variable. Note that we don't return true right away here,
  6832. // because we might still find a ped that's actually using this scenario through a CTaskUseScenario,
  6833. // in which case returning false is still an option.
  6834. foundNearby = true;
  6835. }
  6836. }
  6837. }
  6838.  
  6839. if(foundNearby)
  6840. {
  6841. // We didn't find anybody running a CTaskUseScenario on this scenario, but we found
  6842. // somebody using a scenario of the right type, close enough to the point.
  6843. return true;
  6844. }
  6845. else
  6846. {
  6847. // Nobody nearby is using a scenario of this type.
  6848. return false;
  6849. }
  6850. }
  6851. else
  6852. {
  6853. return true;
  6854. }
  6855. }
  6856.  
  6857. bool CommandPedHasUseScenarioTask(int iPedIndex)
  6858. {
  6859. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex);
  6860. if (SCRIPT_VERIFY(pPed, "PedIndex was invalid for PED_HAS_USE_SCENARIO_TASK!"))
  6861. {
  6862. CTaskUseScenario* pTaskScenario = static_cast<CTaskUseScenario*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_USE_SCENARIO));
  6863. if (pTaskScenario)
  6864. {
  6865. return true;
  6866. }
  6867. }
  6868.  
  6869. return false;
  6870. }
  6871.  
  6872. void CommandOverrideTaskedScenarioBaseAnim(int iPedIndex, const char* clipSet, const char* clip)
  6873. {
  6874. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex);
  6875. if (SCRIPT_VERIFY(pPed, "PedIndex was invalid for OVERRIDE_TASKED_SCENARIO_BASE_ANIM!"))
  6876. {
  6877. CTaskUseScenario* pTaskScenario = static_cast<CTaskUseScenario*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_USE_SCENARIO));
  6878. if (pTaskScenario)
  6879. {
  6880. fwMvClipSetId setId(clipSet);
  6881. fwMvClipId clipId(clip);
  6882. pTaskScenario->OverrideBaseClip(setId, clipId);
  6883. }
  6884.  
  6885. // if we are already running the ambient clips task then we should set the override on there as well.
  6886. CTaskAmbientClips* pTaskAmbientClips = static_cast<CTaskAmbientClips*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_AMBIENT_CLIPS));
  6887. if (pTaskAmbientClips)
  6888. {
  6889. fwMvClipSetId setId(clipSet);
  6890. fwMvClipId clipId(clip);
  6891. pTaskAmbientClips->OverrideBaseClip(setId, clipId);
  6892. }
  6893. }
  6894. }
  6895.  
  6896. void CommandPlayAnimOnRunnningScenario(int iPedIndex, const char* clipSet, const char* clip)
  6897. {
  6898. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex);
  6899. if (SCRIPT_VERIFY(pPed, "PedIndex was invalid for TASK_SCENARIO_PLAY_AS_IDLE!"))
  6900. {
  6901. CTaskAmbientClips* pTaskAmbientClips = static_cast<CTaskAmbientClips*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_AMBIENT_CLIPS));
  6902. if (SCRIPT_VERIFY(pTaskAmbientClips, "Ped is currently not running the right task to run TASK_SCENARIO_PLAY_AS_IDLE"))
  6903. {
  6904. fwMvClipSetId setId(clipSet);
  6905. fwMvClipId clipId(clip);
  6906. if (SCRIPT_VERIFYF(fwClipSetManager::GetClipSet(setId) != NULL, "ClipSet %s did not exist. Are you sure it is in clip_sets.xml?", clipSet))
  6907. {
  6908. pTaskAmbientClips->PlayAnimAsIdle(setId, clipId);
  6909. }
  6910. }
  6911. }
  6912. }
  6913.  
  6914. int GetScenarioGroupHelper(const char* groupName, const char* ASSERT_ONLY(cmdName), bool ASSERT_ONLY(mayNotExist))
  6915. {
  6916. int groupId = CScenarioPointManager::kNoGroup;
  6917. if(groupName && groupName[0])
  6918. {
  6919. groupId = SCENARIOPOINTMGR.FindGroupByNameHash(atHashString(groupName), true);
  6920. }
  6921. scriptAssertf(groupId != CScenarioPointManager::kNoGroup || mayNotExist, "%s used with group name %s, which doesn't exist.", cmdName, groupName ? groupName : "<NULL>");
  6922. return groupId;
  6923. }
  6924.  
  6925. bool CommandDoesScenarioGroupExist(const char* groupName)
  6926. {
  6927. return GetScenarioGroupHelper(groupName, "DOES_SCENARIO_GROUP_EXIST", true) != CScenarioPointManager::kNoGroup;
  6928. }
  6929.  
  6930. bool CommandIsScenarioGroupEnabled(const char* groupName)
  6931. {
  6932. int groupId = GetScenarioGroupHelper(groupName, "IS_SCENARIO_GROUP_ENABLED", false);
  6933. if(groupId != CScenarioPointManager::kNoGroup)
  6934. {
  6935. const int groupIndex = groupId - 1;
  6936. return SCENARIOPOINTMGR.IsGroupEnabled(groupIndex);
  6937. }
  6938. return false;
  6939. }
  6940.  
  6941. void CommandSetScenarioGroupEnabled(const char* groupName, bool enabled)
  6942. {
  6943. int groupId = GetScenarioGroupHelper(groupName, "IS_SCENARIO_GROUP_ENABLED", false);
  6944. if(groupId != CScenarioPointManager::kNoGroup)
  6945. {
  6946. const int groupIndex = groupId - 1;
  6947. SCENARIOPOINTMGR.SetGroupEnabled(groupIndex, enabled);
  6948. }
  6949. }
  6950.  
  6951. void CommandResetScenarioGroupsEnabled()
  6952. {
  6953. SCENARIOPOINTMGR.ResetGroupsEnabledToDefaults();
  6954. }
  6955.  
  6956. void CommandSetExclusiveScenarioGroup(const char* groupName)
  6957. {
  6958. int groupId = GetScenarioGroupHelper(groupName, "SET_EXCLUSIVE_SCENARIO_GROUP", false);
  6959. if(groupId != CScenarioPointManager::kNoGroup)
  6960. {
  6961. const int groupIndex = groupId - 1;
  6962. SCENARIOPOINTMGR.SetExclusivelyEnabledScenarioGroupIndex(groupIndex);
  6963. }
  6964. }
  6965.  
  6966. void CommandResetExclusiveScenarioGroup()
  6967. {
  6968. SCENARIOPOINTMGR.SetExclusivelyEnabledScenarioGroupIndex(-1);
  6969. }
  6970.  
  6971. int GetScenarioTypeHelper(const char* typeName, const char* ASSERT_ONLY(cmdName))
  6972. {
  6973. int ret = -1;
  6974. if(typeName && typeName[0])
  6975. {
  6976. const u32 hash = atStringHash(typeName);
  6977.  
  6978. // Note: this is currently an O(n) operation.
  6979. ret = SCENARIOINFOMGR.GetScenarioIndex(hash, false);
  6980. }
  6981.  
  6982. scriptAssertf(ret >= 0, "%s used with type name %s, which doesn't exist.", cmdName, typeName ? typeName : "<NULL>");
  6983.  
  6984. return ret;
  6985. }
  6986.  
  6987. void CommandForceScenarioGroupPriority(const char* groupName, bool bIsHighPriority)
  6988. {
  6989. int groupId = GetScenarioGroupHelper(groupName, "FORCE_SCENARIO_GROUP_PRIORITY", true);
  6990. if(groupId != CScenarioPointManager::kNoGroup)
  6991. {
  6992. CScenarioPointPriorityManager::GetInstance().ForceScenarioPointGroupPriority((u8)groupId, bIsHighPriority);
  6993. }
  6994. }
  6995.  
  6996. void CommandResetScenarioGroupsPriority()
  6997. {
  6998. CScenarioPointPriorityManager::GetInstance().RestoreGroupsToOriginalPriorities();
  6999. }
  7000.  
  7001. bool CommandIsScenarioTypeEnabled(const char* typeName)
  7002. {
  7003. int typeIndex = GetScenarioTypeHelper(typeName, "IS_SCENARIO_TYPE_ENABLED");
  7004. if(typeIndex >= 0)
  7005. {
  7006. return SCENARIOINFOMGR.IsScenarioTypeEnabled(typeIndex);
  7007. }
  7008. return true;
  7009. }
  7010.  
  7011. void CommandSetScenarioTypeEnabled(const char* typeName, bool enabled)
  7012. {
  7013. int typeIndex = GetScenarioTypeHelper(typeName, "SET_SCENARIO_TYPE_ENABLED");
  7014. if(typeIndex >= 0)
  7015. {
  7016. SCENARIOINFOMGR.SetScenarioTypeEnabled(typeIndex, enabled);
  7017. }
  7018. }
  7019.  
  7020. void CommandResetScenarioTypesEnabled()
  7021. {
  7022. SCENARIOINFOMGR.ResetScenarioTypesEnabledToDefaults();
  7023. }
  7024.  
  7025. void CommandSuppressNormalScenarioExitsNextFrame()
  7026. {
  7027. CScenarioManager::SetScenarioExitsSuppressed(true);
  7028. }
  7029.  
  7030. void CommandSuppressScenarioAttractionNextFrame()
  7031. {
  7032. CScenarioManager::SetScenarioAttractionSuppressed(true);
  7033. }
  7034.  
  7035. void CommandSuppressBreakoutScenarioExitsNextFrame()
  7036. {
  7037. CScenarioManager::SetScenarioBreakoutExitsSuppressed(true);
  7038. }
  7039.  
  7040.  
  7041.  
  7042. CTask* CommonUseNearestScenarioToPos( CPed* pPed, const scrVector & svScenarioPlace, float fMaxRange, bool bWarp, bool ASSERT_ONLY(bCalledFromTask), int iTimeToLeave, bool bMustBeTrainScenario )
  7043. {
  7044. Vector3 vScenarioPoint = svScenarioPlace;
  7045. CScenarioPoint* pScenarioPoint = NULL;
  7046. CPedPopulation::GetScenarioPointInAreaArgs args(RCC_VEC3V(vScenarioPoint), fMaxRange);
  7047. args.m_MustBeFree = true;
  7048. args.m_PedOrDummyToUsePoint = pPed;
  7049. args.m_Random = false;
  7050. args.m_MustBeAttachedToTrain = bMustBeTrainScenario;
  7051. bool bCheckPeds = false;
  7052. if( !CPedPopulation::GetScenarioPointInArea( args, &pScenarioPoint ) )
  7053. {
  7054. // do it again and process it further...the actual use count on the scenario point isn't
  7055. // always what we want if they are going to the point on a long chain and the player is much closer
  7056. args.m_MustBeFree = false;
  7057. args.m_CheckPopulation = false;
  7058.  
  7059. if( !CPedPopulation::GetScenarioPointInArea( args, &pScenarioPoint ) )
  7060. {
  7061. #if __ASSERT
  7062. if( !bCalledFromTask )
  7063. scriptAssertf(0, "%s:TASK_USE_NEAREST_SCENARIO_TO_POS(_WARP) - No scenario found within range", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  7064. #endif // __ASSERT
  7065. return NULL;
  7066. }
  7067. else
  7068. {
  7069. bCheckPeds = true;
  7070. }
  7071. }
  7072.  
  7073.  
  7074. if(bCheckPeds)
  7075. {
  7076. // Really check if the ped is actually using the scenario...
  7077. // The CScenarioPoint.m_iUses won't get reset until the cleanup function is called in CTaskUseScenario
  7078. // Other states here may be valid for us to start the scenario
  7079. CPed::Pool* pool = CPed::GetPool();
  7080. const int maxPeds = pool->GetSize();
  7081. for(int i = 0; i < maxPeds; i++)
  7082. {
  7083. CPed* pCurPed = pool->GetSlot(i);
  7084. if(!pCurPed || pCurPed == args.m_PedOrDummyToUsePoint || pCurPed->PopTypeIsMission())
  7085. {
  7086. continue;
  7087. }
  7088.  
  7089. CTaskUseScenario* pTaskUseScenario = static_cast<CTaskUseScenario*>(pCurPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_USE_SCENARIO));
  7090. if(pTaskUseScenario)
  7091. {
  7092. if (pTaskUseScenario->GetScenarioPoint() != pScenarioPoint)
  7093. {
  7094. continue;
  7095. }
  7096.  
  7097. const int taskState = pTaskUseScenario->GetState();
  7098. if(taskState != CTaskUseScenario::State_Start && taskState != CTaskUseScenario::State_GoToStartPosition)
  7099. {
  7100. #if __ASSERT
  7101. if( !bCalledFromTask )
  7102. scriptAssertf(0, "%s:TASK_USE_NEAREST_SCENARIO_TO_POS(_WARP) - No scenario found within range -- Scenario State For Another Ped Is Actively Using The Scenario", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  7103. #endif // __ASSERT
  7104. return NULL;
  7105. }
  7106. else if (pCurPed->PopTypeIsRandom())
  7107. {
  7108. // Scripted peds take priority over ambient/scenario peds
  7109. // This will prevent undesirable conflicts at atms, vending machines, etc
  7110. pTaskUseScenario->MakeAbortable(aiTask::ABORT_PRIORITY_URGENT, NULL);
  7111. }
  7112. }
  7113. }
  7114. }
  7115.  
  7116. s32 scenarioType = CScenarioManager::ChooseRealScenario(pScenarioPoint->GetScenarioTypeVirtualOrReal(), pPed);
  7117.  
  7118. bool bStartInCurrentPos = !bWarp;
  7119. float fHeading = 0.0f;
  7120. Vector3 vPedPos;
  7121. CTask* pScenarioTask = CScenarioManager::SetupScenarioAndTask(scenarioType, vPedPos, fHeading, *pScenarioPoint, 0, bStartInCurrentPos);
  7122.  
  7123. #if AI_DEBUG_OUTPUT_ENABLED
  7124. CNetObjGame* pNetObjPed = (NetworkInterface::IsGameInProgress() && pPed) ? pPed->GetNetworkObject() : NULL;
  7125. CAILogManager::GetLog().Log("CommonUseNearestScenarioToPos: [0x%p][%s], (%.2f,%.2f,%.2f), Range (%.2f), Warp (%d), ScenarioType %d, ScenarioPoint 0x%p (%.2f,%.2f,%.2f)\r\n",
  7126. pPed, pNetObjPed ? pNetObjPed->GetLogName() : "unknown",
  7127. svScenarioPlace.x, svScenarioPlace.y, svScenarioPlace.z, fMaxRange, bWarp,
  7128. scenarioType, pScenarioPoint, pScenarioPoint->GetWorldPosition().GetXf(), pScenarioPoint->GetWorldPosition().GetYf(), pScenarioPoint->GetWorldPosition().GetZf());
  7129. #endif
  7130.  
  7131. if(pScenarioTask)
  7132. {
  7133. if (pScenarioTask->GetTaskType() == CTaskTypes::TASK_USE_SCENARIO)
  7134. {
  7135. if (iTimeToLeave < 0)
  7136. {
  7137. ((CTaskUseScenario*)pScenarioTask)->SetDontLeaveEver();
  7138. }
  7139.  
  7140. if( iTimeToLeave > 0)
  7141. {
  7142. float fTimeToLeave = (float) iTimeToLeave;
  7143. ((CTaskUseScenario*)pScenarioTask)->SetTimeToLeave(fTimeToLeave/1000.0f);
  7144. }
  7145. }
  7146.  
  7147. // This is probably not strictly necessary, as CTaskUseScenario should warp us into
  7148. // place anyway. But, may still be safest, in case the script gets the position of the ped
  7149. // before the task has run, or if we're using a ragdoll.
  7150. if(bWarp && pPed)
  7151. {
  7152. // If we are using ragdoll, the calls to SetPosition() and other functions wouldn't work
  7153. // well. FlushImmediately() should take care of this by ending tasks and doing other things
  7154. // to restore the ped to a normal state. See B* 333114: "Ignorable Assert - Error: false:
  7155. // CPed::UpdatePhysicsFromEntity called while ragdoll active - fired after starting private dance".
  7156. // Note: we could potentially do this in the non-ragdoll case too, but to start out with, that
  7157. // seemed a bit risky.
  7158. if(pPed->GetUsingRagdoll())
  7159. {
  7160. pPed->GetPedIntelligence()->FlushImmediately(true);
  7161. }
  7162.  
  7163. pPed->SetPosition(vPedPos);
  7164. pPed->SetHeading(fHeading);
  7165. pPed->SetDesiredHeading(fHeading);
  7166. }
  7167. }
  7168. else
  7169. {
  7170. #if __ASSERT
  7171. if( !bCalledFromTask )
  7172. scriptAssertf(0, "%s:TASK_USE_NEAREST_SCENARIO_TO_POS(_WARP) - scenario type found of invalid type", CTheScripts::GetCurrentScriptNameAndProgramCounter());
  7173. #endif // __ASSERT
  7174. }
  7175.  
  7176. // We could probably do this if we wanted to wrap the scenario task in a CTaskUnalerted. The main
  7177. // reason for that would probably be if we needed to support chaining when done using the current scenario.
  7178. // aiTask* pControlTask = CScenarioManager::SetupScenarioControlTask(*pScenarioInfo, pScenarioTask, *pPropScenarioPoint);
  7179.  
  7180. return pScenarioTask;
  7181. }
  7182.  
  7183. CTask* CommonUseNearestScenarioChainToPos(CPed* pPed, const scrVector & svScenarioPlace, float fMaxRange, bool bWarp, bool bCalledFromTask, int iTimeToLeave )
  7184. {
  7185. CTask* pControlTask = NULL;
  7186. if (SCRIPT_VERIFY(pPed, "Invalid ped in CommonUseNearestScenarioChainToPos!"))
  7187. {
  7188. // Construct CTaskUseScenario for the nearest scenario point.
  7189. CTask* pScenarioTask = CommonUseNearestScenarioToPos(pPed, svScenarioPlace, fMaxRange, bWarp, bCalledFromTask, iTimeToLeave);
  7190.  
  7191. if (SCRIPT_VERIFY(pScenarioTask, "Invalid scenario task!"))
  7192. {
  7193. CScenarioPoint* pScenarioPoint = pScenarioTask->GetScenarioPoint();
  7194. if (SCRIPT_VERIFY(pScenarioPoint, "Generated scenario task did not have a valid scenario point!"))
  7195. {
  7196. s32 iScenarioType = CScenarioManager::ChooseRealScenario(pScenarioPoint->GetScenarioTypeVirtualOrReal(), pPed);
  7197. const CScenarioInfo* pScenarioInfo = CScenarioManager::GetScenarioInfo(iScenarioType);
  7198. if (SCRIPT_VERIFY(pScenarioInfo, "Invalid scenario info for type!"))
  7199. {
  7200. // Wrap the scenario point task in CTaskUnalerted so the ped can follow the chain.
  7201. pControlTask = CScenarioManager::SetupScenarioControlTask(*pPed, *pScenarioInfo, pScenarioTask, pScenarioPoint, iScenarioType);
  7202. }
  7203. }
  7204. }
  7205. }
  7206. return pControlTask;
  7207. }
  7208.  
  7209. void CommandTaskUseNearestScenarioToPos( int iPedIndex, const scrVector & svScenarioPlace, float fMaxRange, int iTimeToLeave )
  7210. {
  7211. // NULL peds are valid since this task can run in a sequence
  7212. CPed *pPed = NULL;
  7213. if(iPedIndex != NULL_IN_SCRIPTING_LANGUAGE)
  7214. {
  7215. pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  7216. }
  7217.  
  7218. CTask* pTask = CommonUseNearestScenarioToPos(pPed, svScenarioPlace, fMaxRange, false, false, iTimeToLeave);
  7219. if( pTask )
  7220. CScriptPeds::GivePedScriptedTask(iPedIndex, pTask, SCRIPT_TASK_USE_NEAREST_SCENARIO_TO_POS, "TASK_USE_NEAREST_SCENARIO_TO_COORD");
  7221. }
  7222.  
  7223. void CommandTaskUseNearestScenarioToPosWarp( int iPedIndex, const scrVector & svScenarioPlace, float fMaxRange, int iTimeToLeave )
  7224. {
  7225. // NULL peds are valid since this task can run in a sequence
  7226. CPed *pPed = NULL;
  7227. if(iPedIndex != NULL_IN_SCRIPTING_LANGUAGE)
  7228. {
  7229. pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  7230. }
  7231.  
  7232. CTask* pTask = CommonUseNearestScenarioToPos(pPed, svScenarioPlace, fMaxRange, true, false, iTimeToLeave);
  7233. if( pTask )
  7234. CScriptPeds::GivePedScriptedTask(iPedIndex, pTask, SCRIPT_TASK_USE_NEAREST_SCENARIO_TO_POS, "TASK_USE_NEAREST_SCENARIO_TO_COORD_WARP");
  7235. }
  7236.  
  7237. void CommandTaskUseNearestTrainScenarioToPosWarp( int iPedIndex, const scrVector & svScenarioPlace, float fMaxRange )
  7238. {
  7239. // NULL peds are valid since this task can run in a sequence
  7240. CPed *pPed = NULL;
  7241. if(iPedIndex != NULL_IN_SCRIPTING_LANGUAGE)
  7242. {
  7243. pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  7244. }
  7245.  
  7246. CTask* pUseScenarioTask = CommonUseNearestScenarioToPos(pPed, svScenarioPlace, fMaxRange, true, false, 0, true);
  7247. CTaskRideTrain* pTaskRideTrain = NULL;
  7248.  
  7249. if (pUseScenarioTask)
  7250. {
  7251. const CScenarioPoint* pScenarioPoint = pUseScenarioTask->GetScenarioPoint();
  7252.  
  7253. if (pScenarioPoint)
  7254. {
  7255. //Check if the scenario is on a train.
  7256. CEntity* pEntity = pScenarioPoint->GetEntity();
  7257. if(pEntity && pEntity->GetIsTypeVehicle())
  7258. {
  7259. CVehicle* pVehicle = static_cast<CVehicle *>(pEntity);
  7260. if(pVehicle->InheritsFromTrain())
  7261. {
  7262. //Grab the train.
  7263. CTrain* pTrain = static_cast<CTrain *>(pVehicle);
  7264.  
  7265. //Ride the train with the scenario point.
  7266. pTaskRideTrain = rage_new CTaskRideTrain(pTrain, pUseScenarioTask);
  7267. }
  7268. }
  7269. }
  7270. }
  7271.  
  7272. if (pTaskRideTrain)
  7273. {
  7274. CScriptPeds::GivePedScriptedTask(iPedIndex, pTaskRideTrain, SCRIPT_TASK_USE_NEAREST_TRAIN_SCENARIO_TO_POS, "TASK_USE_NEAREST_TRAIN_SCENARIO_TO_COORD_WARP");
  7275. }
  7276. }
  7277.  
  7278. void CommandTaskUseNearestScenarioChainToPos( int iPedIndex, const scrVector & svScenarioInPlace, float fMaxRange, int iTimeToLeave )
  7279. {
  7280. if(SCRIPT_VERIFY(iPedIndex != NULL_IN_SCRIPTING_LANGUAGE, "Ped index was NULL!"))
  7281. {
  7282. // Find the ped.
  7283. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  7284. if (pPed)
  7285. {
  7286. CTask* pTask = CommonUseNearestScenarioChainToPos(pPed, svScenarioInPlace, fMaxRange, false, false, iTimeToLeave);
  7287. if(pTask)
  7288. {
  7289. // Give the ped the scenario following task.
  7290. CScriptPeds::GivePedScriptedTask(iPedIndex, pTask, SCRIPT_TASK_USE_NEAREST_SCENARIO_CHAIN_TO_POS, "TASK_USE_NEAREST_SCENARIO_CHAIN_TO_COORD");
  7291. }
  7292. }
  7293. }
  7294. }
  7295.  
  7296. void CommandTaskUseNearestScenarioChainToPosWarp( int iPedIndex, const scrVector & svScenarioPlace, float fMaxRange, int iTimeToLeave )
  7297. {
  7298. if(SCRIPT_VERIFY(iPedIndex != NULL_IN_SCRIPTING_LANGUAGE, "Ped index was NULL!"))
  7299. {
  7300. // Find the ped.
  7301. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  7302. if (pPed)
  7303. {
  7304. CTask* pTask = CommonUseNearestScenarioChainToPos(pPed, svScenarioPlace, fMaxRange, true, false, iTimeToLeave);
  7305. if(pTask)
  7306. {
  7307. // Give the ped the scenario following task.
  7308. CScriptPeds::GivePedScriptedTask(iPedIndex, pTask, SCRIPT_TASK_USE_NEAREST_SCENARIO_CHAIN_TO_POS, "TASK_USE_NEAREST_SCENARIO_CHAIN_TO_COORD_WARP");
  7309. }
  7310. }
  7311. }
  7312. }
  7313.  
  7314. bool CommandIsPedActiveInScenario(int iPedIndex)
  7315. {
  7316. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex);
  7317. if (SCRIPT_VERIFY(pPed, "PedIndex was invalid for IS_PED_ACTIVE_IN_SCENARIO or IS_PED_PLAYING_BASE_CLIP_IN_SCENARIO!"))
  7318. {
  7319. CTaskUseScenario* pTaskScenario = static_cast<CTaskUseScenario*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_USE_SCENARIO));
  7320. if (pTaskScenario)
  7321. {
  7322. // The ped is really only "in" the scenario when they are playing the ambient animations associated with it.
  7323. return pTaskScenario->GetState() == CTaskUseScenario::State_PlayAmbients;
  7324. }
  7325. }
  7326.  
  7327. return false;
  7328. }
  7329.  
  7330. bool CommandIsPedPlayingBaseClipInScenario(int iPedIndex)
  7331. {
  7332. if (CommandIsPedActiveInScenario(iPedIndex))
  7333. {
  7334. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex);
  7335. if (pPed)
  7336. {
  7337. CTaskAmbientClips* pTaskAmbientClips = static_cast<CTaskAmbientClips*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_AMBIENT_CLIPS));
  7338. if (pTaskAmbientClips)
  7339. {
  7340. return pTaskAmbientClips->IsBaseClipFullyBlended();
  7341. }
  7342. }
  7343. }
  7344.  
  7345. return false;
  7346. }
  7347.  
  7348. void CommandSetCanPlayAmbientIdles(int PedIndex, bool bBlockIdleClips, bool bRemoveIdleClipIfPlaying)
  7349. {
  7350. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  7351. if (pPed)
  7352. {
  7353. CTaskAmbientClips* pTaskAmbientClips = static_cast<CTaskAmbientClips*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_AMBIENT_CLIPS));
  7354. if (pTaskAmbientClips)
  7355. {
  7356. pTaskAmbientClips->SetBlockAmbientIdles(bBlockIdleClips);
  7357. pTaskAmbientClips->SetRemoveAmbientIdles(bRemoveIdleClipIfPlaying);
  7358. }
  7359. }
  7360. }
  7361.  
  7362. void CommandTaskSwapWeapon(int PedIndex, bool bDrawWeapon)
  7363. {
  7364. u32 nFlags = SWAP_HOLSTER;
  7365. if(bDrawWeapon)
  7366. nFlags |= SWAP_DRAW;
  7367.  
  7368. CTask* pTask = rage_new CTaskSwapWeapon(nFlags);
  7369. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_SWAP_WEAPON, "TASK_SWAP_WEAPON");
  7370. }
  7371.  
  7372.  
  7373. void CommandTaskReloadWeapon(int PedIndex, bool UNUSED_PARAM(bDrawWeapon))
  7374. {
  7375. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  7376.  
  7377. if( SCRIPT_VERIFY(pPed , "PedIndex was invalid for TASK_RELOAD_WEAPON!") &&
  7378. SCRIPT_VERIFY(pPed->GetWeaponManager() , "WeaponManager was invalid for TASK_RELOAD_WEAPON!") &&
  7379. SCRIPT_VERIFY(pPed->GetWeaponManager()->GetEquippedWeapon() , "Equipped weapon was invalid for TASK_RELOAD_WEAPON!") )
  7380. {
  7381. CTaskReloadGun* pTaskToGiveToPed = rage_new CTaskReloadGun(CWeaponController::WCT_Reload);
  7382. if (SCRIPT_VERIFY(pTaskToGiveToPed, "TASK_RELOAD_WEAPON - Unable to create reload gun task"))
  7383. {
  7384. CScriptPeds::GivePedScriptedTask(PedIndex, pTaskToGiveToPed, SCRIPT_TASK_RELOAD_WEAPON, "TASK_RELOAD_WEAPON");
  7385. }
  7386. }
  7387. }
  7388.  
  7389. void CommandTaskCombatRoll(int UNUSED_PARAM(PedIndex), s32 UNUSED_PARAM(iDirection))
  7390. {
  7391. scriptAssertf(0, "TASK_COMBAT_ROLL removed");
  7392. }
  7393.  
  7394. void CommandTaskSkyDive(int iPedIndex, bool bInstant)
  7395. {
  7396. fwFlags32 fallFlags = FF_ForceSkyDive;
  7397. if(bInstant)
  7398. {
  7399. fallFlags.SetFlag(FF_InstantBlend);
  7400. fallFlags.SetFlag(FF_DisableSkydiveTransition);
  7401. }
  7402.  
  7403. CTaskComplexControlMovement * pCtrlTask;
  7404. pCtrlTask = rage_new CTaskComplexControlMovement( rage_new CTaskMoveInAir(), rage_new CTaskFall(fallFlags), CTaskComplexControlMovement::TerminateOnSubtask );
  7405.  
  7406. CScriptPeds::GivePedScriptedTask(iPedIndex, pCtrlTask, SCRIPT_TASK_SKY_DIVE, "TASK_SKY_DIVE");
  7407. }
  7408.  
  7409. void CommandTaskParachute(int iPedID, bool UNUSED_PARAM(bGiveParachuteItem), bool bInstant)
  7410. {
  7411. //Note: The 'give parachute' param is being ignored -- it is
  7412. // too error prone, and causes asserts and failed tasks.
  7413.  
  7414. fwFlags32 paraFlags = CTaskParachute::PF_GiveParachute;
  7415. if(bInstant)
  7416. {
  7417. paraFlags.SetFlag(CTaskParachute::PF_InstantBlend);
  7418. }
  7419.  
  7420. CTaskParachute *pTask = rage_new CTaskParachute(paraFlags);
  7421. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_PARACHUTE, "TASK_PARACHUTE");
  7422. }
  7423.  
  7424. void CommandTaskParachuteToTarget(int iPedID, const scrVector & svTargetLocation)
  7425. {
  7426. CTaskParachute *pTask = rage_new CTaskParachute(CTaskParachute::PF_GiveParachute | CTaskParachute::PF_SkipSkydiving);
  7427. pTask->SetTargetPosition(VECTOR3_TO_VEC3V((Vector3)svTargetLocation));
  7428. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_PARACHUTE_TO_TARGET, "TASK_PARACHUTE_TO_TARGET");
  7429. }
  7430.  
  7431. void CommandSetParachuteTaskTarget(int iPedID, const scrVector & svTargetLocation)
  7432. {
  7433. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  7434. if (pPed)
  7435. {
  7436. CTaskParachute *pTaskParachute = (CTaskParachute *)pPed->GetPedIntelligence()->FindTaskByType(CTaskTypes::TASK_PARACHUTE);
  7437. if (SCRIPT_VERIFY(pTaskParachute, "Ped isn't running parachute task, please use GET_PED_PARACHUTE_STATE != PPS_INVALID to check") )
  7438. {
  7439. pTaskParachute->GetParachuteFlags().SetFlag(CTaskParachute::PF_SkipSkydiving);
  7440. pTaskParachute->SetTargetPosition(VECTOR3_TO_VEC3V((Vector3)svTargetLocation));
  7441. }
  7442. }
  7443. }
  7444.  
  7445. void CommandSetParachuteTaskThrust(int iPedID, float fThrust)
  7446. {
  7447. CPed *pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  7448. if (pPed)
  7449. {
  7450. CTaskParachute *pTaskParachute = (CTaskParachute *)pPed->GetPedIntelligence()->FindTaskByType(CTaskTypes::TASK_PARACHUTE);
  7451. if (SCRIPT_VERIFY(pTaskParachute, "Ped isn't running parachute task, please use GET_PED_PARACHUTE_STATE != PPS_INVALID to check") )
  7452. {
  7453. pTaskParachute->SetParachuteThrust(fThrust);
  7454. }
  7455. }
  7456. }
  7457.  
  7458. void CommandSetParachuteTaskTargetEntity(int iPedID, int iTargetID, const scrVector & vOffset)
  7459. {
  7460. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  7461. if(pPed)
  7462. {
  7463. const CPhysical* pTarget = CTheScripts::GetEntityToModifyFromGUID<CPhysical>(iTargetID);
  7464. if(pTarget)
  7465. {
  7466. CTaskParachute* pTaskParachute = static_cast<CTaskParachute *>(pPed->GetPedIntelligence()->FindTaskByType(CTaskTypes::TASK_PARACHUTE));
  7467. if(SCRIPT_VERIFY(pTaskParachute, "Ped isn't running parachute task, please use GET_PED_PARACHUTE_STATE != PPS_INVALID to check") )
  7468. {
  7469. pTaskParachute->SetTarget(pTarget, VECTOR3_TO_VEC3V((Vector3)vOffset));
  7470. }
  7471. }
  7472. }
  7473. }
  7474.  
  7475. void CommandTaskJetpack(int iPedID)
  7476. {
  7477. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  7478. if(pPed)
  7479. {
  7480. //Ensure the inventory is valid.
  7481. CPedInventory* pPedInventory = pPed->GetInventory();
  7482. if(pPedInventory)
  7483. {
  7484. //! Give ped a jetpack.
  7485. pPedInventory->AddWeapon(GADGETTYPE_JETPACK);
  7486.  
  7487. //! Equip it.
  7488. pPed->SetPedConfigFlag(CPED_CONFIG_FLAG_EquipJetpack, true);
  7489. }
  7490. }
  7491. }
  7492.  
  7493. void CommandTaskJetpackGoToCoord(int JETPACK_ONLY(iPedID), const scrVector & JETPACK_ONLY(scrVecCoors), float JETPACK_ONLY(fMinHeightFromGround), bool JETPACK_ONLY(bDisableThrustAtDestination))
  7494. {
  7495. #if ENABLE_JETPACK
  7496. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  7497. if(pPed)
  7498. {
  7499. CTask* pTask = pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_JETPACK);
  7500. if (SCRIPT_VERIFY(pTask, "TASK_JETPACK_GO_TO_COORD - Not running jetpack task!"))
  7501. {
  7502. CTaskJetpack *pTaskJetpack = static_cast<CTaskJetpack*>(pTask);
  7503. if (SCRIPT_VERIFY(pTaskJetpack, "TASK_JETPACK_GO_TO_COORD - Not running jetpack task!"))
  7504. {
  7505. Vector3 vCoord = Vector3(scrVecCoors);
  7506. pTaskJetpack->SetGoToParametersForAI(NULL, vCoord, fMinHeightFromGround, bDisableThrustAtDestination);
  7507. }
  7508. }
  7509. }
  7510. #endif
  7511. }
  7512.  
  7513. void CommandTaskJetpackGoToEntity(int JETPACK_ONLY(iPedID), int JETPACK_ONLY(iTargetEntityID), const scrVector & JETPACK_ONLY(scrVecCoorsOffset), float JETPACK_ONLY(fMinHeightFromGround), bool JETPACK_ONLY(bDisableThrustAtDestination), bool JETPACK_ONLY(bUseRandomTimerWhenClose))
  7514. {
  7515. #if ENABLE_JETPACK
  7516. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  7517. if(pPed)
  7518. {
  7519. CTask* pTask = pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_JETPACK);
  7520. if (SCRIPT_VERIFY(pTask, "TASK_JETPACK_GO_TO_ENTITY - Not running jetpack task!"))
  7521. {
  7522. CTaskJetpack *pTaskJetpack = static_cast<CTaskJetpack*>(pTask);
  7523. if (SCRIPT_VERIFY(pTaskJetpack, "TASK_JETPACK_GO_TO_ENTITY - Not running jetpack task!"))
  7524. {
  7525. CPhysical* pTargetPhysical = CTheScripts::GetEntityToModifyFromGUID<CPhysical>(iTargetEntityID);
  7526. if (SCRIPT_VERIFY(pTargetPhysical, "TASK_JETPACK_GO_TO_ENTITY - Target entity is not valid!"))
  7527. {
  7528. Vector3 vCoord = Vector3(scrVecCoorsOffset);
  7529. pTaskJetpack->SetGoToParametersForAI(pTargetPhysical, vCoord, fMinHeightFromGround, bDisableThrustAtDestination, bUseRandomTimerWhenClose);
  7530. }
  7531. }
  7532. }
  7533. }
  7534. #endif
  7535. }
  7536.  
  7537. void CommandTaskJetpackShootAtCoord(int JETPACK_ONLY(iPedID), const scrVector & JETPACK_ONLY(scrVecCoors), float JETPACK_ONLY(fAbortRange), int JETPACK_ONLY(iFrequencyPercentage), int JETPACK_ONLY(iFiringPatternHash))
  7538. {
  7539. #if ENABLE_JETPACK
  7540. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  7541. if(pPed)
  7542. {
  7543. CTask* pTask = pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_JETPACK);
  7544. if (SCRIPT_VERIFY(pTask, "TASK_JETPACK_SHOOT_AT_COORD - Not running jetpack task!"))
  7545. {
  7546. CTaskJetpack *pTaskJetpack = static_cast<CTaskJetpack*>(pTask);
  7547. if (SCRIPT_VERIFY(pTaskJetpack, "TASK_JETPACK_SHOOT_AT_COORD - Not running jetpack task!"))
  7548. {
  7549. Vector3 vCoord = Vector3(scrVecCoors);
  7550. pTaskJetpack->SetShootAtParametersForAI(NULL, vCoord, fAbortRange, iFrequencyPercentage, iFiringPatternHash);
  7551. }
  7552. }
  7553. }
  7554. #endif
  7555. }
  7556.  
  7557. void CommandTaskJetpackShootAtEntity(int JETPACK_ONLY(iPedID), int JETPACK_ONLY(iTargetEntityID), const scrVector & JETPACK_ONLY(scrVecCoorsOffset), float JETPACK_ONLY(fAbortRange), int JETPACK_ONLY(iFrequencyPercentage), int JETPACK_ONLY(iFiringPatternHash))
  7558. {
  7559. #if ENABLE_JETPACK
  7560. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  7561. if(pPed)
  7562. {
  7563. CTask* pTask = pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_JETPACK);
  7564. if (SCRIPT_VERIFY(pTask, "TASK_JETPACK_SHOOT_AT_ENTITY - Not running jetpack task!"))
  7565. {
  7566. CTaskJetpack *pTaskJetpack = static_cast<CTaskJetpack*>(pTask);
  7567. if (SCRIPT_VERIFY(pTaskJetpack, "TASK_JETPACK_SHOOT_AT_ENTITY - Not running jetpack task!"))
  7568. {
  7569. Vector3 vCoord = Vector3(scrVecCoorsOffset);
  7570.  
  7571. CPhysical* pTargetPhysical = CTheScripts::GetEntityToModifyFromGUID<CPhysical>(iTargetEntityID);
  7572. if (SCRIPT_VERIFY(pTargetPhysical, "TASK_JETPACK_SHOOT_AT_ENTITY - Target entity is not valid!"))
  7573. {
  7574. pTaskJetpack->SetShootAtParametersForAI(pTargetPhysical, vCoord, fAbortRange, iFrequencyPercentage, iFiringPatternHash);
  7575. }
  7576.  
  7577. }
  7578. }
  7579. }
  7580. #endif
  7581. }
  7582.  
  7583. void CommandTaskJetpackStopShooting(int JETPACK_ONLY(iPedID))
  7584. {
  7585. #if ENABLE_JETPACK
  7586. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  7587. if(pPed)
  7588. {
  7589. CTask* pTask = pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_JETPACK);
  7590. if (SCRIPT_VERIFY(pTask, "TASK_JETPACK_SHOOT_AT_COORD - Not running jetpack task!"))
  7591. {
  7592. CTaskJetpack *pTaskJetpack = static_cast<CTaskJetpack*>(pTask);
  7593. if (SCRIPT_VERIFY(pTaskJetpack, "TASK_JETPACK_SHOOT_AT_COORD - Not running jetpack task!"))
  7594. {
  7595. pTaskJetpack->RequestDrivebyTermination(true);
  7596. }
  7597. }
  7598. }
  7599. #endif
  7600. }
  7601.  
  7602. void CommandTaskRappelFromHeli(int iPedIndex, float fMinRappelHeight)
  7603. {
  7604. CTaskHeliPassengerRappel* pRappelTask = rage_new CTaskHeliPassengerRappel(fMinRappelHeight);
  7605. CScriptPeds::GivePedScriptedTask(iPedIndex, pRappelTask, SCRIPT_TASK_RAPPEL_FROM_HELI, "TASK_RAPPEL_FROM_HELI");
  7606. }
  7607.  
  7608. void CommandTaskDragPedToCoord(int iDraggerIndex, int iDraggedIndex, const scrVector & vCoords, float fMoveBlendRatioForApproach)
  7609. {
  7610. CPed* pDragged = CTheScripts::GetEntityToModifyFromGUID<CPed>(iDraggedIndex, CTheScripts::GUID_ASSERT_FLAGS_NO_DEAD_CHECK);
  7611. if(pDragged)
  7612. {
  7613. CTaskDraggingToSafety* pTask = rage_new CTaskDraggingToSafety(pDragged, NULL, CTaskDraggingToSafety::CF_CoverNotRequired);
  7614. pTask->DragToPosition(vCoords);
  7615. pTask->SetMoveBlendRatioForApproach(fMoveBlendRatioForApproach);
  7616.  
  7617. CScriptPeds::GivePedScriptedTask(iDraggerIndex, pTask, SCRIPT_TASK_DRAG_PED_TO_COORD, "TASK_DRAG_PED_TO_COORD");
  7618. }
  7619. }
  7620.  
  7621. bool CommandIsPedGettingUp(int PedIndex)
  7622. {
  7623. const CPed *pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  7624. if(pPed)
  7625. {
  7626. return pPed->GetPedIntelligence()->IsPedGettingUp();
  7627. }
  7628. return false;
  7629. }
  7630.  
  7631. void CommandTaskWrithe(int iPedID, int iPedTargetID, int nMinFireLoops, int UNUSED_PARAM(StartState), bool bForceShootOnGround, int nShootFromGroundTimer)
  7632. {
  7633. const CPed* pTargetPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedTargetID);
  7634. if (SCRIPT_VERIFY(pTargetPed, "SCRIPT_TASK_WRITHE - Invalid target"))
  7635. {
  7636. bool bFromGetUp = true;
  7637. bool bEnableRagdollOnCollision = true;
  7638.  
  7639. if (bForceShootOnGround)
  7640. {
  7641. bEnableRagdollOnCollision = false;
  7642. }
  7643.  
  7644. CTaskWrithe* pTask = rage_new CTaskWrithe(CWeaponTarget(pTargetPed), bFromGetUp, bEnableRagdollOnCollision , bForceShootOnGround);
  7645. pTask->SetMinFireLoops(nMinFireLoops);
  7646. pTask->SetShootFromGroundTimer(nShootFromGroundTimer);
  7647.  
  7648. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_WRITHE, "TASK_WRITHE");
  7649. }
  7650. }
  7651.  
  7652. bool CommandIsPedInWrithe(int iPedID)
  7653. {
  7654. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedID);
  7655. if (SCRIPT_VERIFY(pPed, "SCRIPT_TASK_WRITHE - Invalid target"))
  7656. {
  7657. return pPed->GetPedResetFlag(CPED_RESET_FLAG_IsInWrithe);
  7658. }
  7659.  
  7660. return false;
  7661. }
  7662.  
  7663. void CommandOpenPatrolRoute(const char* RouteName)
  7664. {
  7665. CTheScripts::GetScriptPatrol().OpenPatrolRoute(RouteName);
  7666. }
  7667.  
  7668. void CommandClosePatrolRoute()
  7669. {
  7670. CTheScripts::GetScriptPatrol().ClosePatrolRoute();
  7671. }
  7672.  
  7673. void CommandAddPatrolNode(int NodeId, const char* NodeType, const scrVector & scrNodePos, const scrVector & scrNodeHeading, int Duration)
  7674. {
  7675. Vector3 vNodePos(scrNodePos);
  7676. Vector3 vNodeHeading(scrNodeHeading);
  7677.  
  7678. CTheScripts::GetScriptPatrol().AddPatrolNode(NodeId, NodeType, vNodePos, vNodeHeading, Duration);
  7679. }
  7680.  
  7681. void CommandAddPatrolNodeLink(int NodeID1, int NodeID2)
  7682. {
  7683. CTheScripts::GetScriptPatrol().AddPatrolLink(NodeID1, NodeID2);
  7684. }
  7685.  
  7686. void CommandCreatePatrolRoute()
  7687. {
  7688. CTheScripts::GetScriptPatrol().CreatePatrolRoute();
  7689. }
  7690.  
  7691. void CommandDeletePatrolRoute(const char * RouteName)
  7692. {
  7693. u32 HashedRouteName = atStringHash(RouteName);
  7694.  
  7695. CTheScripts::GetCurrentGtaScriptHandler()->RemoveScriptResource(CGameScriptResource::SCRIPT_RESOURCE_PATROL_ROUTE, static_cast<ScriptResourceRef>(HashedRouteName));
  7696. }
  7697.  
  7698. void CommandTaskPatrol (int PedIndex, const char* cPatrolRouteName, int iAlertState, bool bCanChatToPeds, bool bUseHeadLookAt)
  7699. {
  7700. SCRIPT_ASSERT(cPatrolRouteName,"Error, NULL patrol route name, did you forget to initialise the route name?");
  7701.  
  7702. int iRouteNameHash =atStringHash(cPatrolRouteName);
  7703. CTaskPatrol::AlertStatus asAlertState = CTaskPatrol::AlertStatus (iAlertState);
  7704. u32 iPatrolFlags = 0;
  7705. if (bCanChatToPeds)
  7706. {
  7707. iPatrolFlags |= GF_CanChatToPeds;
  7708. }
  7709. if (bUseHeadLookAt)
  7710. {
  7711. iPatrolFlags |= GF_UseHeadLookAt;
  7712. }
  7713.  
  7714. CTask* pTask = rage_new CTaskPatrol(iRouteNameHash, asAlertState, iPatrolFlags);
  7715. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_PATROL, "TASK_PATROL");
  7716. }
  7717.  
  7718. void CommandTaskStayInCover (int PedIndex)
  7719. {
  7720. CTask* pTask = rage_new CTaskStayInCover();
  7721. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_STAY_IN_COVER, "TASK_STAY_IN_COVER");
  7722. }
  7723.  
  7724. bool CommandGetPatrolNodeInfo (int PedIndex, int &iTimeLeftAtNode, int &iNodeId)
  7725. {
  7726. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  7727. bool bHaveVaildTask = false;
  7728.  
  7729. if (pPed)
  7730. {
  7731.  
  7732. CTask* pTask = pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_PATROL);
  7733. //CTask* pTask = pPedAI->GetTaskManager()->GetActiveTask();
  7734.  
  7735. if (pTask && pTask->GetTaskType()==CTaskTypes::TASK_PATROL)
  7736. {
  7737. CTaskPatrol* pPatrolTask = (CTaskPatrol*)pTask;
  7738. iNodeId = pPatrolTask->CTaskPatrol::GetCurrentNode();
  7739. iTimeLeftAtNode = pPatrolTask->CTaskPatrol::GetTimeLeftAtNode();
  7740. bHaveVaildTask = true;
  7741. }
  7742.  
  7743. }
  7744. return bHaveVaildTask;
  7745.  
  7746. }
  7747.  
  7748. void CommandTaskHangGlider(int UNUSED_PARAM(PedIndex), int UNUSED_PARAM(HangGliderObjectIndex))
  7749. {
  7750. Assertf(0, "HangGlider is deprecated functionality");
  7751. }
  7752.  
  7753. void CommandSetHangGliderAirSpeed(int UNUSED_PARAM(PedIndex), const scrVector & UNUSED_PARAM(scrVAirSpeed))
  7754. {
  7755. Assertf(0, "HangGlider is deprecated functionality");
  7756. }
  7757.  
  7758. void CommandVehicleShootAtPed(int PedIndex, int OtherPedIndex, float fFireTolerance)
  7759. {
  7760. const CPed* pOtherPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(OtherPedIndex);
  7761.  
  7762. if (pOtherPed)
  7763. {
  7764. CAITarget target(pOtherPed);
  7765. CTask* pTask=rage_new CTaskVehicleCombat(&target, 0, fFireTolerance);
  7766. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_VEHICLE_SHOOT_AT_ENTITY, "TASK_VEHICLE_SHOOT_AT_PED");
  7767. }
  7768. }
  7769.  
  7770. void CommandVehicleAimAtPed(int PedIndex, int OtherPedIndex)
  7771. {
  7772. const CPed* pOtherPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(OtherPedIndex);
  7773.  
  7774. if (pOtherPed)
  7775. {
  7776. CAITarget target(pOtherPed);
  7777. CTask* pTask=rage_new CTaskVehicleCombat(&target, CTaskVehicleCombat::Flag_justAim);
  7778. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_VEHICLE_AIM_AT_ENTITY, "TASK_VEHICLE_AIM_AT_PED");
  7779. }
  7780. }
  7781.  
  7782. void CommandVehicleShootAtCoord(int PedIndex, const scrVector & svTarget, float fFireTolerance)
  7783. {
  7784. Vector3 vTarget(svTarget);
  7785. CAITarget target(vTarget);
  7786.  
  7787. CTask* pTask=rage_new CTaskVehicleCombat(&target, 0, fFireTolerance);
  7788. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_VEHICLE_SHOOT_AT_COORD, "TASK_VEHICLE_SHOOT_AT_COORD");
  7789. }
  7790.  
  7791. void CommandVehicleAimAtCoord(int PedIndex, const scrVector & svTarget)
  7792. {
  7793. Vector3 vTarget(svTarget);
  7794. CAITarget target(vTarget);
  7795.  
  7796. CTask* pTask=rage_new CTaskVehicleCombat(&target, CTaskVehicleCombat::Flag_justAim);
  7797. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_VEHICLE_AIM_AT_COORD, "TASK_VEHICLE_AIM_AT_COORD");
  7798. }
  7799.  
  7800. void CommandVehicleAimUsingCamera(int PedIndex)
  7801. {
  7802. CTask* pTask=rage_new CTaskVehicleCombat(NULL, CTaskVehicleCombat::Flag_useCamera);
  7803. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_VEHICLE_AIM_USING_CAMERA, "TASK_VEHICLE_AIM_USING_CAMERA");
  7804. }
  7805.  
  7806. // Give a ped the bind-pose task to examine the transition from NM to animation.
  7807. // DEV ONLY!
  7808. void CommandTaskBindPose(int DEV_ONLY(iPedID), bool DEV_ONLY(bDoBlendFromNM))
  7809. {
  7810. #if __DEV
  7811. CTask* pTask = rage_new CTaskBindPose(bDoBlendFromNM);
  7812. CScriptPeds::GivePedScriptedTask(iPedID, pTask, SCRIPT_TASK_BIND_POSE, "TASK_BIND_POSE");
  7813. #endif // __DEV
  7814. }
  7815.  
  7816. // Give ped an NM electrocution task.
  7817. void CommandElectrocute(int iPedID, int nMinTime, int nMaxTime)
  7818. {
  7819. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  7820. if (pPed && CTaskNMBehaviour::CanUseRagdoll(pPed, RAGDOLL_TRIGGER_SCRIPT) )
  7821. {
  7822. UpdatePedRagdollBoundsForScriptActivation(pPed);
  7823. CTask* pNmTask = rage_new CTaskNMElectrocute(nMinTime, nMaxTime);
  7824. CEventSwitch2NM event(nMaxTime, pNmTask, true, nMinTime);
  7825. pPed->SwitchToRagdoll(event);
  7826. }
  7827.  
  7828. }
  7829.  
  7830. // Give ped a high fall task.
  7831. void CommandHighFall(int iPedID, int nMinTime, int nMaxTime, int eEntryType)
  7832. {
  7833. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  7834. if (pPed && CTaskNMBehaviour::CanUseRagdoll(pPed, RAGDOLL_TRIGGER_SCRIPT) )
  7835. {
  7836. UpdatePedRagdollBoundsForScriptActivation(pPed);
  7837. CTask* pNmTask = rage_new CTaskNMHighFall(nMinTime, NULL, (CTaskNMHighFall::eHighFallEntryType)eEntryType);
  7838. CEventSwitch2NM event(nMaxTime, pNmTask, true, nMinTime);
  7839. pPed->SwitchToRagdoll(event);
  7840. }
  7841. }
  7842.  
  7843. // Give ped an NM dangle-from-meathook task.
  7844. void CommandDangleFromMeathook(bool bStart, int iPedID, int iHookID, const scrVector & scrPos, bool bDoGrab, float fFrequency, int UNUSED_PARAM(nMinTime), int nMaxTime,
  7845. bool bFixRotation, float fRotMinX, float fRotMinY, float fRotMinZ, float fRotMaxX, float fRotMaxY, float fRotMaxZ)
  7846. {
  7847. Vector3 pos = Vector3(scrPos.x, scrPos.y, scrPos.z);
  7848. Vector3 vecRotMinLimits = Vector3(fRotMinX, fRotMinY, fRotMinZ);
  7849. Vector3 vecRotMaxLimits = Vector3(fRotMaxX, fRotMaxY, fRotMaxZ);
  7850.  
  7851. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  7852. if (pPed)
  7853. {
  7854. // First time activating?
  7855. if (bStart && CTaskNMBehaviour::CanUseRagdoll(pPed, RAGDOLL_TRIGGER_SCRIPT))
  7856. {
  7857. UpdatePedRagdollBoundsForScriptActivation(pPed);
  7858.  
  7859. // Give it the dangle task
  7860. CTask* pNmTask = rage_new CTaskNMDangle(pos);
  7861. CEventSwitch2NM event(nMaxTime, pNmTask, true);
  7862. pPed->SwitchToRagdoll(event);
  7863.  
  7864. // Set grab state
  7865. ((CTaskNMDangle*)pNmTask)->SetGrabParams(pPed, bDoGrab, fFrequency);
  7866.  
  7867. // Create the hook to world constraint
  7868. if (pPed->GetRagdollConstraintData())
  7869. {
  7870. CPhysical* pHook = CTheScripts::GetEntityToModifyFromGUID<CPhysical>(iHookID);
  7871. AssertMsg(pHook && pHook->GetCurrentPhysicsInst(), "CommandDangleFromMeathook - valid hookID not provided");
  7872. if (pHook && pHook->GetCurrentPhysicsInst())
  7873. pPed->GetRagdollConstraintData()->CreateHookToWorldConstraint(pHook, pos, bFixRotation, vecRotMinLimits, vecRotMaxLimits);
  7874. }
  7875. }
  7876.  
  7877. // Set grab state
  7878. if (CTaskNMDangle* pTaskDangle = static_cast<CTaskNMDangle*>(
  7879. pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_NM_DANGLE)))
  7880. {
  7881. pTaskDangle->SetGrabParams(pPed, bDoGrab, fFrequency);
  7882. pTaskDangle->UpdateHookConstraint(pos, vecRotMinLimits, vecRotMaxLimits);
  7883. }
  7884. else if (pPed->GetRagdollConstraintData())
  7885. {
  7886. // Update the hook to world constraint manually if the dangle task has ended
  7887. pPed->GetRagdollConstraintData()->UpdateHookToWorldConstraint(pos, vecRotMinLimits, vecRotMaxLimits);
  7888. }
  7889. }
  7890. }
  7891.  
  7892. // Give ped an NM slung-over-shoulder task.
  7893. void CommandSlungOverShoulder(int iPedIDSlungPed, int iPedIDCarrier, int nMinTime, int nMaxTime)
  7894. {
  7895. CPed* pPedSlung = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIDSlungPed);
  7896. CPed* pPedCarrier = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIDCarrier);
  7897. if (pPedSlung && pPedCarrier && CTaskNMBehaviour::CanUseRagdoll(pPedSlung, RAGDOLL_TRIGGER_SLUNG_OVER_SHOULDER))
  7898. {
  7899. // Perform normal collision to avoid popping upon activation
  7900. pPedSlung->GetRagdollInst()->SetDontZeroMatricesOnActivation();
  7901.  
  7902. UpdatePedRagdollBoundsForScriptActivation(pPedSlung);
  7903.  
  7904. // Give it the slung over shoulder task
  7905. CTask* pNmTask = rage_new CTaskNMSlungOverShoulder(pPedSlung, pPedCarrier);
  7906. CEventSwitch2NM event(nMaxTime, pNmTask, true, nMinTime);
  7907. pPedSlung->SwitchToRagdoll(event);
  7908. }
  7909. }
  7910.  
  7911. // Give ped an NM stumble task.
  7912. void CommandStumble(int iPedID, int nMinTime, int nMaxTime)
  7913. {
  7914. Assertf(0, "CommandStumble is no longer supported");
  7915.  
  7916. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  7917. if (pPed && CTaskNMBehaviour::CanUseRagdoll(pPed, RAGDOLL_TRIGGER_SCRIPT) )
  7918. {
  7919. UpdatePedRagdollBoundsForScriptActivation(pPed);
  7920.  
  7921. CTask* pNmTask = rage_new CTaskNMRelax(nMinTime, nMaxTime);
  7922. CEventSwitch2NM event(nMaxTime, pNmTask, true, nMinTime);
  7923. pPed->SwitchToRagdoll(event);
  7924. }
  7925. }
  7926.  
  7927. void CommandTaskSetBlockingOfNonTemporaryEvents (int PedIndex, bool bSet)
  7928. {
  7929. CTask* pTask=rage_new CTaskSetBlockingOfNonTemporaryEvents(bSet);
  7930. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_SET_BLOCKING_OF_NON_TEMPORARY_EVENTS, "TASK_SET_BLOCKING_OF_NON_TEMPORARY_EVENTS");
  7931. }
  7932.  
  7933. void CommandTaskForceMotionState (int PedIndex, int motionState, bool bForceRestart)
  7934. {
  7935. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex, 0);
  7936. if (scriptVerifyf(CPed::IsAllowedToForceMotionState((CPedMotionStates::eMotionState)motionState, pPed), "%s: TASK_FORCE_MOTION_STATE - Failed to force state %d - See TTY for details", CTheScripts::GetCurrentScriptNameAndProgramCounter(), motionState))
  7937. {
  7938. CTask* pTask=rage_new CTaskForceMotionState((CPedMotionStates::eMotionState)motionState, bForceRestart);
  7939. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_FORCE_MOTION_STATE, "TASK_FORCE_MOTION_STATE");
  7940. }
  7941. }
  7942.  
  7943. void CommandTaskMoveNetworkByName(int PedIndex, const char *network, float blendDuration, bool bAllowOverrideCloneUpdate, const char* szDictionary, s32 flags)
  7944. {
  7945. if (scriptVerifyf(g_NetworkDefStore.FindSlot(network)!=-1, "TASK_MOVE_NETWORK_BY_NAME - Network def '%s' does not exist!", network ))
  7946. {
  7947. u32 iFlags = (u32)flags;
  7948.  
  7949. if(bAllowOverrideCloneUpdate)
  7950. {
  7951. iFlags |= CTaskMoVEScripted::Flag_AllowOverrideCloneUpdate;
  7952. }
  7953.  
  7954. CTaskMoVEScripted* pTask=rage_new CTaskMoVEScripted(fwMvNetworkDefId(network), iFlags, blendDuration, VEC3_ZERO, Quaternion::sm_I);
  7955.  
  7956. if(szDictionary && szDictionary[0] != '\0')
  7957. {
  7958. pTask->SetCloneSyncDictHash(atStringHash(szDictionary));
  7959. }
  7960.  
  7961. bool bPartOfASequence = (PedIndex == NULL_IN_SCRIPTING_LANGUAGE);
  7962.  
  7963. if (iFlags&CTaskMoVEScripted::Flag_Secondary)
  7964. {
  7965. if(SCRIPT_VERIFY( !bPartOfASequence, "TASK_MOVE_NETWORK_BY_NAME_SECONDARY* Cant be used in a sequence!" ))
  7966. {
  7967. CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  7968. if(pPed)
  7969. {
  7970. pPed->GetPedIntelligence()->AddTaskSecondary( pTask, PED_TASK_SECONDARY_PARTIAL_ANIM );
  7971. }
  7972. }
  7973. return;
  7974. }
  7975.  
  7976. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_MOVE_NETWORK, "TASK_MOVE_NETWORK");
  7977. }
  7978. }
  7979.  
  7980. void CommandTaskMoveNetworkByNameWithInitParams(int PedIndex, const char *network, int& initialParameters, float blendDuration, bool bAllowOverrideCloneUpdate, const char* szDictionary, s32 flags)
  7981. {
  7982. if (scriptVerifyf(g_NetworkDefStore.FindSlot(network)!=-1, "TASK_MOVE_NETWORK_BY_NAME - Network def '%s' does not exist!", network ))
  7983. {
  7984. u32 iFlags = (u32)flags;
  7985.  
  7986. if(bAllowOverrideCloneUpdate)
  7987. {
  7988. iFlags |= CTaskMoVEScripted::Flag_AllowOverrideCloneUpdate;
  7989. }
  7990.  
  7991. CTaskMoVEScripted::ScriptInitialParameters* pInitParams = reinterpret_cast<CTaskMoVEScripted::ScriptInitialParameters*>(&initialParameters);
  7992.  
  7993. CTaskMoVEScripted* pTask=rage_new CTaskMoVEScripted(fwMvNetworkDefId(network), iFlags, blendDuration, VEC3_ZERO, Quaternion::sm_I, pInitParams);
  7994.  
  7995. if(szDictionary && szDictionary[0] != '\0')
  7996. {
  7997. pTask->SetCloneSyncDictHash(atStringHash(szDictionary));
  7998. }
  7999.  
  8000. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_MOVE_NETWORK, "TASK_MOVE_NETWORK");
  8001. }
  8002. }
  8003.  
  8004. void CommandTaskMoveNetworkAdvancedByName(int PedIndex, const char *network, const scrVector & pos, const scrVector & rot, s32 RotOrder, float blendDuration, bool bAllowOverrideCloneUpdate, const char* szDictionary, s32 flags)
  8005. {
  8006. if (scriptVerifyf(g_NetworkDefStore.FindSlot(network)!=-1, "TASK_MOVE_NETWORK_ADVANCED_BY_NAME - Network def '%s' does not exist!", network ))
  8007. {
  8008. u32 iFlags = ((u32)flags);
  8009.  
  8010. iFlags |= CTaskMoVEScripted::Flag_SetInitialPosition;
  8011.  
  8012. if(bAllowOverrideCloneUpdate)
  8013. {
  8014. iFlags |= CTaskMoVEScripted::Flag_AllowOverrideCloneUpdate;
  8015. }
  8016.  
  8017. Vector3 vPos(pos);
  8018. Vector3 vRot(rot);
  8019.  
  8020. vRot*= DtoR;
  8021.  
  8022. Quaternion qRot;
  8023. CScriptEulers::QuaternionFromEulers(qRot, vRot, static_cast<EulerAngleOrder>(RotOrder));
  8024. CTaskMoVEScripted* pTask=rage_new CTaskMoVEScripted(fwMvNetworkDefId(network), iFlags, blendDuration, vPos, qRot);
  8025.  
  8026. if(szDictionary && szDictionary[0] != '\0')
  8027. {
  8028. pTask->SetCloneSyncDictHash(atStringHash(szDictionary));
  8029. }
  8030.  
  8031. bool bPartOfASequence = (PedIndex == NULL_IN_SCRIPTING_LANGUAGE);
  8032.  
  8033. if (iFlags&CTaskMoVEScripted::Flag_Secondary)
  8034. {
  8035. if(SCRIPT_VERIFY( !bPartOfASequence, "TASK_MOVE_NETWORK_ADVANCED_BY_NAME_SECONDARY* Cant be used in a sequence!" ))
  8036. {
  8037. CPed * pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  8038. if(pPed)
  8039. {
  8040. pPed->GetPedIntelligence()->AddTaskSecondary( pTask, PED_TASK_SECONDARY_PARTIAL_ANIM );
  8041. }
  8042. }
  8043. return;
  8044. }
  8045.  
  8046. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_MOVE_NETWORK, "TASK_MOVE_NETWORK_ADVANCED");
  8047. }
  8048. }
  8049.  
  8050. CTaskMoVEScripted* FindScriptedMoveTask(const CPed* pPed)
  8051. {
  8052. CTask* pTask = pPed->GetPedIntelligence()->FindTaskByType(CTaskTypes::TASK_MOVE_SCRIPTED);
  8053.  
  8054. if (!pTask)
  8055. {
  8056. pTask = pPed->GetPedIntelligence()->FindTaskSecondaryByType(CTaskTypes::TASK_MOVE_SCRIPTED);
  8057. }
  8058.  
  8059. return static_cast<CTaskMoVEScripted*>(pTask);
  8060. }
  8061.  
  8062. void CommandTaskMoveNetworkAdvancedByNameWithInitParams(int PedIndex, const char *network, int& initialParameters, const scrVector & pos, const scrVector & rot, s32 RotOrder, float blendDuration, bool bAllowOverrideCloneUpdate, const char* szDictionary, s32 flags)
  8063. {
  8064. if (scriptVerifyf(g_NetworkDefStore.FindSlot(network)!=-1, "TASK_MOVE_NETWORK_ADVANCED_BY_NAME - Network def '%s' does not exist!", network ))
  8065. {
  8066. u32 iFlags = ((u32)flags);
  8067.  
  8068. iFlags |= CTaskMoVEScripted::Flag_SetInitialPosition;
  8069.  
  8070. if(bAllowOverrideCloneUpdate)
  8071. {
  8072. iFlags |= CTaskMoVEScripted::Flag_AllowOverrideCloneUpdate;
  8073. }
  8074.  
  8075. CTaskMoVEScripted::ScriptInitialParameters* pInitParams = reinterpret_cast<CTaskMoVEScripted::ScriptInitialParameters*>(&initialParameters);
  8076.  
  8077. Vector3 vPos(pos);
  8078. Vector3 vRot(rot);
  8079.  
  8080. vRot*= DtoR;
  8081.  
  8082. Quaternion qRot;
  8083. CScriptEulers::QuaternionFromEulers(qRot, vRot, static_cast<EulerAngleOrder>(RotOrder));
  8084. CTaskMoVEScripted* pTask=rage_new CTaskMoVEScripted(fwMvNetworkDefId(network), iFlags, blendDuration, vPos, qRot, pInitParams);
  8085.  
  8086. if(szDictionary && szDictionary[0] != '\0')
  8087. {
  8088. pTask->SetCloneSyncDictHash(atStringHash(szDictionary));
  8089. }
  8090.  
  8091. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_MOVE_NETWORK, "TASK_MOVE_NETWORK_ADVANCED");
  8092. }
  8093. }
  8094.  
  8095. bool CommandIsTaskMoveNetworkActive(int PedIndex)
  8096. {
  8097. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  8098. if (pPed && pPed->GetPedIntelligence())
  8099. {
  8100. CTaskMoVEScripted* pTaskMoVE = FindScriptedMoveTask(pPed);
  8101. if( pTaskMoVE && pTaskMoVE->GetIsNetworkActive() )
  8102. {
  8103. return true;
  8104. }
  8105. }
  8106. return false;
  8107. }
  8108.  
  8109. void CommandSetTaskMoveNetworkClipSet(s32 pedIndex, s32 clipSetHash, s32 variableClipSetHash = 0)
  8110. {
  8111. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(pedIndex);
  8112. if (pPed && pPed->GetPedIntelligence())
  8113. {
  8114. CTaskMoVEScripted* pTaskMoVE = FindScriptedMoveTask(pPed);
  8115. if( SCRIPT_VERIFY (pTaskMoVE, "SET_TASK_MOVE_NETWORK_CLIP_SET - task not running! Have you called TASK_MOVE_NETWORK_BY_NAME yet?" ) )
  8116. {
  8117. fwMvClipSetVarId varId;
  8118. fwMvClipSetId setId;
  8119. if (variableClipSetHash==0)
  8120. {
  8121. variableClipSetHash = CLIP_SET_VAR_ID_INVALID;
  8122. }
  8123.  
  8124. varId.SetHash((u32)variableClipSetHash);
  8125. setId.SetHash((u32)clipSetHash);
  8126.  
  8127. pTaskMoVE->SetClipSet(varId, setId);
  8128. }
  8129. }
  8130. }
  8131.  
  8132. bool CommandIsTaskMoveNetworkReadyForTransition(int PedIndex)
  8133. {
  8134. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  8135. if (pPed && pPed->GetPedIntelligence())
  8136. {
  8137. CTaskMoVEScripted* pTaskMoVE = FindScriptedMoveTask(pPed);
  8138. if (SCRIPT_VERIFY (pTaskMoVE, "IS_TASK_MOVE_NETWORK_READY_FOR_TRANSITION - task is not running!"))
  8139. {
  8140. if( SCRIPT_VERIFY (pTaskMoVE->GetIsNetworkActive(), "IS_TASK_MOVE_NETWORK_READY_FOR_TRANSITION - task not active! Check IS_TASK_MOVE_NETWORK_ACTIVE!" ) )
  8141. {
  8142. return pTaskMoVE->GetState() == CTaskMoVEScripted::State_InState;
  8143. }
  8144. }
  8145. }
  8146. return false;
  8147. }
  8148.  
  8149. void CommandRequestTaskMoveNetworkStateTransition(int PedIndex, const char* szState)
  8150. {
  8151. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  8152. if (pPed && pPed->GetPedIntelligence())
  8153. {
  8154. CTaskMoVEScripted* pTaskMoVE = FindScriptedMoveTask(pPed);
  8155. if (SCRIPT_VERIFY (pTaskMoVE, "REQUEST_TASK_MOVE_NETWORK_STATE_TRANSITION - task is not running!"))
  8156. {
  8157. if( SCRIPT_VERIFY (pTaskMoVE->GetIsNetworkActive(), "REQUEST_TASK_MOVE_NETWORK_STATE_TRANSITION - task not active! Check IS_TASK_MOVE_NETWORK_ACTIVE!" ) )
  8158. {
  8159. if( SCRIPT_VERIFY (pTaskMoVE->GetState() == CTaskMoVEScripted::State_InState, "REQUEST_TASK_MOVE_NETWORK_STATE_TRANSITION - task not ready for a transition! Check IS_TASK_MOVE_NETWORK_READY_FOR_TRANSITION!" ) )
  8160. {
  8161. pTaskMoVE->RequestStateTransition(szState);
  8162. }
  8163. }
  8164. }
  8165. }
  8166. }
  8167.  
  8168. void CommandSetExpectedCloneNextTaskMoveNetworkState(int PedIndex, const char* szState)
  8169. {
  8170. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  8171. if (pPed && pPed->GetPedIntelligence())
  8172. {
  8173. CTaskMoVEScripted* pTaskMoVE = FindScriptedMoveTask(pPed);
  8174. if (SCRIPT_VERIFY (pTaskMoVE, "SET_EXPECTED_CLONE_NEXT_TASK_MOVE_NETWORK_STATE - task is not running!"))
  8175. {
  8176. if( SCRIPT_VERIFY (pTaskMoVE->GetIsNetworkActive(), "SET_EXPECTED_CLONE_NEXT_TASK_MOVE_NETWORK_STATE - task not active! Check IS_TASK_MOVE_NETWORK_ACTIVE!" ) )
  8177. {
  8178. if( SCRIPT_VERIFY (pTaskMoVE->GetState() == CTaskMoVEScripted::State_InState, "SET_EXPECTED_CLONE_NEXT_TASK_MOVE_NETWORK_STATE - task not ready for a transition! Check IS_TASK_MOVE_NETWORK_READY_FOR_TRANSITION!" ) )
  8179. {
  8180. pTaskMoVE->SetExpectedCloneNextStateTransition(szState);
  8181. }
  8182. }
  8183. }
  8184. }
  8185. }
  8186. const char* CommandGetTaskMoveNetworkState(int PedIndex)
  8187. {
  8188. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  8189. if (pPed && pPed->GetPedIntelligence())
  8190. {
  8191. CTaskMoVEScripted* pTaskMoVE = FindScriptedMoveTask(pPed);
  8192. if (SCRIPT_VERIFY (pTaskMoVE, "GET_TASK_MOVE_NETWORK_STATE - task is not running!"))
  8193. {
  8194. if( SCRIPT_VERIFY (pTaskMoVE->GetIsNetworkActive(), "GET_TASK_MOVE_NETWORK_STATE - task not active! Check IS_TASK_MOVE_NETWORK_ACTIVE!" ) )
  8195. {
  8196. return pTaskMoVE->GetScriptStateName();
  8197. }
  8198. }
  8199. }
  8200. return "Unknown";
  8201. }
  8202.  
  8203. void CommandSetTaskMoveNetworkSignalFloat(int PedIndex, const char* szSignal, float fSignal)
  8204. {
  8205. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  8206. if (pPed && pPed->GetPedIntelligence())
  8207. {
  8208. CTaskMoVEScripted* pTaskMoVE = FindScriptedMoveTask(pPed);
  8209. if (SCRIPT_VERIFY (pTaskMoVE, "SET_TASK_MOVE_NETWORK_SIGNAL_FLOAT - task is not running!"))
  8210. {
  8211. if( SCRIPT_VERIFY (pTaskMoVE->GetIsNetworkActive(), "SET_TASK_MOVE_NETWORK_SIGNAL_FLOAT - task not active! Check IS_TASK_MOVE_NETWORK_ACTIVE!" ) )
  8212. {
  8213. if( SCRIPT_VERIFY ((!pPed->IsNetworkClone() || pTaskMoVE->GetAllowOverrideCloneUpdate()),
  8214. "SET_TASK_MOVE_NETWORK_SIGNAL_FLOAT - Can't set float on cloned ped if its task is not being overridden!" ) )
  8215. {
  8216. pTaskMoVE->SetSignalFloat(szSignal, fSignal);
  8217. }
  8218. }
  8219. }
  8220. }
  8221. }
  8222.  
  8223. void CommandSetTaskMoveNetworkSignalFloatLerpRate(int PedIndex, const char* szSignal, float fLerpRate)
  8224. {
  8225. scriptAssertf(fLerpRate!=0.0f, "CommandSetTaskMoveNetworkSignalFloatLerpRate don't expect fLerpRate to be 0.0f");
  8226.  
  8227. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  8228. if (pPed && pPed->GetPedIntelligence())
  8229. {
  8230. CTaskMoVEScripted* pTaskMoVE = FindScriptedMoveTask(pPed);
  8231. if (SCRIPT_VERIFY (pTaskMoVE, "SET_TASK_MOVE_NETWORK_SIGNAL_FLOAT_LERP_RATE - task is not running!"))
  8232. {
  8233. if( SCRIPT_VERIFY (pTaskMoVE->GetIsNetworkActive(), "SET_TASK_MOVE_NETWORK_SIGNAL_FLOAT_LERP_RATE - task not active! Check IS_TASK_MOVE_NETWORK_ACTIVE!" ) )
  8234. {
  8235. return pTaskMoVE->SetSignalFloatLerpRate(szSignal, fLerpRate);
  8236. }
  8237. }
  8238. }
  8239. }
  8240.  
  8241. float CommandGetTaskMoveNetworkSignalFloat(int PedIndex, const char* szSignal)
  8242. {
  8243. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  8244. if (pPed && pPed->GetPedIntelligence())
  8245. {
  8246. CTaskMoVEScripted* pTaskMoVE = FindScriptedMoveTask(pPed);
  8247. if (SCRIPT_VERIFY (pTaskMoVE, "GET_TASK_MOVE_NETWORK_SIGNAL_FLOAT - task is not running!"))
  8248. {
  8249. if( SCRIPT_VERIFY (pTaskMoVE->GetIsNetworkActive(), "GET_TASK_MOVE_NETWORK_SIGNAL_FLOAT - task not active! Check IS_TASK_MOVE_NETWORK_ACTIVE!" ) )
  8250. {
  8251. return pTaskMoVE->GetSignalFloat(szSignal);
  8252. }
  8253. }
  8254. }
  8255. return 0.0f;
  8256. }
  8257.  
  8258. void CommandSetTaskMoveNetworkSignalBool(int PedIndex, const char* szSignal, bool bSignal)
  8259. {
  8260. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  8261. if (pPed && pPed->GetPedIntelligence())
  8262. {
  8263. CTaskMoVEScripted* pTaskMoVE = FindScriptedMoveTask(pPed);
  8264. if (SCRIPT_VERIFY (pTaskMoVE, "SET_TASK_MOVE_NETWORK_SIGNAL_BOOL - task is not running!"))
  8265. {
  8266. if( SCRIPT_VERIFY (pTaskMoVE->GetIsNetworkActive(), "SET_TASK_MOVE_NETWORK_SIGNAL_BOOL - task not active! Check IS_TASK_MOVE_NETWORK_ACTIVE!" ) )
  8267. {
  8268. if( SCRIPT_VERIFY ((!pPed->IsNetworkClone() || pTaskMoVE->GetAllowOverrideCloneUpdate()),
  8269. "SET_TASK_MOVE_NETWORK_SIGNAL_BOOL - Can't set bool on cloned ped if its task is not being overridden!" ) )
  8270. {
  8271. pTaskMoVE->SetSignalBool(szSignal, bSignal);
  8272. }
  8273. }
  8274. }
  8275. }
  8276. }
  8277.  
  8278. void CommandSetTaskMoveNetworkSignalLocalBool(int PedIndex, const char* szSignal, bool bSignal)
  8279. {
  8280. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  8281. if (pPed && pPed->GetPedIntelligence())
  8282. {
  8283. CTaskMoVEScripted* pTaskMoVE = FindScriptedMoveTask(pPed);
  8284. if (SCRIPT_VERIFY (pTaskMoVE, "SET_TASK_MOVE_NETWORK_SIGNAL_LOCAL_BOOL - task is not running!"))
  8285. {
  8286. if( SCRIPT_VERIFY (pTaskMoVE->GetIsNetworkActive(), "SET_TASK_MOVE_NETWORK_SIGNAL_LOCAL_BOOL - task not active! Check IS_TASK_MOVE_NETWORK_ACTIVE!" ) )
  8287. {
  8288. pTaskMoVE->SetSignalBool(szSignal, bSignal, false);
  8289. }
  8290. }
  8291. }
  8292. }
  8293.  
  8294. void CommandSetTaskMoveNetworkSignalLocalFloat(int PedIndex, const char* szSignal, float signal)
  8295. {
  8296. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  8297. if (pPed && pPed->GetPedIntelligence())
  8298. {
  8299. CTaskMoVEScripted* pTaskMoVE = FindScriptedMoveTask(pPed);
  8300. if (SCRIPT_VERIFY (pTaskMoVE, "SET_TASK_MOVE_NETWORK_SIGNAL_LOCAL_FLOAT - task is not running!"))
  8301. {
  8302. if( SCRIPT_VERIFY (pTaskMoVE->GetIsNetworkActive(), "SET_TASK_MOVE_NETWORK_SIGNAL_LOCAL_FLOAT - task not active! Check IS_TASK_MOVE_NETWORK_ACTIVE!" ) )
  8303. {
  8304. pTaskMoVE->SetSignalFloat(szSignal, signal, false);
  8305. }
  8306. }
  8307. }
  8308. }
  8309.  
  8310.  
  8311. bool CommandGetTaskMoveNetworkSignalBool(int PedIndex, const char* szSignal)
  8312. {
  8313. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  8314. if (pPed && pPed->GetPedIntelligence())
  8315. {
  8316. CTaskMoVEScripted* pTaskMoVE = FindScriptedMoveTask(pPed);
  8317. if (SCRIPT_VERIFY (pTaskMoVE, "GET_TASK_MOVE_NETWORK_SIGNAL_BOOL - task is not running!"))
  8318. {
  8319. if( SCRIPT_VERIFY (pTaskMoVE->GetIsNetworkActive(), "GET_TASK_MOVE_NETWORK_SIGNAL_BOOL - task not active! Check IS_TASK_MOVE_NETWORK_ACTIVE!" ) )
  8320. {
  8321. return pTaskMoVE->GetSignalBool(szSignal);
  8322. }
  8323. }
  8324. }
  8325. return false;
  8326. }
  8327.  
  8328.  
  8329. bool CommandGetTaskMoveNetworkEvent(int PedIndex, const char * eventName)
  8330. {
  8331. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  8332. if (pPed && pPed->GetPedIntelligence())
  8333. {
  8334. CTaskMoVEScripted* pTaskMoVE = FindScriptedMoveTask(pPed);
  8335. if (SCRIPT_VERIFY (pTaskMoVE, "GET_TASK_MOVE_NETWORK_EVENT - task is not running!"))
  8336. {
  8337. if( SCRIPT_VERIFY (pTaskMoVE && pTaskMoVE->GetIsNetworkActive(), "GET_TASK_MOVE_NETWORK_EVENT - task not active! Check IS_TASK_MOVE_NETWORK_ACTIVE!" ) )
  8338. {
  8339. return pTaskMoVE->GetMoveEvent(eventName);
  8340. }
  8341. }
  8342. }
  8343. return false;
  8344. }
  8345.  
  8346. void CommandSetTaskMoveNetworkEnableCollisionOnNetworkCloneWhenFixed(int PedIndex, bool bEnableCollisionOnNetworkCloneWhenFixed)
  8347. {
  8348. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  8349. if (pPed && pPed->GetPedIntelligence())
  8350. {
  8351. CTaskMoVEScripted* pTaskMoVE = FindScriptedMoveTask(pPed);
  8352. if (SCRIPT_VERIFY(pTaskMoVE, "SET_TASK_MOVE_NETWORK_ENABLE_COLLISION_ON_NETWORK_CLONE_WHEN_FIXED - task is not running!"))
  8353. {
  8354. if (SCRIPT_VERIFY(pTaskMoVE && pTaskMoVE->GetIsNetworkActive(), "SET_TASK_MOVE_NETWORK_ENABLE_COLLISION_ON_NETWORK_CLONE_WHEN_FIXED - task not active! Check IS_TASK_MOVE_NETWORK_ACTIVE!"))
  8355. {
  8356. return pTaskMoVE->SetEnableCollisionOnNetworkCloneWhenFixed(bEnableCollisionOnNetworkCloneWhenFixed);
  8357. }
  8358. }
  8359. }
  8360. }
  8361.  
  8362. void PlayVehicleAnimScriptCommand(int VehicleIndex, const char *pAnimName, const char *pAnimDictNameStr)
  8363. {
  8364. const strStreamingObjectName pAnimDictName( pAnimDictNameStr );
  8365.  
  8366. if(!SCRIPT_VERIFY(pAnimName, "VEHICLE_TASK_PLAY_ANIM - Animation name is null"))
  8367. {
  8368. return;
  8369. }
  8370.  
  8371. if(!SCRIPT_VERIFY(pAnimDictName.IsNotNull(), "VEHICLE_TASK_PLAY_ANIM - Animation dictionary name is null"))
  8372. {
  8373. return;
  8374. }
  8375.  
  8376. CVehicle *pVehicle = NULL;
  8377. if(NULL_IN_SCRIPTING_LANGUAGE!=VehicleIndex)
  8378. {
  8379. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(VehicleIndex);
  8380. if(!pVehicle)
  8381. {
  8382. return;
  8383. }
  8384. }
  8385.  
  8386. //scriptAssertf(strlen(pAnimName)<ANIM_NAMELEN, "%s:TASK_PLAY_ANIM - Animation name is null : %s", CTheScripts::GetCurrentScriptNameAndProgramCounter(), pAnimName);
  8387.  
  8388.  
  8389. aiTask* pTask = rage_new CTaskVehicleAnimation(pAnimDictName, pAnimName);
  8390.  
  8391. if(pVehicle)
  8392. {
  8393. pVehicle->GetIntelligence()->AddTask(VEHICLE_TASK_TREE_SECONDARY, pTask, VEHICLE_TASK_SECONDARY_ANIM);
  8394. }
  8395. }
  8396.  
  8397. void CommandVehicleTaskPlayAnim(int VehicleIndex, const char *pAnimDictName, const char *pAnimName)
  8398. {
  8399. PlayVehicleAnimScriptCommand(VehicleIndex, pAnimName, pAnimDictName);
  8400. }
  8401.  
  8402. bool CommandIsMoveBlendRatioStill(float fMoveBlendRatio)
  8403. {
  8404. return CPedMotionData::GetIsStill(fMoveBlendRatio);
  8405. }
  8406.  
  8407. bool CommandIsMoveBlendRatioWalking(float fMoveBlendRatio)
  8408. {
  8409. return CPedMotionData::GetIsWalking(fMoveBlendRatio);
  8410. }
  8411.  
  8412. bool CommandIsMoveBlendRatioRunning(float fMoveBlendRatio)
  8413. {
  8414. return CPedMotionData::GetIsRunning(fMoveBlendRatio);
  8415. }
  8416.  
  8417. bool CommandIsMoveBlendRatioSprinting(float fMoveBlendRatio)
  8418. {
  8419. return CPedMotionData::GetIsSprinting(fMoveBlendRatio);
  8420. }
  8421.  
  8422. bool CommandIsPedStill(int PedIndex)
  8423. {
  8424. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  8425. if (pPed)
  8426. {
  8427. return pPed->GetMotionData()->GetIsStill();
  8428. }
  8429. return false;
  8430. }
  8431.  
  8432. bool CommandIsPedWalking(int PedIndex)
  8433. {
  8434. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  8435. if (pPed)
  8436. {
  8437. return pPed->GetMotionData()->GetIsWalking();
  8438. }
  8439. return false;
  8440. }
  8441.  
  8442. bool CommandPedIsRunning(int PedIndex)
  8443. {
  8444. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  8445. if (pPed)
  8446. {
  8447. return pPed->GetMotionData()->GetIsRunning();
  8448. }
  8449. return false;
  8450. }
  8451.  
  8452. bool CommandPedIsSprinting(int PedIndex)
  8453. {
  8454. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  8455. if (pPed)
  8456. {
  8457. return pPed->GetMotionData()->GetIsSprinting();
  8458. }
  8459. return false;
  8460. }
  8461.  
  8462. bool CommandPedIsStrafing(int PedIndex)
  8463. {
  8464. const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  8465. if (pPed)
  8466. {
  8467. return pPed->GetMotionData()->GetIsStrafing();
  8468. }
  8469. return false;
  8470. }
  8471.  
  8472. /////////////////////////////////////////////////
  8473. // Start the sweep task and point at an entity
  8474. /////////////////////////////////////////////////
  8475. void CommandTaskSweepAimEntity(int PedIndex, const char* pAnimDictName, const char* pLowAnimName, const char* pMedAnimName, const char* pHiAnimName, int runTime, int TargetEntityIndex, float turnRate, float fBlendInDuration)
  8476. {
  8477. const CEntity *pEntity = CTheScripts::GetEntityToQueryFromGUID<CEntity>(TargetEntityIndex);
  8478. if( pEntity )
  8479. {
  8480. int clipDictId = fwAnimManager::FindSlot(strStreamingObjectName(pAnimDictName)).Get();
  8481. fwMvClipId lowClipId(pLowAnimName);
  8482. fwMvClipId medClipId(pMedAnimName);
  8483. fwMvClipId highClipId(pHiAnimName);
  8484.  
  8485. aiTask *pTask = rage_new CTaskGeneralSweep(clipDictId, lowClipId, medClipId, highClipId, runTime, pEntity, turnRate, fBlendInDuration);
  8486. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_GENERAL_SWEEP, "TASK_GENERAL_SWEEP");
  8487. }
  8488. }
  8489.  
  8490. // Update the sweep task and point at an entity
  8491. void CommandUpdateTaskSweepAimEntity(int PedIndex, int TargetEntityIndex)
  8492. {
  8493. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  8494. if(pPed)
  8495. {
  8496. // Check if the task is running
  8497. CTask* pTask = pPed->GetPedIntelligence()->FindTaskActiveByType( CTaskTypes::TASK_GENERAL_SWEEP );
  8498. if( Verifyf( pTask, "TaskGeneralSweep Isn't running, so cannot be updated!" ) )
  8499. {
  8500. const CEntity *pEntity = CTheScripts::GetEntityToQueryFromGUID<CEntity>(TargetEntityIndex);
  8501.  
  8502. if( Verifyf( pEntity, "Tracking Entity doesn't exist!" ) )
  8503. {
  8504. static_cast<CTaskGeneralSweep*>(pTask)->SetTrackEntity(pEntity);
  8505. }
  8506. }
  8507. }
  8508. }
  8509.  
  8510. // Start the sweep task and point at a position
  8511. void CommandTaskSweepAimPosition(int PedIndex, const char* pAnimDictName, const char* pLowAnimName, const char* pMedAnimName, const char* pHiAnimName, int runTime, const scrVector & scrVecCoors, float turnRate, float fBlendInDuration)
  8512. {
  8513. int clipDictId = fwAnimManager::FindSlot(strStreamingObjectName(pAnimDictName)).Get();
  8514. fwMvClipId lowClipId(pLowAnimName);
  8515. fwMvClipId medClipId(pMedAnimName);
  8516. fwMvClipId highClipId(pHiAnimName);
  8517. const Vector3 AimCoords = Vector3(scrVecCoors);
  8518.  
  8519. aiTask *pTask = rage_new CTaskGeneralSweep(clipDictId, lowClipId, medClipId, highClipId, runTime, &AimCoords, turnRate, fBlendInDuration);
  8520. CScriptPeds::GivePedScriptedTask(PedIndex, pTask, SCRIPT_TASK_GENERAL_SWEEP, "TASK_GENERAL_SWEEP");
  8521. }
  8522.  
  8523. // Update the sweep task and point at a position
  8524. void CommandUpdateTaskSweepAimPosition(int PedIndex, const scrVector & scrVecCoors)
  8525. {
  8526. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(PedIndex);
  8527. if(pPed)
  8528. {
  8529. // Check if the task is running
  8530. CTask* pTask = pPed->GetPedIntelligence()->FindTaskActiveByType( CTaskTypes::TASK_GENERAL_SWEEP );
  8531. if( Verifyf( pTask, "TaskGeneralSweep Isn't running, so cannot be updated!" ) )
  8532. {
  8533. const Vector3 AimCoords = Vector3(scrVecCoors);
  8534. static_cast<CTaskGeneralSweep*>(pTask)->SetTrackPosition(&AimCoords);
  8535. }
  8536. }
  8537. }
  8538.  
  8539. void CommandTaskArrestPed(int CopPedIndex, int CrookPedIndex)
  8540. {
  8541. scriptDisplayf("CommandTaskArrestPed\n");
  8542.  
  8543. CPed *pCopPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(CopPedIndex, 0);
  8544. CPed *pCrookPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(CrookPedIndex, CTheScripts::GUID_ASSERT_FLAGS_INCLUDE_CLONES);
  8545. SCRIPT_ASSERT(pCrookPed, "TASK_ARREST_PED - You must specify the crook ped!");
  8546. if(pCrookPed)
  8547. {
  8548. if(!pCopPed || !pCopPed->IsAPlayerPed())
  8549. {
  8550. CTask* pTask = rage_new CTaskArrestPed(pCrookPed);
  8551. CScriptPeds::GivePedScriptedTask(CopPedIndex, pTask, SCRIPT_TASK_ARREST_PED, "TASK_ARREST_PED");
  8552. }
  8553. }
  8554. }
  8555.  
  8556. bool CommandIsPedRunningArrestTask(int PedIndex)
  8557. {
  8558. const CPed *pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(PedIndex);
  8559. SCRIPT_ASSERT(pPed, "IS_PED_RUNNING_ARREST_TASK - You must specify the ped!");
  8560. if(pPed)
  8561. {
  8562. CTaskPlayerOnFoot *pTaskPlayerOnFoot = static_cast< CTaskPlayerOnFoot * >(pPed->GetPedIntelligence()->FindTaskByType(CTaskTypes::TASK_PLAYER_ON_FOOT));
  8563. if(pTaskPlayerOnFoot)
  8564. {
  8565. aiTask *pTask = pTaskPlayerOnFoot->GetScriptedTask();
  8566. if(pTask && pTask->GetTaskType() == CTaskTypes::TASK_ARREST_PED2)
  8567. {
  8568. return true;
  8569. }
  8570. }
  8571.  
  8572. CTaskArrestPed2 *pTaskArrestPed2 = static_cast< CTaskArrestPed2 * >(pPed->GetPedIntelligence()->FindTaskByType(CTaskTypes::TASK_ARREST_PED2));
  8573. if(pTaskArrestPed2)
  8574. {
  8575. return true;
  8576. }
  8577. }
  8578.  
  8579. return false;
  8580. }
  8581.  
  8582. bool CommandIsArrestTypeValid(int CopPedIndex, int CrookPedIndex, int ArrestType)
  8583. {
  8584. const CPed *pCopPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(CopPedIndex);
  8585. SCRIPT_ASSERT(pCopPed, "IS_ARREST_TYPE_VALID - You must specify the cop ped!");
  8586. const CPed *pCrookPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(CrookPedIndex);
  8587. SCRIPT_ASSERT(pCrookPed, "IS_ARREST_TYPE_VALID - You must specify the crook ped!");
  8588. SCRIPT_ASSERT(ArrestType >= 0 && ArrestType < CArrestHelpers::ARREST_COUNT, "IS_ARREST_TYPE_VALID - You must specify a valid ArrestType!");
  8589. if(pCopPed && pCrookPed && ArrestType >= 0 && ArrestType < CArrestHelpers::ARREST_COUNT)
  8590. {
  8591. return CArrestHelpers::IsArrestTypeValid(pCopPed, pCrookPed, ArrestType);
  8592. }
  8593.  
  8594. return false;
  8595. }
  8596.  
  8597. bool CommandIsPedBeingArrested(int ENABLE_TASKS_ARREST_CUFFED_ONLY(iPedIndex))
  8598. {
  8599. #if ENABLE_TASKS_ARREST_CUFFED
  8600. if (const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex))
  8601. {
  8602. CTaskCuffed* pTaskCuffed = static_cast<CTaskCuffed*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_CUFFED));
  8603. return pTaskCuffed && pTaskCuffed->IsBeingCuffed();
  8604. }
  8605. #endif // ENABLE_TASKS_ARREST_CUFFED
  8606. return false;
  8607. }
  8608.  
  8609. int CommandGetPedArrester(int ENABLE_TASKS_ARREST_CUFFED_ONLY(iPedIndex))
  8610. {
  8611. #if ENABLE_TASKS_ARREST_CUFFED
  8612. if (const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex))
  8613. {
  8614. CTaskCuffed* pTaskCuffed = static_cast<CTaskCuffed*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_CUFFED));
  8615. if (pTaskCuffed && pTaskCuffed->IsBeingCuffed())
  8616. {
  8617. if (CPed* pCustodianPed = pTaskCuffed->GetArrestPed())
  8618. {
  8619. return CTheScripts::GetGUIDFromEntity(*pCustodianPed);
  8620. }
  8621. }
  8622. }
  8623. #endif // ENABLE_TASKS_ARREST_CUFFED
  8624. return 0;
  8625. }
  8626.  
  8627. bool CommandIsPedCuffed(int iPedIndex)
  8628. {
  8629. if (const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex))
  8630. {
  8631. // Just check the handcuffed flag rather than checking for the cuffed state,
  8632. // as other higher priority states may have bumped it off temporarily.
  8633. return pPed->GetPedConfigFlag(CPED_CONFIG_FLAG_IsHandCuffed);
  8634. }
  8635.  
  8636. return false;
  8637. }
  8638.  
  8639. int CommandGetPedCustodian(int iPedIndex)
  8640. {
  8641. if (const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex))
  8642. {
  8643. if (CPed* pCustodianPed = pPed->GetCustodian())
  8644. {
  8645. return CTheScripts::GetGUIDFromEntity(*pCustodianPed);
  8646. }
  8647. }
  8648.  
  8649. return 0;
  8650. }
  8651.  
  8652. bool CommandIsPedBeingUncuffed(int ENABLE_TASKS_ARREST_CUFFED_ONLY(iPedIndex))
  8653. {
  8654. #if ENABLE_TASKS_ARREST_CUFFED
  8655. if (const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex))
  8656. {
  8657. CTaskCuffed* pTaskCuffed = static_cast<CTaskCuffed*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_CUFFED));
  8658. return pTaskCuffed && pTaskCuffed->IsBeingUncuffed();
  8659. }
  8660. #endif // ENABLE_TASKS_ARREST_CUFFED
  8661. return false;
  8662. }
  8663.  
  8664. int CommandGetPedUncuffer(int ENABLE_TASKS_ARREST_CUFFED_ONLY(iPedIndex))
  8665. {
  8666. #if ENABLE_TASKS_ARREST_CUFFED
  8667. if (const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex))
  8668. {
  8669. CTaskCuffed* pTaskCuffed = static_cast<CTaskCuffed*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_CUFFED));
  8670. if (pTaskCuffed && pTaskCuffed->IsBeingUncuffed())
  8671. {
  8672. if (CPed* pCustodianPed = pTaskCuffed->GetArrestPed())
  8673. {
  8674. return CTheScripts::GetGUIDFromEntity(*pCustodianPed);
  8675. }
  8676. }
  8677. }
  8678. #endif // ENABLE_TASKS_ARREST_CUFFED
  8679. return 0;
  8680. }
  8681.  
  8682. bool CommandIsPedArresting(int ENABLE_TASKS_ARREST_CUFFED_ONLY(iPedIndex))
  8683. {
  8684. #if ENABLE_TASKS_ARREST_CUFFED
  8685. if (const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex))
  8686. {
  8687. if (CTaskArrest* pTaskArrest = static_cast<CTaskArrest*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_ARREST)))
  8688. {
  8689. return pTaskArrest->IsArresting();
  8690. }
  8691. }
  8692. #endif // ENABLE_TASKS_ARREST_CUFFED
  8693. return false;
  8694. }
  8695.  
  8696. int CommandGetPedArrestingTarget(int ENABLE_TASKS_ARREST_CUFFED_ONLY(iPedIndex))
  8697. {
  8698. #if ENABLE_TASKS_ARREST_CUFFED
  8699. if (const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex))
  8700. {
  8701. if (CTaskArrest* pTaskArrest = static_cast<CTaskArrest*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_ARREST)))
  8702. {
  8703. if (pTaskArrest->IsArresting())
  8704. {
  8705. if (CPed* pTargetPed = pTaskArrest->GetTargetPed())
  8706. {
  8707. return CTheScripts::GetGUIDFromEntity(*pTargetPed);
  8708. }
  8709. }
  8710. }
  8711. }
  8712. #endif // ENABLE_TASKS_ARREST_CUFFED
  8713. return 0;
  8714. }
  8715.  
  8716. bool CommandIsPedTakingCustody(int ENABLE_TASKS_ARREST_CUFFED_ONLY(iPedIndex))
  8717. {
  8718. #if ENABLE_TASKS_ARREST_CUFFED
  8719. if (const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex))
  8720. {
  8721. if (CTaskArrest* pTaskArrest = static_cast<CTaskArrest*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_ARREST)))
  8722. {
  8723. return pTaskArrest->IsTakingCustody();
  8724. }
  8725.  
  8726. }
  8727. #endif // ENABLE_TASKS_ARREST_CUFFED
  8728. return false;
  8729. }
  8730.  
  8731. int CommandGetPedTakingCustodyTarget(int ENABLE_TASKS_ARREST_CUFFED_ONLY(iPedIndex))
  8732. {
  8733. #if ENABLE_TASKS_ARREST_CUFFED
  8734. if (const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex))
  8735. {
  8736. if (CTaskArrest* pTaskArrest = static_cast<CTaskArrest*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_ARREST)))
  8737. {
  8738. if (pTaskArrest->IsTakingCustody())
  8739. {
  8740. if (CPed* pTargetPed = pTaskArrest->GetTargetPed())
  8741. {
  8742. return CTheScripts::GetGUIDFromEntity(*pTargetPed);
  8743. }
  8744. }
  8745. }
  8746. }
  8747. #endif // ENABLE_TASKS_ARREST_CUFFED
  8748. return 0;
  8749. }
  8750.  
  8751. bool CommandIsPedBeingTakenIntoCustody(int ENABLE_TASKS_ARREST_CUFFED_ONLY(iPedIndex))
  8752. {
  8753. #if ENABLE_TASKS_ARREST_CUFFED
  8754. if (const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex))
  8755. {
  8756. if(!pPed->GetPedConfigFlag(CPED_CONFIG_FLAG_IsInCustody))
  8757. {
  8758. CTaskInCustody* pTaskInCustody = static_cast<CTaskInCustody*>(pPed->GetPedIntelligence()->FindTaskByType(CTaskTypes::TASK_IN_CUSTODY));
  8759. if (pTaskInCustody)
  8760. {
  8761. //! Ask in custody task.
  8762. return pTaskInCustody->IsBeingTakenIntoCustody();
  8763. }
  8764. else if(pPed->GetCustodian())
  8765. {
  8766. //! Having a custodian indicates that someone is trying to put you into custody.
  8767. return true;
  8768. }
  8769. }
  8770. }
  8771. #endif // ENABLE_TASKS_ARREST_CUFFED
  8772. return false;
  8773. }
  8774.  
  8775. bool CommandIsPedUncuffing(int ENABLE_TASKS_ARREST_CUFFED_ONLY(iPedIndex))
  8776. {
  8777. #if ENABLE_TASKS_ARREST_CUFFED
  8778. if (const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex))
  8779. {
  8780. if (CTaskArrest* pTaskArrest = static_cast<CTaskArrest*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_ARREST)))
  8781. {
  8782. return pTaskArrest->IsUnCuffing();
  8783. }
  8784. }
  8785. #endif // ENABLE_TASKS_ARREST_CUFFED
  8786. return false;
  8787. }
  8788.  
  8789. int CommandGetPedUncuffingTarget(int ENABLE_TASKS_ARREST_CUFFED_ONLY(iPedIndex))
  8790. {
  8791. #if ENABLE_TASKS_ARREST_CUFFED
  8792. if (const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex))
  8793. {
  8794. if (CTaskArrest* pTaskArrest = static_cast<CTaskArrest*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_ARREST)))
  8795. {
  8796. if(pTaskArrest->IsUnCuffing())
  8797. {
  8798. if (CPed* pTargetPed = pTaskArrest->GetTargetPed())
  8799. {
  8800. return CTheScripts::GetGUIDFromEntity(*pTargetPed);
  8801. }
  8802. }
  8803. }
  8804. }
  8805. #endif // ENABLE_TASKS_ARREST_CUFFED
  8806. return 0;
  8807. }
  8808.  
  8809. void CommandCuffPed(int iPedIndex)
  8810. {
  8811. if (CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex))
  8812. {
  8813. if(SCRIPT_VERIFY(!pPed->IsNetworkClone(), "CUFF_PED - Can't cuff cloned ped!"))
  8814. {
  8815. // Force the ped to be handcuffed immediately
  8816. pPed->SetPedConfigFlag(CPED_CONFIG_FLAG_IsHandCuffed, true);
  8817. }
  8818. }
  8819. }
  8820.  
  8821. void CommandUncuffPed(int iPedIndex)
  8822. {
  8823. if (CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex))
  8824. {
  8825. if(SCRIPT_VERIFY(!pPed->IsNetworkClone(), "UNCUFF_PED - Can't remove clone ped from cuffs!"))
  8826. {
  8827. // Just unset the handcuffed flag, this will kick the ped out of the cuffed task
  8828. pPed->SetPedConfigFlag(CPED_CONFIG_FLAG_IsHandCuffed, false);
  8829. }
  8830. }
  8831. }
  8832.  
  8833. void CommandTaskTakeCustody(int ENABLE_TASKS_ARREST_CUFFED_ONLY(iCustodianIndex), int ENABLE_TASKS_ARREST_CUFFED_ONLY(iPedIndex))
  8834. {
  8835. #if ENABLE_TASKS_ARREST_CUFFED
  8836. if (CPed* pCustodianPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iCustodianIndex))
  8837. {
  8838. CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex, 0);
  8839. if(pPed)
  8840. {
  8841. if(SCRIPT_VERIFY(!pPed->IsNetworkClone(), "TASK_TAKE_CUSTODY - Must set on ped owner's, not clone!"))
  8842. {
  8843. pPed->SetInCustody(true, pCustodianPed);
  8844. CTaskInCustody* pTaskInCustody = rage_new CTaskInCustody(pCustodianPed, true);
  8845. CScriptPeds::GivePedScriptedTask(iPedIndex, pTaskInCustody, SCRIPT_TASK_IN_CUSTODY, "TASK_IN_CUSTODY");
  8846. }
  8847. }
  8848. }
  8849. #endif //ENABLE_TASKS_ARREST_CUFFED
  8850. }
  8851.  
  8852. void CommandRemovePedFromCustody(int iPedIndex)
  8853. {
  8854. if (CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex))
  8855. {
  8856. if(SCRIPT_VERIFY(!pPed->IsNetworkClone(), "REMOVE_PED_FROM_CUSTODY - Can't remove clone ped from custody!"))
  8857. {
  8858. pPed->SetInCustody(false, NULL);
  8859. }
  8860. }
  8861. }
  8862.  
  8863. float CommandGetPedArrestPhase(int ENABLE_TASKS_ARREST_CUFFED_ONLY(iPedIndex))
  8864. {
  8865. #if ENABLE_TASKS_ARREST_CUFFED
  8866. if (const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex))
  8867. {
  8868. //! Arrest Task.
  8869. CTaskArrest* pTaskArrest = static_cast<CTaskArrest*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_ARREST));
  8870. if (pTaskArrest)
  8871. {
  8872. return pTaskArrest->GetPhase();
  8873. }
  8874. //! Cuffed Task
  8875. CTaskCuffed* pTaskCuffed = static_cast<CTaskCuffed*>(pPed->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_CUFFED));
  8876. if (pTaskCuffed)
  8877. {
  8878. return pTaskCuffed->GetPhase();
  8879. }
  8880. //! In Custody Task.
  8881. if(pPed->GetCustodian())
  8882. {
  8883. CTaskArrest* pTaskArrest = static_cast<CTaskArrest*>(pPed->GetCustodian()->GetPedIntelligence()->FindTaskActiveByType(CTaskTypes::TASK_ARREST));
  8884. if(pTaskArrest && pTaskArrest->IsTakingCustody())
  8885. {
  8886. return pTaskArrest->GetPhase();
  8887. }
  8888. }
  8889. }
  8890. #endif // ENABLE_TASKS_ARREST_CUFFED
  8891. return 0.0f;
  8892. }
  8893.  
  8894. int CommandGetPedPotentialArrestTarget(int iPedIndex)
  8895. {
  8896. if (const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex))
  8897. {
  8898. if (CPed* pTargetPed = pPed->GetArrestTarget())
  8899. {
  8900. return CTheScripts::GetGUIDFromEntity(*pTargetPed);
  8901. }
  8902. }
  8903.  
  8904. return 0;
  8905. }
  8906.  
  8907. int CommandGetPedPotentialUncuffTarget(int iPedIndex)
  8908. {
  8909. if (const CPed* pPed = CTheScripts::GetEntityToQueryFromGUID<CPed>(iPedIndex))
  8910. {
  8911. if (CPed* pTargetPed = pPed->GetUncuffTarget())
  8912. {
  8913. return CTheScripts::GetGUIDFromEntity(*pTargetPed);
  8914. }
  8915. }
  8916.  
  8917. return 0;
  8918. }
  8919.  
  8920. void CommandSetPedCustodyOverrideFollowDistance(int iPedIndex, float fFollowDistance)
  8921. {
  8922. if (CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex))
  8923. {
  8924. pPed->SetCustodyFollowDistanceOverride(fFollowDistance);
  8925. }
  8926. }
  8927.  
  8928. void CommandWarpIntoLeadersVehicle(int iPedIndex)
  8929. {
  8930. if (CPed* pPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedIndex))
  8931. {
  8932. pPed->SetPedConfigFlag(CPED_CONFIG_FLAG_WarpIntoLeadersVehicle, true);
  8933. }
  8934. }
  8935.  
  8936. void CommandTaskVehicleGotoNavmesh(int iPedID, int iVehicleID, const scrVector & scrVecCoors,
  8937. float fCruiseSpeed, int iDrivingFlags, float fTargetReached)
  8938. {
  8939. CVehicle* pVehicle = NULL;
  8940.  
  8941. if(SCRIPT_VERIFY(NULL_IN_SCRIPTING_LANGUAGE != iVehicleID, "TASK_VEHICLE_GOTO_NAVMESH - You must specify a vehicle!"))
  8942. {
  8943. pVehicle = CTheScripts::GetEntityToModifyFromGUID<CVehicle>(iVehicleID);
  8944. }
  8945.  
  8946. if(!pVehicle)
  8947. {
  8948. return;
  8949. }
  8950.  
  8951. sVehicleMissionParams params;
  8952. params.m_iDrivingFlags = iDrivingFlags;
  8953. if (fCruiseSpeed > 0.0f)
  8954. {
  8955. params.m_fCruiseSpeed = fCruiseSpeed;
  8956. }
  8957. else
  8958. {
  8959. params.m_fCruiseSpeed = 64.0f;
  8960. }
  8961. Vector3 vTargetPos(scrVecCoors);
  8962. params.SetTargetPosition(vTargetPos);
  8963. params.m_fTargetArriveDist = fTargetReached;
  8964.  
  8965. ASSERT_ONLY(params.IsTargetValid());
  8966.  
  8967. CTaskVehicleGoToNavmesh* pNavmeshTask = rage_new CTaskVehicleGoToNavmesh(params);
  8968.  
  8969. CTask* pTask = rage_new CTaskControlVehicle(pVehicle, pNavmeshTask);
  8970. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_VEHICLE_GOTO_NAVMESH, "TASK_VEHICLE_GOTO_NAVMESH");
  8971. }
  8972.  
  8973. void CommandGivePedAgitatedTaskConfront(int iPedID, int iAgitatorPedID)
  8974. {
  8975. if( SCRIPT_VERIFYF((iPedID != NULL_IN_SCRIPTING_LANGUAGE && iAgitatorPedID != NULL_IN_SCRIPTING_LANGUAGE), "TASK_AGITATED_ACTION_CONFRONT_RESPONSE - iPedID (%i) or iAgitatorPedID(%i) is NULL",iPedID,iAgitatorPedID) )
  8976. {
  8977. CPed* pTargetPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iPedID);
  8978. if (SCRIPT_VERIFYF((pTargetPed && !pTargetPed->IsAPlayerPed()),"TASK_AGITATED_ACTION_CONFRONT_RESPONSE is trying to give agitated task to a player ped or could not find ped with this ID - %i!", iPedID))
  8979. {
  8980. CPed* pAgitatorPed = CTheScripts::GetEntityToModifyFromGUID<CPed>(iAgitatorPedID);
  8981. if (SCRIPT_VERIFYF(pAgitatorPed,"TASK_AGITATED_ACTION_CONFRONT_RESPONSE could not find agitator ped with this ID - %i", iAgitatorPedID))
  8982. {
  8983. CTaskConfront* pConfrontTask = rage_new CTaskConfront(pAgitatorPed);
  8984. CTask* pTask = rage_new CTaskAgitatedAction(pConfrontTask);
  8985.  
  8986. pTargetPed->SetPedConfigFlag(CPED_CONFIG_FLAG_CanBeAgitated, true);
  8987. pTargetPed->SetPedConfigFlag(CPED_CONFIG_FLAG_IsAgitated, true);
  8988.  
  8989. CTaskAgitated* pAgitatedTask = rage_new CTaskAgitated(pAgitatorPed);
  8990. pAgitatedTask->SetStartedFromScript(true);
  8991.  
  8992. pTargetPed->GetPedIntelligence()->AddTaskSecondary( pAgitatedTask, PED_TASK_SECONDARY_PARTIAL_ANIM );
  8993.  
  8994. CScriptPeds::GivePedScriptedTask( iPedID, pTask, SCRIPT_TASK_AGITATED_ACTION, "TASK_AGITATED_ACTION");
  8995. }
  8996. }
  8997. }
  8998. }
  8999.  
  9000. /////////////////////////////////////////////////
  9001.  
  9002.  
  9003. void SetupScriptCommands()
  9004. {
  9005. SCR_REGISTER_SECURE(TASK_PAUSE,0x19c58ba8a663b64b, CommandTaskPause );
  9006. SCR_REGISTER_SECURE(TASK_STAND_STILL,0x83f5bcfffba26699, CommandTaskStandStill );
  9007. SCR_REGISTER_SECURE(TASK_JUMP,0x012983f49702416c, CommandTaskJump );
  9008. SCR_REGISTER_SECURE(TASK_COWER,0x402a537158a551bd, CommandTaskCower );
  9009. SCR_REGISTER_SECURE(TASK_HANDS_UP,0x3598f95a00026dd8, CommandTaskHandsUp );
  9010. SCR_REGISTER_SECURE(UPDATE_TASK_HANDS_UP_DURATION,0x46a203feec0ecef4, CommandUpdateTaskHandsUpDuration );
  9011. SCR_REGISTER_UNUSED(TASK_DUCK,0x54b5addaf8a132f7, CommandTaskDuck );
  9012. SCR_REGISTER_SECURE(TASK_OPEN_VEHICLE_DOOR,0xf9d446af83e7a624, CommandTaskOpenVehicleDoor );
  9013. SCR_REGISTER_SECURE(TASK_ENTER_VEHICLE,0xb486640392ec50bb, CommandTaskEnterVehicle );
  9014. SCR_REGISTER_SECURE(TASK_LEAVE_VEHICLE,0x02f1caac7cb77e47, CommandTaskLeaveVehicle );
  9015. SCR_REGISTER_UNUSED(TASK_MOUNT_ANIMAL,0x3f0ad0f6b2f34df6, CommandTaskMountAnimal );
  9016. SCR_REGISTER_UNUSED(TASK_DISMOUNT_ANIMAL,0xfe2e56c600a68fce, CommandTaskDismountAnimal );
  9017. SCR_REGISTER_SECURE(TASK_GET_OFF_BOAT,0x9aef335a2f73e00a, CommandTaskGetOffBoat );
  9018. SCR_REGISTER_SECURE(TASK_SKY_DIVE,0x622c61505349f582, CommandTaskSkyDive );
  9019. SCR_REGISTER_SECURE(TASK_PARACHUTE,0xb7121915a3797c65, CommandTaskParachute );
  9020. SCR_REGISTER_SECURE(TASK_PARACHUTE_TO_TARGET,0xf323d744a727a4a2, CommandTaskParachuteToTarget );
  9021. SCR_REGISTER_SECURE(SET_PARACHUTE_TASK_TARGET,0x878fd7e3c8110527, CommandSetParachuteTaskTarget );
  9022. SCR_REGISTER_SECURE(SET_PARACHUTE_TASK_THRUST,0x3ca038370f6e3223, CommandSetParachuteTaskThrust );
  9023. SCR_REGISTER_UNUSED(SET_PARACHUTE_TASK_TARGET_ENTITY,0x63b1ba4dbcd822ac, CommandSetParachuteTaskTargetEntity );
  9024. SCR_REGISTER_UNUSED(TASK_JETPACK,0x23c36cbde291e36c, CommandTaskJetpack );
  9025. SCR_REGISTER_UNUSED(TASK_JETPACK_GO_TO_COORD,0x586dae563b9e50c6, CommandTaskJetpackGoToCoord );
  9026. SCR_REGISTER_UNUSED(TASK_JETPACK_GO_TO_ENTITY,0x67794f749799bd7d, CommandTaskJetpackGoToEntity );
  9027. SCR_REGISTER_UNUSED(TASK_JETPACK_SHOOT_AT_COORD,0x6ebd50cacaab197e, CommandTaskJetpackShootAtCoord );
  9028. SCR_REGISTER_UNUSED(TASK_JETPACK_SHOOT_AT_ENTITY,0xa767f2d717d074f9, CommandTaskJetpackShootAtEntity );
  9029. SCR_REGISTER_UNUSED(TASK_JETPACK_STOP_SHOOTING,0xafd3096512ccc6cd, CommandTaskJetpackStopShooting );
  9030. SCR_REGISTER_SECURE(TASK_RAPPEL_FROM_HELI,0x01ddcf3e0afad31b, CommandTaskRappelFromHeli );
  9031. SCR_REGISTER_UNUSED(TASK_DRAG_PED_TO_COORD,0xb269aa2c4e7f407c, CommandTaskDragPedToCoord );
  9032.  
  9033. SCR_REGISTER_SECURE(TASK_VEHICLE_DRIVE_TO_COORD,0x3b8f94419979a0b1, CommandTaskVehicleDriveToCoord );
  9034. SCR_REGISTER_SECURE(TASK_VEHICLE_DRIVE_TO_COORD_LONGRANGE,0x70d024128ce0c114, CommandTaskVehicleDriveToCoordLongRange);
  9035. SCR_REGISTER_SECURE(TASK_VEHICLE_DRIVE_WANDER,0xad6cdbcda713560a, CommandTaskVehicleDriveWander );
  9036. SCR_REGISTER_SECURE(TASK_FOLLOW_TO_OFFSET_OF_ENTITY,0x6fce069e4940878c, CommandTaskFollowToOffsetOfEntity );
  9037. SCR_REGISTER_UNUSED(TASK_FOLLOW_TO_OFFSET_OF_PICKUP,0x6f91735acae34873, CommandTaskFollowToOffsetOfPickup);
  9038. SCR_REGISTER_SECURE(TASK_GO_STRAIGHT_TO_COORD,0x13c3030981ea7c3b, CommandTaskGoStraightToCoord );
  9039. SCR_REGISTER_SECURE(TASK_GO_STRAIGHT_TO_COORD_RELATIVE_TO_ENTITY,0xc98e8d7f0d9d4795, CommandTaskGoStraightToCoordRelativeToEntity );
  9040. SCR_REGISTER_SECURE(TASK_ACHIEVE_HEADING,0x30e00b59448ab97e, CommandTaskAchieveHeading );
  9041. SCR_REGISTER_SECURE(TASK_FLUSH_ROUTE,0x83a64e1fe4669225, CommandFlushRoute );
  9042. SCR_REGISTER_SECURE(TASK_EXTEND_ROUTE,0x9d38259cb54342be, CommandExtendRoute );
  9043. SCR_REGISTER_SECURE(TASK_FOLLOW_POINT_ROUTE,0x790dea4e63d61baa, CommandTaskFollowPointRoute );
  9044. SCR_REGISTER_SECURE(TASK_GO_TO_ENTITY,0xc149e50fbb27dd70, CommandTaskGoToEntity );
  9045. SCR_REGISTER_SECURE(TASK_SMART_FLEE_COORD,0x84918839a90c954c, CommandTaskSmartFleeCoord );
  9046. SCR_REGISTER_SECURE(TASK_SMART_FLEE_PED,0x7734082b0edb0be0, CommandTaskSmartFleePed );
  9047. SCR_REGISTER_UNUSED(TASK_REACT_AND_FLEE_COORD,0x596713d55325f5c9, CommandTaskReactAndFleeCoord );
  9048. SCR_REGISTER_SECURE(TASK_REACT_AND_FLEE_PED,0x7a9da0518e81ec15, CommandTaskReactAndFleePed );
  9049. SCR_REGISTER_UNUSED(TASK_SHOCKING_EVENT_BACK_AWAY,0xa19ac1e1c0d01b42, CommandTaskShockingEventBackAway );
  9050. SCR_REGISTER_UNUSED(TASK_SHOCKING_EVENT_HURRY_AWAY,0x4e742aa861140b96, CommandTaskShockingEventHurryAway );
  9051. SCR_REGISTER_SECURE(TASK_SHOCKING_EVENT_REACT,0xb5bc9e2b43334cef, CommandTaskShockingEventReact );
  9052. SCR_REGISTER_SECURE(TASK_WANDER_IN_AREA,0x5315f7ac22dc95f1, CommandTaskWanderInArea );
  9053. SCR_REGISTER_SECURE(TASK_WANDER_STANDARD,0xd86a0bc9cc0a625a, CommandTaskWanderStandard );
  9054. SCR_REGISTER_SECURE(TASK_WANDER_SPECIFIC,0x26f1da9738c260f2, CommandTaskWanderSpecific);
  9055. SCR_REGISTER_SECURE(TASK_VEHICLE_PARK,0x5b7af57d366861f2, CommandTaskVehiclePark );
  9056.  
  9057. SCR_REGISTER_SECURE(TASK_STEALTH_KILL,0xe2c1d6fa4e5ea991, CommandTaskStealthKill );
  9058. SCR_REGISTER_SECURE(TASK_PLANT_BOMB,0xd9ab2b08ce49a043, CommandTaskPlantBomb );
  9059.  
  9060. SCR_REGISTER_UNUSED(TASK_SHARK_CIRCLE_COORD,0xfff1232e7a485388, CommandTaskSharkCircleCoord );
  9061. SCR_REGISTER_UNUSED(TASK_SHARK_CIRCLE_PED,0xfd4e7488138e4f25, CommandTaskSharkCirclePed );
  9062.  
  9063. SCR_REGISTER_SECURE(TASK_FOLLOW_NAV_MESH_TO_COORD,0x7d1424753688ee7a, CommandTaskFollowNavMeshToCoord );
  9064. scrThread::RegisterCommand(SCRHASH("TASK_FOLLOW_NAV_MESH_TO_COORD_ADVANCED",0x72f317bc03266125), CommandTaskFollowNavMeshToCoordAdvanced_ScrStruct SCRIPT_DEBUGGING_ONLY(, "TASK_FOLLOW_NAV_MESH_TO_COORD_ADVANCED", __FILE__, scrSignature()));
  9065.  
  9066. SCR_REGISTER_SECURE(SET_PED_PATH_CAN_USE_CLIMBOVERS,0xcacf57ad414acc75, CommandSetPedPathCanUseClimbOvers );
  9067. SCR_REGISTER_SECURE(SET_PED_PATH_CAN_USE_LADDERS,0x32bb80e6e576379a, CommandSetPedPathCanUseLadders );
  9068. SCR_REGISTER_SECURE(SET_PED_PATH_CAN_DROP_FROM_HEIGHT,0x91d9c55e11392690, CommandSetPedPathCanDropFromHeight );
  9069. SCR_REGISTER_SECURE(SET_PED_PATH_CLIMB_COST_MODIFIER,0xd0b0e285f00a8b61, CommandSetPedPathClimbCostModifier );
  9070. SCR_REGISTER_SECURE(SET_PED_PATH_MAY_ENTER_WATER,0xbe74e997fb714956, CommandSetPedToMayEnterWater );
  9071. SCR_REGISTER_SECURE(SET_PED_PATH_PREFER_TO_AVOID_WATER,0x8bb90eda0a7b150e, CommandSetPedPreferToAvoidWater );
  9072. SCR_REGISTER_SECURE(SET_PED_PATH_AVOID_FIRE,0x9ef69bf12b6fbcb3, CommandSetPedPathAvoidFire );
  9073.  
  9074. SCR_REGISTER_SECURE(SET_GLOBAL_MIN_BIRD_FLIGHT_HEIGHT,0xb133bc406357c5a5, CommandSetGlobalMinBirdFlightHeight );
  9075.  
  9076.  
  9077. SCR_REGISTER_SECURE(GET_NAVMESH_ROUTE_DISTANCE_REMAINING,0x9fa616df1ef7172a, CommandGetNavMeshRouteDistanceRemaining );
  9078. SCR_REGISTER_SECURE(GET_NAVMESH_ROUTE_RESULT,0xb02b2cd950b6ba04, CommandGetNavMeshRouteResult );
  9079. SCR_REGISTER_SECURE(IS_CONTROLLED_VEHICLE_UNABLE_TO_GET_TO_ROAD,0xa8a55d2ba7497f6f, CommandIsControlledVehicleUnableToGetToRoad );
  9080.  
  9081. SCR_REGISTER_SECURE(TASK_GO_TO_COORD_ANY_MEANS,0x9603c0ec536c6425, CommandTaskGoToCoordAnyMeans );
  9082. SCR_REGISTER_SECURE(TASK_GO_TO_COORD_ANY_MEANS_EXTRA_PARAMS,0x110dedd855267ad4, CommandTaskGoToCoordAnyMeansExtraParams );
  9083. SCR_REGISTER_SECURE(TASK_GO_TO_COORD_ANY_MEANS_EXTRA_PARAMS_WITH_CRUISE_SPEED,0xfaaa6a6a67097054, CommandTaskGoToCoordAnyMeansExtraParamsWithCruiseSpeed );
  9084.  
  9085. //////////////////////////////////////////////////////////////////////////
  9086. //Animation task commands
  9087. //////////////////////////////////////////////////////////////////////////
  9088.  
  9089. SCR_REGISTER_SECURE(TASK_PLAY_ANIM,0x49d97b076e3590ac, CommandTaskPlayAnim );
  9090. SCR_REGISTER_SECURE(TASK_PLAY_ANIM_ADVANCED,0x246c656f8e525dc7, CommandTaskPlayAnimAdvanced );
  9091. SCR_REGISTER_SECURE(STOP_ANIM_TASK,0x227b2dd85a708e68, CommandStopAnimTask );
  9092.  
  9093. SCR_REGISTER_SECURE(TASK_SCRIPTED_ANIMATION,0x86577f7f045f84c7, CommandTaskScriptedAnimation );
  9094. SCR_REGISTER_SECURE(PLAY_ENTITY_SCRIPTED_ANIM,0xc51d165944c64ca6, CommandPlayEntityScriptedAnimation );
  9095. SCR_REGISTER_UNUSED(START_ANIM_PLAYBACK,0x8fc2aa42fd9fa172, CommandStartAnimPlayback );
  9096. SCR_REGISTER_SECURE(STOP_ANIM_PLAYBACK,0xe3258b995b832e6a, CommandStopAnimPlayback );
  9097. SCR_REGISTER_UNUSED(SET_ANIM_CLIP,0xf962040546b0d2d7, CommandTaskClipSetClip );
  9098. SCR_REGISTER_SECURE(SET_ANIM_WEIGHT,0xecd4da16b454528f, CommandTaskClipSetBlendWeight );
  9099. SCR_REGISTER_UNUSED(SET_ANIM_FILTER,0x979aba5e5d177c74, CommandTaskClipSetFilter );
  9100. SCR_REGISTER_SECURE(SET_ANIM_PHASE,0x60f9850ce23ed209, CommandTaskClipSetPhase );
  9101. SCR_REGISTER_SECURE(SET_ANIM_RATE,0x1cbf84e41b1bfe92, CommandTaskClipSetRate );
  9102. SCR_REGISTER_SECURE(SET_ANIM_LOOPED,0x8bf7b8753e6fadd0, CommandTaskClipSetLooped );
  9103.  
  9104. SCR_REGISTER_SECURE(TASK_PLAY_PHONE_GESTURE_ANIMATION,0xb8ea44dc2c77645c, CommandTaskPlayPhoneGestureAnimation );
  9105. SCR_REGISTER_SECURE(TASK_STOP_PHONE_GESTURE_ANIMATION,0xfcd42d914e921580, CommandTaskStopPhoneGestureAnimation );
  9106. SCR_REGISTER_SECURE(IS_PLAYING_PHONE_GESTURE_ANIM,0x7ce0cfe0533867b0, CommandIsPlayingPhoneGestureAnim );
  9107. SCR_REGISTER_SECURE(GET_PHONE_GESTURE_ANIM_CURRENT_TIME,0x198866ca14785166, CommandGetPhoneGestureAnimCurrentTime );
  9108. SCR_REGISTER_SECURE(GET_PHONE_GESTURE_ANIM_TOTAL_TIME,0xc20701b83e0998c5, CommandGetPhoneGestureAnimTotalTime );
  9109.  
  9110. SCR_REGISTER_SECURE(TASK_VEHICLE_PLAY_ANIM,0x8da8932b29e225ed, CommandVehicleTaskPlayAnim );
  9111. SCR_REGISTER_SECURE(TASK_LOOK_AT_COORD,0xe1e1af00ca06a2b7, CommandTaskLookAtCoord );
  9112. SCR_REGISTER_SECURE(TASK_LOOK_AT_ENTITY,0xf30f15f203736de4, CommandTaskLookAtEntity );
  9113. SCR_REGISTER_SECURE(TASK_CLEAR_LOOK_AT,0xc89ea639a6f338a6, CommandClearLookAt );
  9114.  
  9115. SCR_REGISTER_SECURE(OPEN_SEQUENCE_TASK,0xa888f8cc04f25cc8, CommandOpenSequenceTask );
  9116. SCR_REGISTER_SECURE(CLOSE_SEQUENCE_TASK,0xc963a45b50851768, CommandCloseSequenceTask );
  9117. SCR_REGISTER_SECURE(TASK_PERFORM_SEQUENCE,0x8acada903fcaa42f, CommandTaskPerformSequence );
  9118. SCR_REGISTER_SECURE(TASK_PERFORM_SEQUENCE_LOCALLY,0x7bcccccdabd49a93, CommandTaskPerformSequenceLocally );
  9119.  
  9120. SCR_REGISTER_SECURE(CLEAR_SEQUENCE_TASK,0x7461d7c5ba953bc7, CommandClearSequenceTask );
  9121. SCR_REGISTER_SECURE(SET_SEQUENCE_TO_REPEAT,0x3f2b528df27c8a9f, CommandSetSequenceToRepeat );
  9122. SCR_REGISTER_UNUSED(SET_SEQUENCE_PREVENT_MIGRATION,0x6a177d7d156481ae, CommandSetSequencePreventMigration );
  9123. SCR_REGISTER_SECURE(GET_SEQUENCE_PROGRESS,0x0829092f169950ab, CommandGetSequenceProgress );
  9124.  
  9125. SCR_REGISTER_SECURE(GET_IS_TASK_ACTIVE,0x7f528e84564c4d10, CommandGetIsTaskActive );
  9126.  
  9127. SCR_REGISTER_SECURE(GET_SCRIPT_TASK_STATUS,0x174ced88b97c78d9, CommandGetScriptTaskStatus );
  9128. SCR_REGISTER_SECURE(GET_ACTIVE_VEHICLE_MISSION_TYPE,0xf9eec73ae0b9c439, CommandGetActiveVehicleMissionType);
  9129. SCR_REGISTER_SECURE(TASK_LEAVE_ANY_VEHICLE,0xab7639d658bbccee, CommandTaskLeaveAnyVehicle );
  9130. SCR_REGISTER_SECURE(TASK_AIM_GUN_SCRIPTED,0xccf862b807fe3901, CommandTaskAimGunScripted );
  9131. SCR_REGISTER_SECURE(TASK_AIM_GUN_SCRIPTED_WITH_TARGET,0x30cd3d58df974a16, CommandTaskAimGunScriptedWithTarget );
  9132. SCR_REGISTER_SECURE(UPDATE_TASK_AIM_GUN_SCRIPTED_TARGET,0x20a2aeaf04674323, CommmandUpdateTaskAimGunScriptedTarget );
  9133. SCR_REGISTER_SECURE(GET_CLIP_SET_FOR_SCRIPTED_GUN_TASK,0x3943988de42ef74a, CommandGetClipSetForScriptedGunTask );
  9134. SCR_REGISTER_UNUSED(SET_ROPE_TRACK_ENTITY_FOR_SCRIPTED_GUN_TASK,0x87ac327b490ecccc, CommandSetRopeTrackEntityForGunTask );
  9135.  
  9136. SCR_REGISTER_SECURE(TASK_AIM_GUN_AT_ENTITY,0x636b3584208a6d73, CommandTaskAimGunAtEntity );
  9137. SCR_REGISTER_SECURE(TASK_TURN_PED_TO_FACE_ENTITY,0x529d306014d3c29a, CommandTaskTurnPedToFaceEntity );
  9138. SCR_REGISTER_SECURE(TASK_AIM_GUN_AT_COORD,0x2ea72cdbfacd9e92, CommandTaskAimGunAtCoord );
  9139. SCR_REGISTER_SECURE(TASK_SHOOT_AT_COORD,0xa99ad9dee4794c48, CommandTaskShootAtCoord );
  9140. SCR_REGISTER_SECURE(TASK_SHUFFLE_TO_NEXT_VEHICLE_SEAT,0x8625186d3a8ddd7a, CommandTaskShuffleToNextVehicleSeat );
  9141. SCR_REGISTER_SECURE(CLEAR_PED_TASKS,0x03a927199a2dfe46, CommandClearPedTasks );
  9142. SCR_REGISTER_UNUSED(CLEAR_PED_SCRIPT_TASK_IF_RUNNING_THREAT_RESPONSE_NON_TEMP_TASK,0xf3642376bf6ac7a8, CommandClearPedScriptTaskIfRunningThreatResponseNonTempTask );
  9143.  
  9144. SCR_REGISTER_SECURE(CLEAR_PED_SECONDARY_TASK,0xca2872f050840231, CommandClearPedSecondaryTask );
  9145. SCR_REGISTER_SECURE(TASK_EVERYONE_LEAVE_VEHICLE,0x417047b1f659225c, CommandTaskEveryoneLeaveVehicle );
  9146. SCR_REGISTER_SECURE(TASK_GOTO_ENTITY_OFFSET,0x6624b56c8f9a7bbf, CommandTaskGotoEntityOffset );
  9147. SCR_REGISTER_SECURE(TASK_GOTO_ENTITY_OFFSET_XY,0xb17a6034b9f1bcc2, CommandTaskGotoEntityOffsetXY );
  9148. SCR_REGISTER_UNUSED(TASK_INVESTIGATE_COORDS,0xb834945c258dac7b, CommandTaskInvestigateCoords);
  9149.  
  9150. SCR_REGISTER_SECURE(TASK_TURN_PED_TO_FACE_COORD,0x1a96b8b416bc07d0, CommandTaskTurnPedToFaceCoord );
  9151. SCR_REGISTER_UNUSED(TASK_DRIVE_POINT_ROUTE,0x8c4f2dd2f4b46da9, CommandTaskDrivePointRoute );
  9152. SCR_REGISTER_SECURE(TASK_VEHICLE_TEMP_ACTION,0xcd41d6f721cb9c3a, CommandTaskVehicleTempAction );
  9153. SCR_REGISTER_SECURE(TASK_VEHICLE_MISSION,0xfe5a02cf2178b6a8, CommandTaskVehicleMission );
  9154. SCR_REGISTER_SECURE(TASK_VEHICLE_MISSION_PED_TARGET,0xb69d13e19147910f, CommandTaskVehicleMissionPedTarget );
  9155. SCR_REGISTER_SECURE(TASK_VEHICLE_MISSION_COORS_TARGET,0xfdb121077308e944, CommandTaskVehicleMissionCoorsTarget );
  9156. SCR_REGISTER_UNUSED(IS_PED_INVESTIGATING_WHISTLING_EVENT,0x7fd44d022e2a2e07, CommandIsPedInvestigatingWhistlingEvent );
  9157. SCR_REGISTER_UNUSED(SET_INVESTIGATION_POSITION,0x00f6e31f2f0528cc, CommandSetInvestigationPosition );
  9158. SCR_REGISTER_SECURE(TASK_VEHICLE_ESCORT,0xdbee353c7ca6e88e, CommandTaskVehicleEscort );
  9159. SCR_REGISTER_SECURE(TASK_VEHICLE_FOLLOW,0xbb97101b3b2dbef5, CommandTaskVehicleFollow );
  9160. SCR_REGISTER_SECURE(TASK_VEHICLE_CHASE,0x9286a110a3fd81f1, CommandTaskVehicleChase );
  9161. SCR_REGISTER_SECURE(TASK_VEHICLE_HELI_PROTECT,0x69ac7dd318a3e1ba, CommandTaskHeliProtect );
  9162.  
  9163.  
  9164.  
  9165. SCR_REGISTER_SECURE(SET_TASK_VEHICLE_CHASE_BEHAVIOR_FLAG,0xc8d0b0d2cfd76bb5, CommandSetTaskVehicleChaseBehaviorFlag );
  9166. SCR_REGISTER_SECURE(SET_TASK_VEHICLE_CHASE_IDEAL_PURSUIT_DISTANCE,0xdfad0df477fd9eb3, CommandSetTaskVehicleChaseIdealPursuitDistance);
  9167. SCR_REGISTER_SECURE(TASK_HELI_CHASE,0x42935fa7528ffce8, CommandTaskHeliChase );
  9168. SCR_REGISTER_UNUSED(SET_TASK_HELI_CHASE_TARGET_OFFSET,0x4caff843df59d524, CommandSetTaskHeliChaseTargetOffset );
  9169. SCR_REGISTER_UNUSED(SET_TASK_HELI_CHASE_TARGET_OFFSET_WORLD_SPACE,0x8d6ba126f7ac98e4, CommandSetTaskHeliChaseTargetOffsetWorldSpace );
  9170. SCR_REGISTER_UNUSED(SET_TASK_HELI_CHASE_ORIENTATION,0xe97d050a690da21c, CommandSetTaskHeliChaseOrientation );
  9171.  
  9172. SCR_REGISTER_SECURE(TASK_PLANE_CHASE,0xe8f8c382b0eb7478, CommandTaskPlaneChase );
  9173. SCR_REGISTER_SECURE(TASK_PLANE_LAND,0x214f418bf9481244, CommandTaskPlaneLand );
  9174.  
  9175. SCR_REGISTER_SECURE(CLEAR_DEFAULT_PRIMARY_TASK,0xeb6fbc20375e72c2, CommandClearDefaultPrimaryTask );
  9176. SCR_REGISTER_SECURE(CLEAR_PRIMARY_VEHICLE_TASK,0xe4a094de05c0210c, CommandClearPrimaryVehicleTask );
  9177. SCR_REGISTER_SECURE(CLEAR_VEHICLE_CRASH_TASK,0x273bc6472375634c, CommandClearVehicleCrashTask );
  9178. SCR_REGISTER_SECURE(TASK_PLANE_GOTO_PRECISE_VTOL,0xce661a3c8cf58b44, CommandTaskPlaneGotoPreciseVtol );
  9179. SCR_REGISTER_SECURE(TASK_SUBMARINE_GOTO_AND_STOP,0x835cbdb247b09c67, CommandTaskSubmarineGotoAndStop );
  9180. SCR_REGISTER_SECURE(TASK_HELI_MISSION,0x545c59578966d5b8, CommandTaskHeliMission );
  9181. SCR_REGISTER_SECURE(TASK_HELI_ESCORT_HELI,0x53a1d75e294fdb30, CommandTaskHeliEscort );
  9182. SCR_REGISTER_SECURE(TASK_PLANE_MISSION,0xcdaacb23d43f080d, CommandTaskPlaneMission );
  9183. SCR_REGISTER_SECURE(TASK_PLANE_TAXI,0x908b77e6d8aa83d8, CommandTaskPlaneTaxi );
  9184.  
  9185. SCR_REGISTER_SECURE(TASK_BOAT_MISSION,0xc5a824d6ee9c9cd3, CommandTaskBoatMission );
  9186.  
  9187. SCR_REGISTER_UNUSED(TASK_WEAPON_ROLL, 0x123b2716, CommandTaskWeaponRoll );
  9188.  
  9189. SCR_REGISTER_SECURE(TASK_DRIVE_BY,0x0e6c3a4efa9d9d35, CommandTaskDriveBy );
  9190. SCR_REGISTER_SECURE(SET_DRIVEBY_TASK_TARGET,0x8217f7dfe30383b0, CommandSetDriveByTarget );
  9191. SCR_REGISTER_SECURE(CLEAR_DRIVEBY_TASK_UNDERNEATH_DRIVING_TASK,0xd639b91d6baf25c6, CommandClearDrivebyTaskUnderneathDrivingTask);
  9192. SCR_REGISTER_SECURE(IS_DRIVEBY_TASK_UNDERNEATH_DRIVING_TASK,0x99d3be8c39ba34ff, CommandIsDrivebyTaskUnderneathDrivingTask);
  9193.  
  9194. SCR_REGISTER_SECURE(CONTROL_MOUNTED_WEAPON,0xb604014eee3ca5f8, CommandControlMountedWeapon );
  9195. SCR_REGISTER_SECURE(SET_MOUNTED_WEAPON_TARGET,0x748e7aee8deb2a3a, CommandSetMountedWeaponTarget );
  9196. SCR_REGISTER_UNUSED(CLEAR_MOUNTED_WEAPON_TASK_UNDERNEATH_DRIVING_TASK,0xf4dedafc0c550318, CommandClearMountedWeaponTaskUnderneathDrivingTask);
  9197. SCR_REGISTER_SECURE(IS_MOUNTED_WEAPON_TASK_UNDERNEATH_DRIVING_TASK,0xcb8e14dc7871f52c, CommandIsMountedWeaponTaskUnderneathDrivingTask);
  9198.  
  9199. SCR_REGISTER_SECURE(TASK_USE_MOBILE_PHONE,0x57caa5fbf134d4ae, CommandTaskUseMobilePhone );
  9200. SCR_REGISTER_SECURE(TASK_USE_MOBILE_PHONE_TIMED,0x9bd5d84c8c3f0b2c, CommandTaskUseMobilePhoneTimed );
  9201. SCR_REGISTER_UNUSED(TASK_USE_WALKIE_TALKIE,0x46f7b490eb75e92c, CommandTaskUseWalkieTalkie );
  9202. SCR_REGISTER_SECURE(TASK_CHAT_TO_PED,0x2966111306fa6611, CommandTaskChatToPed );
  9203. SCR_REGISTER_UNUSED(IS_CHATTING_PED_IN_POSITION,0xd701a91d13919148, CommandIsChattingPedInPosition );
  9204. SCR_REGISTER_UNUSED(IS_CHATTING_PED_PLAYING_ANIM,0xae8fabcda3959d22, CommandIsChattingPedPlayingAnim );
  9205. SCR_REGISTER_UNUSED(MAKE_CHATTING_PED_PLAY_ANIM,0x3f4bfc1622d674be, CommandMakeChattingPedPlayAnim );
  9206. SCR_REGISTER_UNUSED(MAKE_CHATTING_PED_LEAVE,0x9dfbb232fdaa2244, CommandMakeChattingPedLeave );
  9207.  
  9208. SCR_REGISTER_UNUSED(ADD_FOLLOW_NAVMESH_TO_PHONE_TASK,0xe12df85ba18a27f8, CommandAddFollowNavmeshToPhoneTask );
  9209.  
  9210. SCR_REGISTER_UNUSED(GET_MOBILE_PHONE_TASK_SUB_TASK,0xeb6576b40ae232f5, CommandGetMobilePhoneTaskSubTask );
  9211. SCR_REGISTER_SECURE(TASK_WARP_PED_INTO_VEHICLE,0x73a521eac1ef5c1b, CommandTaskWarpPedIntoVehicle );
  9212.  
  9213. SCR_REGISTER_SECURE(TASK_SHOOT_AT_ENTITY,0x913e191f1f726271, CommandTaskShootAtEntity );
  9214. SCR_REGISTER_SECURE(TASK_CLIMB,0x893ddd76cc7c67b1, CommandTaskClimb );
  9215. SCR_REGISTER_SECURE(TASK_CLIMB_LADDER,0x12425bd281be5f3c, CommandTaskClimbLadder );
  9216. SCR_REGISTER_UNUSED(TASK_RAPPEL_DOWN_WALL,0x42ee24d502e263b3, CommandTaskRappelDownWall );
  9217. SCR_REGISTER_SECURE(TASK_RAPPEL_DOWN_WALL_USING_CLIPSET_OVERRIDE,0x80f9b0598b0c9c85, CommandTaskRappelDownWallUsingClipsetOverride);
  9218. SCR_REGISTER_SECURE(GET_TASK_RAPPEL_DOWN_WALL_STATE,0xa0584425edd6ec9d, CommandsGetTaskRappelDownWallState );
  9219. SCR_REGISTER_SECURE(CLEAR_PED_TASKS_IMMEDIATELY,0x51bb443b279e4104, CommandClearPedTasksImmediately );
  9220. SCR_REGISTER_SECURE(TASK_PERFORM_SEQUENCE_FROM_PROGRESS,0x23378ce912d5b544, CommandTaskPerformSequenceFromProgress );
  9221. SCR_REGISTER_SECURE(SET_NEXT_DESIRED_MOVE_STATE,0x8ff5f2b541a0e471, CommandSetNextDesiredMoveState );
  9222. SCR_REGISTER_SECURE(SET_PED_DESIRED_MOVE_BLEND_RATIO,0x98f7e0916b6b5a0b, CommandSetPedDesiredMoveBlendRatio );
  9223. SCR_REGISTER_SECURE(GET_PED_DESIRED_MOVE_BLEND_RATIO,0x5e9b3bbf63a5e2f6, CommandGetPedDesiredMoveBlendRatio );
  9224.  
  9225. SCR_REGISTER_SECURE(TASK_GOTO_ENTITY_AIMING,0x27c6152f3e5f2933, CommandTaskGotoEntityAiming );
  9226. SCR_REGISTER_SECURE(TASK_SET_DECISION_MAKER,0xd029ba670c8df65b, CommandTaskSetDecisionMaker );
  9227. SCR_REGISTER_SECURE(TASK_SET_SPHERE_DEFENSIVE_AREA,0x223133feb94059cd, CommandTaskSetSphereDefensiveArea );
  9228. SCR_REGISTER_SECURE(TASK_CLEAR_DEFENSIVE_AREA,0x4b16afbb0c12b630, CommandTaskClearDefensiveArea );
  9229. SCR_REGISTER_SECURE(TASK_PED_SLIDE_TO_COORD,0xed2842d9cc50eb6e, CommandTaskPedSlideToCoord );
  9230. SCR_REGISTER_UNUSED(TASK_PED_SLIDE_TO_COORD_AND_PLAY_ANIM,0x93a741ed3ed7f56f, CommandTaskPedSlideToCoordAndPlayAnim );
  9231. SCR_REGISTER_UNUSED(TASK_PED_SLIDE_TO_COORD_AND_PLAY_ANIM_HDG_RATE, 0x95abc676, CommandTaskPedSlideToCoordAndPlayAnimWithHeadingChangeRate );
  9232. SCR_REGISTER_SECURE(TASK_PED_SLIDE_TO_COORD_HDG_RATE,0xd6711eee6b632dae, CommandTaskPedSlideToCoordWithHeadingChangeRate );
  9233. SCR_REGISTER_UNUSED(TASK_DRIVE_POINT_ROUTE_ADVANCED,0x730dad3cf7f02fa7, CommandTaskDrivePointRouteAdvanced );
  9234.  
  9235. // Combat and cover
  9236. SCR_REGISTER_SECURE(ADD_COVER_POINT,0x41ba9dba367c9c12, CommandAddCoverPoint );
  9237. SCR_REGISTER_SECURE(REMOVE_COVER_POINT,0x5990dad3727a1b45, CommandRemoveCoverPoint );
  9238. SCR_REGISTER_SECURE(DOES_SCRIPTED_COVER_POINT_EXIST_AT_COORDS,0x7fd113b09d96c678, CommandDoesScriptedCoverPointExistAtCoords );
  9239. SCR_REGISTER_SECURE(GET_SCRIPTED_COVER_POINT_COORDS,0x137fb6fc6e40a0a8, CommandGetScriptedCoverPointCoords );
  9240. SCR_REGISTER_SECURE(ADD_SCRIPTED_COVER_AREA, 0x28b7b9bfdaf274aa, CommandAddScriptedCoverArea);
  9241. //SCR_REGISTER_UNUSED(GET_SCRIPTED_COVER_POINT_STATUS, 0x56c9de8d, CommandGetScriptedCoverPointStatus );
  9242. SCR_REGISTER_SECURE(TASK_COMBAT_PED,0xc1a74225341aa9fb, CommandTaskCombat );
  9243. SCR_REGISTER_SECURE(TASK_COMBAT_PED_TIMED,0x5fc4a511155d6f9a, CommandTaskCombatTimed );
  9244. SCR_REGISTER_SECURE(TASK_SEEK_COVER_FROM_POS,0x3f58924930345d8d, CommandTaskSeekCoverFromPos );
  9245. SCR_REGISTER_SECURE(TASK_SEEK_COVER_FROM_PED,0xb67d1d267c666dc4, CommandTaskSeekCoverFromPed );
  9246. SCR_REGISTER_SECURE(TASK_SEEK_COVER_TO_COVER_POINT,0x419e449559bf60b4, CommandTaskSeekCoverToCoverPoint );
  9247. SCR_REGISTER_SECURE(TASK_SEEK_COVER_TO_COORDS,0x264cd1b504831626, CommandTaskSeekCoverToCoords );
  9248. SCR_REGISTER_SECURE(TASK_PUT_PED_DIRECTLY_INTO_COVER,0x809dfa39515d5981, CommandTaskPutPedDirectlyIntoCover );
  9249. SCR_REGISTER_UNUSED(TASK_PUT_PED_DIRECTLY_INTO_COVER_FROM_TARGET,0x9f8e54193d416a78, CommandTaskPutPedDirectlyIntoCoverFromTarget );
  9250. SCR_REGISTER_SECURE(TASK_WARP_PED_DIRECTLY_INTO_COVER,0x6e01e9e8d89f8276, CommandTaskWarpPedDirectlyIntoCover);
  9251. SCR_REGISTER_UNUSED(SET_COVER_TASK_TARGET,0x778c4e702f2a65e5, CommandSetCoverTarget );
  9252. SCR_REGISTER_SECURE(TASK_EXIT_COVER,0x412ed6ee0b28c20d, CommandTaskExitCover );
  9253. SCR_REGISTER_SECURE(TASK_PUT_PED_DIRECTLY_INTO_MELEE,0x957211dc68d2869f, CommandTaskPutPedDirectlyIntoMelee );
  9254. SCR_REGISTER_UNUSED(TASK_ADVANCE_TO_TARGET_IN_LINE,0xd9c691ad25d0d5eb, CommandTaskAdvanceToTargetInLine );
  9255.  
  9256. SCR_REGISTER_UNUSED(SET_CHARGE_TARGET_ENABLED,0x9dea9d830bfc9937, CommandSetChargeTargetEnabled );
  9257. SCR_REGISTER_UNUSED(SET_MAX_NUM_ACTIVE_CHARGERS,0xa2d85c968ea44e3d, CommandSetMaxNumActiveChargers );
  9258. SCR_REGISTER_UNUSED(SET_MIN_TIME_BETWEEN_CHARGES_AT_SAME_TARGET,0xfbb868ae331debcd, CommandSetMinTimeBetweenChargesAtSameTarget );
  9259.  
  9260. SCR_REGISTER_SECURE(TASK_TOGGLE_DUCK,0xa5af895dd224fdc0, CommandTaskToggleDuck );
  9261.  
  9262. SCR_REGISTER_SECURE(TASK_GUARD_CURRENT_POSITION,0x274a180d57a0d9a6, CommandTaskGuardCurrentPosition );
  9263. SCR_REGISTER_SECURE(TASK_GUARD_ASSIGNED_DEFENSIVE_AREA,0x4182d960e26d40bb, CommandTaskGuardAssignedDefensiveArea );
  9264. SCR_REGISTER_UNUSED(TASK_GUARD_ANGLED_DEFENSIVE_AREA,0xf035a69189e11b7a, CommandTaskGuardAngledDefensiveArea );
  9265. SCR_REGISTER_SECURE(TASK_GUARD_SPHERE_DEFENSIVE_AREA,0x061a42ebc9ceb366, CommandTaskGuardSphereDefensiveArea );
  9266. SCR_REGISTER_SECURE(TASK_STAND_GUARD,0x4b551665e9b2e8f6, CommandTaskStandGuard );
  9267.  
  9268. SCR_REGISTER_SECURE(SET_DRIVE_TASK_CRUISE_SPEED,0xbb3480bb855cdb33, CommandSetDriveTaskCruiseSpeed );
  9269. SCR_REGISTER_SECURE(SET_DRIVE_TASK_MAX_CRUISE_SPEED,0x3d2ebac0a745e60c, CommandSetDriveTaskMaxCruiseSpeed );
  9270. SCR_REGISTER_SECURE(SET_DRIVE_TASK_DRIVING_STYLE,0x27be5555cdf6f983, CommandSetDriveTaskDrivingStyle );
  9271. SCR_REGISTER_UNUSED(SET_PURSUE_TASK_IDEAL_DISTANCE,0x971919670679e003, CommandSetPursueTaskIdealDistance );
  9272.  
  9273. SCR_REGISTER_SECURE(ADD_COVER_BLOCKING_AREA,0x5af3192f3c3d45ec, CommandAddCoverBlockingArea );
  9274. SCR_REGISTER_SECURE(REMOVE_ALL_COVER_BLOCKING_AREAS,0x71fcd88fc7f98621, CommandFlushCoverBlockingAreas );
  9275. SCR_REGISTER_SECURE(REMOVE_COVER_BLOCKING_AREAS_AT_POSITION,0xac7ab29fe3c36266, CommandRemoveCoverBlockingAreasAtPosition );
  9276. SCR_REGISTER_SECURE(REMOVE_SPECIFIC_COVER_BLOCKING_AREAS,0xaa443863046f380a, CommandRemoveSpecificCoverBlockingAreas);
  9277.  
  9278. SCR_REGISTER_SECURE(TASK_START_SCENARIO_IN_PLACE,0xc9fefb406c44f60b, CommandTaskStartScenarioInPlace );
  9279. SCR_REGISTER_SECURE(TASK_START_SCENARIO_AT_POSITION,0xdb4f67aafbf32aa5, CommandTaskStartScenarioAtPosition );
  9280. SCR_REGISTER_UNUSED(TASK_START_VEHICLE_SCENARIO,0xbfb160b082e439fa, CommandTaskStartVehicleScenario );
  9281. SCR_REGISTER_SECURE(TASK_USE_NEAREST_SCENARIO_TO_COORD,0x1d698ecdff42ac58, CommandTaskUseNearestScenarioToPos );
  9282. SCR_REGISTER_SECURE(TASK_USE_NEAREST_SCENARIO_TO_COORD_WARP,0x8ceb5d8b56025aa2, CommandTaskUseNearestScenarioToPosWarp );
  9283. SCR_REGISTER_UNUSED(TASK_USE_NEAREST_TRAIN_SCENARIO_TO_COORD_WARP,0x97deba5039a7f6c7, CommandTaskUseNearestTrainScenarioToPosWarp);
  9284. SCR_REGISTER_SECURE(TASK_USE_NEAREST_SCENARIO_CHAIN_TO_COORD,0xaf0492886bc6c105, CommandTaskUseNearestScenarioChainToPos );
  9285. SCR_REGISTER_SECURE(TASK_USE_NEAREST_SCENARIO_CHAIN_TO_COORD_WARP,0x6d44636281842060, CommandTaskUseNearestScenarioChainToPosWarp );
  9286. SCR_REGISTER_SECURE(DOES_SCENARIO_EXIST_IN_AREA,0x5b138084858689ac, CommandDoesScenarioExistInArea );
  9287. SCR_REGISTER_SECURE(DOES_SCENARIO_OF_TYPE_EXIST_IN_AREA,0x48d8c2729764de01, CommandDoesScenarioOfTypeExistInArea);
  9288. SCR_REGISTER_SECURE(IS_SCENARIO_OCCUPIED,0xc85b76c87214bd87, CommandIsScenarioOccupied );
  9289. SCR_REGISTER_SECURE(PED_HAS_USE_SCENARIO_TASK,0x23bf8abbc9594609, CommandPedHasUseScenarioTask );
  9290. SCR_REGISTER_UNUSED(OVERRIDE_TASKED_SCENARIO_BASE_ANIM,0xdd7e39f6a9fa3ce0, CommandOverrideTaskedScenarioBaseAnim );
  9291. SCR_REGISTER_SECURE(PLAY_ANIM_ON_RUNNING_SCENARIO,0x8b90895f7d0bee59, CommandPlayAnimOnRunnningScenario );
  9292.  
  9293. SCR_REGISTER_SECURE(DOES_SCENARIO_GROUP_EXIST,0x1e63be2394148da0, CommandDoesScenarioGroupExist );
  9294. SCR_REGISTER_SECURE(IS_SCENARIO_GROUP_ENABLED,0x96a05000ccd43584, CommandIsScenarioGroupEnabled );
  9295. SCR_REGISTER_SECURE(SET_SCENARIO_GROUP_ENABLED,0xa3d2c191df3cb742, CommandSetScenarioGroupEnabled );
  9296. SCR_REGISTER_SECURE(RESET_SCENARIO_GROUPS_ENABLED,0xb750df5029a6790a, CommandResetScenarioGroupsEnabled );
  9297. SCR_REGISTER_SECURE(SET_EXCLUSIVE_SCENARIO_GROUP,0xedf1af96b1a92325, CommandSetExclusiveScenarioGroup );
  9298. SCR_REGISTER_SECURE(RESET_EXCLUSIVE_SCENARIO_GROUP,0xa7fee431b0d22e80, CommandResetExclusiveScenarioGroup );
  9299. SCR_REGISTER_UNUSED(FORCE_SCENARIO_GROUP_PRIORITY,0xb2a385f314986d7d, CommandForceScenarioGroupPriority );
  9300. SCR_REGISTER_UNUSED(RESET_SCENARIO_GROUPS_PRIORITY,0xf842c44cfffb8884, CommandResetScenarioGroupsPriority );
  9301.  
  9302. SCR_REGISTER_SECURE(IS_SCENARIO_TYPE_ENABLED,0xaec3fb024079cf27, CommandIsScenarioTypeEnabled );
  9303. SCR_REGISTER_SECURE(SET_SCENARIO_TYPE_ENABLED,0x247f21b1803f0ec4, CommandSetScenarioTypeEnabled );
  9304. SCR_REGISTER_SECURE(RESET_SCENARIO_TYPES_ENABLED,0xa9fc42dea687033d, CommandResetScenarioTypesEnabled );
  9305.  
  9306. SCR_REGISTER_UNUSED(SUPPRESS_NORMAL_SCENARIO_EXITS_NEXT_FRAME,0x462559c9bfdb51d1, CommandSuppressNormalScenarioExitsNextFrame);
  9307. SCR_REGISTER_UNUSED(SUPPRESS_SCENARIO_ATTRACTION_NEXT_FRAME,0xf50d4dd468864fca, CommandSuppressScenarioAttractionNextFrame);
  9308. SCR_REGISTER_UNUSED(SUPPRESS_BREAKOUT_SCENARIO_EXITS_NEXT_FRAME,0x743ef6f4b8c462a8,CommandSuppressBreakoutScenarioExitsNextFrame);
  9309.  
  9310.  
  9311. SCR_REGISTER_SECURE(IS_PED_ACTIVE_IN_SCENARIO,0x67360b9474054c5e, CommandIsPedActiveInScenario );
  9312. SCR_REGISTER_SECURE(IS_PED_PLAYING_BASE_CLIP_IN_SCENARIO,0x2dc1bc483b6a3316, CommandIsPedPlayingBaseClipInScenario );
  9313. SCR_REGISTER_SECURE(SET_PED_CAN_PLAY_AMBIENT_IDLES,0xe72d9eb9db4b874d, CommandSetCanPlayAmbientIdles );
  9314.  
  9315. SCR_REGISTER_SECURE(TASK_COMBAT_HATED_TARGETS_IN_AREA,0xe45039a194d735de, CommandTaskCombatHatedTargetsInArea );
  9316. SCR_REGISTER_SECURE(TASK_COMBAT_HATED_TARGETS_AROUND_PED,0x766d377a16f499e3, CommandTaskCombatHatedTargetsAroundPed );
  9317. SCR_REGISTER_SECURE(TASK_COMBAT_HATED_TARGETS_AROUND_PED_TIMED,0x34ad04c1e7cb67d8, CommandTaskCombatHatedTargetsAroundPedTimed );
  9318.  
  9319. SCR_REGISTER_SECURE(TASK_THROW_PROJECTILE,0xa43ab969c8956eb8, CommandTaskThrowProjectile );
  9320.  
  9321. SCR_REGISTER_SECURE(TASK_SWAP_WEAPON,0xd4834169f570e6d2, CommandTaskSwapWeapon );
  9322. SCR_REGISTER_SECURE(TASK_RELOAD_WEAPON,0x62f1ebed7a072b40, CommandTaskReloadWeapon );
  9323. SCR_REGISTER_UNUSED(TASK_COMBAT_ROLL,0x8eddf98bab0a7bc9, CommandTaskCombatRoll );
  9324. SCR_REGISTER_SECURE(IS_PED_GETTING_UP,0x03454821a9ecf4aa, CommandIsPedGettingUp );
  9325. SCR_REGISTER_SECURE(TASK_WRITHE,0x99e9c3c2d6af9a52, CommandTaskWrithe );
  9326. SCR_REGISTER_SECURE(IS_PED_IN_WRITHE,0x645f244ecddef6cf, CommandIsPedInWrithe );
  9327.  
  9328. SCR_REGISTER_SECURE(OPEN_PATROL_ROUTE,0x9d3e7062e40f2049, CommandOpenPatrolRoute );
  9329. SCR_REGISTER_SECURE(CLOSE_PATROL_ROUTE,0xc65dee4d8f9f02eb, CommandClosePatrolRoute );
  9330. SCR_REGISTER_SECURE(ADD_PATROL_ROUTE_NODE,0xad84831de60c1442, CommandAddPatrolNode );
  9331. SCR_REGISTER_SECURE(ADD_PATROL_ROUTE_LINK,0x23c767cf5993cf13, CommandAddPatrolNodeLink );
  9332. SCR_REGISTER_SECURE(CREATE_PATROL_ROUTE,0x274f700901c096dd, CommandCreatePatrolRoute );
  9333. SCR_REGISTER_SECURE(DELETE_PATROL_ROUTE,0x6bd70dca1fdc1c56, CommandDeletePatrolRoute );
  9334. SCR_REGISTER_SECURE(GET_PATROL_TASK_INFO,0x52f734cebe20dfba, CommandGetPatrolNodeInfo );
  9335.  
  9336. SCR_REGISTER_SECURE(TASK_PATROL,0xac81ed4a4f2fec9c, CommandTaskPatrol );
  9337.  
  9338. SCR_REGISTER_SECURE(TASK_STAY_IN_COVER,0xf21f1b3825b46822, CommandTaskStayInCover );
  9339.  
  9340. SCR_REGISTER_SECURE(ADD_VEHICLE_SUBTASK_ATTACK_COORD,0xf2e8f4bd20869ab2, CommandAddVehicleSubtaskAttackCoord );
  9341. SCR_REGISTER_SECURE(ADD_VEHICLE_SUBTASK_ATTACK_PED,0x80e8bfe6e62212c1, CommandAddVehicleSubtaskAttackPed );
  9342.  
  9343. SCR_REGISTER_SECURE(TASK_VEHICLE_SHOOT_AT_PED,0xbba695ad5315cdd8, CommandVehicleShootAtPed );
  9344. SCR_REGISTER_SECURE(TASK_VEHICLE_AIM_AT_PED,0xc514d16960a4fa43, CommandVehicleAimAtPed );
  9345. SCR_REGISTER_SECURE(TASK_VEHICLE_SHOOT_AT_COORD,0xe5d96c43ab0b0dc6, CommandVehicleShootAtCoord );
  9346. SCR_REGISTER_SECURE(TASK_VEHICLE_AIM_AT_COORD,0x7d49955a299139e9, CommandVehicleAimAtCoord );
  9347. SCR_REGISTER_UNUSED(TASK_VEHICLE_AIM_USING_CAMERA,0x6614a146419eb189, CommandVehicleAimUsingCamera );
  9348. SCR_REGISTER_UNUSED(TASK_HANG_GLIDER,0xbdbadc2ff688e5b2, CommandTaskHangGlider );
  9349. SCR_REGISTER_UNUSED(SET_HANG_GLIDER_AIR_SPEED,0x23b2c655efd82c53, CommandSetHangGliderAirSpeed );
  9350. SCR_REGISTER_SECURE(TASK_VEHICLE_GOTO_NAVMESH,0xdf44785f7bc09dd2, CommandTaskVehicleGotoNavmesh );
  9351.  
  9352. SCR_REGISTER_SECURE(TASK_GO_TO_COORD_WHILE_AIMING_AT_COORD,0x642c58f4ca259448, CommandTaskGoToCoordWhileAimingAtCoord );
  9353. SCR_REGISTER_SECURE(TASK_GO_TO_COORD_WHILE_AIMING_AT_ENTITY,0x98db2abd53b8d70b, CommandTaskGoToCoordWhileAimingAtEntity );
  9354. SCR_REGISTER_SECURE(TASK_GO_TO_COORD_AND_AIM_AT_HATED_ENTITIES_NEAR_COORD,0x2a83cd9941ec44d0, CommandTaskGoToCoordAndAimAtHatedEntitiesNearCoord);
  9355. SCR_REGISTER_SECURE(TASK_GO_TO_ENTITY_WHILE_AIMING_AT_COORD,0x60fad147bb45a92a, CommandTaskGoToEntityWhileAimingAtCoord );
  9356. SCR_REGISTER_SECURE(TASK_GO_TO_ENTITY_WHILE_AIMING_AT_ENTITY,0x0b47872e9d74882c, CommandTaskGoToEntityWhileAimingAtEntity);
  9357.  
  9358. SCR_REGISTER_UNUSED(TASK_BIND_POSE,0xac5fea0754bcc7cf, CommandTaskBindPose );
  9359. SCR_REGISTER_UNUSED(ELECTROCUTE_PED,0x9eebf0c360e75bef, CommandElectrocute );
  9360. SCR_REGISTER_SECURE(SET_HIGH_FALL_TASK,0xdb1174c6546afc65, CommandHighFall );
  9361. SCR_REGISTER_UNUSED(DANGLE_FROM_MEATHOOK,0xd9c1a873ff69a447, CommandDangleFromMeathook );
  9362. SCR_REGISTER_UNUSED(SLUNG_OVER_SHOULDER,0xcbdd75b6dfb92714, CommandSlungOverShoulder );
  9363. SCR_REGISTER_UNUSED(MAKE_PED_STUMBLE,0x6b0ebf2507baba30, CommandStumble );
  9364.  
  9365.  
  9366. SCR_REGISTER_SECURE(REQUEST_WAYPOINT_RECORDING,0x70f260358d1a42c4, waypoint_commands::CommandRequestWaypointRecording );
  9367. SCR_REGISTER_SECURE(GET_IS_WAYPOINT_RECORDING_LOADED,0xbd3cea9cd36e271e, waypoint_commands::CommandGetIsWaypointRecordingLoaded );
  9368. SCR_REGISTER_SECURE(REMOVE_WAYPOINT_RECORDING,0x10f7bfe3a88cb99b, waypoint_commands::CommandRemoveWaypointRecording );
  9369.  
  9370. SCR_REGISTER_SECURE(WAYPOINT_RECORDING_GET_NUM_POINTS,0x042959494b85e155, waypoint_commands::CommandWaypointRecordingGetNumPoints );
  9371. SCR_REGISTER_SECURE(WAYPOINT_RECORDING_GET_COORD,0x76263b6f2b150aff, waypoint_commands::CommandWaypointRecordingGetCoord );
  9372. SCR_REGISTER_SECURE(WAYPOINT_RECORDING_GET_SPEED_AT_POINT,0xaa4b93a8c0d05be3, waypoint_commands::CommandWaypointRecordingGetSpeedAtPoint);
  9373. SCR_REGISTER_SECURE(WAYPOINT_RECORDING_GET_CLOSEST_WAYPOINT,0xe49fae8c75dfe3b0, waypoint_commands::CommandWaypointRecordingGetClosestWaypoint );
  9374.  
  9375. SCR_REGISTER_SECURE(TASK_FOLLOW_WAYPOINT_RECORDING,0x4218764824f31173, waypoint_commands::CommandTaskFollowWaypointRecording );
  9376. SCR_REGISTER_SECURE(IS_WAYPOINT_PLAYBACK_GOING_ON_FOR_PED,0xb4ae2a423a4176ce, waypoint_commands::CommandIsWaypointPlaybackGoingOnForPed );
  9377. SCR_REGISTER_SECURE(GET_PED_WAYPOINT_PROGRESS,0x0b331f8dc5c61933, waypoint_commands::CommandGetPedWaypointProgress );
  9378. SCR_REGISTER_UNUSED(SET_PED_WAYPOINT_PROGRESS,0xadc4c24903027450, waypoint_commands::CommandSetPedWaypointProgress );
  9379. SCR_REGISTER_SECURE(GET_PED_WAYPOINT_DISTANCE,0xb80b2f3bfb68df1a, waypoint_commands::CommandGetPedWaypointDistance );
  9380. SCR_REGISTER_SECURE(SET_PED_WAYPOINT_ROUTE_OFFSET,0x455e0249f399ef4c, waypoint_commands::CommandSetPedWaypointRouteOffset );
  9381. SCR_REGISTER_SECURE(GET_WAYPOINT_DISTANCE_ALONG_ROUTE,0xd2fe51a38e9a1946, waypoint_commands::CommandGetWaypointDistanceAlongRoute );
  9382. SCR_REGISTER_SECURE(WAYPOINT_PLAYBACK_GET_IS_PAUSED,0x656f70678f75d966, waypoint_commands::CommandWaypointPlaybackGetIsPaused );
  9383. SCR_REGISTER_SECURE(WAYPOINT_PLAYBACK_PAUSE,0x499c4b0d70f4097c, waypoint_commands::CommandWaypointPlaybackPause );
  9384. SCR_REGISTER_SECURE(WAYPOINT_PLAYBACK_RESUME,0x4ffeb98e621afb27, waypoint_commands::CommandWaypointPlaybackResume );
  9385.  
  9386. SCR_REGISTER_SECURE(WAYPOINT_PLAYBACK_OVERRIDE_SPEED,0x369b082b04a4f619, waypoint_commands::CommandWaypointPlaybackOverrideSpeed );
  9387. SCR_REGISTER_SECURE(WAYPOINT_PLAYBACK_USE_DEFAULT_SPEED,0x5039c5050b42f1e0, waypoint_commands::CommandWaypointPlaybackUseDefaultSpeed );
  9388.  
  9389. SCR_REGISTER_SECURE(USE_WAYPOINT_RECORDING_AS_ASSISTED_MOVEMENT_ROUTE,0xbb6589e0d27bd54e, waypoint_commands::CommandUseWaypointRecordingAsAssistedMovementRoute);
  9390.  
  9391. SCR_REGISTER_SECURE(WAYPOINT_PLAYBACK_START_AIMING_AT_PED,0x9b4dd143cd0c78fe, waypoint_commands::CommandWaypointPlaybackStartAimingAtPed );
  9392. SCR_REGISTER_UNUSED(WAYPOINT_PLAYBACK_START_AIMING_AT_ENTITY,0x47e2d6d68a34062a, waypoint_commands::CommandWaypointPlaybackStartAimingAtEntity );
  9393. SCR_REGISTER_SECURE(WAYPOINT_PLAYBACK_START_AIMING_AT_COORD,0xa142fd669ff80016, waypoint_commands::CommandWaypointPlaybackStartAimingAtCoord );
  9394. SCR_REGISTER_SECURE(WAYPOINT_PLAYBACK_START_SHOOTING_AT_PED,0xa9b13da1d075a160, waypoint_commands::CommandWaypointPlaybackStartShootingAtPed );
  9395. SCR_REGISTER_UNUSED(WAYPOINT_PLAYBACK_START_SHOOTING_AT_ENTITY,0x4f6e75c1ca97a1ef, waypoint_commands::CommandWaypointPlaybackStartShootingAtEntity );
  9396. SCR_REGISTER_SECURE(WAYPOINT_PLAYBACK_START_SHOOTING_AT_COORD,0x4f826adf9bdb6bd8, waypoint_commands::CommandWaypointPlaybackStartShootingAtCoord );
  9397. SCR_REGISTER_SECURE(WAYPOINT_PLAYBACK_STOP_AIMING_OR_SHOOTING,0x282cae6fb0e3b2fc, waypoint_commands::CommandWaypointPlaybackStopAimingOrShooting );
  9398.  
  9399. SCR_REGISTER_SECURE(ASSISTED_MOVEMENT_REQUEST_ROUTE,0xb5549ea4fcf75870, waypoint_commands::CommandAssistedMovementRequestRoute);
  9400. SCR_REGISTER_SECURE(ASSISTED_MOVEMENT_REMOVE_ROUTE,0xed4af6b9266b55c9, waypoint_commands::CommandAssistedMovementRemoveRoute);
  9401.  
  9402. SCR_REGISTER_SECURE(ASSISTED_MOVEMENT_IS_ROUTE_LOADED,0x632b7d3b9b85016a, waypoint_commands::CommandAssistedMovementIsRouteLoaded);
  9403. SCR_REGISTER_UNUSED(ASSISTED_MOVEMENT_GET_ROUTE_PROPERTIES,0xec6dfa1a86cf270a, waypoint_commands::CommandAssistedMovementGetRouteProperties);
  9404. SCR_REGISTER_SECURE(ASSISTED_MOVEMENT_SET_ROUTE_PROPERTIES,0x50569e4320bc8e92, waypoint_commands::CommandAssistedMovementSetRouteProperties);
  9405. SCR_REGISTER_SECURE(ASSISTED_MOVEMENT_OVERRIDE_LOAD_DISTANCE_THIS_FRAME,0xd7e4e11cc0659bb6, waypoint_commands::CommandAssistedMovementOverrideLoadDistanceThisFrame);
  9406.  
  9407. SCR_REGISTER_SECURE(TASK_VEHICLE_FOLLOW_WAYPOINT_RECORDING,0xa24707688ba83cea, waypoint_commands::CommandTaskVehicleFollowWaypointRecording);
  9408. SCR_REGISTER_SECURE(IS_WAYPOINT_PLAYBACK_GOING_ON_FOR_VEHICLE,0x22ff01f89d3006c0, waypoint_commands::CommandIsWaypointPlaybackGoingOnForVehicle);
  9409. SCR_REGISTER_SECURE(GET_VEHICLE_WAYPOINT_PROGRESS,0x46ea6598acefacc1, waypoint_commands::CommandGetVehicleWaypointProgress);
  9410. SCR_REGISTER_SECURE(GET_VEHICLE_WAYPOINT_TARGET_POINT,0x0e9d3608e0ae9ee3, waypoint_commands::CommandGetVehicleWaypointTargetPoint);
  9411. SCR_REGISTER_SECURE(VEHICLE_WAYPOINT_PLAYBACK_PAUSE,0xe3948de25c763434, waypoint_commands::CommandVehicleWaypointPlaybackPause);
  9412. SCR_REGISTER_UNUSED(VEHICLE_WAYPOINT_PLAYBACK_GET_IS_PAUSED,0xa84a1cf14183e169, waypoint_commands::CommandVehicleWaypointPlaybackGetIsPaused);
  9413. SCR_REGISTER_SECURE(VEHICLE_WAYPOINT_PLAYBACK_RESUME,0x211bb80656beac0f, waypoint_commands::CommandVehicleWaypointPlaybackResume);
  9414. SCR_REGISTER_SECURE(VEHICLE_WAYPOINT_PLAYBACK_USE_DEFAULT_SPEED,0x502f9fce448f5724, waypoint_commands::CommandVehicleWaypointPlaybackUseDefaultSpeed);
  9415. SCR_REGISTER_SECURE(VEHICLE_WAYPOINT_PLAYBACK_OVERRIDE_SPEED,0xf248aeaab65d17cd, waypoint_commands::CommandVehicleWaypointPlaybackOverrideSpeed);
  9416.  
  9417. SCR_REGISTER_UNUSED(TASK_NM_ATTACH_PED_TO_ENTITY,0x7ed90e7321ac4a87, CommandTaskNMAttachPedToEntity);
  9418. SCR_REGISTER_SECURE(TASK_SET_BLOCKING_OF_NON_TEMPORARY_EVENTS,0xf7b73727a8f72f54, CommandTaskSetBlockingOfNonTemporaryEvents);
  9419. SCR_REGISTER_SECURE(TASK_FORCE_MOTION_STATE,0x57374b880e0a67bd, CommandTaskForceMotionState);
  9420.  
  9421. // MoVE interface
  9422. SCR_REGISTER_SECURE(TASK_MOVE_NETWORK_BY_NAME,0x84a70ae1a2393914, CommandTaskMoveNetworkByName);
  9423. SCR_REGISTER_SECURE(TASK_MOVE_NETWORK_ADVANCED_BY_NAME,0xad3d17c7e426d09d, CommandTaskMoveNetworkAdvancedByName);
  9424. SCR_REGISTER_SECURE(TASK_MOVE_NETWORK_BY_NAME_WITH_INIT_PARAMS,0x4601817fd87b48e3, CommandTaskMoveNetworkByNameWithInitParams);
  9425. SCR_REGISTER_SECURE(TASK_MOVE_NETWORK_ADVANCED_BY_NAME_WITH_INIT_PARAMS,0xca9cbdbc10f9d281, CommandTaskMoveNetworkAdvancedByNameWithInitParams);
  9426. SCR_REGISTER_SECURE(IS_TASK_MOVE_NETWORK_ACTIVE,0xfcd53f51d587f4c6, CommandIsTaskMoveNetworkActive);
  9427. SCR_REGISTER_SECURE(IS_TASK_MOVE_NETWORK_READY_FOR_TRANSITION,0x0422aefd9002867b, CommandIsTaskMoveNetworkReadyForTransition);
  9428. SCR_REGISTER_SECURE(REQUEST_TASK_MOVE_NETWORK_STATE_TRANSITION,0xdcd29be535921736, CommandRequestTaskMoveNetworkStateTransition);
  9429. SCR_REGISTER_SECURE(SET_EXPECTED_CLONE_NEXT_TASK_MOVE_NETWORK_STATE,0x2029bef342249fb1, CommandSetExpectedCloneNextTaskMoveNetworkState);
  9430. SCR_REGISTER_SECURE(GET_TASK_MOVE_NETWORK_STATE,0x111890991356db66, CommandGetTaskMoveNetworkState);
  9431. SCR_REGISTER_SECURE(SET_TASK_MOVE_NETWORK_ANIM_SET,0x2d9f06756211492a, CommandSetTaskMoveNetworkClipSet);
  9432. SCR_REGISTER_SECURE(SET_TASK_MOVE_NETWORK_SIGNAL_FLOAT,0x8e11f085404a3100, CommandSetTaskMoveNetworkSignalFloat);
  9433. SCR_REGISTER_SECURE(SET_TASK_MOVE_NETWORK_SIGNAL_LOCAL_FLOAT,0x357c016ef8883bad, CommandSetTaskMoveNetworkSignalLocalFloat);
  9434. SCR_REGISTER_SECURE(SET_TASK_MOVE_NETWORK_SIGNAL_FLOAT_LERP_RATE,0x6e3f82dd454ea5b1, CommandSetTaskMoveNetworkSignalFloatLerpRate);
  9435. SCR_REGISTER_SECURE(SET_TASK_MOVE_NETWORK_SIGNAL_BOOL,0xdde2a56a49baf5b0, CommandSetTaskMoveNetworkSignalBool);
  9436. SCR_REGISTER_UNUSED(SET_TASK_MOVE_NETWORK_SIGNAL_LOCAL_BOOL,0xbe46dff5c216a2b0, CommandSetTaskMoveNetworkSignalLocalBool);
  9437. SCR_REGISTER_SECURE(GET_TASK_MOVE_NETWORK_SIGNAL_FLOAT,0x103bce39f925945e, CommandGetTaskMoveNetworkSignalFloat);
  9438. SCR_REGISTER_SECURE(GET_TASK_MOVE_NETWORK_SIGNAL_BOOL,0x501632a36a6512aa, CommandGetTaskMoveNetworkSignalBool);
  9439. SCR_REGISTER_SECURE(GET_TASK_MOVE_NETWORK_EVENT,0xce3f029a4833b5e1, CommandGetTaskMoveNetworkEvent);
  9440. SCR_REGISTER_SECURE(SET_TASK_MOVE_NETWORK_ENABLE_COLLISION_ON_NETWORK_CLONE_WHEN_FIXED,0x4a5f1661be58e97e, CommandSetTaskMoveNetworkEnableCollisionOnNetworkCloneWhenFixed);
  9441. // End MoVE interface
  9442.  
  9443. SCR_REGISTER_SECURE(IS_MOVE_BLEND_RATIO_STILL,0x98daeb6e7093895e, CommandIsMoveBlendRatioStill);
  9444. SCR_REGISTER_SECURE(IS_MOVE_BLEND_RATIO_WALKING,0x6b46f0285c770b5b, CommandIsMoveBlendRatioWalking);
  9445. SCR_REGISTER_SECURE(IS_MOVE_BLEND_RATIO_RUNNING,0x833a52f892a42353, CommandIsMoveBlendRatioRunning);
  9446. SCR_REGISTER_SECURE(IS_MOVE_BLEND_RATIO_SPRINTING,0x3861da7f20602340, CommandIsMoveBlendRatioSprinting);
  9447. SCR_REGISTER_SECURE(IS_PED_STILL,0x443c6afb940b3c83, CommandIsPedStill);
  9448. SCR_REGISTER_SECURE(IS_PED_WALKING,0x834c649d79d5128d, CommandIsPedWalking);
  9449. SCR_REGISTER_SECURE(IS_PED_RUNNING,0x81bbcaf9fe3b469d, CommandPedIsRunning);
  9450. SCR_REGISTER_SECURE(IS_PED_SPRINTING,0xe02d8bdf4b18d48d, CommandPedIsSprinting);
  9451. SCR_REGISTER_SECURE(IS_PED_STRAFING,0xfe3baaf47e48d31f, CommandPedIsStrafing);
  9452.  
  9453. // synchronized scenes
  9454. SCR_REGISTER_SECURE(TASK_SYNCHRONIZED_SCENE,0x950b26f4c891073f, CommandTaskSynchronizedScene);
  9455.  
  9456. SCR_REGISTER_SECURE(TASK_AGITATED_ACTION_CONFRONT_RESPONSE,0x3e7d91f4eece76b8, CommandGivePedAgitatedTaskConfront);
  9457.  
  9458. //////////////////////////////////////////////////////////////////////////
  9459. // Ped SweepTask commands
  9460. //////////////////////////////////////////////////////////////////////////
  9461. SCR_REGISTER_SECURE(TASK_SWEEP_AIM_ENTITY,0x26d2934cf2d5b32c, CommandTaskSweepAimEntity);
  9462. SCR_REGISTER_SECURE(UPDATE_TASK_SWEEP_AIM_ENTITY,0x878b7bb84cc31442, CommandUpdateTaskSweepAimEntity);
  9463. SCR_REGISTER_SECURE(TASK_SWEEP_AIM_POSITION,0x07c9c36e1a3234e9, CommandTaskSweepAimPosition);
  9464. SCR_REGISTER_SECURE(UPDATE_TASK_SWEEP_AIM_POSITION,0xc82e4267a5f18820, CommandUpdateTaskSweepAimPosition);
  9465.  
  9466. // @DEPRECATED: Old arrest commands
  9467. SCR_REGISTER_SECURE(TASK_ARREST_PED,0x463d4f9c4826a59b, CommandTaskArrestPed);
  9468. SCR_REGISTER_SECURE(IS_PED_RUNNING_ARREST_TASK,0x64152dd440e37f50, CommandIsPedRunningArrestTask);
  9469. SCR_REGISTER_UNUSED(IS_ARREST_TYPE_VALID,0x1c805a9f43140ae6, CommandIsArrestTypeValid);
  9470.  
  9471. // Arrest/uncuff commands
  9472. SCR_REGISTER_SECURE(IS_PED_BEING_ARRESTED,0x1c7f03843c4541ad, CommandIsPedBeingArrested);
  9473. SCR_REGISTER_UNUSED(IS_PED_BEING_UNCUFFED,0x522ef0aaa44cd03a, CommandIsPedBeingUncuffed);
  9474. SCR_REGISTER_UNUSED(IS_PED_ARRESTING,0x2a706f5c5d386b6e, CommandIsPedArresting);
  9475. SCR_REGISTER_UNUSED(IS_PED_UNCUFFING,0x1590a589bdbbf96c, CommandIsPedUncuffing);
  9476. SCR_REGISTER_UNUSED(GET_PED_ARRESTER,0x1d081ef24f8c6203, CommandGetPedArrester);
  9477. SCR_REGISTER_UNUSED(GET_PED_UNCUFFER,0x79a3054bf21c9039, CommandGetPedUncuffer);
  9478. SCR_REGISTER_UNUSED(GET_PED_ARRESTING_TARGET,0x9def9d10068f6f46, CommandGetPedArrestingTarget);
  9479. SCR_REGISTER_UNUSED(GET_PED_UNCUFFING_TARGET,0x08c5c742c9b17f90, CommandGetPedUncuffingTarget);
  9480.  
  9481. SCR_REGISTER_UNUSED(CUFF_PED,0x7b9873a2f170f8b0, CommandCuffPed);
  9482. SCR_REGISTER_SECURE(UNCUFF_PED,0x9a89b72b9931965c, CommandUncuffPed);
  9483. SCR_REGISTER_SECURE(IS_PED_CUFFED,0xea266e5f12328e62, CommandIsPedCuffed);
  9484.  
  9485. SCR_REGISTER_UNUSED(IS_PED_TAKING_CUSTODY,0xb178acc0bca5b82c, CommandIsPedTakingCustody);
  9486. SCR_REGISTER_UNUSED(GET_PED_TAKING_CUSTODY_TARGET,0x2f6461d574428769, CommandGetPedTakingCustodyTarget);
  9487. SCR_REGISTER_UNUSED(IS_PED_BEING_TAKEN_INTO_CUSTODY,0xcaff880c04b723c0, CommandIsPedBeingTakenIntoCustody);
  9488.  
  9489. SCR_REGISTER_UNUSED(TASK_TAKE_CUSTODY,0x53baad9817f5de01, CommandTaskTakeCustody);
  9490. SCR_REGISTER_UNUSED(GET_PED_CUSTODIAN,0x670b52c53b47a811, CommandGetPedCustodian);
  9491. SCR_REGISTER_UNUSED(REMOVE_PED_FROM_CUSTODY,0x512b985df2d0e125, CommandRemovePedFromCustody);
  9492.  
  9493. SCR_REGISTER_UNUSED(GET_PED_ARREST_PHASE,0x44559d9a1dd62526, CommandGetPedArrestPhase);
  9494.  
  9495. SCR_REGISTER_UNUSED(GET_PED_POTENTIAL_ARREST_TARGET,0x1214edf270c95469, CommandGetPedPotentialArrestTarget);
  9496. SCR_REGISTER_UNUSED(GET_PED_POTENTIAL_UNCUFF_TARGET,0x346aeaa1e63abaeb, CommandGetPedPotentialUncuffTarget);
  9497.  
  9498. SCR_REGISTER_UNUSED(SET_PED_CUSTODY_FOLLOW_DISTANCE,0x006f134efa946bd1, CommandSetPedCustodyOverrideFollowDistance);
  9499. SCR_REGISTER_UNUSED(WARP_INTO_LEADERS_VEHICLE,0x196931342f1803a2, CommandWarpIntoLeadersVehicle);
  9500. }
  9501. } // end of namespace task_commands
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement