human.c 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665
  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. //! Override this to return the current stance of the human.
  921. int GetCurrentStance()
  922. {
  923. return DayZPlayerConstants.STANCEIDX_ERECT;
  924. }
  925. //! Override this to return the current movement state of the human.
  926. int GetCurrentMovement()
  927. {
  928. return DayZPlayerConstants.MOVEMENT_IDLE;
  929. }
  930. //! Override this to return the current leaning state of the human. <-1, 1>
  931. float GetCurrentLeaning()
  932. {
  933. return 0.0;
  934. }
  935. //---------------------------------------------------------------
  936. // PreAnim Update
  937. //! override this !
  938. //! called before any animation is processed
  939. //! here change animation values, add animation commands
  940. void PreAnimUpdate(float pDt);
  941. //! function usable in PreAnimUpdate or in !!! OnActivate !!!
  942. proto native void PreAnim_CallCommand(int pCommand, int pParamInt, float pParamFloat);
  943. proto native void PreAnim_SetFloat(int pVar, float pFlt);
  944. proto native void PreAnim_SetInt(int pVar, int pInt);
  945. proto native void PreAnim_SetBool(int pVar, bool pBool);
  946. void PreAnim_SetFilteredHeading(float pYawAngle, float pFilterDt, float pMaxYawSpeed)
  947. {
  948. SetHeading(pYawAngle, pFilterDt, pMaxYawSpeed);
  949. }
  950. //---------------------------------------------------------------
  951. // PrePhys Update
  952. //! override this !
  953. //! after animation is processed, before physics is processed
  954. void PrePhysUpdate(float pDt);
  955. //! script function usable in PrePhysUpdate
  956. proto native bool PrePhys_IsEvent(int pEvent);
  957. proto native bool PrePhys_IsTag(int pTag);
  958. proto native bool PrePhys_GetTranslation(out vector pOutTransl); // vec3 in local space !
  959. proto native bool PrePhys_GetRotation(out float pOutRot[4]); // quaternion in local space !
  960. proto native void PrePhys_SetTranslation(vector pInTransl); // vec3 in local space !
  961. proto native void PrePhys_SetRotation(float pInRot[4]); // quaternion in local space !
  962. //---------------------------------------------------------------
  963. // PostPhys Update
  964. //! override this !
  965. //! final adjustment of physics state (after physics was applied)
  966. //! returns true if command continues running / false if command should end (or you can use SetFlagFinished(true))
  967. bool PostPhysUpdate(float pDt);
  968. //! script function usable in PostPhysUpdate
  969. proto native void PostPhys_GetPosition(out vector pOutTransl); //! vec3 in world space
  970. proto native void PostPhys_GetRotation(out float pOutRot[4]); //! quaternion in world space
  971. proto native void PostPhys_SetPosition(vector pInTransl); //! vec3 in world space
  972. proto native void PostPhys_SetRotation(float pInRot[4]); //! quaternion in world space
  973. proto native void PostPhys_LockRotation(); //! do not process rotations !
  974. }
  975. //! used in script-side identification of animation commands on human (swim, fall, move...)
  976. enum HumanMoveCommandID
  977. {
  978. None = 0,
  979. CommandMove = 1,
  980. CommandMelee = 2,
  981. CommandMelee2 = 4,
  982. CommandFall = 8,
  983. CommandClimb = 16,
  984. CommandDeath = 32,
  985. CommandUnconscious = 64,
  986. CommandDamageFullbody = 128,
  987. CommandDamageAdditive = 256,
  988. CommandLadder = 512,
  989. CommandSwim = 1024,
  990. CommandVehicle = 2048,
  991. CommandActionFullbody = 4096,
  992. CommandActionAdditive = 8192
  993. }
  994. // *************************************************************************************
  995. // ! Human - human script interface
  996. // *************************************************************************************
  997. class Human extends Man
  998. {
  999. //! world space - local space - heading space
  1000. //! Deprecated: replaced with 'PhysicsGetTransformLS', which is local space transform
  1001. proto native void GetTransformWS(out vector pTm[4]);
  1002. //! gets human transform in world space
  1003. //! Note: Value is not cached and it is recomputed every call if there is some parent
  1004. proto native void PhysicsGetTransformWS(out vector pTm[4]);
  1005. //! gets human transform in local space to parent/linked
  1006. proto native void PhysicsGetTransformLS(out vector pTm[4]);
  1007. //! gets human position in world space
  1008. //! Note: Value is not cached and it is recomputed every call if there is some parent
  1009. proto native vector PhysicsGetPositionWS();
  1010. //! gets human position in local space to parent/linked
  1011. proto native vector PhysicsGetPositionLS();
  1012. //! 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
  1013. proto native bool CheckFreeSpace(vector localDir, float distance, bool useHeading, vector posOffset = vector.Zero, float xzScale = 1.0);
  1014. //! makes test if character can physically move in given world space direction - length of dir means distance, returns distance fraction
  1015. proto float CollisionMoveTest(vector dir, vector offset, float xzScale, IEntity ignoreEntity, out IEntity hitEntity, out vector hitPosition, out vector hitNormal);
  1016. //---------------------------------------------------------
  1017. // link/unlink to/from local space (enfusion hierachy)
  1018. proto native void LinkToLocalSpaceOf(notnull IEntity child, vector pLocalSpaceMatrix[4]);
  1019. proto native void UnlinkFromLocalSpace();
  1020. //---------------------------------------------------------
  1021. // heading component
  1022. //! smoothly move the player to the target position - do not handle replay, performed internally
  1023. proto native void AlignPositionWS(vector position);
  1024. //! adds the translation to the current position and then calls AlignPositionWS - do not handle replay, performed internally
  1025. proto native void AlignTranslationWS(vector translation);
  1026. //! adds the translation to the current position in heading space and then calls AlignPositionWS - do not handle replay, performed internally
  1027. proto native void AlignTranslationLS(vector translation);
  1028. //! smoothly move the player to face the target direction - do not handle replay, performed internally
  1029. proto native void AlignDirectionWS(vector direction);
  1030. //! callback before the transform is finalized, after PrePhys, called before alignment is applied
  1031. //! - important to ensure state is saved as this function gets replayed on correction
  1032. void OnPhysMove(float dt, vector transform[4]) {}
  1033. //---------------------------------------------------------
  1034. // bone transforms
  1035. //! returns bone index for a name (-1 if pBoneName doesn't exist)
  1036. proto native int GetBoneIndexByName(string pBoneName);
  1037. //! returns animation interface - usable in HumanCommandScript implementations
  1038. proto native HumanAnimInterface GetAnimInterface();
  1039. //---------------------------------------------------------
  1040. // physic props
  1041. //! returns true if physics controller is falling
  1042. proto native bool PhysicsIsFalling(bool pValidate);
  1043. //! entity below us
  1044. proto native IEntity PhysicsGetFloorEntity();
  1045. //! entity we are linked to (not valid when IEntity.GetParent() returns some entity)
  1046. proto native IEntity PhysicsGetLinkedEntity();
  1047. //! if the entity we are on was moving faster than it's defined config 'animPhysDetachSpeed' value
  1048. //! It is the result of the previous keyframe after physics move has been performed
  1049. proto native bool PhysicsWasSlidingOffLinkedEntity();
  1050. //! outs pVelocity - linear velocity of PHYSICS CONTROLLER
  1051. proto native void PhysicsGetVelocity(out vector pVelocity);
  1052. proto native void PhysicsEnableGravity(bool pEnable);
  1053. proto native bool PhysicsIsSolid();
  1054. proto native void PhysicsSetSolid(bool pSolid);
  1055. //! Sets and synchronize interaction layers 'RAGDOLL' and 'RAGDOLL_NO_CHARACTER' to prevent body stacking and players going through dead creatures
  1056. proto native void PhysicsSetRagdoll(bool pEnable);
  1057. //---------------------------------------------------------
  1058. // controller
  1059. //! returns human input controller
  1060. proto native HumanInputController GetInputController();
  1061. //---------------------------------------------------------
  1062. // item accessor
  1063. proto native HumanItemAccessor GetItemAccessor();
  1064. //---------------------------------------------------------
  1065. // commands
  1066. //! returns movement state (current command id, )
  1067. proto native void GetMovementState(HumanMovementState pState);
  1068. //! returns current command ID (see DayZPlayerConstants.COMMANDID_...)
  1069. proto native int GetCurrentCommandID();
  1070. //!----- MOVE -----
  1071. //! starts command - Move
  1072. proto native HumanCommandMove StartCommand_Move();
  1073. proto native HumanCommandMove GetCommand_Move();
  1074. //!----- MELEE -----
  1075. //! starts command - melee
  1076. proto native HumanCommandMelee StartCommand_Melee(EntityAI pTarget);
  1077. proto native HumanCommandMelee GetCommand_Melee();
  1078. //! starts command - melee2
  1079. proto native HumanCommandMelee2 StartCommand_Melee2(EntityAI pTarget, int pHitType, float pComboValue, vector hitPos = vector.Zero);
  1080. proto native HumanCommandMelee2 GetCommand_Melee2();
  1081. //!----- FALL -----
  1082. //! starts command - fall
  1083. //! pYVelocity <= 0 -> fall
  1084. //! pYVelocity > 0 -> jump
  1085. proto native HumanCommandFall StartCommand_Fall(float pYVelocity);
  1086. //!
  1087. proto native HumanCommandFall GetCommand_Fall();
  1088. //!----- LADDER -----
  1089. //! starts command - fall
  1090. proto native HumanCommandLadder StartCommand_Ladder(Building pBuilding, int pLadderIndex);
  1091. proto native HumanCommandLadder GetCommand_Ladder();
  1092. //!----- LADDER -----
  1093. //! starts command - Swim
  1094. proto native HumanCommandSwim StartCommand_Swim();
  1095. proto native HumanCommandSwim GetCommand_Swim();
  1096. //!----- VEHICLE -----
  1097. //! starts command - vehicle
  1098. proto native HumanCommandVehicle StartCommand_Vehicle(Transport pTransport, int pTransportPositionIndex, int pVehicleSeat, bool fromUnconscious = false);
  1099. proto native HumanCommandVehicle GetCommand_Vehicle();
  1100. //!----- CLIMB -----
  1101. //! starts command - climb
  1102. proto native HumanCommandClimb StartCommand_Climb(SHumanCommandClimbResult pClimbResult, int pType);
  1103. proto native HumanCommandClimb GetCommand_Climb();
  1104. //!----- Death -----
  1105. //! starts command - death
  1106. proto native HumanCommandDeathCallback StartCommand_Death(int pType, float pDirection, typename pCallbackClass, bool pKeepInLocalSpaceAfterLeave = false);
  1107. proto native HumanCommandDeathCallback GetCommand_Death();
  1108. //! starts command - unconscious
  1109. proto native HumanCommandUnconscious StartCommand_Unconscious(float pType);
  1110. proto native HumanCommandUnconscious GetCommand_Unconscious();
  1111. //!----- FullBody Damages -----
  1112. //! starts fullbody damage
  1113. // -> of type 0,...
  1114. // -> from direction (lback -180,left -90,0,righ 90,rightback 180)
  1115. proto native HumanCommandFullBodyDamage StartCommand_Damage(int pType, float pDirection);
  1116. proto native HumanCommandFullBodyDamage GetCommand_Damage();
  1117. //!----- ACTIONS -----
  1118. //! starts command - Action
  1119. //! pStanceMask is mix of flags STANCEMASK_ERECT, ...
  1120. proto native HumanCommandActionCallback StartCommand_Action(int pActionID, typename pCallbackClass, int pStanceMask);
  1121. //! is human is in command action - returns its callback, if current command is action
  1122. proto native HumanCommandActionCallback GetCommand_Action();
  1123. //---------------------------------------------------------
  1124. // command modifiers
  1125. //!
  1126. proto native int GetCommandModifierCount();
  1127. //! returns COMMANDID_ .. type id of command modifier on index pIndex
  1128. proto native int GetCommandModifierID(int pIndex);
  1129. //! default (always-on modifiers)
  1130. //! returns modifier for additives / small behaviours on human
  1131. proto native HumanCommandAdditives GetCommandModifier_Additives();
  1132. //! returns interface for handling weapons
  1133. proto native HumanCommandWeapons GetCommandModifier_Weapons();
  1134. // --- modifier/additive actions - played on COMMANDID_MOVE command
  1135. //! adds action command modifier, creates callback instance for you
  1136. proto native HumanCommandActionCallback AddCommandModifier_Action(int pActionID, typename pCallbackClass);
  1137. //! force remove - normally if action is ended or interrupted - this is not needed to call
  1138. proto native void DeleteCommandModifier_Action(HumanCommandActionCallback pCallback);
  1139. //! returns callback for action if any is active, null if nothing runs
  1140. proto native HumanCommandActionCallback GetCommandModifier_Action();
  1141. //!--- modifier for light Damages
  1142. //! starts additive damage
  1143. // -> of type 0,...
  1144. // -> from direction (lback -180,left -90,0,righ 90,rightback 180)
  1145. proto native HumanCommandDamage AddCommandModifier_Damage(int pType, float pDirection);
  1146. proto native void DeleteCommandModifier_Damage(HumanCommandDamage pDamage);
  1147. proto native HumanCommandDamage GetCommandModifier_Damage();
  1148. //!--- SCRIPTED COMMANDS
  1149. //! starts command - Action
  1150. //! pStanceMask is mix of flags STANCEMASK_ERECT, ...
  1151. proto native HumanCommandScript StartCommand_Script(HumanCommandScript pHumanCommand);
  1152. proto native HumanCommandScript StartCommand_ScriptInst(typename pCallbackClass);
  1153. //! is human is in command action - returns its callback, if current command is action
  1154. proto native HumanCommandScript GetCommand_Script();
  1155. //---------------------------------------------------------
  1156. // debug info for Item Accessor
  1157. //! returns current item's class name
  1158. proto native owned string DebugGetItemClass();
  1159. //! returns current item's class that is found in config
  1160. proto native owned string DebugGetItemSuperClass();
  1161. //! returns current item's animation instance
  1162. proto native owned string DebugGetItemAnimInstance();
  1163. //---------------------------------------------------------
  1164. // helper functions for disabling simulation upon death
  1165. proto native void StartDeath();
  1166. proto native void ResetDeath();
  1167. proto native void ResetDeathCooldown();
  1168. proto native bool IsDeathProcessed();
  1169. proto native bool IsDeathConditionMet();
  1170. //--------------------------------------------------------
  1171. // commands start/finish events
  1172. void OnCommandMoveStart();
  1173. void OnCommandMoveFinish();
  1174. void OnCommandMeleeStart();
  1175. void OnCommandMeleeFinish();
  1176. void OnCommandMelee2Start();
  1177. void OnCommandMelee2Finish();
  1178. void OnCommandFallStart();
  1179. void OnCommandFallFinish();
  1180. void OnCommandClimbStart();
  1181. void OnCommandClimbFinish();
  1182. void OnCommandDeathStart();
  1183. void OnCommandDeathFinish();
  1184. void OnCommandUnconsciousStart();
  1185. void OnCommandUnconsciousFinish();
  1186. void OnCommandDamageFullbodyStart();
  1187. void OnCommandDamageFullbodyFinish();
  1188. void OnCommandDamageAdditiveStart();
  1189. void OnCommandDamageAdditiveFinish();
  1190. void OnCommandLadderStart();
  1191. void OnCommandLadderFinish();
  1192. void OnCommandSwimStart();
  1193. void OnCommandSwimFinish();
  1194. void OnCommandVehicleStart();
  1195. void OnCommandVehicleFinish();
  1196. void OnCommandActionFullbodyStart();
  1197. void OnCommandActionFullbodyFinish();
  1198. void OnCommandActionAdditiveStart();
  1199. void OnCommandActionAdditiveFinish();
  1200. //! gets called on stance change
  1201. void OnStanceChange(int previousStance, int newStance);
  1202. //! Called by code to see if it can
  1203. bool CanChangeStance(int previousStance, int newStance);
  1204. //--------------------------------------------------------
  1205. // rolling API
  1206. bool CanRoll();
  1207. void OnRollStart(bool isToTheRight);
  1208. void OnRollFinish();
  1209. //--------------------------------------------------------
  1210. // vehicle API
  1211. void OnVehicleSeatDriverEnter();
  1212. void OnVehicleSeatDriverLeft();
  1213. }