Guest User

Player.ws File

a guest
Jul 21st, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 64.74 KB | None | 0 0
  1. /***********************************************************************/
  2. /** © 2015 CD PROJEKT S.A. All rights reserved.
  3. /** THE WITCHER® is a trademark of CD PROJEKT S. A.
  4. /** The Witcher game is based on the prose of Andrzej Sapkowski.
  5. /***********************************************************************/
  6.  
  7.  
  8.  
  9. enum EPlayerDeathType
  10. {
  11. PDT_Normal = 0,
  12. PDT_Fall = 1,
  13. PDT_KnockBack = 2,
  14. }
  15.  
  16. statemachine import abstract class CPlayer extends CActor
  17. {
  18.  
  19. private var _DEBUGDisplayRadiusMinimapIcons : bool;
  20. private var debug_BIsInputAllowedLocks : array<name>;
  21.  
  22.  
  23.  
  24.  
  25. public const var ENTER_SWIMMING_WATER_LEVEL : float;
  26. default ENTER_SWIMMING_WATER_LEVEL = -1.45;
  27.  
  28.  
  29. public var useSprintingCameraAnim : bool; default useSprintingCameraAnim = false;
  30. public var oTCameraOffset : float; default oTCameraOffset = 0.f;
  31. public var oTCameraPitchOffset : float; default oTCameraPitchOffset = 0.f;
  32.  
  33.  
  34.  
  35. public var bIsRollAllowed : bool;
  36. protected var bIsInCombatAction : bool;
  37. protected var bIsInCombatActionFriendly : bool;
  38. private var bIsInputAllowed : bool;
  39. public var bIsFirstAttackInCombo : bool;
  40. protected var bIsInHitAnim : bool;
  41. import var enemyUpscaling : bool;
  42.  
  43. public editable var FarZoneDistMax : float;
  44. public editable var DangerZoneDistMax : float;
  45.  
  46. default FarZoneDistMax = 30;
  47. default DangerZoneDistMax = 50;
  48.  
  49.  
  50. private var commentaryCooldown : float;
  51. private var commentaryLastTime : EngineTime;
  52.  
  53. private var canPlaySpecificVoiceset : bool;
  54. default canPlaySpecificVoiceset = true;
  55.  
  56.  
  57. public var isHorseMounted : bool;
  58. public var isCompanionFollowing : bool;
  59. public var bStartScreenIsOpened : bool;
  60. public var bEndScreenIsOpened : bool;
  61. public var fStartScreenFadeDuration : float;
  62. public var bStartScreenEndWithBlackScreen : bool;
  63. public var fStartScreenFadeInDuration : float;
  64. const var DEATH_SCREEN_OPEN_DELAY : float;
  65.  
  66. default bStartScreenIsOpened = false;
  67. default bEndScreenIsOpened = false;
  68. default DEATH_SCREEN_OPEN_DELAY = 4.f;
  69. default fStartScreenFadeDuration = 3.0;
  70. default fStartScreenFadeInDuration = 3.0;
  71. default bStartScreenEndWithBlackScreen = false;
  72.  
  73.  
  74. public var bLAxisReleased : bool;
  75. public var bRAxisReleased : bool;
  76. private var bUITakesInput : bool;
  77. protected saved var inputHandler : CPlayerInput;
  78. public var sprintActionPressed : bool;
  79. private var inputModuleNeededToRun : float;
  80.  
  81. default bUITakesInput = false;
  82. default bLAxisReleased = true;
  83. default inputModuleNeededToRun = -1.0;
  84.  
  85.  
  86. private var bInteractionPressed : bool;
  87.  
  88.  
  89. public var rawPlayerSpeed : float;
  90. public var rawPlayerAngle : float;
  91. public var rawPlayerHeading : float;
  92.  
  93. public var cachedRawPlayerHeading : float;
  94. public var cachedCombatActionHeading : float;
  95. public var canResetCachedCombatActionHeading : bool;
  96. protected var combatActionHeading : float;
  97. public var rawCameraHeading : float;
  98. private var isSprinting : bool;
  99. protected var isRunning : bool;
  100. protected var isWalking : bool;
  101. public var playerMoveType : EPlayerMoveType;
  102. private var sprintingTime : float;
  103. private var walkToggle : bool; default walkToggle = false;
  104. private var sprintToggle : bool; default sprintToggle = false;
  105. import public var isMovable : bool;
  106.  
  107. public var moveTarget : CActor;
  108. public var nonActorTarget : CGameplayEntity;
  109. public var tempLookAtTarget : CGameplayEntity;
  110. public var lockTargetSelectionHeading : float;
  111.  
  112. protected var rawLeftJoyRot : float;
  113. protected var rawRightJoyRot : float;
  114. protected var rawLeftJoyVec : Vector;
  115. protected var rawRightJoyVec : Vector;
  116. protected var prevRawLeftJoyVec : Vector;
  117. protected var prevRawRightJoyVec : Vector;
  118. protected var lastValidLeftJoyVec : Vector;
  119. protected var lastValidRightJoyVec : Vector;
  120.  
  121. public var allowStopRunCheck : bool;
  122. public var moveTargetDampValue : float;
  123.  
  124.  
  125.  
  126. public var interiorCamera : bool;
  127. public var movementLockType : EPlayerMovementLockType;
  128. public var scriptedCombatCamera : bool;
  129. public var modifyPlayerSpeed : bool;
  130. public saved var autoCameraCenterToggle : bool;
  131.  
  132. default interiorCamera = false;
  133. default scriptedCombatCamera = true;
  134.  
  135.  
  136. public var inv : CInventoryComponent;
  137.  
  138. public saved var equipmentSlotHistory : array<SItemUniqueId>;
  139.  
  140.  
  141. private var currentTrackedQuestSystemObjectives : array<SJournalQuestObjectiveData>;
  142. private var currentTrackedQuestObjectives : array<SJournalQuestObjectiveData>;
  143. private var currentTrackedQuestGUID : CGUID;
  144. private var HAXNewObjTable : array<CGUID>;
  145.  
  146.  
  147. public var handAimPitch : float;
  148. private saved var vehicleCachedSign : ESignType;
  149.  
  150. default vehicleCachedSign = ST_None;
  151.  
  152.  
  153. public editable var softLockDist : float;
  154. public editable var softLockFrameSize : float;
  155. public var findMoveTargetDist : float;
  156. public var softLockDistVehicle : float;
  157. private var bBIsLockedToTarget : bool;
  158. private var bActorIsLockedToTarget : bool;
  159. private var bIsHardLockedTotarget : bool;
  160.  
  161. default softLockDist = 12.f;
  162. default softLockFrameSize = 1.25f;
  163. default softLockDistVehicle = 30.f;
  164.  
  165.  
  166. private var terrTypeOne : ETerrainType;
  167. private var terrTypeTwo : ETerrainType;
  168. private var terrModifier : float;
  169. private var prevTerrType : ETerrainType;
  170.  
  171. default terrTypeOne = TT_Normal;
  172. default terrTypeTwo = TT_Normal;
  173. default terrModifier = 0.f;
  174. default prevTerrType = TT_Normal;
  175.  
  176.  
  177. protected var currentlyUsedItem : W3UsableItem;
  178. protected var currentlyEquipedItem : SItemUniqueId;
  179. protected var currentlyUsedItemL : W3UsableItem;
  180. public saved var currentlyEquipedItemL : SItemUniqueId;
  181. protected var isUsableItemBlocked : bool;
  182. protected var isUsableItemLtransitionAllowed : bool;
  183. protected var playerActionToRestore : EPlayerActionToRestore; default playerActionToRestore = PATR_Default;
  184.  
  185. public saved var teleportedOnBoatToOtherHUB : bool;
  186. default teleportedOnBoatToOtherHUB = false;
  187.  
  188.  
  189.  
  190. public var isAdaptiveBalance : bool;
  191. default isAdaptiveBalance = false;
  192.  
  193. function IsAdaptiveBalance() : bool
  194. {
  195. return isAdaptiveBalance;
  196. }
  197. function SetAdaptiveBalance( val : bool )
  198. {
  199. Log("Adaptive balance: " + val );
  200. isAdaptiveBalance = val;
  201. }
  202.  
  203. public function SetTeleportedOnBoatToOtherHUB( val : bool )
  204. {
  205. teleportedOnBoatToOtherHUB = val;
  206. }
  207.  
  208.  
  209.  
  210.  
  211.  
  212. import final function LockButtonInteractions( channel : int );
  213.  
  214.  
  215. import final function UnlockButtonInteractions( channel : int );
  216.  
  217. import final function GetActiveExplorationEntity() : CEntity;
  218.  
  219.  
  220.  
  221. event OnSpawned( spawnData : SEntitySpawnData )
  222. {
  223. var conf : int;
  224.  
  225. inv = GetInventory();
  226.  
  227. super.OnSpawned( spawnData );
  228.  
  229. RegisterCollisionEventsListener();
  230. AddTimer( 'PlayerTick', 0.f, true );
  231. //MODEnableMimics
  232. AddTimer( 'RefreshHead', 0.1f, true, , , true );
  233. AddTimer( 'BlinkingStart', 2.f, true, , , true );
  234. //MODEnableMimics END
  235. InitializeParryType();
  236. SetCanPlayHitAnim( true );
  237.  
  238.  
  239. if( inv )
  240. {
  241. inv.Created();
  242. }
  243. if( !spawnData.restored )
  244. {
  245. inputHandler = new CPlayerInput in this;
  246. theGame.EnableUberMovement( true );
  247. ((CInGameConfigWrapper)theGame.GetInGameConfigWrapper()).SetVarValue( 'Gameplay', 'EnableUberMovement', 1 );
  248. }
  249.  
  250. inputHandler.Initialize(spawnData.restored );
  251. SetAutoCameraCenter( ((CInGameConfigWrapper)theGame.GetInGameConfigWrapper()).GetVarValue( 'Gameplay', 'AutoCameraCenter' ) );
  252.  
  253. SetEnemyUpscaling( ((CInGameConfigWrapper)theGame.GetInGameConfigWrapper()).GetVarValue( 'Gameplay', 'EnemyUpscaling' ) );
  254.  
  255. if( !IsNameValid(GetCurrentStateName()) )
  256. {
  257. GotoStateAuto();
  258. }
  259.  
  260. isRunning = false;
  261. SetIsWalking( false );
  262.  
  263.  
  264. EnableBroadcastPresence(true);
  265.  
  266.  
  267. AddAnimEventCallback('EquipItem', 'OnAnimEvent_QuickSlotItems');
  268. AddAnimEventCallback('UseItem', 'OnAnimEvent_QuickSlotItems');
  269. AddAnimEventCallback('HideItem', 'OnAnimEvent_QuickSlotItems');
  270. AddAnimEventCallback('EquipItemL', 'OnAnimEvent_QuickSlotItems');
  271. AddAnimEventCallback('UseItemL', 'OnAnimEvent_QuickSlotItems');
  272. AddAnimEventCallback('HideItemL', 'OnAnimEvent_QuickSlotItems');
  273. AddAnimEventCallback('AllowInput', 'OnAnimEvent_AllowInput');
  274. AddAnimEventCallback('DisallowInput', 'OnAnimEvent_DisallowInput');
  275. AddAnimEventCallback('DisallowHitAnim', 'OnAnimEvent_DisallowHitAnim');
  276. AddAnimEventCallback('AllowHitAnim', 'OnAnimEvent_AllowHitAnim');
  277.  
  278. AddAnimEventCallback('SetRagdoll', 'OnAnimEvent_SetRagdoll');
  279. AddAnimEventCallback('InAirKDCheck', 'OnAnimEvent_InAirKDCheck');
  280. AddAnimEventCallback('EquipMedallion', 'OnAnimEvent_EquipMedallion');
  281. AddAnimEventCallback('HideMedallion', 'OnAnimEvent_HideMedallion');
  282.  
  283.  
  284. ResumeStaminaRegen( 'Sprint' );
  285. }
  286.  
  287.  
  288. public function Debug_ResetInput()
  289. {
  290. inputHandler = new CPlayerInput in this;
  291. inputHandler.Initialize(false);
  292. }
  293.  
  294.  
  295.  
  296. public function GetTutorialInputHandler() : W3PlayerTutorialInput
  297. {
  298. return (W3PlayerTutorialInput)inputHandler;
  299. }
  300.  
  301. public function BlockAction( action : EInputActionBlock, sourceName : name, optional keepOnSpawn : bool, optional isFromQuest : bool, optional isFromPlace : bool ) : bool
  302. {
  303. if ( inputHandler )
  304. {
  305. inputHandler.BlockAction(action, sourceName, true, keepOnSpawn, this, isFromQuest, isFromPlace);
  306. return true;
  307. }
  308. return false;
  309. }
  310.  
  311. public function UnblockAction( action : EInputActionBlock, sourceName : name) : bool
  312. {
  313. if ( inputHandler )
  314. {
  315. inputHandler.BlockAction(action, sourceName, false);
  316. return true;
  317. }
  318. return false;
  319. }
  320.  
  321. public final function TutorialForceUnblockRadial() : array<SInputActionLock>
  322. {
  323. var null : array<SInputActionLock>;
  324.  
  325. if ( inputHandler )
  326. {
  327. return inputHandler.TutorialForceUnblockRadial();
  328. }
  329.  
  330. return null;
  331. }
  332.  
  333. public final function TutorialForceRestoreRadialLocks(radialLocks : array<SInputActionLock>)
  334. {
  335. if ( inputHandler )
  336. {
  337. inputHandler.TutorialForceRestoreRadialLocks(radialLocks);
  338. }
  339. }
  340.  
  341. public function GetActionLocks( action : EInputActionBlock ) : array< SInputActionLock >
  342. {
  343. return inputHandler.GetActionLocks( action );
  344. }
  345.  
  346. public function GetAllActionLocks() : array< array< SInputActionLock > >
  347. {
  348. return inputHandler.GetAllActionLocks();
  349. }
  350.  
  351. public function IsActionAllowed( action : EInputActionBlock ) : bool
  352. {
  353. if ( inputHandler )
  354. {
  355. return inputHandler.IsActionAllowed( action );
  356. }
  357. return true;
  358. }
  359.  
  360. public function IsActionBlockedBy( action : EInputActionBlock, sourceName : name ) : bool
  361. {
  362. if ( inputHandler )
  363. {
  364. return inputHandler.IsActionBlockedBy(action,sourceName);
  365. }
  366. return false;
  367. }
  368.  
  369. public function IsWeaponActionAllowed( weapon : EPlayerWeapon ) : bool
  370. {
  371. if ( inputHandler )
  372. {
  373.  
  374.  
  375. if ( weapon == PW_Fists )
  376. {
  377. return inputHandler.IsActionAllowed( EIAB_Fists );
  378. }
  379. else
  380. {
  381. return inputHandler.IsActionAllowed( EIAB_DrawWeapon );
  382. }
  383. }
  384. return true;
  385. }
  386.  
  387. public function BlockAllActions(sourceName : name, lock : bool, optional exceptions : array<EInputActionBlock>, optional exceptUI : bool, optional saveLock : bool, optional onSpawnedNullPointerHackFix : CPlayer, optional isFromPlace : bool)
  388. {
  389. if(inputHandler)
  390. {
  391. if(exceptUI)
  392. {
  393. exceptions.PushBack(EIAB_OpenInventory);
  394. exceptions.PushBack(EIAB_MeditationWaiting);
  395. exceptions.PushBack(EIAB_FastTravel);
  396. exceptions.PushBack(EIAB_OpenMap);
  397. exceptions.PushBack(EIAB_OpenCharacterPanel);
  398. exceptions.PushBack(EIAB_OpenJournal);
  399. exceptions.PushBack(EIAB_OpenAlchemy);
  400. }
  401. inputHandler.BlockAllActions(sourceName, lock, exceptions, saveLock, onSpawnedNullPointerHackFix, false, isFromPlace);
  402. }
  403. if(lock)
  404. {
  405.  
  406. }
  407. }
  408.  
  409. public final function BlockAllQuestActions(sourceName : name, lock : bool)
  410. {
  411. inputHandler.BlockAllQuestActions(sourceName, lock);
  412. }
  413.  
  414. public function BlockAllUIQuestActions(sourceName : name, lock : bool)
  415. {
  416. inputHandler.BlockAllUIQuestActions(sourceName, lock);
  417. }
  418.  
  419.  
  420.  
  421. public function GetInputHandler() : CPlayerInput
  422. {
  423. return inputHandler;
  424. }
  425.  
  426.  
  427. public function CheatGod2(on : bool)
  428. {
  429. if(on)
  430. SetImmortalityMode( AIM_Immortal, AIC_Default, true );
  431. else
  432. SetImmortalityMode( AIM_None, AIC_Default, true );
  433.  
  434. StaminaBoyInternal(on);
  435. }
  436.  
  437. public function IsInCombatState() : bool
  438. {
  439. var stateName : name;
  440. stateName = thePlayer.GetCurrentStateName();
  441. if ( stateName == 'Combat' || stateName == 'CombatSteel' || stateName == 'CombatSilver' || stateName == 'CombatFists' )
  442. {
  443. return true;
  444. }
  445. return false;
  446. }
  447.  
  448. public function DisableCombatState()
  449. {
  450. if ( IsInCombatState() )
  451. {
  452. GotoState( 'Exploration' );
  453. }
  454. }
  455.  
  456. protected function SetAbilityManager()
  457. {
  458. abilityManager = new W3PlayerAbilityManager in this;
  459. }
  460.  
  461.  
  462. event OnDamageFromBoids( damage : float )
  463. {
  464. var damageAction : W3DamageAction = new W3DamageAction in theGame.damageMgr;
  465.  
  466. damageAction.Initialize(NULL,this,NULL,'boid',EHRT_None,CPS_AttackPower,false,false,false,true);
  467. damageAction.AddDamage(theGame.params.DAMAGE_NAME_PHYSICAL,6.f);
  468. damageAction.SetHitAnimationPlayType(EAHA_ForceNo);
  469.  
  470.  
  471.  
  472. damageAction.SetSuppressHitSounds(true);
  473.  
  474. Log( "DAMAGE FROM BOID!!!!! " + damage );
  475.  
  476.  
  477. theGame.damageMgr.ProcessAction( damageAction );
  478.  
  479. delete damageAction;
  480. }
  481.  
  482.  
  483. function InitializeParryType()
  484. {
  485. var i, j : int;
  486.  
  487. parryTypeTable.Resize( EnumGetMax('EAttackSwingType')+1 );
  488. for( i = 0; i < EnumGetMax('EAttackSwingType')+1; i += 1 )
  489. {
  490. parryTypeTable[i].Resize( EnumGetMax('EAttackSwingDirection')+1 );
  491. }
  492. parryTypeTable[AST_Horizontal][ASD_UpDown] = PT_None;
  493. parryTypeTable[AST_Horizontal][ASD_DownUp] = PT_None;
  494. parryTypeTable[AST_Horizontal][ASD_LeftRight] = PT_None;
  495. parryTypeTable[AST_Horizontal][ASD_RightLeft] = PT_None;
  496. parryTypeTable[AST_Vertical][ASD_UpDown] = PT_None;
  497. parryTypeTable[AST_Vertical][ASD_DownUp] = PT_None;
  498. parryTypeTable[AST_Vertical][ASD_LeftRight] = PT_None;
  499. parryTypeTable[AST_Vertical][ASD_RightLeft] = PT_None;
  500. parryTypeTable[AST_DiagonalUp][ASD_UpDown] = PT_None;
  501. parryTypeTable[AST_DiagonalUp][ASD_DownUp] = PT_None;
  502. parryTypeTable[AST_DiagonalUp][ASD_LeftRight] = PT_None;
  503. parryTypeTable[AST_DiagonalUp][ASD_RightLeft] = PT_None;
  504. parryTypeTable[AST_DiagonalDown][ASD_UpDown] = PT_None;
  505. parryTypeTable[AST_DiagonalDown][ASD_DownUp] = PT_None;
  506. parryTypeTable[AST_DiagonalDown][ASD_LeftRight] = PT_None;
  507. parryTypeTable[AST_DiagonalDown][ASD_RightLeft] = PT_None;
  508. parryTypeTable[AST_Jab][ASD_UpDown] = PT_None;
  509. parryTypeTable[AST_Jab][ASD_DownUp] = PT_None;
  510. parryTypeTable[AST_Jab][ASD_LeftRight] = PT_None;
  511. parryTypeTable[AST_Jab][ASD_RightLeft] = PT_None;
  512. }
  513.  
  514. event OnPlayerTickTimer( deltaTime : float )
  515. {
  516. }
  517.  
  518. timer function PlayerTick( deltaTime : float , id : int)
  519. {
  520. /*addtomes_aerondighht_fix +++*/
  521. var sworditem : SItemUniqueId;
  522. /*addtomes_aerondighht_fix ---*/
  523.  
  524. deltaTime = theTimer.timeDeltaUnscaled;
  525. OnPlayerTickTimer( deltaTime );
  526. runes_fx(); //runes_fx
  527. if( !IsActionAllowed( EIAB_RunAndSprint ) )
  528. {
  529. movementLockType = PMLT_NoRun;
  530. }
  531. else if( !IsActionAllowed( EIAB_Sprint ) )
  532. {
  533. movementLockType = PMLT_NoSprint;
  534. }
  535. else
  536. {
  537. movementLockType = PMLT_Free;
  538. }
  539. swordscampfire(); //Swords Meditation
  540. //invisible weapons +++ ////////////////////////////////////////////////////////////////////////////////////////////////////////
  541. invisibleweapons2(); ///
  542. if(FactsQuerySum("draw_steel2")>0) { AddTimer('draw_steel2',0.001,false,,,false);FactsRemove("draw_steel2"); } ///
  543. if(FactsQuerySum("sheathe_steel2")>0) { AddTimer('sheathe_steel2',0.001,false,,,false);FactsRemove("sheathe_steel2"); } ///
  544. if(FactsQuerySum("draw_silver2")>0) { AddTimer('draw_silver2',0.001,false,,,false);FactsRemove("draw_silver2"); } ///
  545. if(FactsQuerySum("sheathe_silver2")>0) { AddTimer('sheathe_silver2',0.001,false,,,false);FactsRemove("sheathe_silver2"); } ///
  546. if(FactsQuerySum("draw_xbow2")>0) { AddTimer('draw_xbow2',0.001,false,,,false);FactsRemove("draw_xbow2"); } ///
  547. //invisible weapons --- ////////////////////////////////////////////////////////////////////////////////////////////////////////
  548. ///// this section should be before '}' in 'timer function PlayerTick'
  549. /*addtomes_invisible_fix ---*/
  550. if ( theGame.IsDialogOrCutscenePlaying() || thePlayer.IsSwimming() )
  551. { thePlayer.RemoveBuff( EET_Energy );
  552. thePlayer.RemoveBuff( EET_Blackfire );
  553. thePlayer.RemoveBuff( EET_Firewalkwithme );
  554. thePlayer.RemoveBuff( EET_Iceshield );
  555. thePlayer.RemoveBuff( EET_Assassin );
  556. thePlayer.RemoveBuff( EET_Abyss );
  557. thePlayer.RemoveBuff( EET_WeakeningAura );
  558. thePlayer.RemoveBuff( EET_Invisiblequen ); }
  559. /*addtomes_aerondighht_fix +++*/
  560. if ( thePlayer.GetInventory().GetItemEquippedOnSlot(EES_SilverSword, sworditem) )
  561. {
  562. if ( !thePlayer.GetInventory().IsItemHeld(sworditem) )
  563. {
  564. thePlayer.GetInventory().GetItemEntityUnsafe(sworditem).StopAllEffects();
  565. }
  566. }
  567. /*addtomes_aerondighht_fix ---*/
  568. magic_fists_spells();
  569. //addTomes
  570.  
  571. }
  572.  
  573. //MODEnableMimics
  574. timer function RefreshHead( deltaTime : float , id : int)
  575. {
  576. var acs : array< CComponent >;
  577. var head : name;
  578. var inv : CInventoryComponent;
  579. var hIds : array<SItemUniqueId>;
  580. var hId : SItemUniqueId;
  581. var i : int;
  582.  
  583. if(!theGame.IsDialogOrCutscenePlaying()){
  584. inv = thePlayer.GetInventory();
  585. hIds = inv.GetItemsByCategory('head');
  586.  
  587. i = hIds.Size();
  588. i -= 1;
  589. hId = hIds[i];
  590. head = inv.GetItemName(hId);
  591.  
  592. acs = thePlayer.GetComponentsByClassName( 'CHeadManagerComponent' );
  593. if( head == 'head_0' || head == 'head_0_mark' || head == 'head_0_tattoo' || head == 'head_0_mark_tattoo' || head == 'head_1' || head == 'head_1_mark' || head == 'head_1_tattoo' || head == 'head_1_mark_tattoo' || head == 'head_2' || head == 'head_2_mark' || head == 'head_2_tattoo' || head == 'head_2_mark_tattoo' || head == 'head_3' || head == 'head_3_mark' || head == 'head_3_tattoo' || head == 'head_3_mark_tattoo' || head == 'head_4' || head == 'head_4_mark' || head == 'head_4_tattoo' || head == 'head_4_mark_tattoo' ){
  594. ( ( CHeadManagerComponent ) acs[0] ).SetCustomHead( head );
  595. ( ( CHeadManagerComponent ) acs[0] ).BlockGrowing( false );
  596. }
  597. else{
  598. ( ( CHeadManagerComponent ) acs[0] ).SetCustomHead( head );
  599. if( RandF() > 0.81){
  600. ( ( CHeadManagerComponent ) acs[0] ).SetBeardStage( false, 3 );
  601. ( ( CHeadManagerComponent ) acs[0] ).BlockGrowing( false );
  602. }
  603. }
  604.  
  605. RemoveTimer( 'RefreshHead' );
  606. // theGame.GetGuiManager().ShowNotification( head );
  607. // Log("RefreshHead");
  608. // Log(head);
  609. }
  610. }
  611.  
  612. timer function BlinkingStart( deltaTime : float , id : int)
  613. {
  614. AddTimer( 'Blinking', 1.f, false, , , true );
  615.  
  616. RemoveTimer( 'BlinkingStart' );
  617. AddTimer( 'BlinkingStart', 9.f, true, , , true );
  618. }
  619.  
  620. timer function Blinking( deltaTime : float , id : int)
  621. {
  622. RemoveTimer( 'Blinking' );
  623. if(!theGame.IsDialogOrCutscenePlaying())
  624. blink();
  625. else {
  626. AddTimer( 'Blinking', 0.01, false, , , true );
  627. FactsAdd("mimic_reactivate");
  628. }
  629. }
  630.  
  631.  
  632. //invisible weapons/////////////////////////////////////////++ this whole section with timers should be right before 'function IsLookInputIgnored() : bool'
  633. //// CROSSBOW
  634. timer function draw_xbow2( time : float , id : int)
  635. {
  636. AddTimer('xbow_visible2',0.3);
  637. }
  638. timer function xbow_visible2( time : float , id : int)
  639. {
  640. FactsAdd("show_xbow2");
  641. }
  642. //// STEEL
  643. timer function draw_steel2( time : float , id : int)
  644. {
  645. AddTimer('steel_visible2',0.5);
  646. }
  647. timer function steel_visible2( time : float , id : int)
  648. {
  649. FactsAdd("show_steel2");
  650. FactsAdd("OnGrab_steel2");
  651. }
  652. timer function sheathe_steel2( time : float , id : int)
  653. {
  654. FactsAdd("hide_steel2");
  655. FactsAdd("OnPut_steel2");
  656. }
  657. //// SILVER
  658. timer function draw_silver2( time : float , id : int)
  659. {
  660. AddTimer('silver_visible2',0.5);
  661. }
  662. timer function silver_visible2( time : float , id : int)
  663. {
  664. FactsAdd("show_silver2");
  665. FactsAdd("OnGrab_silver2");
  666. }
  667. timer function sheathe_silver2( time : float , id : int)
  668. {
  669. FactsAdd("hide_silver2");
  670. FactsAdd("OnPut_silver2");
  671. }
  672. //invisible weapons///////////////////////////////////////////////////////////--
  673.  
  674. if(FactsDoesExist("mimic_reactivate")) {
  675. FactsRemove("mimic_reactivate");
  676. RefrezhHead();
  677. mtZZ();
  678. }
  679. }
  680.  
  681. function RefrezhHead()
  682. {
  683. var acs : array< CComponent >;
  684. var head : name;
  685. var inv : CInventoryComponent;
  686. var hIds : array<SItemUniqueId>;
  687. var hId : SItemUniqueId;
  688. var i : int;
  689.  
  690. if(!theGame.IsDialogOrCutscenePlaying()){
  691. inv = thePlayer.GetInventory();
  692. hIds = inv.GetItemsByCategory('head');
  693.  
  694. i = hIds.Size();
  695. i -= 1;
  696. hId = hIds[i];
  697. head = inv.GetItemName(hId);
  698.  
  699. acs = thePlayer.GetComponentsByClassName( 'CHeadManagerComponent' );
  700. if( head == 'head_0' || head == 'head_0_mark' || head == 'head_0_tattoo' || head == 'head_0_mark_tattoo' || head == 'head_1' || head == 'head_1_mark' || head == 'head_1_tattoo' || head == 'head_1_mark_tattoo' || head == 'head_2' || head == 'head_2_mark' || head == 'head_2_tattoo' || head == 'head_2_mark_tattoo' || head == 'head_3' || head == 'head_3_mark' || head == 'head_3_tattoo' || head == 'head_3_mark_tattoo' || head == 'head_4' || head == 'head_4_mark' || head == 'head_4_tattoo' || head == 'head_4_mark_tattoo' ){
  701. ( ( CHeadManagerComponent ) acs[0] ).SetCustomHead( head );
  702. ( ( CHeadManagerComponent ) acs[0] ).BlockGrowing( false );
  703. }
  704.  
  705. // theGame.GetGuiManager().ShowNotification( head );
  706. // Log("RefrezhHead");
  707. // Log(head);
  708. }
  709. }
  710.  
  711. function mtZZ()
  712. {
  713. var actors : array<CActor>;
  714. var actor : CActor;
  715. var i : int;
  716.  
  717. actors = GetActorsInRange( thePlayer, 1000, 999, , true );
  718.  
  719. for( i = 0; i < actors.Size(); i += 1 )
  720. {
  721. actor = (CActor) actors[i];
  722. if (actor.GetVoicetag() == 'GERALT')
  723. continue;
  724. if (actor.IsHuman() && actor.IsSpeaking() || actor.IsHuman() && actor.IsPlayingChatScene() || thePlayer.IsSpeaking()){
  725. actor.AddTag('MimiczTrigger');
  726. AddTimer( 'ZmtZZ', 0.01, false, , , true );
  727. continue;}
  728. if (actor.IsHuman())
  729. activateMimicsAndHiResShadows(actor);
  730. }
  731. }
  732.  
  733. timer function ZmtZZ( deltaTime : float , id : int)
  734. {
  735. var actors : array<CActor>;
  736. var actor : CActor;
  737. var i : int;
  738.  
  739. theGame.GetActorsByTag( 'MimiczTrigger', actors );
  740.  
  741. for( i = 0; i < actors.Size(); i += 1 )
  742. {
  743. actor = (CActor) actors[i];
  744. if (actor.GetVoicetag() == 'GERALT')
  745. continue;
  746. if (actor.IsHuman() && actor.IsSpeaking() || actor.IsHuman() && actor.IsPlayingChatScene() || thePlayer.IsSpeaking()){
  747. actor.AddTag('MimiczTrigger');
  748. AddTimer( 'ZmtZZ', 0.01, false, , , true );
  749. continue;
  750. }
  751. if (actor.IsHuman() && !thePlayer.IsSpeaking() && !actor.IsSpeaking() || !actor.IsPlayingChatScene()){
  752. actor.RemoveTag('MimiczTrigger');
  753. activateMimicsAndHiResShadows(actor);
  754. }
  755. else
  756. AddTimer( 'ZmtZZ', 0.01, false, , , true );
  757. }
  758. }
  759.  
  760. timer function QuickBlink( deltaTime : float , id : int)
  761. {
  762. var i : int;
  763. var actor : CActor;
  764. var actors : array<CActor>;
  765. RemoveTimer( 'QuickBlink' );
  766.  
  767. actors = GetActorsInRange( thePlayer, 20, 99, , true );
  768.  
  769. for ( i = 0; i < actors.Size(); i+= 1 )
  770. {
  771. actor = (CActor) actors[i];
  772. if ( actor.GetVoicetag() == 'GERALT' )
  773. continue;
  774. if(!actor.IsSpeaking())
  775. actor.PlayMimicAnimationAsync('blink_fast_face');
  776. }
  777. }
  778. //MODEnableMimics END
  779.  
  780.  
  781. function IsLookInputIgnored() : bool
  782. {
  783. return false;
  784. }
  785.  
  786. private var inputHeadingReady : bool;
  787. public function SetInputHeadingReady( flag : bool )
  788. {
  789. inputHeadingReady = flag;
  790. }
  791.  
  792. public function IsInputHeadingReady() : bool
  793. {
  794. return inputHeadingReady;
  795. }
  796.  
  797. var lastAxisInputIsMovement : bool;
  798. function HandleMovement( deltaTime : float )
  799. {
  800. var leftStickVector : Vector;
  801. var rightStickVector : Vector;
  802.  
  803. var rawLengthL : float;
  804. var rawLengthR : float;
  805.  
  806. var len : float;
  807. var i : int;
  808.  
  809. prevRawLeftJoyVec = rawLeftJoyVec;
  810. prevRawRightJoyVec = rawRightJoyVec;
  811.  
  812. rawLeftJoyVec.X = theInput.GetActionValue( 'GI_AxisLeftX' );
  813. rawLeftJoyVec.Y = theInput.GetActionValue( 'GI_AxisLeftY' );
  814.  
  815. if ( thePlayer.IsPCModeEnabled() )
  816. {
  817. rawRightJoyVec.X = theInput.GetActionValue( 'GI_MouseDampX' );
  818. rawRightJoyVec.Y = theInput.GetActionValue( 'GI_MouseDampY' );
  819. }
  820. else
  821. {
  822. rawRightJoyVec.X = theInput.GetActionValue( 'GI_AxisRightX' );
  823. rawRightJoyVec.Y = theInput.GetActionValue( 'GI_AxisRightY' );
  824. }
  825.  
  826. leftStickVector = rawLeftJoyVec;
  827. rightStickVector = rawRightJoyVec;
  828.  
  829.  
  830. if ( VecDot2D( prevRawLeftJoyVec, leftStickVector ) < 0.0f )
  831. {
  832. leftStickVector = lastValidLeftJoyVec;
  833. }
  834. else
  835. {
  836. lastValidLeftJoyVec = leftStickVector;
  837. }
  838. if ( VecDot2D( prevRawRightJoyVec, rightStickVector ) < 0.0f )
  839. {
  840. rightStickVector = lastValidRightJoyVec;
  841. }
  842. else
  843. {
  844. lastValidRightJoyVec = rightStickVector;
  845. }
  846.  
  847. rawLengthL = VecLength( leftStickVector );
  848. rawLengthR = VecLength( rightStickVector );
  849. SetBehaviorVariable( 'lAxisLength', ClampF( rawLengthL, 0.0f, 1.0f ) );
  850.  
  851.  
  852. rawLeftJoyRot = VecHeading( leftStickVector );
  853. rawRightJoyRot = VecHeading( rightStickVector );
  854.  
  855. if( rawLengthL > 0 )
  856. {
  857. bLAxisReleased = false;
  858. if( isSprinting )
  859. {
  860. if ( rawLengthL > 0.6 )
  861. {
  862. rawPlayerSpeed = 1.3;
  863. allowStopRunCheck = true;
  864. RemoveTimer( 'StopRunDelayedInputCheck' );
  865. }
  866. else
  867. {
  868. if ( allowStopRunCheck )
  869. {
  870. allowStopRunCheck = false;
  871. AddTimer( 'StopRunDelayedInputCheck', 0.25f, false );
  872. }
  873. }
  874. }
  875. else
  876. {
  877. if ( this.GetCurrentStateName() == 'Exploration' )
  878. {
  879. rawPlayerSpeed = 0.9*rawLengthL;
  880. }
  881. else
  882. {
  883. if ( rawLengthL > 0.6 )
  884. {
  885. rawPlayerSpeed = 0.8;
  886. }
  887. else
  888. {
  889. rawPlayerSpeed = 0.4;
  890. }
  891. }
  892. }
  893. }
  894. else
  895. {
  896. if ( isSprinting )
  897. {
  898. if ( allowStopRunCheck )
  899. {
  900. allowStopRunCheck = false;
  901. AddTimer( 'StopRunDelayedInputCheck', 0.25f, false );
  902. }
  903. }
  904. else
  905. {
  906. rawPlayerSpeed = 0.f;
  907. }
  908. bLAxisReleased = true;
  909. }
  910.  
  911. if ( rawLengthR > 0 )
  912. bRAxisReleased = false;
  913. else
  914. bRAxisReleased = true;
  915.  
  916. ProcessLAxisCaching();
  917.  
  918. SetBehaviorVariable( 'moveSpeedWhileCasting', rawPlayerSpeed );
  919.  
  920. if ( rawPlayerSpeed > 0.f )
  921. {
  922. rawPlayerHeading = AngleDistance( theCamera.GetCameraHeading(), -rawLeftJoyRot );
  923. if ( rawPlayerSpeed > 0.1f )
  924. {
  925. cachedRawPlayerHeading = rawPlayerHeading;
  926.  
  927. }
  928. if ( IsInCombatAction() )
  929. {
  930. canResetCachedCombatActionHeading = false;
  931. cachedCombatActionHeading = cachedRawPlayerHeading;
  932. }
  933. }
  934.  
  935.  
  936. rawPlayerAngle = AngleDistance( rawPlayerHeading, GetHeading() );
  937.  
  938. if ( !ProcessLockTargetSelectionInput( rightStickVector, rawLengthR ) )
  939. ProcessLockTargetSelectionInput( rightStickVector, rawLengthR );
  940. }
  941.  
  942. protected function ProcessLAxisCaching()
  943. {
  944. if ( bLAxisReleased )
  945. {
  946. if ( GetBIsCombatActionAllowed() )
  947. {
  948. if ( !lAxisReleaseCounterEnabled )
  949. {
  950. lAxisReleaseCounterEnabled = true;
  951. AddTimer( 'LAxisReleaseCounter', 0.25f );
  952. }
  953. }
  954.  
  955. if ( !lAxisReleaseCounterEnabledNoCA )
  956. {
  957. lAxisReleaseCounterEnabledNoCA = true;
  958. AddTimer( 'LAxisReleaseCounterNoCA', 0.2f );
  959. }
  960.  
  961. if ( !bRAxisReleased )
  962. {
  963. if ( thePlayer.IsPCModeEnabled() )
  964. {
  965. if ( lAxisReleasedAfterCounter )
  966. lastAxisInputIsMovement = false;
  967. }
  968. else
  969. lastAxisInputIsMovement = false;
  970. }
  971. }
  972. else
  973. {
  974. lAxisReleasedAfterCounter = false;
  975. lAxisReleasedAfterCounterNoCA = false;
  976. RemoveTimer( 'LAxisReleaseCounter' );
  977. RemoveTimer( 'LAxisReleaseCounterNoCA' );
  978. lAxisReleaseCounterEnabled = false;
  979. lAxisReleaseCounterEnabledNoCA = false;
  980.  
  981. lastAxisInputIsMovement = true;
  982. }
  983. }
  984.  
  985. public function ResetLastAxisInputIsMovement()
  986. {
  987. lastAxisInputIsMovement = true;
  988. }
  989.  
  990. private var bRAxisReleasedLastFrame : bool;
  991. private var selectTargetTime : float;
  992.  
  993. private var swipeMouseTimeStamp : float;
  994. private var swipeMouseDir : Vector;
  995. private var swipeMouseDist : float;
  996. private var enableSwipeCheck : bool;
  997. protected function ProcessLockTargetSelectionInput( rightStickVector : Vector, rawLengthR : float ) : bool
  998. {
  999. var currTime : float;
  1000. var rightStickVectorNormalized : Vector;
  1001. var dot : float;
  1002.  
  1003. if ( this.IsCameraLockedToTarget() )
  1004. {
  1005. currTime = theGame.GetEngineTimeAsSeconds();
  1006.  
  1007. if ( thePlayer.IsPCModeEnabled() )
  1008. {
  1009. if ( rawLengthR > 0.f )
  1010. {
  1011. rightStickVectorNormalized = VecNormalize( rightStickVector );
  1012.  
  1013. if ( enableSwipeCheck )
  1014. {
  1015. enableSwipeCheck = false;
  1016. swipeMouseTimeStamp = currTime;
  1017. swipeMouseDir = rightStickVector;
  1018. swipeMouseDist = 0.f;
  1019. }
  1020.  
  1021. dot = VecDot( swipeMouseDir, rightStickVector );
  1022.  
  1023. if ( dot > 0.8 )
  1024. {
  1025. swipeMouseDist += rawLengthR;
  1026. }
  1027. else
  1028. {
  1029. enableSwipeCheck = true;
  1030. return false;
  1031. }
  1032.  
  1033. swipeMouseDir = rightStickVector;
  1034.  
  1035.  
  1036. if ( currTime > swipeMouseTimeStamp + 0.2f )
  1037. {
  1038.  
  1039. swipeMouseDist = 0.f;
  1040. enableSwipeCheck = true;
  1041. }
  1042.  
  1043. }
  1044. else
  1045. {
  1046.  
  1047. swipeMouseDist = 0.f;
  1048. enableSwipeCheck = true;
  1049. }
  1050.  
  1051. if ( swipeMouseDist <= 350.f )
  1052. return true;
  1053. else
  1054. {
  1055. rightStickVector = rightStickVectorNormalized;
  1056. rawLengthR = VecLength( rightStickVector );
  1057. }
  1058. }
  1059.  
  1060. if ( bRAxisReleasedLastFrame )
  1061. {
  1062. if ( rawLengthR >= 0.3 )
  1063. {
  1064. inputHandler.OnCbtSelectLockTarget( rightStickVector );
  1065. selectTargetTime = currTime;
  1066. }
  1067. }
  1068. else if ( rawLengthR >= 0.3 && currTime > ( selectTargetTime + 0.5f ) )
  1069. {
  1070. inputHandler.OnCbtSelectLockTarget( rightStickVector );
  1071. selectTargetTime = currTime;
  1072. }
  1073. }
  1074.  
  1075. if ( rawLengthR < 0.3 )
  1076. bRAxisReleasedLastFrame = true;
  1077. else
  1078. bRAxisReleasedLastFrame = false;
  1079.  
  1080. return true;
  1081. }
  1082.  
  1083. public var lAxisReleasedAfterCounter : bool;
  1084. public var lAxisReleaseCounterEnabled : bool;
  1085. private timer function LAxisReleaseCounter( time : float , id : int)
  1086. {
  1087.  
  1088. if ( bLAxisReleased )
  1089. lAxisReleasedAfterCounter = true;
  1090. }
  1091.  
  1092. public var lAxisReleasedAfterCounterNoCA : bool;
  1093. public var lAxisReleaseCounterEnabledNoCA : bool;
  1094. private timer function LAxisReleaseCounterNoCA( time : float , id : int)
  1095. {
  1096.  
  1097. if ( bLAxisReleased )
  1098. lAxisReleasedAfterCounterNoCA = true;
  1099. }
  1100.  
  1101.  
  1102. timer function StopRunDelayedInputCheck( time : float, id : int)
  1103. {
  1104.  
  1105. allowStopRunCheck = true;
  1106. }
  1107.  
  1108. public function IsUITakeInput() : bool
  1109. {
  1110. return bUITakesInput;
  1111. }
  1112.  
  1113. public function SetUITakeInput ( val : bool )
  1114. {
  1115. bUITakesInput = val;
  1116. }
  1117.  
  1118. public function GetRawLeftJoyRot() : float
  1119. {
  1120. return rawLeftJoyRot;
  1121. }
  1122.  
  1123. public function SetIsActorLockedToTarget( flag : bool )
  1124. {
  1125. bActorIsLockedToTarget = flag;
  1126. }
  1127.  
  1128. public function IsActorLockedToTarget() : bool
  1129. {
  1130. return bActorIsLockedToTarget;
  1131. }
  1132.  
  1133.  
  1134. public function SetIsCameraLockedToTarget( flag : bool )
  1135. {
  1136. bBIsLockedToTarget = flag;
  1137. }
  1138.  
  1139. public function IsCameraLockedToTarget() : bool
  1140. {
  1141. return bBIsLockedToTarget;
  1142. }
  1143.  
  1144. public function IsLockedToTarget() : bool
  1145. {
  1146. return false;
  1147. }
  1148.  
  1149. public function EnableHardLock( flag : bool )
  1150. {
  1151. if ( !flag )
  1152. Log( "EnableHardLock : false" );
  1153.  
  1154. bIsHardLockedTotarget = flag;
  1155. }
  1156.  
  1157. public function IsHardLockEnabled() : bool
  1158. {
  1159. return bIsHardLockedTotarget;
  1160. }
  1161.  
  1162.  
  1163.  
  1164.  
  1165. function EnableBroadcastPresence( enable : bool )
  1166. {
  1167. if ( enable )
  1168. {
  1169. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'PlayerPresenceAction', -1.f , 10.0f, 3.f, -1, true);
  1170. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'PlayerPresenceActionFar', -1.f , 20.0f, 3.f, -1, true);
  1171. }
  1172. else
  1173. {
  1174. theGame.GetBehTreeReactionManager().RemoveReactionEvent(this, 'PlayerPresenceAction');
  1175. theGame.GetBehTreeReactionManager().RemoveReactionEvent(this, 'PlayerPresenceActionFar');
  1176. }
  1177. }
  1178.  
  1179. function RemoveReactions()
  1180. {
  1181. theGame.GetBehTreeReactionManager().RemoveReactionEvent( this, 'DrawSwordAction' );
  1182. theGame.GetBehTreeReactionManager().RemoveReactionEvent( this, 'CombatNearbyAction' );
  1183. theGame.GetBehTreeReactionManager().RemoveReactionEvent( this, 'AttackAction' );
  1184. theGame.GetBehTreeReactionManager().RemoveReactionEvent( this, 'CastSignAction' );
  1185. EnableBroadcastPresence(false);
  1186. }
  1187.  
  1188. function RestartReactionsIfNeeded()
  1189. {
  1190. EnableBroadcastPresence(true);
  1191.  
  1192.  
  1193.  
  1194. }
  1195.  
  1196.  
  1197.  
  1198.  
  1199. event OnBlockingSceneStarted( scene: CStoryScene )
  1200. {
  1201. super.OnBlockingSceneStarted( scene );
  1202. ClearAttitudes( true, false, false );
  1203. RaiseForceEvent( 'ForceIdle' );
  1204. RemoveReactions();
  1205. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( thePlayer, 'PlayerInScene', -1.f, 60.0f, -1, -1, true );
  1206. PushState( 'PlayerDialogScene' );
  1207.  
  1208. }
  1209.  
  1210. event OnBlockingSceneStarted_OnIntroCutscene( scene: CStoryScene )
  1211. {
  1212. SetImmortalityMode( AIM_Invulnerable, AIC_Scene );
  1213. SetTemporaryAttitudeGroup( 'geralt_friendly', AGP_Scenes);
  1214. }
  1215.  
  1216. event OnBlockingSceneEnded( optional output : CStorySceneOutput)
  1217. {
  1218. var exceptions : array<EInputActionBlock>;
  1219.  
  1220. super.OnBlockingSceneEnded( output );
  1221.  
  1222. RestartReactionsIfNeeded();
  1223.  
  1224. exceptions.PushBack(EIAB_Movement);
  1225. exceptions.PushBack(EIAB_RunAndSprint);
  1226. exceptions.PushBack(EIAB_Sprint);
  1227. this.BlockAllActions('SceneEnded',true,exceptions);
  1228.  
  1229. this.AddTimer('RemoveSceneEndedActionBlock',1.f,false);
  1230. }
  1231.  
  1232. private timer function RemoveSceneEndedActionBlock( dt : float , id : int)
  1233. {
  1234. this.BlockAllActions('SceneEnded',false);
  1235. if ( !thePlayer.IsInCombat() )
  1236. thePlayer.SetPlayerCombatStance( PCS_Normal );
  1237. }
  1238.  
  1239.  
  1240. public function SetDeathType( type : EPlayerDeathType )
  1241. {
  1242. SetBehaviorVariable( 'DeathType', (float) (int) type );
  1243. }
  1244.  
  1245. public function ResetDeathType()
  1246. {
  1247. SetDeathType( PDT_Normal );
  1248. }
  1249.  
  1250.  
  1251. event OnDeath( damageAction : W3DamageAction )
  1252. {
  1253. var attacker : CGameplayEntity;
  1254. var hud : CR4ScriptedHud;
  1255. var radialModule : CR4HudModuleRadialMenu;
  1256. var depth : float;
  1257. var guiManager : CR4GuiManager;
  1258.  
  1259. var allowDeath : bool;
  1260.  
  1261. super.OnDeath( damageAction );
  1262.  
  1263. ClearAttitudes( true, false, false );
  1264.  
  1265. attacker = damageAction.attacker;
  1266.  
  1267. depth = ((CMovingPhysicalAgentComponent)this.GetMovingAgentComponent()).GetSubmergeDepth();
  1268.  
  1269. if ( (W3ReplacerCiri)this )
  1270. {
  1271. allowDeath = true;
  1272. }
  1273. else if ( !IsUsingVehicle() && depth > -0.5 && !IsSwimming() && attacker && ((CNewNPC)attacker).GetNPCType() == ENGT_Guard )
  1274. {
  1275. ((CR4PlayerStateUnconscious)GetState('Unconscious')).OnKilledByGuard();
  1276. PushState( 'Unconscious' );
  1277. }
  1278. else if ( !IsUsingVehicle() && depth > -0.5 && !IsSwimming() && (W3Elevator)attacker )
  1279. {
  1280. ((CR4PlayerStateUnconscious)GetState('Unconscious')).OnKilledByElevator();
  1281. PushState( 'Unconscious' );
  1282. }
  1283. else if ( !IsUsingVehicle() && depth > -0.5 && !IsSwimming() && WillBeUnconscious() )
  1284. {
  1285. PushState( 'Unconscious' );
  1286. }
  1287. else
  1288. {
  1289. allowDeath = true;
  1290. }
  1291.  
  1292. if ( allowDeath )
  1293. {
  1294. SetAlive(false);
  1295.  
  1296. if ( IsUsingHorse( true ) || IsUsingBoat() )
  1297. {
  1298. }
  1299. else
  1300. {
  1301. RaiseForceEvent( 'Death' );
  1302.  
  1303. SetBehaviorVariable( 'Ragdoll_Weight', 1.f );
  1304. }
  1305.  
  1306. theGame.FadeOutAsync(DEATH_SCREEN_OPEN_DELAY - 0.1 );
  1307.  
  1308. hud = (CR4ScriptedHud)theGame.GetHud();
  1309.  
  1310. guiManager = theGame.GetGuiManager();
  1311. if (guiManager && guiManager.IsAnyMenu())
  1312. {
  1313. guiManager.GetRootMenu().CloseMenu();
  1314. }
  1315.  
  1316.  
  1317.  
  1318. if (hud)
  1319. {
  1320. hud.StartDeathTimer(DEATH_SCREEN_OPEN_DELAY);
  1321. }
  1322. else
  1323. {
  1324. AddTimer('OpenDeathScreen',DEATH_SCREEN_OPEN_DELAY,false);
  1325. }
  1326.  
  1327.  
  1328. if( hud )
  1329. {
  1330. radialModule = (CR4HudModuleRadialMenu)hud.GetHudModule("RadialMenuModule");
  1331. if (radialModule && radialModule.IsRadialMenuOpened())
  1332. {
  1333. radialModule.HideRadialMenu();
  1334. }
  1335. }
  1336. theTelemetry.LogWithLabel(TE_FIGHT_PLAYER_DIES, damageAction.attacker.ToString());
  1337. }
  1338. }
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349. event OnUnconsciousEnd()
  1350. {
  1351. if( GetCurrentStateName() == 'Unconscious' )
  1352. {
  1353. GotoStateAuto();
  1354. }
  1355. }
  1356.  
  1357.  
  1358.  
  1359.  
  1360. event OnDodgeBoost(){}
  1361.  
  1362.  
  1363. function StopRun()
  1364. {
  1365. SetSprintActionPressed(false,true);
  1366. SetIsSprinting( false );
  1367. }
  1368.  
  1369. function IsRunPressed() : bool
  1370. {
  1371. return true;
  1372.  
  1373. }
  1374.  
  1375.  
  1376. private var sprintButtonPressedTimestamp : float;
  1377.  
  1378. function SetSprintActionPressed( enable : bool, optional dontClearTimeStamp : bool )
  1379. {
  1380. sprintActionPressed = enable;
  1381. if ( !dontClearTimeStamp )
  1382. sprintButtonPressedTimestamp = theGame.GetEngineTimeAsSeconds();
  1383. }
  1384.  
  1385. public function GetHowLongSprintButtonWasPressed() : float
  1386. {
  1387. var duration : float;
  1388.  
  1389. if ( !sprintActionPressed || sprintButtonPressedTimestamp <= 0)
  1390. return -1;
  1391.  
  1392. duration = theGame.GetEngineTimeAsSeconds() - sprintButtonPressedTimestamp;
  1393.  
  1394. return duration;
  1395. }
  1396.  
  1397. function SetIsSprinting( flag : bool )
  1398. {
  1399.  
  1400. if( flag == isSprinting )
  1401. {
  1402. if ( flag && disableSprintingTimerEnabled )
  1403. {
  1404. disableSprintingTimerEnabled = false;
  1405. RemoveTimer( 'DisableSprintingTimer' );
  1406. }
  1407. return;
  1408. }
  1409.  
  1410. if ( flag )
  1411. {
  1412. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( thePlayer, 'PlayerSprintAction', -1, 10.0f, 0.5f, -1, true);
  1413. BreakPheromoneEffect();
  1414. RemoveTimer( 'DisableSprintingTimer' );
  1415. AddTimer('SprintingTimer', 0.01, true);
  1416. PauseStaminaRegen( 'Sprint' );
  1417. }
  1418. else
  1419. {
  1420. sprintingTime = 0.0f;
  1421. theGame.GetBehTreeReactionManager().RemoveReactionEvent( thePlayer, 'PlayerSprintAction' );
  1422. ResumeStaminaRegen( 'Sprint' );
  1423. EnableSprintingCamera( false );
  1424. }
  1425.  
  1426. isSprinting = flag;
  1427. SetBehaviorVariable( 'isSprinting', (int)isSprinting );
  1428. }
  1429.  
  1430. var sprintingCamera : bool;
  1431. function EnableSprintingCamera( flag : bool )
  1432. {
  1433. var camera : CCustomCamera;
  1434. var animation : SCameraAnimationDefinition;
  1435. var vel : float;
  1436.  
  1437. if( !theGame.IsUberMovementEnabled() && !useSprintingCameraAnim )
  1438. {
  1439. return;
  1440. }
  1441.  
  1442. if ( IsSwimming() || OnCheckDiving() )
  1443. flag = false;
  1444.  
  1445. camera = theGame.GetGameCamera();
  1446. if ( flag )
  1447. {
  1448.  
  1449. vel = VecLength( this.GetMovingAgentComponent().GetVelocity() );
  1450. if ( !sprintingCamera && vel > 6.5 )
  1451. {
  1452. if( useSprintingCameraAnim )
  1453. {
  1454. animation.animation = 'camera_shake_loop_lvl1_1';
  1455. animation.priority = CAP_High;
  1456. animation.blendIn = 1.f;
  1457. animation.blendOut = 1.f;
  1458. animation.weight = 1.5f;
  1459. animation.speed = 1.0f;
  1460. animation.loop = true;
  1461. animation.additive = true;
  1462. animation.reset = true;
  1463. camera.PlayAnimation( animation );
  1464. }
  1465.  
  1466. sprintingCamera = true;
  1467. }
  1468. }
  1469. else
  1470. {
  1471. sprintingCamera = false;
  1472. camera.StopAnimation('camera_shake_loop_lvl1_1');
  1473. }
  1474. }
  1475.  
  1476. var runningCamera : bool;
  1477. function EnableRunCamera( flag : bool )
  1478. {
  1479. var camera : CCustomCamera = theGame.GetGameCamera();
  1480. var animation : SCameraAnimationDefinition;
  1481. var vel : float;
  1482.  
  1483. if ( IsSwimming() || OnCheckDiving() )
  1484. flag = false;
  1485.  
  1486. if ( flag )
  1487. {
  1488. animation.animation = 'camera_shake_loop_lvl1_5';
  1489. animation.priority = CAP_High;
  1490. animation.blendIn = 1.f;
  1491. animation.blendOut = 1.f;
  1492. animation.weight = 0.7f;
  1493. animation.speed = 0.8f;
  1494. animation.loop = true;
  1495. animation.additive = true;
  1496. animation.reset = true;
  1497. camera.PlayAnimation( animation );
  1498. }
  1499. else
  1500. {
  1501. camera.StopAnimation('camera_shake_loop_lvl1_5');
  1502. }
  1503.  
  1504. runningCamera = flag;
  1505. }
  1506.  
  1507.  
  1508. protected timer function SprintingTimer(dt : float, id : int)
  1509. {
  1510. if ( !thePlayer.modifyPlayerSpeed )
  1511. {
  1512. sprintingTime += dt;
  1513.  
  1514.  
  1515. if ( ShouldDrainStaminaWhileSprinting() )
  1516. {
  1517. DrainStamina(ESAT_Sprint, 0, 0, '', dt);
  1518. }
  1519. }
  1520. }
  1521.  
  1522. protected function ShouldDrainStaminaWhileSprinting() : bool
  1523. {
  1524. var currentStateName : name;
  1525.  
  1526. if ( sprintingTime >= 3.0 || GetStaminaPercents() < 1.0 )
  1527. {
  1528. currentStateName = GetCurrentStateName();
  1529.  
  1530. if( currentStateName == 'Exploration' || currentStateName == 'CombatSteel' || currentStateName == 'CombatSilver' || currentStateName == 'CombatFists' )
  1531. {
  1532. return true;
  1533. }
  1534. }
  1535. return false;
  1536. }
  1537.  
  1538. protected function ShouldUseStaminaWhileSprinting() : bool
  1539. {
  1540. return true;
  1541. }
  1542.  
  1543. function GetIsSprinting() : bool
  1544. {
  1545. return isSprinting;
  1546. }
  1547.  
  1548. function GetSprintingTime() : float
  1549. {
  1550. if( !GetIsSprinting() )
  1551. {
  1552. return 0.0f;
  1553. }
  1554.  
  1555. return sprintingTime;
  1556. }
  1557.  
  1558.  
  1559. var disableSprintingTimerEnabled : bool;
  1560. timer function DisableSprintingTimer ( time : float , id : int)
  1561. {
  1562. disableSprintingTimerEnabled = false;
  1563. if ( !thePlayer.CanSprint( VecLength( rawLeftJoyVec ) ) )
  1564. {
  1565. thePlayer.RemoveTimer('SprintingTimer');
  1566. thePlayer.SetIsSprinting(false);
  1567. }
  1568. }
  1569.  
  1570. public function IsSprintActionPressed() : bool
  1571. {
  1572. return theInput.IsActionPressed('Sprint') || sprintToggle;
  1573. }
  1574.  
  1575. public function SetSprintToggle( flag : bool )
  1576. {
  1577. sprintToggle = flag;
  1578. }
  1579.  
  1580. public function GetIsSprintToggled() : bool
  1581. {
  1582. return sprintToggle;
  1583. }
  1584.  
  1585. public function SetWalkToggle( flag : bool )
  1586. {
  1587. walkToggle = flag;
  1588. }
  1589.  
  1590. public function GetIsWalkToggled() : bool
  1591. {
  1592. return walkToggle;
  1593. }
  1594.  
  1595. public function GetIsRunning() : bool
  1596. {
  1597. return isRunning;
  1598. }
  1599.  
  1600. public function SetIsRunning( flag : bool )
  1601. {
  1602. isRunning = flag;
  1603. }
  1604.  
  1605. function GetIsWalking() : bool
  1606. {
  1607. return isWalking;
  1608. }
  1609.  
  1610. function SetIsWalking( walking : bool )
  1611. {
  1612. isWalking = walking;
  1613. }
  1614.  
  1615. final function SetIsMovable( flag : bool )
  1616. {
  1617. isMovable = flag;
  1618. }
  1619.  
  1620. public function SetManualControl( movement : bool, camera : bool )
  1621. {
  1622. if( movement == false )
  1623. {
  1624. RaiseForceEvent( 'Idle' );
  1625. }
  1626. SetIsMovable( movement );
  1627. SetShowHud( movement );
  1628. }
  1629.  
  1630. final function GetIsMovable() : bool
  1631. {
  1632. return isMovable && inputHandler.IsActionAllowed(EIAB_Movement);
  1633. }
  1634.  
  1635. function SetBInteractionPressed( flag : bool )
  1636. {
  1637. bInteractionPressed = flag;
  1638. }
  1639.  
  1640. function GetBInteractionPressed() : bool
  1641. {
  1642. return bInteractionPressed;
  1643. }
  1644.  
  1645. function IsInCombatAction() : bool
  1646. {
  1647. return bIsInCombatAction;
  1648. }
  1649.  
  1650. function IsInCombatActionFriendly() : bool
  1651. {
  1652. return bIsInCombatActionFriendly;
  1653. }
  1654.  
  1655. public function IsInCombatAction_SpecialAttack() : bool
  1656. {
  1657. return false;
  1658. }
  1659.  
  1660. public function SetBIsInCombatAction(flag : bool)
  1661. {
  1662. if( flag )
  1663. {
  1664. thePlayer.SetBehaviorVariable( 'inJumpState', 1.f );
  1665.  
  1666. }
  1667. else
  1668. {
  1669. thePlayer.SetBehaviorVariable( 'inJumpState', 0.f );
  1670.  
  1671. }
  1672.  
  1673. bIsInCombatAction = flag;
  1674. SetBehaviorVariable( 'isInCombatActionForOverlay', (float)bIsInCombatAction );
  1675.  
  1676. }
  1677.  
  1678. public function SetBIsInCombatActionFriendly(flag : bool)
  1679. {
  1680. bIsInCombatActionFriendly = flag;
  1681. }
  1682.  
  1683. public function RaiseCombatActionFriendlyEvent() : bool
  1684. {
  1685. if ( CanRaiseCombatActionFriendlyEvent() )
  1686. {
  1687. if( RaiseEvent('CombatActionFriendly') )
  1688. {
  1689. SetBIsInCombatActionFriendly( true );
  1690. return true;
  1691. }
  1692. }
  1693.  
  1694. return false;
  1695. }
  1696.  
  1697. public function CanRaiseCombatActionFriendlyEvent( optional isShootingCrossbow : bool ) : bool
  1698. {
  1699. var raiseEvent : bool = false;
  1700. var playerWitcher : W3PlayerWitcher;
  1701. var itemId : SItemUniqueId;
  1702.  
  1703. playerWitcher = (W3PlayerWitcher)this;
  1704.  
  1705. if ( !playerWitcher )
  1706. return true;
  1707. else if ( isShootingCrossbow )
  1708. return true;
  1709. else if ( thePlayer.IsOnBoat() && !thePlayer.IsCombatMusicEnabled() )
  1710. return true;
  1711. else
  1712. {
  1713. itemId = thePlayer.GetSelectedItemId();
  1714. if ( !( playerWitcher.IsHoldingItemInLHand() && inv.IsIdValid(itemId) && !inv.IsItemCrossbow(itemId) && !inv.IsItemBomb(itemId) ) )
  1715. return true;
  1716. }
  1717.  
  1718. thePlayer.DisplayActionDisallowedHudMessage( EIAB_Undefined,,, true );
  1719. return false;
  1720. }
  1721.  
  1722.  
  1723. final function CanParryAttack() : bool
  1724. {
  1725. return inputHandler.IsActionAllowed(EIAB_Parry) && ParryCounterCheck() && !IsCurrentlyDodging() && super.CanParryAttack();
  1726. }
  1727.  
  1728.  
  1729. protected function ParryCounterCheck() : bool
  1730. {
  1731. var combatActionType : int;
  1732. combatActionType = (int)GetBehaviorVariable( 'combatActionType');
  1733.  
  1734. if ( combatActionType == (int)CAT_Parry )
  1735. return true;
  1736.  
  1737. if ( GetBIsCombatActionAllowed() )
  1738. return true;
  1739.  
  1740. if ( thePlayer.IsInCombatAction() && combatActionType == (int)CAT_Dodge )
  1741. {
  1742. if ( thePlayer.CanPlayHitAnim() && thePlayer.IsThreatened() )
  1743. {
  1744. return true;
  1745. }
  1746. }
  1747.  
  1748. return false;
  1749. }
  1750.  
  1751.  
  1752. function SetIsHorseMounted( isOn : bool )
  1753. {
  1754. isHorseMounted = isOn;
  1755. }
  1756.  
  1757. function GetIsHorseMounted() : bool
  1758. {
  1759. return isHorseMounted;
  1760. }
  1761.  
  1762.  
  1763. function SetIsCompanionFollowing( isOn : bool )
  1764. {
  1765. isCompanionFollowing = isOn;
  1766. }
  1767. function GetIsCompanionFollowing() : bool
  1768. {
  1769. return isCompanionFollowing;
  1770. }
  1771.  
  1772. function SetStartScreenIsOpened( isOpened : bool) : void
  1773. {
  1774. bStartScreenIsOpened = isOpened;
  1775.  
  1776.  
  1777. if( isOpened )
  1778. theSound.EnterGameState( ESGS_MusicOnly );
  1779. else
  1780. theSound.LeaveGameState( ESGS_MusicOnly );
  1781. }
  1782.  
  1783. function GetStartScreenIsOpened( ) : bool
  1784. {
  1785. return bStartScreenIsOpened;
  1786. }
  1787.  
  1788. function SetEndScreenIsOpened( isOpened : bool) : void
  1789. {
  1790. bEndScreenIsOpened = isOpened;
  1791.  
  1792.  
  1793. if( isOpened )
  1794. theSound.EnterGameState( ESGS_MusicOnly );
  1795. else
  1796. theSound.LeaveGameState( ESGS_MusicOnly );
  1797. }
  1798.  
  1799. function GetEndScreenIsOpened( ) : bool
  1800. {
  1801. return bEndScreenIsOpened;
  1802. }
  1803.  
  1804. function SetStartScreenFadeDuration( fadeTime : float) : void
  1805. {
  1806. fStartScreenFadeDuration = fadeTime;
  1807. }
  1808.  
  1809. function GetStartScreenFadeDuration( ) : float
  1810. {
  1811. return fStartScreenFadeDuration;
  1812. }
  1813.  
  1814. function SetStartScreenFadeInDuration( fadeTime : float) : void
  1815. {
  1816. fStartScreenFadeInDuration = fadeTime;
  1817. }
  1818.  
  1819. function GetStartScreenFadeInDuration( ) : float
  1820. {
  1821. return fStartScreenFadeInDuration;
  1822. }
  1823.  
  1824. function SetStartScreenEndWithBlackScreen( value : bool ) : void
  1825. {
  1826. bStartScreenEndWithBlackScreen = value;
  1827. }
  1828.  
  1829. function GetStartScreenEndWithBlackScreen( ) : bool
  1830. {
  1831. return bStartScreenEndWithBlackScreen;
  1832. }
  1833.  
  1834.  
  1835.  
  1836. public function CanStartTalk() : bool
  1837. {
  1838. var stateName : name;
  1839. stateName = thePlayer.GetCurrentStateName();
  1840. return ( stateName != 'CombatSteel' && stateName != 'CombatSilver' && stateName != 'CombatFists' );
  1841. }
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847. public function UpdateRequestedDirectionVariables_PlayerDefault()
  1848. {
  1849. UpdateRequestedDirectionVariables( rawPlayerHeading, GetHeading() );
  1850. }
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856. function SetGuarded( flag : bool )
  1857. {
  1858. super.SetGuarded(flag);
  1859. SetParryEnabled(IsGuarded());
  1860.  
  1861. if ( !thePlayer.IsInCombat() )
  1862. {
  1863. if ( flag )
  1864. OnDelayOrientationChange();
  1865. else
  1866. thePlayer.EnableManualCameraControl( true, 'Guard' );
  1867. }
  1868.  
  1869.  
  1870. }
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877. event OnDelayOrientationChange();
  1878.  
  1879. function SetBIsInputAllowed( flag : bool, sourceName : name )
  1880. {
  1881. bIsInputAllowed = flag;
  1882.  
  1883. if(flag)
  1884. {
  1885. debug_BIsInputAllowedLocks.Clear();
  1886. }
  1887. else
  1888. {
  1889. debug_BIsInputAllowedLocks.PushBack(sourceName);
  1890. }
  1891. }
  1892.  
  1893. function GetBIsInputAllowed() : bool
  1894. {
  1895. return bIsInputAllowed;
  1896. }
  1897.  
  1898. function SetBIsFirstAttackInCombo( flag : bool )
  1899. {
  1900. bIsFirstAttackInCombo = flag;
  1901. }
  1902.  
  1903. function IsInHitAnim() : bool
  1904. {
  1905. return bIsInHitAnim;
  1906. }
  1907.  
  1908. function SetIsInHitAnim( flag : bool )
  1909. {
  1910. bIsInHitAnim = flag;
  1911. }
  1912.  
  1913. function SetInputModuleNeededToRun( _inputModuleNeededToRun : float )
  1914. {
  1915. inputModuleNeededToRun = ClampF(_inputModuleNeededToRun, 0.5f, 1.f);
  1916. }
  1917.  
  1918. function GetInputModuleNeededToRun() : float
  1919. {
  1920. var configValue:string;
  1921.  
  1922. if (inputModuleNeededToRun == -1.0)
  1923. {
  1924. configValue = ((CInGameConfigWrapper)theGame.GetInGameConfigWrapper()).GetVarValue('Controls', 'LeftStickSensitivity');
  1925. inputModuleNeededToRun = StringToFloat(configValue, 0.7);
  1926. }
  1927.  
  1928. return inputModuleNeededToRun;
  1929. }
  1930.  
  1931.  
  1932.  
  1933. event OnAnimEvent_AllowInput( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  1934. {
  1935. if ( animEventType == AET_DurationStart )
  1936. {
  1937.  
  1938. SetBIsInputAllowed( true, 'AnimEventAllowInputStart' );
  1939. }
  1940.  
  1941. }
  1942.  
  1943. event OnAnimEvent_DisallowInput( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  1944. {
  1945. if ( animEventType == AET_DurationStart )
  1946. {
  1947. SetBIsInputAllowed( false, 'AnimEventDisallowInputStart' );
  1948. }
  1949. else if ( animEventType == AET_DurationEnd )
  1950. {
  1951. SetBIsInputAllowed( true, 'AnimEventDisallowInputEnd' );
  1952. }
  1953. }
  1954.  
  1955. event OnAnimEvent_DisallowHitAnim( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  1956. {
  1957. if ( animEventType == AET_DurationEnd )
  1958. {
  1959. SetCanPlayHitAnim( true );
  1960. }
  1961. else if ( ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack && !this.bIsFirstAttackInCombo )
  1962. || ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Dodge && GetBehaviorVariable( 'isRolling' ) == 0.f ) )
  1963. {
  1964. }
  1965. else
  1966. {
  1967. SetCanPlayHitAnim( false );
  1968. }
  1969. }
  1970.  
  1971. event OnAnimEvent_AllowHitAnim( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  1972. {
  1973. SetCanPlayHitAnim( true );
  1974. }
  1975.  
  1976. event OnAnimEvent_AllowBlend( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  1977. {
  1978. SetCanPlayHitAnim( true );
  1979. }
  1980.  
  1981. event OnAnimEvent_QuickSlotItems( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  1982. {
  1983. var itemEntity : W3UsableItem;
  1984.  
  1985. if( animEventName == 'EquipItem' && currentlyUsedItem )
  1986. {
  1987. inv.MountItem( currentlyEquipedItem, true );
  1988. }
  1989. else if( animEventName == 'UseItem' && currentlyUsedItem )
  1990. {
  1991. currentlyUsedItem.OnUsed( this );
  1992. }
  1993. else if( animEventName == 'HideItem' )
  1994. {
  1995. inv.UnmountItem( currentlyEquipedItem, true );
  1996. currentlyEquipedItem = GetInvalidUniqueId();
  1997. }
  1998. else if( animEventName == 'EquipItemL' )
  1999. {
  2000. if ( thePlayer.IsHoldingItemInLHand() )
  2001. {
  2002. inv.MountItem( currentlyEquipedItemL, true );
  2003.  
  2004.  
  2005.  
  2006.  
  2007. thePlayer.StartWaitForItemSpawnAndProccesTask();
  2008. }
  2009. }
  2010. else if( ( animEventName == 'UseItemL' || animEventName == 'ItemUseL') )
  2011. {
  2012.  
  2013.  
  2014. thePlayer.AllowUseSelectedItem();
  2015. }
  2016. else if( animEventName == 'HideItemL' )
  2017. {
  2018.  
  2019. thePlayer.KillWaitForItemSpawnAndProccesTask();
  2020.  
  2021. if ( currentlyUsedItemL )
  2022. {
  2023. currentlyUsedItemL.OnHidden( this );
  2024. currentlyUsedItemL.SetVisibility( false );
  2025. }
  2026. inv.UnmountItem( currentlyEquipedItemL, true );
  2027.  
  2028. }
  2029. }
  2030.  
  2031. event OnAnimEvent_SetRagdoll( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2032. {
  2033. if ( ( ( CMovingPhysicalAgentComponent ) this.GetMovingAgentComponent() ).HasRagdoll() )
  2034. {
  2035. if ( this == thePlayer && !thePlayer.IsOnBoat() )
  2036. {
  2037. TurnOnRagdoll();
  2038.  
  2039. }
  2040. }
  2041. }
  2042.  
  2043.  
  2044. event OnAnimEvent_InAirKDCheck( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2045. {
  2046. if(IsInAir())
  2047. {
  2048. TurnOnRagdoll();
  2049. }
  2050. }
  2051.  
  2052. private var illusionMedallion : array<SItemUniqueId>;
  2053.  
  2054. event OnAnimEvent_EquipMedallion( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2055. {
  2056. illusionMedallion.Clear();
  2057. illusionMedallion = inv.GetItemsByName( 'Illusion Medallion' );
  2058. inv.MountItem( illusionMedallion[0], true );
  2059. }
  2060.  
  2061. event OnAnimEvent_HideMedallion( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2062. {
  2063. inv.UnmountItem( illusionMedallion[0], true );
  2064. illusionMedallion.Clear();
  2065. }
  2066.  
  2067.  
  2068.  
  2069.  
  2070. event OnDiving(dir : int){}
  2071. event OnDive(){}
  2072.  
  2073.  
  2074. event OnCheckDiving() { return false; }
  2075. event OnAllowShallowWaterCheck() { return true; }
  2076. event OnCheckUnconscious() { return false; }
  2077. event OnAllowSwimmingSprint() { return false; }
  2078. event OnAllowedDiveDown() { return true; }
  2079. event OnDiveInput( divePitch : float ){}
  2080.  
  2081. event OnIsCameraUnderwater()
  2082. {
  2083.  
  2084.  
  2085. return false;
  2086. }
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095. event OnHitGround()
  2096. {
  2097. }
  2098.  
  2099. event OnHitCeiling()
  2100. {
  2101. }
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109. private function SetTerrModifier( val : float )
  2110. {
  2111. SetBehaviorVariable( 'TerrainModifier', val );
  2112. terrModifier = val;
  2113. }
  2114.  
  2115. private function SetTerrTypeOne( type : ETerrainType )
  2116. {
  2117. SetBehaviorVariable( 'TerrainType', (int)type );
  2118. terrTypeOne = type;
  2119. }
  2120.  
  2121. private function SetTerrTypeTwo( type : ETerrainType )
  2122. {
  2123. SetBehaviorVariable( 'TerrainTypeBlended', (int)type );
  2124. terrTypeTwo = type;
  2125. }
  2126.  
  2127. public function SteppedOnTerrain( type : ETerrainType )
  2128. {
  2129.  
  2130. if( type != terrTypeOne && type != terrTypeTwo )
  2131. {
  2132. if( terrTypeOne == prevTerrType )
  2133. {
  2134.  
  2135. SetTerrTypeTwo( type );
  2136. SetTerrModifier( 0.01f );
  2137. }
  2138. else if( terrTypeTwo == prevTerrType )
  2139. {
  2140. SetTerrTypeOne( type );
  2141. SetTerrModifier( 0.99f );
  2142. }
  2143. }
  2144.  
  2145. if( type == terrTypeOne )
  2146. {
  2147. terrModifier -= 0.1f;
  2148. }
  2149. else if( type == terrTypeTwo )
  2150. {
  2151. terrModifier += 0.1f;
  2152. }
  2153.  
  2154. terrModifier = ClampF( terrModifier, 0.01f, 0.99f );
  2155.  
  2156. SetBehaviorVariable( 'TerrainModifier', terrModifier );
  2157.  
  2158. prevTerrType = type;
  2159. }
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167. function PlayerCanComment() : bool
  2168. {
  2169. var time : EngineTime;
  2170. time = commentaryLastTime + commentaryCooldown;
  2171.  
  2172. return theGame.GetEngineTime() > time;
  2173. }
  2174.  
  2175. function PlayerCanPlayMonsterCommentary() : bool
  2176. {
  2177. var time : EngineTime;
  2178. var commentaryMonsterCooldown : float;
  2179.  
  2180. commentaryMonsterCooldown = 120.0f;
  2181. time = commentaryLastTime + commentaryMonsterCooldown;
  2182.  
  2183. return theGame.GetEngineTime() > time;
  2184. }
  2185.  
  2186. function PlayerCommentary( commentaryType : EPlayerCommentary, optional newCommentaryCooldown : float )
  2187. {
  2188. var actor : CPlayer = thePlayer;
  2189. var activeActor : CEntity;
  2190. var hud : CR4ScriptedHud;
  2191.  
  2192. hud = (CR4ScriptedHud)theGame.GetHud();
  2193. activeActor = (CEntity) actor;
  2194.  
  2195. commentaryLastTime = theGame.GetEngineTime();
  2196.  
  2197. if( newCommentaryCooldown > 0.0f )
  2198. {
  2199. commentaryCooldown = newCommentaryCooldown;
  2200. }
  2201. else
  2202. {
  2203. commentaryCooldown = 20.0f;
  2204. }
  2205. if( commentaryType == PC_MedalionWarning )
  2206. {
  2207. PlayVoiceset( 1, "warning" );
  2208. hud.ShowOneliner( "My medallion", activeActor );
  2209. AddTimer( 'TurnOffOneliner', 3.5f );
  2210.  
  2211. }
  2212. else if( commentaryType == PC_MonsterReaction )
  2213. {
  2214. PlayVoiceset( 1, "monster" );
  2215. }
  2216.  
  2217. else if( commentaryType == PC_ColdWaterComment )
  2218. {
  2219.  
  2220. hud.ShowOneliner( "Damn, it's cold!", activeActor );
  2221. AddTimer( 'TurnOffOneliner', 3.5f );
  2222. }
  2223. }
  2224.  
  2225. timer function TurnOffOneliner( deltaTime : float , id : int)
  2226. {
  2227. var hud : CR4ScriptedHud;
  2228. hud = (CR4ScriptedHud)theGame.GetHud();
  2229. hud.HideOneliner( this );
  2230. }
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238. public function CanPlaySpecificVoiceset() : bool { return canPlaySpecificVoiceset; }
  2239. public function SetCanPlaySpecificVoiceset( val : bool ) { canPlaySpecificVoiceset = val; }
  2240. timer function ResetSpecificVoicesetFlag( dt : float, id : int ) { SetCanPlaySpecificVoiceset( true ); }
  2241.  
  2242. function GetThreatLevel() : int
  2243. {
  2244. return 5;
  2245. }
  2246.  
  2247. function GetBIsCombatActionAllowed() : bool
  2248. {
  2249. return true;
  2250. }
  2251.  
  2252. import function SetEnemyUpscaling( b : bool );
  2253. import public function GetEnemyUpscaling() : bool;
  2254.  
  2255. public function SetAutoCameraCenter( on : bool ) { autoCameraCenterToggle = on; }
  2256. public function GetAutoCameraCenter() : bool
  2257. {
  2258. return autoCameraCenterToggle || IsCameraLockedToTarget();
  2259. }
  2260.  
  2261. public function SetVehicleCachedSign( sign : ESignType ) { vehicleCachedSign = sign; }
  2262. public function GetVehicleCachedSign() : ESignType { return vehicleCachedSign; }
  2263.  
  2264. public function GetMoney() : int
  2265. {
  2266. return inv.GetMoney();
  2267. }
  2268.  
  2269. public function AddMoney(amount : int)
  2270. {
  2271. inv.AddMoney(amount);
  2272. }
  2273.  
  2274. public function RemoveMoney(amount : int)
  2275. {
  2276. inv.RemoveMoney(amount);
  2277. }
  2278.  
  2279. function GetThrowItemMode() : bool
  2280. {
  2281. return false;
  2282. }
  2283.  
  2284. function GetEquippedSign() : ESignType
  2285. {
  2286. return ST_None;
  2287. }
  2288.  
  2289. function GetCurrentlyCastSign() : ESignType
  2290. {
  2291. return ST_None;
  2292. }
  2293.  
  2294. function IsCastingSign() : bool
  2295. {
  2296. return false;
  2297. }
  2298.  
  2299. function IsCurrentSignChanneled() : bool
  2300. {
  2301. return false;
  2302. }
  2303.  
  2304.  
  2305. function OnRadialMenuItemChoose( selectedItem : string )
  2306. {
  2307.  
  2308. }
  2309.  
  2310.  
  2311. public function UpdateQuickSlotItems() : bool
  2312. {
  2313. return false;
  2314. }
  2315.  
  2316.  
  2317. public function SetUpdateQuickSlotItems(bUpdate : bool )
  2318. {
  2319.  
  2320. }
  2321.  
  2322. public function RemoveAllPotionEffects(optional skip : array<CBaseGameplayEffect>)
  2323. {
  2324. effectManager.RemoveAllPotionEffects(skip);
  2325. }
  2326.  
  2327. public function BreakPheromoneEffect() : bool
  2328. {
  2329. if( thePlayer.HasBuff( EET_PheromoneNekker ) || thePlayer.HasBuff( EET_PheromoneDrowner ) || thePlayer.HasBuff( EET_PheromoneBear ) )
  2330. {
  2331. thePlayer.RemoveBuff( EET_PheromoneNekker );
  2332. thePlayer.RemoveBuff( EET_PheromoneDrowner );
  2333. thePlayer.RemoveBuff( EET_PheromoneBear );
  2334. }
  2335.  
  2336. return true;
  2337. }
  2338.  
  2339.  
  2340.  
  2341. public function GetCurrentTrackedQuestSystemObjectives() : array<SJournalQuestObjectiveData>
  2342. {
  2343. return currentTrackedQuestSystemObjectives;
  2344. }
  2345.  
  2346. public function SetCurrentTrackedQuestSystemObjectives(cTQO : array<SJournalQuestObjectiveData>) : void
  2347. {
  2348. var i : int;
  2349.  
  2350. currentTrackedQuestSystemObjectives = cTQO;
  2351.  
  2352. for(i = 0; i < cTQO.Size(); i+=1)
  2353. {
  2354. currentTrackedQuestSystemObjectives[i] = cTQO[i];
  2355. }
  2356. }
  2357.  
  2358. public function GetCurrentTrackedQuestObjectives() : array<SJournalQuestObjectiveData>
  2359. {
  2360. return currentTrackedQuestObjectives;
  2361. }
  2362.  
  2363. public function SetCurrentTrackedQuestObjectives(cTQO : array<SJournalQuestObjectiveData>) : void
  2364. {
  2365. var i : int;
  2366.  
  2367. currentTrackedQuestObjectives = cTQO;
  2368.  
  2369. for(i = 0; i < cTQO.Size(); i+=1)
  2370. {
  2371. currentTrackedQuestObjectives[i] = cTQO[i];
  2372. }
  2373. }
  2374.  
  2375. public function GetCurrentTrackedQuestGUID() : CGUID
  2376. {
  2377. return currentTrackedQuestGUID;
  2378. }
  2379.  
  2380. public function SetCurrentTrackedQuestGUID(cTQG : CGUID) : void
  2381. {
  2382. currentTrackedQuestGUID = cTQG;
  2383. }
  2384.  
  2385.  
  2386. public function HAXCheckIfNew(checkGUID : CGUID ):bool
  2387. {
  2388. var i : int;
  2389. for( i = 0; i < HAXNewObjTable.Size(); i += 1)
  2390. {
  2391. if( HAXNewObjTable[i] == checkGUID)
  2392. {
  2393. return false;
  2394. }
  2395. }
  2396.  
  2397. HAXNewObjTable.PushBack(checkGUID);
  2398. return true;
  2399. }
  2400.  
  2401. public function GetShowHud() : bool
  2402. {
  2403. return true;
  2404. }
  2405.  
  2406. public function SetShowHud( value : bool ) : void
  2407. {
  2408.  
  2409. }
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415. function DebugKillAll()
  2416. {
  2417. var i, enemiesSize : int;
  2418. var actors : array<CActor>;
  2419.  
  2420. actors = GetNPCsAndPlayersInRange(20, 20, '', FLAG_Attitude_Hostile);
  2421. enemiesSize = actors.Size();
  2422.  
  2423. for( i = 0; i < enemiesSize; i += 1 )
  2424. actors[i].Kill( 'Debug', false, this);
  2425. }
  2426.  
  2427. public function DebugTeleportToPin( optional posX : float , optional posY : float )
  2428. {
  2429. var mapManager : CCommonMapManager = theGame.GetCommonMapManager();
  2430. var rootMenu : CR4Menu;
  2431. var mapMenu : CR4MapMenu;
  2432. var currWorld : CWorld = theGame.GetWorld();
  2433. var destWorldPath : string;
  2434. var id : int;
  2435. var area : int;
  2436. var type : int;
  2437. var position : Vector;
  2438. var rotation : EulerAngles;
  2439. var goToCurrent : Bool = false;
  2440.  
  2441. rootMenu = (CR4Menu)theGame.GetGuiManager().GetRootMenu();
  2442.  
  2443. if ( rootMenu )
  2444. {
  2445. mapMenu = (CR4MapMenu)rootMenu.GetSubMenu();
  2446.  
  2447. if ( mapMenu )
  2448. {
  2449. position.X = posX;
  2450. position.Y = posY;
  2451. destWorldPath = mapManager.GetWorldPathFromAreaType( mapMenu.GetShownMapType() );
  2452.  
  2453. if ( mapMenu.IsCurrentAreaShown() )
  2454. {
  2455. goToCurrent = true;
  2456. }
  2457.  
  2458. rootMenu.CloseMenu();
  2459. }
  2460. }
  2461. else
  2462. {
  2463. mapManager.GetUserMapPinByIndex( 0, id, area, position.X, position.Y, type );
  2464. destWorldPath = mapManager.GetWorldPathFromAreaType( area );
  2465.  
  2466. if (destWorldPath == "" || destWorldPath == currWorld.GetPath() )
  2467. {
  2468. goToCurrent = true;
  2469. }
  2470. }
  2471.  
  2472. if ( goToCurrent )
  2473. {
  2474. currWorld.NavigationComputeZ(position, -500.f, 500.f, position.Z);
  2475. currWorld.NavigationFindSafeSpot(position, 0.5f, 20.f, position);
  2476.  
  2477. Teleport( position );
  2478.  
  2479. if ( !currWorld.NavigationComputeZ(position, -500.f, 500.f, position.Z) )
  2480. {
  2481. AddTimer( 'DebugWaitForNavigableTerrain', 1.f, true );
  2482. }
  2483. }
  2484. else
  2485. {
  2486. theGame.ScheduleWorldChangeToPosition( destWorldPath, position, rotation );
  2487. AddTimer( 'DebugWaitForNavigableTerrain', 1.f, true, , , true );
  2488. }
  2489. }
  2490.  
  2491. timer function DebugWaitForNavigableTerrain( delta : float, id : int )
  2492. {
  2493. var position : Vector = GetWorldPosition();
  2494.  
  2495. if ( theGame.GetWorld().NavigationComputeZ(position, -1000.f, 1000.f, position.Z) )
  2496. {
  2497. RemoveTimer( 'DebugWaitForNavigableTerrain' );
  2498. theGame.GetWorld().NavigationFindSafeSpot(position, 0.5f, 20.f, position);
  2499. Teleport( position );
  2500. }
  2501. }
  2502.  
  2503. event OnHitByObstacle( obstacleComponent : CComponent )
  2504. {
  2505. obstacleComponent.SetEnabled( false );
  2506. }
  2507.  
  2508. public function DEBUGGetDisplayRadiusMinimapIcons():bool
  2509. {
  2510. return _DEBUGDisplayRadiusMinimapIcons;
  2511. }
  2512.  
  2513. public function DEBUGSetDisplayRadiusMinimapIcons(inValue : bool):void
  2514. {
  2515. _DEBUGDisplayRadiusMinimapIcons = inValue;
  2516. }
  2517.  
  2518. public function Dbg_UnlockAllActions()
  2519. {
  2520. inputHandler.Dbg_UnlockAllActions();
  2521. }
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  
  2527. event OnCriticalStateAnimStopGlobalHack()
  2528. {
  2529. var buff : CBaseGameplayEffect;
  2530.  
  2531. if(!csNormallyStoppedBuff)
  2532. {
  2533. if(effectManager)
  2534. {
  2535. buff = effectManager.GetCurrentlyAnimatedCS();
  2536. if(buff)
  2537. OnCriticalStateAnimStop();
  2538. }
  2539. }
  2540. else
  2541. {
  2542. csNormallyStoppedBuff = false;
  2543. }
  2544. }
  2545.  
  2546. private var csNormallyStoppedBuff : bool;
  2547.  
  2548.  
  2549. event OnCriticalStateAnimStop()
  2550. {
  2551. csNormallyStoppedBuff = true;
  2552.  
  2553. SetBehaviorVariable( 'bCriticalState', 0);
  2554. CriticalStateAnimStopped(false);
  2555. if ( this.IsRagdolled() )
  2556. this.RaiseForceEvent('RecoverFromRagdoll');
  2557. return true;
  2558. }
  2559.  
  2560. event OnRecoverFromRagdollEnd()
  2561. {
  2562. if ( this.IsRagdolled() )
  2563. this.SetKinematic(true);
  2564. }
  2565.  
  2566. public function ReapplyCriticalBuff()
  2567. {
  2568. var buff : CBaseGameplayEffect;
  2569.  
  2570.  
  2571. buff = ChooseCurrentCriticalBuffForAnim();
  2572. if(buff)
  2573. {
  2574. LogCritical("Reapplying critical <<" + buff.GetEffectType() + ">> after finished CombatAction (End)");
  2575. StartCSAnim(buff);
  2576. }
  2577. }
  2578.  
  2579. timer function ReapplyCSTimer(dt : float, id : int)
  2580. {
  2581. ReapplyCriticalBuff();
  2582. }
  2583.  
  2584. public function IsInAgony() : bool {return false;}
  2585.  
  2586. public function GetOTCameraOffset() : float
  2587. {
  2588. return oTCameraOffset;
  2589. }
  2590.  
  2591. public function IsKnockedUnconscious() : bool
  2592. {
  2593. return OnCheckUnconscious();
  2594. }
  2595.  
  2596.  
  2597.  
  2598.  
  2599. function IsSailing() : bool
  2600. {
  2601. return IsUsingVehicle() && GetCurrentStateName() == 'Sailing';
  2602. }
  2603.  
  2604. final function spawnBoatAndMount()
  2605. {
  2606. var entities : array<CGameplayEntity>;
  2607. var vehicle : CVehicleComponent;
  2608. var i : int;
  2609. var boat : W3Boat;
  2610. var ent : CEntity;
  2611. var player : Vector;
  2612. var rot : EulerAngles;
  2613. var template : CEntityTemplate;
  2614.  
  2615. FindGameplayEntitiesInRange( entities, thePlayer, 10, 10, 'vehicle' );
  2616.  
  2617. for( i = 0; i < entities.Size(); i = i + 1 )
  2618. {
  2619. boat = ( W3Boat )entities[ i ];
  2620. if( boat )
  2621. {
  2622. vehicle = ( CVehicleComponent )( boat.GetComponentByClassName( 'CVehicleComponent' ) );
  2623. if ( vehicle )
  2624. {
  2625. vehicle.Mount( thePlayer, VMT_ImmediateUse, EVS_driver_slot );
  2626. }
  2627.  
  2628. return;
  2629. }
  2630. }
  2631.  
  2632. rot = thePlayer.GetWorldRotation();
  2633. player = thePlayer.GetWorldPosition();
  2634. template = (CEntityTemplate)LoadResource( 'boat' );
  2635. player.Z = 0.0f;
  2636.  
  2637. ent = theGame.CreateEntity(template, player, rot, true, false, false, PM_Persist );
  2638.  
  2639. if( ent )
  2640. {
  2641. vehicle = ( CVehicleComponent )( ent.GetComponentByClassName( 'CVehicleComponent' ) );
  2642. if ( vehicle )
  2643. {
  2644. vehicle.Mount( thePlayer, VMT_ImmediateUse, EVS_driver_slot );
  2645. boat = ( W3Boat )ent;
  2646. if( boat )
  2647. {
  2648. boat.SetTeleportedFromOtherHUB( true );
  2649. }
  2650. }
  2651. }
  2652. }
  2653.  
  2654. timer function DelayedSpawnAndMountBoat( delta : float, id : int )
  2655. {
  2656. spawnBoatAndMount();
  2657. RemoveTimer( 'DelayedSpawnAndMountBoat' );
  2658. }
Add Comment
Please, Sign In to add comment