human.c 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648
  1. /** @file
  2. this file is interface to Human
  3. */
  4. enum HumanInputControllerOverrideType
  5. {
  6. DISABLED,
  7. ENABLED, //! Permenantly active until DISABLED is passed
  8. ONE_FRAME, //! Will apply value and then DISABLED on subsequent CommandHandler call
  9. };
  10. // *************************************************************************************
  11. // ! HumanInputController - what we know about the input - human.GetInputController()
  12. // *************************************************************************************
  13. class HumanInputController
  14. {
  15. //--------------------------------------------------------------
  16. //! disables input controller
  17. proto native void SetDisabled(bool pState);
  18. //! returns pSpeed 0,1..2..3 (idle, walk, run, sprint), local normalized direction vector
  19. proto void GetMovement(out float pSpeed, out vector pLocalDirection);
  20. //! returns main heading angle (in radians) -PI .. PI (this is world Y angle player is actualy pointing the camera)
  21. proto native float GetHeadingAngle();
  22. //! returns per tick aim change (in radians)
  23. proto native vector GetAimChange();
  24. //! returns aim change (in radians)
  25. proto native vector GetAimDelta(float dt);
  26. //! returns absolute tracking change (in radians)
  27. proto native vector GetTracking();
  28. //! 1st/3rd person camera view
  29. proto native bool CameraViewChanged();
  30. //! returns true if freelook is active
  31. proto native bool CameraIsFreeLook();
  32. //! reset freelook toggle
  33. proto native void ResetFreeLookToggle();
  34. //! returns if camera is tracking (using IR device)
  35. proto native bool CameraIsTracking();
  36. //! returns true if camera is on right/ false-left shoulder
  37. proto native bool Camera3rdIsRightShoulder();
  38. //--------------------------------------------------------------
  39. //! stance change button was pressed
  40. proto native bool IsStanceChange();
  41. //! jump/climb action was pressed
  42. proto native bool IsJumpClimb();
  43. //--------------------------------------------------------------
  44. //! returns pressed SHIFT (melee evade)
  45. proto native bool IsMeleeEvade();
  46. //! returns SHIFT down (melee fast/heavy) attack modifier
  47. proto native bool IsMeleeFastAttackModifier();
  48. //! returns 0,1,2 = none,left,right
  49. proto native int IsMeleeLREvade();
  50. //! return weapon melee attack modifier
  51. proto native bool IsMeleeWeaponAttack();
  52. //--------------------------------------------------------------
  53. //! returns true if weapon click perfomed recently (before raise specifically)
  54. proto native bool WeaponWasRaiseClick();
  55. //! returns true if weapon is raised
  56. proto native bool IsWeaponRaised();
  57. //! returns true if weapon ADS mode
  58. proto native bool WeaponADS();
  59. //! resets ADS mode to default
  60. proto native void ResetADS();
  61. //! returns true if change of throwing mode has been requested
  62. proto native bool IsThrowingModeChange();
  63. //! resets Throwing mode
  64. proto native void ResetThrowingMode();
  65. //! returns true if Walk set to toggle
  66. proto native bool IsWalkToggled();
  67. //--------------------------------------------------------------
  68. /**
  69. * \brief Deprecated; returns true if Use/Attack button is pressed (== true for multiple ticks). Synced.
  70. * \note Returns state of both 'UADefaultAction' and 'UAFire' input actions. Those are now separated in the methods below.
  71. */
  72. proto native bool IsUseButton();
  73. /**
  74. * \brief Deprecated; returns true if Use/Attack button has just been pressed (== true for 1 tick only). Synced.
  75. * \note Returns state of both 'UADefaultAction' and 'UAFire' input actions. Those are now separated in the methods below.
  76. */
  77. proto native bool IsUseButtonDown();
  78. //! returns true if 'UADefaultAction' button is pressed (== true for multiple ticks). Synced.
  79. proto native bool IsUseItemButton();
  80. //! returns true if 'UADefaultAction' button has just been pressed (== true for 1 tick only). Synced.
  81. proto native bool IsUseItemButtonDown();
  82. //! returns true if 'UAFire' button is pressed (== true for multiple ticks). Synced.
  83. proto native bool IsAttackButton();
  84. //! returns true if 'UAFire' button has just been pressed (== true for 1 tick only). Synced.
  85. proto native bool IsAttackButtonDown();
  86. //! single 'UADefaultAction' (== true for 1 tick only) + not raised
  87. proto native bool IsSingleUse();
  88. //! Long click 'UADefaultAction' (== true for multiple ticks) + not raised
  89. proto native bool IsContinuousUse();
  90. //! is start of cont. 'UADefaultAction' (== true for 1 tick only) + not raised
  91. proto native bool IsContinuousUseStart();
  92. //! is end of cont. 'UADefaultAction' (== true for 1 tick only) + not raised
  93. proto native bool IsContinuousUseEnd();
  94. //! is immediate action triggered - 1 tick only
  95. //! Middle Button + not raised !
  96. proto native bool IsImmediateAction(); //TODO: revise, may be obsolete
  97. //--------------------------------------------------------------
  98. //! weapon handling
  99. //! R - reloading / bolting (== true for 1 tick only)
  100. proto native bool IsReloadOrMechanismSingleUse();
  101. //! R - reloading / bolting - long press (== true for multiple ticks)
  102. proto native bool IsReloadOrMechanismContinuousUse();
  103. //! R - reloading / bolting (== true for 1 tick only)
  104. proto native bool IsReloadOrMechanismContinuousUseStart();
  105. //! R - reloading / bolting - long press (== true for multiple ticks)
  106. proto native bool IsReloadOrMechanismContinuousUseEnd();
  107. //! zooming
  108. proto native bool IsZoom();
  109. //! zooming toggle
  110. proto native bool IsZoomToggle();
  111. //! reset zoom toggle
  112. proto native void ResetZoomToggle();
  113. //! sight has been changed (in/out ironsights)
  114. proto native bool IsSightChange();
  115. //!
  116. proto native bool IsZoomIn();
  117. //!
  118. proto native bool IsZoomOut();
  119. //! fire mode has changed
  120. proto native bool IsFireModeChange();
  121. //! zeroing up
  122. proto native bool IsZeroingUp();
  123. //! zeroing down
  124. proto native bool IsZeroingDown();
  125. //! holding breath
  126. proto native bool IsHoldBreath();
  127. //! reset hold breath toggle
  128. proto native void ResetHoldBreath();
  129. //--------------------------------------------------------------
  130. //! returns 1..12 if F1 - F12 us pressed, 0 otherwise
  131. //! Deprecated; slots no longer used, bindable input actions instead
  132. proto native int IsGestureSlot();
  133. //! returns true, if player controls other entity (vehicle for example)
  134. proto native bool IsOtherController();
  135. //--------------------------------------------------------------
  136. //! returns 1..10 if some quickbar slot is used, 0 otherwise
  137. proto native int IsQuickBarSlot();
  138. //! single use (== true for 1 tick only)
  139. //! quickbar + not raised !
  140. proto native bool IsQuickBarSingleUse();
  141. //! Long click use (== true for multiple ticks)
  142. //! long quickbar + not raised !
  143. proto native bool IsQuickBarContinuousUse();
  144. //! is start of cont use (== true for 1 tick only)
  145. //! long quickbar + not raised !
  146. proto native bool IsQuickBarContinuousUseStart();
  147. //! is end of cont use (== true for 1 tick only)
  148. //! long quickbar + not raised !
  149. proto native bool IsQuickBarContinuousUseEnd();
  150. //--------------------------------------------------------------
  151. // LIMITS
  152. //! this disables sprint
  153. proto native void LimitsDisableSprint(bool pDisable);
  154. //! is sprint disabled
  155. proto native bool LimitsIsSprintDisabled();
  156. //--------------------------------------------------------------
  157. // overrides
  158. //!
  159. proto native void OverrideMovementSpeed(HumanInputControllerOverrideType overrideType, float value);
  160. //!
  161. proto native void OverrideMovementAngle(HumanInputControllerOverrideType overrideType, float value);
  162. //!
  163. proto native void OverrideAimChangeX(HumanInputControllerOverrideType overrideType, float value);
  164. //!
  165. proto native void OverrideAimChangeY(HumanInputControllerOverrideType overrideType, float value);
  166. //!
  167. proto native void OverrideMeleeEvade(HumanInputControllerOverrideType overrideType, bool value);
  168. //!
  169. proto native void OverrideRaise(HumanInputControllerOverrideType overrideType, bool value);
  170. //!
  171. proto native void Override3rdIsRightShoulder(HumanInputControllerOverrideType overrideType, bool value);
  172. //!
  173. proto native void OverrideFreeLook(HumanInputControllerOverrideType overrideType, bool value);
  174. //--------------------------------------------------------------
  175. //! never created by script
  176. private void HumanInputController()
  177. {
  178. }
  179. //! never created by script
  180. private void ~HumanInputController()
  181. {
  182. }
  183. }
  184. // *************************************************************************************
  185. // ! HumanInputController - what we know about the input - human.GetInputController()
  186. // *************************************************************************************
  187. typedef int TAnimGraphCommand;
  188. typedef int TAnimGraphVariable;
  189. typedef int TAnimGraphTag;
  190. typedef int TAnimGraphEvent;
  191. //!
  192. class HumanAnimInterface
  193. {
  194. private void HumanAnimInterface();
  195. private void ~HumanAnimInterface();
  196. //-----------------------------------------------------
  197. // Binds, returns -1 when error, otherwise if ok
  198. //! returns command index -
  199. proto native TAnimGraphCommand BindCommand(string pCommandName);
  200. //!
  201. proto native TAnimGraphVariable BindVariableFloat(string pVariable);
  202. proto native TAnimGraphVariable BindVariableInt(string pVariable);
  203. proto native TAnimGraphVariable BindVariableBool(string pVariable);
  204. //!
  205. proto native TAnimGraphTag BindTag(string pTagName);
  206. //!
  207. proto native TAnimGraphEvent BindEvent(string pEventName);
  208. }
  209. // *************************************************************************************
  210. // ! HumanCommandActionCallback - called as action callback
  211. // *************************************************************************************
  212. class HumanCommandActionCallback
  213. {
  214. private void HumanCommandActionCallback();
  215. private void ~HumanCommandActionCallback();
  216. //! get the human this cb belongs to
  217. proto native Human GetHuman();
  218. //! cancels action
  219. proto native void Cancel();
  220. //! calls internal command
  221. //! pInternalCommandId is one of CMD_ACTIONINT_ ...
  222. proto native void InternalCommand(int pInternalCommandId);
  223. //! enables character aligning to desired position and direction in world space
  224. proto native void SetAligning(vector pPositionWS, vector pDirectionWS);
  225. //! disables character aligning
  226. proto native void ResetAligning();
  227. //! enables calling cancel condition
  228. //! default is disabled
  229. //! when enabled - there must be a function "bool CancelCondition()" implemented
  230. proto native void EnableCancelCondition(bool pEnable);
  231. //! system implemented cancel condition (now raise or sprint cancels action)
  232. proto native bool DefaultCancelCondition();
  233. //! registers animation event, when event registered and received - it sends OnAnimationEvent with registered id
  234. proto native void RegisterAnimationEvent(string pAnimationEventStr, int pId);
  235. //! enables state change callback OnStateChange
  236. proto native void EnableStateChangeCallback();
  237. //! example of implement of CancelCondition
  238. //! returns true it it should CANCEL the action
  239. // bool CancelCondition() { return false; }
  240. //! undef state - not running anymore
  241. static const int STATE_NONE = 0;
  242. //! looped state
  243. static const int STATE_LOOP_IN = 1;
  244. static const int STATE_LOOP_LOOP = 2;
  245. static const int STATE_LOOP_END = 3;
  246. static const int STATE_LOOP_END2 = 4;
  247. static const int STATE_LOOP_LOOP2 = 5;
  248. static const int STATE_LOOP_ACTION = 6;
  249. //! one time state
  250. static const int STATE_NORMAL = 7;
  251. //! returns one of STATE_...
  252. proto native int GetState();
  253. //----------------------------------
  254. // debug helper
  255. //! returns debug string of current state
  256. static string GetStateString(int pState)
  257. {
  258. switch (pState)
  259. {
  260. case STATE_NONE: return "NONE";
  261. case STATE_LOOP_IN: return "LOOP_IN";
  262. case STATE_LOOP_LOOP: return "LOOP_LOOP";
  263. case STATE_LOOP_END: return "LOOP_END";
  264. case STATE_LOOP_END2: return "LOOP_END2";
  265. case STATE_LOOP_LOOP2: return "LOOP_LOOP2";
  266. case STATE_LOOP_ACTION: return "LOOP_ACTION";
  267. //! one time state
  268. case STATE_NORMAL: return "ONE TIME";
  269. }
  270. return "Undef";
  271. }
  272. //! returns debug string of current state
  273. string GetStateString()
  274. {
  275. return GetStateString(GetState());
  276. }
  277. //----------------------------------
  278. // callbacks
  279. //! calls animation event -> must be registered with RegisterAnimationEvent
  280. void OnAnimationEvent(int pEventID) {};
  281. //! called ALWAYS! when action is finished (normal finish or cancel -> pCanceled)
  282. void OnFinish(bool pCanceled) {};
  283. //! called when enabled by EnableStateChangeCallback and state changes, call GetState() to get actual state
  284. void OnStateChange(int pOldState, int pCurrentState) {};
  285. // helps identify type of callback
  286. bool IsUserActionCallback()
  287. {
  288. return false;
  289. }
  290. bool IsGestureCallback()
  291. {
  292. return false;
  293. }
  294. bool IsSymptomCallback()
  295. {
  296. return false;
  297. }
  298. }
  299. // *************************************************************************************
  300. // ! HumanCommandMove
  301. // *************************************************************************************
  302. class HumanCommandMove
  303. {
  304. private void HumanCommandMove() {}
  305. private void ~HumanCommandMove() {}
  306. //! marks command to continue to combo
  307. //! -180 -90 0 90 180 angles of current movement
  308. proto native float GetCurrentMovementAngle();
  309. //! direction held on keyboard/controller
  310. //! -180 -90 0 90 180 angles of input movement (no filtering, no postprocesses)
  311. //! return false in idle states
  312. proto bool GetCurrentInputAngle(out float pAngle);
  313. //! 0,1,2..3 idle, walk, run, sprint
  314. proto native float GetCurrentMovementSpeed();
  315. //! returns true if character is changing stance
  316. proto native bool IsChangingStance();
  317. //! return true if prone is on back
  318. proto native bool IsOnBack();
  319. //! return true if character barrel rolling
  320. proto native bool IsInRoll();
  321. //! return true if character transitions out of uncon
  322. proto native bool IsLeavingUncon();
  323. //! return true if prone on back is chaning to crounch/stand
  324. proto native bool IsStandingFromBack();
  325. //! marks command to continue to combo
  326. proto native void StartMeleeEvade();
  327. //! marks command to continue to combo, pDirAngle specifies angle
  328. proto native void StartMeleeEvadeA(float pDirAngle);
  329. //! this is true when in melee evade
  330. proto native bool IsMeleeEvade();
  331. //! this enables/disables block
  332. proto native void SetMeleeBlock(bool pBlock);
  333. //! pStanceIds is one of STANCEIDX_ERECT,STANCEIDX_CROUCH,STANCEIDX_PRONE,STANCEIDX_RAISEDERECT,STANCEIDX_RAISEDCROUCH,STANCEIDX_RAISEDPRONE,
  334. //! or -1 when release the stance lock
  335. proto native void ForceStance(int pStanceIdx);
  336. //! pStanceIds is one of STANCEIDX_ERECT,STANCEIDX_CROUCH
  337. //! this forces to stand up to required stance
  338. proto native void ForceStanceUp(int pStanceIdx);
  339. //! sets the multiplier for SHumanCommandMoveSettings::m_fRunSpringTimeout
  340. proto native void SetRunSprintFilterModifier(float value);
  341. //! sets the multiplier for SHumanCommandMoveSettings::m_fDirFilterTimeout
  342. proto native void SetDirectionFilterModifier(float value);
  343. //! sets the multiplier for SHumanCommandMoveSettings::m_fDirFilterSprintTimeout
  344. proto native void SetDirectionSprintFilterModifier(float value);
  345. //! sets the multiplier for HumanItemBehaviorCfg::m_fMoveHeadingFilterSpan
  346. proto native void SetTurnSpanModifier(float value);
  347. //! sets the multiplier for HumanItemBehaviorCfg::m_fMoveHeadingSprintFilterSpan
  348. proto native void SetTurnSpanSprintModifier(float value);
  349. //! sets water level (depth)
  350. proto native void SetCurrentWaterLevel(float value);
  351. }
  352. // *************************************************************************************
  353. // ! HumanCommandMelee - actual command melee running on
  354. // *************************************************************************************
  355. class HumanCommandMelee
  356. {
  357. private void HumanCommandMelee() {}
  358. private void ~HumanCommandMelee() {}
  359. //! marks command to continue to combo
  360. proto native void ContinueCombo();
  361. //! returns true if hit is in range, where person can continue to combo
  362. proto native bool IsInComboRange();
  363. //! is true only once after hit event
  364. proto native bool WasHit();
  365. //! cancels command melee and goes to HumanCommandMove
  366. proto native void Cancel();
  367. //! is on back in prone stance?
  368. proto native bool IsOnBack();
  369. }
  370. // *************************************************************************************
  371. // ! HumanCommandMelee2 - actual command melee running on - Heavy/Light version
  372. // *************************************************************************************
  373. class HumanCommandMelee2
  374. {
  375. private void HumanCommandMelee2() {}
  376. private void ~HumanCommandMelee2() {}
  377. static const int HIT_TYPE_LIGHT = 0;
  378. static const int HIT_TYPE_HEAVY = 1;
  379. static const int HIT_TYPE_FINISHER = 2; //liver stab
  380. static const int HIT_TYPE_FINISHER_NECK = 3;
  381. //! marks command to continue to combo
  382. proto native void ContinueCombo(bool pHeavyHit, float pComboValue, EntityAI target = null, vector hitPos = vector.Zero);
  383. //! returns true if hit is in range, where person can continue to combo
  384. proto native bool IsInComboRange();
  385. //! is true only once after hit event
  386. proto native bool WasHit();
  387. //! cancels command melee and goes to HumanCommandMove
  388. proto native void Cancel();
  389. //! is on back in prone stance?
  390. proto native bool IsOnBack();
  391. proto native int GetComboCount();
  392. proto native int GetCurrentHitType();
  393. proto native bool IsFinisher();
  394. }
  395. // *************************************************************************************
  396. // ! HumanCommandFall - actually falling
  397. // *************************************************************************************
  398. class HumanCommandFall
  399. {
  400. private void HumanCommandFall() {}
  401. private void ~HumanCommandFall() {}
  402. static const int LANDTYPE_NONE = 0;
  403. static const int LANDTYPE_LIGHT = 1;
  404. static const int LANDTYPE_MEDIUM = 2;
  405. static const int LANDTYPE_HEAVY = 3;
  406. //! this is true when fall has physically landed - need to call Land after this is true
  407. proto native bool PhysicsLanded();
  408. //! end fall with land
  409. proto native void Land(int pLandType);
  410. //! returns true if fall is in landing state
  411. proto native bool IsLanding();
  412. }
  413. // *************************************************************************************
  414. // ! HumanCommandDeathCallback - called as action callback
  415. // *************************************************************************************
  416. class HumanCommandDeathCallback
  417. {
  418. //----------------------------------
  419. // callbacks
  420. void OnSimulationEnd() {};
  421. //! 'OnSimulationEnd' is called before this
  422. bool ShouldSimulationBeDisabled() { return true; };
  423. }
  424. // *************************************************************************************
  425. // ! HumanCommandDeath - actually dying
  426. // *************************************************************************************
  427. class HumanCommandDeath
  428. {
  429. private void HumanCommandDeath() {}
  430. private void ~HumanCommandDeath() {}
  431. }
  432. // *************************************************************************************
  433. // ! HumanCommandUnconscious - actually not dying
  434. // *************************************************************************************
  435. class HumanCommandUnconscious
  436. {
  437. private void HumanCommandUnconscious() {}
  438. private void ~HumanCommandUnconscious() {}
  439. proto native void WakeUp(int targetStance = -1);
  440. proto native bool IsWakingUp();
  441. proto native bool IsOnLand();
  442. proto native bool IsInWater();
  443. }
  444. // *************************************************************************************
  445. // ! HumanCommandDamage - additional damage
  446. // *************************************************************************************
  447. class HumanCommandDamage
  448. {
  449. private void HumanCommandDamage() {}
  450. private void ~HumanCommandDamage() {}
  451. }
  452. // *************************************************************************************
  453. // ! HumanCommandLadder ladder
  454. // *************************************************************************************
  455. class HumanCommandLadder
  456. {
  457. private void HumanCommandLadder() {}
  458. private void ~HumanCommandLadder() {}
  459. //! returns true if on exiting point
  460. proto native bool CanExit();
  461. //!
  462. proto native void Exit();
  463. //! debug draws any ladder
  464. proto native static bool DebugDrawLadder(Building pBuilding, int pLadderIndex);
  465. //!
  466. proto native static int DebugGetLadderIndex(string pComponentName);
  467. //! returns the safe logout position in worldspace
  468. //! the position is closest to the last possible exit point the player passed
  469. proto native vector GetLogoutPosition();
  470. }
  471. // *************************************************************************************
  472. // ! HumanCommandLadder ladder
  473. // *************************************************************************************
  474. class HumanCommandSwim
  475. {
  476. private void HumanCommandSwim() {}
  477. private void ~HumanCommandSwim() {}
  478. //!
  479. proto native void StopSwimming();
  480. //! returns water level from entity position
  481. //! returns in format (totalWaterDepth, characterDepht, 0)
  482. proto native static vector WaterLevelCheck(Human pHuman, vector pPosition);
  483. }
  484. // *************************************************************************************
  485. // ! HumanCommandVehicle vehicle
  486. // *************************************************************************************
  487. class HumanCommandVehicle
  488. {
  489. private void HumanCommandVehicle() {}
  490. private void ~HumanCommandVehicle() {}
  491. proto native Transport GetTransport();
  492. proto native int GetVehicleClass();
  493. proto native int GetVehicleSeat();
  494. proto native void SetVehicleType(int pVehicleType);
  495. proto native int GetVehicleType();
  496. proto native void GetOutVehicle();
  497. proto native void KnockedOutVehicle();
  498. proto native bool ShouldBeKnockedOut();
  499. proto native void JumpOutVehicle();
  500. proto native void SwitchSeat(int pTransportPositionIndex, int pVehicleSeat);
  501. proto native bool IsGettingIn();
  502. proto native bool IsGettingOut();
  503. proto native bool IsSwitchSeat();
  504. proto native bool WasGearChange();
  505. proto native void SetClutchState(bool pState);
  506. proto native void KeepInVehicleSpaceAfterLeave(bool pState);
  507. proto native void ProcessLeaveEvents();
  508. bool IsObjectIgnoredOnGettingOut(IEntity entity)
  509. {
  510. Object object;
  511. if (!Class.CastTo(object, entity))
  512. {
  513. return true;
  514. }
  515. Transport transport = GetTransport();
  516. if (!transport)
  517. {
  518. return true;
  519. }
  520. if (object == transport || object.GetParent() == transport)
  521. {
  522. return true;
  523. }
  524. return transport.IsIgnoredObject(object);
  525. }
  526. }
  527. // *************************************************************************************
  528. // ! HumanCommandClimb
  529. // *************************************************************************************
  530. //! result from static test
  531. class SHumanCommandClimbResult
  532. {
  533. bool m_bIsClimb;
  534. bool m_bIsClimbOver;
  535. bool m_bFinishWithFall;
  536. bool m_bHasParent;
  537. float m_fClimbHeight;
  538. vector m_ClimbGrabPoint; //! grab point for climb && climb over (in local space of it's parent)
  539. vector m_ClimbGrabPointNormal; //! normal to grabpoint position (used for character orientation)
  540. vector m_ClimbStandPoint; //! where climb ends (in local space of it's parent)
  541. vector m_ClimbOverStandPoint; //! where climb over ends (in local space of it's parent)
  542. IEntity m_GrabPointParent; //! parent of grabpoint
  543. IEntity m_ClimbStandPointParent;
  544. IEntity m_ClimbOverStandPointParent;
  545. };
  546. //! state of climb command
  547. enum ClimbStates
  548. {
  549. STATE_MOVE,
  550. STATE_TAKEOFF,
  551. STATE_ONTOP,
  552. STATE_FALLING,
  553. STATE_FINISH
  554. };
  555. //! command itself
  556. class HumanCommandClimb
  557. {
  558. private void HumanCommandClimb() {}
  559. private void ~HumanCommandClimb() {}
  560. //! returns the state of climb (enum value of ClimbStates);
  561. proto native int GetState();
  562. //! returns world space position of climbing grab point
  563. proto native vector GetGrabPointWS();
  564. //! returns world space position of landspot after climbing over
  565. proto native vector GetClimbOverStandPointWS();
  566. //! debug draws climb heauristics
  567. //! pDebugDrawLevel viz DebugDrawClimb
  568. //! use for performing arbitrary climb tests
  569. proto native static bool DoClimbTest(Human pHuman, SHumanCommandClimbResult pResult, int pDebugDrawLevel);
  570. //! debug draws climb heauristics
  571. //! pDebugDrawLevel viz DebugDrawClimb
  572. //! use this test before performing the climb command instead of DoClimbTest
  573. proto native static bool DoPerformClimbTest(Human pHuman, SHumanCommandClimbResult pResult, int pDebugDrawLevel);
  574. //! debug draws climb heauristics
  575. //! int pLevel = 1 result, 2 - capsules (3 - all)
  576. proto native static bool DebugDrawClimb(Human pHuman, int pLevel);
  577. }
  578. // *************************************************************************************
  579. // ! HumanCommandFullBodyDamage - full body damages
  580. // *************************************************************************************
  581. class HumanCommandFullBodyDamage
  582. {
  583. private void HumanCommandFullBodyDamage() {}
  584. private void ~HumanCommandFullBodyDamage() {}
  585. }
  586. //! actions
  587. enum WeaponActions
  588. {
  589. INTERRUPT = 15,
  590. NONE = -1,
  591. RELOAD = 0,
  592. MECHANISM = 1,
  593. CHAMBERING = 2,
  594. CHAMBERING_LOADER = 3,
  595. UNJAMMING = 4,
  596. FIRE = 5,
  597. HIDE = 6,
  598. SHOW = 7,
  599. RELOAD_CLIP = 8,
  600. };
  601. //! action types
  602. /// reload action types
  603. enum WeaponActionReloadTypes
  604. {
  605. //! reload action types - rifles
  606. RELOADRIFLE_MAGAZINE_BULLET = 0, // CMD_Reload_Magazine
  607. RELOADRIFLE_NOMAGAZINE_BULLET = 1,
  608. RELOADRIFLE_MAGAZINE_NOBULLET = 2,
  609. RELOADRIFLE_NOMAGAZINE_NOBULLET = 3,
  610. RELOADRIFLE_MAGAZINE_NOBULLET_OPEN = 4,
  611. RELOADRIFLE_NOMAGAZINE_NOBULLET_OPEN = 5,
  612. // reload action types - pistols
  613. RELOADPISTOL_NOMAGAZINE_NOBULLET_CLOSED_UNCOCKED = 8, // CMD_Reload_Magazine
  614. RELOADPISTOL_MAGAZINE_NOBULLET_CLOSED_UNCOCKED = 9,
  615. RELOADPISTOL_MAGAZINE_BULLET_CLOSED = 10,
  616. RELOADPISTOL_NOMAGAZINE_BULLET_CLOSED = 11,
  617. RELOADPISTOL_MAGAZINE_NOBULLET_CLOSED_COCKED = 12,
  618. RELOADPISTOL_NOMAGAZINE_NOBULLET_CLOSED_COCKED = 13,
  619. RELOADPISTOL_NOMAGAZINE_NOBULLET_OPENED = 14,
  620. RELOADPISTOL_MAGAZINE_NOBULLET_OPENED = 15,
  621. RELOAD_MAGAZINE_DETACH = 16,
  622. RELOADRIFLE_MAGAZINE_DETACH = 17, // CMD_Reload_Magazine
  623. RELOADSRIFLE_MAGAZINE_BULLET = 20, // CMD_Reload_Magazine
  624. RELOADSRIFLE_NOMAGAZINE_BULLET = 21,
  625. RELOADSRIFLE_MAGAZINE_NOBULLET = 22,
  626. RELOADSRIFLE_NOMAGAZINE_NOBULLET = 23,
  627. };
  628. enum WeaponActionReloadClipTypes
  629. {
  630. RELOADRIFLE_CLIP_NOBULLET = 0,
  631. RELOADRIFLE_CLIP_BULLET = 1,
  632. }
  633. enum WeaponActionMechanismTypes
  634. {
  635. //! mechanism action types
  636. MECHANISM_OPENED = 0, // CMD_Reload_BoltAction
  637. MECHANISM_CLOSED = 1,
  638. MECHANISM_SPECIAL = 2, // crossbow, magnum ... special mechanism action apropriate for custom weapons
  639. MECHANISM_CLOSED_UNCOCKED = 3,
  640. };
  641. enum WeaponActionChamberingTypes
  642. {
  643. CHAMBERING_END = -1,
  644. //! chambering action types
  645. CHAMBERING_ONEBULLET_OPENED = 0, // CMD_Reload_Chambering
  646. CHAMBERING_ONEBULLET_CLOSED = 1, //
  647. CHAMBERING_ONEBULLET_CLOSED_UNCOCKED = 2,
  648. CHAMBERING_ONEBULLET_UNIQUE_OPENED = 3, //
  649. CHAMBERING_ONEBULLET_UNIQUE_CLOSED = 4, //
  650. CHAMBERING_TWOBULLETS_START = 6, // plays one bullet, then second, then ends, when CHAMBERING_TWOBULLETS_END arise, it's canceled
  651. CHAMBERING_TWOBULLETS_END = 7, // - one bullet reload with closed mechanism
  652. CHAMBERING_STARTLOOPABLE_CLOSED = 10, // start loop chambering
  653. CHAMBERING_ENDLOOPABLE = 11, // end loop chambering
  654. CHAMBERING_STARTLOOPABLE_CLOSED_KEEP = 12, // start loop chambering and keep last bullet
  655. CHAMBERING_STARTLOOPABLE_OPENED = 13, //
  656. CHAMBERING_STARTLOOPABLE_SHOTGUN_UNCOCKED = 15,
  657. CHAMBERING_STARTLOOPABLE_SHOTGUN_COCKED = 16,
  658. CHAMBERING_DOUBLE_1 = 17,
  659. CHAMBERING_DOUBLE_2 = 18,
  660. CHAMBERING_DOUBLE_3 = 19,
  661. CHAMBERING_DOUBLE_4 = 20,
  662. CHAMBERING_CROSSBOW_OPENED = 21, // chambering crossbow
  663. CHAMBERING_CROSSBOW_CLOSED = 22, // chambering crossbow
  664. CHAMBERING_CROSSBOW_FULL = 23, // chambering crossbow
  665. };
  666. enum WeaponActionChamberingLoaderTypes
  667. {
  668. CHAMBERINGLOADER_OPENED = 0, // CMD_Reload_ChamberingFast - one bullet reload with open mechanism
  669. CHAMBERINGLOADER_CLOSED = 1, // - one bullet reload with closed mechanism
  670. };
  671. enum WeaponActionUnjammingTypes
  672. {
  673. //! unjam action types
  674. UNJAMMING_START = 1, // CMD_Weapon_Jam - 0
  675. UNJAMMING_END = 0, // 1
  676. UNJAMMING_INTERRUPT = -1,
  677. };
  678. enum WeaponActionFireTypes
  679. {
  680. FIRE_NORMAL = 0,
  681. FIRE_LAST = 1,
  682. FIRE_COCKED = 2,
  683. FIRE_UNCOCKED = 3,
  684. FIRE_DRY = 4,
  685. FIRE_JAM = 5
  686. };
  687. enum WeaponHideShowTypes
  688. {
  689. HIDESHOW_SLOT_2HDLEFTBACK = 0,
  690. HIDESHOW_SLOT_RFLLEFTBACK = 1,
  691. HIDESHOW_SLOT_1HDLEFTBACK = 2,
  692. HIDESHOW_SLOT_2HDRIGHTBACK = 3,
  693. HIDESHOW_SLOT_RFLRIGHTBACK = 4,
  694. HIDESHOW_SLOT_1HDRIGHTBACK = 5,
  695. HIDESHOW_SLOT_PISTOLBELT = 6,
  696. HIDESHOW_SLOT_PISTOLCHEST = 7,
  697. HIDESHOW_SLOT_KNIFEBACK = 8,
  698. HIDESHOW_SLOT_INVENTORY = 9,
  699. };
  700. string WeaponActionTypeToString (int A, int AT)
  701. {
  702. switch (A)
  703. {
  704. case WeaponActions.INTERRUPT: return "Weapon interrupt";
  705. case WeaponActions.NONE: return "---";
  706. case WeaponActions.RELOAD: return typename.EnumToString(WeaponActionReloadTypes, AT);
  707. case WeaponActions.MECHANISM: return typename.EnumToString(WeaponActionMechanismTypes, AT);
  708. case WeaponActions.CHAMBERING: return typename.EnumToString(WeaponActionChamberingTypes, AT);
  709. case WeaponActions.CHAMBERING_LOADER: return typename.EnumToString(WeaponActionChamberingLoaderTypes, AT);
  710. case WeaponActions.UNJAMMING: return typename.EnumToString(WeaponActionUnjammingTypes, AT);
  711. case WeaponActions.FIRE: return typename.EnumToString(WeaponActionFireTypes, AT);
  712. case WeaponActions.HIDE: return typename.EnumToString(WeaponHideShowTypes, AT);
  713. case WeaponActions.SHOW: return typename.EnumToString(WeaponHideShowTypes, AT);
  714. }
  715. return "---";
  716. }
  717. //! events
  718. enum WeaponEvents
  719. {
  720. ATTACHMENT_HIDE,
  721. ATTACHMENT_SHOW,
  722. BULLET_EJECT,
  723. BULLET_HIDE,
  724. BULLET_HIDE2,
  725. BULLET_IN_CHAMBER,
  726. BULLET_IN_MAGAZINE,
  727. BULLET_SHOW,
  728. BULLET_SHOW2,
  729. CANUNJAM_END,
  730. CANUNJAM_START,
  731. COCKED,
  732. MAGAZINE_ATTACHED,
  733. MAGAZINE_DETACHED,
  734. MAGAZINE_HIDE,
  735. MAGAZINE_SHOW,
  736. SLIDER_OPEN,
  737. UNJAMMED,
  738. HAMMER_UNCOCKED,
  739. HAMMER_COCKED
  740. CHANGE_HIDE,
  741. CHANGE_SHOW,
  742. CYLINDER_ROTATE,
  743. };
  744. // *************************************************************************************
  745. // ! HumanCommandWeapons - weapon handling
  746. // *************************************************************************************
  747. class HumanCommandWeapons
  748. {
  749. private void HumanCommandWeapons() {}
  750. private void ~HumanCommandWeapons() {}
  751. //!
  752. proto native bool IsActionFinished();
  753. //! returns -1 when no action is running or RELOAD,MECHANISM, ....
  754. proto native int GetRunningAction();
  755. //! returns -1 when no action is running or appropriate action type
  756. proto native int GetRunningActionType();
  757. //! sets start and end animation position - f.e. for reload clip action
  758. proto native void SetActionProgressParams(float pStart, float pEnd);
  759. //! start reload,mechanism,chambering,unjam ...
  760. proto native bool StartAction(WeaponActions pAction, int pActionType);
  761. //! register events
  762. proto native void RegisterEvent(string pName, int pId);
  763. //! return -1 when there is no event, otherwise it returns pId of event from animation
  764. proto native int IsEvent();
  765. //! returns true when clip visual change is needed for reload clip action
  766. proto native bool IsInWeaponReloadBulletSwitchState();
  767. //! sets head tilt to optics
  768. proto native void SetADS(bool pState);
  769. //! command for lifting weapon near obstacled (works only when weapon is raised)
  770. proto native void LiftWeapon(bool pState);
  771. //! returns aiming hands up/down (y) offset angle
  772. proto native float GetAimingHandsOffsetUD();
  773. //! returns aiming hands left/right (x) offset angle
  774. proto native float GetAimingHandsOffsetLR();
  775. //!
  776. void RegisterDefaultEvents()
  777. {
  778. RegisterEvent("Weapon_AttachmentHide", WeaponEvents.ATTACHMENT_HIDE);
  779. RegisterEvent("Weapon_AttachmentShow", WeaponEvents.ATTACHMENT_SHOW);
  780. RegisterEvent("Weapon_BulletEject", WeaponEvents.BULLET_EJECT);
  781. RegisterEvent("Weapon_BulletHide", WeaponEvents.BULLET_HIDE);
  782. RegisterEvent("Weapon_BulletHide2", WeaponEvents.BULLET_HIDE2);
  783. RegisterEvent("Weapon_BulletInChamber", WeaponEvents.BULLET_IN_CHAMBER);
  784. RegisterEvent("Weapon_BulletInMagazine", WeaponEvents.BULLET_IN_MAGAZINE);
  785. RegisterEvent("Weapon_BulletShow", WeaponEvents.BULLET_SHOW);
  786. RegisterEvent("Weapon_BulletShow2", WeaponEvents.BULLET_SHOW2);
  787. RegisterEvent("Weapon_CanUnjam_End", WeaponEvents.CANUNJAM_END);
  788. RegisterEvent("Weapon_CanUnjam_Start", WeaponEvents.CANUNJAM_START);
  789. RegisterEvent("Weapon_Cocked", WeaponEvents.COCKED);
  790. RegisterEvent("Weapon_MagazineAttached", WeaponEvents.MAGAZINE_ATTACHED);
  791. RegisterEvent("Weapon_MagazineDetached", WeaponEvents.MAGAZINE_DETACHED);
  792. RegisterEvent("Weapon_MagazineHide", WeaponEvents.MAGAZINE_HIDE);
  793. RegisterEvent("Weapon_MagazineShow", WeaponEvents.MAGAZINE_SHOW);
  794. RegisterEvent("Weapon_SliderOpen", WeaponEvents.SLIDER_OPEN);
  795. RegisterEvent("Weapon_Unjammed", WeaponEvents.UNJAMMED);
  796. RegisterEvent("Weapon_Hammer_Uncocked", WeaponEvents.HAMMER_UNCOCKED);
  797. RegisterEvent("Weapon_Hammer_Cocked", WeaponEvents.HAMMER_COCKED);
  798. RegisterEvent("Weapon_Change_Hide", WeaponEvents.CHANGE_HIDE);
  799. RegisterEvent("Weapon_Change_Show", WeaponEvents.CHANGE_SHOW);
  800. RegisterEvent("Weapon_CylinderRotate", WeaponEvents.CYLINDER_ROTATE);
  801. }
  802. //----------------------------------------------------
  803. // weapon init states
  804. //! this sets to a weapon init state
  805. //! each weapon has a different weapon state
  806. //! those states are defined by animation set by AddItemInHandsProfileIK - in DayZPlayerCfgBase.c
  807. //! each frame of animation is one init state
  808. proto native void SetInitState(int pFrameIndex);
  809. //! just static version of SetInitState
  810. proto native static void StaticSetInitState(Human pHuman, int pFrameIdx);
  811. //----------------------------------------------------
  812. //
  813. //! returns base aiming angle UD - without sway/offsets/...
  814. proto native float GetBaseAimingAngleUD();
  815. //! returns base aiming angle LR - without sway/offsets/...
  816. proto native float GetBaseAimingAngleLR();
  817. //----------------------------------------------------
  818. // throwing
  819. proto native void SetThrowingMode(bool pState);
  820. proto native bool IsThrowingMode();
  821. proto native void ThrowItem(int throwType);
  822. proto native bool WasItemLeaveHandsEvent();
  823. //----------------------------------------------------
  824. // debug copy
  825. //! return -1 when there is no event, otherwise it returns pId of event from animation
  826. proto native int DebugIsEvent();
  827. //!
  828. proto native void DebugResetEvents();
  829. }
  830. // *************************************************************************************
  831. // ! HumanCommandAdditives - additional damage
  832. // *************************************************************************************
  833. class HumanCommandAdditives
  834. {
  835. private void HumanCommandAdditives() {}
  836. private void ~HumanCommandAdditives() {}
  837. //! sets injury level 0..1, interpolate == false -> resets the value, otherwise it's interpolating towards the new value
  838. proto native void SetInjured(float pValue, bool pInterpolate);
  839. //! sets exhaustion level 0..1, interpolate == false -> resets the value, otherwise it's interpolating towards the new value
  840. proto native void SetExhaustion(float pValue, bool pInterpolate);
  841. //! sets talking
  842. proto native void SetTalking(bool pValue);
  843. //! starts modifier
  844. proto native void StartModifier(int pType);
  845. //! cancels modifier
  846. proto native void CancelModifier();
  847. //! is modifier active
  848. proto native bool IsModifierActive();
  849. }
  850. // *************************************************************************************
  851. // ! HumanMovementState - movement state, command, stance, movement, human.GetMovementState(movementState)
  852. // *************************************************************************************
  853. class HumanMovementState
  854. {
  855. int m_CommandTypeId; //! current command's id
  856. int m_iStanceIdx; //! current stance (DayZPlayerConstants.STANCEIDX_ERECT, ...), only if the command has a stance
  857. int m_iMovement; //! current movement (0 idle, 1 walk, 2-run, 3-sprint), only if the command has a movement
  858. float m_fLeaning; //! leaning state (not all commands need to have all movements)
  859. int m_LocalMovement = -1;
  860. //!
  861. bool IsRaised()
  862. {
  863. return m_iStanceIdx >= DayZPlayerConstants.STANCEIDX_RAISEDERECT;
  864. }
  865. //!
  866. bool IsRaisedInProne()
  867. {
  868. return m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE;
  869. }
  870. //!
  871. bool IsInProne()
  872. {
  873. return m_iStanceIdx == DayZPlayerConstants.STANCEIDX_PRONE;
  874. }
  875. //!
  876. bool IsInRaisedProne()
  877. {
  878. return m_iStanceIdx == DayZPlayerConstants.STANCEIDX_RAISEDPRONE;
  879. }
  880. //!
  881. bool IsLeaning()
  882. {
  883. return m_fLeaning != 0;
  884. }
  885. }
  886. enum HumanRelativeHeadingMode
  887. {
  888. //! From the last value that was set
  889. CURRENT,
  890. //! Actual input value
  891. INPUT,
  892. };
  893. /**
  894. *\brief HumanCommandScript fully scriptable command
  895. * \warning NON-MANAGED, will be managed by C++ once it is sent to the CommandHandler through Human.StartCommand_Script
  896. * \note So ideally, it is best to set up the HumanCommandScript, not create any instances and start it through Human.StartCommand_ScriptInst
  897. * In case an instance needs to be created, it needs manual deletion if not sent to the CommandHandler
  898. * But deleting it while it is in the CommandHandler will cause crashes
  899. */
  900. class HumanCommandScript
  901. {
  902. //! constructor must have 1st parameter to be Human
  903. // HumanCommandScript(Human pHuman);
  904. //! virtual to be overridden
  905. //! called when command starts
  906. void OnActivate() { };
  907. //! called when command ends
  908. void OnDeactivate() { };
  909. //---------------------------------------------------------------
  910. // usable everywhere
  911. //! this terminates human command script and shows CommandHandler( ... pCurrentCommandFinished == true );
  912. proto native void SetFlagFinished(bool pFinished);
  913. #ifdef FEATURE_NETWORK_RECONCILIATION
  914. //! Default is MINIMAL. It is reset to MINIMAL at the start of 'PreAnimUpdate'
  915. proto native void OverrideCorrectionType(AnimPhysCorrectionType correctionType);
  916. #endif
  917. //! sets character rotation (heading) (PreAnim/PrePhys only!)
  918. proto native void SetHeading(float yawAngle, float filterDt = -1, float maxYawSpeed = FLT_MAX);
  919. proto native void AddHeadingRelativeTo(HumanRelativeHeadingMode mode, float yawAngle, float filterDt = -1, float maxYawSpeed = FLT_MAX);
  920. //---------------------------------------------------------------
  921. // PreAnim Update
  922. //! override this !
  923. //! called before any animation is processed
  924. //! here change animation values, add animation commands
  925. void PreAnimUpdate(float pDt);
  926. //! function usable in PreAnimUpdate or in !!! OnActivate !!!
  927. proto native void PreAnim_CallCommand(int pCommand, int pParamInt, float pParamFloat);
  928. proto native void PreAnim_SetFloat(int pVar, float pFlt);
  929. proto native void PreAnim_SetInt(int pVar, int pInt);
  930. proto native void PreAnim_SetBool(int pVar, bool pBool);
  931. void PreAnim_SetFilteredHeading(float pYawAngle, float pFilterDt, float pMaxYawSpeed)
  932. {
  933. SetHeading(pYawAngle, pFilterDt, pMaxYawSpeed);
  934. }
  935. //---------------------------------------------------------------
  936. // PrePhys Update
  937. //! override this !
  938. //! after animation is processed, before physics is processed
  939. void PrePhysUpdate(float pDt);
  940. //! script function usable in PrePhysUpdate
  941. proto native bool PrePhys_IsEvent(int pEvent);
  942. proto native bool PrePhys_IsTag(int pTag);
  943. proto native bool PrePhys_GetTranslation(out vector pOutTransl); // vec3 in local space !
  944. proto native bool PrePhys_GetRotation(out float pOutRot[4]); // quaternion in local space !
  945. proto native void PrePhys_SetTranslation(vector pInTransl); // vec3 in local space !
  946. proto native void PrePhys_SetRotation(float pInRot[4]); // quaternion in local space !
  947. //---------------------------------------------------------------
  948. // PostPhys Update
  949. //! override this !
  950. //! final adjustment of physics state (after physics was applied)
  951. //! returns true if command continues running / false if command should end (or you can use SetFlagFinished(true))
  952. bool PostPhysUpdate(float pDt);
  953. //! script function usable in PostPhysUpdate
  954. proto native void PostPhys_GetPosition(out vector pOutTransl); //! vec3 in world space
  955. proto native void PostPhys_GetRotation(out float pOutRot[4]); //! quaternion in world space
  956. proto native void PostPhys_SetPosition(vector pInTransl); //! vec3 in world space
  957. proto native void PostPhys_SetRotation(float pInRot[4]); //! quaternion in world space
  958. proto native void PostPhys_LockRotation(); //! do not process rotations !
  959. }
  960. //! used in script-side identification of animation commands on human (swim, fall, move...)
  961. enum HumanMoveCommandID
  962. {
  963. None = 0,
  964. CommandMove = 1,
  965. CommandMelee = 2,
  966. CommandMelee2 = 4,
  967. CommandFall = 8,
  968. CommandClimb = 16,
  969. CommandDeath = 32,
  970. CommandUnconscious = 64,
  971. CommandDamageFullbody = 128,
  972. CommandDamageAdditive = 256,
  973. CommandLadder = 512,
  974. CommandSwim = 1024,
  975. CommandVehicle = 2048,
  976. CommandActionFullbody = 4096,
  977. CommandActionAdditive = 8192
  978. }
  979. // *************************************************************************************
  980. // ! Human - human script interface
  981. // *************************************************************************************
  982. class Human extends Man
  983. {
  984. //! world space - local space - heading space
  985. //! Deprecated: replaced with 'PhysicsGetTransformLS', which is local space transform
  986. proto native void GetTransformWS(out vector pTm[4]);
  987. //! gets human transform in world space
  988. //! Note: Value is not cached and it is recomputed every call if there is some parent
  989. proto native void PhysicsGetTransformWS(out vector pTm[4]);
  990. //! gets human transform in local space to parent/linked
  991. proto native void PhysicsGetTransformLS(out vector pTm[4]);
  992. //! gets human position in world space
  993. //! Note: Value is not cached and it is recomputed every call if there is some parent
  994. proto native vector PhysicsGetPositionWS();
  995. //! gets human position in local space to parent/linked
  996. proto native vector PhysicsGetPositionLS();
  997. //! makes test if there's enough space for character's collider assuming that character can be pushed away from obstacle - usable for checking if character is in some tight space
  998. proto native bool CheckFreeSpace(vector localDir, float distance, bool useHeading, vector posOffset = vector.Zero, float xzScale = 1.0);
  999. //! makes test if character can physically move in given world space direction - length of dir means distance, returns distance fraction
  1000. proto float CollisionMoveTest(vector dir, vector offset, float xzScale, IEntity ignoreEntity, out IEntity hitEntity, out vector hitPosition, out vector hitNormal);
  1001. //---------------------------------------------------------
  1002. // link/unlink to/from local space (enfusion hierachy)
  1003. proto native void LinkToLocalSpaceOf(notnull IEntity child, vector pLocalSpaceMatrix[4]);
  1004. proto native void UnlinkFromLocalSpace();
  1005. //---------------------------------------------------------
  1006. // heading component
  1007. //! smoothly move the player to the target position - do not handle replay, performed internally
  1008. proto native void AlignPositionWS(vector position);
  1009. //! adds the translation to the current position and then calls AlignPositionWS - do not handle replay, performed internally
  1010. proto native void AlignTranslationWS(vector translation);
  1011. //! adds the translation to the current position in heading space and then calls AlignPositionWS - do not handle replay, performed internally
  1012. proto native void AlignTranslationLS(vector translation);
  1013. //! smoothly move the player to face the target direction - do not handle replay, performed internally
  1014. proto native void AlignDirectionWS(vector direction);
  1015. //! callback before the transform is finalized, after PrePhys, called before alignment is applied
  1016. //! - important to ensure state is saved as this function gets replayed on correction
  1017. void OnPhysMove(float dt, vector transform[4]) {}
  1018. //---------------------------------------------------------
  1019. // bone transforms
  1020. //! returns bone index for a name (-1 if pBoneName doesn't exist)
  1021. proto native int GetBoneIndexByName(string pBoneName);
  1022. //! returns animation interface - usable in HumanCommandScript implementations
  1023. proto native HumanAnimInterface GetAnimInterface();
  1024. //---------------------------------------------------------
  1025. // physic props
  1026. //! returns true if physics controller is falling
  1027. proto native bool PhysicsIsFalling(bool pValidate);
  1028. //! entity below us
  1029. proto native IEntity PhysicsGetFloorEntity();
  1030. //! entity we are linked to (not valid when IEntity.GetParent() returns some entity)
  1031. proto native IEntity PhysicsGetLinkedEntity();
  1032. //! if the entity we are on was moving faster than it's defined config 'animPhysDetachSpeed' value
  1033. //! It is the result of the previous keyframe after physics move has been performed
  1034. proto native bool PhysicsWasSlidingOffLinkedEntity();
  1035. //! outs pVelocity - linear velocity of PHYSICS CONTROLLER
  1036. proto native void PhysicsGetVelocity(out vector pVelocity);
  1037. proto native void PhysicsEnableGravity(bool pEnable);
  1038. proto native bool PhysicsIsSolid();
  1039. proto native void PhysicsSetSolid(bool pSolid);
  1040. //! Sets and synchronize interaction layers 'RAGDOLL' and 'RAGDOLL_NO_CHARACTER' to prevent body stacking and players going through dead creatures
  1041. proto native void PhysicsSetRagdoll(bool pEnable);
  1042. //---------------------------------------------------------
  1043. // controller
  1044. //! returns human input controller
  1045. proto native HumanInputController GetInputController();
  1046. //---------------------------------------------------------
  1047. // item accessor
  1048. proto native HumanItemAccessor GetItemAccessor();
  1049. //---------------------------------------------------------
  1050. // commands
  1051. //! returns movement state (current command id, )
  1052. proto native void GetMovementState(HumanMovementState pState);
  1053. //! returns current command ID (see DayZPlayerConstants.COMMANDID_...)
  1054. proto native int GetCurrentCommandID();
  1055. //!----- MOVE -----
  1056. //! starts command - Move
  1057. proto native HumanCommandMove StartCommand_Move();
  1058. proto native HumanCommandMove GetCommand_Move();
  1059. //!----- MELEE -----
  1060. //! starts command - melee
  1061. proto native HumanCommandMelee StartCommand_Melee(EntityAI pTarget);
  1062. proto native HumanCommandMelee GetCommand_Melee();
  1063. //! starts command - melee2
  1064. proto native HumanCommandMelee2 StartCommand_Melee2(EntityAI pTarget, int pHitType, float pComboValue, vector hitPos = vector.Zero);
  1065. proto native HumanCommandMelee2 GetCommand_Melee2();
  1066. //!----- FALL -----
  1067. //! starts command - fall
  1068. //! pYVelocity <= 0 -> fall
  1069. //! pYVelocity > 0 -> jump
  1070. proto native HumanCommandFall StartCommand_Fall(float pYVelocity);
  1071. //!
  1072. proto native HumanCommandFall GetCommand_Fall();
  1073. //!----- LADDER -----
  1074. //! starts command - fall
  1075. proto native HumanCommandLadder StartCommand_Ladder(Building pBuilding, int pLadderIndex);
  1076. proto native HumanCommandLadder GetCommand_Ladder();
  1077. //!----- LADDER -----
  1078. //! starts command - Swim
  1079. proto native HumanCommandSwim StartCommand_Swim();
  1080. proto native HumanCommandSwim GetCommand_Swim();
  1081. //!----- VEHICLE -----
  1082. //! starts command - vehicle
  1083. proto native HumanCommandVehicle StartCommand_Vehicle(Transport pTransport, int pTransportPositionIndex, int pVehicleSeat, bool fromUnconscious = false);
  1084. proto native HumanCommandVehicle GetCommand_Vehicle();
  1085. //!----- CLIMB -----
  1086. //! starts command - climb
  1087. proto native HumanCommandClimb StartCommand_Climb(SHumanCommandClimbResult pClimbResult, int pType);
  1088. proto native HumanCommandClimb GetCommand_Climb();
  1089. //!----- Death -----
  1090. //! starts command - death
  1091. proto native HumanCommandDeathCallback StartCommand_Death(int pType, float pDirection, typename pCallbackClass, bool pKeepInLocalSpaceAfterLeave = false);
  1092. proto native HumanCommandDeathCallback GetCommand_Death();
  1093. //! starts command - unconscious
  1094. proto native HumanCommandUnconscious StartCommand_Unconscious(float pType);
  1095. proto native HumanCommandUnconscious GetCommand_Unconscious();
  1096. //!----- FullBody Damages -----
  1097. //! starts fullbody damage
  1098. // -> of type 0,...
  1099. // -> from direction (lback -180,left -90,0,righ 90,rightback 180)
  1100. proto native HumanCommandFullBodyDamage StartCommand_Damage(int pType, float pDirection);
  1101. proto native HumanCommandFullBodyDamage GetCommand_Damage();
  1102. //!----- ACTIONS -----
  1103. //! starts command - Action
  1104. //! pStanceMask is mix of flags STANCEMASK_ERECT, ...
  1105. proto native HumanCommandActionCallback StartCommand_Action(int pActionID, typename pCallbackClass, int pStanceMask);
  1106. //! is human is in command action - returns its callback, if current command is action
  1107. proto native HumanCommandActionCallback GetCommand_Action();
  1108. //---------------------------------------------------------
  1109. // command modifiers
  1110. //!
  1111. proto native int GetCommandModifierCount();
  1112. //! returns COMMANDID_ .. type id of command modifier on index pIndex
  1113. proto native int GetCommandModifierID(int pIndex);
  1114. //! default (always-on modifiers)
  1115. //! returns modifier for additives / small behaviours on human
  1116. proto native HumanCommandAdditives GetCommandModifier_Additives();
  1117. //! returns interface for handling weapons
  1118. proto native HumanCommandWeapons GetCommandModifier_Weapons();
  1119. // --- modifier/additive actions - played on COMMANDID_MOVE command
  1120. //! adds action command modifier, creates callback instance for you
  1121. proto native HumanCommandActionCallback AddCommandModifier_Action(int pActionID, typename pCallbackClass);
  1122. //! force remove - normally if action is ended or interrupted - this is not needed to call
  1123. proto native void DeleteCommandModifier_Action(HumanCommandActionCallback pCallback);
  1124. //! returns callback for action if any is active, null if nothing runs
  1125. proto native HumanCommandActionCallback GetCommandModifier_Action();
  1126. //!--- modifier for light Damages
  1127. //! starts additive damage
  1128. // -> of type 0,...
  1129. // -> from direction (lback -180,left -90,0,righ 90,rightback 180)
  1130. proto native HumanCommandDamage AddCommandModifier_Damage(int pType, float pDirection);
  1131. proto native void DeleteCommandModifier_Damage(HumanCommandDamage pDamage);
  1132. proto native HumanCommandDamage GetCommandModifier_Damage();
  1133. //!--- SCRIPTED COMMANDS
  1134. //! starts command - Action
  1135. //! pStanceMask is mix of flags STANCEMASK_ERECT, ...
  1136. proto native HumanCommandScript StartCommand_Script(HumanCommandScript pHumanCommand);
  1137. proto native HumanCommandScript StartCommand_ScriptInst(typename pCallbackClass);
  1138. //! is human is in command action - returns its callback, if current command is action
  1139. proto native HumanCommandScript GetCommand_Script();
  1140. //---------------------------------------------------------
  1141. // debug info for Item Accessor
  1142. //! returns current item's class name
  1143. proto native owned string DebugGetItemClass();
  1144. //! returns current item's class that is found in config
  1145. proto native owned string DebugGetItemSuperClass();
  1146. //! returns current item's animation instance
  1147. proto native owned string DebugGetItemAnimInstance();
  1148. //---------------------------------------------------------
  1149. // helper functions for disabling simulation upon death
  1150. proto native void StartDeath();
  1151. proto native void ResetDeath();
  1152. proto native void ResetDeathCooldown();
  1153. proto native bool IsDeathProcessed();
  1154. proto native bool IsDeathConditionMet();
  1155. //--------------------------------------------------------
  1156. // commands start/finish events
  1157. void OnCommandMoveStart();
  1158. void OnCommandMoveFinish();
  1159. void OnCommandMeleeStart();
  1160. void OnCommandMeleeFinish();
  1161. void OnCommandMelee2Start();
  1162. void OnCommandMelee2Finish();
  1163. void OnCommandFallStart();
  1164. void OnCommandFallFinish();
  1165. void OnCommandClimbStart();
  1166. void OnCommandClimbFinish();
  1167. void OnCommandDeathStart();
  1168. void OnCommandDeathFinish();
  1169. void OnCommandUnconsciousStart();
  1170. void OnCommandUnconsciousFinish();
  1171. void OnCommandDamageFullbodyStart();
  1172. void OnCommandDamageFullbodyFinish();
  1173. void OnCommandDamageAdditiveStart();
  1174. void OnCommandDamageAdditiveFinish();
  1175. void OnCommandLadderStart();
  1176. void OnCommandLadderFinish();
  1177. void OnCommandSwimStart();
  1178. void OnCommandSwimFinish();
  1179. void OnCommandVehicleStart();
  1180. void OnCommandVehicleFinish();
  1181. void OnCommandActionFullbodyStart();
  1182. void OnCommandActionFullbodyFinish();
  1183. void OnCommandActionAdditiveStart();
  1184. void OnCommandActionAdditiveFinish();
  1185. //! gets called on stance change
  1186. void OnStanceChange(int previousStance, int newStance);
  1187. //! Called by code to see if it can
  1188. bool CanChangeStance(int previousStance, int newStance);
  1189. //--------------------------------------------------------
  1190. // rolling API
  1191. bool CanRoll();
  1192. void OnRollStart(bool isToTheRight);
  1193. void OnRollFinish();
  1194. //--------------------------------------------------------
  1195. // vehicle API
  1196. void OnVehicleSeatDriverEnter();
  1197. void OnVehicleSeatDriverLeft();
  1198. }