Guest User

r4Player.ws

a guest
Jul 24th, 2023
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 403.39 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. statemachine abstract import class CR4Player extends CPlayer
  7. {
  8. //---=== modFriendlyHUD ===---
  9. public var fHUDConfig : CModFriendlyHUDConfig;
  10. public saved var newCraftables : array<name>;
  11. //---=== modFriendlyHUD ===---
  12.  
  13. protected var pcGamePlayInitialized : bool;
  14.  
  15.  
  16. private var pcMode : bool;
  17. default pcMode = true;
  18.  
  19.  
  20. protected saved var weaponHolster : WeaponHolster;
  21. public var rangedWeapon : Crossbow;
  22. public var crossbowDontPopStateHack : bool; default crossbowDontPopStateHack = false;
  23.  
  24. private var hitReactTransScale : float;
  25.  
  26. private var bIsCombatActionAllowed : bool;
  27. private var currentCombatAction : EBufferActionType;
  28.  
  29. private var uninterruptedHitsCount : int;
  30. private var uninterruptedHitsCameraStarted : bool;
  31. private var uninterruptedHitsCurrentCameraEffect : name;
  32.  
  33. private var counterTimestamps : array<EngineTime>;
  34.  
  35. private var hitReactionEffect : bool;
  36. public var AHW : CAHW; //modAHW
  37.  
  38. private var lookAtPosition : Vector;
  39. private var orientationTarget : EOrientationTarget;
  40. private var customOrientationTarget : EOrientationTarget;
  41. protected var customOrientationStack : array<SCustomOrientationParams>;
  42.  
  43. public var delayOrientationChange : bool;
  44. protected var delayCameraOrientationChange : bool;
  45. private var actionType : int;
  46. private var customOrientationStackIndex : int;
  47.  
  48. private var emptyMoveTargetTimer : float;
  49.  
  50. private var onlyOneEnemyLeft : bool;
  51.  
  52. public var isInFinisher : bool;
  53. private var finisherTarget : CGameplayEntity;
  54.  
  55. private var combatStance : EPlayerCombatStance;
  56.  
  57. public var approachAttack : int;
  58. default approachAttack = 1;
  59. protected var specialAttackCamera : bool;
  60.  
  61. private var specialAttackTimeRatio : float;
  62.  
  63. public saved var itemsPerLevel : array<name>;
  64. public var itemsPerLevelGiven : array<bool>;
  65.  
  66. private var playerTickTimerPhase : int;
  67. default playerTickTimerPhase = 0;
  68.  
  69. protected var evadeHeading : float;
  70.  
  71. public var vehicleCbtMgrAiming : bool;
  72.  
  73. public var specialHeavyChargeDuration : float;
  74. public var specialHeavyStartEngineTime : EngineTime;
  75. public var playedSpecialAttackMissingResourceSound : bool;
  76. public function SetPlayedSpecialAttackMissingResourceSound(b : bool) {playedSpecialAttackMissingResourceSound = b;}
  77.  
  78. public var counterCollisionGroupNames : array<name>;
  79.  
  80. public saved var lastInstantKillTime : GameTime;
  81.  
  82.  
  83. private var noSaveLockCombatActionName : string; default noSaveLockCombatActionName = 'combat_action';
  84. private var noSaveLockCombatAction : int;
  85. private var deathNoSaveLock : int;
  86. private var noSaveLock : int;
  87.  
  88.  
  89. protected saved var newGamePlusInitialized : bool;
  90. default newGamePlusInitialized = false;
  91.  
  92.  
  93. protected var BufferAllSteps : bool;
  94. protected var BufferCombatAction : EBufferActionType;
  95. protected var BufferButtonStage : EButtonStage;
  96.  
  97. default BufferAllSteps = false;
  98. default customOrientationTarget = OT_None;
  99. default hitReactionEffect = true;
  100. default uninterruptedHitsCount = 0;
  101. default uninterruptedHitsCameraStarted = false;
  102. default customOrientationStackIndex = -1;
  103.  
  104.  
  105. private var keepRequestingCriticalAnimStart : bool;
  106.  
  107. default keepRequestingCriticalAnimStart = false;
  108.  
  109.  
  110. private var currentCustomAction : EPlayerExplorationAction;
  111. public var substateManager : CExplorationStateManager;
  112. protected var isOnBoat : bool;
  113. protected var isInShallowWater : bool;
  114. public var medallion : W3MedallionFX;
  115. protected var lastMedallionEffect : float;
  116. private var isInRunAnimation : bool;
  117. public var interiorTracker :CPlayerInteriorTracker;
  118. public var m_SettlementBlockCanter : int;
  119.  
  120.  
  121.  
  122. private var fistFightMinigameEnabled : bool;
  123. private var isFFMinigameToTheDeath : bool;
  124. private var FFMinigameEndsithBS : bool;
  125. public var fistFightTeleportNode : CNode;
  126. public var isStartingFistFightMinigame : bool;
  127. public var GeraltMaxHealth : float;
  128. public var fistsItems : array< SItemUniqueId >;
  129.  
  130. default FFMinigameEndsithBS = false;
  131. default fistFightMinigameEnabled = false;
  132. default isFFMinigameToTheDeath = false;
  133.  
  134.  
  135. private var gwintAiDifficulty : EGwintDifficultyMode; default gwintAiDifficulty = EGDM_Easy;
  136. private var gwintAiAggression : EGwintAggressionMode; default gwintAiAggression = EGAM_Defensive;
  137. private var gwintMinigameState : EMinigameState; default gwintMinigameState = EMS_None;
  138.  
  139.  
  140. import private var horseWithInventory : EntityHandle;
  141. private var currentlyMountedHorse : CNewNPC;
  142. private var horseSummonTimeStamp : float;
  143. private saved var isHorseRacing : bool;
  144. private var horseCombatSlowMo : bool;
  145. default isHorseRacing = false;
  146. default horseCombatSlowMo = true;
  147.  
  148. public var gmConfig : modGodModeConfig; // ===== Added by God Mode mod - Module: Config =====
  149.  
  150.  
  151. private var HudMessages : array <string>;
  152. protected var fShowToLowStaminaIndication : float;
  153. public var showTooLowAdrenaline : bool;
  154. private var HAXE3Container : W3Container;
  155. private var HAXE3bAutoLoot: bool;
  156. private var bShowHud : bool;
  157. private var dodgeFeedbackTarget : CActor;
  158.  
  159. default HAXE3bAutoLoot = false;
  160. default fShowToLowStaminaIndication = 0.0f;
  161. default bShowHud = true;
  162.  
  163. saved var displayedQuestsGUID : array< CGUID >;
  164. saved var rewardsMultiplier : array< SRewardMultiplier >;
  165. saved var glossaryImageOverride : array< SGlossaryImageOverride >;
  166.  
  167.  
  168. private var prevRawLeftJoyRot : float;
  169. protected var explorationInputContext : name;
  170. protected var combatInputContext : name;
  171. protected var combatFistsInputContext : name;
  172.  
  173.  
  174. private var isInsideInteraction : bool;
  175. private var isInsideHorseInteraction : bool;
  176. public var horseInteractionSource : CEntity;
  177. public var nearbyLockedContainersNoKey : array<W3LockableEntity>;
  178.  
  179.  
  180. private var bMoveTargetChangeAllowed : bool; default bMoveTargetChangeAllowed = true;
  181. private var moveAdj : CMovementAdjustor;
  182. private var defaultLocomotionController : CR4LocomotionPlayerControllerScript;
  183.  
  184.  
  185. private var canFollowNpc : bool;
  186. private var actorToFollow : CActor;
  187. public var terrainPitch : float;
  188. public var steepSlopeNormalPitch : float; default steepSlopeNormalPitch = 65.f;
  189. public var disableSprintTerrainPitch : float; default disableSprintTerrainPitch = 54.f;
  190. private var submergeDepth : float;
  191.  
  192. private var m_useSelectedItemIfSpawned : bool; default m_useSelectedItemIfSpawned = false;
  193.  
  194.  
  195. var navQuery : CNavigationReachabilityQueryInterface;
  196.  
  197.  
  198. public saved var rememberedCustomHead : name;
  199.  
  200.  
  201. public saved var disableWeatherDisplay : bool;
  202.  
  203.  
  204. public saved var proudWalk : bool;
  205. private var etherealCount : int;
  206. default etherealCount = 0;
  207.  
  208.  
  209. public saved var injuredWalk : bool;
  210. public saved var tiedWalk : bool;
  211. private var insideDiveAttackArea : bool;
  212. default insideDiveAttackArea = false;
  213. private var diveAreaNumber : int;
  214. default diveAreaNumber = -1;
  215.  
  216.  
  217. private var flyingBossCamera : bool;
  218. default flyingBossCamera = false;
  219.  
  220. public function SetFlyingBossCamera( val : bool ) { flyingBossCamera = val; }
  221. public function GetFlyingBossCamera() : bool { return flyingBossCamera; }
  222.  
  223.  
  224. public saved var upscaledTooltipState : bool;
  225. default upscaledTooltipState = false;
  226.  
  227.  
  228. private var phantomWeaponMgr : CPhantomWeaponManager;
  229.  
  230.  
  231.  
  232. function EnablePCMode( flag : bool )
  233. {
  234. pcMode = flag;
  235. }
  236.  
  237. public function IsPCModeEnabled() : bool
  238. {
  239. return pcMode && theInput.LastUsedPCInput();
  240. }
  241.  
  242. public function ShouldUsePCModeTargeting() : bool
  243. {
  244. return IsPCModeEnabled() && !lastAxisInputIsMovement;
  245. }
  246.  
  247. public function SetDodgeFeedbackTarget( target : CActor )
  248. {
  249. dodgeFeedbackTarget = target;
  250. }
  251.  
  252. public function GetDodgeFeedbackTarget() : CActor
  253. {
  254. return dodgeFeedbackTarget;
  255. }
  256.  
  257. public function SetSubmergeDepth( depth : float )
  258. {
  259. submergeDepth = depth;
  260. }
  261.  
  262. public function GetSubmergeDepth() : float
  263. {
  264. return submergeDepth;
  265. }
  266.  
  267.  
  268. editable var delayBetweenIllusionOneliners : float;
  269.  
  270. hint delayBetweenIllusionOneliners = "delay in secs between oneliners about illusionary objects";
  271.  
  272. default delayBetweenIllusionOneliners = 5;
  273.  
  274.  
  275. private var battlecry_timeForNext : float;
  276. private var battlecry_delayMin : float; default battlecry_delayMin = 10;
  277. private var battlecry_delayMax : float; default battlecry_delayMax = 55;
  278. private var battlecry_lastTry : name;
  279.  
  280.  
  281. private var previousWeather : name;
  282. private var previousRainStrength : float;
  283.  
  284.  
  285. protected var receivedDamageInCombat : bool;
  286. protected var prevDayNightIsNight : bool;
  287. public var failedFundamentalsFirstAchievementCondition : bool;
  288.  
  289. private var spawnedTime : float;
  290.  
  291. public var currentMonsterHuntInvestigationArea : W3MonsterHuntInvestigationArea;
  292.  
  293. private var isPerformingPhaseChangeAnimation : bool;
  294. default isPerformingPhaseChangeAnimation = false;
  295.  
  296. default receivedDamageInCombat = false;
  297.  
  298.  
  299. public var playerMode : W3PlayerMode;
  300.  
  301.  
  302. protected saved var selectedItemId : SItemUniqueId;
  303. protected saved var blockedRadialSlots : array < SRadialSlotDef >;
  304.  
  305.  
  306. public var enemyCollectionDist : float;
  307. public var findMoveTargetDistMin : float;
  308. public var findMoveTargetDistMax : float;
  309. private var findMoveTargetScaledFrame : float;
  310. public var interactDist : float;
  311. protected var bCanFindTarget : bool;
  312. private var bIsConfirmingEmptyTarget : bool;
  313. private var displayTarget : CGameplayEntity;
  314. private var isShootingFriendly : bool;
  315.  
  316. default findMoveTargetDistMax = 18.f;
  317. default findMoveTargetScaledFrame = 0.5f;
  318. default interactDist = 3.5f;
  319.  
  320.  
  321. private var currentSelectedTarget : CActor;
  322. private var selectedTargetToConfirm : CActor;
  323. private var bConfirmTargetTimerIsEnabled : bool;
  324.  
  325.  
  326. public saved var thrownEntityHandle : EntityHandle;
  327. private var isThrowingItemWithAim : bool;
  328. private saved var isThrowingItem : bool;
  329. private var isThrowHoldPressed : bool;
  330.  
  331.  
  332. private var isAimingCrossbow : bool;
  333.  
  334. default isThrowingItemWithAim = false;
  335.  
  336.  
  337. public var playerAiming : PlayerAiming;
  338.  
  339.  
  340. public var forceDismember : bool;
  341. public var forceDismemberName : name;
  342. public var forceDismemberChance : int;
  343. public var forceDismemberExplosion : bool;
  344.  
  345.  
  346. private var finisherVictim : CActor;
  347. public var forceFinisher : bool;
  348. public var forceFinisherAnimName : name;
  349. public var forceFinisherChance : int;
  350. public var forcedStance : bool;
  351.  
  352.  
  353. private var m_WeaponFXCollisionGroupNames : array <name>;
  354. private var m_CollisionEffect : CEntity;
  355. private var m_LastWeaponTipPos : Vector;
  356. private var m_CollisionFxTemplate : CEntityTemplate;
  357. private var m_RefreshWeaponFXType : bool;
  358. private var m_PlayWoodenFX : bool;
  359.  
  360.  
  361. private var m_activePoster : W3Poster;
  362.  
  363. var ArdHoodBound : KeybindArdHood; //mod__hoods
  364.  
  365. public function SetActivePoster ( poster : W3Poster )
  366. {
  367. m_activePoster = poster;
  368. }
  369.  
  370. public function RemoveActivePoster ()
  371. {
  372. m_activePoster = NULL;
  373. }
  374.  
  375. public function GetActivePoster () : W3Poster
  376. {
  377. return m_activePoster;
  378. }
  379.  
  380.  
  381.  
  382.  
  383.  
  384. public var horseOnNavMesh : bool;
  385. default horseOnNavMesh = true;
  386.  
  387. public function SetHorseNav( val : bool ) { horseOnNavMesh = val; }
  388.  
  389.  
  390. public var testAdjustRequestedMovementDirection : bool;
  391. default testAdjustRequestedMovementDirection = false;
  392.  
  393.  
  394. default autoState = 'Exploration';
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401. import final function GetEnemiesInRange( out enemies : array< CActor > );
  402. import final function GetVisibleEnemies( out enemies : array< CActor > );
  403. import final function IsEnemyVisible( enemy : CActor ) : bool;
  404.  
  405.  
  406. import final function SetupEnemiesCollection( range, heightTolerance : float,
  407. maxEnemies : int,
  408. optional tag : name,
  409. optional flags : int );
  410.  
  411. import final function IsInInterior() : bool;
  412. import final function IsInSettlement() : bool;
  413. import final function EnterSettlement( isEntering : bool );
  414. import final function ActionDirectControl( controller : CR4LocomotionDirectController ) : bool;
  415. import final function SetPlayerTarget( target : CActor );
  416. import final function SetPlayerCombatTarget( target : CActor );
  417. import final function ObtainTicketFromCombatTarget( ticketName : CName, ticketsCount : int );
  418. import final function FreeTicketAtCombatTarget();
  419. import final function SetScriptMoveTarget( target : CActor );
  420. import final function GetRiderData() : CAIStorageRiderData;
  421. import final function SetIsInCombat( inCombat : bool );
  422. import final function SaveLastMountedHorse( mountedHorse : CActor );
  423.  
  424. import final function SetBacklightFromHealth( healthPercentage : float );
  425. import private final function SetBacklightColor( color : Vector );
  426.  
  427. import final function GetCombatDataComponent() : CCombatDataComponent;
  428.  
  429. import final function GetTemplatePathAndAppearance( out templatePath : string, out appearance : name );
  430.  
  431. import final function HACK_BoatDismountPositionCorrection( slotPos : Vector );
  432.  
  433. import final function HACK_ForceGetBonePosition( boneIndex : int ) : Vector;
  434.  
  435.  
  436. public function GetLevel() : int
  437. {
  438. return 0;
  439. }
  440.  
  441. public function ApplyCastSettings()
  442. {
  443. }
  444.  
  445.  
  446.  
  447. var targeting : CR4PlayerTargeting;
  448. var targetingPrecalcs : SR4PlayerTargetingPrecalcs;
  449. var targetingIn : SR4PlayerTargetingIn;
  450. var targetingOut : SR4PlayerTargetingOut;
  451. var useNativeTargeting : bool;
  452. default useNativeTargeting = true;
  453.  
  454. var visibleActors : array< CActor >;
  455. var visibleActorsTime : array< float >;
  456.  
  457.  
  458.  
  459. event OnSpawned( spawnData : SEntitySpawnData )
  460. {
  461. var atts : array<name>;
  462. var skill : ESkill;
  463. var i : int;
  464. var item : SItemUniqueId;
  465.  
  466.  
  467. var tempItem : SItemUniqueId;
  468.  
  469. //---=== modFriendlyHUD ===---
  470.  
  471. AddAnimEventCallback('ThrowHoldTest', 'OnAnimEvent_ThrowHoldTest');
  472. AddAnimEventCallback('OnWeaponDrawReady', 'OnAnimEvent_OnWeaponDrawReady');
  473. AddAnimEventCallback('OnWeaponHolsterReady', 'OnAnimEvent_OnWeaponHolsterReady');
  474. AddAnimEventCallback('AllowTempLookAt', 'OnAnimEvent_AllowTempLookAt');
  475. AddAnimEventCallback('SlideToTarget', 'OnAnimEvent_SlideToTarget');
  476. AddAnimEventCallback('PlayFinisherBlood', 'OnAnimEvent_PlayFinisherBlood');
  477. AddAnimEventCallback('SlowMo', 'OnAnimEvent_SlowMo');
  478. AddAnimEventCallback('BloodTrailForced', 'OnAnimEvent_BloodTrailForced');
  479. AddAnimEventCallback('FadeOut', 'OnAnimEvent_FadeOut');
  480. AddAnimEventCallback('FadeIn', 'OnAnimEvent_FadeIn');
  481. AddAnimEventCallback('DisallowHitAnim', 'OnAnimEvent_DisallowHitAnim');
  482. AddAnimEventCallback('AllowFall', 'OnAnimEvent_AllowFall');
  483. AddAnimEventCallback('AllowFall2', 'OnAnimEvent_AllowFall2');
  484. AddAnimEventCallback('DettachGround', 'OnAnimEvent_DettachGround');
  485. AddAnimEventCallback('KillWithRagdoll', 'OnAnimEvent_KillWithRagdoll');
  486. AddAnimEventCallback('pad_vibration', 'OnAnimEvent_pad_vibration');
  487. AddAnimEventCallback('pad_vibration_light', 'OnAnimEvent_pad_vibration_light');
  488. AddAnimEventCallback('RemoveBurning', 'OnAnimEvent_RemoveBurning');
  489. AddAnimEventCallback('RemoveTangled', 'OnAnimEvent_RemoveTangled');
  490. AddAnimEventCallback('MoveNoise', 'OnAnimEvent_MoveNoise');
  491.  
  492.  
  493. AddAnimEventCallback('ClimbCameraOn', 'OnAnimEvent_ClimbCameraOn');
  494. AddAnimEventCallback('ClimbCameraOff', 'OnAnimEvent_ClimbCameraOff');
  495. AddAnimEventCallback('LadderCamReset', 'OnAnimEvent_LadderCamReset');
  496.  
  497. AddItemPerLevelList();
  498.  
  499. enemyCollectionDist = findMoveTargetDistMax;
  500.  
  501.  
  502. theGame.RemoveTimeScale('horse_melee');
  503.  
  504. gmConfig = new modGodModeConfig in this; // +++++ Added by God Mode mod - Module: Config +++++
  505. gmConfig.Init(); // ----- Added by God Mode mod - Module: Config -----
  506.  
  507. if(!spawnData.restored && !((W3ReplacerCiri)this) )
  508. {
  509. AddTimer('GiveStartingItems', 0.00001, true, , , true);
  510.  
  511. if(!theGame.IsFinalBuild())
  512. {
  513.  
  514. AddAbility('GeraltSkills_Testing');
  515. AddTimer('Debug_GiveTestingItems',0.0001,true);
  516. }
  517.  
  518.  
  519. FactsAdd("tut_stash_fresh_playthrough");
  520. }
  521.  
  522. InitTargeting();
  523.  
  524.  
  525. if( spawnData.restored )
  526. {
  527.  
  528.  
  529.  
  530. theGame.GameplayFactsRemove( "in_combat" );
  531. }
  532.  
  533.  
  534.  
  535. if ( !weaponHolster )
  536. {
  537. weaponHolster = new WeaponHolster in this;
  538. }
  539.  
  540. weaponHolster.Initialize( this, spawnData.restored );
  541.  
  542. if ( !interiorTracker )
  543. {
  544. interiorTracker = new CPlayerInteriorTracker in this;
  545. }
  546. interiorTracker.Init( spawnData.restored );
  547.  
  548.  
  549. super.OnSpawned( spawnData );
  550.  
  551.  
  552. medallion = new W3MedallionFX in this;
  553.  
  554. playerMode = new W3PlayerMode in this;
  555. playerMode.Initialize( this );
  556.  
  557.  
  558. playerAiming = new PlayerAiming in this;
  559. playerAiming.Initialize( this );
  560.  
  561.  
  562. navQuery = new CNavigationReachabilityQueryInterface in this;
  563.  
  564.  
  565. EnableFindTarget( true );
  566. AddTimer( 'CombatCheck', 0.2f, true );
  567.  
  568.  
  569. substateManager = ( CExplorationStateManager ) GetComponentByClassName( 'CExplorationStateManager' );
  570.  
  571. findMoveTargetDist = findMoveTargetDistMax;
  572.  
  573. SetupEnemiesCollection( enemyCollectionDist, findMoveTargetDist, 10, 'None', FLAG_Attitude_Neutral + FLAG_Attitude_Hostile + FLAG_Attitude_Friendly + FLAG_OnlyAliveActors );
  574.  
  575.  
  576. inputHandler.RemoveLocksOnSpawn();
  577.  
  578.  
  579. ((CActor) this ).SetInteractionPriority( IP_Prio_0 );
  580.  
  581. prevDayNightIsNight = theGame.envMgr.IsNight();
  582. CheckDayNightCycle();
  583.  
  584.  
  585. EnableVisualDebug( SHOW_AI, true );
  586.  
  587.  
  588. FactsRemove("blocked_illusion_oneliner");
  589.  
  590. SetFailedFundamentalsFirstAchievementCondition(false);
  591. m_CollisionFxTemplate = (CEntityTemplate) LoadResource( 'sword_colision_fx' );
  592. if( m_WeaponFXCollisionGroupNames.Size() == 0 )
  593. {
  594. m_WeaponFXCollisionGroupNames.PushBack('Static');
  595. m_WeaponFXCollisionGroupNames.PushBack('Foliage');
  596. m_WeaponFXCollisionGroupNames.PushBack('Fence');
  597. m_WeaponFXCollisionGroupNames.PushBack('BoatSide');
  598. m_WeaponFXCollisionGroupNames.PushBack('Door');
  599. m_WeaponFXCollisionGroupNames.PushBack('RigidBody');
  600. m_WeaponFXCollisionGroupNames.PushBack('Dynamic');
  601. m_WeaponFXCollisionGroupNames.PushBack('Destructible');
  602. }
  603.  
  604. if ( counterCollisionGroupNames.Size() == 0 )
  605. {
  606. counterCollisionGroupNames.PushBack('Static');
  607. counterCollisionGroupNames.PushBack('Foliage');
  608. counterCollisionGroupNames.PushBack('Fence');
  609. counterCollisionGroupNames.PushBack('Terrain');
  610. counterCollisionGroupNames.PushBack('Door');
  611. counterCollisionGroupNames.PushBack('RigidBody');
  612. counterCollisionGroupNames.PushBack('Dynamic');
  613. counterCollisionGroupNames.PushBack('Destructible');
  614. }
  615.  
  616.  
  617. ResetPadBacklightColor();
  618.  
  619. if( spawnData.restored )
  620. {
  621. if (IsCurrentlyUsingItemL())
  622. {
  623. if (inv.HasItemById( currentlyEquipedItemL ))
  624. {
  625. OnUseSelectedItem();
  626. }
  627. else
  628. {
  629. HideUsableItem(true);
  630. }
  631. }
  632. if ( GetCurrentMeleeWeaponType() == PW_Steel || GetCurrentMeleeWeaponType() == PW_Silver )
  633. {
  634. OnEquipMeleeWeapon(GetCurrentMeleeWeaponType(), true, true);
  635. }
  636.  
  637. AddTimer( 'UnmountCrossbowTimer', 0.01, true );
  638.  
  639. ClearBlockedSlots();
  640. }
  641.  
  642. ((CR4PlayerStateSwimming)this.GetState('Swimming')).OnParentSpawned();
  643.  
  644.  
  645. SetImmortalityMode( AIM_None, AIC_SyncedAnim );
  646.  
  647.  
  648. theGame.GetDefinitionsManager().GetContainedAbilities('DwimeritiumBomb_3', atts);
  649. for(i=0; i<atts.Size(); i+=1)
  650. {
  651. skill = SkillNameToEnum(atts[i]);
  652. if(skill != S_SUndefined)
  653. BlockSkill(skill, false);
  654. }
  655.  
  656.  
  657. this.GetInventory().GetItemEquippedOnSlot( EES_SteelSword, item );
  658. if( this.GetInventory().ItemHasTag( item, 'PhantomWeapon' ) )
  659. {
  660. this.InitPhantomWeaponMgr();
  661. }
  662.  
  663.  
  664. if(FactsQuerySum("mq3036_fact_done") > 0)
  665. BlockAllActions('mq3036', false);
  666.  
  667. spawnedTime = theGame.GetEngineTimeAsSeconds();
  668.  
  669. //mod_hoods++
  670. ArdHoodBound = new KeybindArdHood in this;
  671. ArdHoodBound.init();
  672. //--mod_hoods
  673.  
  674. if ( theGame.GetInGameConfigWrapper().GetVarValue('Gameplay', 'EnableUberMovement' ) == "1" )
  675. theGame.EnableUberMovement( true );
  676. else
  677. theGame.EnableUberMovement( false );
  678.  
  679.  
  680. if ( !FactsDoesExist("gwent_difficulty") )
  681. FactsAdd("gwent_difficulty", 2);
  682.  
  683.  
  684. if(!newGamePlusInitialized && FactsQuerySum("NewGamePlus") > 0)
  685. {
  686. NewGamePlusInitialize();
  687. }
  688.  
  689.  
  690. if( lastInstantKillTime > theGame.GetGameTime() )
  691. {
  692. SetLastInstantKillTime( GameTimeCreate(0) );
  693. }
  694.  
  695.  
  696. SetPlayerCameraPreset();
  697.  
  698. GetWitcherPlayer().UnequipItemFromSlot(EES_Petard2,true);
  699.  
  700. this.GetInventory().GetItemEquippedOnSlot( EES_Quickslot2, tempItem );
  701. if(this.GetInventory().IsIdValid(tempItem) && this.GetInventory().GetItemCategory(tempItem) != 'mask')
  702. {
  703. GetWitcherPlayer().UnequipItemFromSlot(EES_Quickslot2,true);
  704. }
  705.  
  706. shouldAutoApplyOils = theGame.GetInGameConfigWrapper().GetVarValue('Gameplay', 'AutoApplyBladeOils' ) == "true";
  707. }
  708.  
  709. public function NewGamePlusInitialize()
  710. {
  711.  
  712. SetLastInstantKillTime( GameTimeCreate(0) );
  713. }
  714.  
  715. public function GetTimeSinceSpawned() : float
  716. {
  717. return theGame.GetEngineTimeAsSeconds() - spawnedTime;
  718. }
  719.  
  720. timer function UnmountCrossbowTimer( dt : float, id : int )
  721. {
  722. var itemId : SItemUniqueId;
  723.  
  724. itemId = this.inv.GetItemFromSlot( 'l_weapon' );
  725. if ( inv.IsIdValid( itemId ) && inv.IsItemCrossbow( itemId ) )
  726. {
  727. rangedWeapon = (Crossbow)( inv.GetItemEntityUnsafe( itemId ) );
  728.  
  729. if (rangedWeapon)
  730. {
  731. rangedWeapon.Initialize( (CActor)( rangedWeapon.GetParentEntity() ) );
  732. OnRangedForceHolster( true, true );
  733. RemoveTimer( 'UnmountCrossbowTimer' );
  734. }
  735. }
  736. else
  737. RemoveTimer( 'UnmountCrossbowTimer' );
  738. }
  739.  
  740. event OnDestroyed()
  741. {
  742. playerAiming.RemoveAimingSloMo();
  743.  
  744. if(rangedWeapon)
  745. rangedWeapon.ClearDeployedEntity(true);
  746.  
  747. ResetPadBacklightColor();
  748.  
  749.  
  750. theGame.ReleaseNoSaveLock( noSaveLock );
  751. }
  752.  
  753. public function OnShieldHit()
  754. {
  755. }
  756.  
  757.  
  758.  
  759.  
  760.  
  761. public function GetBlockedSlots () : array < SRadialSlotDef >
  762. {
  763. return blockedRadialSlots;
  764. }
  765.  
  766. public function ClearBlockedSlots()
  767. {
  768. var i : int;
  769.  
  770.  
  771.  
  772. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  773. {
  774. if( !IsSwimming() )
  775. {
  776. if ( EnableRadialSlot(blockedRadialSlots[i].slotName, 'swimming'))
  777. {
  778. i-=1;
  779. continue;
  780. }
  781. }
  782. if (!IsUsingVehicle())
  783. {
  784. if ( EnableRadialSlot(blockedRadialSlots[i].slotName, 'useVehicle'))
  785. {
  786. i-=1;
  787. continue;
  788. }
  789. }
  790. if ( !IsCurrentlyUsingItemL() || !IsUsableItemLBlocked() )
  791. {
  792. if ( EnableRadialSlot(blockedRadialSlots[i].slotName, 'usableItemL'))
  793. {
  794. i-=1;
  795. continue;
  796. }
  797. }
  798. if ( !IsThrowingItem() )
  799. {
  800. if ( EnableRadialSlot(blockedRadialSlots[i].slotName, 'throwBomb'))
  801. {
  802. i-=1;
  803. continue;
  804. }
  805. }
  806. }
  807.  
  808.  
  809.  
  810. }
  811.  
  812. public function RestoreBlockedSlots ()
  813. {
  814. var i : int;
  815. var slotsToBlock : array<name>;
  816.  
  817. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  818. {
  819. slotsToBlock.PushBack ( blockedRadialSlots[i].slotName );
  820. }
  821. if ( slotsToBlock.Size() > 0 )
  822. {
  823. EnableRadialSlots ( false, slotsToBlock );
  824. }
  825. }
  826. private function DisableRadialSlot ( slotName : name, sourceName : name ) : bool
  827. {
  828. var i : int;
  829. var k : int;
  830. var slotsToBlock : array<name>;
  831.  
  832. var blockedRadialSlotEntry : SRadialSlotDef;
  833.  
  834. slotsToBlock.PushBack ( slotName );
  835.  
  836. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  837. {
  838. if ( blockedRadialSlots[i].slotName == slotName )
  839. {
  840. if ( sourceName != '' )
  841. {
  842. for ( k = 0; k < blockedRadialSlots[i].disabledBySources.Size(); k += 1 )
  843. {
  844. if ( blockedRadialSlots[i].disabledBySources[k] == sourceName )
  845. {
  846. return false;
  847. }
  848. }
  849. blockedRadialSlots[i].disabledBySources.PushBack ( sourceName );
  850. return false;
  851. }
  852.  
  853. return false;
  854. }
  855. }
  856.  
  857. blockedRadialSlotEntry = InitBlockedRadialSlotEntry ( slotName );
  858.  
  859. if ( sourceName != '' )
  860. {
  861. blockedRadialSlotEntry.disabledBySources.PushBack ( sourceName );
  862. }
  863. blockedRadialSlots.PushBack ( blockedRadialSlotEntry );
  864. EnableRadialSlots ( false, slotsToBlock );
  865. return true;
  866. }
  867.  
  868. public function EnableRadialSlot ( slotName : name, sourceName : name ) : bool
  869. {
  870. var i : int;
  871. var k : int;
  872.  
  873. var slotsToBlock : array<name>;
  874.  
  875. slotsToBlock.PushBack ( slotName );
  876.  
  877. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  878. {
  879. if ( blockedRadialSlots[i].slotName == slotName )
  880. {
  881.  
  882. if ( sourceName != '' )
  883. {
  884. for ( k = 0; k < blockedRadialSlots[i].disabledBySources.Size(); k += 1 )
  885. {
  886. if ( blockedRadialSlots[i].disabledBySources[k] == sourceName )
  887. {
  888. blockedRadialSlots[i].disabledBySources.Remove ( blockedRadialSlots[i].disabledBySources[k] );
  889. }
  890. }
  891. }
  892. if ( blockedRadialSlots[i].disabledBySources.Size() <= 0 )
  893. {
  894. blockedRadialSlots.Remove( blockedRadialSlots[i] );
  895. EnableRadialSlots ( true, slotsToBlock );
  896. return true;
  897. }
  898. return false;
  899. }
  900. }
  901. return false;
  902.  
  903. }
  904.  
  905. private function InitBlockedRadialSlotEntry ( slotName : name ) : SRadialSlotDef
  906. {
  907. var blockedRadialSlotEntry : SRadialSlotDef;
  908.  
  909. blockedRadialSlotEntry.slotName = slotName;
  910.  
  911. return blockedRadialSlotEntry;
  912.  
  913. }
  914.  
  915. public function EnableRadialSlotsWithSource ( enable : bool, slotsToBlock : array < name >, sourceName : name )
  916. {
  917. var i : int;
  918.  
  919. for ( i = 0; i < slotsToBlock.Size(); i+=1 )
  920. {
  921. if ( enable )
  922. {
  923. EnableRadialSlot ( slotsToBlock[i], sourceName );
  924. }
  925. else
  926. {
  927. DisableRadialSlot ( slotsToBlock[i], sourceName );
  928. }
  929. }
  930. if ( blockedRadialSlots.Size() <= 0 )
  931. {
  932. blockedRadialSlots.Clear();
  933. }
  934. }
  935.  
  936. public function IsRadialSlotBlocked ( slotName : name ) : bool
  937. {
  938. var i : int;
  939.  
  940. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  941. {
  942. if ( blockedRadialSlots[i].slotName == slotName )
  943. {
  944. return true;
  945. }
  946. }
  947. return false;
  948. }
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955. public function RepairItem ( rapairKitId : SItemUniqueId, usedOnItem : SItemUniqueId );
  956. public function HasRepairAbleGearEquiped () : bool;
  957. public function HasRepairAbleWaponEquiped () : bool;
  958. public function IsItemRepairAble ( item : SItemUniqueId ) : bool;
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965. public final function ReduceAllOilsAmmo( id : SItemUniqueId )
  966. {
  967. var i : int;
  968. var oils : array< W3Effect_Oil >;
  969.  
  970. oils = inv.GetOilsAppliedOnItem( id );
  971.  
  972. for( i=0; i<oils.Size(); i+=1 )
  973. {
  974. oils[ i ].ReduceAmmo();
  975. }
  976. }
  977.  
  978. public final function ResumeOilBuffs( steel : bool )
  979. {
  980. var item : SItemUniqueId;
  981. var oils : array< CBaseGameplayEffect >;
  982. var buff, recentOil : W3Effect_Oil;
  983. var i : int;
  984.  
  985. item = GetEquippedSword( steel );
  986. oils = GetBuffs( EET_Oil );
  987.  
  988. if( oils.Size() > 1 )
  989. {
  990.  
  991.  
  992. recentOil = inv.GetNewestOilAppliedOnItem( item, false );
  993. }
  994.  
  995. for( i=0; i<oils.Size(); i+=1 )
  996. {
  997. buff = ( W3Effect_Oil ) oils[ i ];
  998.  
  999. if( recentOil && recentOil == buff )
  1000. {
  1001. continue;
  1002. }
  1003.  
  1004. if(buff && buff.GetSwordItemId() == item )
  1005. {
  1006. buff.Resume( '' );
  1007. }
  1008. }
  1009.  
  1010. if( recentOil )
  1011. {
  1012. recentOil.Resume( '' );
  1013. }
  1014. }
  1015.  
  1016. protected final function PauseOilBuffs( isSteel : bool )
  1017. {
  1018. var item : SItemUniqueId;
  1019. var oils : array< CBaseGameplayEffect >;
  1020. var buff : W3Effect_Oil;
  1021. var i : int;
  1022.  
  1023. item = GetEquippedSword( isSteel );
  1024. oils = GetBuffs( EET_Oil );
  1025.  
  1026. for( i=0; i<oils.Size(); i+=1 )
  1027. {
  1028. buff = ( W3Effect_Oil ) oils[ i ];
  1029. if(buff && buff.GetSwordItemId() == item )
  1030. {
  1031. buff.Pause( '', true );
  1032. }
  1033. }
  1034. }
  1035.  
  1036. public final function ManageAerondightBuff( apply : bool )
  1037. {
  1038. var aerondight : W3Effect_Aerondight;
  1039. var item : SItemUniqueId;
  1040.  
  1041. item = inv.GetCurrentlyHeldSword();
  1042.  
  1043. if( inv.ItemHasTag( item, 'Aerondight' ) )
  1044. {
  1045. aerondight = (W3Effect_Aerondight)GetBuff( EET_Aerondight );
  1046.  
  1047. if( apply )
  1048. {
  1049. if( !aerondight )
  1050. {
  1051. AddEffectDefault( EET_Aerondight, this, "Aerondight" );
  1052. }
  1053. else
  1054. {
  1055. aerondight.Resume( 'ManageAerondightBuff' );
  1056. }
  1057. }
  1058. else
  1059. {
  1060. aerondight.Pause( 'ManageAerondightBuff' );
  1061. }
  1062. }
  1063. }
  1064.  
  1065.  
  1066.  
  1067. private function CheckForPreviousLevelOilExploit(oilName : name, oils : array< W3Effect_Oil >)
  1068. {
  1069. var oilsToCheck : array<name>;
  1070. var i : int;
  1071.  
  1072. switch( oilName )
  1073. {
  1074. case 'Beast Oil 3':
  1075. case 'Beast Oil 2':
  1076. case 'Beast Oil 1':
  1077. oilsToCheck.PushBack('Beast Oil 3');
  1078. oilsToCheck.PushBack('Beast Oil 2');
  1079. oilsToCheck.PushBack('Beast Oil 1');
  1080. break;
  1081.  
  1082. case 'Cursed Oil 3':
  1083. case 'Cursed Oil 2':
  1084. case 'Cursed Oil 1':
  1085. oilsToCheck.PushBack('Cursed Oil 3');
  1086. oilsToCheck.PushBack('Cursed Oil 2');
  1087. oilsToCheck.PushBack('Cursed Oil 1');
  1088. break;
  1089.  
  1090. case 'Draconide Oil 3':
  1091. case 'Draconide Oil 2':
  1092. case 'Draconide Oil 1':
  1093. oilsToCheck.PushBack('Draconide Oil 3');
  1094. oilsToCheck.PushBack('Draconide Oil 2');
  1095. oilsToCheck.PushBack('Draconide Oil 1');
  1096. break;
  1097.  
  1098. case 'Hanged Man Venom 3':
  1099. case 'Hanged Man Venom 2':
  1100. case 'Hanged Man Venom 1':
  1101. oilsToCheck.PushBack('Hanged Man Venom 3');
  1102. oilsToCheck.PushBack('Hanged Man Venom 2');
  1103. oilsToCheck.PushBack('Hanged Man Venom 1');
  1104. break;
  1105.  
  1106. case 'Hybrid Oil 3':
  1107. case 'Hybrid Oil 2':
  1108. case 'Hybrid Oil 1':
  1109. oilsToCheck.PushBack('Hybrid Oil 3');
  1110. oilsToCheck.PushBack('Hybrid Oil 2');
  1111. oilsToCheck.PushBack('Hybrid Oil 1');
  1112. break;
  1113.  
  1114. case 'Insectoid Oil 3':
  1115. case 'Insectoid Oil 2':
  1116. case 'Insectoid Oil 1':
  1117. oilsToCheck.PushBack('Insectoid Oil 3');
  1118. oilsToCheck.PushBack('Insectoid Oil 2');
  1119. oilsToCheck.PushBack('Insectoid Oil 1');
  1120. break;
  1121.  
  1122. case 'Magicals Oil 3':
  1123. case 'Magicals Oil 2':
  1124. case 'Magicals Oil 1':
  1125. oilsToCheck.PushBack('Magicals Oil 3');
  1126. oilsToCheck.PushBack('Magicals Oil 2');
  1127. oilsToCheck.PushBack('Magicals Oil 1');
  1128. break;
  1129.  
  1130. case 'Necrophage Oil 3':
  1131. case 'Necrophage Oil 2':
  1132. case 'Necrophage Oil 1':
  1133. oilsToCheck.PushBack('Necrophage Oil 3');
  1134. oilsToCheck.PushBack('Necrophage Oil 2');
  1135. oilsToCheck.PushBack('Necrophage Oil 1');
  1136. break;
  1137.  
  1138. case 'Ogre Oil 3':
  1139. case 'Ogre Oil 2':
  1140. case 'Ogre Oil 1':
  1141. oilsToCheck.PushBack('Ogre Oil 3');
  1142. oilsToCheck.PushBack('Ogre Oil 2');
  1143. oilsToCheck.PushBack('Ogre Oil 1');
  1144. break;
  1145.  
  1146. case 'Relic Oil 3':
  1147. case 'Relic Oil 2':
  1148. case 'Relic Oil 1':
  1149. oilsToCheck.PushBack('Relic Oil 3');
  1150. oilsToCheck.PushBack('Relic Oil 2');
  1151. oilsToCheck.PushBack('Relic Oil 1');
  1152. break;
  1153.  
  1154. case 'Specter Oil 3':
  1155. case 'Specter Oil 2':
  1156. case 'Specter Oil 1':
  1157. oilsToCheck.PushBack('Specter Oil 3');
  1158. oilsToCheck.PushBack('Specter Oil 2');
  1159. oilsToCheck.PushBack('Specter Oil 1');
  1160. break;
  1161.  
  1162. case 'Vampire Oil 3':
  1163. case 'Vampire Oil 2':
  1164. case 'Vampire Oil 1':
  1165. oilsToCheck.PushBack('Vampire Oil 3');
  1166. oilsToCheck.PushBack('Vampire Oil 2');
  1167. oilsToCheck.PushBack('Vampire Oil 1');
  1168. break;
  1169. }
  1170.  
  1171. oilsToCheck.Remove(oilName);
  1172.  
  1173. for( i=0; i<oilsToCheck.Size(); i+=1 )
  1174. {
  1175. CheckIfPreviousOilApplied(oilsToCheck[i], oils);
  1176. }
  1177. }
  1178.  
  1179. private function CheckIfPreviousOilApplied(oil : name, oils : array< W3Effect_Oil >)
  1180. {
  1181. var i : int;
  1182.  
  1183. for( i=0; i<oils.Size(); i+=1 )
  1184. {
  1185. if( oils[ i ].GetOilItemName() == oil )
  1186. {
  1187. RemoveEffect( oils[ i ] );
  1188. }
  1189. }
  1190. }
  1191.  
  1192.  
  1193.  
  1194.  
  1195. public function ApplyOil( oilId : SItemUniqueId, usedOnItem : SItemUniqueId ) : bool
  1196. {
  1197. var oilAbilities : array< name >;
  1198. var ammo, ammoBonus : float;
  1199. var dm : CDefinitionsManagerAccessor;
  1200. var buffParams : SCustomEffectParams;
  1201. var oilParams : W3OilBuffParams;
  1202. var oilName : name;
  1203. var min, max : SAbilityAttributeValue;
  1204. var i : int;
  1205. var oils : array< W3Effect_Oil >;
  1206. var existingOil : W3Effect_Oil;
  1207.  
  1208. if( !CanApplyOilOnItem( oilId, usedOnItem ) )
  1209. {
  1210. return false;
  1211. }
  1212.  
  1213. dm = theGame.GetDefinitionsManager();
  1214. inv.GetItemAbilitiesWithTag( oilId, theGame.params.OIL_ABILITY_TAG, oilAbilities );
  1215. oilName = inv.GetItemName( oilId );
  1216. oils = inv.GetOilsAppliedOnItem( usedOnItem );
  1217.  
  1218.  
  1219. for( i=0; i<oils.Size(); i+=1 )
  1220. {
  1221. if( oils[ i ].GetOilItemName() == oilName )
  1222. {
  1223. existingOil = oils[ i ];
  1224. break;
  1225. }
  1226. }
  1227.  
  1228.  
  1229. if(CanUseSkill(S_Alchemy_s06))
  1230. CheckForPreviousLevelOilExploit(oilName,oils);
  1231.  
  1232.  
  1233.  
  1234. if( !existingOil )
  1235. {
  1236.  
  1237.  
  1238. if( !GetWitcherPlayer() || !CanUseSkill(S_Alchemy_s06) )
  1239.  
  1240. {
  1241. inv.RemoveAllOilsFromItem( usedOnItem );
  1242. }
  1243. else
  1244. {
  1245.  
  1246.  
  1247.  
  1248. if( inv.GetActiveOilsAppliedOnItemCount( usedOnItem ) >= GetSkillLevel( S_Alchemy_s06 ) )
  1249.  
  1250. {
  1251. inv.RemoveOldestOilFromItem( usedOnItem );
  1252. }
  1253. }
  1254. }
  1255.  
  1256.  
  1257. ammo = CalculateAttributeValue(inv.GetItemAttributeValue(oilId, 'ammo'));
  1258. if(CanUseSkill(S_Alchemy_s06))
  1259. {
  1260. ammoBonus = CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s06, 'ammo_bonus', false, false));
  1261. ammo *= 1 + ammoBonus * GetSkillLevel(S_Alchemy_s06);
  1262. }
  1263.  
  1264.  
  1265. if( existingOil )
  1266. {
  1267. existingOil.Reapply( RoundMath( ammo ) );
  1268. }
  1269. else
  1270. {
  1271. buffParams.effectType = EET_Oil;
  1272. buffParams.creator = this;
  1273. oilParams = new W3OilBuffParams in this;
  1274. oilParams.iconPath = dm.GetItemIconPath( oilName );
  1275. oilParams.localizedName = dm.GetItemLocalisationKeyName( oilName );
  1276. oilParams.localizedDescription = dm.GetItemLocalisationKeyName( oilName );
  1277. oilParams.sword = usedOnItem;
  1278. oilParams.maxCount = RoundMath( ammo );
  1279. oilParams.currCount = RoundMath( ammo );
  1280. oilParams.oilAbilityName = oilAbilities[ 0 ];
  1281. oilParams.oilItemName = oilName;
  1282. buffParams.buffSpecificParams = oilParams;
  1283.  
  1284. AddEffectCustom( buffParams );
  1285.  
  1286. delete oilParams;
  1287. }
  1288.  
  1289. LogOils("Added oil <<" + oilName + ">> to <<" + inv.GetItemName( usedOnItem ) + ">>");
  1290.  
  1291.  
  1292. SetFailedFundamentalsFirstAchievementCondition( true );
  1293.  
  1294. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnOilApplied );
  1295.  
  1296. if( !inv.IsItemHeld( usedOnItem ) )
  1297. {
  1298. PauseOilBuffs( inv.IsItemSteelSwordUsableByPlayer( usedOnItem ) );
  1299. }
  1300.  
  1301. return true;
  1302. }
  1303.  
  1304.  
  1305. public final function IsEquippedSwordUpgradedWithOil(steel : bool, optional oilName : name) : bool
  1306. {
  1307. var sword : SItemUniqueId;
  1308. var i : int;
  1309. var oils : array< W3Effect_Oil >;
  1310.  
  1311. sword = GetEquippedSword( steel );
  1312. if( !inv.IsIdValid( sword ) )
  1313. {
  1314. return false;
  1315. }
  1316.  
  1317. if( oilName == '' )
  1318. {
  1319. return inv.ItemHasAnyActiveOilApplied( sword );
  1320. }
  1321.  
  1322. oils = inv.GetOilsAppliedOnItem( sword );
  1323. for( i=0; i<oils.Size(); i+=1 )
  1324. {
  1325. if( oils[ i ].GetOilItemName() == oilName )
  1326. {
  1327. return true;
  1328. }
  1329. }
  1330.  
  1331. return false;
  1332. }
  1333.  
  1334. public function CanApplyOilOnItem(oilId : SItemUniqueId, usedOnItem : SItemUniqueId) : bool
  1335. {
  1336. if(inv.ItemHasTag(oilId, theGame.params.TAG_STEEL_OIL) && inv.IsItemSteelSwordUsableByPlayer(usedOnItem))
  1337. return true;
  1338.  
  1339. if(inv.ItemHasTag(oilId, theGame.params.TAG_SILVER_OIL) && inv.IsItemSilverSwordUsableByPlayer(usedOnItem))
  1340. return true;
  1341.  
  1342. return false;
  1343. }
  1344.  
  1345.  
  1346. public final function DidFailFundamentalsFirstAchievementCondition() : bool
  1347. {
  1348. return failedFundamentalsFirstAchievementCondition;
  1349. }
  1350.  
  1351. public final function SetFailedFundamentalsFirstAchievementCondition(b : bool)
  1352. {
  1353. var i : int;
  1354. var npc : CNewNPC;
  1355.  
  1356. failedFundamentalsFirstAchievementCondition = b;
  1357.  
  1358.  
  1359. if(failedFundamentalsFirstAchievementCondition)
  1360. {
  1361. for(i=0; i<hostileEnemies.Size(); i+=1)
  1362. {
  1363. if(hostileEnemies[i].HasTag(theGame.params.MONSTER_HUNT_ACTOR_TAG))
  1364. {
  1365. npc = (CNewNPC)hostileEnemies[i];
  1366. npc.AddTag('failedFundamentalsAchievement');
  1367. npc.AddTimer('FundamentalsAchFailTimer', 30*60, , , , true, true);
  1368. }
  1369. }
  1370. }
  1371. }
  1372.  
  1373. public function IsInCombatFist() : bool
  1374. {
  1375. return this.GetCurrentStateName() == 'CombatFists';
  1376. }
  1377.  
  1378. public function IsInitialized() : bool;
  1379.  
  1380. public function IsCiri() : bool
  1381. {
  1382. return ((W3ReplacerCiri)this);
  1383. }
  1384.  
  1385. protected function WouldLikeToMove() : bool
  1386. {
  1387. var speedVec : Vector;
  1388. var speed, speedMult : float;
  1389.  
  1390.  
  1391. speedVec.X = theInput.GetActionValue( 'GI_AxisLeftX' );
  1392. speedVec.Y = theInput.GetActionValue( 'GI_AxisLeftY' );
  1393. speed = VecLength2D( speedVec );
  1394.  
  1395. return speed > 0.1f;
  1396. }
  1397.  
  1398. function HandleMovement( deltaTime : float )
  1399. {
  1400.  
  1401.  
  1402.  
  1403.  
  1404. if (WouldLikeToMove())
  1405. SetBehaviorVariable( 'playerWouldLikeToMove', 1.0f);
  1406. else
  1407. SetBehaviorVariable( 'playerWouldLikeToMove', 0.0f);
  1408.  
  1409. super.HandleMovement( deltaTime );
  1410. }
  1411.  
  1412. function BattleCryIsReady( ) : bool
  1413. {
  1414. var l_currentTime : float;
  1415.  
  1416. l_currentTime = theGame.GetEngineTimeAsSeconds();
  1417.  
  1418. if( l_currentTime >= battlecry_timeForNext )
  1419. {
  1420. return true;
  1421. }
  1422. return false;
  1423. }
  1424.  
  1425. function PlayBattleCry( _BattleCry : name , _Chance : float, optional _IgnoreDelay, ignoreRepeatCheck : bool )
  1426. {
  1427. var l_randValue : float;
  1428. var fact : int;
  1429.  
  1430. fact = FactsQuerySum("force_stance_normal");
  1431.  
  1432. if( IsSwimming()
  1433. || theGame.IsDialogOrCutscenePlaying()
  1434. || IsInNonGameplayCutscene()
  1435. || IsInGameplayScene()
  1436. || theGame.IsCurrentlyPlayingNonGameplayScene()
  1437. || theGame.IsFading()
  1438. || theGame.IsBlackscreen()
  1439. || FactsQuerySum("force_stance_normal") > 0
  1440. || FactsQuerySum("block_geralts_battlecries") > 0 )
  1441. {
  1442. return;
  1443. }
  1444.  
  1445.  
  1446. if ( !ignoreRepeatCheck )
  1447. {
  1448. if( battlecry_lastTry == _BattleCry )
  1449. return;
  1450. }
  1451.  
  1452. battlecry_lastTry = _BattleCry;
  1453.  
  1454. l_randValue = RandF();
  1455.  
  1456.  
  1457. if( l_randValue < _Chance && ( _IgnoreDelay || BattleCryIsReady() ) )
  1458. {
  1459. thePlayer.PlayVoiceset( 90, _BattleCry );
  1460.  
  1461. battlecry_timeForNext = theGame.GetEngineTimeAsSeconds() + RandRangeF( battlecry_delayMax, battlecry_delayMin );
  1462. }
  1463.  
  1464. }
  1465.  
  1466. public final function OnWeatherChanged()
  1467. {
  1468. if( IsInInterior()
  1469. || GetCurrentStateName() != 'Exploration'
  1470. || theGame.IsDialogOrCutscenePlaying()
  1471. || IsInNonGameplayCutscene()
  1472. || IsInGameplayScene()
  1473. || theGame.IsCurrentlyPlayingNonGameplayScene()
  1474. || theGame.IsFading()
  1475. || theGame.IsBlackscreen()
  1476. || GetTimeSinceSpawned() < 60 )
  1477. {
  1478. return;
  1479. }
  1480.  
  1481. AddTimer( 'CommentOnWeather', 1 );
  1482. }
  1483.  
  1484. public final timer function CommentOnWeather( _Delta : float, _Id : int )
  1485. {
  1486. var l_weather : name;
  1487. var l_currentArea : EAreaName;
  1488. var l_rand : float;
  1489.  
  1490. l_weather = GetWeatherConditionName();
  1491.  
  1492. l_currentArea = theGame.GetCommonMapManager().GetCurrentArea();
  1493.  
  1494. switch ( l_weather )
  1495. {
  1496. case 'WT_Clear':
  1497.  
  1498. l_rand = RandF();
  1499.  
  1500. if( l_rand > 0.66f && !AreaIsCold() && theGame.envMgr.IsDay() )
  1501. {
  1502. thePlayer.PlayVoiceset( 90, 'WeatherHot' );
  1503. }
  1504. else if ( l_rand > 0.33f )
  1505. {
  1506. thePlayer.PlayVoiceset( 90, 'WeatherClearingUp' );
  1507. }
  1508. break;
  1509.  
  1510. case 'WT_Rain_Storm':
  1511. thePlayer.PlayVoiceset( 90, 'WeatherStormy' );
  1512. break;
  1513.  
  1514. case 'WT_Light_Clouds':
  1515. if( previousRainStrength < GetRainStrength() )
  1516. {
  1517. thePlayer.PlayVoiceset( 90, 'WeatherLooksLikeRain' );
  1518. }
  1519. else if( AreaIsCold() && previousWeather == 'WT_Clear' )
  1520. {
  1521. thePlayer.PlayVoiceset( 90, 'WeatherCold' );
  1522. }
  1523. break;
  1524.  
  1525. case 'WT_Mid_Clouds':
  1526. if( previousRainStrength < GetRainStrength() )
  1527. {
  1528. thePlayer.PlayVoiceset( 90, 'WeatherRaining' );
  1529. }
  1530. else if( AreaIsCold() && previousWeather == 'WT_Clear' )
  1531. {
  1532. thePlayer.PlayVoiceset( 90, 'WeatherCold' );
  1533. }
  1534. break;
  1535.  
  1536. case 'WT_Mid_Clouds_Dark':
  1537. if( previousWeather != 'WT_Heavy_Clouds' && previousWeather != 'WT_Heavy_Clouds_Dark' )
  1538. thePlayer.PlayVoiceset( 90, 'WeatherWindy' );
  1539. break;
  1540.  
  1541. case 'WT_Heavy_Clouds':
  1542. if( previousWeather != 'WT_Mid_Clouds_Dark' && previousWeather != 'WT_Heavy_Clouds_Dark' )
  1543. thePlayer.PlayVoiceset( 90, 'WeatherWindy' );
  1544. break;
  1545.  
  1546. case 'WT_Heavy_Clouds_Dark':
  1547. if( thePlayer.IsOnBoat() )
  1548. {
  1549. thePlayer.PlayVoiceset( 90, 'WeatherSeaWillStorm' );
  1550. }
  1551. else if( previousRainStrength < GetRainStrength() )
  1552. {
  1553. thePlayer.PlayVoiceset( 90, 'WeatherLooksLikeRain' );
  1554. }
  1555. else
  1556. {
  1557. thePlayer.PlayVoiceset( 90, 'WeatherWindy' );
  1558. }
  1559. break;
  1560.  
  1561. case 'WT_Snow':
  1562. if( RandF() > 0.5f )
  1563. thePlayer.PlayVoiceset( 90, 'WeatherSnowy' );
  1564. else
  1565. thePlayer.PlayVoiceset( 90, 'WeatherCold' );
  1566. break;
  1567. }
  1568.  
  1569. previousRainStrength = GetRainStrength();
  1570. previousWeather = l_weather;
  1571. }
  1572.  
  1573. function CanUpdateMovement() : bool
  1574. {
  1575. if ( rangedWeapon
  1576. && GetBehaviorVariable( 'fullBodyAnimWeight' ) >= 1.f
  1577. && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  1578. return false;
  1579.  
  1580. return true;
  1581. }
  1582.  
  1583. public function SetDefaultLocomotionController()
  1584. {
  1585. if( !defaultLocomotionController )
  1586. {
  1587. defaultLocomotionController = new CR4LocomotionPlayerControllerScript in this;
  1588. }
  1589.  
  1590. ActionDirectControl( defaultLocomotionController );
  1591. }
  1592.  
  1593. event OnPlayerTickTimer( deltaTime : float )
  1594. {
  1595. var focusModeController : CFocusModeController;
  1596. var cnt : int;
  1597.  
  1598. super.OnPlayerTickTimer( deltaTime );
  1599.  
  1600. HandleMovement( deltaTime );
  1601.  
  1602. if ( playerAiming.GetCurrentStateName() == 'Aiming' )
  1603. {
  1604. FindTarget();
  1605. FindNonActorTarget( false );
  1606. UpdateDisplayTarget();
  1607. UpdateLookAtTarget();
  1608. }
  1609. else
  1610. {
  1611. if( playerTickTimerPhase == 0 )
  1612. {
  1613. FindTarget();
  1614. }
  1615. else if( playerTickTimerPhase == 1 )
  1616. {
  1617. FindNonActorTarget( false );
  1618. }
  1619. else if ( playerTickTimerPhase == 2 )
  1620. {
  1621. UpdateDisplayTarget();
  1622. UpdateLookAtTarget();
  1623. }
  1624. }
  1625.  
  1626.  
  1627.  
  1628. playerTickTimerPhase = ( playerTickTimerPhase + 1 ) % 3;
  1629.  
  1630. focusModeController = theGame.GetFocusModeController();
  1631. focusModeController.UpdateFocusInteractions( deltaTime );
  1632.  
  1633.  
  1634. cnt = (int)( effectManager.GetCriticalBuffsCount() > 0 );
  1635. SetBehaviorVariable('hasCriticalBuff', cnt);
  1636. }
  1637.  
  1638. event OnDeath( damageAction : W3DamageAction )
  1639. {
  1640. super.OnDeath( damageAction );
  1641.  
  1642. RemoveTimer('RequestCriticalAnimStart');
  1643.  
  1644. EnableFindTarget( false );
  1645. BlockAllActions('Death', true);
  1646.  
  1647. EnableHardLock( false );
  1648.  
  1649. theGame.CreateNoSaveLock( 'player_death', deathNoSaveLock, false, false );
  1650. theGame.SetDeathSaveLockId( deathNoSaveLock );
  1651.  
  1652. ClearHostileEnemiesList();
  1653. RemoveReactions();
  1654. SetPlayerCombatTarget(NULL);
  1655. OnEnableAimingMode( false );
  1656.  
  1657. theGame.EnableFreeCamera( false );
  1658. }
  1659.  
  1660.  
  1661. function OnRevived()
  1662. {
  1663. super.OnRevived();
  1664. BlockAllActions('Death', false);
  1665.  
  1666. theGame.ReleaseNoSaveLock(deathNoSaveLock);
  1667.  
  1668. this.RestartReactionsIfNeeded();
  1669. }
  1670.  
  1671. public function CanStartTalk() : bool
  1672. {
  1673. if ( beingWarnedBy.Size() > 0 )
  1674. return false;
  1675.  
  1676. return super.CanStartTalk();
  1677. }
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684. public function AddCounterTimeStamp(time : EngineTime) {counterTimestamps.PushBack(time);}
  1685.  
  1686.  
  1687. public function CheckCounterSpamming(attacker : CActor) : bool
  1688. {
  1689. var counterWindowStartTime : EngineTime;
  1690. var i, spamCounter : int;
  1691. var reflexAction : bool;
  1692. var testEngineTime : EngineTime;
  1693.  
  1694. if(!attacker)
  1695. return false;
  1696.  
  1697. counterWindowStartTime = ((CNewNPC)attacker).GetCounterWindowStartTime();
  1698. spamCounter = 0;
  1699. reflexAction = false;
  1700.  
  1701.  
  1702. if ( counterWindowStartTime == testEngineTime )
  1703. {
  1704. return false;
  1705. }
  1706.  
  1707. for(i = counterTimestamps.Size() - 1; i>=0; i-=1)
  1708. {
  1709.  
  1710. if(counterTimestamps[i] >= (counterWindowStartTime - EngineTimeFromFloat(0.4)) )
  1711. {
  1712. spamCounter += 1;
  1713. }
  1714.  
  1715. else
  1716. {
  1717. counterTimestamps.Remove(counterTimestamps[i]);
  1718. continue;
  1719. }
  1720.  
  1721.  
  1722. if(!reflexAction && (counterTimestamps[i] >= counterWindowStartTime))
  1723. reflexAction = true;
  1724. }
  1725.  
  1726.  
  1727. if(spamCounter == 1 && reflexAction)
  1728. return true;
  1729.  
  1730. return false;
  1731. }
  1732.  
  1733. protected function PerformCounterCheck(parryInfo: SParryInfo) : bool
  1734. {
  1735. var mult : float;
  1736. var parryType : EParryType;
  1737. var validCounter, useKnockdown : bool;
  1738. var slideDistance, duration : float;
  1739. var playerToTargetRot : EulerAngles;
  1740. var zDifference, mutation8TriggerHP : float;
  1741. var effectType : EEffectType;
  1742. var repelType : EPlayerRepelType = PRT_Random;
  1743. var params : SCustomEffectParams;
  1744. var thisPos, attackerPos : Vector;
  1745. var fistFightCheck, isMutation8 : bool;
  1746. var fistFightCounter : bool;
  1747. var attackerInventory : CInventoryComponent;
  1748. var weaponId : SItemUniqueId;
  1749. var weaponTags : array<name>;
  1750. var playerToAttackerVector : Vector;
  1751. var tracePosStart : Vector;
  1752. var tracePosEnd : Vector;
  1753. var hitPos : Vector;
  1754. var hitNormal : Vector;
  1755. var min, max : SAbilityAttributeValue;
  1756. var npc : CNewNPC;
  1757.  
  1758. if(ShouldProcessTutorial('TutorialDodge') || ShouldProcessTutorial('TutorialCounter'))
  1759. {
  1760. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
  1761. FactsRemove("tut_fight_slomo_ON");
  1762. }
  1763.  
  1764. if ( !parryInfo.canBeParried || parryInfo.attacker.HasAbility( 'CannotBeCountered' ) )
  1765. return false;
  1766.  
  1767. fistFightCheck = FistFightCheck( parryInfo.target, parryInfo.attacker, fistFightCounter );
  1768.  
  1769. if( ParryCounterCheck() && parryInfo.targetToAttackerAngleAbs < theGame.params.PARRY_HALF_ANGLE && fistFightCheck )
  1770. {
  1771.  
  1772. validCounter = CheckCounterSpamming(parryInfo.attacker);
  1773.  
  1774. if(validCounter)
  1775. {
  1776. if ( IsInCombatActionFriendly() )
  1777. RaiseEvent('CombatActionFriendlyEnd');
  1778.  
  1779. SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
  1780. SetBehaviorVariable( 'counter', (float)validCounter);
  1781.  
  1782.  
  1783.  
  1784. SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
  1785. SetBehaviorVariable( 'counter', (float)validCounter);
  1786. this.SetBehaviorVariable( 'combatActionType', (int)CAT_Parry );
  1787.  
  1788.  
  1789. if ( !fistFightCounter )
  1790. {
  1791. attackerInventory = parryInfo.attacker.GetInventory();
  1792. weaponId = attackerInventory.GetItemFromSlot('r_weapon');
  1793. attackerInventory.GetItemTags( weaponId , weaponTags );
  1794.  
  1795. if( GetWitcherPlayer().IsMutationActive( EPMT_Mutation8 ) )
  1796. {
  1797. isMutation8 = true;
  1798. theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Mutation8', 'hp_perc_trigger', min, max );
  1799. mutation8TriggerHP = min.valueMultiplicative;
  1800. }
  1801.  
  1802.  
  1803.  
  1804. npc = (CNewNPC)parryInfo.attacker;
  1805.  
  1806.  
  1807. if ( parryInfo.attacker.HasAbility('mon_gravehag') )
  1808. {
  1809. repelType = PRT_Slash;
  1810. parryInfo.attacker.AddEffectDefault(EET_CounterStrikeHit, this, 'ReflexParryPerformed');
  1811.  
  1812. }
  1813. else if ( npc && !npc.IsHuman() && !npc.HasTag( 'dettlaff_vampire' ) )
  1814. {
  1815. repelType = PRT_SideStepSlash;
  1816. }
  1817. else if ( weaponTags.Contains('spear2h') )
  1818. {
  1819. repelType = PRT_SideStepSlash;
  1820. parryInfo.attacker.AddEffectDefault(EET_CounterStrikeHit, this, "ReflexParryPerformed");
  1821. parryInfo.attacker.SignalGameplayEvent( 'SpearDestruction');
  1822. ((CNewNPC)parryInfo.attacker).ProcessSpearDestruction();
  1823. }
  1824. else if( isMutation8 && npc && !npc.IsImmuneToMutation8Finisher() )
  1825. {
  1826. repelType = PRT_RepelToFinisher;
  1827. npc.AddEffectDefault( EET_CounterStrikeHit, this, "ReflexParryPerformed" );
  1828.  
  1829.  
  1830. SetTarget( npc, true );
  1831.  
  1832. PerformFinisher( 0.f, 0 );
  1833. }
  1834. else
  1835. {
  1836.  
  1837. thisPos = this.GetWorldPosition();
  1838. attackerPos = parryInfo.attacker.GetWorldPosition();
  1839. playerToTargetRot = VecToRotation( thisPos - attackerPos );
  1840. zDifference = thisPos.Z - attackerPos.Z;
  1841.  
  1842. if ( playerToTargetRot.Pitch < -5.f && zDifference > 0.35 )
  1843. {
  1844. repelType = PRT_Kick;
  1845.  
  1846. ragdollTarget = parryInfo.attacker;
  1847. AddTimer( 'ApplyCounterRagdollTimer', 0.3 );
  1848. }
  1849. else
  1850. {
  1851. useKnockdown = false;
  1852. if ( CanUseSkill(S_Sword_s11) )
  1853. {
  1854. if( GetSkillLevel(S_Sword_s11) > 1 && RandRangeF(3,0) < GetWitcherPlayer().GetStat(BCS_Focus) )
  1855. {
  1856. duration = CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s11, 'duration', false, true));
  1857. useKnockdown = true;
  1858. }
  1859. }
  1860. else if ( parryInfo.attacker.IsHuman() )
  1861. {
  1862.  
  1863. tracePosStart = parryInfo.attacker.GetWorldPosition();
  1864. tracePosStart.Z += 1.f;
  1865. playerToAttackerVector = VecNormalize( parryInfo.attacker.GetWorldPosition() - parryInfo.target.GetWorldPosition() );
  1866. tracePosEnd = ( playerToAttackerVector * 0.75f ) + ( playerToAttackerVector * parryInfo.attacker.GetRadius() ) + parryInfo.attacker.GetWorldPosition();
  1867. tracePosEnd.Z += 1.f;
  1868.  
  1869. if ( !theGame.GetWorld().StaticTrace( tracePosStart, tracePosEnd, hitPos, hitNormal, counterCollisionGroupNames ) )
  1870. {
  1871. tracePosStart = tracePosEnd;
  1872. tracePosEnd -= 3.f;
  1873.  
  1874. if ( !theGame.GetWorld().StaticTrace( tracePosStart, tracePosEnd, hitPos, hitNormal, counterCollisionGroupNames ) )
  1875. useKnockdown = true;
  1876. }
  1877. }
  1878.  
  1879. if(useKnockdown && (!parryInfo.attacker.IsImmuneToBuff(EET_HeavyKnockdown) || !parryInfo.attacker.IsImmuneToBuff(EET_Knockdown)))
  1880. {
  1881. if(!parryInfo.attacker.IsImmuneToBuff(EET_HeavyKnockdown))
  1882. {
  1883. params.effectType = EET_HeavyKnockdown;
  1884. }
  1885. else
  1886. {
  1887. params.effectType = EET_Knockdown;
  1888. }
  1889.  
  1890. repelType = PRT_Kick;
  1891. params.creator = this;
  1892. params.sourceName = "ReflexParryPerformed";
  1893. params.duration = duration;
  1894.  
  1895. parryInfo.attacker.AddEffectCustom(params);
  1896. }
  1897. else
  1898. {
  1899. parryInfo.attacker.AddEffectDefault(EET_CounterStrikeHit, this, "ReflexParryPerformed");
  1900. }
  1901. }
  1902. }
  1903.  
  1904. parryInfo.attacker.GetInventory().PlayItemEffect(parryInfo.attackerWeaponId, 'counterattack');
  1905.  
  1906.  
  1907. if ( repelType == PRT_Random )
  1908. if ( RandRange(100) > 50 )
  1909. repelType = PRT_Bash;
  1910. else
  1911. repelType = PRT_Kick;
  1912.  
  1913. this.SetBehaviorVariable( 'repelType', (int)repelType );
  1914. parryInfo.attacker.SetBehaviorVariable( 'repelType', (int)repelType );
  1915. }
  1916. else
  1917. {
  1918. parryInfo.attacker.AddEffectDefault(EET_CounterStrikeHit, this, "ReflexParryPerformed");
  1919. }
  1920.  
  1921.  
  1922. SetParryTarget ( parryInfo.attacker );
  1923. SetSlideTarget( parryInfo.attacker );
  1924. if ( !IsActorLockedToTarget() )
  1925. SetMoveTarget( parryInfo.attacker );
  1926.  
  1927. if ( RaiseForceEvent( 'PerformCounter' ) )
  1928. OnCombatActionStart();
  1929.  
  1930. SetCustomRotation( 'Counter', VecHeading( parryInfo.attacker.GetWorldPosition() - this.GetWorldPosition() ), 0.0f, 0.2f, false );
  1931. AddTimer( 'UpdateCounterRotation', 0.4f, true );
  1932. AddTimer( 'SetCounterRotation', 0.2f );
  1933.  
  1934. IncreaseUninterruptedHitsCount();
  1935.  
  1936.  
  1937. if(IsHeavyAttack(parryInfo.attackActionName))
  1938. mult = theGame.params.HEAVY_STRIKE_COST_MULTIPLIER;
  1939.  
  1940. DrainStamina(ESAT_Counterattack, 0, 0, '', 0, mult);
  1941.  
  1942. theGame.GetGamerProfile().IncStat(ES_CounterattackChain);
  1943.  
  1944. }
  1945. else
  1946. {
  1947. ResetUninterruptedHitsCount();
  1948. }
  1949. return validCounter;
  1950. }
  1951.  
  1952. return false;
  1953. }
  1954.  
  1955. timer function UpdateCounterRotation( dt : float, id : int )
  1956. {
  1957. UpdateCustomRotationHeading( 'Counter', VecHeading( parryTarget.GetWorldPosition() - this.GetWorldPosition() ) );
  1958. }
  1959.  
  1960. timer function SetCounterRotation( dt : float, id : int )
  1961. {
  1962. SetCustomRotation( 'Counter', VecHeading( parryTarget.GetWorldPosition() - this.GetWorldPosition() ), 360.f, 0.2f, false );
  1963. }
  1964.  
  1965. private var parryTarget : CActor;
  1966. private function SetParryTarget( t : CActor )
  1967. {
  1968. parryTarget = t;
  1969. }
  1970.  
  1971. private var ragdollTarget : CActor;
  1972. timer function ApplyCounterRagdollTimer( time : float , id : int)
  1973. {
  1974. var actor : CActor;
  1975.  
  1976. actor = (CActor)ragdollTarget;
  1977.  
  1978. if(actor)
  1979. {
  1980. actor.AddEffectDefault(EET_HeavyKnockdown, this, 'ReflexParryPerformed');
  1981. }
  1982. }
  1983.  
  1984.  
  1985.  
  1986.  
  1987. public function EnableMode( mode : EPlayerMode, enable : bool )
  1988. {
  1989. playerMode.EnableMode( mode, enable );
  1990. }
  1991.  
  1992. public function GetPlayerMode() : W3PlayerMode
  1993. {
  1994. return playerMode;
  1995. }
  1996.  
  1997. private function GetClosestIncomingAttacker() : CActor
  1998. {
  1999. var i, size : int;
  2000. var attackerToPlayerDistances : array< float >;
  2001. var closestAttackerIndex : int;
  2002. var incomingAttackers : array<CActor>;
  2003.  
  2004.  
  2005. if(playerMode && playerMode.combatDataComponent)
  2006. {
  2007. if ( incomingAttackers.Size() <= 0 )
  2008. this.playerMode.combatDataComponent.GetTicketSourceOwners( incomingAttackers, 'TICKET_Charge' );
  2009.  
  2010. if ( incomingAttackers.Size() <= 0 )
  2011. this.playerMode.combatDataComponent.GetTicketSourceOwners( incomingAttackers, 'TICKET_Melee' );
  2012.  
  2013. if ( incomingAttackers.Size() <= 0 )
  2014. this.playerMode.combatDataComponent.GetTicketSourceOwners( incomingAttackers, 'TICKET_Range' );
  2015. }
  2016.  
  2017. size = incomingAttackers.Size();
  2018. attackerToPlayerDistances.Resize( size );
  2019.  
  2020. if ( size > 0 )
  2021. {
  2022. for ( i = incomingAttackers.Size()-1; i >= 0; i -= 1)
  2023. {
  2024. if ( !IsEnemyVisible( incomingAttackers[i] ) )
  2025. {
  2026. incomingAttackers.EraseFast( i );
  2027. }
  2028. }
  2029. }
  2030.  
  2031. if ( size > 0 )
  2032. {
  2033. for ( i = 0; i < size; i += 1 )
  2034. {
  2035. attackerToPlayerDistances[i] = VecDistance( incomingAttackers[i].GetWorldPosition(), this.GetWorldPosition() );
  2036. }
  2037. closestAttackerIndex = ArrayFindMinF( attackerToPlayerDistances );
  2038. return incomingAttackers[ closestAttackerIndex ];
  2039. }
  2040. else
  2041. {
  2042. return NULL;
  2043. }
  2044. }
  2045.  
  2046.  
  2047. timer function CombatCheck( time : float , id : int)
  2048. {
  2049. var i : int;
  2050. var strLevel, temp : string;
  2051. var enemies : array<CActor>;
  2052.  
  2053. UpdateFinishableEnemyList();
  2054. FindMoveTarget();
  2055. playerMode.UpdateCombatMode();
  2056.  
  2057. if( GetPlayerCombatStance() == PCS_Guarded )
  2058. {
  2059. if( GetTarget().GetHealthPercents() > 0.25f )
  2060. {
  2061. PlayBattleCry( 'BattleCryTaunt', 0.2f );
  2062. }
  2063. else
  2064. {
  2065. if( GetTarget().IsHuman() )
  2066. PlayBattleCry( 'BattleCryHumansEnd', 0.3f );
  2067. else
  2068. PlayBattleCry( 'BattleCryMonstersEnd', 0.3f );
  2069. }
  2070. }
  2071.  
  2072. if(IsThreatened() && ShouldProcessTutorial('TutorialMonsterThreatLevels') && FactsQuerySum("q001_nightmare_ended") > 0)
  2073. {
  2074. GetEnemiesInRange(enemies);
  2075. for(i=0; i<enemies.Size(); i+=1)
  2076. {
  2077. strLevel = ((CNewNPC)enemies[i]).GetExperienceDifferenceLevelName(temp);
  2078. if(strLevel == "deadlyLevel" || strLevel == "highLevel")
  2079. {
  2080. FactsAdd("tut_high_threat_monster");
  2081. break;
  2082. }
  2083. }
  2084. }
  2085. }
  2086.  
  2087. public function ReceivedDamageInCombat() : bool
  2088. {
  2089. return receivedDamageInCombat;
  2090. }
  2091.  
  2092. //---=== modFriendlyHUD ===---
  2093. timer function PinEssentialGroupTimer( deltaTime : float, id : int )
  2094. {
  2095. ToggleEssentialModules( !IsHUDGroupEnabledForReason( GetFHUDConfig().essentialModules, "PinEssentialGroup" ), "PinEssentialGroup" );
  2096. }
  2097.  
  2098. timer function EssentialsOnTimer( deltaTime : float, id : int )
  2099. {
  2100. ToggleEssentialModules( true, "EssentialModulesHotkey" );
  2101. }
  2102.  
  2103. timer function MapOnTimer( deltaTime : float, id : int )
  2104. {
  2105. ToggleMinimapModules( true, "MinimapModulesHotkey" );
  2106. }
  2107.  
  2108. timer function QuestsOnTimer( deltaTime : float, id : int )
  2109. {
  2110. ToggleQuestsModules( true, "QuestsModulesHotkey" );
  2111. }
  2112.  
  2113. timer function CharOnTimer( deltaTime : float, id : int )
  2114. {
  2115. ToggleCharacterModules( true, "CharModulesHotkey" );
  2116. }
  2117.  
  2118. timer function DamageOffTimer( deltaTime : float, id : int ) //still needed as workaround
  2119. {
  2120. ToggleHUDModule( "WolfHeadModule", false, "OnDamage" );
  2121. }
  2122.  
  2123. timer function MeditationModulesOnTimer( deltaTime : float, id : int ) //needed for compatibility
  2124. {
  2125. if ( GetFHUDConfig().enableMeditationModules )
  2126. {
  2127. ToggleMeditModules( true, "RealTimeMeditation" );
  2128. }
  2129. }
  2130.  
  2131. timer function MeditationModulesOffTimer( deltaTime : float, id : int ) //needed for compatibility
  2132. {
  2133. if ( GetFHUDConfig().enableMeditationModules )
  2134. {
  2135. ToggleMeditModules( false, "RealTimeMeditation" );
  2136. }
  2137. }
  2138. //---=== modFriendlyHUD ===---
  2139.  
  2140. event OnCombatStart()
  2141. {
  2142. var weaponType : EPlayerWeapon;
  2143.  
  2144. //---=== modFriendlyHUD ===---
  2145. if ( GetFHUDConfig().enableCombatModules )
  2146. {
  2147. ToggleCombatModules( true, "InCombat" );
  2148. }
  2149. //---=== modFriendlyHUD ===---
  2150.  
  2151. theGame.CreateNoSaveLock( 'combat', noSaveLock );
  2152.  
  2153. theGame.GameplayFactsAdd( "in_combat" );
  2154.  
  2155.  
  2156. FactsRemove("statistics_cerberus_sign");
  2157. FactsRemove("statistics_cerberus_petard");
  2158. FactsRemove("statistics_cerberus_bolt");
  2159. FactsRemove("statistics_cerberus_fists");
  2160. FactsRemove("statistics_cerberus_melee");
  2161. FactsRemove("statistics_cerberus_environment");
  2162.  
  2163. BlockAction(EIAB_OpenMeditation, 'InCombat');
  2164. BlockAction(EIAB_HighlightObjective, 'InCombat');
  2165.  
  2166. if ( !this.IsUsingBoat() && GetTarget().GetAttitude(this) == AIA_Hostile )
  2167. {
  2168. weaponType = GetMostConvenientMeleeWeapon( GetTarget() );
  2169.  
  2170. if ( weaponType == PW_Steel || weaponType == PW_Silver )
  2171. this.OnEquipMeleeWeapon( weaponType, false );
  2172. }
  2173. }
  2174.  
  2175.  
  2176. event OnCombatFinished()
  2177. {
  2178. var cnt : int;
  2179.  
  2180. //---=== modFriendlyHUD ===---
  2181. if ( GetFHUDConfig().enableCombatModules )
  2182. {
  2183. ToggleCombatModules( false, "InCombat" );
  2184. }
  2185. //---=== modFriendlyHUD ===---
  2186.  
  2187. reevaluateCurrentWeapon = false;
  2188.  
  2189. thePlayer.HardLockToTarget( false );
  2190.  
  2191. receivedDamageInCombat = false;
  2192.  
  2193. theGame.GameplayFactsRemove( "in_combat" );
  2194.  
  2195.  
  2196. cnt = 0;
  2197. if(FactsQuerySum("statistics_cerberus_sign") > 0)
  2198. cnt += 1;
  2199. if(FactsQuerySum("statistics_cerberus_petard") > 0)
  2200. cnt += 1;
  2201. if(FactsQuerySum("statistics_cerberus_bolt") > 0)
  2202. cnt += 1;
  2203. if(FactsQuerySum("statistics_cerberus_fists") > 0)
  2204. cnt += 1;
  2205. if(FactsQuerySum("statistics_cerberus_melee") > 0)
  2206. cnt += 1;
  2207. if(FactsQuerySum("statistics_cerberus_environment") > 0)
  2208. cnt += 1;
  2209.  
  2210.  
  2211. FactsRemove("statistics_cerberus_sign");
  2212. FactsRemove("statistics_cerberus_petard");
  2213. FactsRemove("statistics_cerberus_bolt");
  2214. FactsRemove("statistics_cerberus_fists");
  2215. FactsRemove("statistics_cerberus_melee");
  2216. FactsRemove("statistics_cerberus_environment");
  2217.  
  2218. if(cnt >= 3)
  2219. {
  2220. theGame.GetGamerProfile().AddAchievement(EA_Cerberus);
  2221. }
  2222. else
  2223. {
  2224. theGame.GetGamerProfile().NoticeAchievementProgress(EA_Cerberus, cnt);
  2225. }
  2226.  
  2227.  
  2228. if(theGame.GetTutorialSystem() && FactsQuerySum("TutorialShowSilver") > 0)
  2229. {
  2230. FactsAdd("tut_show_silver_sword", 1);
  2231. FactsRemove("TutorialShowSilver");
  2232. }
  2233. this.SetBehaviorVariable('isInCombatForOverlay',0.f);
  2234. GoToExplorationIfNeeded();
  2235. theGame.ReleaseNoSaveLock( noSaveLock );
  2236. LogChannel( 'OnCombatFinished', "OnCombatFinished: ReleaseNoSaveLock" );
  2237.  
  2238. SetFailedFundamentalsFirstAchievementCondition(false);
  2239.  
  2240. UnblockAction(EIAB_OpenMeditation, 'InCombat');
  2241. UnblockAction(EIAB_HighlightObjective, 'InCombat');
  2242. }
  2243.  
  2244. event OnReactToBeingHit( damageAction : W3DamageAction )
  2245. {
  2246. var weaponType : EPlayerWeapon;
  2247.  
  2248. super.OnReactToBeingHit(damageAction);
  2249. IncHitCounter();
  2250.  
  2251. if ( IsInCombat() && damageAction.attacker && damageAction.attacker == GetTarget() && !( this.IsUsingVehicle() && this.IsOnBoat() ) )
  2252. {
  2253. weaponType = GetMostConvenientMeleeWeapon( GetTarget() );
  2254. if ( weaponType != PW_Fists && weaponType != PW_None && weaponType != this.GetCurrentMeleeWeaponType() )
  2255. OnEquipMeleeWeapon( weaponType, false );
  2256. }
  2257. }
  2258.  
  2259.  
  2260. public function ReceivedCombatDamage()
  2261. {
  2262. receivedDamageInCombat = true;
  2263. }
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270. timer function UninterruptedHitsResetOnIdle(dt : float, id : int)
  2271. {
  2272. ResetUninterruptedHitsCount();
  2273. }
  2274.  
  2275. public function ResetUninterruptedHitsCount()
  2276. {
  2277. uninterruptedHitsCount = 0;
  2278. LogUnitAtt("Uninterrupted attacks reset!!!!");
  2279. }
  2280.  
  2281. public function IncreaseUninterruptedHitsCount()
  2282. {
  2283. uninterruptedHitsCount += 1;
  2284. LogUnitAtt("Uninterrupted attacks count increased to " + uninterruptedHitsCount);
  2285.  
  2286. if(uninterruptedHitsCount == 4)
  2287. AddTimer('StartUninterruptedBlurr', 1, false);
  2288.  
  2289.  
  2290. AddTimer('UninterruptedHitsResetOnIdle', 4.f, false);
  2291. }
  2292.  
  2293. timer function StartUninterruptedBlurr(dt : float, id : int)
  2294. {
  2295. var changed : bool;
  2296. var movingAgent : CMovingPhysicalAgentComponent;
  2297. var target : CActor;
  2298.  
  2299.  
  2300. if(uninterruptedHitsCount < 4)
  2301. {
  2302. LogUnitAtt("Stopping camera effect");
  2303. thePlayer.StopEffect(uninterruptedHitsCurrentCameraEffect);
  2304. uninterruptedHitsCurrentCameraEffect = '';
  2305. uninterruptedHitsCameraStarted = false;
  2306. RemoveTimer('StartUninterruptedBlurr');
  2307. }
  2308. else
  2309. {
  2310. target = GetTarget();
  2311.  
  2312. if( target )
  2313. {
  2314. movingAgent = ( (CMovingPhysicalAgentComponent) (target.GetMovingAgentComponent()) );
  2315. }
  2316.  
  2317. if(!uninterruptedHitsCameraStarted)
  2318. {
  2319. LogUnitAtt("Starting camera effect");
  2320. AddTimer('StartUninterruptedBlurr', 0.001, true);
  2321. if(movingAgent && movingAgent.GetCapsuleHeight() > 2)
  2322. uninterruptedHitsCurrentCameraEffect = theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_BIG_ENEMY;
  2323. else
  2324. uninterruptedHitsCurrentCameraEffect = theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_REGULAR_ENEMY;
  2325. thePlayer.PlayEffect(uninterruptedHitsCurrentCameraEffect);
  2326. uninterruptedHitsCameraStarted = true;
  2327. }
  2328. else
  2329. {
  2330. changed = false;
  2331. if(movingAgent && movingAgent.GetCapsuleHeight() > 2 && uninterruptedHitsCurrentCameraEffect != theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_BIG_ENEMY)
  2332. changed = true;
  2333. else if(!movingAgent || ( movingAgent.GetCapsuleHeight() <= 2 && uninterruptedHitsCurrentCameraEffect != theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_REGULAR_ENEMY) )
  2334. changed = true;
  2335.  
  2336.  
  2337. if(changed)
  2338. {
  2339.  
  2340. thePlayer.StopEffect(uninterruptedHitsCurrentCameraEffect);
  2341.  
  2342.  
  2343. if(uninterruptedHitsCurrentCameraEffect == theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_BIG_ENEMY)
  2344. uninterruptedHitsCurrentCameraEffect = theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_REGULAR_ENEMY;
  2345. else
  2346. uninterruptedHitsCurrentCameraEffect = theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_BIG_ENEMY;
  2347.  
  2348.  
  2349. thePlayer.PlayEffect(uninterruptedHitsCurrentCameraEffect);
  2350. }
  2351. }
  2352. }
  2353. }
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359. private var playerActionEventListeners : array<CGameplayEntity>;
  2360. private var playerActionEventBlockingListeners : array<CGameplayEntity>;
  2361.  
  2362. private function PlayerActionBlockGameplayActions( sourceName : name, lock : bool, isFromPlace : bool )
  2363. {
  2364. if ( lock )
  2365. {
  2366. thePlayer.BlockAction( EIAB_Signs, sourceName, false, false, isFromPlace );
  2367. thePlayer.BlockAction( EIAB_DrawWeapon, sourceName, false, false, isFromPlace );
  2368. thePlayer.BlockAction( EIAB_CallHorse, sourceName, false, false, isFromPlace );
  2369. thePlayer.BlockAction( EIAB_FastTravel, sourceName, false, false, isFromPlace );
  2370. thePlayer.BlockAction( EIAB_Fists, sourceName, false, false, isFromPlace );
  2371. thePlayer.BlockAction( EIAB_InteractionAction, sourceName, false, false, isFromPlace );
  2372. thePlayer.DisableCombatState();
  2373. }
  2374. else
  2375. {
  2376. thePlayer.UnblockAction( EIAB_Signs, sourceName );
  2377. thePlayer.UnblockAction( EIAB_DrawWeapon, sourceName );
  2378. thePlayer.UnblockAction( EIAB_CallHorse, sourceName );
  2379. thePlayer.UnblockAction( EIAB_FastTravel, sourceName );
  2380. thePlayer.UnblockAction( EIAB_Fists, sourceName );
  2381. thePlayer.UnblockAction( EIAB_InteractionAction, sourceName );
  2382. }
  2383. }
  2384.  
  2385. public function GetPlayerActionEventListeners() : array<CGameplayEntity>
  2386. {
  2387. return playerActionEventListeners;
  2388. }
  2389.  
  2390.  
  2391. public function RegisterForPlayerAction( listener : CGameplayEntity, isLockedByPlace : bool )
  2392. {
  2393. if ( !playerActionEventListeners.Contains( listener ) )
  2394. {
  2395. playerActionEventListeners.PushBack( listener );
  2396. }
  2397. if ( listener.ShouldBlockGameplayActionsOnInteraction() )
  2398. {
  2399. if ( !playerActionEventBlockingListeners.Contains( listener ) )
  2400. {
  2401. playerActionEventBlockingListeners.PushBack( listener );
  2402. }
  2403. if ( playerActionEventBlockingListeners.Size() == 1 )
  2404. {
  2405. PlayerActionBlockGameplayActions( 'PlayerAction', true, isLockedByPlace );
  2406. }
  2407. }
  2408. }
  2409.  
  2410.  
  2411. public function UnregisterForPlayerAction( listener : CGameplayEntity, isLockedByPlace : bool )
  2412. {
  2413. playerActionEventListeners.Remove( listener );
  2414. playerActionEventBlockingListeners.Remove( listener );
  2415. if ( playerActionEventBlockingListeners.Size() == 0 )
  2416. {
  2417. PlayerActionBlockGameplayActions( 'PlayerAction', false, isLockedByPlace );
  2418. }
  2419. }
  2420.  
  2421. event OnPlayerActionStart()
  2422. {
  2423.  
  2424. thePlayer.SetBehaviorVariable( 'inJumpState', 1.f );
  2425. }
  2426.  
  2427. event OnPlayerActionEnd()
  2428. {
  2429. var i : int;
  2430. for ( i = playerActionEventListeners.Size() - 1; i >= 0; i-=1 )
  2431. {
  2432. playerActionEventListeners[i].OnPlayerActionEnd();
  2433. }
  2434. currentCustomAction = PEA_None;
  2435.  
  2436.  
  2437. thePlayer.SetBehaviorVariable( 'inJumpState', 0.f );
  2438. }
  2439.  
  2440. event OnPlayerActionStartFinished()
  2441. {
  2442. var i : int;
  2443. for ( i = playerActionEventListeners.Size() - 1; i >= 0; i-=1 )
  2444. {
  2445. playerActionEventListeners[i].OnPlayerActionStartFinished();
  2446. }
  2447. }
  2448.  
  2449. function PlayerStartAction( playerAction : EPlayerExplorationAction, optional animName : name ) : bool
  2450. {
  2451. if ( playerAction == PEA_SlotAnimation && !IsNameValid(animName) )
  2452. {
  2453. return false;
  2454. }
  2455.  
  2456. SetBehaviorVariable( 'playerStopAction', 0.0);
  2457. SetBehaviorVariable( 'playerExplorationAction', (float)(int)playerAction);
  2458.  
  2459.  
  2460.  
  2461. if ( RaiseForceEvent('playerActionStart') )
  2462. {
  2463. currentCustomAction = playerAction;
  2464. if ( playerAction == PEA_SlotAnimation )
  2465. {
  2466. playerActionSlotAnimName = animName;
  2467. AddTimer('PlayActionAnimWorkaround',0,false);
  2468. }
  2469. return true;
  2470. }
  2471. return false;
  2472. }
  2473.  
  2474. private var playerActionSlotAnimName : name;
  2475.  
  2476. timer function PlayActionAnimWorkaround( dt : float , id : int)
  2477. {
  2478. this.ActionPlaySlotAnimationAsync('PLAYER_ACTION_SLOT',playerActionSlotAnimName, 0.2, 0.2, true);
  2479. }
  2480.  
  2481. function PlayerStopAction( playerAction : EPlayerExplorationAction )
  2482. {
  2483. SetBehaviorVariable( 'playerExplorationAction', (float)(int)playerAction);
  2484. SetBehaviorVariable( 'playerStopAction', 1.0);
  2485. currentCustomAction = PEA_None;
  2486. }
  2487.  
  2488. function GetPlayerAction() : EPlayerExplorationAction
  2489. {
  2490. return currentCustomAction;
  2491. }
  2492.  
  2493. function MedallionPing()
  2494. {
  2495. var currTime : float = theGame.GetEngineTimeAsSeconds();
  2496.  
  2497. if ( lastMedallionEffect < currTime )
  2498. {
  2499. lastMedallionEffect = theGame.GetEngineTimeAsSeconds() + medallion.effectDuration;
  2500. medallion.TriggerMedallionFX();
  2501. }
  2502. }
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508. public function CanPerformPlayerAction(optional alsoOutsideExplorationState : bool) : bool
  2509. {
  2510.  
  2511. if(!alsoOutsideExplorationState && GetCurrentStateName() != 'Exploration')
  2512. return false;
  2513.  
  2514. if( isInAir || (substateManager && !substateManager.CanInteract()) || IsInCombatAction() || GetCriticalBuffsCount() > 0)
  2515. return false;
  2516.  
  2517. return true;
  2518. }
  2519.  
  2520.  
  2521. event OnItemGiven(data : SItemChangedData)
  2522. {
  2523. var keyName : name;
  2524. var i : int;
  2525. var hud : CR4ScriptedHud;
  2526. var message : string;
  2527. var inve : CInventoryComponent;
  2528.  
  2529. if(data.informGui)
  2530. {
  2531. hud = (CR4ScriptedHud)theGame.GetHud();
  2532. if(hud)
  2533. {
  2534. message = GetLocStringByKeyExt("panel_common_item_received") + ": " + GetLocStringByKeyExt(inv.GetItemLocalizedNameByUniqueID(data.ids[0]));
  2535. if(data.quantity > 1)
  2536. message += " x" + data.quantity;
  2537. hud.HudConsoleMsg(message);
  2538. }
  2539. }
  2540.  
  2541. inve = GetInventory();
  2542.  
  2543.  
  2544. if(inve.ItemHasTag(data.ids[0], 'key'))
  2545. {
  2546. keyName = inve.GetItemName(data.ids[0]);
  2547. for(i=nearbyLockedContainersNoKey.Size()-1; i>=0; i-=1)
  2548. {
  2549. if(nearbyLockedContainersNoKey[i].GetKeyName() == keyName && nearbyLockedContainersNoKey[i].IsEnabled())
  2550. {
  2551. nearbyLockedContainersNoKey[i].UpdateComponents("Unlock");
  2552. nearbyLockedContainersNoKey.Remove(nearbyLockedContainersNoKey[i]);
  2553. }
  2554. }
  2555. }
  2556.  
  2557.  
  2558. if(inve.IsItemAlchemyItem(data.ids[0]))
  2559. {
  2560. UpgradeAlchemyItem(data.ids[0], CanUseSkill(S_Perk_08));
  2561. }
  2562.  
  2563. if(inve.ItemHasTag(data.ids[0], theGame.params.TAG_OFIR_SET))
  2564. CheckOfirSetAchievement();
  2565. }
  2566.  
  2567. private final function CheckOfirSetAchievement()
  2568. {
  2569. var hasArmor, hasBoots, hasGloves, hasPants, hasSword, hasSaddle, hasBag, hasBlinders : bool;
  2570. var doneItems : int;
  2571.  
  2572.  
  2573. CheckOfirItems(GetInventory(), hasArmor, hasBoots, hasGloves, hasPants, hasSword, hasSaddle, hasBag, hasBlinders);
  2574.  
  2575.  
  2576. CheckOfirItems(GetWitcherPlayer().GetHorseManager().GetInventoryComponent(), hasArmor, hasBoots, hasGloves, hasPants, hasSword, hasSaddle, hasBag, hasBlinders);
  2577.  
  2578.  
  2579. doneItems = 0;
  2580. if(hasArmor)
  2581. doneItems += 1;
  2582. if(hasBoots)
  2583. doneItems += 1;
  2584. if(hasGloves)
  2585. doneItems += 1;
  2586. if(hasPants)
  2587. doneItems += 1;
  2588. if(hasSword)
  2589. doneItems += 1;
  2590. if(hasSaddle)
  2591. doneItems += 1;
  2592. if(hasBag)
  2593. doneItems += 1;
  2594. if(hasBlinders)
  2595. doneItems += 1;
  2596.  
  2597. if(doneItems >= 8)
  2598. {
  2599. theGame.GetGamerProfile().AddAchievement(EA_LatestFashion);
  2600. }
  2601. else
  2602. {
  2603. theGame.GetGamerProfile().NoticeAchievementProgress(EA_LatestFashion, doneItems);
  2604. }
  2605. }
  2606.  
  2607. private final function CheckOfirItems(inv : CInventoryComponent, out hasArmor : bool, out hasBoots : bool, out hasGloves : bool, out hasPants : bool, out hasSword : bool, out hasSaddle : bool, out hasBag : bool, out hasBlinders : bool)
  2608. {
  2609. var ofirs : array<SItemUniqueId>;
  2610. var i : int;
  2611.  
  2612. ofirs = inv.GetItemsByTag(theGame.params.TAG_OFIR_SET);
  2613. for(i=0; i<ofirs.Size(); i+=1)
  2614. {
  2615. if(inv.IsItemChestArmor(ofirs[i]))
  2616. {
  2617. hasArmor = true;
  2618. continue;
  2619. }
  2620. else if(inv.IsItemBoots(ofirs[i]))
  2621. {
  2622. hasBoots = true;
  2623. continue;
  2624. }
  2625. else if(inv.IsItemGloves(ofirs[i]))
  2626. {
  2627. hasGloves = true;
  2628. continue;
  2629. }
  2630. else if(inv.IsItemPants(ofirs[i]))
  2631. {
  2632. hasPants = true;
  2633. continue;
  2634. }
  2635. else if(inv.IsItemSteelSwordUsableByPlayer(ofirs[i]))
  2636. {
  2637. hasSword = true;
  2638. continue;
  2639. }
  2640. else if(inv.IsItemSilverSwordUsableByPlayer(ofirs[i]))
  2641. {
  2642. hasSword = true;
  2643. continue;
  2644. }
  2645. else if(inv.IsItemSaddle(ofirs[i]))
  2646. {
  2647. hasSaddle = true;
  2648. continue;
  2649. }
  2650. else if(inv.IsItemHorseBag(ofirs[i]))
  2651. {
  2652. hasBag = true;
  2653. continue;
  2654. }
  2655. else if(inv.IsItemBlinders(ofirs[i]))
  2656. {
  2657. hasBlinders = true;
  2658. continue;
  2659. }
  2660. }
  2661. }
  2662.  
  2663.  
  2664. public function ChangeAlchemyItemsAbilities(upgrade : bool)
  2665. {
  2666. var i : int;
  2667. var dm : CDefinitionsManagerAccessor;
  2668. var items : array<SItemUniqueId>;
  2669.  
  2670. inv.GetAllItems(items);
  2671. dm = theGame.GetDefinitionsManager();
  2672.  
  2673. for(i=0; i<items.Size(); i+=1)
  2674. if(inv.IsItemAlchemyItem(items[i]))
  2675. UpgradeAlchemyItem(items[i], upgrade);
  2676. }
  2677.  
  2678.  
  2679. public function UpgradeAlchemyItem(itemID : SItemUniqueId, upgrade : bool)
  2680. {
  2681. var j, currLevel, otherLevel : int;
  2682. var dm : CDefinitionsManagerAccessor;
  2683. var abs, currAbilities, otherAbilities : array<name>;
  2684. var min, max : SAbilityAttributeValue;
  2685.  
  2686. if(!inv.IsItemAlchemyItem(itemID))
  2687. return;
  2688.  
  2689.  
  2690. currLevel = (int)CalculateAttributeValue(inv.GetItemAttributeValue(itemID, 'level'));
  2691.  
  2692.  
  2693. if(currLevel == 3 || currLevel == 2 || currLevel < 2 || currLevel > 3)
  2694. return;
  2695.  
  2696.  
  2697. currAbilities = inv.GetItemAbilitiesWithAttribute(itemID, 'level', currLevel);
  2698.  
  2699.  
  2700. inv.GetItemContainedAbilities(itemID, abs);
  2701. dm = theGame.GetDefinitionsManager();
  2702. for(j=0; j<abs.Size(); j+=1)
  2703. {
  2704. dm.GetAbilityAttributeValue(abs[j], 'level', min, max);
  2705. otherLevel = (int)CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  2706. if( (otherLevel == 2 || otherLevel == 3) && otherLevel != currLevel)
  2707. otherAbilities.PushBack(abs[j]);
  2708. }
  2709.  
  2710.  
  2711. if(otherAbilities.Size() == 0)
  2712. {
  2713. LogAssert(false, "CR4Player.UpgradeAlchemyItem: cannot find ability to swap to from <<" + currAbilities[0] + ">> on item <<" + inv.GetItemName(itemID) + ">> !!!");
  2714. }
  2715. else
  2716. {
  2717. for(j=0; j<currAbilities.Size(); j+=1)
  2718. inv.RemoveItemBaseAbility(itemID, currAbilities[j]);
  2719.  
  2720. for(j=0; j<otherAbilities.Size(); j+=1)
  2721. inv.AddItemBaseAbility(itemID, otherAbilities[j]);
  2722. }
  2723. }
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729. public function MovAdjRotateToTarget( ticket : SMovementAdjustmentRequestTicket )
  2730. {
  2731. var movementAdjustor : CMovementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  2732. var localOrientationTarget : EOrientationTarget = GetOrientationTarget();
  2733.  
  2734. if ( localOrientationTarget == OT_CustomHeading )
  2735. {
  2736. movementAdjustor.RotateTo( ticket, GetOrientationTargetCustomHeading() );
  2737. }
  2738. else if ( localOrientationTarget == OT_Actor )
  2739. {
  2740. if ( slideTarget )
  2741. movementAdjustor.RotateTowards( ticket, slideTarget );
  2742. else if ( lAxisReleasedAfterCounter )
  2743. movementAdjustor.RotateTo( ticket, GetHeading() );
  2744. else
  2745. movementAdjustor.RotateTo( ticket, GetCombatActionHeading() );
  2746. }
  2747. else if ( localOrientationTarget == OT_Player )
  2748. {
  2749. if ( bLAxisReleased )
  2750. movementAdjustor.RotateTo( ticket, GetHeading() );
  2751. else
  2752. movementAdjustor.RotateTo( ticket, rawPlayerHeading );
  2753. }
  2754. else if ( localOrientationTarget == OT_CameraOffset )
  2755. {
  2756.  
  2757. movementAdjustor.RotateTo( ticket, VecHeading( theCamera.GetCameraDirection() ) );
  2758. }
  2759. else
  2760. {
  2761.  
  2762. movementAdjustor.RotateTo( ticket, rawCameraHeading );
  2763. }
  2764.  
  2765. }
  2766.  
  2767.  
  2768.  
  2769.  
  2770.  
  2771. public function UpdateLookAtTarget()
  2772. {
  2773. var localOrientationTarget : EOrientationTarget;
  2774. var playerRot : EulerAngles;
  2775. var lookAtActive : Float;
  2776. var lookAtTarget : Vector;
  2777. var headBoneIdx : int;
  2778. var tempComponent : CDrawableComponent;
  2779. var entityHeight : float;
  2780. var useTorsoBone : bool;
  2781.  
  2782. var angles : EulerAngles;
  2783. var dir : Vector;
  2784. var camZ : float;
  2785.  
  2786. var target : CActor;
  2787.  
  2788. lookAtActive = 0.0f;
  2789.  
  2790. localOrientationTarget = GetOrientationTarget();
  2791.  
  2792. if ( localOrientationTarget == OT_Player || localOrientationTarget == OT_CustomHeading )
  2793. {
  2794.  
  2795.  
  2796.  
  2797.  
  2798. if ( localOrientationTarget == OT_Player )
  2799. angles = VecToRotation( GetHeadingVector() );
  2800. else if ( customOrientationInfoStack.Size() > 0 )
  2801. angles = VecToRotation( VecFromHeading( customOrientationInfoStack[ customOrientationInfoStack.Size() - 1 ].customHeading ) );
  2802. else
  2803. angles = VecToRotation( GetHeadingVector() );
  2804.  
  2805.  
  2806. dir = RotForward( angles );
  2807. lookAtTarget = dir * 30.f + this.GetWorldPosition();
  2808. lookAtTarget.Z += 1.6f;
  2809. lookAtActive = 1.0f;
  2810. }
  2811. else if ( localOrientationTarget == OT_Camera )
  2812. {
  2813. headBoneIdx = GetHeadBoneIndex();
  2814. if ( headBoneIdx >= 0 )
  2815. {
  2816. lookAtTarget = MatrixGetTranslation( GetBoneWorldMatrixByIndex( headBoneIdx ) );
  2817. }
  2818. else
  2819. {
  2820. lookAtTarget = GetWorldPosition();
  2821. lookAtTarget.Z += 1.6f;
  2822. }
  2823. lookAtTarget += theCamera.GetCameraDirection() * 100.f;
  2824. lookAtActive = 1.0f;
  2825. }
  2826. else if ( localOrientationTarget == OT_CameraOffset )
  2827. {
  2828.  
  2829.  
  2830. dir = theCamera.GetCameraDirection();
  2831. angles = VecToRotation( dir );
  2832. angles.Pitch = -angles.Pitch + oTCameraPitchOffset;
  2833. angles.Yaw -= oTCameraOffset;
  2834. dir = RotForward( angles );
  2835.  
  2836. lookAtTarget = dir * 30.f + this.GetWorldPosition();
  2837. lookAtTarget.Z += 1.6f;
  2838. lookAtActive = 1.0f;
  2839. }
  2840. else if ( localOrientationTarget == OT_Actor )
  2841. {
  2842. if ( IsInCombatAction() )
  2843. {
  2844. if ( ( ( ( W3PlayerWitcher )this ).GetCurrentlyCastSign() != ST_None && GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign )
  2845. || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_ItemThrow )
  2846.  
  2847. useTorsoBone = true;
  2848. }
  2849.  
  2850. if ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  2851. useTorsoBone = true;
  2852.  
  2853. if ( tempLookAtTarget && (CActor)(tempLookAtTarget) )
  2854. {
  2855. lookAtTarget = ProcessLookAtTargetPosition( tempLookAtTarget, useTorsoBone );
  2856. lookAtActive = 1.0f;
  2857. }
  2858.  
  2859. if ( GetDisplayTarget() && IsDisplayTargetTargetable() )
  2860. {
  2861. lookAtTarget = ProcessLookAtTargetPosition( GetDisplayTarget(), useTorsoBone );
  2862. lookAtActive = 1.0f;
  2863. }
  2864. else
  2865. {
  2866.  
  2867.  
  2868. if ( slideTarget )
  2869. {
  2870. lookAtTarget = ProcessLookAtTargetPosition( slideTarget, useTorsoBone );
  2871. }
  2872. else
  2873. {
  2874. target = GetTarget();
  2875. if ( target )
  2876. {
  2877. lookAtTarget = ProcessLookAtTargetPosition( target, useTorsoBone );
  2878. }
  2879. }
  2880.  
  2881. lookAtActive = 1.0f;
  2882. }
  2883.  
  2884. if ( !slideTarget && !IsUsingVehicle() )
  2885. {
  2886.  
  2887. playerRot = GetWorldRotation();
  2888. lookAtTarget = GetWorldPosition() + VecFromHeading( playerRot.Yaw ) * 100.0f;
  2889. lookAtActive = 0.0f;
  2890. }
  2891.  
  2892. if ( useTorsoBone )
  2893. lookAtTarget.Z += 0.2f;
  2894. }
  2895.  
  2896.  
  2897.  
  2898.  
  2899. GetVisualDebug().AddSphere('lookAtTarget', 1.f, lookAtTarget, true, Color(255,0,0), 3.0f );
  2900. SetLookAtPosition( lookAtTarget );
  2901. UpdateLookAtVariables( lookAtActive, lookAtTarget );
  2902. }
  2903.  
  2904. private function ProcessLookAtTargetPosition( ent : CGameplayEntity, useTorsoBone : bool ) : Vector
  2905. {
  2906. var boneIdx : int;
  2907. var actor : CActor;
  2908. var lookAtTarget : Vector;
  2909. var tempComponent : CDrawableComponent;
  2910. var box : Box;
  2911. var entityHeight : float;
  2912. var entityPos : Vector;
  2913. var predictedPos : Vector;
  2914. var z : float;
  2915. var entMat : Matrix;
  2916.  
  2917. actor = (CActor)(ent);
  2918. entityPos = ent.GetWorldPosition();
  2919. lookAtTarget = entityPos;
  2920.  
  2921. if ( actor )
  2922. {
  2923. if ( useTorsoBone )
  2924. boneIdx = actor.GetTorsoBoneIndex();
  2925. else
  2926. boneIdx = actor.GetHeadBoneIndex();
  2927. }
  2928. else
  2929. boneIdx = -1;
  2930.  
  2931. if ( !( ent.aimVector.X == 0 && ent.aimVector.Y == 0 && ent.aimVector.Z == 0 ) )
  2932. {
  2933. entMat = ent.GetLocalToWorld();
  2934. lookAtTarget = VecTransform( entMat, ent.aimVector );
  2935. }
  2936. else if ( boneIdx >= 0 )
  2937. {
  2938. lookAtTarget = MatrixGetTranslation( ent.GetBoneWorldMatrixByIndex( boneIdx ) );
  2939. }
  2940. else
  2941. {
  2942. if ( actor )
  2943. lookAtTarget.Z += ( ((CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent()).GetCapsuleHeight() * 0.5 );
  2944. else
  2945. {
  2946. tempComponent = (CDrawableComponent)( ent.GetComponentByClassName('CDrawableComponent') );
  2947. if ( tempComponent.GetObjectBoundingVolume( box ) )
  2948. {
  2949. entityHeight = box.Max.Z - box.Min.Z;
  2950. lookAtTarget = lookAtTarget + Vector(0,0,entityHeight/2);
  2951. }
  2952. }
  2953. }
  2954. z = ((CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent()).GetCapsuleHeight();
  2955. if ( actor )
  2956. {
  2957. if ( PredictLookAtTargetPosition( actor, lookAtTarget.Z - entityPos.Z, predictedPos ) )
  2958. lookAtTarget = predictedPos;
  2959. }
  2960.  
  2961. return lookAtTarget;
  2962. }
  2963.  
  2964.  
  2965. private function PredictLookAtTargetPosition( targetActor : CActor, zOffSet : float, out predictedPos : Vector ) : bool
  2966. {
  2967. var virtualPos : Vector;
  2968. var i : int;
  2969. var dist : float;
  2970. var deltaTime : float;
  2971. var projSpeed : float;
  2972. var projSpeedInt : Vector;
  2973. var projAngle : float;
  2974.  
  2975. var e3Hack : bool;
  2976. var currentTimeInCurve : float;
  2977. e3Hack = false;
  2978.  
  2979. if ( rangedWeapon
  2980. && rangedWeapon.GetDeployedEntity()
  2981. && ( rangedWeapon.GetCurrentStateName() == 'State_WeaponAim' || rangedWeapon.GetCurrentStateName() == 'State_WeaponShoot' ) )
  2982. {
  2983. projSpeed = rangedWeapon.GetDeployedEntity().projSpeed;
  2984.  
  2985. virtualPos = targetActor.GetWorldPosition();
  2986.  
  2987. if ( e3Hack && targetActor.HasTag( 'e3_griffin' ) )
  2988. {
  2989. for ( i = 0; i < 10; i += 1 )
  2990. {
  2991. dist = VecDistance( rangedWeapon.GetDeployedEntity().GetWorldPosition(), virtualPos );
  2992. deltaTime = dist/projSpeed;
  2993. virtualPos = targetActor.PredictWorldPosition( deltaTime );
  2994. }
  2995. }
  2996. else
  2997. return false;
  2998.  
  2999. virtualPos.Z += zOffSet;
  3000. predictedPos = virtualPos;
  3001. GetVisualDebug().AddSphere('CrossbowPredictedPos', 1.0f, virtualPos , true, Color(255,50,50), 5.0f );
  3002. return true;
  3003. }
  3004. return false;
  3005. }
  3006.  
  3007. public function SetLookAtPosition( vec : Vector )
  3008. {
  3009. lookAtPosition = vec;
  3010. }
  3011.  
  3012. public function GetLookAtPosition() : Vector
  3013. {
  3014. return lookAtPosition;
  3015. }
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021. event OnBlockingSceneEnded( optional output : CStorySceneOutput)
  3022. {
  3023.  
  3024. SetImmortalityMode( AIM_None, AIC_SyncedAnim );
  3025. super.OnBlockingSceneEnded(output);
  3026. }
  3027.  
  3028.  
  3029. event OnDismountCSHolsterWeapon()
  3030. {
  3031. var steel, silver : SItemUniqueId;
  3032. var hud : CR4ScriptedHud;
  3033. var qst : CR4HudModuleQuests;
  3034. var mm : CR4HudModuleMinimap2;
  3035.  
  3036. hud = (CR4ScriptedHud)theGame.GetHud();
  3037. if(hud)
  3038. {
  3039. mm = (CR4HudModuleMinimap2)hud.GetHudModule("Minimap2Module");
  3040. qst = (CR4HudModuleQuests)hud.GetHudModule("QuestsModule");
  3041.  
  3042. if(mm)
  3043. mm.SetIsInDlg(true);
  3044.  
  3045. if(qst)
  3046. qst.SetIsInDlg(true);
  3047. }
  3048.  
  3049. if( inv.GetItemEquippedOnSlot(EES_SilverSword, silver) && inv.IsItemHeld(silver))
  3050. HolsterItems(true, silver);
  3051. if( inv.GetItemEquippedOnSlot(EES_SteelSword, steel) && inv.IsItemHeld(steel))
  3052. HolsterItems(true, steel);
  3053. }
  3054.  
  3055.  
  3056.  
  3057.  
  3058.  
  3059.  
  3060. function GetCurrentMeleeWeaponName() : name
  3061. {
  3062. return weaponHolster.GetCurrentMeleeWeaponName();
  3063. }
  3064.  
  3065. public function GetCurrentMeleeWeaponType() : EPlayerWeapon
  3066. {
  3067. return weaponHolster.GetCurrentMeleeWeapon();
  3068. }
  3069.  
  3070. public function OnMeleeForceHolster(ignoreActionLock : bool)
  3071. {
  3072. weaponHolster.HolsterWeapon(ignoreActionLock, true);
  3073. }
  3074.  
  3075. event OnForcedHolsterWeapon()
  3076. {
  3077. weaponHolster.OnForcedHolsterWeapon();
  3078. }
  3079.  
  3080. event OnEquippedItem( category : name, slotName : name )
  3081. {
  3082. var weaponType : EPlayerWeapon;
  3083.  
  3084. if ( slotName == 'r_weapon' )
  3085. {
  3086. switch ( category )
  3087. {
  3088. case 'None' :
  3089. weaponType = PW_None;
  3090. break;
  3091. case 'fist' :
  3092. weaponType = PW_Fists;
  3093. break;
  3094. case 'steelsword' :
  3095. weaponType = PW_Steel;
  3096. break;
  3097. case 'silversword' :
  3098. weaponType = PW_Silver;
  3099. break;
  3100. default :
  3101. return true;
  3102. }
  3103.  
  3104. weaponHolster.OnEquippedMeleeWeapon( weaponType );
  3105. }
  3106. }
  3107.  
  3108. private var isHoldingDeadlySword : bool;
  3109. public function ProcessIsHoldingDeadlySword()
  3110. {
  3111. isHoldingDeadlySword = IsDeadlySwordHeld();
  3112. }
  3113.  
  3114. public function IsHoldingDeadlySword() : bool
  3115. {
  3116. return isHoldingDeadlySword;
  3117. }
  3118.  
  3119. event OnHolsteredItem( category : name, slotName : name )
  3120. {
  3121. var weaponType : EPlayerWeapon;
  3122.  
  3123.  
  3124. if ( slotName == 'r_weapon' && (category == 'steelsword' || category == 'silversword') )
  3125. {
  3126. if( category == 'silversword' )
  3127. {
  3128. ManageAerondightBuff( false );
  3129. }
  3130.  
  3131. GetBuff( EET_LynxSetBonus ).Pause( 'drawing weapon' );
  3132.  
  3133. PauseOilBuffs( category == 'steelsword' );
  3134. }
  3135.  
  3136. if ( slotName == 'r_weapon' )
  3137. {
  3138. weaponType = weaponHolster.GetCurrentMeleeWeapon();
  3139. switch ( category )
  3140. {
  3141. case 'fist' :
  3142. if ( weaponType == PW_Fists )
  3143. weaponHolster.OnEquippedMeleeWeapon( PW_None );
  3144. return true;
  3145. case 'steelsword' :
  3146. if ( weaponType == PW_Steel )
  3147. weaponHolster.OnEquippedMeleeWeapon( PW_None );
  3148. return true;
  3149. case 'silversword' :
  3150. if ( weaponType == PW_Silver )
  3151. weaponHolster.OnEquippedMeleeWeapon( PW_None );
  3152. return true;
  3153. default :
  3154. return true;
  3155. }
  3156. }
  3157. }
  3158.  
  3159. event OnEquipMeleeWeapon( weaponType : EPlayerWeapon, ignoreActionLock : bool, optional sheatheIfAlreadyEquipped : bool )
  3160. {
  3161. RemoveTimer( 'DelayedSheathSword' );
  3162.  
  3163. weaponHolster.OnEquipMeleeWeapon( weaponType, ignoreActionLock, sheatheIfAlreadyEquipped );
  3164.  
  3165.  
  3166.  
  3167. m_RefreshWeaponFXType = true;
  3168. }
  3169.  
  3170. event OnHolsterLeftHandItem()
  3171. {
  3172. weaponHolster.OnHolsterLeftHandItem();
  3173. }
  3174.  
  3175. timer function DelayedTryToReequipWeapon( dt: float, id : int )
  3176. {
  3177. var weaponType : EPlayerWeapon;
  3178.  
  3179. if( IsInCombat() && GetTarget() )
  3180. {
  3181. weaponType = GetMostConvenientMeleeWeapon( GetTarget() );
  3182.  
  3183. if ( weaponType == PW_Steel || weaponType == PW_Silver )
  3184. weaponHolster.OnEquipMeleeWeapon( weaponType, false );
  3185. }
  3186. }
  3187.  
  3188. timer function DelayedSheathSword( dt: float, id : int )
  3189. {
  3190. if ( !IsCombatMusicEnabled() )
  3191. {
  3192. if ( IsInCombatAction() || !IsActionAllowed( EIAB_DrawWeapon ) )
  3193. {
  3194. LogChannel( 'OnCombatFinished', "DelayedSheathSword: Sheath pushed to buffer" );
  3195. PushCombatActionOnBuffer(EBAT_Sheathe_Sword,BS_Pressed);
  3196. }
  3197. else
  3198. {
  3199. LogChannel( 'OnCombatFinished', "DelayedSheathSword: Sheath successful" );
  3200. OnEquipMeleeWeapon( PW_None, false );
  3201. }
  3202. }
  3203. }
  3204.  
  3205. protected function ShouldAutoSheathSwordInstantly() : bool
  3206. {
  3207. var enemies : array<CActor>;
  3208. var i : int;
  3209.  
  3210. GetEnemiesInRange( enemies );
  3211.  
  3212. for ( i = 0; i < enemies.Size(); i += 1 )
  3213. {
  3214. if ( IsThreat( enemies[i] ) &&
  3215. VecDistance( enemies[i].GetWorldPosition(), this.GetWorldPosition() ) <= findMoveTargetDist )
  3216. {
  3217. return false;
  3218. }
  3219. }
  3220.  
  3221. return true;
  3222. }
  3223.  
  3224. public function PrepareToAttack( optional target : CActor, optional action : EBufferActionType )
  3225. {
  3226. var weaponType : EPlayerWeapon;
  3227.  
  3228. if( IsInAir() || !GetBIsCombatActionAllowed() )
  3229. {
  3230. return ;
  3231. }
  3232.  
  3233. if( !target )
  3234. {
  3235. target = (CActor)displayTarget;
  3236. }
  3237. if( !target && IsCombatMusicEnabled() )
  3238. {
  3239. target = moveTarget;
  3240. }
  3241. if( !target )
  3242. {
  3243. if ( this.GetCurrentStateName() == 'Exploration' )
  3244. {
  3245. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  3246. thePlayer.CanAttackWhenNotInCombat( action, false, target );
  3247. }
  3248. }
  3249.  
  3250. weaponHolster.TryToPrepareMeleeWeaponToAttack();
  3251.  
  3252.  
  3253. {
  3254. weaponType = GetCurrentMeleeWeaponType();
  3255.  
  3256. if ( weaponType == PW_None )
  3257. {
  3258.  
  3259. weaponType = GetMostConvenientMeleeWeapon( target );
  3260. }
  3261.  
  3262.  
  3263. if( !OnStateCanGoToCombat() )
  3264. {
  3265. return;
  3266. }
  3267.  
  3268. GoToCombat( weaponType );
  3269. }
  3270. }
  3271.  
  3272. public function DisplayCannotAttackMessage( actor : CActor ) : bool
  3273. {
  3274. if ( actor && ( actor.GetMovingAgentComponent().GetName() == "child_base" || ((CNewNPC)actor).GetNPCType() == ENGT_Quest ) )
  3275. {
  3276. DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_cant_attack_this_target"));
  3277. return true;
  3278. }
  3279.  
  3280. return false;
  3281. }
  3282.  
  3283. public function GetMostConvenientMeleeWeapon( targetToDrawAgainst : CActor, optional ignoreActionLock : bool ) : EPlayerWeapon
  3284. {
  3285. return weaponHolster.GetMostConvenientMeleeWeapon( targetToDrawAgainst, ignoreActionLock );
  3286. }
  3287.  
  3288. private var reevaluateCurrentWeapon : bool;
  3289.  
  3290. event OnTargetWeaponDrawn()
  3291. {
  3292. var weaponType : EPlayerWeapon = this.GetCurrentMeleeWeaponType();
  3293. if ( weaponType == PW_Fists )
  3294. reevaluateCurrentWeapon = true;
  3295. }
  3296.  
  3297. public function GoToCombatIfNeeded( optional enemy : CActor ) : bool
  3298. {
  3299. var weaponType : EPlayerWeapon;
  3300. var target : CActor;
  3301.  
  3302. if( !enemy && IsInCombat() )
  3303. {
  3304. target = GetTarget();
  3305.  
  3306. if ( target )
  3307. enemy = target;
  3308. else
  3309. enemy = moveTarget;
  3310. }
  3311.  
  3312.  
  3313. if( !ShouldGoToCombat( enemy ) )
  3314. {
  3315. return false;
  3316. }
  3317.  
  3318. weaponType = this.GetCurrentMeleeWeaponType();
  3319.  
  3320. if ( weaponType == PW_None || ( reevaluateCurrentWeapon && weaponType == PW_Fists ) || ( !IsInCombat() && weaponHolster.IsOnTheMiddleOfHolstering() ) )
  3321. {
  3322.  
  3323. weaponType = weaponHolster.GetMostConvenientMeleeWeapon( enemy );
  3324. reevaluateCurrentWeapon = false;
  3325. }
  3326.  
  3327.  
  3328. GoToCombat( weaponType );
  3329.  
  3330.  
  3331. return true;
  3332. }
  3333.  
  3334. public function GoToCombatIfWanted( ) : bool
  3335. {
  3336. var weaponType : EPlayerWeapon;
  3337. var target : CActor;
  3338. var enemy : CActor;
  3339.  
  3340.  
  3341. if( !IsInCombat() )
  3342. {
  3343. return false;
  3344. }
  3345.  
  3346. target = GetTarget();
  3347.  
  3348. if ( target )
  3349. enemy = target;
  3350. else
  3351. enemy = moveTarget;
  3352.  
  3353. weaponType = this.GetCurrentMeleeWeaponType();
  3354.  
  3355. if ( weaponType == PW_None || ( !IsInCombat() && weaponHolster.IsOnTheMiddleOfHolstering() ) )
  3356. {
  3357.  
  3358. weaponType = weaponHolster.GetMostConvenientMeleeWeapon( enemy );
  3359. }
  3360.  
  3361.  
  3362. GoToCombat( weaponType );
  3363.  
  3364.  
  3365. return true;
  3366. }
  3367.  
  3368. public function GoToExplorationIfNeeded() : bool
  3369. {
  3370.  
  3371.  
  3372. if( ! IsInCombatState() )
  3373. {
  3374. return false;
  3375. }
  3376.  
  3377. if( !ShouldGoToExploration() )
  3378. {
  3379. return false;
  3380. }
  3381.  
  3382.  
  3383. weaponHolster.EndedCombat();
  3384.  
  3385.  
  3386. GotoState( 'Exploration' );
  3387. return true;
  3388. }
  3389.  
  3390. event OnStateCanGoToCombat()
  3391. {
  3392. return false;
  3393. }
  3394.  
  3395. event OnStateCanUpdateExplorationSubstates()
  3396. {
  3397. return false;
  3398. }
  3399.  
  3400. private function ShouldGoToCombat( optional enemy : CActor ) : bool
  3401. {
  3402. var currentStateName : name;
  3403.  
  3404.  
  3405. if( !OnStateCanGoToCombat() )
  3406. {
  3407. return false;
  3408. }
  3409.  
  3410. currentStateName = GetCurrentStateName();
  3411.  
  3412. if( currentStateName == 'AimThrow' )
  3413. {
  3414. return false;
  3415. }
  3416.  
  3417. if( currentStateName == 'Swimming' )
  3418. {
  3419. return false;
  3420. }
  3421.  
  3422. if( currentStateName == 'TraverseExploration' )
  3423. {
  3424. return false;
  3425. }
  3426.  
  3427.  
  3428.  
  3429.  
  3430.  
  3431.  
  3432. if ( !enemy )
  3433. {
  3434. return playerMode.combatMode;
  3435. }
  3436.  
  3437.  
  3438.  
  3439.  
  3440.  
  3441. return true;
  3442. }
  3443.  
  3444. private function ShouldGoToExploration() : bool
  3445. {
  3446. if ( IsInCombat() )
  3447. {
  3448. return false;
  3449. }
  3450.  
  3451. if ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  3452. {
  3453. return false;
  3454. }
  3455. if( IsFistFightMinigameEnabled() )
  3456. {
  3457. return false;
  3458. }
  3459. if( IsKnockedUnconscious() )
  3460. {
  3461. return false;
  3462. }
  3463. if( IsInCombatAction() )
  3464. {
  3465. return false;
  3466. }
  3467. if( GetCriticalBuffsCount() > 0 )
  3468. {
  3469. return false;
  3470. }
  3471.  
  3472. return true;
  3473. }
  3474.  
  3475. private function GoToCombat( weaponType : EPlayerWeapon, optional initialAction : EInitialAction )
  3476. {
  3477.  
  3478. switch( weaponType )
  3479. {
  3480. case PW_Silver:
  3481. ((W3PlayerWitcherStateCombatSilver) GetState('CombatSilver')).SetupState( initialAction );
  3482. GoToStateIfNew( 'CombatSilver' );
  3483. break;
  3484. case PW_Steel:
  3485. ((W3PlayerWitcherStateCombatSteel) GetState('CombatSteel')).SetupState( initialAction );
  3486. GoToStateIfNew( 'CombatSteel' );
  3487. break;
  3488. case PW_Fists:
  3489. case PW_None:
  3490. default :
  3491. ((W3PlayerWitcherStateCombatFists) GetState('CombatFists')).SetupState( initialAction );
  3492. GoToStateIfNew( 'CombatFists' );
  3493. break;
  3494. }
  3495. }
  3496.  
  3497. public function GoToStateIfNew( newState : name, optional keepStack : bool, optional forceEvents : bool )
  3498. {
  3499. if( newState != GetCurrentStateName() )
  3500. {
  3501. GotoState( newState, keepStack, forceEvents );
  3502.  
  3503. ShouldAutoApplyOil();
  3504. }
  3505. }
  3506.  
  3507.  
  3508. private var shouldAutoApplyOils : bool;
  3509. public function SetAutoApplyOils(set : bool){ shouldAutoApplyOils = set; }
  3510.  
  3511. public function ShouldAutoApplyOil()
  3512. {
  3513. if( !IsCiri() && shouldAutoApplyOils )
  3514. {
  3515. RemoveTimer('AutoApplyBladeOilTimer');
  3516. AddTimer('AutoApplyBladeOilTimer',0.3f,false);
  3517. }
  3518. }
  3519.  
  3520. private timer function AutoApplyBladeOilTimer(dt:float, id:int)
  3521. {
  3522. AutoApplyBladeOil();
  3523. }
  3524.  
  3525. public function ShouldAutoApplyOilImmediately( target : CActor )
  3526. {
  3527. if( !IsCiri() && shouldAutoApplyOils )
  3528. {
  3529. AutoApplyBladeOil( target );
  3530. }
  3531. }
  3532.  
  3533. private function AutoApplyBladeOil( optional target : CActor )
  3534. {
  3535. var monsterCategory : EMonsterCategory;
  3536. var isTeleporting, canBeTargeted, canBeHitByFists, steel : bool;
  3537. var itemName, soundMonsterName : name;
  3538. var oilItems : array<SItemUniqueId>;
  3539. var oils : array<name>;
  3540. var i : int;
  3541.  
  3542. if( !target )
  3543. target = GetTarget();
  3544.  
  3545. if( !target )
  3546. return;
  3547.  
  3548. theGame.GetMonsterParamsForActor( target, monsterCategory, soundMonsterName, isTeleporting, canBeTargeted, canBeHitByFists );
  3549. if( monsterCategory == MC_NotSet )
  3550. return;
  3551.  
  3552. oils = MonsterCategoryToOilNames(monsterCategory);
  3553.  
  3554. for( i=0; i<oils.Size(); i+=1 )
  3555. {
  3556. if( inv.HasItem( oils[i] ) )
  3557. {
  3558. oilItems = inv.GetItemsByName( oils[i] );
  3559. ApplyOil(oilItems[0], GetEquippedSword( target.UsesVitality() ));
  3560. break;
  3561. }
  3562. }
  3563. }
  3564.  
  3565.  
  3566.  
  3567. public function GotoState( newState : name, optional keepStack : bool, optional forceEvents : bool )
  3568. {
  3569.  
  3570.  
  3571. super.GotoState( newState, keepStack, forceEvents );
  3572.  
  3573. }
  3574.  
  3575. public function IsThisACombatSuperState( stateName : name ) : bool
  3576. {
  3577. return stateName == 'Combat' || stateName == 'CombatSteel' || stateName == 'CombatSilver' || stateName == 'CombatFists';
  3578. }
  3579.  
  3580. public function GetWeaponHolster() : WeaponHolster
  3581. {
  3582. return weaponHolster;
  3583. }
  3584.  
  3585. public function AbortSign()
  3586. {
  3587. var playerWitcher : W3PlayerWitcher;
  3588. var sign : W3SignEntity;
  3589.  
  3590. playerWitcher = (W3PlayerWitcher)this;
  3591.  
  3592. if(playerWitcher)
  3593. {
  3594. sign = (W3SignEntity)playerWitcher.GetCurrentSignEntity();
  3595. if (sign)
  3596. {
  3597. sign.OnSignAborted();
  3598. }
  3599. }
  3600. }
  3601.  
  3602.  
  3603.  
  3604.  
  3605. protected var disableActionBlend : bool;
  3606.  
  3607.  
  3608.  
  3609.  
  3610. event OnAnimEvent_DisallowHitAnim( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3611. {
  3612. if ( animEventType == AET_DurationEnd )
  3613. {
  3614. if ( ( BufferCombatAction == EBAT_Dodge || BufferCombatAction == EBAT_Roll )
  3615. && IsInCombatAction()
  3616. && GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
  3617. {
  3618.  
  3619. ( (CR4Player)this ).ProcessCombatActionBuffer();
  3620. disableActionBlend = true;
  3621. }
  3622. }
  3623. else if ( IsInCombatAction() && GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Dodge && animEventType == AET_DurationStart )
  3624. {
  3625. disableActionBlend = false;
  3626. }
  3627.  
  3628. super.OnAnimEvent_DisallowHitAnim( animEventName, animEventType, animInfo );
  3629. }
  3630.  
  3631.  
  3632. event OnAnimEvent_FadeOut( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3633. {
  3634. theGame.FadeOutAsync( 0.2, Color( 0, 0, 0, 1 ) );
  3635. }
  3636.  
  3637. event OnAnimEvent_FadeIn( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3638. {
  3639. theGame.FadeInAsync( 0.4 );
  3640. }
  3641.  
  3642. event OnAnimEvent_BloodTrailForced( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3643. {
  3644. var bloodTrailParam : CBloodTrailEffect;
  3645. var weaponId : SItemUniqueId;
  3646.  
  3647. if ( isInFinisher )
  3648. {
  3649. bloodTrailParam = (CBloodTrailEffect)(GetFinisherVictim()).GetGameplayEntityParam( 'CBloodTrailEffect' );
  3650. weaponId = this.inv.GetItemFromSlot('r_weapon');
  3651. if ( bloodTrailParam )
  3652. thePlayer.inv.PlayItemEffect( weaponId, bloodTrailParam.GetEffectName() );
  3653. }
  3654. }
  3655.  
  3656. event OnAnimEvent_SlowMo( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3657. {
  3658. if ( isInFinisher && DisableManualCameraControlStackHasSource( 'Finisher' ) )
  3659. {
  3660. if( animEventType != AET_DurationEnd )
  3661. theGame.SetTimeScale( 0.1f, 'AnimEventSlomoMo', 1000, true );
  3662. else
  3663. theGame.RemoveTimeScale( 'AnimEventSlomoMo' );
  3664. }
  3665. }
  3666.  
  3667. event OnAnimEvent_PlayFinisherBlood( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3668. {
  3669. if ( isInFinisher )
  3670. {
  3671. SpawnFinisherBlood();
  3672. }
  3673. }
  3674.  
  3675. event OnAnimEvent_OnWeaponDrawReady( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3676. {
  3677. weaponHolster.OnWeaponDrawReady();
  3678. }
  3679.  
  3680. event OnAnimEvent_OnWeaponHolsterReady( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3681. {
  3682. weaponHolster.OnWeaponHolsterReady();
  3683. }
  3684.  
  3685. event OnAnimEvent_ThrowHoldTest( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3686. {
  3687. var thrownEntity : CThrowable;
  3688.  
  3689. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  3690.  
  3691. if( IsThrowHold() )
  3692. {
  3693. SetBehaviorVariable( 'throwStage', (int)TS_Loop );
  3694. PushState( 'AimThrow' );
  3695. thrownEntity.StartAiming();
  3696. }
  3697. else
  3698. {
  3699. BombThrowRelease();
  3700. SetCombatIdleStance( 1.f );
  3701. }
  3702. }
  3703.  
  3704. event OnAnimEvent_AllowTempLookAt( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3705. {
  3706. if( animEventType == AET_DurationStart )
  3707. SetTempLookAtTarget( slideTarget );
  3708. else if( animEventType == AET_DurationEnd )
  3709. SetTempLookAtTarget( NULL );
  3710. }
  3711.  
  3712. protected var slideNPC : CNewNPC;
  3713. protected var minSlideDistance : float;
  3714. protected var maxSlideDistance : float;
  3715. protected var slideTicket : SMovementAdjustmentRequestTicket;
  3716.  
  3717. event OnAnimEvent_SlideToTarget( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3718. {
  3719. var movementAdjustor : CMovementAdjustor;
  3720.  
  3721. if( animEventType == AET_DurationStart )
  3722. {
  3723. slideNPC = (CNewNPC)slideTarget;
  3724. }
  3725.  
  3726. if( !slideNPC )
  3727. {
  3728. return false;
  3729. }
  3730.  
  3731. if( animEventType == AET_DurationStart && slideNPC.GetGameplayVisibility() )
  3732. {
  3733. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  3734. slideTicket = movementAdjustor.GetRequest( 'SlideToTarget' );
  3735. movementAdjustor.CancelByName( 'SlideToTarget' );
  3736. slideTicket = movementAdjustor.CreateNewRequest( 'SlideToTarget' );
  3737. movementAdjustor.BindToEventAnimInfo( slideTicket, animInfo );
  3738.  
  3739. movementAdjustor.MaxLocationAdjustmentSpeed( slideTicket, 1000000 );
  3740. movementAdjustor.ScaleAnimation( slideTicket );
  3741. minSlideDistance = ((CMovingPhysicalAgentComponent)this.GetMovingAgentComponent()).GetCapsuleRadius()+((CMovingPhysicalAgentComponent)slideNPC.GetMovingAgentComponent()).GetCapsuleRadius();
  3742. if( IsInCombatFist() )
  3743. {
  3744. maxSlideDistance = 1000.0f;
  3745. }
  3746. else
  3747. {
  3748. maxSlideDistance = minSlideDistance;
  3749. }
  3750. movementAdjustor.SlideTowards( slideTicket, slideTarget, minSlideDistance, maxSlideDistance );
  3751. }
  3752. else if( !slideNPC.GetGameplayVisibility() )
  3753. {
  3754. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  3755. movementAdjustor.CancelByName( 'SlideToTarget' );
  3756. slideNPC = NULL;
  3757. }
  3758. else
  3759. {
  3760. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  3761. movementAdjustor.SlideTowards( slideTicket, slideTarget, minSlideDistance, maxSlideDistance );
  3762. }
  3763. }
  3764.  
  3765. event OnAnimEvent_ActionBlend( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3766. {
  3767. }
  3768.  
  3769.  
  3770. event OnAnimEvent_SubstateManager( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3771. {
  3772.  
  3773. substateManager.OnAnimEvent( animEventName, animEventType, animInfo );
  3774. }
  3775.  
  3776. event OnAnimEvent_AllowFall( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3777. {
  3778. if ( !substateManager.m_OwnerMAC.IsOnGround() )
  3779. {
  3780. substateManager.m_SharedDataO.SetFallFromCritical( true );
  3781. substateManager.m_MoverO.SetVelocity( -6.0f * GetWorldForward() );
  3782. substateManager.QueueStateExternal( 'Jump' );
  3783. RemoveBuff( EET_Knockdown, true );
  3784. RemoveBuff( EET_HeavyKnockdown, true );
  3785. return true;
  3786. }
  3787. return false;
  3788. }
  3789.  
  3790. event OnAnimEvent_AllowFall2( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3791. {
  3792. if ( !substateManager.m_OwnerMAC.IsOnGround() )
  3793. {
  3794.  
  3795.  
  3796. substateManager.QueueStateExternal( 'Jump' );
  3797. RemoveBuff( EET_Knockdown, true );
  3798. RemoveBuff( EET_HeavyKnockdown, true );
  3799. }
  3800. if( substateManager.StateWantsAndCanEnter( 'Slide' ) )
  3801. {
  3802. substateManager.QueueStateExternal( 'Slide' );
  3803. }
  3804. }
  3805.  
  3806. event OnAnimEvent_DettachGround( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3807. {
  3808.  
  3809. }
  3810.  
  3811.  
  3812. event OnAnimEvent_pad_vibration( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3813. {
  3814. var witcher : W3PlayerWitcher;
  3815.  
  3816. theGame.VibrateControllerHard();
  3817.  
  3818.  
  3819. witcher = GetWitcherPlayer();
  3820. if(isInFinisher && witcher)
  3821. {
  3822. if(HasAbility('Runeword 10 _Stats', true) && !witcher.runeword10TriggerredOnFinisher && ((bool)theGame.GetInGameConfigWrapper().GetVarValue('Gameplay', 'AutomaticFinishersEnabled')) == true)
  3823. {
  3824. witcher.Runeword10Triggerred();
  3825. witcher.runeword10TriggerredOnFinisher = true;
  3826. }
  3827. else if(HasAbility('Runeword 12 _Stats', true) && !witcher.runeword12TriggerredOnFinisher)
  3828. {
  3829. witcher.Runeword12Triggerred();
  3830. witcher.runeword12TriggerredOnFinisher = true;
  3831. }
  3832. }
  3833. }
  3834.  
  3835.  
  3836. event OnAnimEvent_pad_vibration_light( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3837. {
  3838.  
  3839. }
  3840.  
  3841. event OnAnimEvent_KillWithRagdoll( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3842. {
  3843.  
  3844.  
  3845. }
  3846.  
  3847. event OnAnimEvent_RemoveBurning( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3848. {
  3849. thePlayer.AddBuffImmunity(EET_Burning, 'AnimEvent_RemoveBurning', true);
  3850. }
  3851.  
  3852. event OnAnimEvent_RemoveTangled( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3853. {
  3854. if ( this.HasBuff( EET_Tangled ) )
  3855. {
  3856. this.StopEffect('black_spider_web');
  3857. this.PlayEffectSingle('black_spider_web_break');
  3858. }
  3859. }
  3860.  
  3861.  
  3862. event OnAnimEvent_MoveNoise( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3863. {
  3864. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'MoveNoise', -1, 30.0f, -1.f, -1, true );
  3865. }
  3866.  
  3867.  
  3868. event OnBehaviorGraphNotification( notificationName : name, stateName : name )
  3869. {
  3870. substateManager.OnBehaviorGraphNotification( notificationName, stateName );
  3871.  
  3872. if( notificationName == 'PlayerRunActivate' )
  3873. {
  3874. isInRunAnimation = true;
  3875. }
  3876. else if( notificationName == 'PlayerRunDeactivate' )
  3877. {
  3878. isInRunAnimation = false;
  3879. }
  3880. }
  3881.  
  3882. event OnEnumAnimEvent( animEventName : name, variant : SEnumVariant, animEventType : EAnimationEventType, animEventDuration : float, animInfo : SAnimationEventAnimInfo )
  3883. {
  3884. var movementAdjustor : CMovementAdjustor;
  3885. var ticket : SMovementAdjustmentRequestTicket;
  3886. var rotationRate : ERotationRate;
  3887.  
  3888. if ( animEventName == 'RotateToTarget' )
  3889. {
  3890.  
  3891. rotationRate = GetRotationRateFromAnimEvent( variant.enumValue );
  3892.  
  3893. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  3894. if ( animEventType == AET_DurationStart || animEventType == AET_DurationStartInTheMiddle )
  3895. {
  3896.  
  3897.  
  3898. if (! movementAdjustor.IsRequestActive( movementAdjustor.GetRequest( 'RotateToTarget' ) ) )
  3899. {
  3900.  
  3901. ticket = movementAdjustor.CreateNewRequest( 'RotateToTarget' );
  3902.  
  3903.  
  3904. if ((int)rotationRate == 0)
  3905. movementAdjustor.AdjustmentDuration( ticket, animEventDuration );
  3906. else
  3907. {
  3908. movementAdjustor.Continuous( ticket );
  3909. movementAdjustor.BindToEvent( ticket, 'RotateToTarget' );
  3910. }
  3911.  
  3912. movementAdjustor.DontUseSourceAnimation( ticket );
  3913. movementAdjustor.ReplaceRotation( ticket );
  3914. }
  3915. else
  3916. {
  3917.  
  3918. ticket = movementAdjustor.GetRequest( 'RotateToTarget' );
  3919. }
  3920. MovAdjRotateToTarget( ticket );
  3921.  
  3922. if ((int)rotationRate > 0)
  3923. {
  3924. movementAdjustor.MaxRotationAdjustmentSpeed( ticket, (float)((int)rotationRate) );
  3925. }
  3926. }
  3927. else if ( animEventType == AET_DurationEnd )
  3928. {
  3929.  
  3930.  
  3931. }
  3932. else
  3933. {
  3934.  
  3935. ticket = movementAdjustor.GetRequest( 'RotateToTarget' );
  3936. MovAdjRotateToTarget( ticket );
  3937. }
  3938. }
  3939. super.OnEnumAnimEvent(animEventName, variant, animEventType, animEventDuration, animInfo);
  3940. }
  3941.  
  3942. event OnTeleported()
  3943. {
  3944. if( substateManager )
  3945. {
  3946. substateManager.OnTeleported();
  3947. }
  3948. }
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955. event OnStartFistfightMinigame()
  3956. {
  3957. super.OnStartFistfightMinigame();
  3958.  
  3959.  
  3960. SetFistFightMinigameEnabled( true );
  3961. FistFightHealthChange( true );
  3962. thePlayer.GetPlayerMode().ForceCombatMode( FCMR_QuestFunction );
  3963. SetImmortalityMode(AIM_Unconscious, AIC_Fistfight);
  3964. thePlayer.SetBehaviorVariable( 'playerWeaponLatent', (int)PW_Fists );
  3965. GotoCombatStateWithAction( IA_None );
  3966. ((CMovingAgentComponent)this.GetMovingAgentComponent()).SnapToNavigableSpace( true );
  3967. EquipGeraltFistfightWeapon( true );
  3968. BlockAction( EIAB_RadialMenu, 'FistfightMinigame' ,,true);
  3969. BlockAction( EIAB_Signs, 'FistfightMinigame' ,,true);
  3970. BlockAction( EIAB_ThrowBomb, 'FistfightMinigame' ,,true);
  3971. BlockAction( EIAB_UsableItem, 'FistfightMinigame' ,,true);
  3972. BlockAction( EIAB_Crossbow, 'FistfightMinigame' ,,true);
  3973. BlockAction( EIAB_DrawWeapon, 'FistfightMinigame' ,,true);
  3974. BlockAction( EIAB_RunAndSprint, 'FistfightMinigame' ,,true);
  3975. BlockAction( EIAB_SwordAttack, 'FistfightMinigame' ,,true);
  3976. BlockAction( EIAB_CallHorse, 'FistfightMinigame' ,,true);
  3977. BlockAction( EIAB_Roll, 'FistfightMinigame' ,,true);
  3978. BlockAction( EIAB_Interactions, 'FistfightMinigame' ,,true);
  3979. BlockAction( EIAB_Explorations, 'FistfightMinigame' ,,true);
  3980. BlockAction( EIAB_OpenInventory, 'FistfightMinigame' ,,true);
  3981. BlockAction( EIAB_QuickSlots, 'FistfightMinigame' ,,true);
  3982. BlockAction( EIAB_OpenCharacterPanel, 'FistfightMinigame' ,,true);
  3983. }
  3984.  
  3985. event OnEndFistfightMinigame()
  3986. {
  3987. ((CMovingAgentComponent)this.GetMovingAgentComponent()).SnapToNavigableSpace( false );
  3988. FistFightHealthChange( false );
  3989. thePlayer.GetPlayerMode().ReleaseForceCombatMode( FCMR_QuestFunction );
  3990. EquipGeraltFistfightWeapon( false );
  3991. SetFistFightMinigameEnabled( false );
  3992. SetImmortalityMode(AIM_None, AIC_Fistfight);
  3993. BlockAllActions('FistfightMinigame',false);
  3994.  
  3995. super.OnEndFistfightMinigame();
  3996. }
  3997.  
  3998. public function GetFistFightFinisher( out masterAnimName, slaveAnimIndex : name )
  3999. {
  4000. var index : int;
  4001.  
  4002. index = RandRange(1);
  4003. switch ( index )
  4004. {
  4005. case 0 : masterAnimName = 'man_fistfight_finisher_1_win'; slaveAnimIndex = 'man_fistfight_finisher_1_looser';
  4006. }
  4007. }
  4008.  
  4009. public function SetFistFightMinigameEnabled( flag : bool )
  4010. {
  4011. fistFightMinigameEnabled = flag;
  4012. }
  4013.  
  4014. public function SetFistFightParams( toDeath : bool, endsWithBS : bool )
  4015. {
  4016. isFFMinigameToTheDeath = toDeath;
  4017. FFMinigameEndsithBS = endsWithBS;
  4018. }
  4019.  
  4020. public function IsFistFightMinigameEnabled() : bool
  4021. {
  4022. return fistFightMinigameEnabled;
  4023. }
  4024.  
  4025. public function IsFistFightMinigameToTheDeath() : bool
  4026. {
  4027. return isFFMinigameToTheDeath;
  4028. }
  4029.  
  4030. public function FistFightHealthChange( val : bool )
  4031. {
  4032. if( val == true )
  4033. {
  4034. GeraltMaxHealth = thePlayer.GetStatMax(BCS_Vitality);
  4035. ClampGeraltMaxHealth( 2000 );
  4036. SetHealthPerc( 100 );
  4037. }
  4038. else
  4039. {
  4040. ClampGeraltMaxHealth( GeraltMaxHealth );
  4041. SetHealthPerc( 100 );
  4042. }
  4043.  
  4044. }
  4045.  
  4046. function ClampGeraltMaxHealth( val : float )
  4047. {
  4048. thePlayer.abilityManager.SetStatPointMax( BCS_Vitality, val );
  4049. }
  4050.  
  4051. function EquipGeraltFistfightWeapon( val : bool )
  4052. {
  4053. if ( val )
  4054. {
  4055. fistsItems = thePlayer.GetInventory().AddAnItem( 'Geralt Fistfight Fists', 1, true, true );
  4056. thePlayer.GetInventory().MountItem( fistsItems[0] , true );
  4057. }
  4058. else
  4059. {
  4060. thePlayer.GetInventory().DropItem( fistsItems[0], true );
  4061. }
  4062. }
  4063.  
  4064.  
  4065.  
  4066.  
  4067. public function GetGwintAiDifficulty() : EGwintDifficultyMode
  4068. {
  4069. return gwintAiDifficulty;
  4070. }
  4071.  
  4072. public function SetGwintAiDifficulty( difficulty : EGwintDifficultyMode )
  4073. {
  4074. gwintAiDifficulty = difficulty;
  4075. }
  4076.  
  4077. public function GetGwintAiAggression() : EGwintAggressionMode
  4078. {
  4079. return gwintAiAggression;
  4080. }
  4081.  
  4082. public function SetGwintAiAggression( aggression : EGwintAggressionMode )
  4083. {
  4084. gwintAiAggression = aggression;
  4085. }
  4086.  
  4087. public function GetGwintMinigameState() : EMinigameState
  4088. {
  4089. return gwintMinigameState;
  4090. }
  4091.  
  4092. public function SetGwintMinigameState( minigameState : EMinigameState )
  4093. {
  4094. gwintMinigameState = minigameState;
  4095. }
  4096.  
  4097. public function OnGwintGameRequested( deckName : name, forceFaction : eGwintFaction )
  4098. {
  4099. var gwintManager:CR4GwintManager;
  4100. gwintManager = theGame.GetGwintManager();
  4101.  
  4102. gwintMinigameState = EMS_None;
  4103.  
  4104. gwintManager.SetEnemyDeckByName(deckName);
  4105. gwintManager.SetForcedFaction(forceFaction);
  4106.  
  4107. if (gwintManager.GetHasDoneTutorial() || !theGame.GetTutorialSystem().AreMessagesEnabled())
  4108. {
  4109. gwintManager.gameRequested = true;
  4110. theGame.RequestMenu( 'DeckBuilder' );
  4111. }
  4112. else
  4113. {
  4114. theGame.GetGuiManager().ShowUserDialog( UMID_SkipGwintTutorial, "gwint_tutorial_play_query_title", "gwint_tutorial_play_query", UDB_YesNo );
  4115. }
  4116. }
  4117.  
  4118. public function StartGwint_TutorialOrSkip( skipTutorial : bool )
  4119. {
  4120. var gwintManager : CR4GwintManager;
  4121.  
  4122. if( skipTutorial )
  4123. {
  4124. gwintManager = theGame.GetGwintManager();
  4125. gwintManager.gameRequested = true;
  4126. gwintManager.SetHasDoneTutorial(true);
  4127. gwintManager.SetHasDoneDeckTutorial(true);
  4128. theGame.RequestMenu( 'DeckBuilder' );
  4129. }
  4130. else
  4131. {
  4132. theGame.RequestMenu( 'GwintGame' );
  4133. }
  4134. }
  4135.  
  4136. private var gwintCardNumbersArray : array<int>;
  4137.  
  4138. public function InitGwintCardNumbersArray( arr : array<int> )
  4139. {
  4140. gwintCardNumbersArray.Clear();
  4141. gwintCardNumbersArray = arr;
  4142. }
  4143.  
  4144. public function GetCardNumbersArray() : array<int>
  4145. {
  4146. return gwintCardNumbersArray;
  4147. }
  4148.  
  4149.  
  4150.  
  4151.  
  4152. protected var customCameraStack : array<SCustomCameraParams>;
  4153.  
  4154. public function AddCustomCamToStack( customCameraParams : SCustomCameraParams ) : int
  4155. {
  4156. if( customCameraParams.useCustomCamera )
  4157. {
  4158. if ( customCameraParams.cameraParams.enums[0].enumType != 'ECustomCameraType' )
  4159. {
  4160. LogChannel( 'CustomCamera', "ERROR: Selected enum is not a custom camera!!!" );
  4161. return -1;
  4162. }
  4163. else
  4164. {
  4165. customCameraStack.PushBack( customCameraParams );
  4166. return ( customCameraStack.Size() - 1 );
  4167. }
  4168. }
  4169.  
  4170. return 0;
  4171. }
  4172.  
  4173. public function DisableCustomCamInStack( customCameraStackIndex : int )
  4174. {
  4175. if ( customCameraStackIndex != -1 )
  4176. customCameraStack[customCameraStackIndex].useCustomCamera = false;
  4177. else
  4178. LogChannel( 'CustomCamera', "ERROR: Custom camera to disable does not exist!!!" );
  4179. }
  4180.  
  4181. event OnInteriorStateChanged( inInterior : bool )
  4182. {
  4183. interiorCamera = inInterior;
  4184. }
  4185.  
  4186. event OnModifyPlayerSpeed( flag : bool )
  4187. {
  4188. modifyPlayerSpeed = flag;
  4189. SetBehaviorVariable( 'modifyPlayerSpeed', (float)modifyPlayerSpeed );
  4190. }
  4191.  
  4192. event OnGameCameraTick( out moveData : SCameraMovementData, dt : float )
  4193. {
  4194. var targetRotation : EulerAngles;
  4195. var dist : float;
  4196.  
  4197. if( thePlayer.IsInCombat() )
  4198. {
  4199. dist = VecDistance2D( thePlayer.GetWorldPosition(), thePlayer.GetTarget().GetWorldPosition() );
  4200. thePlayer.GetVisualDebug().AddText( 'dbg', dist, thePlayer.GetWorldPosition() + Vector( 0.f,0.f,2.f ), true, , Color( 0, 255, 0 ) );
  4201. }
  4202.  
  4203. if ( isStartingFistFightMinigame )
  4204. {
  4205. moveData.pivotRotationValue = fistFightTeleportNode.GetWorldRotation();
  4206. isStartingFistFightMinigame = false;
  4207. }
  4208.  
  4209.  
  4210. if( substateManager.UpdateCameraIfNeeded( moveData, dt ) )
  4211. {
  4212. return true;
  4213. }
  4214.  
  4215.  
  4216. if ( theGame.IsFocusModeActive() )
  4217. {
  4218.  
  4219. if(GetExplCamera())
  4220. {
  4221.  
  4222. return true;
  4223. }
  4224.  
  4225.  
  4226. theGame.GetGameCamera().ChangePivotRotationController( 'Exploration' );
  4227. theGame.GetGameCamera().ChangePivotDistanceController( 'Default' );
  4228. theGame.GetGameCamera().ChangePivotPositionController( 'Default' );
  4229.  
  4230.  
  4231. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  4232. moveData.pivotDistanceController = theGame.GetGameCamera().GetActivePivotDistanceController();
  4233. moveData.pivotPositionController = theGame.GetGameCamera().GetActivePivotPositionController();
  4234.  
  4235.  
  4236.  
  4237. moveData.pivotPositionController.SetDesiredPosition( thePlayer.GetWorldPosition() );
  4238.  
  4239. moveData.pivotRotationController.SetDesiredPitch( -10.0f );
  4240. moveData.pivotRotationController.maxPitch = 50.0;
  4241.  
  4242. moveData.pivotDistanceController.SetDesiredDistance( 3.5f );
  4243.  
  4244. if ( !interiorCamera )
  4245. {
  4246. moveData.pivotPositionController.offsetZ = 1.5f;
  4247. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( 0.5f, 2.0f, 0.3f ), 0.20f, dt );
  4248. }
  4249. else
  4250. {
  4251. moveData.pivotPositionController.offsetZ = 1.3f;
  4252. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( 0.5f, 2.3f, 0.5f ), 0.3f, dt );
  4253. }
  4254.  
  4255. return true;
  4256. }
  4257.  
  4258.  
  4259.  
  4260.  
  4261.  
  4262.  
  4263.  
  4264. if( customCameraStack.Size() > 0 )
  4265. {
  4266.  
  4267.  
  4268. }
  4269.  
  4270. return false;
  4271. }
  4272.  
  4273. private var questCameraRequest : SQuestCameraRequest;
  4274. private var cameraRequestTimeStamp : float;
  4275.  
  4276. public function RequestQuestCamera( camera : SQuestCameraRequest )
  4277. {
  4278. questCameraRequest = camera;
  4279. questCameraRequest.requestTimeStamp = theGame.GetEngineTimeAsSeconds();
  4280. }
  4281.  
  4282. public function ResetQuestCameraRequest()
  4283. {
  4284. var cameraRequest : SQuestCameraRequest;
  4285.  
  4286. questCameraRequest = cameraRequest;
  4287. }
  4288.  
  4289. event OnGameCameraPostTick( out moveData : SCameraMovementData, dt : float )
  4290. {
  4291. var ent : CEntity;
  4292. var playerPos : Vector;
  4293. var angles : EulerAngles;
  4294.  
  4295. var distance : float;
  4296.  
  4297.  
  4298. if(GetExplCamera() && substateManager.GetStateCur() == 'Interaction')
  4299. {
  4300. moveData.pivotDistanceController.SetDesiredDistance( 1.5f );
  4301. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( 0.7f, -0.3f, 0.3f ), 0.5f, dt );
  4302. }
  4303.  
  4304.  
  4305.  
  4306.  
  4307. if ( questCameraRequest.requestTimeStamp > 0 )
  4308. {
  4309. if ( questCameraRequest.duration > 0 && questCameraRequest.requestTimeStamp + questCameraRequest.duration < theGame.GetEngineTimeAsSeconds() )
  4310. {
  4311. ResetQuestCameraRequest();
  4312. return false;
  4313. }
  4314.  
  4315. if( questCameraRequest.lookAtTag )
  4316. {
  4317. ent = theGame.GetEntityByTag( questCameraRequest.lookAtTag );
  4318. playerPos = GetWorldPosition();
  4319. playerPos.Z += 1.8f;
  4320.  
  4321. angles = VecToRotation( ent.GetWorldPosition() - playerPos );
  4322.  
  4323. moveData.pivotRotationController.SetDesiredHeading( angles.Yaw );
  4324. moveData.pivotRotationController.SetDesiredPitch( -angles.Pitch );
  4325. }
  4326. else
  4327. {
  4328. if( questCameraRequest.requestYaw )
  4329. {
  4330. angles = GetWorldRotation();
  4331. moveData.pivotRotationController.SetDesiredHeading( angles.Yaw + questCameraRequest.yaw );
  4332. }
  4333.  
  4334. if( questCameraRequest.requestPitch )
  4335. {
  4336. moveData.pivotRotationController.SetDesiredPitch( questCameraRequest.pitch );
  4337. }
  4338. }
  4339. }
  4340. }
  4341.  
  4342. var wasRunning : bool;
  4343. var vel : float;
  4344. var smoothTime : float;
  4345.  
  4346. var constDamper : ConstDamper;
  4347. var rotMultVel : float;
  4348.  
  4349. public function UpdateCameraInterior( out moveData : SCameraMovementData, timeDelta : float )
  4350. {
  4351. var camDist : float;
  4352. var camOffset : float;
  4353. var rotMultDest : float;
  4354. var rotMult : float;
  4355. var angles : EulerAngles;
  4356.  
  4357. theGame.GetGameCamera().ChangePivotRotationController( 'ExplorationInterior' );
  4358. theGame.GetGameCamera().ChangePivotDistanceController( 'Default' );
  4359. theGame.GetGameCamera().ChangePivotPositionController( 'Default' );
  4360.  
  4361.  
  4362. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  4363. moveData.pivotDistanceController = theGame.GetGameCamera().GetActivePivotDistanceController();
  4364. moveData.pivotPositionController = theGame.GetGameCamera().GetActivePivotPositionController();
  4365.  
  4366.  
  4367. moveData.pivotPositionController.SetDesiredPosition( GetWorldPosition(), 15.f );
  4368.  
  4369. if ( !constDamper )
  4370. {
  4371. constDamper = new ConstDamper in this;
  4372. constDamper.SetDamp( 0.35f );
  4373. }
  4374.  
  4375. if ( rawPlayerSpeed <= 0 || AbsF( AngleDistance( rawPlayerHeading, GetHeading() ) ) > 135 )
  4376. constDamper.Reset();
  4377. else if ( theGame.IsUberMovementEnabled() )
  4378. rotMult = 0.5f;
  4379. else
  4380. rotMult = 1.f;
  4381.  
  4382. rotMult = constDamper.UpdateAndGet( timeDelta, rotMult );
  4383.  
  4384.  
  4385.  
  4386. if ( AbsF( AngleDistance( GetHeading(), moveData.pivotRotationValue.Yaw ) ) < 135.f && rawPlayerSpeed > 0 )
  4387. moveData.pivotRotationController.SetDesiredHeading( GetHeading(), rotMult );
  4388. else
  4389. moveData.pivotRotationController.SetDesiredHeading( moveData.pivotRotationValue.Yaw );
  4390.  
  4391. moveData.pivotDistanceController.SetDesiredDistance( 1.5f );
  4392.  
  4393. angles = VecToRotation( GetMovingAgentComponent().GetVelocity() );
  4394. if ( AbsF( angles.Pitch ) < 8.f || bLAxisReleased )
  4395. moveData.pivotRotationController.SetDesiredPitch( -10.f );
  4396. else
  4397. moveData.pivotRotationController.SetDesiredPitch( -angles.Pitch - 18.f );
  4398.  
  4399. if ( IsGuarded() )
  4400. moveData.pivotPositionController.offsetZ = 1.0f;
  4401. else
  4402. moveData.pivotPositionController.offsetZ = 1.3f;
  4403.  
  4404.  
  4405.  
  4406. if ( playerMoveType >= PMT_Run )
  4407. {
  4408.  
  4409. camDist = -0.5f;
  4410. camOffset = 0.25;
  4411.  
  4412. if ( !wasRunning )
  4413. {
  4414. smoothTime = 1.f;
  4415. wasRunning = true;
  4416. }
  4417. DampFloatSpring( smoothTime, vel, 0.1, 0.5, timeDelta );
  4418. }
  4419. else
  4420. {
  4421.  
  4422. camDist = 0.f;
  4423. camOffset = 0.4f;
  4424. smoothTime = 0.2f;
  4425. wasRunning = false;
  4426. }
  4427.  
  4428.  
  4429.  
  4430. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( 0.3f, camDist, 0.3f ), smoothTime, timeDelta );
  4431.  
  4432.  
  4433.  
  4434.  
  4435.  
  4436. }
  4437.  
  4438.  
  4439. private var closeSignCam : bool;
  4440. public function GetCloseSignCam() : bool {return closeSignCam;}
  4441.  
  4442.  
  4443. var wasBRAxisPushed : bool;
  4444. protected function UpdateCameraChanneledSign( out moveData : SCameraMovementData, timeDelta : float ) : bool
  4445. {
  4446. var screenSpaceOffset : float;
  4447. var screenSpaceOffsetFwd : float;
  4448. var screenSpaceOffsetUp : float;
  4449. var heading : float;
  4450. var pitch : float;
  4451. var playerToTargetRot : EulerAngles;
  4452. var rightOffset : float = -20.f;
  4453. var leftOffset : float = 15.f;
  4454. var angles : EulerAngles;
  4455.  
  4456. var vec : Vector;
  4457.  
  4458. if( this.IsCurrentSignChanneled() && this.GetCurrentlyCastSign() != ST_Quen && this.GetCurrentlyCastSign() != ST_Yrden )
  4459. {
  4460. theGame.GetGameCamera().ChangePivotRotationController( 'SignChannel' );
  4461. theGame.GetGameCamera().ChangePivotDistanceController( 'SignChannel' );
  4462.  
  4463. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  4464. moveData.pivotDistanceController = theGame.GetGameCamera().GetActivePivotDistanceController();
  4465.  
  4466.  
  4467. if ( GetCurrentlyCastSign() == ST_Axii )
  4468. leftOffset = 32.f;
  4469.  
  4470. if ( oTCameraOffset != leftOffset && oTCameraOffset != rightOffset )
  4471. {
  4472.  
  4473. if( (GetExplCamera() && !IsInCombat()) || (GetCmbtCamera() && IsInCombat()) )
  4474. {
  4475. oTCameraOffset = leftOffset;
  4476. closeSignCam = true;
  4477. }
  4478. else if( ( interiorCamera && !moveTarget )
  4479. || ( AngleDistance( GetHeading(), moveData.pivotRotationValue.Yaw ) < 0 ))
  4480. oTCameraOffset = leftOffset;
  4481. else
  4482. oTCameraOffset = rightOffset;
  4483. }
  4484.  
  4485. if ( oTCameraOffset == leftOffset )
  4486. {
  4487. screenSpaceOffset = 0.95f;
  4488. oTCameraPitchOffset = 13.f;
  4489.  
  4490. }
  4491. else if ( oTCameraOffset == rightOffset )
  4492. {
  4493. screenSpaceOffset = -0.95f;
  4494. oTCameraPitchOffset = 13.f;
  4495.  
  4496. }
  4497.  
  4498. moveData.pivotPositionController.offsetZ = 1.3f;
  4499.  
  4500. if ( !delayCameraOrientationChange )
  4501. {
  4502. if ( GetOrientationTarget() == OT_Camera || GetOrientationTarget() == OT_CameraOffset )
  4503. {
  4504. if ( bRAxisReleased )
  4505. {
  4506. heading = moveData.pivotRotationValue.Yaw;
  4507. pitch = moveData.pivotRotationValue.Pitch;
  4508. }
  4509. else
  4510. {
  4511. heading = moveData.pivotRotationValue.Yaw + oTCameraOffset;
  4512. pitch = moveData.pivotRotationValue.Pitch;
  4513. }
  4514. }
  4515. else if ( GetOrientationTarget() == OT_Actor )
  4516. {
  4517. if ( GetDisplayTarget() )
  4518. vec = GetDisplayTarget().GetWorldPosition() - GetWorldPosition();
  4519. else if ( slideTarget )
  4520. vec = slideTarget.GetWorldPosition() - GetWorldPosition();
  4521. else if ( GetTarget() )
  4522. vec = GetTarget().GetWorldPosition() - GetWorldPosition();
  4523. else
  4524. vec = GetHeadingVector();
  4525.  
  4526. angles = VecToRotation( vec );
  4527. heading = angles.Yaw + oTCameraOffset;
  4528. pitch = -angles.Pitch - oTCameraPitchOffset;
  4529. }
  4530. else
  4531. {
  4532. angles = VecToRotation( GetHeadingVector() );
  4533. heading = angles.Yaw + oTCameraOffset;
  4534. pitch = -angles.Pitch - oTCameraPitchOffset;
  4535. }
  4536.  
  4537. if ( !wasBRAxisPushed && ( !bRAxisReleased ) )
  4538. wasBRAxisPushed = true;
  4539.  
  4540. moveData.pivotRotationController.SetDesiredHeading( heading , 2.f );
  4541. moveData.pivotRotationController.SetDesiredPitch( pitch );
  4542. }
  4543. else
  4544. {
  4545. moveData.pivotRotationController.SetDesiredHeading( moveData.pivotRotationValue.Yaw, 1.f );
  4546. moveData.pivotRotationController.SetDesiredPitch( -oTCameraPitchOffset );
  4547. }
  4548.  
  4549. if ( moveData.pivotRotationValue.Pitch <= 5.f && moveData.pivotRotationValue.Pitch >= -15.f )
  4550. {
  4551. screenSpaceOffsetFwd = 0.5;
  4552. screenSpaceOffsetUp = 0.0;
  4553. }
  4554. else if ( moveData.pivotRotationValue.Pitch > 0 )
  4555. {
  4556. screenSpaceOffsetFwd = moveData.pivotRotationValue.Pitch*0.00727 + 1.275f;
  4557.  
  4558. screenSpaceOffsetFwd = 0.5;
  4559.  
  4560. screenSpaceOffsetUp = -moveData.pivotRotationValue.Pitch*0.00727 + 0.4363f;
  4561.  
  4562. screenSpaceOffsetUp = 0;
  4563. }
  4564. else
  4565. {
  4566. if ( GetCurrentlyCastSign() == ST_Axii )
  4567. {
  4568. screenSpaceOffsetFwd = -moveData.pivotRotationValue.Pitch*0.0425 + 0.8625f;
  4569.  
  4570. screenSpaceOffsetFwd = 0.5;
  4571. }
  4572. else
  4573. {
  4574. screenSpaceOffsetFwd = -moveData.pivotRotationValue.Pitch*0.035 + 0.75f;
  4575.  
  4576. screenSpaceOffsetFwd = 0.5;
  4577. }
  4578. screenSpaceOffsetUp = -moveData.pivotRotationValue.Pitch*0.005 + 0.325f;
  4579.  
  4580. screenSpaceOffsetUp = 0;
  4581. }
  4582.  
  4583. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( screenSpaceOffset, screenSpaceOffsetFwd, screenSpaceOffsetUp ), 0.25f, timeDelta );
  4584. moveData.pivotDistanceController.SetDesiredDistance( 2.8f, 5.f );
  4585. moveData.pivotPositionController.SetDesiredPosition( GetWorldPosition() );
  4586.  
  4587. return true;
  4588. }
  4589. else
  4590. {
  4591. closeSignCam = false;
  4592. this.wasBRAxisPushed = false;
  4593.  
  4594. return false;
  4595. }
  4596. }
  4597.  
  4598. protected function UpdateCameraForSpecialAttack( out moveData : SCameraMovementData, timeDelta : float ) : bool
  4599. {
  4600. var screenSpaceOffset : float;
  4601. var tempHeading : float;
  4602. var cameraOffsetLeft : float;
  4603. var cameraOffsetRight : float;
  4604.  
  4605. if ( !specialAttackCamera )
  4606. return false;
  4607.  
  4608. theGame.GetGameCamera().ForceManualControlHorTimeout();
  4609. theGame.GetGameCamera().ForceManualControlVerTimeout();
  4610.  
  4611.  
  4612. cameraOffsetLeft = 30.f;
  4613. cameraOffsetRight = -30.f;
  4614.  
  4615.  
  4616.  
  4617.  
  4618.  
  4619.  
  4620.  
  4621. theGame.GetGameCamera().ChangePivotRotationController( 'SignChannel' );
  4622. theGame.GetGameCamera().ChangePivotDistanceController( 'SignChannel' );
  4623.  
  4624. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  4625. moveData.pivotDistanceController = theGame.GetGameCamera().GetActivePivotDistanceController();
  4626.  
  4627. if ( slideTarget )
  4628. tempHeading = VecHeading( slideTarget.GetWorldPosition() - GetWorldPosition() );
  4629. else
  4630. tempHeading = GetHeading();
  4631.  
  4632. oTCameraPitchOffset = 0.f;
  4633.  
  4634. if( ( interiorCamera && !moveTarget )
  4635. || ( AngleDistance( tempHeading, moveData.pivotRotationValue.Yaw ) < 0 ) )
  4636. oTCameraOffset = cameraOffsetLeft;
  4637. else
  4638. oTCameraOffset = cameraOffsetRight;
  4639.  
  4640. if ( oTCameraOffset == cameraOffsetLeft )
  4641. {
  4642. if ( delayCameraOrientationChange || delayOrientationChange )
  4643. {
  4644. screenSpaceOffset = 0.75f;
  4645. moveData.pivotDistanceController.SetDesiredDistance( 1.6f, 3.f );
  4646. moveData.pivotPositionController.offsetZ = 1.4f;
  4647. moveData.pivotRotationController.SetDesiredPitch( -15.f );
  4648. }
  4649. else
  4650. {
  4651. screenSpaceOffset = 0.7f;
  4652. moveData.pivotDistanceController.SetDesiredDistance( 3.25f );
  4653. moveData.pivotPositionController.offsetZ = 1.2f;
  4654. moveData.pivotRotationController.SetDesiredPitch( -10.f );
  4655. }
  4656. }
  4657. else if ( oTCameraOffset == cameraOffsetRight )
  4658. {
  4659. if ( delayCameraOrientationChange || delayOrientationChange )
  4660. {
  4661. screenSpaceOffset = -0.85f;
  4662. moveData.pivotDistanceController.SetDesiredDistance( 1.6f, 3.f );
  4663. moveData.pivotPositionController.offsetZ = 1.4f;
  4664. moveData.pivotRotationController.SetDesiredPitch( -15.f );
  4665. }
  4666. else
  4667. {
  4668. screenSpaceOffset = -0.8f;
  4669. moveData.pivotDistanceController.SetDesiredDistance( 3.25f );
  4670. moveData.pivotPositionController.offsetZ = 1.2f;
  4671. moveData.pivotRotationController.SetDesiredPitch( -10.f );
  4672. }
  4673. }
  4674. else
  4675. {
  4676. moveData.pivotDistanceController.SetDesiredDistance( 1.25f, 3.f );
  4677. moveData.pivotPositionController.offsetZ = 1.3f;
  4678. moveData.pivotRotationController.SetDesiredPitch( -5.5f );
  4679. }
  4680.  
  4681. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( screenSpaceOffset, 0.f, 0.f ), 1.f, timeDelta );
  4682.  
  4683. if ( !delayCameraOrientationChange )
  4684. {
  4685. if ( moveTarget )
  4686. moveData.pivotRotationController.SetDesiredHeading( GetHeading() + oTCameraOffset, 0.5f );
  4687. else
  4688. moveData.pivotRotationController.SetDesiredHeading( GetHeading() + oTCameraOffset, 1.f );
  4689. }
  4690. else
  4691. moveData.pivotRotationController.SetDesiredHeading( moveData.pivotRotationValue.Yaw, 1.f );
  4692.  
  4693. moveData.pivotPositionController.SetDesiredPosition( GetWorldPosition() );
  4694.  
  4695. return true;
  4696. }
  4697.  
  4698.  
  4699. private var fovVel : float;
  4700. private var sprintOffset : Vector;
  4701. private var previousOffset : bool;
  4702. private var previousRotationVelocity : float;
  4703. private var pivotRotationTimeStamp : float;
  4704. protected function UpdateCameraSprint( out moveData : SCameraMovementData, timeDelta : float )
  4705. {
  4706. var angleDiff : float;
  4707. var camOffsetVector : Vector;
  4708. var smoothSpeed : float;
  4709. var camera : CCustomCamera;
  4710. var camAngularSpeed : float;
  4711.  
  4712. var playerToCamAngle : float;
  4713. var useExplorationSprintCam : bool;
  4714.  
  4715.  
  4716. if(GetExplCamera() || GetCmbtCamera())
  4717. {
  4718. return;
  4719. }
  4720.  
  4721.  
  4722. camera = theGame.GetGameCamera();
  4723. if( camera )
  4724. {
  4725. if ( sprintingCamera )
  4726. {
  4727.  
  4728. if( thePlayer.GetAutoCameraCenter() )
  4729. {
  4730. theGame.GetGameCamera().ForceManualControlVerTimeout();
  4731. }
  4732.  
  4733. playerToCamAngle = AbsF( AngleDistance( GetHeading(), moveData.pivotRotationValue.Yaw ) );
  4734.  
  4735.  
  4736. useExplorationSprintCam = false;
  4737.  
  4738. if ( useExplorationSprintCam )
  4739. {
  4740. if ( playerToCamAngle <= 45 )
  4741. {
  4742. theGame.GetGameCamera().ChangePivotRotationController( 'Sprint' );
  4743.  
  4744. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  4745.  
  4746. moveData.pivotRotationController.SetDesiredHeading( GetHeading(), 0.25f );
  4747. moveData.pivotRotationController.SetDesiredPitch( -3.5f, 0.5f );
  4748. thePlayer.EnableManualCameraControl( true, 'Sprint' );
  4749. }
  4750. else
  4751. {
  4752. thePlayer.EnableManualCameraControl( false, 'Sprint' );
  4753. }
  4754. }
  4755. else
  4756. {
  4757. if ( theGame.IsUberMovementEnabled() )
  4758. moveData.pivotRotationController.SetDesiredHeading( GetHeading(), 0.35f );
  4759.  
  4760. thePlayer.EnableManualCameraControl( true, 'Sprint' );
  4761. }
  4762.  
  4763. if ( bRAxisReleased )
  4764. {
  4765. if ( AbsF( rawLeftJoyRot ) > 25 )
  4766. angleDiff = AngleDistance( GetHeading(), moveData.pivotRotationValue.Yaw );
  4767.  
  4768. pivotRotationTimeStamp = theGame.GetEngineTimeAsSeconds();
  4769. previousRotationVelocity = 0.f;
  4770. }
  4771. else
  4772. {
  4773. if ( previousRotationVelocity <= 0 && AbsF( moveData.pivotRotationVelocity.Yaw ) > 250 )
  4774. {
  4775. pivotRotationTimeStamp = theGame.GetEngineTimeAsSeconds();
  4776. previousRotationVelocity = AbsF( moveData.pivotRotationVelocity.Yaw );
  4777. }
  4778. }
  4779.  
  4780. if ( pivotRotationTimeStamp + 0.4f <= theGame.GetEngineTimeAsSeconds() && AbsF( moveData.pivotRotationVelocity.Yaw ) > 250 )
  4781. angleDiff = VecHeading( rawRightJoyVec );
  4782.  
  4783. if ( useExplorationSprintCam )
  4784. {
  4785. if ( playerToCamAngle > 90 )
  4786. {
  4787. camOffsetVector.X = 0.f;
  4788. smoothSpeed = 1.f;
  4789. }
  4790. else if ( angleDiff > 15.f )
  4791. {
  4792. camOffsetVector.X = -0.8;
  4793. smoothSpeed = 1.f;
  4794. previousOffset = true;
  4795. }
  4796. else if ( angleDiff < -15.f )
  4797. {
  4798. camOffsetVector.X = 0.475f;
  4799. smoothSpeed = 1.5f;
  4800. previousOffset = false;
  4801. }
  4802. else
  4803. {
  4804. if ( previousOffset )
  4805. {
  4806. camOffsetVector.X = -0.8;
  4807. smoothSpeed = 1.5f;
  4808. }
  4809. else
  4810. {
  4811. camOffsetVector.X = 0.475f;
  4812. smoothSpeed = 1.5f;
  4813. }
  4814. }
  4815.  
  4816. camOffsetVector.Y = 1.4f;
  4817. camOffsetVector.Z = 0.275f;
  4818. }
  4819. else
  4820. {
  4821.  
  4822. smoothSpeed = 0.75f;
  4823.  
  4824. camOffsetVector.X = 0.f;
  4825. camOffsetVector.Y = 1.f;
  4826. camOffsetVector.Z = 0.2f;
  4827. moveData.pivotRotationController.SetDesiredPitch( -10.f, 0.5f );
  4828. }
  4829.  
  4830. DampVectorConst( sprintOffset, camOffsetVector, smoothSpeed, timeDelta );
  4831.  
  4832. moveData.cameraLocalSpaceOffset = sprintOffset;
  4833.  
  4834. DampFloatSpring( camera.fov, fovVel, 70.f, 1.0, timeDelta );
  4835. }
  4836. else
  4837. {
  4838. sprintOffset = moveData.cameraLocalSpaceOffset;
  4839. DampFloatSpring( camera.fov, fovVel, 60.f, 1.0, timeDelta );
  4840. previousOffset = false;
  4841. }
  4842. }
  4843. }
  4844.  
  4845. function EnableSprintingCamera( flag : bool )
  4846. {
  4847. if( !theGame.IsUberMovementEnabled() && !useSprintingCameraAnim )
  4848. {
  4849. return;
  4850. }
  4851.  
  4852. super.EnableSprintingCamera( flag );
  4853.  
  4854. if ( !flag )
  4855. {
  4856. thePlayer.EnableManualCameraControl( true, 'Sprint' );
  4857. }
  4858. }
  4859.  
  4860. protected function UpdateCameraCombatActionButNotInCombat( out moveData : SCameraMovementData, timeDelta : float )
  4861. {
  4862. var vel : Vector;
  4863. var heading : float;
  4864. var pitch : float;
  4865. var headingMult : float;
  4866. var pitchMult : float;
  4867. var camOffset : Vector;
  4868. var buff : CBaseGameplayEffect;
  4869. var runningAndAlertNear : bool;
  4870. var desiredDist : float;
  4871.  
  4872. if ( !GetExplCamera() && !GetCmbtCamera() && ( !IsCurrentSignChanneled() || GetCurrentlyCastSign() == ST_Quen || GetCurrentlyCastSign() == ST_Yrden ) && !specialAttackCamera && !IsInCombatActionFriendly() )
  4873. {
  4874. buff = GetCurrentlyAnimatedCS();
  4875. runningAndAlertNear = GetPlayerCombatStance() == PCS_AlertNear && playerMoveType == PMT_Run && !GetDisplayTarget();
  4876. if ( runningAndAlertNear ||
  4877. ( GetPlayerCombatStance() == PCS_AlertFar && !IsInCombatAction() && !buff ) )
  4878. {
  4879. camOffset.X = 0.f;
  4880. camOffset.Y = 0.f;
  4881. camOffset.Z = -0.1f;
  4882.  
  4883. if ( runningAndAlertNear )
  4884. {
  4885. moveData.pivotDistanceController.SetDesiredDistance( 4.f );
  4886. moveData.pivotPositionController.offsetZ = 1.5f;
  4887. }
  4888. }
  4889. else
  4890. {
  4891. camOffset.X = 0.f;
  4892. camOffset.Y = -1.5f;
  4893. camOffset.Z = -0.2f;
  4894. }
  4895.  
  4896. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( camOffset.X, camOffset.Y, camOffset.Z ), 0.4f, timeDelta );
  4897. sprintOffset = moveData.cameraLocalSpaceOffset;
  4898. heading = moveData.pivotRotationValue.Yaw;
  4899.  
  4900. if ( GetOrientationTarget() == OT_Camera || GetOrientationTarget() == OT_CameraOffset )
  4901. pitch = moveData.pivotRotationValue.Pitch;
  4902. else if ( lastAxisInputIsMovement
  4903. || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack
  4904. || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_SpecialAttack
  4905. || ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign && !IsCurrentSignChanneled() && GetCurrentlyCastSign() == ST_Quen ) )
  4906. {
  4907. theGame.GetGameCamera().ForceManualControlVerTimeout();
  4908. pitch = -20.f;
  4909. }
  4910. else
  4911. pitch = moveData.pivotRotationValue.Pitch;
  4912.  
  4913. headingMult = 1.f;
  4914. pitchMult = 1.f;
  4915.  
  4916.  
  4917. if( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign
  4918. && ( GetEquippedSign() == ST_Aard || GetEquippedSign() == ST_Yrden )
  4919. && GetBehaviorVariable( 'alternateSignCast' ) == 1 )
  4920. {
  4921.  
  4922. theGame.GetGameCamera().ForceManualControlVerTimeout();
  4923. pitch = -20.f;
  4924.  
  4925.  
  4926. }
  4927.  
  4928.  
  4929.  
  4930.  
  4931.  
  4932.  
  4933.  
  4934. if ( IsCurrentSignChanneled() && GetCurrentlyCastSign() == ST_Quen )
  4935. {
  4936. pitch = moveData.pivotRotationValue.Pitch;
  4937. }
  4938.  
  4939. moveData.pivotRotationController.SetDesiredHeading( heading, );
  4940. moveData.pivotRotationController.SetDesiredPitch( pitch );
  4941. }
  4942. }
  4943.  
  4944.  
  4945.  
  4946. event OnGameCameraExplorationRotCtrlChange()
  4947. {
  4948. if( substateManager )
  4949. {
  4950. return substateManager.OnGameCameraExplorationRotCtrlChange( );
  4951. }
  4952.  
  4953. return false;
  4954. }
  4955.  
  4956.  
  4957.  
  4958.  
  4959.  
  4960.  
  4961. function SetCustomRotation( customRotationName : name, rotHeading : float, rotSpeed : float, activeTime : float, rotateExistingDeltaLocation : bool )
  4962. {
  4963. var movementAdjustor : CMovementAdjustor;
  4964. var ticket : SMovementAdjustmentRequestTicket;
  4965.  
  4966. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  4967. ticket = movementAdjustor.GetRequest( customRotationName );
  4968. movementAdjustor.Cancel( ticket );
  4969. ticket = movementAdjustor.CreateNewRequest( customRotationName );
  4970. movementAdjustor.Continuous( ticket );
  4971. movementAdjustor.ReplaceRotation( ticket );
  4972. movementAdjustor.RotateTo( ticket, rotHeading );
  4973. movementAdjustor.MaxRotationAdjustmentSpeed( ticket, rotSpeed );
  4974. if (rotSpeed == 0.0f)
  4975. {
  4976. movementAdjustor.AdjustmentDuration( ticket, activeTime );
  4977. }
  4978. movementAdjustor.KeepActiveFor( ticket, activeTime );
  4979. movementAdjustor.RotateExistingDeltaLocation( ticket, rotateExistingDeltaLocation );
  4980. }
  4981.  
  4982. function UpdateCustomRotationHeading( customRotationName : name, rotHeading : float )
  4983. {
  4984. var movementAdjustor : CMovementAdjustor;
  4985. var ticket : SMovementAdjustmentRequestTicket;
  4986.  
  4987. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  4988. ticket = movementAdjustor.GetRequest( customRotationName );
  4989. movementAdjustor.RotateTo( ticket, rotHeading );
  4990. }
  4991.  
  4992. function SetCustomRotationTowards( customRotationName : name, target : CActor, rotSpeed : float, optional activeTime : float )
  4993. {
  4994. var movementAdjustor : CMovementAdjustor;
  4995. var ticket : SMovementAdjustmentRequestTicket;
  4996.  
  4997. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  4998. ticket = movementAdjustor.GetRequest( customRotationName );
  4999. movementAdjustor.Cancel( ticket );
  5000. ticket = movementAdjustor.CreateNewRequest( customRotationName );
  5001. movementAdjustor.Continuous( ticket );
  5002. movementAdjustor.ReplaceRotation( ticket );
  5003. movementAdjustor.RotateTowards( ticket, target );
  5004. movementAdjustor.MaxRotationAdjustmentSpeed( ticket, rotSpeed );
  5005. if (activeTime > 0.0f)
  5006. {
  5007. movementAdjustor.KeepActiveFor( ticket, activeTime );
  5008. }
  5009. else
  5010. {
  5011. movementAdjustor.DontEnd( ticket );
  5012. }
  5013. }
  5014.  
  5015.  
  5016. function CustomLockMovement( customMovementName : name, heading : float )
  5017. {
  5018. var movementAdjustor : CMovementAdjustor;
  5019. var ticket : SMovementAdjustmentRequestTicket;
  5020.  
  5021. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  5022. ticket = movementAdjustor.GetRequest( customMovementName );
  5023. movementAdjustor.Cancel( ticket );
  5024. ticket = movementAdjustor.CreateNewRequest( customMovementName );
  5025. movementAdjustor.Continuous( ticket );
  5026. movementAdjustor.DontEnd( ticket );
  5027. movementAdjustor.LockMovementInDirection( ticket, heading );
  5028. }
  5029.  
  5030. function BindMovementAdjustmentToEvent( customRotationName : name, eventName : CName )
  5031. {
  5032. var movementAdjustor : CMovementAdjustor;
  5033. var ticket : SMovementAdjustmentRequestTicket;
  5034.  
  5035. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  5036. ticket = movementAdjustor.GetRequest( customRotationName );
  5037. movementAdjustor.BindToEvent( ticket, eventName );
  5038. }
  5039.  
  5040. function UpdateCustomLockMovementHeading( customMovementName : name, heading : float )
  5041. {
  5042. var movementAdjustor : CMovementAdjustor;
  5043. var ticket : SMovementAdjustmentRequestTicket;
  5044.  
  5045. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  5046. ticket = movementAdjustor.GetRequest( customMovementName );
  5047. movementAdjustor.LockMovementInDirection( ticket, heading );
  5048. }
  5049.  
  5050. function CustomLockDistance( customMovementName : name, maintainDistanceTo : CNode, minDist, maxDist : float )
  5051. {
  5052. var movementAdjustor : CMovementAdjustor;
  5053. var ticket : SMovementAdjustmentRequestTicket;
  5054.  
  5055. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  5056. ticket = movementAdjustor.GetRequest( customMovementName );
  5057. movementAdjustor.Cancel( ticket );
  5058. ticket = movementAdjustor.CreateNewRequest( customMovementName );
  5059. movementAdjustor.Continuous( ticket );
  5060. movementAdjustor.SlideTowards( ticket, maintainDistanceTo, minDist, maxDist );
  5061. }
  5062.  
  5063. function UpdateCustomLockDistance( customMovementName : name, maintainDistanceTo : CNode, minDist, maxDist : float )
  5064. {
  5065. var movementAdjustor : CMovementAdjustor;
  5066. var ticket : SMovementAdjustmentRequestTicket;
  5067.  
  5068. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  5069. ticket = movementAdjustor.GetRequest( customMovementName );
  5070. movementAdjustor.SlideTowards( ticket, maintainDistanceTo, minDist, maxDist );
  5071. }
  5072.  
  5073. private var disableManualCameraControlStack : array<name>;
  5074. public function EnableManualCameraControl( enable : bool, sourceName : name )
  5075. {
  5076. if ( !enable )
  5077. {
  5078. if ( !disableManualCameraControlStack.Contains( sourceName ) )
  5079. {
  5080. disableManualCameraControlStack.PushBack( sourceName );
  5081. }
  5082. }
  5083. else
  5084. {
  5085. disableManualCameraControlStack.Remove( sourceName );
  5086. }
  5087.  
  5088. if ( disableManualCameraControlStack.Size() > 0 )
  5089. theGame.GetGameCamera().EnableManualControl( false );
  5090. else
  5091. theGame.GetGameCamera().EnableManualControl( true );
  5092. }
  5093.  
  5094. public function IsCameraControlDisabled( optional disabledBySourceName : name ) : bool
  5095. {
  5096. if ( disabledBySourceName )
  5097. return disableManualCameraControlStack.Contains( disabledBySourceName );
  5098. else
  5099. return disableManualCameraControlStack.Size() > 0;
  5100. }
  5101.  
  5102. public function DisableManualCameraControlStackHasSource( sourceName : name ) : bool
  5103. {
  5104. return disableManualCameraControlStack.Contains( sourceName );
  5105. }
  5106.  
  5107. public function ClearDisableManualCameraControlStack()
  5108. {
  5109. disableManualCameraControlStack.Clear();
  5110. theGame.GetGameCamera().EnableManualControl( true );
  5111. }
  5112.  
  5113. function SetOrientationTarget( target : EOrientationTarget )
  5114. {
  5115. /*
  5116. if ( IsPCModeEnabled() && target == OT_Player )
  5117. {
  5118. target = OT_Camera;
  5119. }
  5120. */ //modCombatStance
  5121.  
  5122. orientationTarget = target;
  5123. }
  5124.  
  5125. function GetOrientationTarget() : EOrientationTarget
  5126. {
  5127. return orientationTarget;
  5128. }
  5129.  
  5130. var customOrientationInfoStack : array<SCustomOrientationInfo>;
  5131. public function AddCustomOrientationTarget( orientationTarget : EOrientationTarget, sourceName : name )
  5132. {
  5133. var customOrientationInfo : SCustomOrientationInfo;
  5134. var i : int;
  5135.  
  5136. if ( customOrientationInfoStack.Size() > 0 )
  5137. {
  5138. for( i = customOrientationInfoStack.Size()-1; i>=0; i-=1 )
  5139. {
  5140. if ( customOrientationInfoStack[i].sourceName == sourceName )
  5141. customOrientationInfoStack.Erase(i);
  5142. }
  5143. }
  5144.  
  5145. customOrientationInfo.sourceName = sourceName;
  5146. customOrientationInfo.orientationTarget = orientationTarget;
  5147. customOrientationInfoStack.PushBack( customOrientationInfo );
  5148. SetOrientationTarget( orientationTarget );
  5149. }
  5150.  
  5151. public function RemoveCustomOrientationTarget( sourceName : name )
  5152. {
  5153. var customOrientationInfo : SCustomOrientationInfo;
  5154. var i : int;
  5155.  
  5156. if ( customOrientationInfoStack.Size() > 0 )
  5157. {
  5158. for( i = customOrientationInfoStack.Size()-1; i>=0; i-=1 )
  5159. {
  5160. if ( customOrientationInfoStack[i].sourceName == sourceName )
  5161. customOrientationInfoStack.Erase(i);
  5162. }
  5163. }
  5164. else
  5165. LogChannel( 'CustomOrienatation', "ERROR: Custom orientation cannot be removed, stack is already empty!!!" );
  5166. }
  5167.  
  5168. protected function ClearCustomOrientationInfoStack()
  5169. {
  5170. customOrientationInfoStack.Clear();
  5171. }
  5172.  
  5173. protected function GetCustomOrientationTarget( out infoStack : SCustomOrientationInfo ) : bool
  5174. {
  5175. var size : int;
  5176.  
  5177. size = customOrientationInfoStack.Size();
  5178.  
  5179. if ( size <= 0 )
  5180. return false;
  5181. else
  5182. {
  5183. infoStack = customOrientationInfoStack[ size - 1 ];
  5184. return true;
  5185. }
  5186. }
  5187.  
  5188. public function SetOrientationTargetCustomHeading( heading : float, sourceName : name ) : bool
  5189. {
  5190. var i : int;
  5191. if ( customOrientationInfoStack.Size() > 0 )
  5192. {
  5193. for( i = customOrientationInfoStack.Size()-1; i>=0; i-=1 )
  5194. {
  5195. if ( customOrientationInfoStack[i].sourceName == sourceName )
  5196. {
  5197. customOrientationInfoStack[i].customHeading = heading;
  5198. return true;
  5199. }
  5200. }
  5201. }
  5202.  
  5203. LogChannel( 'SetOrientationTargetCustomHeading', "ERROR: Cannot set customHeading because stack is empty or sourceName is not found!!!" );
  5204. return false;
  5205. }
  5206.  
  5207.  
  5208. public function GetOrientationTargetCustomHeading() : float
  5209. {
  5210. var i : int;
  5211. if ( customOrientationInfoStack.Size() > 0 )
  5212. {
  5213. for( i = customOrientationInfoStack.Size()-1; i>=0; i-=1 )
  5214. {
  5215. if ( customOrientationInfoStack[i].orientationTarget == OT_CustomHeading )
  5216. {
  5217. return customOrientationInfoStack[i].customHeading;
  5218. }
  5219. }
  5220. }
  5221.  
  5222. LogChannel( 'SetOrientationTargetCustomHeading', "ERROR: Cannot get customHeading because stack is empty or no OT_CustomHeading in stack!!!" );
  5223. return -1.f;
  5224. }
  5225.  
  5226. public function GetCombatActionOrientationTarget( combatActionType : ECombatActionType ) : EOrientationTarget
  5227. {
  5228. var newCustomOrientationTarget : EOrientationTarget;
  5229. var targetEnt : CGameplayEntity;
  5230. var targetActor : CActor;
  5231.  
  5232. if ( GetCurrentStateName() == 'AimThrow' )
  5233. newCustomOrientationTarget = OT_CameraOffset;
  5234. else
  5235. {
  5236. targetEnt = GetDisplayTarget();
  5237. targetActor = (CActor)targetEnt;
  5238.  
  5239. if ( targetEnt )
  5240. {
  5241. if ( targetActor )
  5242. {
  5243. if ( moveTarget )
  5244. newCustomOrientationTarget = OT_Actor;
  5245. else
  5246. {
  5247. if ( this.IsSwimming() )
  5248. newCustomOrientationTarget = OT_Camera;
  5249. else if ( lastAxisInputIsMovement )
  5250. newCustomOrientationTarget = OT_Player;
  5251. else
  5252. newCustomOrientationTarget = OT_Actor;
  5253. }
  5254. }
  5255. else
  5256. {
  5257. if ( combatActionType == CAT_Crossbow && targetEnt.HasTag( 'softLock_Bolt' ) )
  5258. newCustomOrientationTarget = OT_Actor;
  5259. else
  5260. {
  5261. if ( this.IsSwimming() )
  5262. newCustomOrientationTarget = OT_Camera;
  5263. else if ( lastAxisInputIsMovement )
  5264. newCustomOrientationTarget = OT_Player;
  5265. else
  5266. newCustomOrientationTarget = OT_Camera;
  5267.  
  5268. }
  5269. }
  5270. }
  5271. else
  5272. {
  5273. if ( IsUsingVehicle() )
  5274. newCustomOrientationTarget = OT_Camera;
  5275. else if ( lastAxisInputIsMovement )
  5276. {
  5277. if ( this.IsSwimming() )
  5278. {
  5279.  
  5280.  
  5281. newCustomOrientationTarget = OT_Camera;
  5282.  
  5283.  
  5284. }
  5285. else
  5286. newCustomOrientationTarget = OT_Player;
  5287.  
  5288. }
  5289. else
  5290. newCustomOrientationTarget = OT_Camera;
  5291. }
  5292. }
  5293.  
  5294. return newCustomOrientationTarget;
  5295. }
  5296.  
  5297. public function GetOrientationTargetHeading( orientationTarget : EOrientationTarget ) : float
  5298. {
  5299. var heading : float;
  5300.  
  5301. if( orientationTarget == OT_Camera )
  5302. heading = VecHeading( theCamera.GetCameraDirection() );
  5303. else if( orientationTarget == OT_CameraOffset )
  5304. heading = VecHeading( theCamera.GetCameraDirection() ) - oTCameraOffset;
  5305. else if( orientationTarget == OT_CustomHeading )
  5306. heading = GetOrientationTargetCustomHeading();
  5307. else if ( GetDisplayTarget() && orientationTarget == OT_Actor )
  5308. {
  5309. if ( (CActor)( GetDisplayTarget() ) )
  5310. {
  5311.  
  5312. heading = VecHeading( GetDisplayTarget().GetWorldPosition() - GetWorldPosition() );
  5313.  
  5314.  
  5315. }
  5316. else
  5317. {
  5318. if ( GetDisplayTarget().HasTag( 'softLock_Bolt' ) )
  5319. heading = VecHeading( GetDisplayTarget().GetWorldPosition() - GetWorldPosition() );
  5320. else
  5321. heading = GetHeading();
  5322. }
  5323. }
  5324. else
  5325. heading = GetHeading();
  5326.  
  5327. return heading;
  5328. }
  5329.  
  5330. event OnDelayOrientationChange()
  5331. {
  5332. var delayOrientation : bool;
  5333. var delayCameraRotation : bool;
  5334. var moveData : SCameraMovementData;
  5335. var time : float;
  5336.  
  5337. time = 0.01f;
  5338.  
  5339. if ( theInput.GetActionValue( 'CastSignHold' ) == 1.f )
  5340. {
  5341. actionType = 0;
  5342. if ( moveTarget )
  5343. delayOrientation = true;
  5344. else
  5345. {
  5346. if ( !GetBIsCombatActionAllowed() )
  5347. delayOrientation = true;
  5348. }
  5349.  
  5350.  
  5351. }
  5352. else if ( theInput.GetActionValue( 'ThrowItemHold' ) == 1.f )
  5353. {
  5354. actionType = 3;
  5355. delayOrientation = true;
  5356. }
  5357. else if ( theInput.GetActionValue( 'SpecialAttackHeavy' ) == 1.f )
  5358. {
  5359. actionType = 2;
  5360. if ( !slideTarget )
  5361. delayOrientation = true;
  5362. else
  5363. delayOrientation = true;
  5364. }
  5365. else if ( IsGuarded() && !moveTarget )
  5366. {
  5367. actionType = 1;
  5368. delayOrientation = true;
  5369. }
  5370.  
  5371. if ( delayOrientation )
  5372. {
  5373. delayOrientationChange = true;
  5374. theGame.GetGameCamera().ForceManualControlHorTimeout();
  5375. theGame.GetGameCamera().ForceManualControlVerTimeout();
  5376. AddTimer( 'DelayOrientationChangeTimer', time, true );
  5377. }
  5378.  
  5379. if ( delayCameraRotation )
  5380. {
  5381. delayCameraOrientationChange = true;
  5382. theGame.GetGameCamera().ForceManualControlHorTimeout();
  5383. theGame.GetGameCamera().ForceManualControlVerTimeout();
  5384. AddTimer( 'DelayOrientationChangeTimer', time, true );
  5385. }
  5386. }
  5387.  
  5388.  
  5389. event OnDelayOrientationChangeOff()
  5390. {
  5391. delayOrientationChange = false;
  5392. delayCameraOrientationChange = false;
  5393. RemoveTimer( 'DelayOrientationChangeTimer' );
  5394.  
  5395.  
  5396.  
  5397. }
  5398.  
  5399. timer function DelayOrientationChangeTimer( time : float , id : int)
  5400. {
  5401. if ( ( actionType == 0 && theInput.GetActionValue( 'CastSignHold' ) == 0.f )
  5402. || ( actionType == 2 && theInput.GetActionValue( 'SpecialAttackHeavy' ) == 0.f )
  5403. || ( actionType == 3 && theInput.GetActionValue( 'ThrowItemHold' ) == 0.f )
  5404. || ( actionType == 1 && !IsGuarded() )
  5405. || ( VecLength( rawRightJoyVec ) > 0.f ) )
  5406. {
  5407. OnDelayOrientationChangeOff();
  5408. }
  5409. }
  5410.  
  5411. public function SetCombatActionHeading( heading : float )
  5412. {
  5413. combatActionHeading = heading;
  5414. }
  5415.  
  5416. public function GetCombatActionHeading() : float
  5417. {
  5418. return combatActionHeading;
  5419. }
  5420.  
  5421. protected function EnableCloseCombatCharacterRadius( flag : bool )
  5422. {
  5423. var actor : CActor;
  5424.  
  5425. actor = (CActor)slideTarget;
  5426. if ( flag )
  5427. {
  5428. this.GetMovingAgentComponent().SetVirtualRadius( 'CloseCombatCharacterRadius' );
  5429. if(actor)
  5430. actor.GetMovingAgentComponent().SetVirtualRadius( 'CloseCombatCharacterRadius' );
  5431. }
  5432. else
  5433. {
  5434. if ( this.IsInCombat() )
  5435. {
  5436. GetMovingAgentComponent().SetVirtualRadius( 'CombatCharacterRadius' );
  5437. if(actor)
  5438. actor.GetMovingAgentComponent().SetVirtualRadius( 'CombatCharacterRadius' );
  5439. }
  5440. else
  5441. {
  5442. this.GetMovingAgentComponent().ResetVirtualRadius();
  5443. if(actor)
  5444. actor.GetMovingAgentComponent().ResetVirtualRadius();
  5445. }
  5446. }
  5447. }
  5448.  
  5449.  
  5450.  
  5451.  
  5452.  
  5453.  
  5454. private var isSnappedToNavMesh : bool;
  5455. private var snapToNavMeshCachedFlag : bool;
  5456. public function SnapToNavMesh( flag : bool )
  5457. {
  5458. var comp : CMovingAgentComponent;
  5459.  
  5460. comp = (CMovingAgentComponent)this.GetMovingAgentComponent();
  5461.  
  5462. if ( comp )
  5463. {
  5464. comp.SnapToNavigableSpace( flag );
  5465. isSnappedToNavMesh = flag;
  5466. }
  5467. else
  5468. {
  5469. snapToNavMeshCachedFlag = flag;
  5470. AddTimer( 'DelayedSnapToNavMesh', 0.2f );
  5471. }
  5472. }
  5473.  
  5474. public final function PlayRuneword4FX(optional weaponType : EPlayerWeapon)
  5475. {
  5476. var hasSwordDrawn : bool;
  5477. var sword : SItemUniqueId;
  5478.  
  5479.  
  5480.  
  5481.  
  5482. if(abilityManager.GetOverhealBonus() > (0.005 * GetStatMax(BCS_Vitality)))
  5483. {
  5484. hasSwordDrawn = HasAbility('Runeword 4 _Stats', true);
  5485.  
  5486. if(!hasSwordDrawn && GetWitcherPlayer())
  5487. {
  5488. if(weaponType == PW_Steel)
  5489. {
  5490. if(GetWitcherPlayer().GetItemEquippedOnSlot(EES_SteelSword, sword))
  5491. hasSwordDrawn = inv.ItemHasAbility(sword, 'Runeword 4 _Stats');
  5492. }
  5493. else if(weaponType == PW_Silver)
  5494. {
  5495. if(GetWitcherPlayer().GetItemEquippedOnSlot(EES_SilverSword, sword))
  5496. hasSwordDrawn = inv.ItemHasAbility(sword, 'Runeword 4 _Stats');
  5497. }
  5498. }
  5499.  
  5500. if(hasSwordDrawn)
  5501. {
  5502. if(!IsEffectActive('runeword_4', true))
  5503. PlayEffect('runeword_4');
  5504. }
  5505. }
  5506. }
  5507.  
  5508. timer function DelayedSnapToNavMesh( dt : float, id : int)
  5509. {
  5510. SnapToNavMesh( snapToNavMeshCachedFlag );
  5511. }
  5512.  
  5513. saved var navMeshSnapInfoStack : array<name>;
  5514. public function EnableSnapToNavMesh( source : name, enable : bool )
  5515. {
  5516. if ( enable )
  5517. {
  5518. if ( !navMeshSnapInfoStack.Contains( source ) )
  5519. navMeshSnapInfoStack.PushBack( source );
  5520. }
  5521. else
  5522. {
  5523. if ( navMeshSnapInfoStack.Contains( source ) )
  5524. navMeshSnapInfoStack.Remove( source );
  5525. }
  5526.  
  5527. if ( navMeshSnapInfoStack.Size() > 0 )
  5528. SnapToNavMesh( true );
  5529. else
  5530. SnapToNavMesh( false );
  5531. }
  5532.  
  5533. public function ForceRemoveAllNavMeshSnaps()
  5534. {
  5535. navMeshSnapInfoStack.Clear();
  5536. SnapToNavMesh( false );
  5537. }
  5538.  
  5539. public function CanSprint( speed : float ) : bool
  5540. {
  5541. if( speed <= 0.8f )
  5542. {
  5543. return false;
  5544. }
  5545.  
  5546. if ( thePlayer.GetIsSprintToggled() )
  5547. {
  5548. }
  5549.  
  5550. else if(GetLeftStickSprint() && theInput.LastUsedGamepad())
  5551. {
  5552. if(GetIsSprintToggled() && GetIsSprinting())
  5553. {
  5554. }
  5555. else if(!GetIsSprintToggled())
  5556. return false;
  5557. }
  5558.  
  5559. else if ( !sprintActionPressed )
  5560. {
  5561. return false;
  5562. }
  5563. else if( !theInput.IsActionPressed('Sprint') || ( theInput.LastUsedGamepad() && IsInsideInteraction() && GetHowLongSprintButtonWasPressed() < 0.12 ) )
  5564. {
  5565. return false;
  5566. }
  5567.  
  5568. if(gmConfig().enableNoEncumbered) { GetWitcherPlayer().RemoveAllBuffsOfType( EET_OverEncumbered ); } // ===== Added by God Mode mod - Module: No Encumbered =====
  5569.  
  5570. if ( thePlayer.HasBuff( EET_OverEncumbered ) )
  5571. {
  5572. return false;
  5573. }
  5574. if ( !IsSwimming() )
  5575. {
  5576. if ( ShouldUseStaminaWhileSprinting() && !GetIsSprinting() && !IsInCombat() && GetStatPercents(BCS_Stamina) <= 0.9 )
  5577. {
  5578. return false;
  5579. }
  5580. if( ( !IsCombatMusicEnabled() || IsInFistFightMiniGame() ) && ( !IsActionAllowed(EIAB_RunAndSprint) || !IsActionAllowed(EIAB_Sprint) ) )
  5581. {
  5582. return false;
  5583. }
  5584. if( IsTerrainTooSteepToRunUp() )
  5585. {
  5586. return false;
  5587. }
  5588. if( IsInCombatAction() )
  5589. {
  5590. return false;
  5591. }
  5592. if( IsInAir() )
  5593. {
  5594. return false;
  5595. }
  5596. }
  5597. if( theGame.IsFocusModeActive() && !gmConfig().enableSenseJumpRun ) // ===== Added by God Mode mod - Module: Sense Run Jump =====
  5598. {
  5599. return false;
  5600. }
  5601.  
  5602. return true;
  5603. }
  5604.  
  5605.  
  5606. public function SetTerrainPitch( pitch : float )
  5607. {
  5608. terrainPitch = pitch;
  5609. }
  5610.  
  5611. public function IsTerrainTooSteepToRunUp() : bool
  5612. {
  5613. return terrainPitch <= disableSprintTerrainPitch;
  5614. }
  5615.  
  5616. public function SetTempLookAtTarget( actor : CGameplayEntity )
  5617. {
  5618. tempLookAtTarget = actor;
  5619. }
  5620.  
  5621. private var beingWarnedBy : array<CActor>;
  5622.  
  5623. event OnBeingWarnedStart( sender : CActor )
  5624. {
  5625. if ( !beingWarnedBy.Contains(sender) )
  5626. beingWarnedBy.PushBack(sender);
  5627. }
  5628. event OnBeingWarnedStop( sender : CActor )
  5629. {
  5630. beingWarnedBy.Remove(sender);
  5631. }
  5632.  
  5633. event OnCanFindPath( sender : CActor )
  5634. {
  5635. AddCanFindPathEnemyToList(sender,true);
  5636. }
  5637. event OnCannotFindPath( sender : CActor )
  5638. {
  5639. AddCanFindPathEnemyToList(sender,false);
  5640. }
  5641. event OnBecomeAwareAndCanAttack( sender : CActor )
  5642. {
  5643. AddEnemyToHostileEnemiesList( sender, true );
  5644. OnApproachAttack( sender );
  5645. }
  5646. event OnBecomeUnawareOrCannotAttack( sender : CActor )
  5647. {
  5648. AddEnemyToHostileEnemiesList( sender, false );
  5649. OnApproachAttackEnd( sender );
  5650. OnCannotFindPath(sender);
  5651. }
  5652. event OnApproachAttack( sender : CActor )
  5653. {
  5654. AddEnemyToHostileEnemiesList( sender, true );
  5655. super.OnApproachAttack( sender );
  5656. }
  5657. event OnApproachAttackEnd( sender : CActor )
  5658. {
  5659. AddEnemyToHostileEnemiesList( sender, false );
  5660. super.OnApproachAttackEnd( sender );
  5661. }
  5662. event OnAttack( sender : CActor )
  5663. {
  5664. super.OnAttack( sender );
  5665. }
  5666. event OnAttackEnd( sender : CActor )
  5667. {
  5668. super.OnAttackEnd( sender );
  5669. }
  5670.  
  5671. event OnHitCeiling()
  5672. {
  5673. substateManager.ReactOnHitCeiling();
  5674. }
  5675.  
  5676. protected var hostileEnemies : array<CActor>;
  5677. private var hostileMonsters : array<CActor>;
  5678. function AddEnemyToHostileEnemiesList( actor : CActor, add : bool )
  5679. {
  5680. if ( add )
  5681. {
  5682. RemoveTimer( 'RemoveEnemyFromHostileEnemiesListTimer' );
  5683. if ( !hostileEnemies.Contains( actor ) )
  5684. {
  5685. hostileEnemies.PushBack( actor );
  5686.  
  5687. if( !actor.IsHuman() )
  5688. hostileMonsters.PushBack( actor );
  5689. }
  5690. }
  5691. else
  5692. {
  5693. if ( hostileEnemies.Size() == 1 )
  5694. {
  5695. if ( !actor.IsAlive() || actor.IsKnockedUnconscious() )
  5696. {
  5697. hostileEnemies.Remove( actor );
  5698. if( !actor.IsHuman() )
  5699. hostileMonsters.Remove( actor );
  5700. }
  5701. else
  5702. {
  5703.  
  5704. if( hostileEnemyToRemove )
  5705. {
  5706. hostileEnemies.Remove( hostileEnemyToRemove );
  5707. if( !hostileEnemyToRemove.IsHuman() )
  5708. hostileMonsters.Remove( hostileEnemyToRemove );
  5709. }
  5710. hostileEnemyToRemove = actor;
  5711. AddTimer( 'RemoveEnemyFromHostileEnemiesListTimer', 3.f );
  5712. }
  5713. }
  5714. else
  5715. {
  5716. hostileEnemies.Remove( actor );
  5717. if( !actor.IsHuman() )
  5718. hostileMonsters.Remove( actor );
  5719. }
  5720. }
  5721. }
  5722.  
  5723.  
  5724.  
  5725. public function ShouldEnableCombatMusic() : bool
  5726. {
  5727. var moveTargetNPC : CNewNPC;
  5728.  
  5729. if ( thePlayer.GetPlayerMode().GetForceCombatMode() )
  5730. return true;
  5731. else if ( !IsCombatMusicEnabled() )
  5732. {
  5733. if ( IsInCombat() )
  5734. return true;
  5735. else if ( IsThreatened() )
  5736. {
  5737. moveTargetNPC = (CNewNPC)moveTarget;
  5738. if ( moveTargetNPC.IsRanged() && hostileEnemies.Contains( moveTargetNPC ) )
  5739. return true;
  5740. else
  5741. return false;
  5742. }
  5743. else
  5744. return false;
  5745. }
  5746. else if ( ( thePlayer.IsThreatened() && ( hostileEnemies.Size() > 0 || thePlayer.GetPlayerCombatStance() == PCS_AlertNear ) )
  5747. || IsInCombat()
  5748. || finishableEnemiesList.Size() > 0
  5749. || isInFinisher )
  5750. return true;
  5751. else
  5752. return false;
  5753.  
  5754. }
  5755.  
  5756. public var canFindPathEnemiesList : array<CActor>;
  5757. public var disablecanFindPathEnemiesListUpdate : bool;
  5758. private var lastCanFindPathEnemy : CActor;
  5759. private var cachedMoveTarget : CActor;
  5760. private var reachabilityTestId : int;
  5761. private var reachabilityTestId2 : int;
  5762. function AddCanFindPathEnemyToList( actor : CActor, add : bool )
  5763. {
  5764. if ( disablecanFindPathEnemiesListUpdate )
  5765. return;
  5766.  
  5767. if ( add && !canFindPathEnemiesList.Contains( actor ) )
  5768. {
  5769. canFindPathEnemiesList.PushBack(actor);
  5770. }
  5771. else if ( !add )
  5772. {
  5773. canFindPathEnemiesList.Remove(actor);
  5774.  
  5775. if ( canFindPathEnemiesList.Size() <= 0 )
  5776. playerMode.UpdateCombatMode();
  5777. }
  5778. }
  5779.  
  5780. public function ClearCanFindPathEnemiesList( dt : float, id : int )
  5781. {
  5782. canFindPathEnemiesList.Clear();
  5783. }
  5784.  
  5785. public var finishableEnemiesList : array<CActor>;
  5786. function AddToFinishableEnemyList( actor : CActor, add : bool )
  5787. {
  5788. if ( add && !finishableEnemiesList.Contains( actor ) )
  5789. {
  5790. finishableEnemiesList.PushBack(actor);
  5791. }
  5792. else if ( !add )
  5793. {
  5794. finishableEnemiesList.Remove(actor);
  5795. }
  5796. }
  5797.  
  5798. private function UpdateFinishableEnemyList()
  5799. {
  5800. var i : int;
  5801. i = 0;
  5802. while ( i < finishableEnemiesList.Size() )
  5803. {
  5804. if ( !finishableEnemiesList[ i ] )
  5805. {
  5806. finishableEnemiesList.EraseFast( i );
  5807. }
  5808. else
  5809. {
  5810. i += 1;
  5811. }
  5812. }
  5813. }
  5814.  
  5815. private timer function ClearFinishableEnemyList( dt : float, id : int )
  5816. {
  5817. finishableEnemiesList.Clear();
  5818. }
  5819.  
  5820. private var hostileEnemyToRemove : CActor;
  5821. private timer function RemoveEnemyFromHostileEnemiesListTimer( time : float , id : int)
  5822. {
  5823. hostileEnemies.Remove( hostileEnemyToRemove );
  5824.  
  5825. if( hostileEnemyToRemove.IsMonster() )
  5826. hostileMonsters.Remove( hostileEnemyToRemove );
  5827.  
  5828. hostileEnemyToRemove = NULL;
  5829. }
  5830.  
  5831. private function ClearHostileEnemiesList()
  5832. {
  5833. hostileEnemies.Clear();
  5834. hostileMonsters.Clear();
  5835. canFindPathEnemiesList.Clear();
  5836. }
  5837.  
  5838. private var moveTargets : array<CActor>;
  5839. public function GetMoveTargets() : array<CActor> { return moveTargets; }
  5840. public function GetNumberOfMoveTargets() : int { return moveTargets.Size(); }
  5841. public function GetHostileEnemies() : array<CActor> { return hostileEnemies; }
  5842. public function GetHostileEnemiesCount() : int { return hostileEnemies.Size(); }
  5843.  
  5844. protected var enableStrafe : bool;
  5845.  
  5846.  
  5847. public function FindMoveTarget()
  5848. {
  5849. var moveTargetDists : array<float>;
  5850. var moveTargetCanPathFinds : array<bool>;
  5851. var aPotentialMoveTargetCanFindPath : bool;
  5852.  
  5853. var newMoveTarget : CActor;
  5854. var actors : array<CActor>;
  5855. var currentHeading : float;
  5856. var size, i : int;
  5857. var playerToNewMoveTargetDist : float;
  5858. var playerToMoveTargetDist : float;
  5859. var confirmEmptyMoveTarget : bool;
  5860. var newEmptyMoveTargetTimer : float;
  5861. var wasVisibleInFullFrame : bool;
  5862. var setIsThreatened : bool;
  5863.  
  5864. var enemysTarget : CActor;
  5865. var isEnemyInCombat : bool;
  5866. var potentialMoveTargets : array<CActor>;
  5867. var onlyThreatTargets : bool;
  5868.  
  5869. thePlayer.SetupEnemiesCollection( enemyCollectionDist, enemyCollectionDist, 10, 'None', FLAG_Attitude_Neutral + FLAG_Attitude_Hostile + FLAG_Attitude_Friendly + FLAG_OnlyAliveActors );
  5870.  
  5871.  
  5872.  
  5873.  
  5874. if ( GetCurrentStateName() != 'PlayerDialogScene' && IsAlive() )
  5875. {
  5876. GetVisibleEnemies( actors );
  5877.  
  5878.  
  5879. if ( hostileEnemies.Size() > 0 )
  5880. {
  5881. for( i=0; i < hostileEnemies.Size() ; i+=1 )
  5882. {
  5883. if ( !actors.Contains( hostileEnemies[i] ) )
  5884. actors.PushBack( hostileEnemies[i] );
  5885. }
  5886. }
  5887.  
  5888.  
  5889. if ( finishableEnemiesList.Size() > 0 )
  5890. {
  5891. for( i=0; i < finishableEnemiesList.Size() ; i+=1 )
  5892. {
  5893. if ( !actors.Contains( finishableEnemiesList[i] ) )
  5894. actors.PushBack( finishableEnemiesList[i] );
  5895. }
  5896. }
  5897.  
  5898.  
  5899. if ( moveTarget && !actors.Contains( moveTarget ) )
  5900. actors.PushBack( moveTarget );
  5901.  
  5902. FilterActors( actors, onlyThreatTargets, false );
  5903.  
  5904.  
  5905. if ( actors.Size() > 0 )
  5906. {
  5907. setIsThreatened = false;
  5908.  
  5909. if ( onlyThreatTargets )
  5910. {
  5911. setIsThreatened = true;
  5912. }
  5913. else
  5914. {
  5915. for( i=0; i < actors.Size() ; i+=1 )
  5916. {
  5917. if ( IsThreat( actors[i] ) )
  5918. {
  5919. setIsThreatened = true;
  5920. break;
  5921. }
  5922. else
  5923. {
  5924. enemysTarget = actors[i].GetTarget();
  5925. isEnemyInCombat = actors[i].IsInCombat();
  5926. if ( isEnemyInCombat && enemysTarget && GetAttitudeBetween( enemysTarget, this ) == AIA_Friendly && enemysTarget.isPlayerFollower )
  5927. {
  5928. setIsThreatened = true;
  5929. break;
  5930. }
  5931. }
  5932. }
  5933. }
  5934.  
  5935.  
  5936. for( i = actors.Size()-1; i>=0; i-=1 )
  5937. {
  5938. if ( ( !actors[i].IsAlive() && !finishableEnemiesList.Contains( actors[i] ) )
  5939. || actors[i].IsKnockedUnconscious()
  5940. || this.GetUsedVehicle() == actors[i]
  5941. || !actors[i].CanBeTargeted() )
  5942. {
  5943. actors.EraseFast(i);
  5944. }
  5945. else if ( !IsThreatened() )
  5946. {
  5947. if ( !WasVisibleInScaledFrame( actors[i], 1.f, 1.f ) )
  5948. actors.EraseFast(i);
  5949. }
  5950. }
  5951. }
  5952. else if ( moveTarget && IsThreat( moveTarget ) )
  5953. setIsThreatened = true;
  5954.  
  5955. else
  5956. setIsThreatened = false;
  5957.  
  5958.  
  5959. if ( setIsThreatened )
  5960. {
  5961. enemyCollectionDist = 50.f;
  5962. SetIsThreatened( true );
  5963. }
  5964. else
  5965. {
  5966. if ( IsThreatened() )
  5967. AddTimer( 'finishableEnemiesList', 1.f );
  5968.  
  5969. enemyCollectionDist = findMoveTargetDistMax;
  5970. SetIsThreatened( false );
  5971. }
  5972.  
  5973. moveTargets = actors;
  5974. potentialMoveTargets = moveTargets;
  5975.  
  5976.  
  5977. if ( !moveTarget )
  5978. enableStrafe = false;
  5979.  
  5980. if ( potentialMoveTargets.Size() > 0 )
  5981. {
  5982. for ( i = 0; i < potentialMoveTargets.Size(); i += 1 )
  5983. {
  5984. if ( potentialMoveTargets[i].CanBeStrafed() )
  5985. enableStrafe = true;
  5986.  
  5987. if ( !potentialMoveTargets[i].GetGameplayVisibility() )
  5988. moveTargetDists.PushBack( 100.f );
  5989. else
  5990. moveTargetDists.PushBack( VecDistance( potentialMoveTargets[i].GetNearestPointInPersonalSpace( GetWorldPosition() ), GetWorldPosition() ) );
  5991.  
  5992. if ( canFindPathEnemiesList.Contains( potentialMoveTargets[i] ) )
  5993. {
  5994. moveTargetCanPathFinds.PushBack( true );
  5995. aPotentialMoveTargetCanFindPath = true;
  5996. }
  5997. else
  5998. {
  5999. moveTargetCanPathFinds.PushBack( false );
  6000. }
  6001. }
  6002.  
  6003. if ( aPotentialMoveTargetCanFindPath )
  6004. {
  6005. for ( i = moveTargetCanPathFinds.Size()-1 ; i >= 0; i-=1 )
  6006. {
  6007. if ( !moveTargetCanPathFinds[i] )
  6008. {
  6009. moveTargetCanPathFinds.EraseFast(i);
  6010. potentialMoveTargets.EraseFast(i);
  6011. moveTargetDists.EraseFast(i);
  6012. }
  6013. }
  6014. }
  6015.  
  6016. if ( moveTargetDists.Size() > 0 )
  6017. newMoveTarget = potentialMoveTargets[ ArrayFindMinF( moveTargetDists ) ];
  6018. }
  6019.  
  6020. if ( newMoveTarget && newMoveTarget != moveTarget )
  6021. {
  6022. if ( moveTarget )
  6023. {
  6024. playerToNewMoveTargetDist = VecDistance( newMoveTarget.GetNearestPointInPersonalSpace( GetWorldPosition() ), GetWorldPosition() );
  6025. playerToMoveTargetDist = VecDistance( moveTarget.GetNearestPointInPersonalSpace( GetWorldPosition() ), GetWorldPosition() );
  6026. wasVisibleInFullFrame = WasVisibleInScaledFrame( moveTarget, 1.f, 1.f ) ;
  6027.  
  6028. if ( !IsThreat( moveTarget )
  6029. || !wasVisibleInFullFrame
  6030. || !IsEnemyVisible( moveTarget )
  6031. || ( !moveTarget.IsAlive() && !finishableEnemiesList.Contains( moveTarget ) )
  6032. || !moveTarget.GetGameplayVisibility()
  6033. || ( moveTarget.IsAlive() && moveTarget.IsKnockedUnconscious() )
  6034. || ( wasVisibleInFullFrame && IsEnemyVisible( moveTarget ) && playerToNewMoveTargetDist < playerToMoveTargetDist - 0.25f ) )
  6035. {
  6036. SetMoveTarget( newMoveTarget );
  6037. }
  6038. }
  6039. else
  6040. SetMoveTarget( newMoveTarget );
  6041. }
  6042.  
  6043.  
  6044. if ( !IsThreatened() )
  6045. {
  6046. if ( moveTarget
  6047. && ( ( !moveTarget.IsAlive() && !finishableEnemiesList.Contains( moveTarget ) ) || !WasVisibleInScaledFrame( moveTarget, 0.8f, 1.f ) || VecDistance( moveTarget.GetWorldPosition(), this.GetWorldPosition() ) > theGame.params.MAX_THROW_RANGE ) )
  6048. {
  6049. confirmEmptyMoveTarget = true;
  6050. newEmptyMoveTargetTimer = 0.f;
  6051. }
  6052. }
  6053.  
  6054. else if ( moveTarget && ( IsThreat( moveTarget ) || finishableEnemiesList.Contains( moveTarget ) ) )
  6055. {
  6056. if ( !IsEnemyVisible( moveTarget ) )
  6057. {
  6058. confirmEmptyMoveTarget = true;
  6059. newEmptyMoveTargetTimer = 5.f;
  6060. }
  6061. else
  6062. SetMoveTarget( moveTarget );
  6063. }
  6064. else if ( IsInCombat() )
  6065. {
  6066. confirmEmptyMoveTarget = true;
  6067. newEmptyMoveTargetTimer = 1.0f;
  6068. }
  6069.  
  6070. if ( confirmEmptyMoveTarget )
  6071. {
  6072. if ( newEmptyMoveTargetTimer < emptyMoveTargetTimer )
  6073. {
  6074. bIsConfirmingEmptyTarget = false;
  6075. emptyMoveTargetTimer = newEmptyMoveTargetTimer;
  6076. }
  6077.  
  6078. ConfirmEmptyMoveTarget( newEmptyMoveTargetTimer );
  6079. }
  6080. }
  6081. else
  6082. SetIsThreatened( false );
  6083.  
  6084.  
  6085. if ( IsThreatened() && !IsInFistFightMiniGame() )
  6086. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'CombatNearbyAction', 5.0, 18.0f, -1.f, -1, true );
  6087. else
  6088. theGame.GetBehTreeReactionManager().RemoveReactionEvent( this, 'CombatNearbyAction');
  6089.  
  6090.  
  6091. theSound.SoundParameter( "monster_count", hostileMonsters.Size() );
  6092. }
  6093.  
  6094. private function ConfirmEmptyMoveTarget( timeDelta : float )
  6095. {
  6096. if ( !bIsConfirmingEmptyTarget )
  6097. {
  6098. bIsConfirmingEmptyTarget = true;
  6099. AddTimer( 'ConfirmEmptyTargetTimer', timeDelta );
  6100. }
  6101. }
  6102.  
  6103. private timer function ConfirmEmptyTargetTimer( time : float , id : int)
  6104. {
  6105. SetMoveTarget( NULL );
  6106. }
  6107.  
  6108.  
  6109. var isInCombatReason : int;
  6110. var canFindPathToEnemy : bool;
  6111. var combatModeEnt : CEntity;
  6112. var navDist : float;
  6113. var directDist : float;
  6114. var reachableEnemyWasTooFar : bool;
  6115. var reachableEnemyWasTooFarTimeStamp : float;
  6116. var reachablilityFailed : bool;
  6117. var reachablilityFailedTimeStamp : float;
  6118. public function ShouldEnableCombat( out unableToPathFind : bool, forceCombatMode : bool ) : bool
  6119. {
  6120. var shouldFindPathToNPCs : bool;
  6121. var playerToTargetDist : float;
  6122. var canFindPathToTarget : bool;
  6123. var moveTargetNPC : CNewNPC;
  6124. var currentTime : float;
  6125. var currentTime2 : float;
  6126. var isReachableEnemyTooFar : bool;
  6127. var reachableEnemyWasTooFarTimeStampDelta : float;
  6128. var reachablilityFailedTimeStampDelta : float;
  6129. var currentTimeTemp : float;
  6130.  
  6131.  
  6132.  
  6133. if ( forceCombatMode && isSnappedToNavMesh )
  6134. return true;
  6135.  
  6136. if ( !IsThreatened() )
  6137. {
  6138. reachableEnemyWasTooFar = false;
  6139. reachablilityFailed = false;
  6140. isInCombatReason = 0;
  6141. return false;
  6142. }
  6143.  
  6144. if( thePlayer.substateManager.GetStateCur() != 'CombatExploration' && !thePlayer.substateManager.CanChangeToState( 'CombatExploration' )
  6145. && thePlayer.substateManager.GetStateCur() != 'Ragdoll' )
  6146. {
  6147. reachableEnemyWasTooFar = false;
  6148. reachablilityFailed = false;
  6149. isInCombatReason = 0;
  6150. return false;
  6151. }
  6152.  
  6153. if ( moveTarget )
  6154. {
  6155. canFindPathToEnemy = CanFindPathToTarget( unableToPathFind );
  6156. currentTimeTemp = EngineTimeToFloat( theGame.GetEngineTime() );
  6157.  
  6158. if ( canFindPathToEnemy )
  6159. isReachableEnemyTooFar = IsReachableEnemyTooFar();
  6160.  
  6161. if ( IsInCombat() )
  6162. {
  6163. if ( canFindPathToEnemy )
  6164. {
  6165. if ( forceCombatMode )
  6166. return true;
  6167.  
  6168. reachablilityFailed = false;
  6169. reachablilityFailedTimeStamp = currentTimeTemp;
  6170.  
  6171. if ( reachableEnemyWasTooFar )
  6172. {
  6173. if ( isReachableEnemyTooFar )
  6174. {
  6175. currentTime = currentTimeTemp;
  6176.  
  6177. if ( GetIsSprinting() )
  6178. reachableEnemyWasTooFarTimeStampDelta = 0.f;
  6179. else
  6180. reachableEnemyWasTooFarTimeStampDelta = 3.f;
  6181.  
  6182. if ( currentTime > reachableEnemyWasTooFarTimeStamp + reachableEnemyWasTooFarTimeStampDelta )
  6183. {
  6184. isInCombatReason = 0;
  6185. unableToPathFind = true;
  6186. return false;
  6187. }
  6188. }
  6189. else
  6190. reachableEnemyWasTooFar = false;
  6191. }
  6192. else
  6193. {
  6194. if ( isReachableEnemyTooFar )
  6195. {
  6196. reachableEnemyWasTooFar = true;
  6197. reachableEnemyWasTooFarTimeStamp = currentTimeTemp;
  6198. }
  6199. else
  6200. reachableEnemyWasTooFar = false;
  6201. }
  6202.  
  6203. return true;
  6204. }
  6205. else
  6206. {
  6207. reachableEnemyWasTooFar = false;
  6208. reachableEnemyWasTooFarTimeStamp = currentTimeTemp;
  6209.  
  6210. if ( reachablilityFailed )
  6211. {
  6212. if ( IsEnemyTooHighToReach() )
  6213. reachablilityFailedTimeStampDelta = 1.f;
  6214. else
  6215. reachablilityFailedTimeStampDelta = 5.f;
  6216.  
  6217. currentTime2 = currentTimeTemp;
  6218. if ( currentTime2 > reachablilityFailedTimeStamp + reachablilityFailedTimeStampDelta )
  6219. {
  6220. unableToPathFind = true;
  6221. return false;
  6222. }
  6223. }
  6224. else
  6225. {
  6226. reachablilityFailed = true;
  6227. reachablilityFailedTimeStamp = currentTimeTemp;
  6228. }
  6229.  
  6230. return true;
  6231. }
  6232. }
  6233. else if ( canFindPathToEnemy )
  6234. {
  6235. if ( forceCombatMode )
  6236. {
  6237. reachableEnemyWasTooFar = false;
  6238. return true;
  6239. }
  6240.  
  6241. reachablilityFailed = false;
  6242. reachablilityFailedTimeStamp = currentTimeTemp;
  6243.  
  6244. moveTargetNPC = (CNewNPC)moveTarget;
  6245. playerToTargetDist = VecDistance( moveTarget.GetWorldPosition(), this.GetWorldPosition() );
  6246.  
  6247. if ( reachableEnemyWasTooFar
  6248. && ( isReachableEnemyTooFar || !theGame.GetWorld().NavigationLineTest( this.GetWorldPosition(), moveTarget.GetWorldPosition(), 0.4f ) ) )
  6249. {
  6250. isInCombatReason = 0;
  6251. return false;
  6252. }
  6253. else if ( playerToTargetDist <= findMoveTargetDistMin )
  6254. isInCombatReason = 1;
  6255. else if ( ( moveTargetNPC.GetCurrentStance() == NS_Fly || moveTargetNPC.IsRanged() ) && hostileEnemies.Contains( moveTarget ) )
  6256. isInCombatReason = 2;
  6257. else
  6258. {
  6259. isInCombatReason = 0;
  6260. return false;
  6261. }
  6262.  
  6263. reachableEnemyWasTooFar = false;
  6264. return true;
  6265. }
  6266. }
  6267. else
  6268. {
  6269. reachableEnemyWasTooFar = false;
  6270. reachablilityFailed = false;
  6271. }
  6272.  
  6273. isInCombatReason = 0;
  6274. return false;
  6275. }
  6276.  
  6277. private function CanFindPathToTarget( out unableToPathFind : bool, optional forcedTarget : CNewNPC ) : bool
  6278. {
  6279. var moveTargetNPC : CNewNPC;
  6280. var moveTargetsTemp : array<CActor>;
  6281. var i : int;
  6282. var safeSpotTolerance : float;
  6283. var ent : CEntity;
  6284.  
  6285. moveTargetsTemp = moveTargets;
  6286.  
  6287. for ( i = 0; i < moveTargetsTemp.Size(); i += 1 )
  6288. {
  6289. moveTargetNPC = (CNewNPC)moveTargetsTemp[i];
  6290.  
  6291. if ( moveTargetNPC && moveTargetNPC.GetCurrentStance() == NS_Fly )
  6292. {
  6293. isInCombatReason = 2;
  6294. return true;
  6295. }
  6296. }
  6297.  
  6298. switch ( navQuery.GetLastOutput( 0.4 ) )
  6299. {
  6300. case EAsyncTastResult_Failure:
  6301. {
  6302. isInCombatReason = 0;
  6303. return false;
  6304. }
  6305. case EAsyncTastResult_Success:
  6306. {
  6307. ent = navQuery.GetOutputClosestEntity();
  6308.  
  6309. if ( ent )
  6310. combatModeEnt = moveTarget;
  6311.  
  6312. navDist = navQuery.GetOutputClosestDistance();
  6313.  
  6314. isInCombatReason = 1;
  6315. return true;
  6316. }
  6317. case EAsyncTastResult_Pending:
  6318. {
  6319. return canFindPathToEnemy;
  6320. }
  6321. case EAsyncTastResult_Invalidated:
  6322. {
  6323. if ( IsInCombat() )
  6324. {
  6325. if ( IsEnemyTooHighToReach() )
  6326. safeSpotTolerance = 0.f;
  6327. else
  6328. safeSpotTolerance = 3.f;
  6329. }
  6330. else
  6331. safeSpotTolerance = 0.f;
  6332.  
  6333. switch( navQuery.TestActorsList( ENavigationReachability_Any, this, moveTargetsTemp, safeSpotTolerance, 75.0 ) )
  6334. {
  6335. case EAsyncTastResult_Failure:
  6336. {
  6337. isInCombatReason = 0;
  6338. return false;
  6339. }
  6340. case EAsyncTastResult_Success:
  6341. {
  6342. ent = navQuery.GetOutputClosestEntity();
  6343.  
  6344. if ( ent )
  6345. combatModeEnt = moveTarget;
  6346.  
  6347. navDist = navQuery.GetOutputClosestDistance();
  6348.  
  6349. isInCombatReason = 1;
  6350. return true;
  6351. }
  6352. case EAsyncTastResult_Pending:
  6353. {
  6354. return canFindPathToEnemy;
  6355. }
  6356. case EAsyncTastResult_Invalidated:
  6357. {
  6358. if ( IsInCombat() )
  6359. return true;
  6360. else
  6361. return false;
  6362. }
  6363. }
  6364. }
  6365. }
  6366. }
  6367.  
  6368. private function IsReachableEnemyTooFar() : bool
  6369. {
  6370.  
  6371. var navDistLimit : float = findMoveTargetDist;
  6372. var navDistDivisor : float = 2.f;
  6373. var playerToTargetVector : Vector;
  6374.  
  6375. directDist = VecDistance( combatModeEnt.GetWorldPosition(), thePlayer.GetWorldPosition() );
  6376. playerToTargetVector = this.GetWorldPosition() - combatModeEnt.GetWorldPosition();
  6377.  
  6378. if ( playerMode.GetForceCombatMode() || isInCombatReason == 2 )
  6379. return false;
  6380.  
  6381. if ( ( playerToTargetVector.Z < 0.5 && navDist > navDistLimit && directDist < navDist/navDistDivisor ) )
  6382. return true;
  6383. else
  6384. return false;
  6385. }
  6386.  
  6387. private function IsEnemyTooHighToReach() : bool
  6388. {
  6389. var playerToTargetVector : Vector;
  6390.  
  6391. playerToTargetVector = this.GetWorldPosition() - combatModeEnt.GetWorldPosition();
  6392.  
  6393. if ( playerToTargetVector.Z < -0.5f && !theGame.GetWorld().NavigationLineTest( this.GetWorldPosition(), combatModeEnt.GetWorldPosition(), 0.4f ) )
  6394. return true;
  6395. else
  6396. return false;
  6397. }
  6398.  
  6399.  
  6400. public function LockToMoveTarget( lockTime : float )
  6401. {
  6402.  
  6403. }
  6404.  
  6405. private timer function DisableLockToMoveTargetTimer( time : float , id : int)
  6406. {
  6407. if ( !this.IsActorLockedToTarget() )
  6408. {
  6409. SetMoveTargetChangeAllowed( true );
  6410. }
  6411. }
  6412.  
  6413. public function SetMoveTargetChangeAllowed( flag : bool )
  6414. {
  6415.  
  6416. }
  6417.  
  6418. public function IsMoveTargetChangeAllowed() : bool
  6419. {
  6420. return bMoveTargetChangeAllowed;
  6421. }
  6422.  
  6423. public function SetMoveTarget( actor : CActor )
  6424. {
  6425. if ( !actor && ForceCombatModeOverride() )
  6426. return;
  6427.  
  6428. if ( IsMoveTargetChangeAllowed()
  6429. && moveTarget != actor )
  6430. {
  6431. moveTarget = actor;
  6432. bIsConfirmingEmptyTarget = false;
  6433. RemoveTimer( 'ConfirmEmptyTargetTimer' );
  6434.  
  6435. if ( !moveTarget )
  6436. SetScriptMoveTarget( moveTarget );
  6437. }
  6438. }
  6439.  
  6440. private var isThreatened : bool;
  6441. protected function SetIsThreatened( flag : bool )
  6442. {
  6443. var allowSetIsThreatened : bool;
  6444.  
  6445. allowSetIsThreatened = true;
  6446. if ( ForceCombatModeOverride() )
  6447. {
  6448. if ( flag || !moveTarget )
  6449. allowSetIsThreatened = true;
  6450. else
  6451. allowSetIsThreatened = false;
  6452. }
  6453.  
  6454. if ( allowSetIsThreatened )
  6455. {
  6456. isThreatened = flag;
  6457. }
  6458. }
  6459.  
  6460. public function ForceCombatModeOverride() : bool
  6461. {
  6462. if( this.GetPlayerMode().GetForceCombatMode()
  6463. && canFindPathToEnemy
  6464. && theGame.GetGlobalAttitude( GetBaseAttitudeGroup(), moveTarget.GetBaseAttitudeGroup() ) == AIA_Hostile )
  6465. return true;
  6466. else
  6467. return false;
  6468. }
  6469.  
  6470. public function IsThreatened() : bool { return isThreatened; }
  6471.  
  6472. public function EnableFindTarget( flag : bool )
  6473. {
  6474. var target : CActor;
  6475.  
  6476. if( IsActorLockedToTarget() )
  6477. {
  6478. target = GetTarget();
  6479.  
  6480. if ( target && target.IsAlive() )
  6481. bCanFindTarget = flag;
  6482. else
  6483. bCanFindTarget = true;
  6484. }
  6485. else
  6486. bCanFindTarget = flag;
  6487. }
  6488.  
  6489. public function UpdateDisplayTarget( optional forceUpdate : bool, optional forceNullActor : bool )
  6490. {
  6491. var hud : CR4ScriptedHud;
  6492. var tempTarget : CGameplayEntity;
  6493. var angleDist1 : float;
  6494. var angleDist2 : float;
  6495. var nonActorTargetMult : float;
  6496. var combatActionType : int;
  6497. var currTarget : CActor;
  6498. var interactionTarget : CInteractionComponent;
  6499.  
  6500. var heading : float;
  6501.  
  6502. if(theGame.IsDialogOrCutscenePlaying())
  6503. {
  6504. currentSelectedDisplayTarget = NULL;
  6505.  
  6506. if ( displayTarget )
  6507. ConfirmDisplayTarget( NULL );
  6508.  
  6509. return;
  6510. }
  6511.  
  6512. if ( forceNullActor )
  6513. currTarget = NULL;
  6514. else
  6515. currTarget = GetTarget();
  6516.  
  6517. currentSelectedDisplayTarget = currTarget;
  6518.  
  6519. if ( currTarget && !currTarget.IsTargetableByPlayer() )
  6520. {
  6521. currentSelectedDisplayTarget = NULL;
  6522. ConfirmDisplayTarget( currentSelectedDisplayTarget );
  6523. return;
  6524. }
  6525.  
  6526. nonActorTargetMult = 1.25;
  6527.  
  6528.  
  6529. hud = (CR4ScriptedHud)theGame.GetHud();
  6530.  
  6531. if ( !IsThreatened() )
  6532. {
  6533. if ( !bLAxisReleased || lastAxisInputIsMovement )
  6534. {
  6535. if ( currTarget )
  6536. angleDist1 = AbsF( AngleDistance( this.GetHeading(), VecHeading( currTarget.GetWorldPosition() - this.GetWorldPosition() ) ) );
  6537. else
  6538. angleDist1 = 360;
  6539.  
  6540. if ( nonActorTarget )
  6541. angleDist2 = AbsF( AngleDistance( this.GetHeading(), VecHeading( nonActorTarget.GetWorldPosition() - this.GetWorldPosition() ) ) );
  6542. else
  6543. angleDist2 = 360;
  6544. }
  6545. else
  6546. {
  6547. if ( currTarget )
  6548. angleDist1 = AbsF( AngleDistance( theCamera.GetCameraHeading(), VecHeading( currTarget.GetWorldPosition() - theCamera.GetCameraPosition() ) ) );
  6549. else
  6550. angleDist1 = 360;
  6551.  
  6552. if ( nonActorTarget )
  6553. angleDist2 = AbsF( AngleDistance( theCamera.GetCameraHeading(), VecHeading( nonActorTarget.GetWorldPosition() - theCamera.GetCameraPosition() ) ) );
  6554. else
  6555. angleDist2 = 360;
  6556. }
  6557. }
  6558.  
  6559. else
  6560. {
  6561. if ( !bLAxisReleased )
  6562. {
  6563. if ( ShouldUsePCModeTargeting() )
  6564. {
  6565. if ( currTarget )
  6566. angleDist1 = AbsF( AngleDistance( theCamera.GetCameraHeading(), VecHeading( currTarget.GetWorldPosition() - theCamera.GetCameraPosition() ) ) );
  6567. else
  6568. angleDist1 = 360;
  6569.  
  6570. if ( nonActorTarget && IsInCombatAction() )
  6571. {
  6572. angleDist2 = nonActorTargetMult * AbsF( AngleDistance( theCamera.GetCameraHeading(), VecHeading( nonActorTarget.GetWorldPosition() - theCamera.GetCameraPosition() ) ) );
  6573. }
  6574. else
  6575. angleDist2 = 360;
  6576. }
  6577. else
  6578. {
  6579. if ( currTarget )
  6580. angleDist1 = AbsF( AngleDistance( rawPlayerHeading, VecHeading( currTarget.GetWorldPosition() - this.GetWorldPosition() ) ) );
  6581. else
  6582. angleDist1 = 360;
  6583.  
  6584. if ( nonActorTarget && IsInCombatAction() )
  6585. {
  6586. angleDist2 = nonActorTargetMult * AbsF( AngleDistance( rawPlayerHeading, VecHeading( nonActorTarget.GetWorldPosition() - this.GetWorldPosition() ) ) );
  6587. }
  6588. else
  6589. angleDist2 = 360;
  6590. }
  6591. }
  6592. else
  6593. {
  6594. angleDist1 = 0;
  6595. angleDist2 = 360;
  6596. }
  6597. }
  6598.  
  6599.  
  6600. if ( angleDist1 < angleDist2 )
  6601. tempTarget = currTarget;
  6602. else
  6603. tempTarget = nonActorTarget;
  6604.  
  6605.  
  6606. if ( slideTarget && IsInCombatAction() )
  6607. {
  6608. combatActionType = (int)this.GetBehaviorVariable( 'combatActionType' );
  6609. if ( combatActionType == (int)CAT_Attack
  6610. || ( combatActionType == (int)CAT_SpecialAttack && this.GetBehaviorVariable( 'playerAttackType' ) == 1.f )
  6611. || ( combatActionType == (int)CAT_ItemThrow )
  6612. || ( combatActionType == (int)CAT_CastSign && !IsCurrentSignChanneled() )
  6613. || ( combatActionType == (int)CAT_CastSign && IsCurrentSignChanneled() && GetCurrentlyCastSign() == ST_Axii )
  6614. || ( combatActionType == (int)CAT_CastSign && IsCurrentSignChanneled() && GetCurrentlyCastSign() == ST_Igni )
  6615. || combatActionType == (int)CAT_Dodge
  6616. || combatActionType == (int)CAT_Roll )
  6617. {
  6618. if ( combatActionType == (int)CAT_CastSign && GetCurrentlyCastSign() == ST_Igni && !IsCombatMusicEnabled() )
  6619. currentSelectedDisplayTarget = tempTarget;
  6620. else
  6621. currentSelectedDisplayTarget = slideTarget;
  6622. }
  6623. else
  6624. currentSelectedDisplayTarget = tempTarget;
  6625. }
  6626. else if ( slideTarget
  6627. && this.rangedWeapon
  6628. && this.rangedWeapon.GetCurrentStateName() != 'State_WeaponWait'
  6629. && this.playerAiming.GetCurrentStateName() == 'Waiting' )
  6630. currentSelectedDisplayTarget = slideTarget;
  6631. else
  6632. currentSelectedDisplayTarget = tempTarget;
  6633.  
  6634. interactionTarget = theGame.GetInteractionsManager().GetActiveInteraction();
  6635. if ( interactionTarget && !IsThreatened() && !( this.IsCastingSign() && this.IsCurrentSignChanneled() ) )
  6636. {
  6637. tempTarget = (CGameplayEntity)interactionTarget.GetEntity();
  6638. if ( tempTarget && tempTarget != this.GetUsedVehicle() )
  6639. {
  6640. currentSelectedDisplayTarget = tempTarget;
  6641. SetDisplayTarget( currentSelectedDisplayTarget );
  6642. }
  6643. }
  6644.  
  6645.  
  6646. if ( (CActor)currentSelectedDisplayTarget && !((CActor)currentSelectedDisplayTarget).GetGameplayVisibility() )
  6647. {
  6648. currentSelectedDisplayTarget = NULL;
  6649. }
  6650.  
  6651. if ( displayTarget != currentSelectedDisplayTarget )
  6652. {
  6653. if ( forceUpdate )
  6654. SetDisplayTarget( currentSelectedDisplayTarget );
  6655. else
  6656. ConfirmDisplayTarget( currentSelectedDisplayTarget );
  6657. }
  6658. }
  6659.  
  6660. private var bConfirmDisplayTargetTimerEnabled : bool;
  6661. private var displayTargetToConfirm : CGameplayEntity;
  6662. private var currentSelectedDisplayTarget : CGameplayEntity;
  6663.  
  6664. private function ConfirmDisplayTarget( targetToConfirm : CGameplayEntity )
  6665. {
  6666. if ( targetToConfirm != displayTarget )
  6667. {
  6668. displayTargetToConfirm = targetToConfirm;
  6669. if( !bConfirmDisplayTargetTimerEnabled )
  6670. {
  6671. bConfirmDisplayTargetTimerEnabled = true;
  6672.  
  6673. if ( targetToConfirm )
  6674. AddTimer( 'ConfirmDisplayTargetTimer', 0.1f );
  6675. else
  6676. AddTimer( 'ConfirmDisplayTargetTimer', 0.f );
  6677. }
  6678. }
  6679. }
  6680.  
  6681. private timer function ConfirmDisplayTargetTimer( time : float, optional id : int)
  6682. {
  6683. if ( displayTargetToConfirm == currentSelectedDisplayTarget )
  6684. SetDisplayTarget( displayTargetToConfirm );
  6685.  
  6686. bConfirmDisplayTargetTimerEnabled = false;
  6687. }
  6688.  
  6689.  
  6690. protected function SetDisplayTarget( e : CGameplayEntity )
  6691. {
  6692. var displayTargetActor : CActor;
  6693.  
  6694. if ( e != displayTarget )
  6695. {
  6696. displayTarget = e;
  6697. displayTargetActor = (CActor)displayTarget;
  6698. SetPlayerCombatTarget( displayTargetActor );
  6699.  
  6700. if ( displayTargetActor && !displayTargetActor.IsTargetableByPlayer())
  6701. {
  6702. isDisplayTargetTargetable = false;
  6703. }
  6704. else if ( !displayTargetActor && displayTarget != nonActorTarget )
  6705. {
  6706. isDisplayTargetTargetable = false;
  6707. }
  6708. else
  6709. {
  6710. isDisplayTargetTargetable = true;
  6711. }
  6712. }
  6713. }
  6714.  
  6715. public function GetDisplayTarget() : CGameplayEntity { return displayTarget; }
  6716.  
  6717. private var isDisplayTargetTargetable : bool;
  6718. public function IsDisplayTargetTargetable() : bool
  6719. {
  6720. return isDisplayTargetTargetable;
  6721. }
  6722.  
  6723. public var radialSlots : array<name>;
  6724. public function EnableRadialSlots( enable : bool, slotNames : array<name> )
  6725. {
  6726. var hud : CR4ScriptedHud;
  6727. var module : CR4HudModuleRadialMenu;
  6728. var i : int;
  6729.  
  6730. hud = (CR4ScriptedHud)theGame.GetHud();
  6731. module = (CR4HudModuleRadialMenu)hud.GetHudModule("RadialMenuModule");
  6732.  
  6733. for(i=0; i<slotNames.Size(); i+=1)
  6734. {
  6735. module.SetDesaturated( !enable, slotNames[i] );
  6736. }
  6737. }
  6738.  
  6739. public function IsEnemyInCone( source : CActor, coneHeading : Vector, coneDist, coneAngle : float, out newLockTarget : CActor ) : bool
  6740. {
  6741. var targets : array<CActor>;
  6742. var sourceToTargetDists : array<float>;
  6743. var i : int;
  6744. var targetingInfo : STargetingInfo;
  6745.  
  6746.  
  6747.  
  6748. targets = GetMoveTargets();
  6749.  
  6750. if ( targets.Size() > 0 )
  6751. {
  6752. targetingInfo.source = this;
  6753. targetingInfo.canBeTargetedCheck = true;
  6754. targetingInfo.coneCheck = true;
  6755. targetingInfo.coneHalfAngleCos = CosF( Deg2Rad( coneAngle * 0.5f ) );
  6756. targetingInfo.coneDist = coneDist;
  6757. targetingInfo.coneHeadingVector = coneHeading;
  6758. targetingInfo.distCheck = true;
  6759. targetingInfo.invisibleCheck = true;
  6760. targetingInfo.navMeshCheck = true;
  6761. targetingInfo.inFrameCheck = false;
  6762. targetingInfo.frameScaleX = 1.f;
  6763. targetingInfo.frameScaleY = 1.f;
  6764. targetingInfo.knockDownCheck = false;
  6765. targetingInfo.knockDownCheckDist = 1.5f;
  6766. targetingInfo.rsHeadingCheck = false;
  6767. targetingInfo.rsHeadingLimitCos = 1.0f;
  6768.  
  6769. for( i = targets.Size() - 1; i >= 0; i -= 1 )
  6770. {
  6771. targetingInfo.targetEntity = targets[i];
  6772. if ( !IsEntityTargetable( targetingInfo ) )
  6773. targets.Erase( i );
  6774. }
  6775.  
  6776. for ( i = 0; i < targets.Size(); i += 1 )
  6777. sourceToTargetDists.PushBack( VecDistance( source.GetWorldPosition(), targets[i].GetWorldPosition() ) );
  6778.  
  6779. if(sourceToTargetDists.Size() > 0)
  6780. newLockTarget = targets[ ArrayFindMinF( sourceToTargetDists ) ];
  6781. else
  6782. newLockTarget = NULL;
  6783. }
  6784.  
  6785. return targets.Size() > 0;
  6786. }
  6787.  
  6788. public function GetScreenSpaceLockTarget( sourceEnt : CGameplayEntity, coneAngle, coneDist, coneHeading : float, optional inFrameCheck : bool ) : CActor
  6789. {
  6790. var source : CActor;
  6791. var sourcePos, targetPos : Vector;
  6792. var targets : array<CActor>;
  6793. var sourceToTargetDists : array<float>;
  6794. var sourceCoord : Vector;
  6795. var targetCoord : Vector;
  6796. var i : int;
  6797. var angleDiff : float;
  6798. var sourceToTargetHeading : float;
  6799. var sourceToTargetDist : float;
  6800. var size : float;
  6801. var targetingDist : float;
  6802. var targetingInfo : STargetingInfo;
  6803.  
  6804. var temp : int;
  6805.  
  6806.  
  6807.  
  6808.  
  6809. source = (CActor)sourceEnt;
  6810.  
  6811. targets = GetMoveTargets();
  6812.  
  6813. if ( this.IsPCModeEnabled() )
  6814. {
  6815. if ( ( coneHeading > -45.f && coneHeading < 45.f )
  6816. || coneHeading > 135.f
  6817. || coneHeading < -135.f )
  6818. {
  6819. if ( coneHeading > 0 )
  6820. coneHeading = 180 - coneHeading;
  6821. else
  6822. coneHeading = 180 + coneHeading;
  6823. }
  6824. }
  6825.  
  6826.  
  6827.  
  6828. for( i = targets.Size() - 1; i >= 0; i -= 1 )
  6829. {
  6830. if ( ( !targets[i].GetGameplayVisibility() || !IsThreat( targets[i] ) || !IsEnemyVisible( targets[i] ) || !this.CanBeTargetedIfSwimming( targets[i] ) )
  6831. && ( !IsCastingSign() || GetCurrentlyCastSign() != ST_Axii ) )
  6832. targets.Erase(i);
  6833. }
  6834.  
  6835. if ( source )
  6836. {
  6837. temp = source.GetTorsoBoneIndex();
  6838.  
  6839. if ( temp < 0 )
  6840. sourcePos = source.GetWorldPosition();
  6841. else
  6842. sourcePos = MatrixGetTranslation( source.GetBoneWorldMatrixByIndex( source.GetTorsoBoneIndex() ) );
  6843. }
  6844. else
  6845. sourcePos = sourceEnt.GetWorldPosition();
  6846.  
  6847. theCamera.WorldVectorToViewRatio( sourcePos, sourceCoord.X , sourceCoord.Y );
  6848.  
  6849.  
  6850. targetingDist = softLockDistVehicle;
  6851.  
  6852. if ( targets.Size() > 0 )
  6853. {
  6854. targetingInfo.source = this;
  6855. targetingInfo.canBeTargetedCheck = true;
  6856. targetingInfo.coneCheck = false;
  6857. targetingInfo.coneHalfAngleCos = 0.86602540378f;
  6858. targetingInfo.coneDist = targetingDist;
  6859. targetingInfo.coneHeadingVector = Vector( 0.0f, 1.0f, 0.0f );
  6860. targetingInfo.distCheck = true;
  6861. targetingInfo.invisibleCheck = true;
  6862. targetingInfo.navMeshCheck = false;
  6863.  
  6864. if ( inFrameCheck )
  6865. targetingInfo.inFrameCheck = true;
  6866. else
  6867. targetingInfo.inFrameCheck = false;
  6868.  
  6869. targetingInfo.frameScaleX = 1.f;
  6870. targetingInfo.frameScaleY = 1.f;
  6871. targetingInfo.knockDownCheck = false;
  6872. targetingInfo.knockDownCheckDist = softLockDist;
  6873. if ( bRAxisReleased )
  6874. targetingInfo.rsHeadingCheck = false;
  6875. else
  6876. targetingInfo.rsHeadingCheck = true;
  6877. targetingInfo.rsHeadingLimitCos = -0.5f;
  6878.  
  6879. for( i = targets.Size() - 1; i >= 0; i -= 1 )
  6880. {
  6881. temp = targets[i].GetTorsoBoneIndex();
  6882.  
  6883. if ( temp < 0 )
  6884. targetPos = targets[i].GetWorldPosition();
  6885. else
  6886. targetPos = MatrixGetTranslation( targets[i].GetBoneWorldMatrixByIndex( targets[i].GetTorsoBoneIndex() ) );
  6887.  
  6888. theCamera.WorldVectorToViewRatio( targetPos, targetCoord.X, targetCoord.Y );
  6889. sourceToTargetHeading = VecHeading( targetCoord - sourceCoord );
  6890. angleDiff = AbsF( AngleDistance( coneHeading, sourceToTargetHeading ) );
  6891.  
  6892. targetingInfo.targetEntity = targets[i];
  6893. if ( !IsEntityTargetable( targetingInfo ) )
  6894. targets.Erase( i );
  6895. else if ( !bRAxisReleased && angleDiff > ( coneAngle * 0.5 ) )
  6896. targets.Erase( i );
  6897. else if ( targets[i] == sourceEnt )
  6898. targets.Erase( i );
  6899.  
  6900.  
  6901. }
  6902. }
  6903.  
  6904. size = targets.Size();
  6905. if ( size > 0 )
  6906. {
  6907. for ( i = 0; i < targets.Size(); i += 1 )
  6908. {
  6909. temp = targets[i].GetTorsoBoneIndex();
  6910.  
  6911. if ( temp < 0 )
  6912. targetPos = targets[i].GetWorldPosition();
  6913. else
  6914. targetPos = MatrixGetTranslation( targets[i].GetBoneWorldMatrixByIndex( targets[i].GetTorsoBoneIndex() ) );
  6915.  
  6916. theCamera.WorldVectorToViewRatio( targetPos, targetCoord.X, targetCoord.Y );
  6917. sourceToTargetHeading = AbsF( VecHeading( targetCoord - sourceCoord ) );
  6918. angleDiff = AngleDistance( 180, sourceToTargetHeading );
  6919. sourceToTargetDist = VecDistance2D( sourceCoord, targetCoord );
  6920.  
  6921. sourceToTargetDists.PushBack( SinF( Deg2Rad( angleDiff ) ) * sourceToTargetDist );
  6922. }
  6923. }
  6924.  
  6925. if ( targets.Size() > 0 )
  6926. return targets[ ArrayFindMinF( sourceToTargetDists ) ];
  6927. else
  6928. return NULL;
  6929. }
  6930.  
  6931. public function IsEntityTargetable( out info : STargetingInfo, optional usePrecalcs : bool ) : bool
  6932. {
  6933. var playerHasBlockingBuffs : bool;
  6934. var sourceActor : CActor;
  6935. var targetEntity : CEntity;
  6936. var targetActor : CActor;
  6937. var targetNPC : CNewNPC;
  6938. var sourcePosition : Vector;
  6939. var targetPosition : Vector;
  6940. var direction : Vector;
  6941. var sourceToTargetDist : float;
  6942. var sourceCapsuleRadius : float;
  6943. var mpac : CMovingPhysicalAgentComponent;
  6944.  
  6945. var coneDistSq : float;
  6946. var knockDownCheckDistSq : float;
  6947. var sourceToTargetAngleDist : float;
  6948. var b : bool;
  6949. var infoSourceWorldPos : Vector;
  6950. var infoTargetWorldPos : Vector;
  6951. var finishEnabled : bool;
  6952.  
  6953. if ( usePrecalcs )
  6954. {
  6955. playerHasBlockingBuffs = targetingIn.playerHasBlockingBuffs;
  6956. }
  6957. else
  6958. {
  6959. playerHasBlockingBuffs = thePlayer.HasBuff( EET_Confusion ) || thePlayer.HasBuff( EET_Hypnotized ) || thePlayer.HasBuff( EET_Blindness ) || thePlayer.HasBuff( EET_WraithBlindness );
  6960. }
  6961. if ( playerHasBlockingBuffs )
  6962. {
  6963. return false;
  6964. }
  6965.  
  6966. sourceActor = info.source;
  6967. targetEntity = info.targetEntity;
  6968. if ( !sourceActor || !targetEntity )
  6969. {
  6970. return false;
  6971. }
  6972.  
  6973. targetActor = (CActor)targetEntity;
  6974.  
  6975.  
  6976. if ( info.canBeTargetedCheck && !targetActor.CanBeTargeted() )
  6977. {
  6978. return false;
  6979. }
  6980.  
  6981.  
  6982. if ( info.invisibleCheck && !targetActor.GetGameplayVisibility() )
  6983. {
  6984. return false;
  6985. }
  6986.  
  6987. sourcePosition = sourceActor.GetWorldPosition();
  6988. targetPosition = targetEntity.GetWorldPosition();
  6989.  
  6990. if ( targetActor )
  6991. {
  6992. {
  6993. targetNPC = (CNewNPC)targetActor;
  6994. if ( targetNPC )
  6995. {
  6996. if ( targetNPC.IsHorse() && !targetNPC.GetHorseComponent().IsDismounted() )
  6997. {
  6998. return false;
  6999. }
  7000. }
  7001. }
  7002. }
  7003.  
  7004. if ( info.distCheck || info.knockDownCheck )
  7005. {
  7006. if ( usePrecalcs )
  7007. {
  7008. if ( targetActor )
  7009. {
  7010.  
  7011. sourceToTargetDist = Distance2DBetweenCapsuleAndPoint( targetActor, sourceActor ) - targetingPrecalcs.playerRadius;
  7012. }
  7013. else
  7014. {
  7015. sourceToTargetDist = VecDistance2D( sourcePosition, targetPosition ) - targetingPrecalcs.playerRadius;
  7016. }
  7017. }
  7018. else
  7019. {
  7020. if ( targetActor )
  7021. {
  7022. sourceToTargetDist = Distance2DBetweenCapsules( sourceActor, targetActor );
  7023. }
  7024. else
  7025. {
  7026. sourceToTargetDist = Distance2DBetweenCapsuleAndPoint( sourceActor, targetEntity );
  7027. }
  7028. }
  7029. }
  7030.  
  7031.  
  7032. if ( info.distCheck )
  7033. {
  7034. if ( sourceToTargetDist >= info.coneDist )
  7035. {
  7036. return false;
  7037. }
  7038. }
  7039.  
  7040.  
  7041. if ( info.coneCheck || info.rsHeadingCheck )
  7042. {
  7043. direction = VecNormalize2D( targetPosition - sourcePosition );
  7044. }
  7045.  
  7046.  
  7047. if ( info.coneCheck )
  7048. {
  7049. if ( VecDot2D( direction, info.coneHeadingVector ) < info.coneHalfAngleCos )
  7050. {
  7051. return false;
  7052. }
  7053. }
  7054.  
  7055.  
  7056. if ( info.rsHeadingCheck )
  7057. {
  7058. if ( usePrecalcs )
  7059. {
  7060. if ( VecDot2D( direction, targetingIn.lookAtDirection ) < info.rsHeadingLimitCos )
  7061. {
  7062. return false;
  7063. }
  7064. }
  7065. else
  7066. {
  7067. if ( VecDot2D( direction, VecNormalize2D( GetLookAtPosition() - sourcePosition ) ) < info.rsHeadingLimitCos )
  7068. {
  7069. return false;
  7070. }
  7071. }
  7072. }
  7073.  
  7074.  
  7075. if ( info.inFrameCheck && !WasVisibleInScaledFrame( targetEntity, info.frameScaleX, info.frameScaleY ) )
  7076. {
  7077. return false;
  7078. }
  7079.  
  7080.  
  7081. if ( info.navMeshCheck && !IsSwimming() )
  7082. {
  7083. sourceCapsuleRadius = 0.1f;
  7084. if ( usePrecalcs )
  7085. {
  7086. sourceCapsuleRadius = targetingPrecalcs.playerRadius;
  7087. }
  7088. else
  7089. {
  7090. mpac = (CMovingPhysicalAgentComponent)sourceActor.GetMovingAgentComponent();
  7091. if ( mpac )
  7092. {
  7093. sourceCapsuleRadius = mpac.GetCapsuleRadius();
  7094. }
  7095. }
  7096. if ( !theGame.GetWorld().NavigationLineTest( sourcePosition, targetPosition, sourceCapsuleRadius ) )
  7097. {
  7098. return false;
  7099. }
  7100. }
  7101.  
  7102.  
  7103. if ( info.knockDownCheck )
  7104. {
  7105.  
  7106. if ( targetActor && !targetActor.IsAlive() )
  7107. {
  7108.  
  7109. finishEnabled = targetActor.GetComponent( 'Finish' ).IsEnabled();
  7110. if ( finishEnabled )
  7111. {
  7112.  
  7113. if ( finishableEnemiesList.Contains( targetActor ) )
  7114. {
  7115.  
  7116. if ( sourceToTargetDist >= info.knockDownCheckDist )
  7117. {
  7118. return false;
  7119. }
  7120. }
  7121. }
  7122. }
  7123. }
  7124.  
  7125. return true;
  7126. }
  7127.  
  7128. public function CanBeTargetedIfSwimming( actor : CActor, optional usePrecalcs : bool ) : bool
  7129. {
  7130. var subDepth : float;
  7131. var isDiving : bool;
  7132.  
  7133. if ( !actor )
  7134. {
  7135. return false;
  7136. }
  7137.  
  7138. if ( usePrecalcs )
  7139. {
  7140. isDiving = targetingIn.isDiving;
  7141. }
  7142. else
  7143. {
  7144. isDiving = IsSwimming() && OnCheckDiving();
  7145. }
  7146.  
  7147. subDepth = ((CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent()).GetSubmergeDepth();
  7148.  
  7149. if ( isDiving )
  7150. {
  7151. return ( subDepth < -1.0f );
  7152. }
  7153. else
  7154. {
  7155. return ( subDepth >= -1.0f );
  7156. }
  7157. }
  7158.  
  7159.  
  7160. private function FilterActors( out targets : array<CActor>, out onlyThreatsReturned : bool, optional usePrecalcs : bool )
  7161. {
  7162. var i : int;
  7163. var size : int;
  7164. var foundThreat : bool;
  7165. var foundNonThreat : bool;
  7166. var threatsCount : int;
  7167. var tmpActor : CActor;
  7168.  
  7169. foundThreat = false;
  7170. foundNonThreat = false;
  7171.  
  7172. size = targets.Size();
  7173. i = 0;
  7174. threatsCount = 0;
  7175.  
  7176.  
  7177. for ( i = 0; i < size; i+=1 )
  7178. {
  7179. if( IsThreat( targets[ i ], usePrecalcs ) )
  7180. {
  7181. foundThreat = true;
  7182. if ( i != threatsCount )
  7183. {
  7184. tmpActor = targets[ i ];
  7185. targets[ i ] = targets[ threatsCount ];
  7186. targets[ threatsCount ] = tmpActor;
  7187. }
  7188. threatsCount += 1;
  7189. }
  7190. else
  7191. {
  7192. foundNonThreat = true;
  7193. }
  7194. }
  7195.  
  7196. if ( foundThreat )
  7197. {
  7198. onlyThreatsReturned = true;
  7199. if ( foundNonThreat )
  7200. {
  7201. targets.Resize( threatsCount );
  7202. }
  7203. }
  7204. }
  7205.  
  7206. private function InternalFindTargetsInCone( out targets : array< CActor >, out outHeadingVector : Vector, optional usePrecalcs : bool )
  7207. {
  7208. var size, i : int;
  7209. var coneHalfAngleDot : float;
  7210. var coneHeading : float;
  7211. var coneHeadingVector : Vector;
  7212. var position : Vector;
  7213. var direction : Vector;
  7214. var onlyThreatTargetsFound : bool;
  7215.  
  7216. targets.Clear();
  7217. GetVisibleEnemies( targets );
  7218.  
  7219.  
  7220. for( i = 0; i < finishableEnemiesList.Size() ; i+=1 )
  7221. {
  7222. if ( !targets.Contains( finishableEnemiesList[i] ) )
  7223. {
  7224. targets.PushBack( finishableEnemiesList[i] );
  7225. }
  7226. }
  7227.  
  7228. onlyThreatTargetsFound = false;
  7229. FilterActors( targets, onlyThreatTargetsFound, true );
  7230.  
  7231. if ( IsCombatMusicEnabled() && targets.Size() > 0 && !onlyThreatTargetsFound && !IsThreat( targets[0], usePrecalcs ) )
  7232. {
  7233. targets.Clear();
  7234. }
  7235.  
  7236. coneHeading = 0.0f;
  7237. coneHalfAngleDot = 0.0f;
  7238. if ( ( orientationTarget == OT_Camera ) || ( orientationTarget == OT_CameraOffset ) )
  7239. {
  7240. if ( usePrecalcs )
  7241. {
  7242. coneHeading = targetingPrecalcs.cameraHeading;
  7243. }
  7244. else
  7245. {
  7246. coneHeading = theGame.GetGameCamera().GetHeading();
  7247. }
  7248. coneHalfAngleDot = 0.5f;
  7249. }
  7250. else
  7251. {
  7252. if ( IsSwimming() )
  7253. {
  7254. if ( usePrecalcs )
  7255. {
  7256. coneHeading = targetingPrecalcs.cameraHeading;
  7257. }
  7258. else
  7259. {
  7260. coneHeading = theGame.GetGameCamera().GetHeading();
  7261. }
  7262. coneHalfAngleDot = 0.17364817766f;
  7263. }
  7264. else if ( bLAxisReleased )
  7265. {
  7266. if( IsInCombatAction() )
  7267. {
  7268. coneHeading = GetCombatActionHeading();
  7269. }
  7270. else
  7271. {
  7272. if ( ShouldUsePCModeTargeting() )
  7273. coneHeading = theGame.GetGameCamera().GetHeading();
  7274. else
  7275. coneHeading = cachedRawPlayerHeading;
  7276. }
  7277.  
  7278. if ( IsInCombat() )
  7279. {
  7280. if ( ShouldUsePCModeTargeting() )
  7281. coneHalfAngleDot = -1;
  7282. else
  7283. coneHalfAngleDot = 0.17364817766f;
  7284. }
  7285. else
  7286. {
  7287. coneHalfAngleDot = -1.0f;
  7288. }
  7289. }
  7290. else
  7291. {
  7292. if( IsInCombatAction() )
  7293. {
  7294. coneHeading = GetCombatActionHeading();
  7295. }
  7296. else
  7297. {
  7298. if ( ShouldUsePCModeTargeting() )
  7299. coneHeading = theGame.GetGameCamera().GetHeading();
  7300. else
  7301. coneHeading = cachedRawPlayerHeading;
  7302. }
  7303.  
  7304. if ( ShouldUsePCModeTargeting() )
  7305. coneHalfAngleDot = -1;
  7306. else
  7307. coneHalfAngleDot = 0.17364817766f;
  7308. }
  7309.  
  7310. coneHeadingVector = VecFromHeading( coneHeading );
  7311. position = this.GetWorldPosition();
  7312.  
  7313. for ( i = targets.Size() - 1; i >= 0; i -= 1 )
  7314. {
  7315. if ( !targets[i] )
  7316. {
  7317. targets.EraseFast(i);
  7318. continue;
  7319. }
  7320.  
  7321. direction = VecNormalize2D( targets[i].GetWorldPosition() - position );
  7322.  
  7323. if ( VecDot2D( coneHeadingVector, direction ) < coneHalfAngleDot )
  7324. {
  7325. targets.EraseFast( i );
  7326. }
  7327. }
  7328. }
  7329.  
  7330. outHeadingVector = coneHeadingVector;
  7331. }
  7332.  
  7333.  
  7334.  
  7335.  
  7336. function InitTargeting()
  7337. {
  7338. var consts : SR4PlayerTargetingConsts;
  7339.  
  7340. if ( !targeting )
  7341. {
  7342. targeting = new CR4PlayerTargeting in this;
  7343. }
  7344. if ( targeting )
  7345. {
  7346. consts.softLockDistance = this.softLockDist;
  7347. consts.softLockFrameSize = this.softLockFrameSize;
  7348. targeting.SetConsts( consts );
  7349. }
  7350. }
  7351.  
  7352. function PrepareTargetingIn( actionCheck : bool, bufferActionType : EBufferActionType, actionInput : bool )
  7353. {
  7354. var coneDist : float;
  7355.  
  7356. if ( actionCheck && bufferActionType == EBAT_ItemUse )
  7357. {
  7358. coneDist = findMoveTargetDist;
  7359. }
  7360. else if ( IsSwimming() )
  7361. {
  7362. coneDist = theGame.params.MAX_THROW_RANGE;
  7363. }
  7364. else if ( ( GetPlayerCombatStance() == PCS_AlertNear ) && ( ( playerMoveType == PMT_Walk ) || ( playerMoveType == PMT_Idle ) ) )
  7365. {
  7366. coneDist = softLockDist;
  7367. }
  7368. else
  7369. {
  7370. coneDist = findMoveTargetDist;
  7371. }
  7372.  
  7373. targetingIn.canFindTarget = this.bCanFindTarget;
  7374. targetingIn.playerHasBlockingBuffs = thePlayer.HasBuff( EET_Confusion ) || thePlayer.HasBuff( EET_Hypnotized ) || thePlayer.HasBuff( EET_Blindness ) || thePlayer.HasBuff( EET_WraithBlindness );
  7375. targetingIn.isHardLockedToTarget = this.IsHardLockEnabled();
  7376. targetingIn.isActorLockedToTarget = this.IsActorLockedToTarget();
  7377. targetingIn.isCameraLockedToTarget = this.IsCameraLockedToTarget();
  7378. targetingIn.actionCheck = actionCheck;
  7379. targetingIn.actionInput = actionInput;
  7380. targetingIn.isInCombatAction = this.IsInCombatAction();
  7381. targetingIn.isLAxisReleased = this.bLAxisReleased;
  7382. targetingIn.isLAxisReleasedAfterCounter = this.lAxisReleasedAfterCounter;
  7383. targetingIn.isLAxisReleasedAfterCounterNoCA = this.lAxisReleasedAfterCounterNoCA;
  7384. targetingIn.lastAxisInputIsMovement = this.lastAxisInputIsMovement;
  7385. targetingIn.isAiming = this.playerAiming.GetCurrentStateName() == 'Aiming';
  7386. targetingIn.isSwimming = this.IsSwimming();
  7387. targetingIn.isDiving = this.IsSwimming() && OnCheckDiving();
  7388. targetingIn.isThreatened = this.IsThreatened();
  7389. targetingIn.isCombatMusicEnabled = this.IsCombatMusicEnabled();
  7390. targetingIn.isPcModeEnabled = this.IsPCModeEnabled();
  7391. targetingIn.isInParryOrCounter = this.isInParryOrCounter;
  7392. targetingIn.shouldUsePcModeTargeting = this.ShouldUsePCModeTargeting();
  7393. targetingIn.bufferActionType = bufferActionType;
  7394. targetingIn.orientationTarget = this.GetOrientationTarget();
  7395. targetingIn.coneDist = coneDist;
  7396. targetingIn.findMoveTargetDist = this.findMoveTargetDist;
  7397. targetingIn.cachedRawPlayerHeading = this.cachedRawPlayerHeading;
  7398. targetingIn.combatActionHeading = this.GetCombatActionHeading();
  7399. targetingIn.rawPlayerHeadingVector = VecFromHeading( this.rawPlayerHeading );
  7400. targetingIn.lookAtDirection = VecNormalize2D( this.GetLookAtPosition() - GetWorldPosition() );
  7401. targetingIn.moveTarget = this.moveTarget;
  7402. targetingIn.aimingTarget = this.playerAiming.GetAimedTarget();
  7403. targetingIn.displayTarget = (CActor)this.displayTarget;
  7404. targetingIn.finishableEnemies = this.finishableEnemiesList;
  7405. targetingIn.hostileEnemies = this.hostileEnemies;
  7406. targetingIn.defaultSelectionWeights = ProcessSelectionWeights();
  7407. }
  7408.  
  7409. function ResetTargetingOut()
  7410. {
  7411. targetingOut.target = NULL;
  7412. targetingOut.result = false;
  7413. targetingOut.confirmNewTarget = false;
  7414. targetingOut.forceDisableUpdatePosition = false;
  7415. }
  7416.  
  7417. function MakeFindTargetPrecalcs()
  7418. {
  7419. var mpac : CMovingPhysicalAgentComponent;
  7420.  
  7421. targetingPrecalcs.playerPosition = thePlayer.GetWorldPosition();
  7422. targetingPrecalcs.playerHeading = thePlayer.GetHeading();
  7423. targetingPrecalcs.playerHeadingVector = thePlayer.GetHeadingVector();
  7424. targetingPrecalcs.playerHeadingVector.Z = 0;
  7425. targetingPrecalcs.playerHeadingVector = VecNormalize2D( targetingPrecalcs.playerHeadingVector );
  7426.  
  7427. targetingPrecalcs.playerRadius = 0.5f;
  7428. mpac = (CMovingPhysicalAgentComponent)thePlayer.GetMovingAgentComponent();
  7429. if ( mpac )
  7430. {
  7431. targetingPrecalcs.playerRadius = mpac.GetCapsuleRadius();
  7432. }
  7433.  
  7434. targetingPrecalcs.cameraPosition = theCamera.GetCameraPosition();
  7435. targetingPrecalcs.cameraDirection = theCamera.GetCameraDirection();
  7436. targetingPrecalcs.cameraHeadingVector = targetingPrecalcs.cameraDirection;
  7437. targetingPrecalcs.cameraHeadingVector.Z = 0;
  7438. targetingPrecalcs.cameraHeadingVector = VecNormalize2D( targetingPrecalcs.cameraHeadingVector );
  7439. targetingPrecalcs.cameraHeading = VecHeading( targetingPrecalcs.cameraHeadingVector );
  7440. }
  7441.  
  7442. public function GetForceDisableUpdatePosition() : bool
  7443. {
  7444. return targetingOut.forceDisableUpdatePosition;
  7445. }
  7446.  
  7447. public function SetUseNativeTargeting( use : bool )
  7448. {
  7449. useNativeTargeting = use;
  7450. }
  7451.  
  7452. protected function FindTarget( optional actionCheck : bool, optional action : EBufferActionType, optional actionInput : bool ) : CActor
  7453. {
  7454. if ( IsCombatMusicEnabled() && !IsInCombat() && reachableEnemyWasTooFar )
  7455. {
  7456. playerMode.UpdateCombatMode();
  7457. }
  7458.  
  7459. PrepareTargetingIn( actionCheck, action, actionInput );
  7460. if ( useNativeTargeting )
  7461. {
  7462. targeting.BeginFindTarget( targetingIn );
  7463. targeting.FindTarget();
  7464. targeting.EndFindTarget( targetingOut );
  7465. }
  7466. else
  7467. {
  7468. UpdateVisibleActors();
  7469. MakeFindTargetPrecalcs();
  7470. ResetTargetingOut();
  7471. FindTarget_Scripted();
  7472. }
  7473. if ( targetingOut.result )
  7474. {
  7475. if ( targetingOut.confirmNewTarget )
  7476. {
  7477. ConfirmNewTarget( targetingOut.target );
  7478. }
  7479. return targetingOut.target;
  7480. }
  7481. return NULL;
  7482. }
  7483.  
  7484. protected function FindTarget_Scripted()
  7485. {
  7486. var currentTarget : CActor;
  7487. var newTarget : CActor;
  7488. var selectedTarget : CActor;
  7489. var displayTargetActor : CActor;
  7490. var playerPosition : Vector;
  7491. var playerHeadingVector : Vector;
  7492. var cameraPosition : Vector;
  7493. var cameraHeadingVector : Vector;
  7494. var selectionHeadingVector : Vector;
  7495. var targetingInfo : STargetingInfo;
  7496. var selectionWeights : STargetSelectionWeights;
  7497. var targets : array< CActor >;
  7498. var isMoveTargetTargetable : bool;
  7499. var targetChangeFromActionInput : bool;
  7500. var retainCurrentTarget : bool;
  7501.  
  7502.  
  7503.  
  7504. playerPosition = this.GetWorldPosition();
  7505. playerHeadingVector = targetingPrecalcs.playerHeadingVector;
  7506. cameraPosition = theCamera.GetCameraPosition();
  7507. cameraHeadingVector = targetingPrecalcs.cameraHeadingVector;
  7508.  
  7509. currentTarget = GetTarget();
  7510. if ( currentTarget )
  7511. {
  7512. if ( IsHardLockEnabled() && currentTarget.IsAlive() && !currentTarget.IsKnockedUnconscious() )
  7513. {
  7514. if ( VecDistanceSquared( playerPosition, currentTarget.GetWorldPosition() ) > 50.f * 50.0f )
  7515. {
  7516. HardLockToTarget( false );
  7517. }
  7518. else
  7519. {
  7520. targetingOut.target = currentTarget;
  7521. targetingOut.result = true;
  7522. return;
  7523. }
  7524. }
  7525. GetVisualDebug().AddSphere('target', 1.0f, currentTarget.GetWorldPosition(), true, Color( 255, 255, 0 ), 1.0f );
  7526. }
  7527.  
  7528. if ( bCanFindTarget && !IsActorLockedToTarget() )
  7529. {
  7530. if ( !targetingIn.playerHasBlockingBuffs )
  7531. {
  7532. InternalFindTargetsInCone( targets, selectionHeadingVector, true );
  7533. }
  7534.  
  7535. targetingInfo.source = this;
  7536. targetingInfo.canBeTargetedCheck = true;
  7537. targetingInfo.coneCheck = false;
  7538. targetingInfo.coneHalfAngleCos = 1.0f;
  7539. targetingInfo.coneDist = targetingIn.coneDist;
  7540. targetingInfo.distCheck = true;
  7541. targetingInfo.invisibleCheck = true;
  7542. targetingInfo.navMeshCheck = false;
  7543.  
  7544. if ( ShouldUsePCModeTargeting() )
  7545. targetingInfo.inFrameCheck = false;
  7546. else
  7547. targetingInfo.inFrameCheck = true;
  7548.  
  7549. targetingInfo.frameScaleX = 1.0f;
  7550. targetingInfo.frameScaleY = 1.0f;
  7551. targetingInfo.knockDownCheck = false;
  7552. targetingInfo.knockDownCheckDist = 1.5f;
  7553. targetingInfo.rsHeadingCheck = false;
  7554. targetingInfo.rsHeadingLimitCos = 1.0f;
  7555.  
  7556. if ( currentTarget )
  7557. {
  7558. targetingInfo.targetEntity = currentTarget;
  7559. if ( !IsEntityTargetable( targetingInfo, true ) )
  7560. {
  7561. currentTarget = NULL;
  7562. }
  7563. if ( currentTarget && !CanBeTargetedIfSwimming( currentTarget, true ) )
  7564. {
  7565. currentTarget = NULL;
  7566. }
  7567. }
  7568.  
  7569. isMoveTargetTargetable = false;
  7570. if ( moveTarget )
  7571. {
  7572. if ( CanBeTargetedIfSwimming( moveTarget, true ) )
  7573. {
  7574. targetingInfo.targetEntity = moveTarget;
  7575. targetingInfo.coneDist = findMoveTargetDist;
  7576. targetingInfo.inFrameCheck = false;
  7577. if ( IsEntityTargetable( targetingInfo, true ) )
  7578. {
  7579. isMoveTargetTargetable = true;
  7580. }
  7581. }
  7582. }
  7583.  
  7584.  
  7585. targetingInfo.coneDist = targetingIn.coneDist;
  7586.  
  7587. if ( !targetingIn.playerHasBlockingBuffs )
  7588. {
  7589. RemoveNonTargetable( targets, targetingInfo, selectionHeadingVector );
  7590. }
  7591.  
  7592. newTarget = NULL;
  7593. if ( this.playerAiming.GetCurrentStateName() == 'Aiming' )
  7594. {
  7595. newTarget = this.playerAiming.GetAimedTarget();
  7596. if ( !newTarget )
  7597. {
  7598. selectionWeights.angleWeight = 1.f;
  7599. selectionWeights.distanceWeight = 0.f;
  7600. selectionWeights.distanceRingWeight = 0.f;
  7601.  
  7602. selectedTarget = SelectTarget( targets, false, cameraPosition, cameraHeadingVector, selectionWeights, true );
  7603. newTarget = selectedTarget;
  7604. }
  7605. }
  7606. else if ( IsSwimming() )
  7607. {
  7608. selectionWeights.angleWeight = 0.9f;
  7609. selectionWeights.distanceWeight = 0.1f;
  7610. selectionWeights.distanceRingWeight = 0.f;
  7611.  
  7612. selectedTarget = SelectTarget( targets, true, cameraPosition, cameraHeadingVector, selectionWeights, true );
  7613. newTarget = selectedTarget;
  7614. }
  7615. else if ( IsThreatened() )
  7616. {
  7617.  
  7618. if ( IsCameraLockedToTarget() )
  7619. {
  7620. if ( currentTarget && !currentTarget.GetGameplayVisibility() )
  7621. {
  7622. ForceSelectLockTarget();
  7623. }
  7624. }
  7625.  
  7626. displayTargetActor = (CActor)displayTarget;
  7627. selectedTarget = SelectTarget( targets, true, playerPosition, selectionHeadingVector, targetingIn.defaultSelectionWeights, true );
  7628.  
  7629. if ( !selectedTarget )
  7630. {
  7631. targetingOut.forceDisableUpdatePosition = true;
  7632. }
  7633.  
  7634. targetChangeFromActionInput = targetingIn.actionInput && !lAxisReleasedAfterCounter;
  7635. if ( selectedTarget &&
  7636. ( !IsThreat( currentTarget, true ) || ShouldUsePCModeTargeting() || ( !IsInCombatAction() && !lAxisReleasedAfterCounterNoCA ) || targetChangeFromActionInput ) )
  7637. {
  7638. newTarget = selectedTarget;
  7639. }
  7640. else if ( displayTargetActor &&
  7641. ( ( bLAxisReleased && !ShouldUsePCModeTargeting() )|| IsInCombatAction() ) &&
  7642. ( displayTargetActor.IsAlive() || finishableEnemiesList.Contains( displayTargetActor ) ) &&
  7643. displayTargetActor.GetGameplayVisibility() &&
  7644. ( IsEnemyVisible( displayTargetActor ) || finishableEnemiesList.Contains( displayTargetActor ) ) &&
  7645. this.CanBeTargetedIfSwimming( displayTargetActor, true ) &&
  7646. IsThreat( displayTargetActor, true ) &&
  7647. WasVisibleInScaledFrame( displayTargetActor, 1.f, 1.f ) )
  7648. {
  7649. newTarget = displayTargetActor;
  7650. }
  7651.  
  7652.  
  7653. else if ( moveTarget &&
  7654. isMoveTargetTargetable &&
  7655. ( !IsInCombatAction() || isInParryOrCounter || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Dodge || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Roll ) )
  7656. {
  7657. newTarget = moveTarget;
  7658. }
  7659. else
  7660. {
  7661. newTarget = NULL;
  7662. }
  7663. }
  7664. else
  7665. {
  7666. retainCurrentTarget = false;
  7667. if ( lAxisReleasedAfterCounterNoCA )
  7668. {
  7669. if ( lastAxisInputIsMovement && !this.IsSwimming())
  7670. {
  7671. selectionWeights.angleWeight = 0.375f;
  7672. selectionWeights.distanceWeight = 0.275f;
  7673. selectionWeights.distanceRingWeight = 0.35f;
  7674. selectedTarget = SelectTarget( targets, false, playerPosition, playerHeadingVector, selectionWeights, true );
  7675.  
  7676. if ( currentTarget != selectedTarget )
  7677. {
  7678. targetingInfo.targetEntity = currentTarget;
  7679. if ( IsEntityTargetable( targetingInfo, true ) && currentTarget.IsAlive() )
  7680. {
  7681. retainCurrentTarget = true;
  7682. }
  7683. }
  7684. }
  7685. else
  7686. {
  7687. selectionWeights.angleWeight = 0.75f;
  7688. selectionWeights.distanceWeight = 0.125f;
  7689. selectionWeights.distanceRingWeight = 0.125f;
  7690. selectedTarget = SelectTarget( targets, false, cameraPosition, cameraHeadingVector, selectionWeights, true );
  7691. }
  7692. }
  7693. else
  7694. {
  7695. selectionWeights.angleWeight = 0.6f;
  7696. selectionWeights.distanceWeight = 0.4f;
  7697. selectionWeights.distanceRingWeight = 0.f;
  7698. selectedTarget = SelectTarget( targets, true, playerPosition, targetingIn.rawPlayerHeadingVector, selectionWeights, true );
  7699. }
  7700.  
  7701. if ( retainCurrentTarget )
  7702. {
  7703. newTarget = currentTarget;
  7704. }
  7705. else if ( IsInCombatAction() && GetBehaviorVariable( 'isPerformingSpecialAttack' ) == 1.0f )
  7706. {
  7707. newTarget = moveTarget;
  7708. }
  7709. else if ( selectedTarget )
  7710. {
  7711. newTarget = selectedTarget;
  7712. }
  7713. else
  7714. {
  7715. newTarget = NULL;
  7716. }
  7717. }
  7718.  
  7719. targetingOut.confirmNewTarget = true;
  7720. }
  7721. else
  7722. {
  7723. newTarget = NULL;
  7724. }
  7725.  
  7726. targetingOut.result = true;
  7727. targetingOut.target = newTarget;
  7728. }
  7729.  
  7730. function UpdateVisibleActors()
  7731. {
  7732. var i : int;
  7733. var now : float;
  7734.  
  7735. now = theGame.GetEngineTimeAsSeconds();
  7736. for ( i = visibleActors.Size() - 1; i >= 0; i-=1 )
  7737. {
  7738.  
  7739. if ( ( now - visibleActorsTime[i] ) > 1.0f )
  7740. {
  7741. visibleActors.EraseFast( i );
  7742. visibleActorsTime.EraseFast( i );
  7743. }
  7744. }
  7745. }
  7746.  
  7747. function RemoveNonTargetable( out targets : array< CActor >, out info : STargetingInfo, selectionHeadingVector : Vector )
  7748. {
  7749. var i : int;
  7750. var cameraPosition : Vector;
  7751. var cameraDirection : Vector;
  7752. var nonCombatCheck : bool;
  7753. var playerToCamPlaneDist : float;
  7754. var targetToCamPlaneDist : float;
  7755.  
  7756. if ( targets.Size() == 0 )
  7757. {
  7758. return;
  7759. }
  7760.  
  7761. nonCombatCheck = bLAxisReleased && !IsInCombat();
  7762.  
  7763.  
  7764. if ( nonCombatCheck )
  7765. {
  7766. info.coneHeadingVector = targetingPrecalcs.playerHeadingVector;
  7767. if ( lastAxisInputIsMovement )
  7768. {
  7769. info.coneHeadingVector = selectionHeadingVector;
  7770. info.invisibleCheck = false;
  7771. info.coneCheck = true;
  7772. info.coneHalfAngleCos = 0.76604444311f;
  7773. }
  7774. else
  7775. {
  7776. info.invisibleCheck = false;
  7777. info.frameScaleX = 0.9f;
  7778. info.frameScaleY = 0.9f;
  7779. }
  7780. }
  7781. else
  7782. {
  7783. info.coneHeadingVector = Vector( 0.0f, 0.0f, 0.0f );
  7784.  
  7785.  
  7786. if ( IsInCombat() )
  7787. {
  7788. info.inFrameCheck = false;
  7789. }
  7790. else
  7791. {
  7792. if ( !bLAxisReleased )
  7793. {
  7794. info.coneCheck = true;
  7795.  
  7796. if ( this.IsSwimming() )
  7797. info.coneHalfAngleCos = -1;
  7798. else
  7799. info.coneHalfAngleCos = 0.86602540378f;
  7800.  
  7801. info.coneHeadingVector = targetingIn.rawPlayerHeadingVector;
  7802. }
  7803. }
  7804. }
  7805.  
  7806. cameraPosition = theCamera.GetCameraPosition();
  7807. cameraDirection = targetingPrecalcs.cameraDirection;
  7808. playerToCamPlaneDist = VecDot2D( cameraDirection, this.GetWorldPosition() - cameraPosition );
  7809.  
  7810.  
  7811. for( i = targets.Size() - 1; i >= 0; i -= 1 )
  7812. {
  7813. info.targetEntity = targets[i];
  7814.  
  7815. if ( !CanBeTargetedIfSwimming( targets[i], true ) )
  7816. {
  7817. targets.EraseFast( i );
  7818. }
  7819. else if ( !IsEntityTargetable( info, true ) )
  7820. {
  7821. targets.EraseFast( i );
  7822. }
  7823. else
  7824. {
  7825. if ( nonCombatCheck && !lastAxisInputIsMovement )
  7826. {
  7827.  
  7828. targetToCamPlaneDist = VecDot2D( cameraDirection, targets[i].GetWorldPosition() - cameraPosition );
  7829. if ( targetToCamPlaneDist < playerToCamPlaneDist )
  7830. {
  7831. targets.EraseFast( i );
  7832. }
  7833. }
  7834. }
  7835. }
  7836. }
  7837.  
  7838. var combatModeColor : Color;
  7839. public function CombatModeDebug()
  7840. {
  7841. var visualDebug : CVisualDebug = GetVisualDebug();
  7842.  
  7843. var naviQueryMsg : string;
  7844. var naviQueryMsg1 : string;
  7845. var naviQueryMsg2 : string;
  7846.  
  7847. var navSnapMsg : string;
  7848. var i : int;
  7849.  
  7850. if ( IsCombatMusicEnabled() )
  7851. visualDebug.AddText( 'CombatMusic', "CombatMusic : On", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.7f ), true, , Color( 255, 255, 255 ) );
  7852. else
  7853. visualDebug.AddText( 'CombatMusic', "CombatMusic : Off", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.7f ), true, , Color( 0, 0, 0 ) );
  7854.  
  7855. if ( GetPlayerMode().GetForceCombatMode() )
  7856. visualDebug.AddText( 'ForcedCombatMode', "ForcedCombatMode : TRUE", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.6f ), true, , Color( 255, 255, 255 ) );
  7857. else
  7858. visualDebug.AddText( 'ForcedCombatMode', "ForcedCombatMode : FALSE", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.6f ), true, , Color( 0, 0, 0 ) );
  7859.  
  7860.  
  7861. if ( IsThreatened() )
  7862. {
  7863. if ( IsInCombat() )
  7864. visualDebug.AddText( 'CombatMode', "CombatMode : AlertNear/Far", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.5f ), true, , Color( 255, 0, 0 ) );
  7865. else
  7866. visualDebug.AddText( 'CombatMode', "CombatMode : CombatExploration", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.5f ), true, , Color( 255, 255, 0 ) );
  7867. }
  7868. else
  7869. visualDebug.AddText( 'CombatMode', "CombatMode : NormalExploration", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.5f ), true, , Color( 0, 255, 0 ) );
  7870.  
  7871. visualDebug.AddText( 'NaviQuery', naviQueryMsg, combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7872. visualDebug.AddText( 'NaviQuery1', naviQueryMsg1, thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7873. visualDebug.AddText( 'NaviQuery2', naviQueryMsg2, thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7874.  
  7875. if ( isInCombatReason == 0 )
  7876. visualDebug.AddText( 'CombatModeReason', "CombatModeReason : ", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.4f ), true, , Color( 125, 125, 125 ) );
  7877. else if ( isInCombatReason == 1 )
  7878. visualDebug.AddText( 'CombatModeReason', "CombatModeReason : Geralt CAN pathfind to NPC", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.4f ), true, , Color( 255, 0, 0 ) );
  7879. else if ( isInCombatReason == 2 )
  7880. visualDebug.AddText( 'CombatModeReason', "CombatModeReason : An NPC is flying or ranged", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.4f ), true, , Color( 255, 0, 0 ) );
  7881. else if ( isInCombatReason == 2 )
  7882. visualDebug.AddText( 'CombatModeReason', "CombatModeReason : Forced Combat Mode", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.4f ), true, , Color( 255, 0, 0 ) );
  7883.  
  7884. if ( reachableEnemyWasTooFar )
  7885. {
  7886. combatModeColor.Red = 255;
  7887. combatModeColor.Green = 255;
  7888. combatModeColor.Blue = 0;
  7889. }
  7890. else
  7891. {
  7892. combatModeColor.Red = 0;
  7893. combatModeColor.Green = 255;
  7894. combatModeColor.Blue = 0;
  7895. }
  7896.  
  7897. if ( IsThreatened() )
  7898. {
  7899. switch ( navQuery.GetLastOutput( 2.0 ) )
  7900. {
  7901. case EAsyncTastResult_Failure:
  7902. {
  7903. if ( this.playerMode.GetForceCombatMode() )
  7904. {
  7905. if ( isSnappedToNavMesh )
  7906. {
  7907. visualDebug.AddText( 'NaviQuery', "", combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7908. visualDebug.AddText( 'NaviQuery1', "Naviquery : Snapped So no need for query", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7909. visualDebug.AddText( 'NaviQuery2', "Naviquery : Snapped So no need for query", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7910. }
  7911. else
  7912. {
  7913. visualDebug.AddText( 'NaviQuery', "", combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7914. visualDebug.AddText( 'NaviQuery1', "Naviquery : Failed", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7915. visualDebug.AddText( 'NaviQuery2', "Naviquery : Failed", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7916. }
  7917. }
  7918. else
  7919. {
  7920. visualDebug.AddText( 'NaviQuery', "", combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7921. visualDebug.AddText( 'NaviQuery1', "Naviquery : Failed", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7922. visualDebug.AddText( 'NaviQuery2', "Naviquery : Failed", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7923. }
  7924. break;
  7925. }
  7926. case EAsyncTastResult_Success:
  7927. {
  7928. visualDebug.AddText( 'NaviQuery', combatModeEnt.GetName(), combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7929. visualDebug.AddText( 'NaviQuery1', "Naviquery : Success (navDist: " + navDist + ")", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7930. visualDebug.AddText( 'NaviQuery2', "Naviquery : Success (directDist: " + directDist + ")", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7931. break;
  7932. }
  7933. case EAsyncTastResult_Pending:
  7934. {
  7935. visualDebug.AddText( 'NaviQuery', combatModeEnt.GetName(), combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7936. visualDebug.AddText( 'NaviQuery1', "Naviquery : Pending (navDist: " + navDist + ")", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7937. visualDebug.AddText( 'NaviQuery2', "Naviquery : Pending (directDist: " + directDist + ")", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7938. break;
  7939. }
  7940. case EAsyncTastResult_Invalidated:
  7941. {
  7942. visualDebug.AddText( 'NaviQuery', "", combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7943. visualDebug.AddText( 'NaviQuery1', "Naviquery : Invalidated", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7944. visualDebug.AddText( 'NaviQuery2', "Naviquery : Invalidated", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7945. break;
  7946. }
  7947. }
  7948. }
  7949. else
  7950. {
  7951. visualDebug.AddText( 'NaviQuery', "", combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7952. visualDebug.AddText( 'NaviQuery1', "", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7953. visualDebug.AddText( 'NaviQuery2', "", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7954. }
  7955.  
  7956. if ( navMeshSnapInfoStack.Size() > 0 )
  7957. {
  7958. for ( i = navMeshSnapInfoStack.Size()-1; i >= 0; i -= 1 )
  7959. {
  7960. navSnapMsg = navSnapMsg + navMeshSnapInfoStack[i] + " ";
  7961. }
  7962.  
  7963. visualDebug.AddText( 'NavMeshSnap', "NavMeshSnap: Enabled, Sources : " + navSnapMsg, thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.1f ), true, , Color( 255, 255, 255 ) );
  7964. }
  7965. else
  7966. visualDebug.AddText( 'NavMeshSnap', "NavMeshSnap: Disabled" , thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.1f ), true, , Color( 0, 0, 0 ) );
  7967.  
  7968. }
  7969.  
  7970. function IsCombatMusicEnabled() : bool
  7971. {
  7972. if ( theSound.GetCurrentGameState() == ESGS_UnderwaterCombat
  7973. || theSound.GetCurrentGameState() == ESGS_Combat
  7974. || theSound.GetCurrentGameState() == ESGS_CombatMonsterHunt
  7975. || theSound.GetCurrentGameState() == ESGS_FocusUnderwaterCombat )
  7976. return true;
  7977. else
  7978. return false;
  7979. }
  7980.  
  7981. function IsSoundStateCombatMusic( gameState : ESoundGameState ) : bool
  7982. {
  7983. if ( gameState == ESGS_UnderwaterCombat
  7984. || gameState == ESGS_Combat
  7985. || gameState == ESGS_CombatMonsterHunt
  7986. || gameState == ESGS_FocusUnderwaterCombat )
  7987. return true;
  7988. else
  7989. return false;
  7990. }
  7991.  
  7992. private function ConfirmNewTarget( actorToConfirm : CActor )
  7993. {
  7994. var leftJoyRotLimit : float = 1.f;
  7995.  
  7996. var target : CActor;
  7997.  
  7998. target = GetTarget();
  7999.  
  8000.  
  8001. if ( !target
  8002. || !moveTarget
  8003. || ( target && ( !IsThreat( target ) || !target.IsAlive() ) )
  8004. || VecLength( rawLeftJoyVec ) < 0.7f
  8005. || ( IsInCombatAction() && ( ( GetBehaviorVariable( 'combatActionType') == (int)CAT_Dodge ) || ( VecLength( rawLeftJoyVec ) >= 0.7f && ( prevRawLeftJoyRot >= ( rawLeftJoyRot + leftJoyRotLimit ) || prevRawLeftJoyRot <= ( rawLeftJoyRot - leftJoyRotLimit ) || AbsF( AngleDistance( cachedRawPlayerHeading, VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() ) ) ) > 60 ) ) ) )
  8006. || ( !IsInCombatAction() && ( !rangedWeapon || ( rangedWeapon.GetCurrentStateName() != 'State_WeaponHolster' ) ) ))
  8007. {
  8008. SetPrevRawLeftJoyRot();
  8009.  
  8010. if ( actorToConfirm != target )
  8011. {
  8012. SetTarget( actorToConfirm );
  8013. }
  8014. }
  8015. }
  8016.  
  8017. protected function SelectTarget( targets : array< CActor >, useVisibilityCheck : bool, sourcePosition : Vector, headingVector : Vector, selectionWeights : STargetSelectionWeights, optional usePrecalcs : bool ) : CActor
  8018. {
  8019. var i : int;
  8020. var target : CActor;
  8021. var selectedTarget : CActor;
  8022. var currentTarget : CActor;
  8023. var playerPosition : Vector;
  8024. var distanceToPlayer : float;
  8025. var priority : float;
  8026. var maxPriority : float;
  8027. var now : float;
  8028. var remove : bool;
  8029. var visibleActorIndex : int;
  8030.  
  8031. if ( useVisibilityCheck )
  8032. {
  8033. currentTarget = this.GetTarget();
  8034. playerPosition = this.GetWorldPosition();
  8035. now = theGame.GetEngineTimeAsSeconds();
  8036.  
  8037. for ( i = targets.Size() - 1; i >= 0; i-=1 )
  8038. {
  8039. target = targets[ i ];
  8040. if ( target != currentTarget && ( !IsPCModeEnabled() && !WasVisibleInScaledFrame( target, softLockFrameSize, softLockFrameSize ) ) )
  8041. {
  8042. remove = true;
  8043. visibleActorIndex = visibleActors.FindFirst( target );
  8044. if ( visibleActorIndex != -1 )
  8045. {
  8046. if ( usePrecalcs )
  8047. {
  8048. distanceToPlayer = Distance2DBetweenCapsuleAndPoint( target, this ) - targetingPrecalcs.playerRadius;
  8049. }
  8050. else
  8051. {
  8052. distanceToPlayer = Distance2DBetweenCapsules( this, target );
  8053. }
  8054.  
  8055. if ( distanceToPlayer < this.softLockDist && ( now - visibleActorsTime[ i ] ) < 1.0f )
  8056. {
  8057. remove = false;
  8058. }
  8059. }
  8060. if ( remove )
  8061. {
  8062. targets.EraseFast( i );
  8063. }
  8064. }
  8065. else
  8066. {
  8067. visibleActorIndex = visibleActors.FindFirst( target );
  8068. if ( visibleActorIndex == -1 )
  8069. {
  8070. visibleActors.PushBack( target );
  8071. visibleActorsTime.PushBack( now );
  8072. }
  8073. else
  8074. {
  8075. visibleActorsTime[ visibleActorIndex ] = now;
  8076. }
  8077. }
  8078. }
  8079. }
  8080.  
  8081. selectedTarget = NULL;
  8082. maxPriority = -1.0f;
  8083. for( i = targets.Size() - 1; i >= 0; i-=1 )
  8084. {
  8085. priority = CalcSelectionPriority( targets[ i ], selectionWeights, sourcePosition, headingVector );
  8086. if ( priority > maxPriority )
  8087. {
  8088. maxPriority = priority;
  8089. selectedTarget = targets[ i ];
  8090. }
  8091. }
  8092.  
  8093.  
  8094. return selectedTarget;
  8095. }
  8096.  
  8097. function Distance2DBetweenCapsuleAndPoint( actor : CActor, entity : CEntity ) : float
  8098. {
  8099. var distance : float;
  8100. var mpac : CMovingPhysicalAgentComponent;
  8101.  
  8102. distance = VecDistance2D( actor.GetWorldPosition(), entity.GetWorldPosition() );
  8103.  
  8104. mpac = (CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent();
  8105. if ( mpac )
  8106. {
  8107. distance -= mpac.GetCapsuleRadius();
  8108. }
  8109.  
  8110. return distance;
  8111. }
  8112.  
  8113.  
  8114. function Distance2DBetweenCapsules( actor1 : CActor, actor2 : CActor ) : float
  8115. {
  8116. var distance : float;
  8117. var mpac : CMovingPhysicalAgentComponent;
  8118.  
  8119. distance = VecDistance2D( actor1.GetWorldPosition(), actor2.GetWorldPosition() );
  8120.  
  8121. mpac = (CMovingPhysicalAgentComponent)actor1.GetMovingAgentComponent();
  8122. if ( mpac )
  8123. {
  8124. distance -= mpac.GetCapsuleRadius();
  8125. }
  8126.  
  8127. mpac = (CMovingPhysicalAgentComponent)actor2.GetMovingAgentComponent();
  8128. if ( mpac )
  8129. {
  8130. distance -= mpac.GetCapsuleRadius();
  8131. }
  8132.  
  8133. return distance;
  8134. }
  8135.  
  8136. protected function ProcessSelectionWeights() : STargetSelectionWeights
  8137. {
  8138. var selectionWeights : STargetSelectionWeights;
  8139.  
  8140. if ( ShouldUsePCModeTargeting() )
  8141. {
  8142. selectionWeights.angleWeight = 0.75f;
  8143. selectionWeights.distanceWeight = 0.25f;
  8144. selectionWeights.distanceRingWeight = 0.f;
  8145. return selectionWeights;
  8146. }
  8147.  
  8148. if ( IsInCombatAction() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Dodge || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Roll ) )
  8149. {
  8150. selectionWeights.angleWeight = 0.575f;
  8151. selectionWeights.distanceWeight = 0.175f;
  8152. selectionWeights.distanceRingWeight = 0.25f;
  8153. }
  8154. if ( !lAxisReleasedAfterCounter || IsInCombatAction() )
  8155. {
  8156. if ( theInput.GetActionValue( 'ThrowItem' ) == 1.f || ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' ) )
  8157. {
  8158. selectionWeights.angleWeight = 1.f;
  8159. selectionWeights.distanceWeight = 0.f;
  8160. selectionWeights.distanceRingWeight = 0.f;
  8161. }
  8162. else if ( !lAxisReleasedAfterCounter )
  8163. {
  8164. selectionWeights.angleWeight = 0.55f;
  8165. selectionWeights.distanceWeight = 0.45f;
  8166. selectionWeights.distanceRingWeight = 0.f;
  8167. }
  8168. else
  8169. {
  8170. selectionWeights.angleWeight = 0.75f;
  8171. selectionWeights.distanceWeight = 0.25f;
  8172. selectionWeights.distanceRingWeight = 0.f;
  8173. }
  8174. }
  8175. else if( !IsCurrentSignChanneled() )
  8176. {
  8177. selectionWeights.angleWeight = 0.35f;
  8178. selectionWeights.distanceWeight = 0.65f;
  8179. selectionWeights.distanceRingWeight = 0.f;
  8180. }
  8181. else
  8182. {
  8183. selectionWeights.angleWeight = 0.275f;
  8184. selectionWeights.distanceWeight = 0.375f;
  8185. selectionWeights.distanceRingWeight = 0.35f;
  8186. }
  8187.  
  8188. return selectionWeights;
  8189. }
  8190.  
  8191. protected function CalcSelectionPriority( target : CEntity, selectionWeights : STargetSelectionWeights, sourcePosition : Vector, headingVector : Vector ) : float
  8192. {
  8193. var sourceToTarget : Vector;
  8194. var sourceToTargetDist : float;
  8195. var sourceToTargetAngleDiff : float;
  8196. var selectionPriority : float;
  8197.  
  8198. sourceToTarget = target.GetWorldPosition() - sourcePosition;
  8199. sourceToTargetDist = VecLength2D( sourceToTarget );
  8200.  
  8201. if ( sourceToTargetDist < 0.0001f )
  8202. {
  8203. sourceToTarget = Vector( 0.0f, 0.0f, 0.0f );
  8204. }
  8205. else
  8206. {
  8207. sourceToTarget *= ( 1.0f / sourceToTargetDist );
  8208. }
  8209. sourceToTargetAngleDiff = AbsF( Rad2Deg( AcosF( VecDot2D( sourceToTarget, headingVector ) ) ) );
  8210.  
  8211. selectionPriority = ( selectionWeights.angleWeight * ( ( 180 - sourceToTargetAngleDiff ) / 180 ) );
  8212. selectionPriority += selectionWeights.distanceWeight * ( ( softLockDist - sourceToTargetDist ) / softLockDist );
  8213.  
  8214. if ( sourceToTargetDist > 0.f && sourceToTargetDist <= 6.f )
  8215. {
  8216. selectionPriority += selectionWeights.distanceRingWeight * 1.0f;
  8217. }
  8218. else if ( sourceToTargetDist > 6.f && sourceToTargetDist <= softLockDist )
  8219. {
  8220. selectionPriority += selectionWeights.distanceRingWeight * 0.4f;
  8221. }
  8222.  
  8223. return selectionPriority;
  8224. }
  8225.  
  8226. protected function SetTarget( targetActor : CActor, optional forceSetTarget : bool )
  8227. {
  8228. var playerToTargetDistance : float;
  8229. var target : CActor;
  8230. var allow : bool;
  8231.  
  8232. target = GetTarget();
  8233.  
  8234. if ( !IsInNonGameplayCutscene() )
  8235. allow = true;
  8236.  
  8237. if ( allow )
  8238. {
  8239. if ( targetActor )
  8240. {
  8241. if ( ( targetActor.IsAlive() && !targetActor.IsKnockedUnconscious() ) || finishableEnemiesList.Contains( targetActor ) )
  8242. allow = true;
  8243. else
  8244. allow = false;
  8245. }
  8246. else
  8247. allow = true;
  8248. }
  8249.  
  8250. if ( forceSetTarget )
  8251. allow = true;
  8252.  
  8253. if ( allow && target != targetActor )
  8254. allow = true;
  8255. else
  8256. allow = false;
  8257.  
  8258. if ( allow )
  8259. {
  8260. SetPlayerTarget( targetActor );
  8261.  
  8262.  
  8263.  
  8264. }
  8265. }
  8266.  
  8267.  
  8268. public function SetSlideTarget( actor : CGameplayEntity )
  8269. {
  8270.  
  8271.  
  8272.  
  8273. slideTarget = actor;
  8274.  
  8275. if ( slideTarget )
  8276. SetPlayerCombatTarget((CActor)slideTarget);
  8277. else
  8278. Log( "slideTarget = NULL" );
  8279.  
  8280. if ( slideTarget == nonActorTarget )
  8281. UpdateDisplayTarget( true, true );
  8282. else
  8283. UpdateDisplayTarget();
  8284.  
  8285. ConfirmDisplayTargetTimer(0.f);
  8286. }
  8287.  
  8288. event OnForceSelectLockTarget()
  8289. {
  8290. ForceSelectLockTarget();
  8291. }
  8292.  
  8293. private function ForceSelectLockTarget()
  8294. {
  8295. var newMoveTarget : CActor;
  8296. var target : CActor;
  8297.  
  8298. newMoveTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, 90 );
  8299.  
  8300. if ( !newMoveTarget )
  8301. newMoveTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, -90 );
  8302.  
  8303. if ( newMoveTarget )
  8304. {
  8305. thePlayer.ProcessLockTarget( newMoveTarget );
  8306.  
  8307. target = GetTarget();
  8308. if ( target )
  8309. {
  8310. thePlayer.SetSlideTarget( target );
  8311.  
  8312. if ( IsHardLockEnabled() )
  8313. thePlayer.HardLockToTarget( true );
  8314. }
  8315. }
  8316. else
  8317. {
  8318. thePlayer.HardLockToTarget( false );
  8319. }
  8320. }
  8321.  
  8322. public function SetFinisherVictim( actor : CActor )
  8323. {
  8324. finisherVictim = actor;
  8325. }
  8326.  
  8327. public function GetFinisherVictim() : CActor
  8328. {
  8329. return finisherVictim;
  8330. }
  8331.  
  8332. protected function SetNonActorTarget( actor : CGameplayEntity )
  8333. {
  8334. if ( nonActorTarget != actor )
  8335. nonActorTarget = actor;
  8336. }
  8337.  
  8338. timer function DisableTargetHighlightTimer( time : float , id : int)
  8339. {
  8340. var target : CActor;
  8341. target = GetTarget();
  8342.  
  8343. if( target )
  8344. {
  8345. target.StopEffect( 'select_character' );
  8346. }
  8347. }
  8348.  
  8349. public function WasVisibleInScaledFrame( entity : CEntity, frameSizeX : float, frameSizeY : float ) : bool
  8350. {
  8351. var position : Vector;
  8352. var positionFound : bool;
  8353. var inFront : bool;
  8354. var x, y : float;
  8355. var boneIndex : int;
  8356. var actor : CActor;
  8357. var gameplayEntity : CGameplayEntity;
  8358. var gameplayEntityMatrix : Matrix;
  8359. var drawableComp : CDrawableComponent;
  8360. var box : Box;
  8361. var ok : bool;
  8362.  
  8363. if ( !entity )
  8364. {
  8365. return false;
  8366. }
  8367. if ( frameSizeX <= 0.0f && frameSizeY <= 0.0f )
  8368. {
  8369. LogChannel( 'WasVisibleInScaledFrame', "ERROR: WasVisibleInScaledFrame: frameSizeX && frameSizeY are both negative!!!" );
  8370. return false;
  8371. }
  8372.  
  8373. if ( useNativeTargeting )
  8374. {
  8375. return targeting.WasVisibleInScaledFrame( entity, frameSizeX, frameSizeY );
  8376. }
  8377.  
  8378. position = entity.GetWorldPosition();
  8379.  
  8380. actor = (CActor)entity;
  8381. if ( actor )
  8382. {
  8383. boneIndex = entity.GetBoneIndex( 'pelvis' );
  8384. if ( boneIndex == -1 )
  8385. {
  8386. boneIndex = entity.GetBoneIndex( 'k_pelvis_g' );
  8387. }
  8388.  
  8389. if ( boneIndex != -1 )
  8390. {
  8391. position = MatrixGetTranslation( entity.GetBoneWorldMatrixByIndex( boneIndex ) );
  8392. }
  8393. else
  8394. {
  8395. position = entity.GetWorldPosition();
  8396. position.Z += ( (CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent() ).GetCapsuleHeight() * 0.5;
  8397. }
  8398. positionFound = true;
  8399. }
  8400. else
  8401. {
  8402. gameplayEntity = (CGameplayEntity)entity;
  8403. if ( gameplayEntity && !( gameplayEntity.aimVector.X == 0 && gameplayEntity.aimVector.Y == 0 && gameplayEntity.aimVector.Z == 0 ) )
  8404. {
  8405. gameplayEntityMatrix = gameplayEntity.GetLocalToWorld();
  8406. position = VecTransform( gameplayEntityMatrix, gameplayEntity.aimVector );
  8407. positionFound = true;
  8408. }
  8409. }
  8410.  
  8411.  
  8412. if ( !positionFound )
  8413. {
  8414. drawableComp = (CDrawableComponent)entity.GetComponentByClassName( 'CDrawableComponent' );
  8415. if ( drawableComp && drawableComp.GetObjectBoundingVolume( box ) )
  8416. {
  8417. position.Z += ( ( box.Max.Z - box.Min.Z ) * 0.66f );
  8418. }
  8419. }
  8420.  
  8421. inFront = theCamera.WorldVectorToViewRatio( position, x, y );
  8422. if ( !inFront )
  8423. {
  8424. return false;
  8425. }
  8426. x = AbsF( x );
  8427. y = AbsF( y );
  8428.  
  8429. ok = true;
  8430. ok = ok && ( frameSizeX <= 0.0f || x < frameSizeX );
  8431. ok = ok && ( frameSizeY <= 0.0f || y < frameSizeY );
  8432.  
  8433. return ok;
  8434. }
  8435.  
  8436. public function HardLockToTarget( flag : bool )
  8437. {
  8438. if( flag && GetTarget().HasTag( 'NoHardLock' ) )
  8439. return;
  8440.  
  8441. EnableHardLock( flag );
  8442. LockToTarget( flag );
  8443. }
  8444.  
  8445. public function LockToTarget( flag : bool )
  8446. {
  8447. if ( IsHardLockEnabled() && !flag )
  8448. return;
  8449.  
  8450. LockCameraToTarget( flag );
  8451. LockActorToTarget( flag );
  8452. }
  8453.  
  8454. public function LockCameraToTarget( flag : bool )
  8455. {
  8456. if ( flag && !IsCameraLockedToTarget() )
  8457. {
  8458. thePlayer.EnableManualCameraControl( false, 'LockCameraToTarget' );
  8459.  
  8460. SetIsCameraLockedToTarget( flag );
  8461. }
  8462. else if ( !flag && IsCameraLockedToTarget() )
  8463. {
  8464. thePlayer.EnableManualCameraControl( true, 'LockCameraToTarget' );
  8465.  
  8466. SetIsCameraLockedToTarget( flag );
  8467. }
  8468. }
  8469.  
  8470. public function LockActorToTarget( flag : bool, optional withoutIcon : bool )
  8471. {
  8472. var displayTargetActor : CActor;
  8473.  
  8474. if ( flag )
  8475. {
  8476. if ( !IsActorLockedToTarget() )
  8477. {
  8478.  
  8479. SetIsActorLockedToTarget( flag );
  8480. SetMoveTargetChangeAllowed( true );
  8481. SetMoveTarget( GetTarget() );
  8482. SetMoveTargetChangeAllowed( false );
  8483. SetTarget( GetTarget() );
  8484. SetSlideTarget( GetTarget() );
  8485. AddTimer( 'CheckLockTargetIsAlive', 0.5, true );
  8486. }
  8487.  
  8488. if ( IsActorLockedToTarget() )
  8489. {
  8490. displayTargetActor = (CActor)( GetDisplayTarget() );
  8491.  
  8492. if ( displayTargetActor && IsThreat( displayTargetActor ) && !withoutIcon )
  8493. EnableHardLockIcon( flag );
  8494. }
  8495. }
  8496. else if ( !flag && IsActorLockedToTarget() )
  8497. {
  8498. SetIsActorLockedToTarget( flag );
  8499. SetMoveTargetChangeAllowed( true );
  8500. RemoveTimer( 'CheckLockTargetIsAlive' );
  8501. EnableHardLockIcon( flag );
  8502. }
  8503. }
  8504.  
  8505. private function EnableHardLockIcon( flag : bool )
  8506. {
  8507. var hud : CR4ScriptedHud;
  8508. var module : CR4HudModuleEnemyFocus;
  8509.  
  8510. if( GetTarget().HasTag( 'NoHardLockIcon' ) )
  8511. return;
  8512.  
  8513. hud = (CR4ScriptedHud)theGame.GetHud();
  8514. module = (CR4HudModuleEnemyFocus)hud.GetHudModule("EnemyFocusModule");
  8515. module.SetShowHardLock( flag );
  8516. }
  8517.  
  8518. private timer function CheckLockTargetIsAlive( time : float , id : int)
  8519. {
  8520. var vitality : float;
  8521. var essence : float;
  8522. var actor : CActor;
  8523. var target : CActor;
  8524.  
  8525. target = (CActor)GetDisplayTarget();
  8526.  
  8527. if( !target
  8528. || !target.IsAlive()
  8529. || ( !target.GetGameplayVisibility() )
  8530. || !CanBeTargetedIfSwimming( target )
  8531. || (!target.UsesVitality() && !target.UsesEssence()))
  8532. {
  8533. if ( !ProcessLockTarget() )
  8534. HardLockToTarget( false );
  8535. }
  8536. }
  8537.  
  8538.  
  8539.  
  8540.  
  8541.  
  8542.  
  8543. protected function PlayHitAnimation(damageAction : W3DamageAction, animType : EHitReactionType)
  8544. {
  8545. var hitRotation : float;
  8546. var onHitCounter : SAbilityAttributeValue;
  8547. var counter : int;
  8548.  
  8549. if( damageAction.HasAnyCriticalEffect() )
  8550. return;
  8551.  
  8552. if( !substateManager.ReactOnBeingHit() && !IsUsingVehicle() )
  8553. {
  8554. return;
  8555. }
  8556.  
  8557. if ( damageAction.GetHitReactionType() == EHRT_Reflect )
  8558. SetBehaviorVariable( 'isAttackReflected', 1.f );
  8559. else
  8560. SetBehaviorVariable( 'isAttackReflected', 0.f );
  8561.  
  8562. SetBehaviorVariable( 'HitReactionType',(int)animType);
  8563. SetBehaviorVariable( 'HitReactionWeapon', ProcessSwordOrFistHitReaction( this, (CActor)damageAction.attacker ) );
  8564.  
  8565. if (damageAction.attacker)
  8566. {
  8567. super.PlayHitAnimation( damageAction, animType );
  8568. if ( damageAction.attacker.HasAbility( 'IncreaseHitReactionSeverityWithHitCounter' ) )
  8569. {
  8570. counter = GetHitCounter();
  8571. switch ( counter )
  8572. {
  8573. case 2 :
  8574. SetBehaviorVariable( 'HitReactionType', 2 );
  8575. break;
  8576.  
  8577. case 3 :
  8578. AddEffectDefault( EET_Stagger, damageAction.attacker, damageAction.attacker.GetName() );
  8579. break;
  8580.  
  8581. case 4 :
  8582. AddEffectDefault( EET_Knockdown, damageAction.attacker, damageAction.attacker.GetName() );
  8583. break;
  8584.  
  8585. default :
  8586. break;
  8587. }
  8588. }
  8589. SetHitReactionDirection(damageAction.attacker);
  8590. SetDetailedHitReaction(damageAction.GetSwingType(), damageAction.GetSwingDirection());
  8591. }
  8592.  
  8593. RaiseForceEvent( 'Hit' );
  8594. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'ActorInHitReaction', -1, 30.0f, -1.f, -1, true );
  8595.  
  8596. if ( IsUsingBoat() )
  8597. {
  8598. SoundEvent("cmb_play_hit_light");
  8599. return;
  8600. }
  8601.  
  8602. if ( IsUsingVehicle() )
  8603. return;
  8604.  
  8605. if(damageAction.attacker)
  8606. {
  8607. hitRotation = VecHeading( damageAction.attacker.GetWorldPosition() - GetWorldPosition() );
  8608. if ( this.GetBehaviorVariable( 'HitReactionDirection' ) == (float)( (int)EHRD_Back ) )
  8609. hitRotation += 180.f;
  8610.  
  8611.  
  8612. SetCustomRotation( 'Hit', hitRotation, 1080.f, 0.1f, false );
  8613. }
  8614.  
  8615. CriticalEffectAnimationInterrupted("PlayHitAnimation");
  8616. }
  8617.  
  8618. public function ReduceDamage( out damageData : W3DamageAction)
  8619. {
  8620. super.ReduceDamage(damageData);
  8621.  
  8622.  
  8623. if(damageData.attacker == this && (damageData.GetBuffSourceName() == "petard" || (W3Petard)damageData.causer) )
  8624. {
  8625. if ( theGame.CanLog() )
  8626. {
  8627. LogDMHits("CR4Player.ReduceDamage: hitting self with own bomb - damage reduced by 50%", damageData );
  8628. }
  8629. damageData.processedDmg.vitalityDamage = damageData.processedDmg.vitalityDamage / 2;
  8630. damageData.processedDmg.essenceDamage = damageData.processedDmg.essenceDamage / 2;
  8631. }
  8632. }
  8633.  
  8634.  
  8635. public function GetCriticalHitChance( isLightAttack : bool, isHeavyAttack : bool, target : CActor, victimMonsterCategory : EMonsterCategory, isBolt : bool ) : float
  8636. {
  8637. var critChance : float;
  8638. var oilChanceAttribute : name;
  8639. var weapons : array< SItemUniqueId >;
  8640. var i : int;
  8641. var holdsCrossbow : bool;
  8642. var critVal : SAbilityAttributeValue;
  8643.  
  8644. critChance = 0;
  8645.  
  8646.  
  8647. if( FactsQuerySum( 'debug_fact_critical_boy' ) > 0 )
  8648. {
  8649. critChance += 1;
  8650. }
  8651.  
  8652. if( IsInState( 'HorseRiding' ) && ( ( CActor )GetUsedVehicle() ).GetMovingAgentComponent().GetRelativeMoveSpeed() >= 4.0 )
  8653. {
  8654. critChance += 1;
  8655. }
  8656.  
  8657.  
  8658. critChance += CalculateAttributeValue( GetAttributeValue( theGame.params.CRITICAL_HIT_CHANCE ) );
  8659.  
  8660.  
  8661. weapons = inv.GetHeldWeapons();
  8662. for( i=0; i<weapons.Size(); i+=1 )
  8663. {
  8664. holdsCrossbow = ( inv.IsItemCrossbow( weapons[i] ) || inv.IsItemBolt( weapons[i] ) );
  8665. if( holdsCrossbow != isBolt )
  8666. {
  8667. critVal = inv.GetItemAttributeValue( weapons[i], theGame.params.CRITICAL_HIT_CHANCE );
  8668. critChance -= CalculateAttributeValue( critVal );
  8669. }
  8670. }
  8671.  
  8672.  
  8673. if( isHeavyAttack && CanUseSkill( S_Sword_s08 ) )
  8674. {
  8675. critChance += CalculateAttributeValue( GetSkillAttributeValue( S_Sword_s08, theGame.params.CRITICAL_HIT_CHANCE, false, true ) ) * GetSkillLevel( S_Sword_s08 );
  8676. }
  8677. else if( isLightAttack && CanUseSkill( S_Sword_s17 ) )
  8678. {
  8679. critChance += CalculateAttributeValue( GetSkillAttributeValue( S_Sword_s17, theGame.params.CRITICAL_HIT_CHANCE, false, true ) ) * GetSkillLevel( S_Sword_s17 );
  8680. }
  8681.  
  8682. if( target && target.HasBuff( EET_Confusion ) )
  8683. {
  8684. critChance += ( ( W3ConfuseEffect )target.GetBuff( EET_Confusion ) ).GetCriticalHitChanceBonus();
  8685. }
  8686.  
  8687.  
  8688. oilChanceAttribute = MonsterCategoryToCriticalChanceBonus( victimMonsterCategory );
  8689. if( IsNameValid( oilChanceAttribute ) )
  8690. {
  8691. critChance += CalculateAttributeValue( GetAttributeValue( oilChanceAttribute ) );
  8692. }
  8693.  
  8694. return critChance;
  8695. }
  8696.  
  8697.  
  8698. public function GetCriticalHitDamageBonus(weaponId : SItemUniqueId, victimMonsterCategory : EMonsterCategory, isStrikeAtBack : bool) : SAbilityAttributeValue
  8699. {
  8700. var bonus, oilBonus : SAbilityAttributeValue;
  8701. var vsAttributeName : name;
  8702.  
  8703. bonus = super.GetCriticalHitDamageBonus(weaponId, victimMonsterCategory, isStrikeAtBack);
  8704.  
  8705.  
  8706. if( inv.ItemHasActiveOilApplied( weaponId, victimMonsterCategory ) )
  8707. {
  8708. vsAttributeName = MonsterCategoryToCriticalDamageBonus(victimMonsterCategory);
  8709. oilBonus = inv.GetItemAttributeValue(weaponId, vsAttributeName);
  8710. bonus += oilBonus;
  8711. }
  8712.  
  8713. return bonus;
  8714. }
  8715.  
  8716.  
  8717. public function ReactToBeingHit(damageAction : W3DamageAction, optional buffNotApplied : bool) : bool
  8718. {
  8719. var strength : float;
  8720. var animType : EHitReactionType;
  8721. var sup : bool;
  8722. var boat : CBoatComponent;
  8723. var combatActionType : int;
  8724. var attackAction : W3Action_Attack;
  8725. var npc : CNewNPC;
  8726. var shakeCam : bool;
  8727.  
  8728. attackAction = (W3Action_Attack)damageAction;
  8729.  
  8730. if(!damageAction.IsDoTDamage() && (!attackAction || (!attackAction.IsParried() && !attackAction.IsCountered() && !attackAction.WasDodged()) ) )
  8731. {
  8732. npc = (CNewNPC)attackAction.attacker;
  8733. if(npc && npc.IsHeavyAttack(attackAction.GetAttackName()))
  8734. theGame.VibrateControllerVeryHard();
  8735. else
  8736. theGame.VibrateControllerHard();
  8737. }
  8738.  
  8739. if ( (CActor)GetUsedVehicle() && this.playerAiming.GetCurrentStateName() == 'Aiming' && !damageAction.IsDoTDamage())
  8740. {
  8741. OnRangedForceHolster( true, true );
  8742. }
  8743.  
  8744. combatActionType = (int)GetBehaviorVariable( 'combatActionType' );
  8745.  
  8746. if ( thePlayer.IsCurrentlyDodging() && ( combatActionType == (int)CAT_Roll || combatActionType == (int)CAT_CiriDodge ) )
  8747. sup = false;
  8748. else if ( this.GetCurrentStateName() == 'DismountHorse' )
  8749. sup = false;
  8750. else
  8751. sup = super.ReactToBeingHit(damageAction, buffNotApplied);
  8752. sup = false;
  8753.  
  8754. if(damageAction.attacker)
  8755. theTelemetry.LogWithLabelAndValue( TE_FIGHT_HERO_GETS_HIT, damageAction.attacker.ToString(), (int)damageAction.processedDmg.vitalityDamage );
  8756.  
  8757.  
  8758. if(damageAction.DealsAnyDamage())
  8759. {
  8760. if( ((W3PlayerWitcher)this) && GetWitcherPlayer().IsAnyQuenActive() && damageAction.IsDoTDamage())
  8761. {
  8762. shakeCam = false;
  8763. }
  8764. else
  8765. {
  8766. shakeCam = true;
  8767. }
  8768.  
  8769. if(shakeCam)
  8770. {
  8771. animType = ModifyHitSeverityReaction(this, damageAction.GetHitReactionType());
  8772.  
  8773. if(animType == EHRT_Light || animType == EHRT_LightClose)
  8774. strength = 0.1;
  8775. else if(animType == EHRT_Heavy || animType == EHRT_Igni)
  8776. strength = 0.2;
  8777.  
  8778. GCameraShakeLight(strength, false, GetWorldPosition(), 10.0);
  8779. }
  8780.  
  8781. this.HitReactionEffect( 0.25 );
  8782.  
  8783.  
  8784. ResetUninterruptedHitsCount();
  8785. }
  8786.  
  8787.  
  8788. if(!damageAction.IsDoTDamage() && IsThreatened() && ShouldPauseHealthRegenOnHit() && damageAction.DealsAnyDamage() && !damageAction.WasDodged() && attackAction.CanBeParried() && !attackAction.IsParried())
  8789. {
  8790. PauseHPRegenEffects('being_hit', theGame.params.ON_HIT_HP_REGEN_DELAY);
  8791. }
  8792.  
  8793.  
  8794.  
  8795.  
  8796.  
  8797. if(damageAction.processedDmg.vitalityDamage > 0 && !((W3Effect_Toxicity)damageAction.causer))
  8798. ReceivedCombatDamage();
  8799.  
  8800.  
  8801. if(FactsQuerySum("tut_fight_use_slomo") > 0)
  8802. {
  8803. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
  8804. FactsRemove("tut_fight_slomo_ON");
  8805. }
  8806.  
  8807.  
  8808. if( !substateManager.ReactOnBeingHit( damageAction ) )
  8809. {
  8810. GoToCombatIfNeeded();
  8811.  
  8812. }
  8813.  
  8814. return sup;
  8815. }
  8816.  
  8817. protected function ShouldPauseHealthRegenOnHit() : bool
  8818. {
  8819. return true;
  8820. }
  8821.  
  8822. public function PlayHitEffect(damageAction : W3DamageAction)
  8823. {
  8824. super.PlayHitEffect(damageAction);
  8825.  
  8826.  
  8827. if(damageAction.DealsAnyDamage() && !damageAction.IsDoTDamage())
  8828. PlayEffect('hit_screen');
  8829. }
  8830.  
  8831. function HitReactionEffect( interval : float )
  8832. {
  8833. if ( hitReactionEffect )
  8834. {
  8835. PlayEffect( 'radial_blur' );
  8836. hitReactionEffect = false;
  8837. }
  8838. else
  8839. {
  8840. AddTimer( 'HitReactionEffectCooldown', interval, false );
  8841. }
  8842. }
  8843.  
  8844. timer function HitReactionEffectCooldown( td : float , id : int)
  8845. {
  8846. hitReactionEffect = true;
  8847. }
  8848.  
  8849.  
  8850.  
  8851.  
  8852.  
  8853.  
  8854. function PerformParryCheck( parryInfo : SParryInfo) : bool
  8855. {
  8856. var mult : float;
  8857. var parryType : EParryType;
  8858. var parryDir : EPlayerParryDirection;
  8859. var parryHeading : float;
  8860. var fistFightParry : bool;
  8861. var action : W3DamageAction;
  8862. var xmlStaminaDamage : float;
  8863. var xmlStaminaDamageName : name = 'stamina_damage' ;
  8864. var counter : int;
  8865. var onHitCounter : SAbilityAttributeValue;
  8866.  
  8867.  
  8868.  
  8869.  
  8870. if(CanParryAttack() && FistFightCheck( parryInfo.target, parryInfo.attacker, fistFightParry ) )
  8871. {
  8872. parryHeading = GetParryHeading( parryInfo, parryDir ) ;
  8873.  
  8874. SetBehaviorVariable( 'parryDirection', (float)( (int)( parryDir ) ) );
  8875. SetBehaviorVariable( 'parryDirectionOverlay', (float)( (int)( parryDir ) ) );
  8876. SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
  8877.  
  8878. if ( IsInCombatActionFriendly() )
  8879. RaiseEvent('CombatActionFriendlyEnd');
  8880.  
  8881. if ( HasStaminaToParry(parryInfo.attackActionName) )
  8882. {
  8883. this.SetBehaviorVariable( 'combatActionType', (int)CAT_Parry );
  8884.  
  8885. if ( parryInfo.targetToAttackerDist > 3.f && !bLAxisReleased && !thePlayer.IsCiri() )
  8886. {
  8887. if ( !RaiseForceEvent( 'PerformParryOverlay' ) )
  8888. return false;
  8889. else
  8890. {
  8891. ClearCustomOrientationInfoStack();
  8892. IncDefendCounter();
  8893. }
  8894. }
  8895. else
  8896. {
  8897. counter = GetDefendCounter();
  8898. onHitCounter = parryInfo.attacker.GetAttributeValue( 'break_through_parry_on_hit_counter' );
  8899. if ( onHitCounter.valueBase > 0 && counter == onHitCounter.valueBase )
  8900. {
  8901. AddEffectDefault( EET_Stagger, parryInfo.attacker, "Break through parry" );
  8902. }
  8903. else if ( RaiseForceEvent( 'PerformParry' ) )
  8904. {
  8905. OnCombatActionStart();
  8906. ClearCustomOrientationInfoStack();
  8907. SetSlideTarget( parryInfo.attacker );
  8908. SetCustomRotation( 'Parry', parryHeading, 1080.f, 0.1f, false );
  8909. IncDefendCounter();
  8910. }
  8911. else
  8912. return false;
  8913. }
  8914. }
  8915. else
  8916. {
  8917. AddEffectDefault(EET_Stagger, parryInfo.attacker, "Parry");
  8918. return true;
  8919. }
  8920.  
  8921. if ( parryInfo.attacker.IsWeaponHeld( 'fist' ) && !parryInfo.target.IsWeaponHeld( 'fist' ) )
  8922. {
  8923. parryInfo.attacker.ReactToReflectedAttack(parryInfo.target);
  8924. }
  8925. else
  8926. {
  8927. if ( this.IsInFistFightMiniGame() && fistFightParry )
  8928. {
  8929. if ( IsNameValid(xmlStaminaDamageName) )
  8930. {
  8931. xmlStaminaDamage = CalculateAttributeValue(parryInfo.attacker.GetAttributeValue( xmlStaminaDamageName ));
  8932. DrainStamina(ESAT_FixedValue, xmlStaminaDamage);
  8933. }
  8934. }
  8935. else
  8936. {
  8937. DrainStamina(ESAT_Parry, 0, 0, '', 0, mult);
  8938. }
  8939. if(IsLightAttack(parryInfo.attackActionName))
  8940. parryInfo.target.PlayEffectOnHeldWeapon('light_block');
  8941. else
  8942. parryInfo.target.PlayEffectOnHeldWeapon('heavy_block');
  8943. }
  8944. return true;
  8945. }
  8946.  
  8947. return false;
  8948. }
  8949.  
  8950. protected function GetParryHeading( parryInfo : SParryInfo, out parryDir : EPlayerParryDirection ) : float
  8951. {
  8952. var targetToAttackerHeading : float;
  8953. var currToTargetAttackerAngleDiff : float;
  8954.  
  8955. targetToAttackerHeading = VecHeading( parryInfo.attacker.GetWorldPosition() - parryInfo.target.GetWorldPosition() );
  8956. currToTargetAttackerAngleDiff = AngleDistance( VecHeading( parryInfo.target.GetHeadingVector() ), targetToAttackerHeading );
  8957.  
  8958. if ( !parryInfo.target.IsWeaponHeld( 'fist' ) )
  8959. {
  8960. if( currToTargetAttackerAngleDiff > -45 && currToTargetAttackerAngleDiff < 45 )
  8961. {
  8962. parryDir = PPD_Forward;
  8963. return targetToAttackerHeading;
  8964. }
  8965. else if( currToTargetAttackerAngleDiff >= 45 && currToTargetAttackerAngleDiff < 135 )
  8966. {
  8967. parryDir = PPD_Right;
  8968.  
  8969. return targetToAttackerHeading + 90;
  8970. }
  8971. else if( currToTargetAttackerAngleDiff <= -45 && currToTargetAttackerAngleDiff > -135 )
  8972. {
  8973. parryDir = PPD_Left;
  8974.  
  8975. return targetToAttackerHeading - 90;
  8976. }
  8977. else
  8978. {
  8979. parryDir = PPD_Back;
  8980.  
  8981. return targetToAttackerHeading + 180;
  8982. }
  8983. }
  8984. else
  8985. {
  8986. if( currToTargetAttackerAngleDiff > -45 && currToTargetAttackerAngleDiff < 45 )
  8987. {
  8988. parryDir = PPD_Forward;
  8989. return targetToAttackerHeading;
  8990. }
  8991. else if( currToTargetAttackerAngleDiff >= 45 && currToTargetAttackerAngleDiff < 180 )
  8992. {
  8993. parryDir = PPD_Right;
  8994. return targetToAttackerHeading + 90;
  8995. }
  8996. else if( currToTargetAttackerAngleDiff <= -45 && currToTargetAttackerAngleDiff >= -180 )
  8997. {
  8998. parryDir = PPD_Left;
  8999. return targetToAttackerHeading - 90;
  9000. }
  9001. else
  9002. {
  9003. parryDir = PPD_Back;
  9004. return targetToAttackerHeading + 180;
  9005. }
  9006. }
  9007. }
  9008.  
  9009. function ProcessLockTarget( optional newLockTarget : CActor, optional checkLeftStickHeading : bool ) : bool
  9010. {
  9011. var attackerNearestPoint : Vector;
  9012. var playerNearestPoint : Vector;
  9013. var incomingAttacker : CActor;
  9014. var tempLockTarget : CActor;
  9015. var target : CActor;
  9016. var useIncomingAttacker : bool;
  9017.  
  9018. if( newLockTarget.HasTag( 'NoHardLock' ) )
  9019. return false;
  9020.  
  9021. if ( newLockTarget )
  9022. tempLockTarget = newLockTarget;
  9023. else
  9024. {
  9025. incomingAttacker = GetClosestIncomingAttacker();
  9026. if ( incomingAttacker && incomingAttacker.IsAlive() && IsUsingVehicle() )
  9027. {
  9028. tempLockTarget = incomingAttacker;
  9029. useIncomingAttacker = false;
  9030. }
  9031.  
  9032. if ( !useIncomingAttacker )
  9033. {
  9034. target = GetTarget();
  9035. if( target.HasTag('ForceHardLock'))
  9036. {
  9037. return true;
  9038. }
  9039. else if ( target && target.IsAlive() && target.GetGameplayVisibility() && IsEnemyVisible( target ) && IsThreat( target ) && CanBeTargetedIfSwimming( target ) )
  9040. tempLockTarget = FindTarget();
  9041. else
  9042. {
  9043. tempLockTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, 0.f );
  9044. }
  9045. }
  9046. }
  9047.  
  9048. if( tempLockTarget.HasTag( 'NoHardLock' ) )
  9049. return false;
  9050.  
  9051. if ( tempLockTarget )
  9052. {
  9053. if ( IsCombatMusicEnabled() || hostileEnemies.Size() > 0 )
  9054. {
  9055. if ( !IsThreat( tempLockTarget ) )
  9056. tempLockTarget = NULL;
  9057. }
  9058. }
  9059.  
  9060. SetTarget( tempLockTarget, true );
  9061. SetMoveTargetChangeAllowed( true );
  9062. SetMoveTarget( tempLockTarget );
  9063. SetMoveTargetChangeAllowed( false );
  9064. SetSlideTarget( tempLockTarget );
  9065.  
  9066. if ( tempLockTarget )
  9067. {
  9068. if ( this.IsActorLockedToTarget() )
  9069. EnableHardLockIcon( true );
  9070.  
  9071. return true;
  9072. }
  9073. else
  9074. return false;
  9075. }
  9076.  
  9077.  
  9078.  
  9079.  
  9080.  
  9081. event OnTaskSyncAnim( npc : CNewNPC, animNameLeft : name ) {}
  9082.  
  9083.  
  9084. public function IsDoingSpecialAttack(heavy : bool) : bool
  9085. {
  9086. var pat : EPlayerAttackType;
  9087.  
  9088. if(IsInCombatAction() && ( (int)GetBehaviorVariable('combatActionType')) == CAT_SpecialAttack)
  9089. {
  9090. pat = (int)GetBehaviorVariable('playerAttackType');
  9091.  
  9092. if(heavy && pat == PAT_Heavy)
  9093. {
  9094. return true;
  9095. }
  9096. else if(!heavy && pat == PAT_Light)
  9097. {
  9098. return true;
  9099. }
  9100. }
  9101.  
  9102. return false;
  9103. }
  9104.  
  9105. public function SetIsCurrentlyDodging(enable : bool, optional isRolling : bool)
  9106. {
  9107. super.SetIsCurrentlyDodging(enable, isRolling);
  9108.  
  9109. if ( isRolling )
  9110. {
  9111. SetCanPlayHitAnim( false );
  9112. this.AddBuffImmunity( EET_KnockdownTypeApplicator, 'Roll', false );
  9113. this.AddBuffImmunity( EET_Knockdown, 'Roll', false );
  9114. this.AddBuffImmunity( EET_HeavyKnockdown, 'Roll', false );
  9115. this.AddBuffImmunity( EET_Stagger, 'Roll', false );
  9116. }
  9117. else
  9118. {
  9119. SetCanPlayHitAnim( true );
  9120. this.RemoveBuffImmunity( EET_KnockdownTypeApplicator, 'Roll' );
  9121. this.RemoveBuffImmunity( EET_Knockdown, 'Roll' );
  9122. this.RemoveBuffImmunity( EET_HeavyKnockdown, 'Roll' );
  9123. this.RemoveBuffImmunity( EET_Stagger, 'Roll' );
  9124. }
  9125. }
  9126.  
  9127. public function EnableHardLock( flag : bool )
  9128. {
  9129. super.EnableHardLock(flag);
  9130.  
  9131. if(flag && ShouldProcessTutorial('TutorialTargettingWaiting'))
  9132. {
  9133. FactsAdd("tut_hardlocked");
  9134. }
  9135. }
  9136.  
  9137. protected function TestParryAndCounter(data : CPreAttackEventData, weaponId : SItemUniqueId, out parried : bool, out countered : bool) : array<CActor>
  9138. {
  9139. var ret : array<CActor>;
  9140.  
  9141.  
  9142. if(FactsQuerySum('player_is_the_boss') > 0)
  9143. {
  9144.  
  9145.  
  9146. SetDebugAttackRange(data.rangeName);
  9147. RemoveTimer('PostAttackDebugRangeClear');
  9148.  
  9149. return ret;
  9150. }
  9151.  
  9152. ret = super.TestParryAndCounter(data, weaponId, parried, countered);
  9153.  
  9154.  
  9155. if(parried)
  9156. theGame.GetGamerProfile().ResetStat(ES_CounterattackChain);
  9157.  
  9158. return ret;
  9159. }
  9160.  
  9161. public function SetSpecialAttackTimeRatio(f : float)
  9162. {
  9163. LogSpecialHeavy(f);
  9164. specialAttackTimeRatio = f;
  9165. }
  9166.  
  9167. public function GetSpecialAttackTimeRatio() : float
  9168. {
  9169. return specialAttackTimeRatio;
  9170. }
  9171.  
  9172.  
  9173. public function OnSpecialAttackHeavyActionProcess()
  9174. {
  9175.  
  9176. SetSpecialAttackTimeRatio(0.f);
  9177. }
  9178.  
  9179. protected function DoAttack(animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float)
  9180. {
  9181. var shakeStr : float;
  9182. var weapon : EPlayerWeapon;
  9183. var targetActor : CActor;
  9184.  
  9185.  
  9186. if ( animData.attackName == 'attack_heavy_special' )
  9187. {
  9188. if( specialAttackTimeRatio != 1 )
  9189. shakeStr = (specialAttackTimeRatio / 3.333) + 0.2;
  9190. else
  9191. shakeStr = 0.5;
  9192.  
  9193. GCameraShake( shakeStr, false, GetWorldPosition(), 10);
  9194. }
  9195. else if ( IsHeavyAttack(attackActionName) )
  9196. {
  9197. if(parriedBy.Size() > 0)
  9198. shakeStr = 0.2;
  9199. else
  9200. shakeStr = 0.1;
  9201.  
  9202. GCameraShake(shakeStr, false, GetWorldPosition(), 10);
  9203. }
  9204.  
  9205. targetActor = (CActor)slideTarget;
  9206. if ( targetActor && hitTargets.Contains(targetActor) )
  9207. {
  9208. weapon = this.GetMostConvenientMeleeWeapon(targetActor,true);
  9209. if ( this.GetCurrentMeleeWeaponType() != PW_Fists && weapon != this.GetCurrentMeleeWeaponType() )
  9210. {
  9211. if ( weapon == PW_Steel )
  9212. {
  9213. thePlayer.OnEquipMeleeWeapon(PW_Steel,true);
  9214. }
  9215. else if ( weapon == PW_Silver )
  9216. {
  9217. thePlayer.OnEquipMeleeWeapon(PW_Silver,true);
  9218. }
  9219.  
  9220. }
  9221. }
  9222.  
  9223. super.DoAttack(animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime);
  9224. }
  9225.  
  9226.  
  9227.  
  9228. private var confirmCombatStanceTimeStamp : float;
  9229. private var isConfirmingCombatStance : bool;
  9230. final function SetPlayerCombatStance(stance : EPlayerCombatStance, optional force : bool )
  9231. {
  9232. var stanceInt : int;
  9233.  
  9234. if ( !CanChangeCombatStance( stance, force ) )
  9235. return;
  9236.  
  9237. combatStance = stance;
  9238. stanceInt = (int)stance;
  9239.  
  9240. SetBehaviorVariable( 'playerCombatStance' , (float)stanceInt);
  9241. SetBehaviorVariable( 'playerCombatStanceForOverlay' , (float)stanceInt);
  9242. if ( force )
  9243. SetBehaviorVariable( 'forceCombatStance' , 1.f);
  9244. else
  9245. SetBehaviorVariable( 'forceCombatStance' , 0.f);
  9246.  
  9247. if ( stance == PCS_AlertNear )
  9248. this.SetBehaviorVariable('isInCombatForOverlay',1.f);
  9249. else
  9250. this.SetBehaviorVariable('isInCombatForOverlay',0.f);
  9251. }
  9252.  
  9253. private function CanChangeCombatStance( stance : EPlayerCombatStance, optional force : bool ) : bool
  9254. {
  9255. var currTime : float;
  9256.  
  9257. if ( force )
  9258. return true;
  9259.  
  9260. if ( IsInFistFightMiniGame() )
  9261. return true;
  9262.  
  9263. if ( isInHolsterAnim )
  9264. return false;
  9265.  
  9266. /*
  9267. if ( ( combatStance == PCS_Normal || combatStance == PCS_AlertFar ) && stance == PCS_AlertNear )
  9268. {
  9269. currTime = theGame.GetEngineTimeAsSeconds();
  9270. if ( !isConfirmingCombatStance )
  9271. {
  9272. isConfirmingCombatStance = true;
  9273. confirmCombatStanceTimeStamp = currTime;
  9274.  
  9275. return false;
  9276. }
  9277. else if ( currTime < confirmCombatStanceTimeStamp + 1.f )
  9278. {
  9279. if ( stance == PCS_AlertNear )
  9280. return false;
  9281. }
  9282. else
  9283. isConfirmingCombatStance = false;
  9284. }
  9285. else
  9286. isConfirmingCombatStance = false;
  9287. */ //modCombatStance: remove the delay
  9288.  
  9289. return true;
  9290. }
  9291.  
  9292. private var isInHolsterAnim : bool;
  9293. event OnHolsterWeaponStart()
  9294. {
  9295. isInHolsterAnim = true;
  9296. AddTimer('ResetIsInHolsterAnim', 5.0f, false, , , , true); //modCombatStance: fix a bug with isInHolsterAnim never resetting after some of the cutscenes
  9297. }
  9298.  
  9299. event OnHolsterWeaponEnd()
  9300. {
  9301. isInHolsterAnim = false;
  9302. }
  9303.  
  9304. //modCombatStance begin
  9305. timer function ResetIsInHolsterAnim( time : float , id : int)
  9306. {
  9307. isInHolsterAnim = false;
  9308. }
  9309. //modCombatStance end
  9310.  
  9311. final function GetPlayerCombatStance() : EPlayerCombatStance
  9312. {
  9313. return combatStance;
  9314. }
  9315.  
  9316. timer function DelayedDisableFindTarget( time : float , id : int)
  9317. {
  9318. if ( GetTarget().IsAlive() )
  9319. {
  9320. EnableFindTarget( false );
  9321. }
  9322. else
  9323. {
  9324. EnableFindTarget( true );
  9325. }
  9326. }
  9327.  
  9328.  
  9329.  
  9330.  
  9331.  
  9332. private var dodgeTimerRunning : bool;
  9333.  
  9334. function StartDodgeTimer()
  9335. {
  9336. dodgeTimerRunning = true;
  9337. thePlayer.AddTimer('DodgeTimer',0.2,false);
  9338. }
  9339.  
  9340. function StopDodgeTimer()
  9341. {
  9342. this.RemoveTimer('DodgeTimer');
  9343. dodgeTimerRunning = false;
  9344. }
  9345.  
  9346. function IsDodgeTimerRunning() : bool
  9347. {
  9348. return dodgeTimerRunning;
  9349. }
  9350.  
  9351. timer function DodgeTimer( dt : float, id : int )
  9352. {
  9353. dodgeTimerRunning = false;
  9354. }
  9355.  
  9356. public function EvadePressed( bufferAction : EBufferActionType )
  9357. {
  9358. }
  9359.  
  9360. public function PerformingCombatAction() : EBufferActionType
  9361. {
  9362. return BufferCombatAction;
  9363. }
  9364.  
  9365. public function PushCombatActionOnBuffer( action : EBufferActionType, stage : EButtonStage, optional allSteps : bool )
  9366. {
  9367. BufferButtonStage = stage;
  9368. BufferCombatAction = action;
  9369. BufferAllSteps = allSteps;
  9370. }
  9371.  
  9372. protected function ProcessCombatActionHeading( action : EBufferActionType ) : float
  9373. {
  9374. var processedActionHeading : float;
  9375.  
  9376. HandleMovement( 0.f );
  9377.  
  9378. if ( ShouldUsePCModeTargeting() )
  9379. return theGame.GetGameCamera().GetHeading();
  9380.  
  9381. if ( lAxisReleasedAfterCounter )
  9382. ResetCachedRawPlayerHeading();
  9383.  
  9384. processedActionHeading = cachedRawPlayerHeading;
  9385.  
  9386. return processedActionHeading;
  9387. }
  9388.  
  9389.  
  9390. function ResetRawPlayerHeading()
  9391. {
  9392. if ( GetDisplayTarget() )
  9393. rawPlayerHeading = VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() );
  9394. else
  9395. rawPlayerHeading = GetHeading();
  9396.  
  9397.  
  9398. }
  9399.  
  9400. function ResetCachedRawPlayerHeading()
  9401. {
  9402. cachedRawPlayerHeading = rawPlayerHeading;
  9403. if ( GetDisplayTarget() && IsDisplayTargetTargetable() && AbsF( AngleDistance( VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() ), this.GetHeading() ) ) < 90.f )
  9404. cachedRawPlayerHeading = VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() );
  9405. else
  9406. cachedRawPlayerHeading = this.GetHeading();
  9407.  
  9408. if ( canResetCachedCombatActionHeading )
  9409. cachedCombatActionHeading = cachedRawPlayerHeading;
  9410. }
  9411.  
  9412. public function GetCombatActionTarget( action : EBufferActionType ) : CGameplayEntity
  9413. {
  9414. var selectedTargetableEntity : CGameplayEntity;
  9415.  
  9416. if ( !this.IsUsingVehicle() )
  9417. selectedTargetableEntity = FindNonActorTarget( true, action );
  9418.  
  9419. if ( selectedTargetableEntity )
  9420. {
  9421. return selectedTargetableEntity;
  9422. }
  9423. else
  9424. {
  9425.  
  9426.  
  9427. if ( !this.IsUsingVehicle() )
  9428. FindTarget( true, action, true );
  9429. else
  9430. ((CR4PlayerStateUseGenericVehicle)this.GetState( 'UseGenericVehicle' )).FindTarget();
  9431.  
  9432. return GetTarget();
  9433. }
  9434. }
  9435.  
  9436.  
  9437. private function FindNonActorTarget( actionCheck : bool, optional action : EBufferActionType ) : CGameplayEntity
  9438. {
  9439. var targetableEntities : array<CGameplayEntity>;
  9440. var selectedTargetableEntity : CGameplayEntity;
  9441. var selectionPriority : array< float >;
  9442. var selectionWeights : STargetSelectionWeights;
  9443. var findEntityDist : float;
  9444. var i, size : int;
  9445. var playerHeading : float;
  9446. var playerInventory : CInventoryComponent;
  9447. var castSignType : ESignType;
  9448. var targetingInfo : STargetingInfo;
  9449. var playerPosition : Vector;
  9450. var cameraPosition : Vector;
  9451. var playerHeadingVector : Vector;
  9452. var rawPlayerHeadingVector : Vector;
  9453.  
  9454. playerPosition = this.GetWorldPosition();
  9455. cameraPosition = theCamera.GetCameraPosition();
  9456. rawPlayerHeadingVector = VecFromHeading( rawPlayerHeading );
  9457.  
  9458. if ( bCanFindTarget && !IsHardLockEnabled() )
  9459. {
  9460. if ( actionCheck && IsInCombat() && action == EBAT_CastSign )
  9461. {
  9462. findEntityDist = 6.f;
  9463. selectionWeights.angleWeight = 0.375f;
  9464. selectionWeights.distanceWeight = 0.275f;
  9465. selectionWeights.distanceRingWeight = 0.35f;
  9466. }
  9467. else if ( !IsInCombat() && lastAxisInputIsMovement )
  9468. {
  9469. findEntityDist = softLockDist;
  9470. selectionWeights.angleWeight = 0.375f;
  9471. selectionWeights.distanceWeight = 0.275f;
  9472. selectionWeights.distanceRingWeight = 0.35f;
  9473. }
  9474. else
  9475. {
  9476. findEntityDist = softLockDist;
  9477. selectionWeights.angleWeight = 0.75f;
  9478. selectionWeights.distanceWeight = 0.125f;
  9479. selectionWeights.distanceRingWeight = 0.125f;
  9480. }
  9481.  
  9482.  
  9483. if ( !IsInCombat() || !bLAxisReleased )
  9484. {
  9485. FindGameplayEntitiesInRange( targetableEntities, this, findEntityDist, 10, theGame.params.TAG_SOFT_LOCK );
  9486. }
  9487.  
  9488. if ( targetableEntities.Size() > 0 )
  9489. {
  9490. playerInventory = this.GetInventory();
  9491. castSignType = this.GetEquippedSign();
  9492.  
  9493. if ( !bLAxisReleased )
  9494. {
  9495. targetingInfo.source = this;
  9496. targetingInfo.canBeTargetedCheck = false;
  9497. targetingInfo.coneCheck = true;
  9498. targetingInfo.coneHalfAngleCos = 0.5f;
  9499. targetingInfo.coneDist = softLockDist;
  9500. targetingInfo.coneHeadingVector = rawPlayerHeadingVector;
  9501. targetingInfo.distCheck = true;
  9502. targetingInfo.invisibleCheck = false;
  9503. targetingInfo.navMeshCheck = false;
  9504. targetingInfo.frameScaleX = 1.0f;
  9505. targetingInfo.frameScaleY = 1.0f;
  9506. targetingInfo.knockDownCheck = false;
  9507. targetingInfo.knockDownCheckDist = 0.0f;
  9508. targetingInfo.rsHeadingCheck = false;
  9509. targetingInfo.rsHeadingLimitCos = 1.0f;
  9510. }
  9511.  
  9512. for( i = targetableEntities.Size()-1; i>=0; i-=1 )
  9513. {
  9514. if ( bLAxisReleased )
  9515. {
  9516. if ( !lastAxisInputIsMovement )
  9517. {
  9518. if ( !WasVisibleInScaledFrame( targetableEntities[i], 0.9f, 0.9f ) )
  9519. {
  9520. targetableEntities.Erase(i);
  9521. continue;
  9522. }
  9523. }
  9524. else if ( !WasVisibleInScaledFrame( targetableEntities[i], 1.f, 1.f ) )
  9525. {
  9526. targetableEntities.Erase(i);
  9527. continue;
  9528. }
  9529. }
  9530. else
  9531. {
  9532. targetingInfo.targetEntity = targetableEntities[i];
  9533. if ( actionCheck && moveTarget )
  9534. {
  9535. targetingInfo.inFrameCheck = false;
  9536. if ( !IsEntityTargetable( targetingInfo ) )
  9537. {
  9538. targetableEntities.Erase(i);
  9539. continue;
  9540. }
  9541. }
  9542. else
  9543. {
  9544. targetingInfo.inFrameCheck = true;
  9545. if ( !IsEntityTargetable( targetingInfo ) )
  9546. {
  9547. targetableEntities.Erase(i);
  9548. continue;
  9549. }
  9550. }
  9551. }
  9552.  
  9553. if ( actionCheck )
  9554. {
  9555. if ( action == EBAT_ItemUse )
  9556. {
  9557. if ( ( playerInventory.IsItemBomb( this.GetSelectedItemId() ) && !targetableEntities[i].HasTag( 'softLock_Bomb' ) )
  9558. || ( playerInventory.IsItemCrossbow( this.GetSelectedItemId() ) && !targetableEntities[i].HasTag( 'softLock_Bolt' ) ) )
  9559. {
  9560. targetableEntities.Erase(i);
  9561. continue;
  9562. }
  9563. }
  9564. else if ( action == EBAT_CastSign )
  9565. {
  9566. if ( ( castSignType == ST_Aard && !targetableEntities[i].HasTag( 'softLock_Aard' ) )
  9567. || ( castSignType == ST_Igni && !targetableEntities[i].HasTag( 'softLock_Igni' ) )
  9568. || ( castSignType == ST_Axii && !targetableEntities[i].HasTag( 'softLock_Axii' ) )
  9569. || castSignType == ST_Yrden
  9570. || castSignType == ST_Quen )
  9571. {
  9572. targetableEntities.Erase(i);
  9573. continue;
  9574. }
  9575. }
  9576. else if ( action == EBAT_LightAttack || action == EBAT_HeavyAttack || action == EBAT_SpecialAttack_Heavy )
  9577. {
  9578. if ( ( IsWeaponHeld( 'fist' ) && !targetableEntities[i].HasTag( 'softLock_Fist' ) ) || ( !IsWeaponHeld( 'fist' ) && !targetableEntities[i].HasTag( 'softLock_Weapon' ) ) )
  9579. {
  9580. targetableEntities.Erase(i);
  9581. continue;
  9582. }
  9583. }
  9584. else
  9585. {
  9586. targetableEntities.Erase(i);
  9587. continue;
  9588. }
  9589. }
  9590. }
  9591. }
  9592.  
  9593. if ( targetableEntities.Size() > 0)
  9594. {
  9595. playerHeading = this.GetHeading();
  9596. playerHeadingVector = this.GetHeadingVector();
  9597. if ( IsInCombat() )
  9598. {
  9599. for( i = 0; i < targetableEntities.Size(); i += 1 )
  9600. {
  9601. if ( bLAxisReleased )
  9602. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, cameraPosition, rawPlayerHeadingVector ) );
  9603. else
  9604. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, rawPlayerHeadingVector ) );
  9605. }
  9606.  
  9607. if ( selectionPriority.Size() > 0 )
  9608. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  9609. }
  9610. else
  9611. {
  9612. if ( bLAxisReleased )
  9613. {
  9614. if ( !lastAxisInputIsMovement )
  9615. {
  9616. for( i = 0; i < targetableEntities.Size(); i += 1 )
  9617. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, cameraPosition, rawPlayerHeadingVector ) );
  9618.  
  9619. if ( selectionPriority.Size() > 0 )
  9620. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  9621. }
  9622. else
  9623. {
  9624. if ( IsInCombatAction() )
  9625. selectedTargetableEntity = nonActorTarget;
  9626. else
  9627. {
  9628. for( i = 0; i < targetableEntities.Size(); i += 1 )
  9629. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, playerHeadingVector ) );
  9630.  
  9631. if ( selectionPriority.Size() > 0 )
  9632. {
  9633. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  9634.  
  9635. targetingInfo.source = this;
  9636. targetingInfo.targetEntity = selectedTargetableEntity;
  9637. targetingInfo.canBeTargetedCheck = false;
  9638. targetingInfo.coneCheck = true;
  9639. targetingInfo.coneHalfAngleCos = 0.0f;
  9640. targetingInfo.coneDist = softLockDist;
  9641. targetingInfo.coneHeadingVector = this.GetHeadingVector();
  9642. targetingInfo.distCheck = true;
  9643. targetingInfo.invisibleCheck = false;
  9644. targetingInfo.navMeshCheck = false;
  9645. targetingInfo.inFrameCheck = false;
  9646. targetingInfo.frameScaleX = 1.0f;
  9647. targetingInfo.frameScaleY = 1.0f;
  9648. targetingInfo.knockDownCheck = false;
  9649. targetingInfo.knockDownCheckDist = 0.0f;
  9650. targetingInfo.rsHeadingCheck = false;
  9651. targetingInfo.rsHeadingLimitCos = 1.0f;
  9652.  
  9653. if ( !IsEntityTargetable( targetingInfo ) )
  9654. selectedTargetableEntity = NULL;
  9655. }
  9656. }
  9657. }
  9658. }
  9659. else
  9660. {
  9661. for( i = 0; i < targetableEntities.Size(); i += 1 )
  9662. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, rawPlayerHeadingVector ) );
  9663.  
  9664. if ( selectionPriority.Size() > 0 )
  9665. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  9666. }
  9667. }
  9668. }
  9669. else
  9670. selectedTargetableEntity = NULL;
  9671. }
  9672.  
  9673. SetNonActorTarget( selectedTargetableEntity );
  9674. return selectedTargetableEntity;
  9675. }
  9676.  
  9677.  
  9678. public function SetupCombatAction( action : EBufferActionType, stage : EButtonStage )
  9679. {
  9680. var weaponType : EPlayerWeapon;
  9681. var canAttackTarget : CGameplayEntity;
  9682. var target : CActor;
  9683.  
  9684.  
  9685. if ( !IsCombatMusicEnabled() )
  9686. {
  9687. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  9688. FindTarget();
  9689. UpdateDisplayTarget( true );
  9690. }
  9691.  
  9692. if ( displayTarget && IsDisplayTargetTargetable() )
  9693. canAttackTarget = displayTarget;
  9694. else if ( GetTarget() )
  9695. canAttackTarget = GetTarget();
  9696. else if( !target && IsCombatMusicEnabled() )
  9697. canAttackTarget = moveTarget;
  9698.  
  9699. target = (CActor)canAttackTarget;
  9700.  
  9701. if ( !AllowAttack( target, action ) )
  9702. return;
  9703.  
  9704. if( ( action != EBAT_ItemUse ) && ( action != EBAT_CastSign ) )
  9705. {
  9706. weaponType = weaponHolster.GetCurrentMeleeWeapon();
  9707. PrepareToAttack( target, action );
  9708.  
  9709.  
  9710. if ( weaponType != weaponHolster.GetCurrentMeleeWeapon() )
  9711. {
  9712.  
  9713. if ( !( weaponType == PW_None && weaponHolster.GetCurrentMeleeWeapon() == PW_Fists ) )
  9714. return;
  9715. }
  9716. }
  9717.  
  9718.  
  9719. if(action == EBAT_SpecialAttack_Heavy && !((W3ReplacerCiri)this) )
  9720. thePlayer.SetAttackActionName(SkillEnumToName(S_Sword_s02));
  9721.  
  9722. CriticalEffectAnimationInterrupted("SetupCombatAction " + action);
  9723. PushCombatActionOnBuffer( action, stage );
  9724.  
  9725. if( GetBIsCombatActionAllowed() )
  9726. {
  9727. ProcessCombatActionBuffer();
  9728. }
  9729. }
  9730.  
  9731. public function AllowAttack( target : CActor, action : EBufferActionType ) : bool
  9732. {
  9733. var newTarget : CActor;
  9734. var canAttackWhenNotInCombat : bool;
  9735. var messageDisplayed : bool;
  9736.  
  9737. var itemId : SItemUniqueId;
  9738. var isShootingCrossbow : bool;
  9739.  
  9740. var isInCorrectState : bool;
  9741.  
  9742. if ( target )
  9743. {
  9744. if ( target.IsTargetableByPlayer())
  9745. {
  9746. if ( !target.IsAttackableByPlayer() )
  9747. {
  9748. DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_cant_attack_this_target"));
  9749. return false;
  9750. }
  9751. }
  9752. }
  9753.  
  9754. if ( this.GetCurrentStateName() == 'Exploration' )
  9755. isInCorrectState = true;
  9756.  
  9757. if ( action == EBAT_ItemUse )
  9758. {
  9759. itemId = thePlayer.GetSelectedItemId();
  9760. if ( inv.IsIdValid(itemId) && inv.IsItemCrossbow(itemId) )
  9761. isShootingCrossbow = true;
  9762.  
  9763. if ( !isInCorrectState )
  9764. {
  9765. if ( this.GetCurrentStateName() == 'AimThrow' && !isShootingCrossbow )
  9766. {
  9767. isInCorrectState = true;
  9768. }
  9769. }
  9770. }
  9771.  
  9772. if ( isInCorrectState )
  9773. canAttackWhenNotInCombat = thePlayer.CanAttackWhenNotInCombat( action, false, newTarget, target );
  9774.  
  9775. if( !target )
  9776. {
  9777. if ( isInCorrectState )
  9778. {
  9779. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  9780. target = newTarget;
  9781. }
  9782. }
  9783.  
  9784. if ( isInCorrectState )
  9785. {
  9786. if ( !canAttackWhenNotInCombat )
  9787. {
  9788. if ( DisplayCannotAttackMessage( target ) )
  9789. messageDisplayed = true;
  9790. else if ( ( action == EBAT_LightAttack || action == EBAT_HeavyAttack )
  9791. && !RaiseAttackFriendlyEvent( target ) )
  9792. messageDisplayed = true;
  9793. else
  9794. {
  9795. if ( !CanRaiseCombatActionFriendlyEvent( isShootingCrossbow ) )
  9796. messageDisplayed = true;
  9797. }
  9798. }
  9799.  
  9800. if ( messageDisplayed )
  9801. {
  9802. theInput.ForceDeactivateAction('ThrowItem');
  9803. theInput.ForceDeactivateAction('ThrowItemHold');
  9804. this.SignalGameplayEvent( 'FriendlyAttackAction' );
  9805. return false;
  9806. }
  9807. }
  9808.  
  9809. return true;
  9810. }
  9811.  
  9812.  
  9813.  
  9814. public function ProcessCombatActionBuffer() : bool
  9815. {
  9816. var actionResult : bool;
  9817. var action : EBufferActionType = this.BufferCombatAction;
  9818. var stage : EButtonStage = this.BufferButtonStage;
  9819. var s : SNotWorkingOutFunctionParametersHackStruct1;
  9820. var allSteps : bool = this.BufferAllSteps;
  9821.  
  9822. if ( IsInCombatActionFriendly() )
  9823. {
  9824. RaiseEvent('CombatActionFriendlyEnd');
  9825. }
  9826.  
  9827.  
  9828. if ( ( action != EBAT_SpecialAttack_Heavy && action != EBAT_ItemUse )
  9829. || ( action == EBAT_SpecialAttack_Heavy && stage == BS_Pressed )
  9830. || ( action == EBAT_ItemUse && stage != BS_Released ) )
  9831. {
  9832. GetMovingAgentComponent().GetMovementAdjustor().CancelAll();
  9833. SetUnpushableTarget( NULL );
  9834. }
  9835.  
  9836.  
  9837. if ( !( action == EBAT_Dodge || action == EBAT_Roll ) )
  9838. {
  9839. SetIsCurrentlyDodging(false);
  9840. }
  9841.  
  9842. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  9843.  
  9844.  
  9845.  
  9846. if ( action == EBAT_ItemUse && GetInventory().IsItemCrossbow( selectedItemId ) )
  9847. {
  9848.  
  9849. if ( rangedWeapon
  9850. && ( ( rangedWeapon.GetCurrentStateName() != 'State_WeaponShoot' && rangedWeapon.GetCurrentStateName() != 'State_WeaponAim' ) || GetIsShootingFriendly() ) )
  9851. {
  9852. SetSlideTarget( GetCombatActionTarget( action ) );
  9853. }
  9854. }
  9855. else if ( !( ( action == EBAT_SpecialAttack_Heavy && stage == BS_Released ) || GetCurrentStateName() == 'AimThrow' ) )
  9856. {
  9857. SetSlideTarget( GetCombatActionTarget( action ) );
  9858. }
  9859.  
  9860. if( !slideTarget )
  9861. LogChannel( 'Targeting', "NO SLIDE TARGET" );
  9862.  
  9863.  
  9864. actionResult = true;
  9865.  
  9866. switch ( action )
  9867. {
  9868. case EBAT_EMPTY :
  9869. {
  9870. this.BufferAllSteps = false;
  9871. return true;
  9872. } break;
  9873.  
  9874. case EBAT_LightAttack :
  9875. {
  9876. if ( IsCiri() )
  9877. return false;
  9878.  
  9879. switch ( stage )
  9880. {
  9881. case BS_Pressed :
  9882. {
  9883.  
  9884.  
  9885.  
  9886.  
  9887.  
  9888.  
  9889. DrainStamina(ESAT_LightAttack);
  9890.  
  9891.  
  9892. thePlayer.BreakPheromoneEffect();
  9893. actionResult = OnPerformAttack(theGame.params.ATTACK_NAME_LIGHT);
  9894.  
  9895. } break;
  9896.  
  9897. default :
  9898. {
  9899. actionResult = false;
  9900. }break;
  9901. }
  9902. }break;
  9903.  
  9904. case EBAT_HeavyAttack :
  9905. {
  9906. if ( IsCiri() )
  9907. return false;
  9908.  
  9909. switch ( stage )
  9910. {
  9911. case BS_Released :
  9912. {
  9913.  
  9914.  
  9915.  
  9916.  
  9917.  
  9918. DrainStamina(ESAT_HeavyAttack);
  9919.  
  9920.  
  9921.  
  9922. thePlayer.BreakPheromoneEffect();
  9923. actionResult = this.OnPerformAttack(theGame.params.ATTACK_NAME_HEAVY);
  9924.  
  9925. } break;
  9926.  
  9927. case BS_Pressed :
  9928. {
  9929. if ( this.GetCurrentStateName() == 'CombatFists' )
  9930. {
  9931.  
  9932.  
  9933.  
  9934.  
  9935.  
  9936. DrainStamina(ESAT_HeavyAttack);
  9937.  
  9938.  
  9939.  
  9940. thePlayer.BreakPheromoneEffect();
  9941. actionResult = this.OnPerformAttack(theGame.params.ATTACK_NAME_HEAVY);
  9942.  
  9943. }
  9944. } break;
  9945.  
  9946. default :
  9947. {
  9948. actionResult = false;
  9949.  
  9950. } break;
  9951. }
  9952. } break;
  9953.  
  9954. case EBAT_ItemUse :
  9955. {
  9956. switch ( stage )
  9957. {
  9958. case BS_Pressed :
  9959. {
  9960. if ( !( (W3PlayerWitcher)this ) ||
  9961. ( !IsInCombatActionFriendly() && !( !GetBIsCombatActionAllowed() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign ) ) ) )
  9962.  
  9963. {
  9964. if ( inv.IsItemCrossbow( selectedItemId ) )
  9965. {
  9966. rangedWeapon = ( Crossbow )( inv.GetItemEntityUnsafe( selectedItemId ) );
  9967. rangedWeapon.OnRangedWeaponPress();
  9968. GetTarget().SignalGameplayEvent( 'Approach' );
  9969. GetTarget().SignalGameplayEvent( 'ShootingCrossbow' );
  9970. }
  9971. else if(inv.IsItemBomb(selectedItemId) && this.inv.SingletonItemGetAmmo(selectedItemId) > 0 )
  9972. {
  9973. if( ((W3PlayerWitcher)this).GetBombDelay( ((W3PlayerWitcher)this).GetItemSlot( selectedItemId ) ) <= 0.0f )
  9974. {
  9975. BombThrowStart();
  9976. GetTarget().SignalGameplayEvent( 'Approach' );
  9977. }
  9978. }
  9979. else
  9980. {
  9981. DrainStamina(ESAT_UsableItem);
  9982. UsableItemStart();
  9983. }
  9984. }
  9985.  
  9986. } if (!allSteps) break;
  9987.  
  9988. case BS_Released:
  9989. {
  9990. if ( !( (W3PlayerWitcher)this ) ||
  9991. ( !IsInCombatActionFriendly() && ( GetBIsCombatActionAllowed() || !( !GetBIsCombatActionAllowed() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign ) ) ) ) )
  9992.  
  9993. {
  9994. if ( inv.IsItemCrossbow( selectedItemId ) )
  9995. {
  9996.  
  9997. rangedWeapon.OnRangedWeaponRelease();
  9998. }
  9999. else if(inv.IsItemBomb(selectedItemId))
  10000. {
  10001. BombThrowRelease();
  10002. }
  10003. else
  10004. {
  10005. UsableItemRelease();
  10006. }
  10007. }
  10008. } break;
  10009.  
  10010. default :
  10011. {
  10012. actionResult = false;
  10013. break;
  10014. }
  10015. }
  10016. } break;
  10017.  
  10018. case EBAT_Dodge :
  10019. {
  10020. switch ( stage )
  10021. {
  10022. case BS_Released :
  10023. {
  10024. theGame.GetBehTreeReactionManager().CreateReactionEvent( this, 'PlayerEvade', 1.0f, 10.0f, -1.0f, -1 );
  10025. thePlayer.BreakPheromoneEffect();
  10026. actionResult = this.OnPerformEvade( PET_Dodge );
  10027. } break;
  10028.  
  10029.  
  10030.  
  10031. default :
  10032. {
  10033. actionResult = false;
  10034. } break;
  10035. }
  10036. } break;
  10037.  
  10038. case EBAT_Roll :
  10039. {
  10040. if ( IsCiri() )
  10041. return false;
  10042.  
  10043. switch ( stage )
  10044. {
  10045. case BS_Released :
  10046. {
  10047. theGame.GetBehTreeReactionManager().CreateReactionEvent( this, 'PlayerEvade', 1.0f, 10.0f, -1.0f, -1 );
  10048. thePlayer.BreakPheromoneEffect();
  10049. actionResult = this.OnPerformEvade( PET_Roll );
  10050. } break;
  10051.  
  10052. case BS_Pressed :
  10053. {
  10054. if ( this.GetBehaviorVariable( 'combatActionType' ) == 2.f )
  10055. {
  10056. if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
  10057. actionResult = this.OnPerformEvade( PET_Pirouette );
  10058. else
  10059. actionResult = this.OnPerformEvade( PET_Roll );
  10060. }
  10061. else
  10062. {
  10063. if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
  10064. {
  10065. actionResult = this.OnPerformEvade( PET_Dodge );
  10066. actionResult = this.OnPerformEvade( PET_Pirouette );
  10067. }
  10068. else
  10069. {
  10070. actionResult = this.OnPerformEvade( PET_Dodge );
  10071. actionResult = this.OnPerformEvade( PET_Roll );
  10072. }
  10073. }
  10074.  
  10075.  
  10076. } break;
  10077.  
  10078. default :
  10079. {
  10080. actionResult = false;
  10081. } break;
  10082. }
  10083. } break;
  10084.  
  10085. case EBAT_Draw_Steel :
  10086. {
  10087. switch ( stage )
  10088. {
  10089. case BS_Pressed :
  10090. {
  10091. if( !IsActionAllowed(EIAB_DrawWeapon) )
  10092. {
  10093. thePlayer.DisplayActionDisallowedHudMessage(EIAB_DrawWeapon);
  10094. actionResult = false;
  10095. break;
  10096. }
  10097. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'steelsword' ) )
  10098. {
  10099. OnEquipMeleeWeapon( PW_Steel, false, true );
  10100. }
  10101.  
  10102. actionResult = false;
  10103.  
  10104. } break;
  10105.  
  10106. default :
  10107. {
  10108. actionResult = false;
  10109. } break;
  10110. }
  10111. } break;
  10112.  
  10113. case EBAT_Draw_Silver :
  10114. {
  10115. switch ( stage )
  10116. {
  10117. case BS_Pressed :
  10118. {
  10119. if( !IsActionAllowed(EIAB_DrawWeapon) )
  10120. {
  10121. thePlayer.DisplayActionDisallowedHudMessage(EIAB_DrawWeapon);
  10122. actionResult = false;
  10123. break;
  10124. }
  10125. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'silversword' ) )
  10126. {
  10127. OnEquipMeleeWeapon( PW_Silver, false, true );
  10128. }
  10129.  
  10130. actionResult = false;
  10131.  
  10132. } break;
  10133.  
  10134. default :
  10135. {
  10136. actionResult = false;
  10137. } break;
  10138. }
  10139. } break;
  10140.  
  10141. case EBAT_Sheathe_Sword :
  10142. {
  10143. switch ( stage )
  10144. {
  10145. case BS_Pressed :
  10146. {
  10147. if( GetCurrentMeleeWeaponType() == PW_Silver )
  10148. {
  10149. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'silversword' ) )
  10150. {
  10151. OnEquipMeleeWeapon( PW_Silver, false, true );
  10152. }
  10153. }
  10154. else if( GetCurrentMeleeWeaponType() == PW_Steel )
  10155. {
  10156. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'steelsword' ) )
  10157. {
  10158. OnEquipMeleeWeapon( PW_Steel, false, true );
  10159. }
  10160. }
  10161.  
  10162. actionResult = false;
  10163.  
  10164. } break;
  10165.  
  10166. default :
  10167. {
  10168. actionResult = false;
  10169. } break;
  10170. }
  10171. } break;
  10172.  
  10173. default:
  10174. return false;
  10175. }
  10176.  
  10177.  
  10178. CleanCombatActionBuffer();
  10179.  
  10180. if (actionResult)
  10181. {
  10182. SetCombatAction( action ) ;
  10183.  
  10184. if(GetWitcherPlayer().IsInFrenzy())
  10185. GetWitcherPlayer().SkillFrenzyFinish(0);
  10186. }
  10187.  
  10188. return true;
  10189. }
  10190.  
  10191. public function CleanCombatActionBuffer()
  10192. {
  10193. BufferCombatAction = EBAT_EMPTY;
  10194. BufferAllSteps = false;
  10195. }
  10196.  
  10197. public function CancelHoldAttacks()
  10198. {
  10199. RemoveTimer( 'IsSpecialLightAttackInputHeld' );
  10200. RemoveTimer( 'IsSpecialHeavyAttackInputHeld' );
  10201. RemoveTimer( 'SpecialAttackLightSustainCost' );
  10202. RemoveTimer( 'SpecialAttackHeavySustainCost' );
  10203. RemoveTimer( 'UpdateSpecialAttackLightHeading' );
  10204. UnblockAction( EIAB_Crossbow, 'SpecialAttack' );
  10205.  
  10206. ResumeStaminaRegen('WhirlSkill');
  10207.  
  10208. if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_SpecialAttack && GetBehaviorVariable( 'isPerformingSpecialAttack' ) == 1.f )
  10209. {
  10210. if( GetBehaviorVariable( 'playerAttackType' ) == (int)PAT_Light )
  10211. {
  10212. SetAttackActionName(SkillEnumToName(S_Sword_s01));
  10213. PushCombatActionOnBuffer( EBAT_SpecialAttack_Light, BS_Released );
  10214. ProcessCombatActionBuffer();
  10215.  
  10216. ((W3PlayerWitcherStateCombatFists) GetState('Combat')).ResetTimeToEndCombat();
  10217.  
  10218. }
  10219. else if( GetBehaviorVariable( 'playerAttackType' ) == (int)PAT_Heavy )
  10220. {
  10221. SetAttackActionName(SkillEnumToName(S_Sword_s02));
  10222. PushCombatActionOnBuffer( EBAT_SpecialAttack_Heavy, BS_Released );
  10223. ProcessCombatActionBuffer();
  10224.  
  10225. theGame.HapticStart( "haptic_rend_stop" );
  10226. }
  10227. }
  10228. }
  10229.  
  10230. public function RaiseAttackFriendlyEvent( actor : CActor ) : bool
  10231. {
  10232. var playerToTargetHeading : float;
  10233.  
  10234. if ( actor && RaiseCombatActionFriendlyEvent() )
  10235. {
  10236. SetBehaviorVariable( 'tauntTypeForOverlay', 0.f );
  10237. SetBehaviorVariable( 'combatActionTypeForOverlay', (int)CAT_Attack );
  10238.  
  10239. if ( actor )
  10240. actor.SignalGameplayEvent('PersonalTauntAction');
  10241. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'TauntAction', -1.0, 4.5f, -1, 9999, true );
  10242.  
  10243. OnCombatActionStart();
  10244.  
  10245. playerToTargetHeading = VecHeading( actor.GetWorldPosition() - GetWorldPosition() );
  10246.  
  10247. SetCustomRotation( 'Attack', playerToTargetHeading, 0.0f, 0.3f, false );
  10248.  
  10249. return true;
  10250. }
  10251.  
  10252. return false;
  10253. }
  10254.  
  10255. public function SendAttackReactionEvent()
  10256. {
  10257. var reactionName : name;
  10258.  
  10259.  
  10260.  
  10261. reactionName = 'AttackAction';
  10262.  
  10263. if ( IsNameValid(reactionName) )
  10264. {
  10265. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, reactionName, -1.0, 8.0f, -1, 5, true );
  10266. }
  10267.  
  10268.  
  10269. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'outOfMyWay', -1.0, 2.0f, -1, 5, true );
  10270. }
  10271.  
  10272. var forceCanAttackWhenNotInCombat : int;
  10273. public function SetForceCanAttackWhenNotInCombat( forceMode : int )
  10274. {
  10275. forceCanAttackWhenNotInCombat = forceMode;
  10276. }
  10277.  
  10278. public function CanAttackWhenNotInCombat( actionType : EBufferActionType, altCast : bool, out newTarget : CActor, optional target : CGameplayEntity ) : bool
  10279. {
  10280. var localTargets : array<CActor>;
  10281. var i, size : int;
  10282. var inputHeading : float;
  10283. var clearanceMin, clearanceMax : float;
  10284. var attackLength : float;
  10285. var attackAngle : float;
  10286. var npc : CNewNPC;
  10287. var canAttackTarget : CGameplayEntity;
  10288. var canAttackTargetActor : CActor;
  10289.  
  10290. if ( target )
  10291. canAttackTarget = target;
  10292. else if ( displayTarget && IsDisplayTargetTargetable() )
  10293. canAttackTarget = displayTarget;
  10294. else
  10295. canAttackTarget = slideTarget;
  10296.  
  10297. canAttackTargetActor = (CActor)canAttackTarget;
  10298.  
  10299. if ( forceCanAttackWhenNotInCombat == 2 )
  10300. return true;
  10301. else if ( forceCanAttackWhenNotInCombat == 1 && ( !canAttackTarget || !canAttackTargetActor.IsHuman() ) )
  10302. return true;
  10303.  
  10304. if ( actionType == EBAT_CastSign )
  10305. {
  10306. if ( thePlayer.GetEquippedSign() != ST_Quen && thePlayer.GetEquippedSign() != ST_Axii )
  10307. {
  10308. if ( CanUseSkill( S_Magic_s20 ) )
  10309. {
  10310. if ( thePlayer.GetEquippedSign() == ST_Aard )
  10311. attackLength = 6.f;
  10312. else if ( thePlayer.GetEquippedSign() == ST_Igni )
  10313. attackLength = 4.f;
  10314. else
  10315. attackLength = 6.f;
  10316. }
  10317. else
  10318. {
  10319. if ( thePlayer.GetEquippedSign() == ST_Aard )
  10320. attackLength = 9.f;
  10321. else if ( thePlayer.GetEquippedSign() == ST_Igni )
  10322. attackLength = 6.f;
  10323. else
  10324. attackLength = 6.f;
  10325. }
  10326.  
  10327. if ( altCast )
  10328. attackAngle = 180.f;
  10329. else
  10330.  
  10331. attackAngle = 90.f;
  10332.  
  10333. if ( !lastAxisInputIsMovement )
  10334. inputHeading = VecHeading( theCamera.GetCameraDirection() );
  10335. else if ( lAxisReleasedAfterCounter )
  10336. inputHeading = GetHeading();
  10337. else
  10338. inputHeading = GetCombatActionHeading();
  10339.  
  10340. clearanceMin = 1.f;
  10341. clearanceMax = attackLength + 1.f;
  10342. }
  10343. else if ( thePlayer.GetEquippedSign() == ST_Axii )
  10344. {
  10345. npc = (CNewNPC)canAttackTarget;
  10346. if ( npc && npc.GetNPCType() == ENGT_Quest && !npc.HasTag(theGame.params.TAG_AXIIABLE_LOWER_CASE) && !npc.HasTag(theGame.params.TAG_AXIIABLE))
  10347. return false;
  10348. else if ( npc && npc.IsUsingHorse() )
  10349. return false;
  10350. else
  10351. return true;
  10352. }
  10353. else
  10354. return true;
  10355. }
  10356. else if ( actionType == EBAT_ItemUse )
  10357. {
  10358. attackLength = theGame.params.MAX_THROW_RANGE;
  10359. attackAngle = 90.f;
  10360.  
  10361. if ( thePlayer.lastAxisInputIsMovement )
  10362. inputHeading = GetCombatActionHeading();
  10363. else
  10364. inputHeading = VecHeading( theCamera.GetCameraDirection() );
  10365.  
  10366. clearanceMin = 0.8f;
  10367. clearanceMax = attackLength + 3.f;
  10368. }
  10369. else
  10370. {
  10371. if ( actionType == EBAT_SpecialAttack_Light || actionType == EBAT_SpecialAttack_Heavy )
  10372. {
  10373. attackLength = 1.9f;
  10374. attackAngle = 90.f;
  10375. }
  10376. else
  10377. {
  10378. if( thePlayer.GetCurrentMeleeWeaponType() == PW_Fists || thePlayer.GetCurrentMeleeWeaponType() == PW_None )
  10379. attackLength = 1.2f;
  10380. else
  10381. attackLength = 1.9f;
  10382.  
  10383. attackAngle = 90.f;
  10384. }
  10385.  
  10386. if ( lastAxisInputIsMovement )
  10387. inputHeading = GetCombatActionHeading();
  10388. else
  10389. inputHeading = VecHeading( theCamera.GetCameraDirection() );
  10390.  
  10391. clearanceMin = attackLength / 2.f;
  10392. clearanceMax = attackLength + 3.f;
  10393. }
  10394.  
  10395.  
  10396. if ( canAttackTarget )
  10397. {
  10398. if ( ( canAttackTargetActor && canAttackTargetActor.IsHuman() ) || canAttackTargetActor.HasTag( 'softLock_Friendly' ) )
  10399. {
  10400. if ( ShouldPerformFriendlyAction( canAttackTargetActor, inputHeading, attackAngle, clearanceMin, clearanceMax ) )
  10401. {
  10402. SetSlideTarget( canAttackTargetActor );
  10403. newTarget = canAttackTargetActor;
  10404. return false;
  10405. }
  10406. }
  10407.  
  10408.  
  10409. }
  10410.  
  10411. return true;
  10412.  
  10413. thePlayer.GetVisibleEnemies( localTargets );
  10414. size = localTargets.Size();
  10415.  
  10416. if ( size > 0 )
  10417. {
  10418. for ( i = size-1; i>=0; i-=1 )
  10419. {
  10420.  
  10421. if ( !localTargets[i].IsHuman() && !localTargets[i].HasTag( 'softLock_Friendly' ) )
  10422. localTargets.Erase(i);
  10423. }
  10424. }
  10425.  
  10426. size = localTargets.Size();
  10427. if ( size > 0 )
  10428. {
  10429. for ( i = 0; i < localTargets.Size(); i += 1 )
  10430. {
  10431. if ( ShouldPerformFriendlyAction( localTargets[i], inputHeading, attackAngle, clearanceMin, clearanceMax ) )
  10432. {
  10433. SetSlideTarget( localTargets[i] );
  10434. newTarget = localTargets[i];
  10435. return false;
  10436. }
  10437. }
  10438. }
  10439.  
  10440. newTarget = NULL;
  10441.  
  10442. return true;
  10443. }
  10444.  
  10445. private function ShouldPerformFriendlyAction( actor : CActor, inputHeading, attackAngle, clearanceMin, clearanceMax : float ) : bool
  10446. {
  10447. var npc : CNewNPC;
  10448. var argh : float;
  10449. var playerToTargetDist : float;
  10450.  
  10451. npc = (CNewNPC)actor;
  10452.  
  10453. if ( npc && !npc.HasTag('force_friendly_action') && ( GetAttitudeBetween(thePlayer, npc) == AIA_Hostile || ( GetAttitudeBetween(thePlayer, npc) == AIA_Neutral && npc.GetNPCType() != ENGT_Guard ) ) )
  10454. {
  10455. }
  10456. else
  10457. {
  10458. playerToTargetDist = VecDistance( this.GetWorldPosition(), actor.PredictWorldPosition( 0.5f ) );
  10459.  
  10460. argh = AbsF( AngleDistance( inputHeading, VecHeading( actor.GetWorldPosition() - thePlayer.GetWorldPosition() ) ) );
  10461.  
  10462. if ( AbsF( AngleDistance( inputHeading, VecHeading( actor.GetWorldPosition() - thePlayer.GetWorldPosition() ) ) ) < attackAngle )
  10463. {
  10464. if ( playerToTargetDist < clearanceMax )
  10465. {
  10466. return true;
  10467. }
  10468. }
  10469. else
  10470. {
  10471. if ( playerToTargetDist < clearanceMin )
  10472. {
  10473. return true;
  10474. }
  10475. }
  10476. }
  10477.  
  10478. return false;
  10479. }
  10480.  
  10481.  
  10482.  
  10483.  
  10484.  
  10485. public function GetHudMessagesSize() : int
  10486. {
  10487. return HudMessages.Size();
  10488. }
  10489.  
  10490. public function GetHudPendingMessage() : string
  10491. {
  10492. return HudMessages[0];
  10493. }
  10494.  
  10495. public function DisplayHudMessage( value : string ) : void
  10496. {
  10497. if (value == "")
  10498. {
  10499. return;
  10500. }
  10501.  
  10502. if( GetHudMessagesSize() > 0 )
  10503. {
  10504. if( HudMessages[HudMessages.Size()-1] == value )
  10505. {
  10506. return;
  10507. }
  10508. }
  10509. HudMessages.PushBack(value);
  10510. }
  10511.  
  10512.  
  10513. private final function DisallowedActionDontShowHack(action : EInputActionBlock, isTimeLock : bool) : bool
  10514. {
  10515. var locks : array< SInputActionLock >;
  10516. var i : int;
  10517.  
  10518.  
  10519. if((action == EIAB_Fists || action == EIAB_SwordAttack || action == EIAB_Signs || action == EIAB_LightAttacks || action == EIAB_HeavyAttacks || action == EIAB_SpecialAttackLight || action == EIAB_SpecialAttackHeavy) && (HasBuff(EET_Stagger) || HasBuff(EET_LongStagger)) )
  10520. {
  10521. return true;
  10522. }
  10523.  
  10524.  
  10525. if( action == EIAB_ThrowBomb && ( HasBuff( EET_Hypnotized ) || HasBuff( EET_Confusion ) ) )
  10526. {
  10527. return false;
  10528. }
  10529.  
  10530.  
  10531. if(isTimeLock)
  10532. return false;
  10533.  
  10534.  
  10535. if(action == EIAB_OpenMeditation)
  10536. return false;
  10537.  
  10538.  
  10539. locks = GetActionLocks(action);
  10540. for(i=0; i<locks.Size(); i+=1)
  10541. {
  10542. if(locks[i].isFromQuest || locks[i].isFromPlace)
  10543. return false;
  10544. }
  10545.  
  10546. if ( this.IsCurrentlyUsingItemL() )
  10547. {
  10548. if ( action == EIAB_HeavyAttacks || action == EIAB_Parry )
  10549. return false;
  10550. }
  10551.  
  10552.  
  10553. return true;
  10554. }
  10555.  
  10556. public final function DisplayActionDisallowedHudMessage(action : EInputActionBlock, optional isCombatLock : bool, optional isPlaceLock : bool, optional isTimeLock : bool, optional isDangerous : bool)
  10557. {
  10558. var lockType : name;
  10559.  
  10560. if(action != EIAB_Undefined && DisallowedActionDontShowHack(action, isTimeLock))
  10561. return;
  10562.  
  10563.  
  10564. if(IsInCombat() && !IsActionCombat(action))
  10565. isCombatLock = true;
  10566.  
  10567.  
  10568. if(!isCombatLock && !isPlaceLock && !isTimeLock && action != EIAB_Undefined)
  10569. {
  10570. lockType = inputHandler.GetActionBlockedHudLockType(action);
  10571.  
  10572. if(lockType == 'combat')
  10573. isCombatLock = true;
  10574. else if(lockType == 'place')
  10575. isPlaceLock = true;
  10576. else if(lockType == 'time')
  10577. isTimeLock = true;
  10578. }
  10579.  
  10580. if(isDangerous)
  10581. {
  10582. DisplayHudMessage(GetLocStringByKeyExt( "message_meditation_too_dangerous" ));
  10583. }
  10584. else if(isCombatLock)
  10585. {
  10586. DisplayHudMessage(GetLocStringByKeyExt( "panel_hud_message_actionnotallowed_combat" ));
  10587. }
  10588. else if(isPlaceLock)
  10589. {
  10590. DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_here" ));
  10591. }
  10592. else if(isTimeLock)
  10593. {
  10594. DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_now" ));
  10595. }
  10596. }
  10597.  
  10598.  
  10599. public function RemoveHudMessageByString(msg : string, optional allQueuedInstances : bool)
  10600. {
  10601. var i, j : int;
  10602.  
  10603. for(i=0; i<HudMessages.Size(); i+=1)
  10604. {
  10605. if(HudMessages[i] == msg)
  10606. {
  10607. HudMessages.EraseFast(i);
  10608.  
  10609. if(!allQueuedInstances)
  10610. return;
  10611.  
  10612. break;
  10613. }
  10614. }
  10615.  
  10616.  
  10617. for(j=HudMessages.Size()-1; j >= i; j-=1)
  10618. {
  10619. if(HudMessages[i] == msg)
  10620. {
  10621. HudMessages.EraseFast(i);
  10622. }
  10623. }
  10624. }
  10625.  
  10626. public function RemoveHudMessageByIndex(idx : int)
  10627. {
  10628. if(idx >= 0 && idx < HudMessages.Size())
  10629. HudMessages.Erase(idx);
  10630. }
  10631.  
  10632. function SetSettlementBlockCanter( valueAdd : int )
  10633. {
  10634. m_SettlementBlockCanter += valueAdd;
  10635. }
  10636.  
  10637. var countDownToStart : int;
  10638. default countDownToStart = 0;
  10639.  
  10640. function DisplayRaceStart( countDownSecondsNumber : int )
  10641. {
  10642. var i : int;
  10643. countDownToStart = countDownSecondsNumber;
  10644. for( i = countDownSecondsNumber; i > 0; i -= 1 )
  10645. {
  10646. DisplayHudMessage(IntToString(i));
  10647. }
  10648. DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_race_start"));
  10649. AddTimer('RaceCountdown',1,true);
  10650. }
  10651.  
  10652. timer function RaceCountdown(dt : float, id : int)
  10653. {
  10654. var hud : CR4ScriptedHud;
  10655. var messageModule : CR4HudModuleMessage;
  10656.  
  10657. countDownToStart -= 1;
  10658. hud = (CR4ScriptedHud)theGame.GetHud();
  10659.  
  10660. if( hud )
  10661. {
  10662. messageModule = (CR4HudModuleMessage)hud.GetHudModule("MessageModule");
  10663. if( messageModule )
  10664. {
  10665. messageModule.OnMessageHidden();
  10666. }
  10667. }
  10668.  
  10669. if( countDownToStart <= 0 )
  10670. {
  10671. RemoveTimer('RaceCountdown');
  10672. }
  10673. }
  10674.  
  10675. public function GetCountDownToStart() : int
  10676. {
  10677. return countDownToStart;
  10678. }
  10679.  
  10680. public function HAXE3GetContainer() : W3Container
  10681. {
  10682. return HAXE3Container;
  10683. }
  10684.  
  10685. public function HAXE3SetContainer( container : W3Container) : void
  10686. {
  10687. HAXE3Container = container;
  10688. }
  10689.  
  10690. public function HAXE3GetAutoLoot() : bool
  10691. {
  10692. return HAXE3bAutoLoot;
  10693. }
  10694.  
  10695. public function HAXE3SetAutoLoot( value : bool ) : void
  10696. {
  10697. HAXE3bAutoLoot = value;
  10698. }
  10699.  
  10700. public function GetShowHud() : bool
  10701. {
  10702. return bShowHud;
  10703. }
  10704.  
  10705. public function SetShowHud( value : bool ) : void
  10706. {
  10707. bShowHud = value;
  10708. }
  10709.  
  10710. public function DisplayItemRewardNotification( itemName : name, optional quantity : int ) : void
  10711. {
  10712. var hud : CR4ScriptedHud;
  10713. hud = (CR4ScriptedHud)theGame.GetHud();
  10714. hud.OnItemRecivedDuringScene(itemName, quantity);
  10715. }
  10716.  
  10717. function IsNewQuest( questGuid : CGUID ) : bool
  10718. {
  10719. var i : int;
  10720. for(i = 0; i < displayedQuestsGUID.Size(); i += 1 )
  10721. {
  10722. if( displayedQuestsGUID[i] == questGuid )
  10723. {
  10724. return false;
  10725. }
  10726. }
  10727. displayedQuestsGUID.PushBack(questGuid);
  10728. return true;
  10729. }
  10730.  
  10731. function GetRewardMultiplierData( rewardName : name ) : SRewardMultiplier
  10732. {
  10733. var defaultReward : SRewardMultiplier;
  10734. var i : int;
  10735.  
  10736. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  10737. {
  10738. if( rewardsMultiplier[i].rewardName == rewardName )
  10739. {
  10740. return rewardsMultiplier[i];
  10741. }
  10742. }
  10743.  
  10744. defaultReward.rewardName = rewardName;
  10745. defaultReward.rewardMultiplier = 1.0;
  10746. defaultReward.isItemMultiplier = false;
  10747.  
  10748. return defaultReward;
  10749. }
  10750.  
  10751. function GetRewardMultiplier( rewardName : name ) : float
  10752. {
  10753. var i : int;
  10754. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  10755. {
  10756. if( rewardsMultiplier[i].rewardName == rewardName )
  10757. {
  10758. return rewardsMultiplier[i].rewardMultiplier;
  10759. }
  10760. }
  10761. return 1.0;
  10762. }
  10763.  
  10764. function GetRewardMultiplierExists( rewardName : name ) : bool
  10765. {
  10766. var i : int;
  10767. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  10768. {
  10769. if( rewardsMultiplier[i].rewardName == rewardName )
  10770. {
  10771. return true;
  10772. }
  10773. }
  10774. return false;
  10775. }
  10776.  
  10777. function SetRewardMultiplier( rewardName : name, value : float, optional isItemMultiplier : bool ) : void
  10778. {
  10779. var i : int;
  10780. var rewardMultiplier : SRewardMultiplier;
  10781.  
  10782. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  10783. {
  10784. if( rewardsMultiplier[i].rewardName == rewardName )
  10785. {
  10786. rewardsMultiplier[i].rewardMultiplier = value;
  10787. rewardsMultiplier[i].isItemMultiplier = isItemMultiplier;
  10788. return;
  10789. }
  10790. }
  10791.  
  10792. rewardMultiplier.rewardName = rewardName;
  10793. rewardMultiplier.rewardMultiplier = value;
  10794. rewardMultiplier.isItemMultiplier = isItemMultiplier;
  10795.  
  10796. rewardsMultiplier.PushBack(rewardMultiplier);
  10797. }
  10798.  
  10799. function RemoveRewardMultiplier( rewardName : name ) : void
  10800. {
  10801. var i : int;
  10802. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  10803. {
  10804. if( rewardsMultiplier[i].rewardName == rewardName )
  10805. {
  10806. rewardsMultiplier.Erase(i);
  10807. return;
  10808. }
  10809. }
  10810. }
  10811.  
  10812.  
  10813.  
  10814.  
  10815.  
  10816.  
  10817.  
  10818. public final function TissueExtractorDischarge() : bool
  10819. {
  10820. var ids : array<SItemUniqueId>;
  10821. var chargesLeft, uses, curr, max, red, blue, green : int;
  10822. var i : int;
  10823. var text : string;
  10824.  
  10825. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  10826. if( ids.Size() == 0 )
  10827. {
  10828. return false;
  10829. }
  10830.  
  10831. curr = GetTissueExtractorChargesCurr();
  10832. max = GetTissueExtractorChargesMax();
  10833.  
  10834. if( curr >= max )
  10835. {
  10836.  
  10837. uses = FloorF( ( ( float ) curr ) / ( ( float ) max ) );
  10838. chargesLeft = Max( 0, curr - uses * max );
  10839.  
  10840.  
  10841. inv.SetItemModifierInt( ids[0], 'charges', chargesLeft );
  10842.  
  10843.  
  10844. blue = 0;
  10845. green = 0;
  10846. red = 0;
  10847. for( i=0; i<uses; i+=1 )
  10848. {
  10849. switch( RandRange( 3 ) )
  10850. {
  10851. case 0:
  10852. blue += 1;
  10853. break;
  10854. case 1:
  10855. green += 1;
  10856. break;
  10857. case 2:
  10858. red += 1;
  10859. }
  10860. }
  10861.  
  10862. text = GetLocStringByKeyExt( "message_q705_extractor_extracted" );
  10863.  
  10864. if( blue > 0 )
  10865. {
  10866. inv.AddAnItem( 'Greater mutagen blue', blue, false, true );
  10867. text += "<br/>" + blue + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen blue' ) );
  10868. }
  10869. if( green > 0 )
  10870. {
  10871. inv.AddAnItem( 'Greater mutagen green', green, false, true );
  10872. text += "<br/>" + green + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen green' ) );
  10873. }
  10874. if( red > 0 )
  10875. {
  10876. inv.AddAnItem( 'Greater mutagen red', red, false, true );
  10877. text += "<br/>" + red + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen red' ) );
  10878. }
  10879.  
  10880.  
  10881. theGame.GetGuiManager().ShowNotification( text );
  10882.  
  10883.  
  10884. inv.SetItemModifierInt( ids[0], 'ui_notified', 0 );
  10885.  
  10886. return true;
  10887. }
  10888. else
  10889. {
  10890.  
  10891. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_q705_extractor_too_few_charges" ) );
  10892. }
  10893.  
  10894. return false;
  10895. }
  10896.  
  10897. public final function TissueExtractorIncCharge()
  10898. {
  10899. var ids : array<SItemUniqueId>;
  10900. var uiData : SInventoryItemUIData;
  10901. var curr : int;
  10902.  
  10903. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  10904. if( ids.Size() == 0 )
  10905. {
  10906. return;
  10907. }
  10908.  
  10909. curr = GetTissueExtractorChargesCurr() + 1;
  10910. inv.SetItemModifierInt( ids[0], 'charges', curr );
  10911.  
  10912.  
  10913. if( curr >= GetTissueExtractorChargesMax() )
  10914. {
  10915. uiData = inv.GetInventoryItemUIData( ids[0] );
  10916. uiData.isNew = true;
  10917. inv.SetInventoryItemUIData( ids[0], uiData );
  10918.  
  10919.  
  10920. if( inv.GetItemModifierInt( ids[0], 'ui_notified', 0 ) == 0 )
  10921. {
  10922. inv.SetItemModifierInt( ids[0], 'ui_notified', 1 );
  10923. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_q705_extractor_charged" ), , true );
  10924. }
  10925. }
  10926. }
  10927.  
  10928. public final function GetTissueExtractorChargesCurr() : int
  10929. {
  10930. var ids : array<SItemUniqueId>;
  10931.  
  10932. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  10933. if( ids.Size() == 0 )
  10934. {
  10935. return 0;
  10936. }
  10937.  
  10938. return inv.GetItemModifierInt( ids[0], 'charges', 0 );
  10939. }
  10940.  
  10941. public final function GetTissueExtractorChargesMax() : int
  10942. {
  10943. var ids : array<SItemUniqueId>;
  10944. var val : SAbilityAttributeValue;
  10945.  
  10946. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  10947. if( ids.Size() == 0 )
  10948. {
  10949. return 0;
  10950. }
  10951.  
  10952. val = inv.GetItemAttributeValue( ids[0], 'maxCharges' );
  10953.  
  10954. return FloorF( val.valueBase );
  10955. }
  10956.  
  10957. public function GetEquippedSword(steel : bool) : SItemUniqueId;
  10958.  
  10959. public final function HasRequiredLevelToEquipItem(item : SItemUniqueId) : bool
  10960. {
  10961.  
  10962. if (thePlayer.IsCiri())
  10963. if(gmConfig().enableNoItemLevel) { return true; } // ===== Added by God Mode mod - Module: No Item Level =====
  10964.  
  10965. return true;
  10966.  
  10967. if(HasBuff(EET_WolfHour))
  10968. {
  10969. if((inv.GetItemLevel(item) - 2) > GetLevel() )
  10970. return false;
  10971. }
  10972. else
  10973. {
  10974. if(inv.GetItemLevel(item) > GetLevel() )
  10975. return false;
  10976. }
  10977.  
  10978. return true;
  10979. }
  10980.  
  10981. public function SkillReduceBombAmmoBonus()
  10982. {
  10983. var i, ammo, maxAmmo : int;
  10984. var items : array<SItemUniqueId>;
  10985.  
  10986. items = inv.GetSingletonItems();
  10987.  
  10988. for(i=0; i<items.Size(); i+=1)
  10989. {
  10990. ammo = inv.GetItemModifierInt(items[i], 'ammo_current');
  10991.  
  10992.  
  10993. if(ammo > 0)
  10994. {
  10995. maxAmmo = inv.SingletonItemGetMaxAmmo(items[i]);
  10996.  
  10997.  
  10998. if(ammo > maxAmmo)
  10999. {
  11000. inv.SetItemModifierInt(items[i], 'ammo_current', maxAmmo);
  11001. }
  11002. }
  11003. }
  11004. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  11005. }
  11006.  
  11007. public function ConsumeItem( itemId : SItemUniqueId ) : bool
  11008. {
  11009. var params : SCustomEffectParams;
  11010. var buffs : array<SEffectInfo>;
  11011. var i : int;
  11012. var category : name;
  11013. var potionToxicity : float;
  11014.  
  11015. if(!inv.IsIdValid(itemId))
  11016. return false;
  11017.  
  11018.  
  11019. category = inv.GetItemCategory(itemId);
  11020. if(category == 'edibles' || inv.ItemHasTag(itemId, 'Drinks') || ( category == 'alchemy_ingredient' && inv.ItemHasTag(itemId, 'Alcohol')) )
  11021. {
  11022.  
  11023. if(IsFistFightMinigameEnabled() || IsDiving())
  11024. {
  11025. DisplayActionDisallowedHudMessage(EIAB_Undefined, false, false, true);
  11026. return false;
  11027. }
  11028.  
  11029.  
  11030. inv.GetItemBuffs(itemId, buffs);
  11031.  
  11032. for(i=0; i<buffs.Size(); i+=1)
  11033. {
  11034. params.effectType = buffs[i].effectType;
  11035. params.creator = this;
  11036. params.sourceName = "edible";
  11037. params.customAbilityName = buffs[i].effectAbilityName;
  11038. AddEffectCustom(params);
  11039. }
  11040.  
  11041.  
  11042. if ( inv.ItemHasTag(itemId, 'Alcohol') )
  11043. {
  11044. potionToxicity = CalculateAttributeValue(inv.GetItemAttributeValue(itemId, 'toxicity'));
  11045. abilityManager.GainStat(BCS_Toxicity, potionToxicity );
  11046. AddEffectDefault(EET_Drunkenness, NULL, inv.GetItemName(itemId));
  11047. }
  11048. PlayItemConsumeSound( itemId );
  11049. }
  11050.  
  11051. if(inv.IsItemFood(itemId))
  11052. FactsAdd("consumed_food_cnt");
  11053.  
  11054.  
  11055. if(!inv.ItemHasTag(itemId, theGame.params.TAG_INFINITE_USE) && !inv.RemoveItem(itemId))
  11056. {
  11057. LogAssert(false,"Failed to remove consumable item from player inventory!" + inv.GetItemName( itemId ) );
  11058. return false;
  11059. }
  11060.  
  11061. return true;
  11062. }
  11063.  
  11064. public function MountVehicle( vehicleEntity : CEntity, mountType : EVehicleMountType, optional vehicleSlot : EVehicleSlot )
  11065. {
  11066. var vehicle : CVehicleComponent;
  11067. vehicle = (CVehicleComponent)(vehicleEntity.GetComponentByClassName('CVehicleComponent'));
  11068.  
  11069. if ( vehicle )
  11070. vehicle.Mount( this, mountType, vehicleSlot );
  11071. }
  11072.  
  11073. public function DismountVehicle( vehicleEntity : CEntity, dismountType : EDismountType )
  11074. {
  11075. var vehicle : CVehicleComponent;
  11076. vehicle = (CVehicleComponent)(vehicleEntity.GetComponentByClassName('CVehicleComponent'));
  11077.  
  11078. if ( vehicle )
  11079. vehicle.IssueCommandToDismount( dismountType );
  11080. }
  11081.  
  11082.  
  11083.  
  11084.  
  11085.  
  11086. protected function ShouldDrainStaminaWhileSprinting() : bool
  11087. {
  11088. if( HasBuff( EET_PolishedGenitals ) && !IsInCombat() && !IsThreatened() )
  11089. {
  11090. return false;
  11091. }
  11092.  
  11093. return super.ShouldDrainStaminaWhileSprinting();
  11094. }
  11095.  
  11096.  
  11097.  
  11098. public function HasStaminaToUseAction(action : EStaminaActionType, optional abilityName : name, optional dt :float, optional multiplier : float) : bool
  11099. {
  11100. var cost : float;
  11101. var ret : bool;
  11102.  
  11103. ret = super.HasStaminaToUseAction(action, abilityName, dt, multiplier);
  11104.  
  11105. if(!ret)
  11106. {
  11107. SetCombatActionHeading( GetHeading() );
  11108.  
  11109. if(multiplier == 0)
  11110. multiplier = 1;
  11111.  
  11112. cost = multiplier * GetStaminaActionCost(action, abilityName, dt);
  11113. SetShowToLowStaminaIndication(cost);
  11114. }
  11115.  
  11116. return ret;
  11117. }
  11118.  
  11119.  
  11120. timer function AbilityManager_FloorStaminaSegment(dt : float, id : int)
  11121. {
  11122. ((W3PlayerAbilityManager)abilityManager).FloorStaminaSegment();
  11123. }
  11124.  
  11125. public function DrainToxicity(amount : float )
  11126. {
  11127. if(abilityManager && abilityManager.IsInitialized() && IsAlive())
  11128. abilityManager.DrainToxicity(amount);
  11129. }
  11130.  
  11131. public function DrainFocus(amount : float )
  11132. {
  11133. if(abilityManager && abilityManager.IsInitialized() && IsAlive())
  11134. abilityManager.DrainFocus(amount);
  11135. }
  11136.  
  11137. public function GetOffenseStat():int
  11138. {
  11139. if(abilityManager && abilityManager.IsInitialized())
  11140. return ((W3PlayerAbilityManager)abilityManager).GetOffenseStat();
  11141.  
  11142. return 0;
  11143. }
  11144.  
  11145. public function GetDefenseStat():int
  11146. {
  11147. if(abilityManager && abilityManager.IsInitialized())
  11148. return ((W3PlayerAbilityManager)abilityManager).GetDefenseStat();
  11149.  
  11150. return 0;
  11151. }
  11152.  
  11153. public function GetSignsStat():float
  11154. {
  11155. if(abilityManager && abilityManager.IsInitialized())
  11156. return ((W3PlayerAbilityManager)abilityManager).GetSignsStat();
  11157.  
  11158. return 0;
  11159. }
  11160.  
  11161.  
  11162.  
  11163.  
  11164.  
  11165. private var inWaterTrigger : bool;
  11166.  
  11167. event OnOceanTriggerEnter()
  11168. {
  11169. inWaterTrigger = true;
  11170. }
  11171.  
  11172. event OnOceanTriggerLeave()
  11173. {
  11174. inWaterTrigger = false;
  11175. }
  11176.  
  11177. public function IsInWaterTrigger() : bool
  11178. {
  11179. return inWaterTrigger;
  11180. }
  11181.  
  11182.  
  11183.  
  11184.  
  11185.  
  11186. public function GetSkillColor(skill : ESkill) : ESkillColor
  11187. {
  11188. if(abilityManager && abilityManager.IsInitialized())
  11189. return ((W3PlayerAbilityManager)abilityManager).GetSkillColor(skill);
  11190.  
  11191. return SC_None;
  11192. }
  11193.  
  11194. public function GetSkillSlotIndexFromSkill(skill : ESkill) : int
  11195. {
  11196. if(abilityManager && abilityManager.IsInitialized())
  11197. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIndexFromSkill(skill);
  11198.  
  11199. return -1;
  11200. }
  11201.  
  11202. public final function GetSkillSlotIndex(slotID : int, checkIfUnlocked : bool) : int
  11203. {
  11204. if(abilityManager && abilityManager.IsInitialized())
  11205. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIndex(slotID, checkIfUnlocked);
  11206.  
  11207. return -1;
  11208. }
  11209.  
  11210. public final function GetSkillSlotIDFromIndex(skillSlotIndex : int) : int
  11211. {
  11212. if(abilityManager && abilityManager.IsInitialized())
  11213. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIDFromIndex(skillSlotIndex);
  11214.  
  11215. return -1;
  11216. }
  11217.  
  11218. public function GetSkillSlotID(skill : ESkill) : int
  11219. {
  11220. if(abilityManager && abilityManager.IsInitialized())
  11221. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotID(skill);
  11222.  
  11223. return -1;
  11224. }
  11225.  
  11226. public function GetSkillGroupBonus(groupID : int) : name
  11227. {
  11228. if(abilityManager && abilityManager.IsInitialized())
  11229. return ((W3PlayerAbilityManager)abilityManager).GetGroupBonus(groupID);
  11230.  
  11231. return '';
  11232. }
  11233.  
  11234. public function GetGroupBonusCount(commonColor : ESkillColor,groupID : int) : int
  11235. {
  11236. if(abilityManager && abilityManager.IsInitialized())
  11237. return ((W3PlayerAbilityManager)abilityManager).GetSkillGroupColorCount(commonColor, groupID);
  11238.  
  11239. return 0;
  11240. }
  11241.  
  11242. public function GetMutagenSlotIDFromGroupID(groupID : int) : int
  11243. {
  11244. if(abilityManager && abilityManager.IsInitialized())
  11245. return ((W3PlayerAbilityManager)abilityManager).GetMutagenSlotIDFromGroupID(groupID);
  11246.  
  11247. return -1;
  11248. }
  11249.  
  11250. public function GetSkillLevel(skill : ESkill) : int
  11251. {
  11252. if(abilityManager && abilityManager.IsInitialized())
  11253. return ((W3PlayerAbilityManager)abilityManager).GetSkillLevel(skill);
  11254.  
  11255. return -1;
  11256. }
  11257.  
  11258. public function GetBoughtSkillLevel(skill : ESkill) : int
  11259. {
  11260. if(abilityManager && abilityManager.IsInitialized())
  11261. return ((W3PlayerAbilityManager)abilityManager).GetBoughtSkillLevel(skill);
  11262.  
  11263. return -1;
  11264. }
  11265.  
  11266. public function AddSkill(skill : ESkill, optional isTemporary : bool)
  11267. {
  11268. if(abilityManager && abilityManager.IsInitialized())
  11269. ((W3PlayerAbilityManager)abilityManager).AddSkill(skill, isTemporary);
  11270. }
  11271.  
  11272. public function AddMultipleSkills(skill : ESkill, optional number : int, optional isTemporary : bool)
  11273. {
  11274. var i : int;
  11275.  
  11276. if(number)
  11277. {
  11278. for( i=0; i<number; i+=1)
  11279. {
  11280. AddSkill(skill,isTemporary);
  11281. }
  11282. }
  11283. else
  11284. {
  11285. AddSkill(skill,isTemporary);
  11286. }
  11287. }
  11288.  
  11289. public function GetSkillAbilityName(skill : ESkill) : name
  11290. {
  11291. if(abilityManager && abilityManager.IsInitialized())
  11292. return ((W3PlayerAbilityManager)abilityManager).GetSkillAbilityName(skill);
  11293.  
  11294. return '';
  11295. }
  11296.  
  11297. public function HasStaminaToUseSkill(skill : ESkill, optional perSec : bool, optional signHack : bool) : bool
  11298. {
  11299. var ret : bool;
  11300. var cost : float;
  11301.  
  11302. cost = GetSkillStaminaUseCost(skill, perSec);
  11303.  
  11304. ret = ( CanUseSkill(skill) && (abilityManager.GetStat(BCS_Stamina, signHack) >= cost) );
  11305.  
  11306.  
  11307. if(!ret && IsSkillSign(skill) && CanUseSkill(S_Perk_09) && (GetStat(BCS_Focus) >= 1 || GetWitcherPlayer().IsSuperchargedSign()) )
  11308. {
  11309. ret = true;
  11310. }
  11311.  
  11312.  
  11313. if( !ret && IsSkillSign( skill ) && GetWitcherPlayer().HasBuff( EET_GryphonSetBonus ) )
  11314. {
  11315. ret = true;
  11316. }
  11317.  
  11318. if(!ret)
  11319. {
  11320. SetCombatActionHeading( GetHeading() );
  11321. SetShowToLowStaminaIndication(cost);
  11322. }
  11323.  
  11324. return ret;
  11325. }
  11326.  
  11327. protected function GetSkillStaminaUseCost(skill : ESkill, optional perSec : bool) : float
  11328. {
  11329. if(abilityManager && abilityManager.IsInitialized())
  11330. return ((W3PlayerAbilityManager)abilityManager).GetSkillStaminaUseCost(skill, perSec);
  11331.  
  11332. return 0;
  11333. }
  11334.  
  11335.  
  11336. public function GetSkillAttributeValue(skill : ESkill, attributeName : name, addBaseCharAttribute : bool, addSkillModsAttribute : bool) : SAbilityAttributeValue
  11337. {
  11338. var null : SAbilityAttributeValue;
  11339.  
  11340. if(abilityManager && abilityManager.IsInitialized())
  11341. return abilityManager.GetSkillAttributeValue(SkillEnumToName(skill), attributeName, addBaseCharAttribute, addSkillModsAttribute);
  11342.  
  11343. return null;
  11344. }
  11345.  
  11346. public function GetSkillLocalisationKeyName(skill : ESkill) : string
  11347. {
  11348. if(abilityManager && abilityManager.IsInitialized())
  11349. return ((W3PlayerAbilityManager)abilityManager).GetSkillLocalisationKeyName(skill);
  11350.  
  11351. return "";
  11352. }
  11353.  
  11354. public function GetSkillLocalisationKeyDescription(skill : ESkill) : string
  11355. {
  11356. if(abilityManager && abilityManager.IsInitialized())
  11357. return ((W3PlayerAbilityManager)abilityManager).GetSkillLocalisationKeyDescription(skill);
  11358.  
  11359. return "";
  11360. }
  11361.  
  11362. public function GetSkillIconPath(skill : ESkill) : string
  11363. {
  11364. if(abilityManager && abilityManager.IsInitialized())
  11365. return ((W3PlayerAbilityManager)abilityManager).GetSkillIconPath(skill);
  11366.  
  11367. return "";
  11368. }
  11369.  
  11370. public function HasLearnedSkill(skill : ESkill) : bool
  11371. {
  11372. if(abilityManager && abilityManager.IsInitialized())
  11373. return ((W3PlayerAbilityManager)abilityManager).HasLearnedSkill(skill);
  11374.  
  11375. return false;
  11376. }
  11377.  
  11378. public function IsSkillEquipped(skill : ESkill) : bool
  11379. {
  11380. if(abilityManager && abilityManager.IsInitialized())
  11381. return ((W3PlayerAbilityManager)abilityManager).IsSkillEquipped(skill);
  11382.  
  11383. return false;
  11384. }
  11385.  
  11386. public function CanUseSkill(skill : ESkill) : bool
  11387. {
  11388. if(abilityManager && abilityManager.IsInitialized())
  11389. return ((W3PlayerAbilityManager)abilityManager).CanUseSkill(skill);
  11390.  
  11391. return false;
  11392. }
  11393.  
  11394. public function CanLearnSkill(skill : ESkill) : bool
  11395. {
  11396. if(abilityManager && abilityManager.IsInitialized())
  11397. return ((W3PlayerAbilityManager)abilityManager).CanLearnSkill(skill);
  11398.  
  11399. return false;
  11400. }
  11401.  
  11402. public function HasSpentEnoughPoints(skill : ESkill) : bool
  11403. {
  11404. if(abilityManager && abilityManager.IsInitialized())
  11405. return ((W3PlayerAbilityManager)abilityManager).HasSpentEnoughPoints(skill);
  11406.  
  11407. return false;
  11408. }
  11409.  
  11410. public function PathPointsForSkillsPath(skill : ESkill) : int
  11411. {
  11412. if(abilityManager && abilityManager.IsInitialized())
  11413. return ((W3PlayerAbilityManager)abilityManager).PathPointsSpentInSkillPathOfSkill(skill);
  11414.  
  11415. return -1;
  11416. }
  11417.  
  11418. public function GetPlayerSkills() : array<SSkill>
  11419. {
  11420. var null : array<SSkill>;
  11421.  
  11422. if(abilityManager && abilityManager.IsInitialized())
  11423. return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkills();
  11424.  
  11425. return null;
  11426. }
  11427.  
  11428. public function GetPlayerSkill(s : ESkill) : SSkill
  11429. {
  11430. var null : SSkill;
  11431.  
  11432. if(abilityManager && abilityManager.IsInitialized())
  11433. return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkill(s);
  11434.  
  11435. return null;
  11436. }
  11437.  
  11438. public function GetSkillSubPathType(s : ESkill) : ESkillSubPath
  11439. {
  11440. if(abilityManager && abilityManager.IsInitialized())
  11441. return ((W3PlayerAbilityManager)abilityManager).GetSkillSubPathType(s);
  11442.  
  11443. return ESSP_NotSet;
  11444. }
  11445.  
  11446. public function GetSkillSlotsCount() : int
  11447. {
  11448. if(abilityManager && abilityManager.IsInitialized())
  11449. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotsCount();
  11450.  
  11451. return 0;
  11452. }
  11453.  
  11454. public function GetSkillSlots() : array<SSkillSlot>
  11455. {
  11456. var null : array<SSkillSlot>;
  11457.  
  11458. if(abilityManager && abilityManager.IsInitialized())
  11459. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlots();
  11460.  
  11461. return null;
  11462. }
  11463.  
  11464. public function GetPlayerSkillMutagens() : array<SMutagenSlot>
  11465. {
  11466. var null : array<SMutagenSlot>;
  11467.  
  11468. if(abilityManager && abilityManager.IsInitialized())
  11469. return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkillMutagens();
  11470.  
  11471. return null;
  11472. }
  11473.  
  11474.  
  11475.  
  11476.  
  11477. public function BlockSkill(skill : ESkill, block : bool, optional cooldown : float) : bool
  11478. {
  11479. if(abilityManager && abilityManager.IsInitialized())
  11480. return ((W3PlayerAbilityManager)abilityManager).BlockSkill(skill, block, cooldown);
  11481.  
  11482. return false;
  11483. }
  11484.  
  11485. public function IsSkillBlocked(skill : ESkill) : bool
  11486. {
  11487. if(abilityManager && abilityManager.IsInitialized())
  11488. return ((W3PlayerAbilityManager)abilityManager).IsSkillBlocked(skill);
  11489.  
  11490. return false;
  11491. }
  11492.  
  11493.  
  11494. public function EquipSkill(skill : ESkill, slotID : int) : bool
  11495. {
  11496. var ret : bool;
  11497. var groupID : int;
  11498. var pam : W3PlayerAbilityManager;
  11499.  
  11500. if(abilityManager && abilityManager.IsInitialized())
  11501. {
  11502. pam = (W3PlayerAbilityManager)abilityManager;
  11503. ret = pam.EquipSkill(skill, slotID);
  11504. if(ret)
  11505. {
  11506. groupID = pam.GetSkillGroupIdFromSkillSlotId(slotID);
  11507. LogSkillColors("Equipped <<" + GetSkillColor(skill) + ">> skill <<" + skill + ">> to group <<" + groupID + ">>");
  11508. LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
  11509. LogSkillColors("");
  11510. }
  11511.  
  11512. return ret;
  11513. }
  11514.  
  11515. return false;
  11516. }
  11517.  
  11518.  
  11519. public function UnequipSkill(slotID : int) : bool
  11520. {
  11521. var ret : bool;
  11522. var groupID : int;
  11523. var skill : ESkill;
  11524. var pam : W3PlayerAbilityManager;
  11525.  
  11526. if(abilityManager && abilityManager.IsInitialized())
  11527. {
  11528. pam = (W3PlayerAbilityManager)abilityManager;
  11529. GetSkillOnSlot(slotID, skill);
  11530. ret = pam.UnequipSkill(slotID);
  11531. if(ret)
  11532. {
  11533. groupID = pam.GetSkillGroupIdFromSkillSlotId(slotID);
  11534. LogSkillColors("Unequipped <<" + GetSkillColor(skill) + ">> skill <<" + skill + ">> from group <<" + groupID + ">>");
  11535. LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
  11536. LogSkillColors("");
  11537. }
  11538. return ret;
  11539. }
  11540.  
  11541. return false;
  11542. }
  11543.  
  11544.  
  11545. public function GetSkillOnSlot(slotID : int, out skill : ESkill) : bool
  11546. {
  11547. if(abilityManager && abilityManager.IsInitialized())
  11548. return ((W3PlayerAbilityManager)abilityManager).GetSkillOnSlot(slotID, skill);
  11549.  
  11550. skill = S_SUndefined;
  11551. return false;
  11552. }
  11553.  
  11554.  
  11555. public function GetFreeSkillSlot() : int
  11556. {
  11557. var i, size : int;
  11558. var skill : ESkill;
  11559.  
  11560. size = ((W3PlayerAbilityManager)abilityManager).GetSkillSlotsCount();
  11561. for(i=1; i<size; i+=1)
  11562. {
  11563. if(!GetSkillOnSlot(i, skill))
  11564. continue;
  11565.  
  11566. if(skill == S_SUndefined)
  11567. return i;
  11568. }
  11569.  
  11570. return -1;
  11571. }
  11572.  
  11573.  
  11574.  
  11575.  
  11576.  
  11577.  
  11578. protected function Attack( hitTarget : CGameplayEntity, animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float, weaponEntity : CItemEntity)
  11579. {
  11580. var attackAction : W3Action_Attack;
  11581.  
  11582. if(!PrepareAttackAction(hitTarget, animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime, weaponEntity, attackAction))
  11583. return;
  11584.  
  11585. if ( attackAction.IsParried() && ( ((CNewNPC)attackAction.victim).IsShielded(attackAction.attacker) || ((CNewNPC)attackAction.victim).SignalGameplayEventReturnInt('IsDefending',0) == 1 ) )
  11586. {
  11587. thePlayer.SetCanPlayHitAnim(true);
  11588. thePlayer.ReactToReflectedAttack(attackAction.victim);
  11589. }
  11590.  
  11591. theTelemetry.LogWithLabel( TE_FIGHT_PLAYER_ATTACKS, attackAction.GetAttackName() );
  11592.  
  11593.  
  11594. theGame.damageMgr.ProcessAction(attackAction);
  11595.  
  11596. delete attackAction;
  11597. }
  11598.  
  11599. public function IsHeavyAttack(attackName : name) : bool
  11600. {
  11601. var skill : ESkill;
  11602. var sup : bool;
  11603.  
  11604. sup = super.IsHeavyAttack(attackName);
  11605. if(sup)
  11606. return true;
  11607.  
  11608. if ( attackName == 'attack_heavy_special' )
  11609. return true;
  11610.  
  11611. skill = SkillNameToEnum(attackName);
  11612.  
  11613. return skill == S_Sword_2 || skill == S_Sword_s02;
  11614. }
  11615.  
  11616. public function IsLightAttack(attackName : name) : bool
  11617. {
  11618. var skill : ESkill;
  11619. var sup : bool;
  11620.  
  11621. sup = super.IsLightAttack(attackName);
  11622. if(sup)
  11623. return true;
  11624.  
  11625. skill = SkillNameToEnum(attackName);
  11626.  
  11627. return skill == S_Sword_1 || skill == S_Sword_s01;
  11628. }
  11629.  
  11630. public final function ProcessWeaponCollision()
  11631. {
  11632. var l_stateName : name;
  11633.  
  11634. var l_weaponPosition : Vector;
  11635. var l_weaponTipPos : Vector;
  11636. var l_collidingPosition : Vector;
  11637. var l_offset : Vector;
  11638. var l_normal : Vector;
  11639.  
  11640. var l_slotMatrix : Matrix;
  11641.  
  11642. var l_distance : float;
  11643.  
  11644. var l_materialName : name;
  11645. var l_hitComponent : CComponent;
  11646. var l_destructibleCmp : CDestructionSystemComponent;
  11647. var barrel : COilBarrelEntity;
  11648.  
  11649.  
  11650.  
  11651. if( isCurrentlyDodging )
  11652. return;
  11653.  
  11654. l_stateName = GetCurrentStateName();
  11655.  
  11656. if( !attackEventInProgress && l_stateName == 'CombatFists' )
  11657. return;
  11658.  
  11659. CalcEntitySlotMatrix('r_weapon', l_slotMatrix);
  11660.  
  11661. l_weaponPosition = MatrixGetTranslation( l_slotMatrix );
  11662.  
  11663.  
  11664. switch( l_stateName )
  11665. {
  11666. case 'CombatFists':
  11667. l_offset = MatrixGetAxisX( l_slotMatrix );
  11668. l_offset = VecNormalize( l_offset ) * 0.25f;
  11669. break;
  11670.  
  11671. default:
  11672. l_offset = MatrixGetAxisZ( l_slotMatrix );
  11673. l_offset = VecNormalize( l_offset ) * 1.f;
  11674. break;
  11675. }
  11676.  
  11677. l_weaponTipPos = l_weaponPosition + l_offset;
  11678.  
  11679.  
  11680.  
  11681. if( !attackEventInProgress )
  11682. {
  11683.  
  11684. if( m_LastWeaponTipPos == Vector ( 0, 0, 0 ) )
  11685. l_distance = 0;
  11686. else
  11687. l_distance = VecDistance( l_weaponTipPos, m_LastWeaponTipPos ) ;
  11688.  
  11689.  
  11690.  
  11691.  
  11692. m_LastWeaponTipPos = l_weaponTipPos;
  11693. if( l_distance < 0.35f )
  11694. return;
  11695.  
  11696. }
  11697.  
  11698.  
  11699.  
  11700. m_LastWeaponTipPos = l_weaponTipPos;
  11701.  
  11702. if ( !theGame.GetWorld().StaticTraceWithAdditionalInfo( l_weaponPosition, l_weaponTipPos, l_collidingPosition, l_normal, l_materialName, l_hitComponent, m_WeaponFXCollisionGroupNames ) )
  11703. {
  11704.  
  11705. if( l_stateName == 'CombatFists' )
  11706. {
  11707. CalcEntitySlotMatrix('l_weapon', l_slotMatrix);
  11708. l_weaponPosition = MatrixGetTranslation( l_slotMatrix );
  11709. l_offset = MatrixGetAxisX( l_slotMatrix );
  11710. l_offset = VecNormalize( l_offset ) * 0.25f;
  11711. l_weaponTipPos = l_weaponPosition + l_offset;
  11712. if( !theGame.GetWorld().StaticTrace( l_weaponPosition, l_weaponTipPos, l_collidingPosition, l_normal, m_WeaponFXCollisionGroupNames ) )
  11713. {
  11714. return;
  11715. }
  11716. }
  11717. else
  11718. {
  11719. return;
  11720. }
  11721. }
  11722.  
  11723. if( !m_CollisionEffect )
  11724. {
  11725. m_CollisionEffect = theGame.CreateEntity( m_CollisionFxTemplate, l_collidingPosition, EulerAngles(0,0,0) );
  11726. }
  11727.  
  11728. m_CollisionEffect.Teleport( l_collidingPosition );
  11729.  
  11730.  
  11731. switch( l_stateName )
  11732. {
  11733. case 'CombatFists':
  11734. m_CollisionEffect.PlayEffect('fist');
  11735. break;
  11736. default:
  11737.  
  11738. if( m_RefreshWeaponFXType )
  11739. {
  11740. m_PlayWoodenFX = IsSwordWooden();
  11741. m_RefreshWeaponFXType = false;
  11742. }
  11743.  
  11744. if( m_PlayWoodenFX )
  11745. {
  11746. m_CollisionEffect.PlayEffect('wood');
  11747. }
  11748. else
  11749. {
  11750. switch( l_materialName )
  11751. {
  11752. case 'wood_hollow':
  11753. case 'wood_debris':
  11754. case 'wood_solid':
  11755. m_CollisionEffect.PlayEffect('wood');
  11756. break;
  11757. case 'dirt_hard':
  11758. case 'dirt_soil':
  11759. case 'hay':
  11760. m_CollisionEffect.PlayEffect('fist');
  11761. break;
  11762. case 'stone_debris':
  11763. case 'stone_solid':
  11764. case 'clay_tile':
  11765. case 'gravel_large':
  11766. case 'gravel_small':
  11767. case 'metal':
  11768. case 'custom_sword':
  11769. m_CollisionEffect.PlayEffect('sparks');
  11770. break;
  11771. case 'flesh':
  11772. m_CollisionEffect.PlayEffect('blood');
  11773. break;
  11774. default:
  11775. m_CollisionEffect.PlayEffect('wood');
  11776. break;
  11777. }
  11778.  
  11779. }
  11780. break;
  11781. }
  11782.  
  11783.  
  11784. if(l_hitComponent)
  11785. {
  11786. barrel = (COilBarrelEntity)l_hitComponent.GetEntity();
  11787. if(barrel)
  11788. {
  11789. barrel.OnFireHit(NULL);
  11790. return;
  11791. }
  11792. }
  11793.  
  11794.  
  11795. l_destructibleCmp = (CDestructionSystemComponent) l_hitComponent;
  11796. if( l_destructibleCmp && l_stateName != 'CombatFists' )
  11797. {
  11798. l_destructibleCmp.ApplyFracture();
  11799. }
  11800.  
  11801.  
  11802.  
  11803. }
  11804.  
  11805. public function ReactToReflectedAttack( target : CGameplayEntity)
  11806. {
  11807.  
  11808. var hp, dmg : float;
  11809. var action : W3DamageAction;
  11810.  
  11811. super.ReactToReflectedAttack(target);
  11812.  
  11813. if ( !((CNewNPC)target).IsShielded(this) )
  11814. {
  11815. action = new W3DamageAction in this;
  11816. action.Initialize(target,this,NULL,'',EHRT_Reflect,CPS_AttackPower,true,false,false,false);
  11817. action.AddEffectInfo(EET_Stagger);
  11818. action.SetProcessBuffsIfNoDamage(true);
  11819.  
  11820. theGame.damageMgr.ProcessAction( action );
  11821. delete action;
  11822. }
  11823.  
  11824. theGame.VibrateControllerLight();
  11825. }
  11826.  
  11827.  
  11828.  
  11829.  
  11830.  
  11831.  
  11832. function GetFallDist( out fallDist : float ) : bool
  11833. {
  11834. var fallDiff, jumpTotalDiff : float;
  11835.  
  11836.  
  11837. substateManager.m_SharedDataO.CalculateFallingHeights( fallDiff, jumpTotalDiff );
  11838.  
  11839. if ( fallDiff <= 0 )
  11840. return false;
  11841.  
  11842. fallDist = fallDiff;
  11843. return true;
  11844. }
  11845.  
  11846. function ApplyFallingDamage(heightDiff : float, optional reducing : bool) : float
  11847. {
  11848. var hpPerc : float;
  11849. var tut : STutorialMessage;
  11850.  
  11851. if ( IsSwimming() || FactsQuerySum("block_falling_damage") >= 1 )
  11852. return 0.0f;
  11853.  
  11854. hpPerc = super.ApplyFallingDamage( heightDiff, reducing );
  11855.  
  11856. if(hpPerc > 0)
  11857. {
  11858. theGame.VibrateControllerHard();
  11859.  
  11860. if(IsAlive())
  11861. {
  11862. if(ShouldProcessTutorial('TutorialFallingDamage'))
  11863. {
  11864. FactsSet( "tutorial_falling_damage", 1 );
  11865. }
  11866.  
  11867. if(FactsQuerySum("tutorial_falling_damage") > 1 && ShouldProcessTutorial('TutorialFallingRoll'))
  11868. {
  11869.  
  11870. tut.type = ETMT_Hint;
  11871. tut.tutorialScriptTag = 'TutorialFallingRoll';
  11872. tut.hintPositionType = ETHPT_DefaultGlobal;
  11873. tut.hintDurationType = ETHDT_Long;
  11874. tut.canBeShownInMenus = false;
  11875. tut.glossaryLink = false;
  11876. tut.markAsSeenOnShow = true;
  11877.  
  11878.  
  11879. theGame.GetTutorialSystem().DisplayTutorial(tut);
  11880. }
  11881. }
  11882. }
  11883.  
  11884. return hpPerc;
  11885. }
  11886.  
  11887.  
  11888.  
  11889. public function SetShowToLowStaminaIndication( value : float ) : void
  11890. {
  11891. fShowToLowStaminaIndication = value;
  11892. }
  11893.  
  11894. public function GetShowToLowStaminaIndication() : float
  11895. {
  11896. return fShowToLowStaminaIndication;
  11897. }
  11898.  
  11899. public final function IndicateTooLowAdrenaline()
  11900. {
  11901. SoundEvent("gui_no_adrenaline");
  11902. showTooLowAdrenaline = true;
  11903. }
  11904.  
  11905.  
  11906.  
  11907. protected function GotoCombatStateWithAction( initialAction : EInitialAction, optional initialBuff : CBaseGameplayEffect )
  11908. {
  11909. if ( this.GetCurrentActionType() == ActorAction_Exploration )
  11910. ActionCancelAll();
  11911.  
  11912. ((W3PlayerWitcherStateCombatFists)this.GetState('CombatFists')).SetupState( initialAction, initialBuff );
  11913. this.GotoState( 'CombatFists' );
  11914.  
  11915. }
  11916.  
  11917.  
  11918. public function IsThreat( actor : CActor, optional usePrecalcs : bool ) : bool
  11919. {
  11920. var npc : CNewNPC;
  11921. var dist : float;
  11922. var targetCapsuleHeight : float;
  11923. var isDistanceExpanded : bool;
  11924. var distanceToTarget : float;
  11925. var attitude : EAIAttitude;
  11926.  
  11927. if (!actor)
  11928. {
  11929. return false;
  11930. }
  11931.  
  11932. if ( finishableEnemiesList.Contains( actor ) )
  11933. {
  11934. return true;
  11935. }
  11936.  
  11937. if ( !actor.IsAlive() || actor.IsKnockedUnconscious() )
  11938. {
  11939. return false;
  11940. }
  11941.  
  11942. npc = (CNewNPC)actor;
  11943. if (npc && npc.IsHorse() )
  11944. {
  11945. return false;
  11946. }
  11947.  
  11948. if ( hostileEnemies.Contains( actor ) )
  11949. {
  11950. return true;
  11951. }
  11952.  
  11953.  
  11954. if ( GetAttitudeBetween( this, actor ) == AIA_Hostile )
  11955. {
  11956. if ( usePrecalcs )
  11957. {
  11958. distanceToTarget = Distance2DBetweenCapsuleAndPoint( actor, this ) - targetingPrecalcs.playerRadius;
  11959. }
  11960. else
  11961. {
  11962. distanceToTarget = Distance2DBetweenCapsules( this, actor );
  11963. }
  11964.  
  11965.  
  11966. if ( distanceToTarget < findMoveTargetDist + 5.0f )
  11967. {
  11968. return true;
  11969. }
  11970.  
  11971. if ( actor.IsInCombat() || this.IsHardLockEnabled() )
  11972. {
  11973. targetCapsuleHeight = ( (CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent() ).GetCapsuleHeight();
  11974. if ( targetCapsuleHeight >= 2.0f || npc.GetCurrentStance() == NS_Fly )
  11975. {
  11976.  
  11977. if ( distanceToTarget < 40.0f )
  11978. {
  11979. return true;
  11980. }
  11981. }
  11982. }
  11983. }
  11984.  
  11985. if ( actor.GetAttitudeGroup() == 'npc_charmed' )
  11986. {
  11987. if ( theGame.GetGlobalAttitude( GetBaseAttitudeGroup(), actor.GetBaseAttitudeGroup() ) == AIA_Hostile )
  11988. {
  11989. return true;
  11990. }
  11991. }
  11992.  
  11993. return false;
  11994. }
  11995.  
  11996. function SetBIsCombatActionAllowed ( flag : bool )
  11997. {
  11998. bIsCombatActionAllowed = flag;
  11999.  
  12000. if ( !flag )
  12001. {
  12002. SetBIsInCombatAction(true);
  12003. }
  12004. else
  12005. {
  12006. this.ProcessLAxisCaching();
  12007.  
  12008. }
  12009.  
  12010.  
  12011. }
  12012.  
  12013. function GetBIsCombatActionAllowed() : bool
  12014. {
  12015. return bIsCombatActionAllowed;
  12016. }
  12017.  
  12018. function SetCombatAction( action : EBufferActionType )
  12019. {
  12020. currentCombatAction = action;
  12021. }
  12022.  
  12023. function GetCombatAction() : EBufferActionType
  12024. {
  12025. return currentCombatAction;
  12026. }
  12027.  
  12028. protected function WhenCombatActionIsFinished()
  12029. {
  12030. if(IsThrowingItem() || IsThrowingItemWithAim() )
  12031. {
  12032. if(inv.IsItemBomb(selectedItemId))
  12033. {
  12034. BombThrowAbort();
  12035. }
  12036. else
  12037. {
  12038. ThrowingAbort();
  12039. }
  12040. }
  12041.  
  12042. if ( this.GetCurrentStateName() != 'DismountHorse' )
  12043. OnRangedForceHolster( true );
  12044.  
  12045.  
  12046. }
  12047.  
  12048. public function IsInCombatAction_Attack(): bool
  12049. {
  12050. if ( IsInCombatAction_NonSpecialAttack() || IsInCombatAction_SpecialAttack() )
  12051. return true;
  12052. else
  12053. return false;
  12054. }
  12055.  
  12056. public function IsInCombatAction_NonSpecialAttack(): bool
  12057. {
  12058. if ( IsInCombatAction() && ( GetCombatAction() == EBAT_LightAttack || GetCombatAction() == EBAT_HeavyAttack ) )
  12059. return true;
  12060. else
  12061. return false;
  12062. }
  12063.  
  12064. public function IsInSpecificCombatAction ( specificCombatAction : EBufferActionType ) : bool
  12065. {
  12066. if ( IsInCombatAction() && GetCombatAction() == specificCombatAction )
  12067. return true;
  12068. else
  12069. return false;
  12070. }
  12071.  
  12072. public function IsInRunAnimation() : bool
  12073. {
  12074. return isInRunAnimation;
  12075. }
  12076.  
  12077.  
  12078. public function SetCombatIdleStance( stance : float )
  12079. {
  12080. SetBehaviorVariable( 'combatIdleStance', stance );
  12081. SetBehaviorVariable( 'CombatStanceForOverlay', stance );
  12082.  
  12083. if ( stance == 0.f )
  12084. LogChannel( 'ComboInput', "combatIdleStance = Left" );
  12085. else
  12086. LogChannel( 'ComboInput', "combatIdleStance = Right" );
  12087. }
  12088.  
  12089. public function GetCombatIdleStance() : float
  12090. {
  12091.  
  12092. return GetBehaviorVariable( 'combatIdleStance' );
  12093. }
  12094.  
  12095. protected var isRotatingInPlace : bool;
  12096. event OnRotateInPlaceStart()
  12097. {
  12098. isRotatingInPlace = true;
  12099. }
  12100.  
  12101. event OnRotateInPlaceEnd()
  12102. {
  12103. isRotatingInPlace = false;
  12104. }
  12105.  
  12106. event OnFullyBlendedIdle()
  12107. {
  12108. if ( bLAxisReleased )
  12109. {
  12110. ResetRawPlayerHeading();
  12111. ResetCachedRawPlayerHeading();
  12112. defaultLocomotionController.ResetMoveDirection();
  12113. }
  12114. }
  12115.  
  12116. private var isInIdle : bool;
  12117.  
  12118. event OnPlayerIdleStart()
  12119. {
  12120. isInIdle = true;
  12121. }
  12122.  
  12123. event OnPlayerIdleEnd()
  12124. {
  12125. isInIdle = false;
  12126. }
  12127.  
  12128. public function IsInIdle() : bool
  12129. {
  12130. return isInIdle;
  12131. }
  12132.  
  12133. event OnRunLoopStart()
  12134. {
  12135. EnableRunCamera( true );
  12136. }
  12137.  
  12138. event OnRunLoopEnd()
  12139. {
  12140. EnableRunCamera( false );
  12141. }
  12142.  
  12143. event OnCombatActionStartBehgraph()
  12144. {
  12145. var action : EBufferActionType;
  12146. var cost, delay : float;
  12147.  
  12148.  
  12149.  
  12150.  
  12151. OnCombatActionStart();
  12152.  
  12153. action = PerformingCombatAction();
  12154. switch ( action )
  12155. {
  12156. case EBAT_LightAttack :
  12157. {
  12158. abilityManager.GetStaminaActionCost(ESAT_LightAttack, cost, delay);
  12159. } break;
  12160. case EBAT_HeavyAttack :
  12161. {
  12162. abilityManager.GetStaminaActionCost(ESAT_HeavyAttack, cost, delay);
  12163. } break;
  12164. case EBAT_ItemUse :
  12165. {
  12166. abilityManager.GetStaminaActionCost(ESAT_UsableItem, cost, delay);
  12167. } break;
  12168. case EBAT_Parry :
  12169. {
  12170. abilityManager.GetStaminaActionCost(ESAT_Parry, cost, delay);
  12171. } break;
  12172. case EBAT_Dodge :
  12173. {
  12174. abilityManager.GetStaminaActionCost(ESAT_Dodge, cost, delay);
  12175. } break;
  12176. case EBAT_Roll :
  12177. abilityManager.GetStaminaActionCost(ESAT_Roll, cost, delay);
  12178. break;
  12179. case EBAT_SpecialAttack_Light :
  12180. {
  12181. abilityManager.GetStaminaActionCost(ESAT_Ability, cost, delay, 0,0, GetSkillAbilityName(S_Sword_s01));
  12182. } break;
  12183. case EBAT_SpecialAttack_Heavy :
  12184. {
  12185. abilityManager.GetStaminaActionCost(ESAT_Ability, cost, delay, 0,0, GetSkillAbilityName(S_Sword_s02));
  12186. } break;
  12187. case EBAT_Roll :
  12188. {
  12189. abilityManager.GetStaminaActionCost(ESAT_Evade, cost, delay);
  12190. } break;
  12191.  
  12192. default :
  12193. ;
  12194. }
  12195.  
  12196.  
  12197.  
  12198. if( delay > 0 )
  12199. PauseStaminaRegen( 'InsideCombatAction' );
  12200. }
  12201.  
  12202. public function HolsterUsableItem() : bool
  12203. {
  12204. return holsterUsableItem;
  12205. }
  12206.  
  12207. private var isInGuardedState : bool;
  12208. public function IsInGuardedState() : bool
  12209. {
  12210. return isInGuardedState;
  12211. }
  12212.  
  12213. event OnGuardedStart()
  12214. {
  12215. isInParryOrCounter = true;
  12216. isInGuardedState = true;
  12217. }
  12218.  
  12219. event OnGuardedEnd()
  12220. {
  12221. isInParryOrCounter = false;
  12222. isInGuardedState = false;
  12223. }
  12224.  
  12225. private var restoreUsableItem : bool;
  12226. private var holsterUsableItem : bool;
  12227. event OnCombatActionStart()
  12228. {
  12229.  
  12230.  
  12231. BlockAction( EIAB_UsableItem, 'OnCombatActionStart' );
  12232. BlockAction( EIAB_CallHorse, 'OnCombatActionStart' );
  12233.  
  12234.  
  12235.  
  12236. LogChannel('combatActionAllowed',"FALSE OnCombatActionStart");
  12237. SetBIsCombatActionAllowed( false );
  12238. SetBIsInputAllowed( false, 'OnCombatActionStart' );
  12239.  
  12240.  
  12241. ClearFinishableEnemyList( 0.f, 0 );
  12242.  
  12243. bIsInHitAnim = false;
  12244.  
  12245.  
  12246.  
  12247. if ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  12248. {
  12249. CleanCombatActionBuffer();
  12250. SetIsAimingCrossbow( false );
  12251. OnRangedForceHolster( false, true );
  12252. }
  12253.  
  12254.  
  12255. holsterUsableItem = false;
  12256. if ( thePlayer.IsHoldingItemInLHand() )
  12257. {
  12258. if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign )
  12259. holsterUsableItem = true;
  12260. else if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
  12261. {
  12262. if ( this.GetCurrentStateName() == 'CombatFists' )
  12263. holsterUsableItem = true;
  12264. }
  12265. }
  12266.  
  12267. if ( holsterUsableItem )
  12268. {
  12269. thePlayer.SetPlayerActionToRestore ( PATR_None );
  12270. thePlayer.OnUseSelectedItem( true );
  12271.  
  12272. restoreUsableItem = true;
  12273. }
  12274.  
  12275.  
  12276. if ( GetBehaviorVariable( 'combatActionType' ) != (int)CAT_Attack && GetBehaviorVariable( 'combatActionType' ) != (int)CAT_PreAttack )
  12277. {
  12278. RemoveTimer( 'ProcessAttackTimer' );
  12279. RemoveTimer( 'AttackTimerEnd' );
  12280. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  12281. }
  12282. else
  12283. {
  12284.  
  12285. BlockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  12286. }
  12287.  
  12288.  
  12289. }
  12290.  
  12291. var isInParryOrCounter : bool;
  12292. event OnParryOrCounterStart()
  12293. {
  12294. isInParryOrCounter = true;
  12295. OnCombatActionStartBehgraph();
  12296. }
  12297.  
  12298. event OnParryOrCounterEnd()
  12299. {
  12300. isInParryOrCounter = false;
  12301. OnCombatActionEnd();
  12302. SetBIsInCombatAction( false );
  12303. }
  12304.  
  12305.  
  12306. event OnCombatActionEnd()
  12307. {
  12308. var item : SItemUniqueId;
  12309. var combatActionType : float;
  12310.  
  12311. super.OnCombatActionEnd();
  12312.  
  12313.  
  12314.  
  12315. BlockAllActions( 'OnCombatActionStart', false );
  12316.  
  12317. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  12318.  
  12319.  
  12320. UnblockAction( EIAB_Movement, 'CombatActionFriendly' );
  12321.  
  12322.  
  12323.  
  12324.  
  12325. oTCameraOffset = 0.f;
  12326. oTCameraPitchOffset = 0.f;
  12327.  
  12328.  
  12329. SetBIsCombatActionAllowed( true );
  12330.  
  12331.  
  12332. SetBIsInputAllowed( true, 'OnCombatActionEnd' );
  12333. SetCanPlayHitAnim( true );
  12334. EnableFindTarget( true );
  12335.  
  12336.  
  12337.  
  12338.  
  12339. SetFinisherVictim( NULL );
  12340.  
  12341. OnBlockAllCombatTickets( false );
  12342.  
  12343. LogStamina("CombatActionEnd");
  12344.  
  12345.  
  12346.  
  12347.  
  12348. if(!IsDoingSpecialAttack(true))
  12349. SetAttackActionName('');
  12350.  
  12351.  
  12352. combatActionType = GetBehaviorVariable('combatActionType');
  12353.  
  12354.  
  12355. if(GetBehaviorVariable('combatActionType') == (int)CAT_SpecialAttack)
  12356. {
  12357. theGame.GetGameCamera().StopAnimation( 'camera_shake_loop_lvl1_1' );
  12358. OnSpecialAttackHeavyActionProcess();
  12359. }
  12360.  
  12361. substateManager.ReactToChanceToFallAndSlide();
  12362. }
  12363.  
  12364. event OnCombatActionFriendlyStart()
  12365. {
  12366. SetBIsInCombatActionFriendly(true);
  12367. BlockAction( EIAB_Movement, 'CombatActionFriendly', false, false, false );
  12368. OnCombatActionStart();
  12369. }
  12370.  
  12371. event OnCombatActionFriendlyEnd()
  12372. {
  12373. SetBIsInCombatActionFriendly(false);
  12374. UnblockAction( EIAB_Movement, 'CombatActionFriendly' );
  12375. OnCombatActionEnd();
  12376. SetBIsInCombatAction(false);
  12377.  
  12378. }
  12379.  
  12380. event OnHitStart()
  12381. {
  12382. var timeLeft : float;
  12383. var currentEffects : array<CBaseGameplayEffect>;
  12384. var none : SAbilityAttributeValue;
  12385.  
  12386. CancelHoldAttacks();
  12387. WhenCombatActionIsFinished();
  12388. if ( isInFinisher )
  12389. {
  12390. if ( finisherTarget )
  12391. ( (CNewNPC)finisherTarget ).SignalGameplayEvent( 'FinisherInterrupt' );
  12392. isInFinisher = false;
  12393. finisherTarget = NULL;
  12394. SetBIsCombatActionAllowed( true );
  12395. }
  12396.  
  12397. bIsInHitAnim = true;
  12398.  
  12399. OnCombatActionStart();
  12400.  
  12401.  
  12402. ResumeStaminaRegen( 'InsideCombatAction' );
  12403.  
  12404. if( GetHealthPercents() < 0.3f )
  12405. {
  12406. PlayBattleCry('BattleCryBadSituation', 0.10f, true );
  12407. }
  12408. else
  12409. {
  12410. PlayBattleCry('BattleCryBadSituation', 0.05f, true );
  12411. }
  12412. }
  12413.  
  12414. event OnHitStartSwimming()
  12415. {
  12416. OnRangedForceHolster( true, true, false );
  12417. }
  12418.  
  12419. private var finisherSaveLock : int;
  12420. event OnFinisherStart()
  12421. {
  12422. var currentEffects : array<CBaseGameplayEffect>;
  12423.  
  12424. theGame.CreateNoSaveLock("Finisher",finisherSaveLock,true,false);
  12425.  
  12426. isInFinisher = true;
  12427.  
  12428. finisherTarget = slideTarget;
  12429. OnCombatActionStart();
  12430.  
  12431. CancelHoldAttacks();
  12432.  
  12433. PlayFinisherCameraAnimation( theGame.GetSyncAnimManager().GetFinisherCameraAnimName() );
  12434. this.AddAnimEventCallback('SyncEvent','OnFinisherAnimEvent_SyncEvent');
  12435. SetImmortalityMode( AIM_Invulnerable, AIC_SyncedAnim );
  12436. }
  12437.  
  12438. public function IsPerformingFinisher() : bool
  12439. {
  12440. return isInFinisher;
  12441. }
  12442.  
  12443. private function PlayFinisherCameraAnimation( cameraAnimName : name )
  12444. {
  12445. var camera : CCustomCamera = theGame.GetGameCamera();
  12446. var animation : SCameraAnimationDefinition;
  12447.  
  12448. if( IsLastEnemyKilled() && theGame.GetWorld().NavigationCircleTest( this.GetWorldPosition(), 3.f ) )
  12449. {
  12450. camera.StopAnimation('camera_shake_hit_lvl3_1' );
  12451.  
  12452. animation.animation = cameraAnimName;
  12453. animation.priority = CAP_Highest;
  12454. animation.blendIn = 0.5f;
  12455. animation.blendOut = 0.5f;
  12456. animation.weight = 1.f;
  12457. animation.speed = 1.0f;
  12458. animation.reset = true;
  12459.  
  12460. camera.PlayAnimation( animation );
  12461.  
  12462.  
  12463. thePlayer.EnableManualCameraControl( false, 'Finisher' );
  12464. }
  12465. }
  12466.  
  12467. public function IsLastEnemyKilled() : bool
  12468. {
  12469. var tempMoveTargets : array<CActor>;
  12470.  
  12471. FindMoveTarget();
  12472. tempMoveTargets = GetMoveTargets();
  12473. if ( tempMoveTargets.Size() <= 0 || !thePlayer.IsThreat( tempMoveTargets[0] ) )
  12474. return true;
  12475.  
  12476. return false;
  12477. }
  12478.  
  12479. event OnFinisherAnimEvent_SyncEvent( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  12480. {
  12481. if ( finisherTarget )
  12482. ( (CNewNPC)finisherTarget ).SignalGameplayEvent('FinisherKill');
  12483. finisherTarget = NULL;
  12484. }
  12485.  
  12486. event OnFinisherEnd()
  12487. {
  12488. isInFinisher = false;
  12489. finisherTarget = NULL;
  12490.  
  12491. theGame.ReleaseNoSaveLock(finisherSaveLock);
  12492.  
  12493. this.RemoveAnimEventCallback('SyncEvent');
  12494.  
  12495.  
  12496. SetImmortalityMode( AIM_None, AIC_SyncedAnim );
  12497. theGame.RemoveTimeScale( 'AnimEventSlomoMo' );
  12498. AddTimer( 'FinisherEndEnableCamera', 0.5f );
  12499.  
  12500. OnCombatActionEnd();
  12501. OnCombatActionEndComplete();
  12502. }
  12503.  
  12504. private timer function FinisherEndEnableCamera( dt : float, id : int )
  12505. {
  12506. thePlayer.EnableManualCameraControl( true, 'Finisher' );
  12507. }
  12508.  
  12509. public function SpawnFinisherBlood()
  12510. {
  12511. var weaponEntity : CEntity;
  12512. var weaponSlotMatrix : Matrix;
  12513. var bloodFxPos : Vector;
  12514. var bloodFxRot : EulerAngles;
  12515. var tempEntity : CEntity;
  12516.  
  12517. weaponEntity = this.GetInventory().GetItemEntityUnsafe( GetInventory().GetItemFromSlot('r_weapon') );
  12518. weaponEntity.CalcEntitySlotMatrix( 'blood_fx_point', weaponSlotMatrix );
  12519. bloodFxPos = MatrixGetTranslation( weaponSlotMatrix );
  12520. bloodFxRot = this.GetWorldRotation();
  12521. tempEntity = theGame.CreateEntity( (CEntityTemplate)LoadResource('finisher_blood'), bloodFxPos, bloodFxRot);
  12522. tempEntity.PlayEffect('crawl_blood');
  12523. }
  12524.  
  12525.  
  12526. event OnCombatActionEndComplete()
  12527. {
  12528. var buff : CBaseGameplayEffect;
  12529.  
  12530. buff = ChooseCurrentCriticalBuffForAnim();
  12531. SetCombatAction( EBAT_EMPTY );
  12532.  
  12533.  
  12534. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart' );
  12535. UnblockAction( EIAB_OpenInventory, 'OnCombatActionStart' );
  12536. UnblockAction( EIAB_UsableItem, 'OnCombatActionStart' );
  12537.  
  12538. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  12539.  
  12540. SetUnpushableTarget( NULL );
  12541. SetBIsInCombatAction(false);
  12542. SetIsCurrentlyDodging(false);
  12543. SetMoveTargetChangeAllowed( true );
  12544. SetCanPlayHitAnim( true );
  12545.  
  12546. SetFinisherVictim( NULL );
  12547.  
  12548. this.RemoveBuffImmunity(EET_Burning, 'AnimEvent_RemoveBurning');
  12549.  
  12550. if ( rangedWeapon && rangedWeapon.GetCurrentStateName() == 'State_WeaponWait' && !buff )
  12551. {
  12552. ClearCustomOrientationInfoStack();
  12553. SetSlideTarget( NULL );
  12554. }
  12555.  
  12556. UnblockAction( EIAB_Crossbow, 'OnForceHolster' );
  12557.  
  12558. specialAttackCamera = false;
  12559.  
  12560. bIsRollAllowed = false;
  12561.  
  12562. if ( bLAxisReleased )
  12563. {
  12564. ResetRawPlayerHeading();
  12565. ResetCachedRawPlayerHeading();
  12566. }
  12567.  
  12568.  
  12569. ReapplyCriticalBuff();
  12570. SetBIsInputAllowed( true, 'OnCombatActionEndComplete' );
  12571.  
  12572.  
  12573. ResumeStaminaRegen( 'InsideCombatAction' );
  12574.  
  12575. bIsInHitAnim = false;
  12576.  
  12577. SetBIsCombatActionAllowed( true );
  12578.  
  12579. m_LastWeaponTipPos = Vector(0, 0, 0, 0 );
  12580.  
  12581.  
  12582. this.AddTimer('FreeTickets',3.f,false);
  12583.  
  12584.  
  12585.  
  12586. }
  12587.  
  12588. event OnMovementFullyBlended()
  12589. {
  12590. SetBehaviorVariable( 'isPerformingSpecialAttack', 0.f );
  12591.  
  12592. if ( restoreUsableItem )
  12593. {
  12594. restoreUsableItem = false;
  12595. SetPlayerActionToRestore ( PATR_Default );
  12596. OnUseSelectedItem();
  12597. }
  12598. }
  12599.  
  12600. event OnCombatMovementStart()
  12601. {
  12602. SetCombatIdleStance( 1.f );
  12603. OnCombatActionEndComplete();
  12604. }
  12605.  
  12606. timer function FreeTickets( dt : float, id : int )
  12607. {
  12608. FreeTicketAtCombatTarget();
  12609. }
  12610.  
  12611.  
  12612.  
  12613. event OnGuardedReleased(){}
  12614. event OnPerformAttack( playerAttackType : name ){}
  12615. event OnPerformEvade( playerEvadeType : EPlayerEvadeType ){}
  12616. event OnInterruptAttack(){}
  12617. event OnPerformGuard(){}
  12618. event OnSpawnHorse(){}
  12619. event OnDismountActionScriptCallback(){}
  12620.  
  12621. event OnHorseSummonStart()
  12622. {
  12623. thePlayer.BlockAction(EIAB_CallHorse, 'HorseSummon');
  12624. thePlayer.BlockAction(EIAB_Signs, 'HorseSummon');
  12625. thePlayer.BlockAction(EIAB_Crossbow, 'HorseSummon');
  12626. thePlayer.BlockAction(EIAB_UsableItem, 'HorseSummon');
  12627. thePlayer.BlockAction(EIAB_ThrowBomb, 'HorseSummon');
  12628. thePlayer.BlockAction(EIAB_SwordAttack, 'HorseSummon');
  12629. thePlayer.BlockAction(EIAB_Jump, 'HorseSummon');
  12630. thePlayer.BlockAction(EIAB_Dodge, 'HorseSummon');
  12631. thePlayer.BlockAction(EIAB_LightAttacks, 'HorseSummon');
  12632. thePlayer.BlockAction(EIAB_HeavyAttacks, 'HorseSummon');
  12633. thePlayer.BlockAction(EIAB_SpecialAttackLight, 'HorseSummon');
  12634. thePlayer.BlockAction(EIAB_SpecialAttackHeavy, 'HorseSummon');
  12635.  
  12636. horseSummonTimeStamp = theGame.GetEngineTimeAsSeconds();
  12637. }
  12638.  
  12639. event OnHorseSummonStop()
  12640. {
  12641. thePlayer.BlockAllActions('HorseSummon',false);
  12642. }
  12643.  
  12644.  
  12645. event OnCombatActionStartVehicle( action : EVehicleCombatAction )
  12646. {
  12647. this.SetBIsCombatActionAllowed( false );
  12648.  
  12649. if ( action != EHCA_ShootCrossbow )
  12650. {
  12651. SetIsAimingCrossbow( false );
  12652. OnRangedForceHolster();
  12653. }
  12654. }
  12655.  
  12656. event OnCombatActionEndVehicle()
  12657. {
  12658. this.SetBIsCombatActionAllowed( true );
  12659. }
  12660.  
  12661.  
  12662.  
  12663.  
  12664.  
  12665. protected function CriticalBuffInformBehavior(buff : CBaseGameplayEffect)
  12666. {
  12667.  
  12668. if( !CanAnimationReactToCriticalState( buff ) )
  12669. {
  12670. return;
  12671. }
  12672.  
  12673.  
  12674.  
  12675.  
  12676. SetBehaviorVariable( 'CriticalStateType', (int)GetBuffCriticalType(buff) );
  12677. SetBehaviorVariable( 'bCriticalState', 1);
  12678.  
  12679. if(CriticalBuffUsesFullBodyAnim(buff))
  12680. RaiseEvent('CriticalState');
  12681.  
  12682. SetBehaviorVariable( 'IsInAir', (int)IsInAir());
  12683.  
  12684. LogCritical("Sending player critical state event for <<" + buff.GetEffectType() + ">>");
  12685.  
  12686.  
  12687. }
  12688.  
  12689. private function CanAnimationReactToCriticalState( buff : CBaseGameplayEffect ) : bool
  12690. {
  12691. var buffCritical : W3CriticalEffect;
  12692. var buffCriticalDOT : W3CriticalDOTEffect;
  12693. var isHeavyCritical : bool;
  12694.  
  12695. isHeavyCritical = false;
  12696.  
  12697.  
  12698. buffCritical = ( W3CriticalEffect ) buff;
  12699. if( buffCritical )
  12700. {
  12701. isHeavyCritical = buffCritical.explorationStateHandling == ECH_HandleNow;
  12702. }
  12703. else
  12704. {
  12705. buffCriticalDOT = ( W3CriticalDOTEffect ) buff;
  12706. if( buffCriticalDOT )
  12707. {
  12708. isHeavyCritical = buffCriticalDOT.explorationStateHandling == ECH_HandleNow;
  12709. }
  12710. }
  12711.  
  12712.  
  12713. if( !isHeavyCritical )
  12714. {
  12715. if( !CanReactToCriticalState() )
  12716. {
  12717. return false;
  12718. }
  12719. }
  12720.  
  12721. return true;
  12722. }
  12723.  
  12724. public function CanReactToCriticalState() : bool
  12725. {
  12726. return substateManager.CanReactToHardCriticalState();
  12727. }
  12728.  
  12729. event OnCriticalStateAnimStart()
  12730. {
  12731. var heading : float;
  12732. var newCritical : ECriticalStateType;
  12733. var newReqCS : CBaseGameplayEffect;
  12734.  
  12735. OnCombatActionEndComplete();
  12736.  
  12737.  
  12738. newReqCS = newRequestedCS;
  12739. if(super.OnCriticalStateAnimStart())
  12740. {
  12741.  
  12742. RemoveTimer( 'IsItemUseInputHeld' );
  12743. keepRequestingCriticalAnimStart = false;
  12744. CancelHoldAttacks();
  12745.  
  12746.  
  12747.  
  12748.  
  12749.  
  12750. if(!IsUsingVehicle())
  12751. {
  12752. newCritical = GetBuffCriticalType(newReqCS);
  12753. if(newCritical == ECST_HeavyKnockdown
  12754. || newCritical == ECST_Knockdown
  12755. || newCritical == ECST_Stagger
  12756. || newCritical == ECST_Ragdoll
  12757. || newCritical == ECST_LongStagger )
  12758. {
  12759. if(newReqCS.GetCreator())
  12760. heading = VecHeading(newReqCS.GetCreator().GetWorldPosition() - GetWorldPosition());
  12761. else
  12762. heading = GetHeading();
  12763.  
  12764.  
  12765. SetCustomRotation( 'Knockdown', heading, 2160.f, 0.1f, true );
  12766.  
  12767. if ( newCritical != ECST_Stagger && newCritical != ECST_LongStagger )
  12768. substateManager.ReactOnCriticalState( true );
  12769. }
  12770. }
  12771.  
  12772. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'CriticalEffectStart', -1, 30.0f, -1.f, -1, true );
  12773. return true;
  12774. }
  12775.  
  12776.  
  12777. return false;
  12778. }
  12779.  
  12780.  
  12781. public function StartCSAnim(buff : CBaseGameplayEffect) : bool
  12782. {
  12783. SetBehaviorVariable( 'bCriticalStopped', 0 );
  12784.  
  12785. if(super.StartCSAnim(buff))
  12786. {
  12787. if(!CriticalBuffUsesFullBodyAnim(buff))
  12788. {
  12789. OnCriticalStateAnimStart();
  12790. }
  12791.  
  12792. ResumeStaminaRegen( 'InsideCombatAction' );
  12793.  
  12794. keepRequestingCriticalAnimStart = true;
  12795. AddTimer('RequestCriticalAnimStart', 0, true);
  12796.  
  12797.  
  12798. return true;
  12799. }
  12800.  
  12801. return false;
  12802. }
  12803.  
  12804. public function CriticalEffectAnimationInterrupted(reason : string) : bool
  12805. {
  12806. var ret : bool;
  12807.  
  12808. LogCriticalPlayer("R4Player.CriticalEffectAnimationInterrupted() - because: " + reason);
  12809.  
  12810. ret = super.CriticalEffectAnimationInterrupted(reason);
  12811.  
  12812. if(ret)
  12813. {
  12814. keepRequestingCriticalAnimStart = false;
  12815. }
  12816.  
  12817. substateManager.ReactOnCriticalState( false );
  12818.  
  12819. return ret;
  12820. }
  12821.  
  12822. public function CriticalStateAnimStopped(forceRemoveBuff : bool)
  12823. {
  12824. LogCriticalPlayer("R4Player.CriticalStateAnimStopped() - forced: " + forceRemoveBuff);
  12825.  
  12826. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'RecoveredFromCriticalEffect', -1, 30.0f, -1.f, -1, true );
  12827. super.CriticalStateAnimStopped(forceRemoveBuff);
  12828.  
  12829. substateManager.ReactOnCriticalState( false );
  12830. }
  12831.  
  12832.  
  12833. timer function RequestCriticalAnimStart(dt : float, id : int)
  12834. {
  12835. if(keepRequestingCriticalAnimStart)
  12836. {
  12837. if(newRequestedCS && newRequestedCS.GetDurationLeft() > 0)
  12838. {
  12839. CriticalBuffInformBehavior(newRequestedCS);
  12840. }
  12841. else
  12842. {
  12843. keepRequestingCriticalAnimStart = false;
  12844. RemoveTimer('RequestCriticalAnimStart');
  12845. }
  12846. }
  12847. else
  12848. {
  12849. RemoveTimer('RequestCriticalAnimStart');
  12850. }
  12851. }
  12852.  
  12853. event OnRagdollUpdate(progress : float)
  12854. {
  12855.  
  12856.  
  12857. SetIsInAir(progress == 0);
  12858. }
  12859.  
  12860.  
  12861. event OnRagdollOnGround()
  12862. {
  12863.  
  12864. TryToEndRagdollOnGround( 0.0f );
  12865. }
  12866.  
  12867. event OnRagdollInAir()
  12868. {
  12869. RemoveTimer('TryToEndRagdollOnGround');
  12870. }
  12871.  
  12872. event OnNoLongerInRagdoll()
  12873. {
  12874. RemoveTimer('TryToEndRagdollOnGround');
  12875. }
  12876.  
  12877. timer function TryToEndRagdollOnGround( td : float, optional id : int)
  12878. {
  12879. var critical : CBaseGameplayEffect;
  12880. var type : EEffectType;
  12881.  
  12882. critical = GetCurrentlyAnimatedCS();
  12883. if(critical)
  12884. {
  12885. type = critical.GetEffectType();
  12886. if(type == EET_Knockdown || type == EET_HeavyKnockdown || type == EET_Ragdoll)
  12887. {
  12888.  
  12889. if (critical.GetTimeActive() >= 2.5f)
  12890. {
  12891. SetIsInAir(false);
  12892. RequestCriticalAnimStop();
  12893. RemoveTimer('TryToEndRagdollOnGround');
  12894. }
  12895. else
  12896. {
  12897. AddTimer('TryToEndRagdollOnGround', 0.2f, true);
  12898. }
  12899. return;
  12900. }
  12901. }
  12902.  
  12903.  
  12904. RemoveTimer('TryToEndRagdollOnGround');
  12905. }
  12906.  
  12907. public function RequestCriticalAnimStop(optional dontSetCriticalToStopped : bool)
  12908. {
  12909. var buff : CBaseGameplayEffect;
  12910.  
  12911. buff = GetCurrentlyAnimatedCS();
  12912. if(buff && !CriticalBuffUsesFullBodyAnim(buff))
  12913. {
  12914. CriticalStateAnimStopped(false);
  12915. }
  12916.  
  12917. if(!buff || !CriticalBuffUsesFullBodyAnim(buff))
  12918. {
  12919. SetBehaviorVariable( 'bCriticalState', 0);
  12920. }
  12921.  
  12922. super.RequestCriticalAnimStop(dontSetCriticalToStopped);
  12923. }
  12924.  
  12925.  
  12926.  
  12927.  
  12928. public function SimulateBuffTimePassing(simulatedTime : float)
  12929. {
  12930. effectManager.SimulateBuffTimePassing(simulatedTime);
  12931. }
  12932.  
  12933. public function AddEffectDefault(effectType : EEffectType, creat : CGameplayEntity, srcName : string, optional isSignEffect : bool) : EEffectInteract
  12934. {
  12935. var params : SCustomEffectParams;
  12936.  
  12937.  
  12938. if(effectType == EET_Stagger || effectType == EET_LongStagger || effectType == EET_Knockdown || effectType == EET_HeavyKnockdown)
  12939. {
  12940. params.effectType = effectType;
  12941. params.creator = creat;
  12942. params.sourceName = srcName;
  12943. params.isSignEffect = isSignEffect;
  12944.  
  12945. if ( effectType == EET_Stagger )
  12946. params.duration = 1.83;
  12947. else if ( effectType == EET_LongStagger )
  12948. params.duration = 4;
  12949. else if ( effectType == EET_Knockdown )
  12950. params.duration = 2.5;
  12951. else if ( effectType == EET_HeavyKnockdown )
  12952. params.duration = 4;
  12953.  
  12954. return super.AddEffectCustom(params);
  12955. }
  12956. else
  12957. {
  12958. return super.AddEffectDefault(effectType, creat, srcName, isSignEffect);
  12959. }
  12960. }
  12961.  
  12962.  
  12963.  
  12964.  
  12965.  
  12966. public function CheatResurrect()
  12967. {
  12968. var items : array< SItemUniqueId >;
  12969. var i, size, itemLevel, maxPrice, itemPrice : int;
  12970. var itemToEquip : SItemUniqueId;
  12971.  
  12972. if(IsAlive())
  12973. return;
  12974.  
  12975.  
  12976. if ( !theGame.GetGuiManager().GetRootMenu() )
  12977. {
  12978. Log(" *** Call this function after DeathScreen appears *** ");
  12979. return;
  12980. }
  12981.  
  12982.  
  12983. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_DebugInput) );
  12984.  
  12985. SetAlive(true);
  12986.  
  12987. SetKinematic(true);
  12988.  
  12989. EnableFindTarget( true );
  12990. SetBehaviorVariable( 'Ragdoll_Weight', 0.f );
  12991. RaiseForceEvent( 'RecoverFromRagdoll' );
  12992. SetCanPlayHitAnim( true );
  12993. SetBehaviorVariable( 'CriticalStateType', (int)ECST_None );
  12994. GoToStateIfNew('Exploration');
  12995.  
  12996. ( (CDismembermentComponent)this.GetComponent( 'Dismemberment' ) ).ClearVisibleWound();
  12997.  
  12998. SetIsInAir(false);
  12999.  
  13000. theInput.SetContext('Exploration');
  13001.  
  13002. ResetDeathType();
  13003.  
  13004. ForceUnlockAllInputActions(false);
  13005.  
  13006. theGame.CloseMenu('DeathScreenMenu');
  13007.  
  13008.  
  13009. theSound.LeaveGameState(ESGS_Death);
  13010.  
  13011.  
  13012. abilityManager.ForceSetStat(BCS_Vitality, GetStatMax(BCS_Vitality));
  13013. effectManager.StopVitalityRegen();
  13014. abilityManager.ForceSetStat( BCS_Air , 100.f );
  13015. effectManager.StopAirRegen();
  13016. abilityManager.ForceSetStat( BCS_Stamina , 100.f );
  13017. effectManager.StopStaminaRegen();
  13018. abilityManager.ForceSetStat( BCS_Toxicity , 0.f );
  13019. abilityManager.ForceSetStat( BCS_Focus , 0.f );
  13020. GetWitcherPlayer().UpdateEncumbrance();
  13021.  
  13022.  
  13023. if ( !inv.IsThereItemOnSlot( EES_SteelSword ) )
  13024. {
  13025. items = inv.GetItemsByCategory( 'steelsword' );
  13026. }
  13027. else if ( !inv.IsThereItemOnSlot( EES_SilverSword ) )
  13028. {
  13029. items = inv.GetItemsByCategory( 'silversword' );
  13030. }
  13031.  
  13032. size = items.Size();
  13033. maxPrice = -1;
  13034. for ( i = 0; i < size; i += 1 )
  13035. {
  13036. itemPrice = inv.GetItemPrice(items[i]);
  13037. itemLevel = inv.GetItemLevel(items[i]);
  13038. if ( itemLevel <= GetLevel() && itemPrice > maxPrice )
  13039. {
  13040. maxPrice = itemPrice;
  13041. itemToEquip = items[i];
  13042. }
  13043. }
  13044. if( inv.IsIdValid( itemToEquip ) )
  13045. {
  13046. EquipItem( itemToEquip , , true );
  13047. }
  13048.  
  13049. theGame.ReleaseNoSaveLock(deathNoSaveLock);
  13050. }
  13051.  
  13052.  
  13053.  
  13054. public function SetIsInsideInteraction(b : bool) {isInsideInteraction = b;}
  13055. public function IsInsideInteraction() : bool {return isInsideInteraction;}
  13056.  
  13057. public function SetIsInsideHorseInteraction( b : bool, horse : CEntity )
  13058. {
  13059.  
  13060. if(b)
  13061. horse.SetBehaviorVariable( 'horsePetting', 1.0f );
  13062. else if(!isPettingHorse)
  13063. horseInteractionSource.SetBehaviorVariable( 'horsePetting', 0.0f );
  13064.  
  13065.  
  13066. isInsideHorseInteraction = b;
  13067. horseInteractionSource = horse;
  13068. }
  13069. public function IsInsideHorseInteraction() : bool {return isInsideHorseInteraction;}
  13070.  
  13071.  
  13072. event OnInteractionActivationTest( interactionComponentName : string, activator : CEntity )
  13073. {
  13074. if ( interactionComponentName == "ClimbLadder" )
  13075. {
  13076. if( PlayerHasLadderExplorationReady() )
  13077. {
  13078. return true;
  13079. }
  13080. }
  13081.  
  13082. return false;
  13083. }
  13084.  
  13085. private function PlayerHasLadderExplorationReady() : bool
  13086. {
  13087. if( !substateManager.CanInteract() )
  13088. {
  13089. return false;
  13090. }
  13091.  
  13092. if( !substateManager.m_SharedDataO.HasValidLadderExploration() )
  13093. {
  13094. return false;
  13095. }
  13096.  
  13097. return true;
  13098. }
  13099.  
  13100.  
  13101.  
  13102.  
  13103.  
  13104. public function SetGuarded(flag : bool)
  13105. {
  13106. super.SetGuarded(flag);
  13107.  
  13108. if(flag && FactsQuerySum("tut_fight_use_slomo") > 0)
  13109. {
  13110. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
  13111. FactsRemove("tut_fight_slomo_ON");
  13112. }
  13113. }
  13114.  
  13115.  
  13116. public function IsGuarded() : bool
  13117. {
  13118. return super.IsGuarded() && ( !rangedWeapon || rangedWeapon.GetCurrentStateName() == 'State_WeaponWait' );
  13119. }
  13120.  
  13121.  
  13122.  
  13123.  
  13124. public function GetSelectedItemId() : SItemUniqueId {return selectedItemId;}
  13125. public function ClearSelectedItemId() {selectedItemId = GetInvalidUniqueId();}
  13126.  
  13127. public function IsHoldingItemInLHand() : bool
  13128. {
  13129. return currentlyEquipedItemL != GetInvalidUniqueId();
  13130. }
  13131.  
  13132. public function GetCurrentlyUsedItemL () : W3UsableItem
  13133. {
  13134. return currentlyUsedItemL;
  13135. }
  13136.  
  13137. public function SetPlayerActionToRestore ( actionToRestoreType : EPlayerActionToRestore )
  13138. {
  13139. playerActionToRestore = actionToRestoreType;
  13140. }
  13141.  
  13142. public function IsCurrentlyUsingItemL () : bool
  13143. {
  13144. return currentlyUsingItem;
  13145. }
  13146.  
  13147. function BlockSlotsOnLItemUse ()
  13148. {
  13149. var slotsToBlock : array<name>;
  13150.  
  13151. slotsToBlock.PushBack( 'Slot1' );
  13152. slotsToBlock.PushBack( 'Slot2' );
  13153. slotsToBlock.PushBack( 'Slot3' );
  13154. slotsToBlock.PushBack( 'Slot4' );
  13155. slotsToBlock.PushBack( 'Slot5' );
  13156. slotsToBlock.PushBack( 'Yrden' );
  13157. slotsToBlock.PushBack( 'Quen' );
  13158. slotsToBlock.PushBack( 'Igni' );
  13159. slotsToBlock.PushBack( 'Axii' );
  13160. slotsToBlock.PushBack( 'Aard' );
  13161.  
  13162.  
  13163. EnableRadialSlotsWithSource ( false, slotsToBlock, 'usableItemL' );
  13164. }
  13165.  
  13166. function UnblockSlotsOnLItemUse ()
  13167. {
  13168. var slotsToBlock : array<name>;
  13169.  
  13170. slotsToBlock.PushBack( 'Slot1' );
  13171. slotsToBlock.PushBack( 'Slot2' );
  13172. slotsToBlock.PushBack( 'Slot3' );
  13173. slotsToBlock.PushBack( 'Slot4' );
  13174. slotsToBlock.PushBack( 'Slot5' );
  13175. slotsToBlock.PushBack( 'Yrden' );
  13176. slotsToBlock.PushBack( 'Quen' );
  13177. slotsToBlock.PushBack( 'Igni' );
  13178. slotsToBlock.PushBack( 'Axii' );
  13179. slotsToBlock.PushBack( 'Aard' );
  13180.  
  13181.  
  13182. EnableRadialSlotsWithSource ( true, slotsToBlock, 'usableItemL' );
  13183. }
  13184.  
  13185. function IsUsableItemLBlocked () : bool
  13186. {
  13187. return isUsableItemBlocked;
  13188. }
  13189. function HideUsableItem( optional force : bool )
  13190. {
  13191. if( currentlyEquipedItemL != GetInvalidUniqueId() )
  13192. {
  13193. if( force )
  13194. {
  13195. if( !RaiseForceEvent( 'ItemEndL' ) )
  13196. {
  13197.  
  13198. OnUsingItemsReset();
  13199. }
  13200. return;
  13201.  
  13202. }
  13203. RaiseEvent( 'ItemUseL' );
  13204. }
  13205. }
  13206. function ProcessUsableItemsTransition ( actionToRestore : EPlayerActionToRestore )
  13207. {
  13208. var category : name;
  13209. var signSkill : ESkill;
  13210.  
  13211. category = inv.GetItemCategory ( selectedItemId );
  13212. signSkill = SignEnumToSkillEnum( GetEquippedSign());
  13213.  
  13214. switch ( actionToRestore )
  13215. {
  13216. case PATR_None:
  13217. if ( currentlyUsedItemL )
  13218. {
  13219. inv.UnmountItem( currentlyEquipedItemL, true );
  13220. }
  13221. currentlyEquipedItemL = GetInvalidUniqueId();
  13222. return;
  13223.  
  13224. case PATR_Default:
  13225. if ( IsSlotQuickslot( inv.GetSlotForItemId ( selectedItemId )) && category == 'usable' && currentlyEquipedItemL != selectedItemId )
  13226. {
  13227. if ( currentlyUsedItemL )
  13228. {
  13229. inv.UnmountItem( currentlyEquipedItemL, true );
  13230. }
  13231. currentlyEquipedItemL = GetInvalidUniqueId();
  13232. OnUseSelectedItem();
  13233. return;
  13234. }
  13235. break;
  13236. case PATR_Crossbow:
  13237. if ( inv.IsItemCrossbow ( selectedItemId ) )
  13238. {
  13239. if ( currentlyUsedItemL )
  13240. {
  13241. inv.UnmountItem( currentlyEquipedItemL, true );
  13242. }
  13243. currentlyEquipedItemL = GetInvalidUniqueId();
  13244. SetIsAimingCrossbow( true );
  13245.  
  13246. if ( theInput.IsActionPressed( 'ThrowItem' ) )
  13247. SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  13248. else
  13249. {
  13250. SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  13251. SetupCombatAction( EBAT_ItemUse, BS_Released );
  13252. }
  13253. return;
  13254. }
  13255. break;
  13256. case PATR_CastSign:
  13257. if( signSkill != S_SUndefined && playerActionToRestore == PATR_CastSign )
  13258. {
  13259. if ( currentlyUsedItemL )
  13260. {
  13261. inv.UnmountItem( currentlyEquipedItemL, true );
  13262. }
  13263. currentlyEquipedItemL = GetInvalidUniqueId();
  13264.  
  13265. if( HasStaminaToUseSkill( signSkill, false ) )
  13266. {
  13267. if( GetInvalidUniqueId() != inv.GetItemFromSlot( 'l_weapon' ) )
  13268. PushCombatActionOnBuffer( EBAT_CastSign, BS_Pressed );
  13269. else
  13270. SetupCombatAction( EBAT_CastSign, BS_Pressed );
  13271. }
  13272. else
  13273. {
  13274. thePlayer.SoundEvent("gui_no_stamina");
  13275. }
  13276. return;
  13277. }
  13278. break;
  13279. case PATR_ThrowBomb:
  13280. if ( inv.IsItemBomb ( selectedItemId ) )
  13281. {
  13282. if ( currentlyUsedItemL )
  13283. {
  13284. inv.UnmountItem( currentlyEquipedItemL, true );
  13285. }
  13286. currentlyEquipedItemL = GetInvalidUniqueId();
  13287. PrepareToAttack();
  13288. SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  13289. return;
  13290. }
  13291. break;
  13292. case PATR_CallHorse:
  13293. theGame.OnSpawnPlayerHorse();
  13294. break;
  13295. default:
  13296. if ( currentlyUsedItemL )
  13297. {
  13298. inv.UnmountItem( currentlyEquipedItemL, true );
  13299. }
  13300. currentlyEquipedItemL = GetInvalidUniqueId();
  13301. return;
  13302. }
  13303. if ( currentlyUsedItemL )
  13304. {
  13305. inv.UnmountItem( currentlyEquipedItemL, true );
  13306. }
  13307. currentlyEquipedItemL = GetInvalidUniqueId();
  13308. }
  13309.  
  13310. function GetUsableItemLtransitionAllowed () : bool
  13311. {
  13312. return isUsableItemLtransitionAllowed;
  13313. }
  13314.  
  13315. function SetUsableItemLtransitionAllowed ( isAllowed : bool)
  13316. {
  13317. isUsableItemLtransitionAllowed = isAllowed;
  13318. }
  13319.  
  13320. event OnItemUseLUnBlocked ()
  13321. {
  13322. if ( isUsableItemBlocked )
  13323. {
  13324. isUsableItemBlocked = false;
  13325. UnblockSlotsOnLItemUse ();
  13326. }
  13327. }
  13328.  
  13329. event OnItemUseLBlocked ()
  13330. {
  13331. if ( !isUsableItemBlocked )
  13332. {
  13333. isUsableItemBlocked = true;
  13334. BlockSlotsOnLItemUse ();
  13335. }
  13336. }
  13337.  
  13338. event OnUsingItemsReset()
  13339. {
  13340. if ( currentlyUsingItem )
  13341. {
  13342. OnItemUseLUnBlocked ();
  13343. OnUsingItemsComplete();
  13344. }
  13345. }
  13346. event OnUsingItemsComplete ()
  13347. {
  13348. if ( isUsableItemBlocked )
  13349. {
  13350. OnItemUseLUnBlocked ();
  13351. }
  13352. currentlyUsingItem = false;
  13353. if ( GetUsableItemLtransitionAllowed () )
  13354. {
  13355. ProcessUsableItemsTransition( playerActionToRestore );
  13356. }
  13357. else
  13358. {
  13359. if ( currentlyUsedItemL )
  13360. {
  13361. inv.UnmountItem( currentlyEquipedItemL, true );
  13362. }
  13363. currentlyEquipedItemL = GetInvalidUniqueId();
  13364. }
  13365.  
  13366. SetPlayerActionToRestore ( PATR_Default );
  13367. }
  13368.  
  13369. event OnUseSelectedItem( optional force : bool )
  13370. {
  13371. var category : name;
  13372. var itemEntity : W3UsableItem;
  13373.  
  13374. if ( isUsableItemBlocked && !force )
  13375. {
  13376. return false;
  13377. }
  13378. if ( IsCastingSign() )
  13379. return false;
  13380.  
  13381. if ( currentlyEquipedItemL != GetInvalidUniqueId() )
  13382. {
  13383. SetBehaviorVariable( 'SelectedItemL', (int)GetUsableItemTypeById( currentlyEquipedItemL ), true );
  13384. if ( force )
  13385. {
  13386. if ( RaiseEvent( 'ItemEndL' ) )
  13387. {
  13388. SetUsableItemLtransitionAllowed ( true );
  13389. return true;
  13390. }
  13391. }
  13392. else
  13393. {
  13394. if ( RaiseEvent( 'ItemUseL' ) )
  13395. {
  13396. SetUsableItemLtransitionAllowed ( true );
  13397. return true;
  13398. }
  13399. }
  13400. }
  13401. else
  13402. {
  13403. category = inv.GetItemCategory( selectedItemId );
  13404. if( category != 'usable' )
  13405. {
  13406. return false;
  13407. }
  13408. SetBehaviorVariable( 'SelectedItemL', (int)GetUsableItemTypeById( selectedItemId ), true );
  13409. if( RaiseEvent( 'ItemUseL' ) )
  13410. {
  13411. currentlyEquipedItemL = selectedItemId;
  13412. SetUsableItemLtransitionAllowed ( false );
  13413. currentlyUsingItem = true;
  13414.  
  13415.  
  13416. SetBehaviorVariable('playerDoubleHandSword',0.0f);
  13417.  
  13418. return true;
  13419. }
  13420. inv.UnmountItem( selectedItemId, true );
  13421. }
  13422. }
  13423.  
  13424. protected saved var currentlyUsingItem : bool;
  13425.  
  13426. public function ProcessUseSelectedItem( itemEntity : W3UsableItem, optional shouldCallOnUsed : bool )
  13427. {
  13428. currentlyUsedItemL = itemEntity;
  13429. DrainStamina(ESAT_UsableItem);
  13430.  
  13431. if ( shouldCallOnUsed )
  13432. {
  13433. currentlyUsedItemL.OnUsed( thePlayer );
  13434. }
  13435. }
  13436.  
  13437. function GetUsableItemTypeById ( itemId : SItemUniqueId ) : EUsableItemType
  13438. {
  13439. var itemName : name;
  13440.  
  13441. itemName = inv.GetItemName ( itemId );
  13442.  
  13443. return theGame.GetDefinitionsManager().GetUsableItemType ( itemName );
  13444.  
  13445. }
  13446.  
  13447.  
  13448. public function StartWaitForItemSpawnAndProccesTask()
  13449. {
  13450. AddTimer( 'WaitForItemSpawnAndProccesTask', 0.001f, true,,,,true );
  13451. }
  13452.  
  13453.  
  13454. public function KillWaitForItemSpawnAndProccesTask()
  13455. {
  13456. RemoveTimer ( 'WaitForItemSpawnAndProccesTask' );
  13457. }
  13458.  
  13459.  
  13460.  
  13461. public function AllowUseSelectedItem()
  13462. {
  13463. m_useSelectedItemIfSpawned = true;
  13464. }
  13465.  
  13466.  
  13467.  
  13468. timer function WaitForItemSpawnAndProccesTask( timeDelta : float , id : int )
  13469. {
  13470. var itemEntity : W3UsableItem;
  13471. var canTaskBeKilled : bool;
  13472. canTaskBeKilled = false;
  13473.  
  13474. if ( IsCastingSign() )
  13475. {
  13476. return;
  13477. }
  13478.  
  13479.  
  13480. if ( selectedItemId == GetInvalidUniqueId() )
  13481. {
  13482. canTaskBeKilled = true;
  13483. }
  13484.  
  13485. itemEntity = (W3UsableItem)inv.GetItemEntityUnsafe( selectedItemId );
  13486. if ( itemEntity && m_useSelectedItemIfSpawned )
  13487. {
  13488.  
  13489. canTaskBeKilled = true;
  13490. m_useSelectedItemIfSpawned = false;
  13491. ProcessUseSelectedItem( itemEntity, true );
  13492. }
  13493.  
  13494. if ( canTaskBeKilled )
  13495. {
  13496. KillWaitForItemSpawnAndProccesTask();
  13497. }
  13498. }
  13499.  
  13500. event OnBombProjectileReleased()
  13501. {
  13502. ResetRawPlayerHeading();
  13503. UnblockAction(EIAB_ThrowBomb, 'BombThrow');
  13504. UnblockAction(EIAB_Crossbow, 'BombThrow');
  13505.  
  13506. if(GetCurrentStateName() == 'AimThrow')
  13507. PopState();
  13508.  
  13509. FactsAdd("ach_bomb", 1, 4 );
  13510. theGame.GetGamerProfile().CheckLearningTheRopes();
  13511. }
  13512.  
  13513. public function SetIsThrowingItemWithAim(b : bool)
  13514. {
  13515. isThrowingItemWithAim = b;
  13516. }
  13517.  
  13518. public function SetIsThrowingItem( flag : bool ) {isThrowingItem = flag;}
  13519. public function IsThrowingItem() : bool {return isThrowingItem;}
  13520. public function IsThrowingItemWithAim() : bool {return isThrowingItemWithAim;}
  13521. public function SetThrowHold(b : bool) {isThrowHoldPressed = b;}
  13522. public function IsThrowHold() : bool {return isThrowHoldPressed;}
  13523. public function SetIsAimingCrossbow( flag : bool ) {isAimingCrossbow = flag;}
  13524. public function GetIsAimingCrossbow() : bool {return isAimingCrossbow;}
  13525.  
  13526. event OnThrowAnimLeave()
  13527. {
  13528. var throwStage : EThrowStage;
  13529. var thrownEntity : CThrowable;
  13530.  
  13531. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  13532.  
  13533. if(thrownEntity && !thrownEntity.WasThrown())
  13534. {
  13535. throwStage = (int)GetBehaviorVariable( 'throwStage', (int)TS_Stop);
  13536. if(inv.IsItemBomb(selectedItemId))
  13537. {
  13538. BombThrowCleanUp();
  13539. }
  13540. else
  13541. {
  13542. ThrowingAbort();
  13543. }
  13544. }
  13545.  
  13546. thrownEntity = NULL;
  13547. SetIsThrowingItem( false );
  13548. SetIsThrowingItemWithAim( false );
  13549.  
  13550. this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
  13551. UnblockAction(EIAB_ThrowBomb, 'BombThrow');
  13552. UnblockAction(EIAB_Crossbow, 'BombThrow');
  13553. }
  13554.  
  13555.  
  13556. protected function BombThrowStart()
  13557. {
  13558. var slideTargetActor : CActor;
  13559.  
  13560. BlockAction( EIAB_ThrowBomb, 'BombThrow' );
  13561. BlockAction(EIAB_Crossbow, 'BombThrow');
  13562.  
  13563. SetBehaviorVariable( 'throwStage', (int)TS_Start );
  13564. SetBehaviorVariable( 'combatActionType', (int)CAT_ItemThrow );
  13565.  
  13566. if ( slideTarget )
  13567. {
  13568. AddCustomOrientationTarget( OT_Actor, 'BombThrow' );
  13569.  
  13570. slideTargetActor = (CActor)( slideTarget );
  13571.  
  13572.  
  13573.  
  13574.  
  13575.  
  13576. }
  13577. else
  13578. {
  13579. if ( lastAxisInputIsMovement )
  13580. AddCustomOrientationTarget( OT_Actor, 'BombThrow' );
  13581. else
  13582. AddCustomOrientationTarget( OT_Camera, 'BombThrow' );
  13583. }
  13584.  
  13585. UpdateLookAtTarget();
  13586. SetCustomRotation( 'Throw', VecHeading( this.GetLookAtPosition() - GetWorldPosition() ), 0.0f, 0.3f, false );
  13587.  
  13588. SetBehaviorVariable( 'itemType', (int)IT_Petard );
  13589.  
  13590. ProcessCanAttackWhenNotInCombatBomb();
  13591.  
  13592. if ( RaiseForceEvent('CombatAction') )
  13593. OnCombatActionStart();
  13594.  
  13595.  
  13596. theTelemetry.LogWithLabel(TE_FIGHT_HERO_THROWS_BOMB, inv.GetItemName( selectedItemId ));
  13597. }
  13598.  
  13599.  
  13600. event OnThrowAnimStart()
  13601. {
  13602. var itemId : SItemUniqueId;
  13603. var thrownEntity : CThrowable;
  13604.  
  13605. this.radialSlots.Clear();
  13606. GetWitcherPlayer().GetItemEquippedOnSlot(EES_Petard1, itemId );
  13607.  
  13608. if( GetSelectedItemId() == itemId )
  13609. {
  13610. this.radialSlots.PushBack( 'Slot2' );
  13611. }
  13612. else
  13613. {
  13614. this.radialSlots.PushBack( 'Slot1' );
  13615. }
  13616. this.radialSlots.PushBack( 'Slot3' );
  13617. this.radialSlots.PushBack( 'Slot4' );
  13618. this.radialSlots.PushBack( 'Slot5' );
  13619. this.EnableRadialSlotsWithSource( false, this.radialSlots, 'throwBomb' );
  13620.  
  13621. thrownEntity = (CThrowable)inv.GetDeploymentItemEntity( selectedItemId,,,true );
  13622. thrownEntity.Initialize( this, selectedItemId );
  13623. EntityHandleSet( thrownEntityHandle, thrownEntity );
  13624. SetIsThrowingItem( true );
  13625. }
  13626.  
  13627. public function BombThrowAbort()
  13628. {
  13629. BombThrowCleanUp();
  13630. UnblockAction( EIAB_ThrowBomb, 'BombThrow' );
  13631. UnblockAction(EIAB_Crossbow, 'BombThrow');
  13632. }
  13633.  
  13634. private function BombThrowCleanUp()
  13635. {
  13636. var throwStage : EThrowStage;
  13637. var thrownEntity : CThrowable;
  13638. var vehicle : CVehicleComponent;
  13639.  
  13640. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  13641.  
  13642. this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
  13643. throwStage = (int)GetBehaviorVariable( 'throwStage', (int)TS_Stop);
  13644.  
  13645. SetBehaviorVariable( 'throwStage', (int)TS_Stop );
  13646.  
  13647. if( GetCurrentStateName() == 'AimThrow')
  13648. {
  13649. PopState();
  13650. thrownEntity.StopAiming( true );
  13651. }
  13652. else if ( this.IsUsingHorse() )
  13653. {
  13654. vehicle = (CVehicleComponent)(GetUsedVehicle().GetComponentByClassName('CVehicleComponent'));
  13655. vehicle.GetUserCombatManager().OnForceItemActionAbort();
  13656. }
  13657.  
  13658.  
  13659. if(thrownEntity && !thrownEntity.WasThrown())
  13660. {
  13661. thrownEntity.BreakAttachment();
  13662. thrownEntity.Destroy();
  13663. }
  13664.  
  13665. thrownEntity = NULL;
  13666. SetIsThrowingItem( false );
  13667. SetIsThrowingItemWithAim( false );
  13668. RemoveCustomOrientationTarget( 'BombThrow' );
  13669. }
  13670.  
  13671. public function ProcessCanAttackWhenNotInCombatBomb()
  13672. {
  13673. var targets : array< CGameplayEntity >;
  13674. var temp, throwVector, throwFrom, throwTo, throwVectorU : Vector;
  13675. var temp_n : name;
  13676. var throwVecLen : float;
  13677. var component : CComponent;
  13678.  
  13679.  
  13680.  
  13681. if( FactsQuerySum( "BombThrowSpecificTargets" ) > 0 )
  13682. {
  13683.  
  13684.  
  13685.  
  13686.  
  13687.  
  13688. throwFrom = playerAiming.GetThrowStartPosition();
  13689. throwTo = playerAiming.GetThrowPosition();
  13690. throwVector = throwTo - throwFrom;
  13691. throwVecLen = VecDistance( throwFrom, throwTo );
  13692. throwVectorU = throwVector / throwVecLen;
  13693. if( theGame.GetWorld().StaticTraceWithAdditionalInfo( throwFrom, throwTo + throwVectorU, temp, temp, temp_n, component ) && component && component.GetEntity().HasTag( 'BombThrowSpecificTarget' ) )
  13694. {
  13695. SetIsShootingFriendly( false );
  13696. }
  13697. else
  13698. {
  13699. SetIsShootingFriendly( true );
  13700. }
  13701. }
  13702. else if( FactsQuerySum( "BombThrowDisallowSpecificTargets" ) > 0 )
  13703. {
  13704.  
  13705. throwFrom = playerAiming.GetThrowStartPosition();
  13706. throwTo = playerAiming.GetThrowPosition();
  13707. throwVector = throwTo - throwFrom;
  13708. throwVecLen = VecDistance( throwFrom, throwTo );
  13709. throwVectorU = throwVector / throwVecLen;
  13710. if( theGame.GetWorld().StaticTraceWithAdditionalInfo( throwFrom, throwTo + throwVectorU, temp, temp, temp_n, component ) && component && component.GetEntity().HasTag( 'BombThrowDisallowedTarget' ) )
  13711. {
  13712. SetIsShootingFriendly( true );
  13713. }
  13714. else
  13715. {
  13716. SetIsShootingFriendly( false );
  13717. }
  13718. }
  13719. else
  13720. {
  13721. SetIsShootingFriendly( false );
  13722. }
  13723.  
  13724. SetBehaviorVariable( 'isShootingFriendly', (float)( GetIsShootingFriendly() ) );
  13725. }
  13726.  
  13727. public function SetIsShootingFriendly( flag : bool )
  13728. {
  13729. isShootingFriendly = flag;
  13730. }
  13731.  
  13732. public function GetIsShootingFriendly() : bool
  13733. {
  13734. return isShootingFriendly;
  13735. }
  13736.  
  13737.  
  13738. protected function UsableItemStart()
  13739. {
  13740. var thrownEntity : CThrowable;
  13741.  
  13742.  
  13743. thrownEntity = (CThrowable)inv.GetDeploymentItemEntity( selectedItemId,,,true );
  13744. thrownEntity.Initialize( this, selectedItemId );
  13745. EntityHandleSet( thrownEntityHandle, thrownEntity );
  13746. SetBehaviorVariable( 'throwStage', (int)TS_Start );
  13747. SetIsThrowingItem( true );
  13748. SetBehaviorVariable( 'combatActionType', (int)CAT_ItemThrow );
  13749.  
  13750. if ( slideTarget )
  13751. {
  13752. AddCustomOrientationTarget( OT_Actor, 'UsableItems' );
  13753. }
  13754. else
  13755. {
  13756. if ( lastAxisInputIsMovement )
  13757. AddCustomOrientationTarget( OT_Actor, 'UsableItems' );
  13758. else
  13759. AddCustomOrientationTarget( OT_Camera, 'UsableItems' );
  13760. }
  13761.  
  13762. SetBehaviorVariable( 'itemType', (int)(-1) );
  13763.  
  13764. if ( RaiseForceEvent('CombatAction') )
  13765. OnCombatActionStart();
  13766. }
  13767.  
  13768. protected function BombThrowRelease()
  13769. {
  13770. var stateName : name;
  13771.  
  13772. stateName = playerAiming.GetCurrentStateName();
  13773. OnDelayOrientationChangeOff();
  13774.  
  13775. if( GetIsShootingFriendly() || ( FactsQuerySum( "BombThrowSpecificTargets" ) > 0 && stateName != 'Aiming' ) )
  13776. {
  13777. BombThrowAbort();
  13778. }
  13779. else
  13780. {
  13781. SetBehaviorVariable( 'throwStage', (int)TS_End );
  13782.  
  13783. if ( stateName == 'Aiming' )
  13784. {
  13785. SetCustomRotation( 'Throw', VecHeading( this.GetLookAtPosition() - GetWorldPosition() ), 0.0f, 0.2f, false );
  13786. }
  13787. }
  13788. }
  13789.  
  13790. protected function UsableItemRelease()
  13791. {
  13792. OnDelayOrientationChangeOff();
  13793. SetBehaviorVariable( 'throwStage', (int)TS_End );
  13794. RemoveCustomOrientationTarget( 'UsableItems' );
  13795. }
  13796.  
  13797.  
  13798. public function ThrowingAbort()
  13799. {
  13800. var thrownEntity : CThrowable;
  13801.  
  13802. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  13803.  
  13804. SetBehaviorVariable( 'throwStage', (int)TS_Stop );
  13805. RaiseEvent( 'actionStop' );
  13806.  
  13807. if( GetCurrentStateName() == 'AimThrow')
  13808. {
  13809. PopState();
  13810. thrownEntity.StopAiming( true );
  13811. }
  13812.  
  13813.  
  13814. if(thrownEntity && !thrownEntity.WasThrown())
  13815. {
  13816. thrownEntity.BreakAttachment();
  13817. thrownEntity.Destroy();
  13818. }
  13819. this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
  13820. }
  13821.  
  13822. public function CanSetupCombatAction_Throw() : bool
  13823. {
  13824.  
  13825. if(!inv.IsIdValid( selectedItemId ))
  13826. return false;
  13827.  
  13828.  
  13829. if(!inv.IsItemSingletonItem(selectedItemId))
  13830. return false;
  13831.  
  13832.  
  13833. if(!GetBIsInputAllowed())
  13834. return false;
  13835.  
  13836.  
  13837. if(inv.GetItemQuantity(GetSelectedItemId()) <= 0 && !inv.ItemHasTag(selectedItemId, theGame.params.TAG_INFINITE_AMMO))
  13838. return false;
  13839.  
  13840.  
  13841. if(!inputHandler.IsActionAllowed(EIAB_ThrowBomb) && GetCurrentStateName() != 'Swimming')
  13842. return false;
  13843.  
  13844. return true;
  13845. }
  13846.  
  13847. public function GetThrownEntity() : CThrowable
  13848. {
  13849. return (CThrowable)EntityHandleGet( thrownEntityHandle );
  13850. }
  13851.  
  13852.  
  13853. event OnWeaponWait() { rangedWeapon.OnWeaponWait(); }
  13854. event OnWeaponDrawStart() { rangedWeapon.OnWeaponDrawStart(); }
  13855. event OnWeaponReloadStart() { rangedWeapon.OnWeaponReloadStart(); }
  13856. event OnWeaponReloadEnd() { rangedWeapon.OnWeaponReloadEnd(); }
  13857. event OnWeaponAimStart() { rangedWeapon.OnWeaponAimStart(); }
  13858. event OnWeaponShootStart() { rangedWeapon.OnWeaponShootStart(); }
  13859. event OnWeaponShootEnd() { rangedWeapon.OnWeaponShootEnd(); }
  13860. event OnWeaponAimEnd() { rangedWeapon.OnWeaponAimEnd(); }
  13861. event OnWeaponHolsterStart() { rangedWeapon.OnWeaponHolsterStart(); }
  13862. event OnWeaponHolsterEnd() { rangedWeapon.OnWeaponHolsterEnd(); }
  13863. event OnWeaponToNormalTransStart() { rangedWeapon.OnWeaponToNormalTransStart(); }
  13864. event OnWeaponToNormalTransEnd() { rangedWeapon.OnWeaponToNormalTransEnd(); }
  13865.  
  13866. event OnEnableAimingMode( enable : bool )
  13867. {
  13868. if( !crossbowDontPopStateHack )
  13869. {
  13870. if ( enable )
  13871. PushState( 'AimThrow' );
  13872. else if ( GetCurrentStateName() == 'AimThrow' )
  13873. PopState();
  13874. }
  13875. }
  13876.  
  13877. event OnRangedForceHolster( optional forceUpperBodyAnim, instant, dropItem : bool )
  13878. {
  13879. if(rangedWeapon)
  13880. rangedWeapon.OnForceHolster( forceUpperBodyAnim, instant, dropItem );
  13881. }
  13882.  
  13883.  
  13884. public function IsCrossbowHeld() : bool
  13885. {
  13886. if (rangedWeapon)
  13887. return rangedWeapon.GetCurrentStateName() != 'State_WeaponWait';
  13888. return false;
  13889. }
  13890.  
  13891.  
  13892. event OnBlockAllCombatTickets( release : bool )
  13893. {
  13894. if (!release )
  13895. ((CR4PlayerStateCombat)GetState('Combat')).OnBlockAllCombatTickets(false);
  13896. }
  13897. event OnForceTicketUpdate() {}
  13898.  
  13899.  
  13900.  
  13901.  
  13902.  
  13903. event OnProcessActionPost(action : W3DamageAction)
  13904. {
  13905. var npc : CNewNPC;
  13906. var attackAction : W3Action_Attack;
  13907. var lifeLeech : float;
  13908.  
  13909. super.OnProcessActionPost(action);
  13910.  
  13911. attackAction = (W3Action_Attack)action;
  13912.  
  13913. if(attackAction)
  13914. {
  13915. npc = (CNewNPC)action.victim;
  13916.  
  13917.  
  13918. if ( npc && npc.UsesEssence() )
  13919. {
  13920. PlayBattleCry( 'BattleCryMonstersSilverHit', 0.09f );
  13921. }
  13922.  
  13923. else if(npc && (npc.IsHuman() || npc.GetMovingAgentComponent().GetName() == "wild_hunt_base") )
  13924. {
  13925. PlayBattleCry('BattleCryHumansHit', 0.09f );
  13926. }
  13927. else
  13928. {
  13929. PlayBattleCry('BattleCryMonstersHit', 0.09f );
  13930. }
  13931.  
  13932. if(attackAction.IsActionMelee())
  13933. {
  13934.  
  13935. IncreaseUninterruptedHitsCount();
  13936.  
  13937.  
  13938. if( IsLightAttack( attackAction.GetAttackName() ) )
  13939. {
  13940. GCameraShake(0.1, false, GetWorldPosition(), 10);
  13941. }
  13942.  
  13943.  
  13944. if(npc && inv.GetItemName(attackAction.GetWeaponId()) == 'PC Caretaker Shovel')
  13945. {
  13946.  
  13947. lifeLeech = CalculateAttributeValue(inv.GetItemAttributeValue(attackAction.GetWeaponId() ,'lifesteal'));
  13948. if (npc.UsesVitality())
  13949. lifeLeech *= action.processedDmg.vitalityDamage;
  13950. else if (UsesEssence())
  13951. lifeLeech *= action.processedDmg.essenceDamage;
  13952. else
  13953. lifeLeech = 0;
  13954.  
  13955. if ( lifeLeech > 0 )
  13956. {
  13957. inv.PlayItemEffect( attackAction.GetWeaponId(), 'stab_attack' );
  13958. PlayEffect('drain_energy_caretaker_shovel');
  13959. GainStat(BCS_Vitality, lifeLeech);
  13960. }
  13961. }
  13962. }
  13963. }
  13964. }
  13965.  
  13966. public function SetHitReactTransScale(f : float) {hitReactTransScale = f;}
  13967. public function GetHitReactTransScale() : float
  13968. {
  13969. if ( ( (CNewNPC)slideTarget ).GetIsTranslationScaled() )
  13970. return hitReactTransScale;
  13971. else
  13972. return 1.f;
  13973. }
  13974.  
  13975.  
  13976.  
  13977.  
  13978.  
  13979. public function GetHorseWithInventory() : CNewNPC
  13980. {
  13981. return (CNewNPC)EntityHandleGet( horseWithInventory );
  13982. }
  13983. public function GetHorseCurrentlyMounted() : CNewNPC
  13984. {
  13985. return currentlyMountedHorse;
  13986. }
  13987.  
  13988. public function _SetHorseCurrentlyMounted( horse : CNewNPC )
  13989. {
  13990. currentlyMountedHorse = horse;
  13991. }
  13992.  
  13993. public function WasHorseRecentlySummoned() : bool
  13994. {
  13995. if ( horseSummonTimeStamp + 5.f > theGame.GetEngineTimeAsSeconds() )
  13996. return true;
  13997.  
  13998. return false;
  13999. }
  14000.  
  14001. private const var MOUNT_DISTANCE_CBT : float;
  14002. default MOUNT_DISTANCE_CBT = 3.0;
  14003.  
  14004. private const var MOUNT_ANGLE_CBT : float;
  14005. default MOUNT_ANGLE_CBT = 35.0;
  14006.  
  14007. private const var MOUNT_ANGLE_EXP : float;
  14008. default MOUNT_ANGLE_EXP = 45.0;
  14009.  
  14010. public function IsMountingHorseAllowed( optional alwaysAllowedInExploration : bool ) : bool
  14011. {
  14012. var angle : float;
  14013. var distance : float;
  14014.  
  14015. if( IsInsideHorseInteraction() )
  14016. {
  14017. angle = AngleDistance( thePlayer.rawPlayerHeading, VecHeading( thePlayer.horseInteractionSource.GetWorldPosition() - thePlayer.GetWorldPosition() ) );
  14018.  
  14019. if( thePlayer.IsInCombat() )
  14020. {
  14021. if( AbsF( angle ) < MOUNT_ANGLE_CBT )
  14022. {
  14023. distance = VecDistance( thePlayer.GetWorldPosition(), thePlayer.horseInteractionSource.GetWorldPosition() );
  14024.  
  14025. if( distance < MOUNT_DISTANCE_CBT )
  14026. {
  14027. return true;
  14028. }
  14029. else
  14030. {
  14031. return false;
  14032. }
  14033. }
  14034. else
  14035. {
  14036. return false;
  14037. }
  14038.  
  14039. }
  14040. else
  14041. {
  14042. if( alwaysAllowedInExploration )
  14043. {
  14044. return true;
  14045. }
  14046. else
  14047. {
  14048. if( AbsF( angle ) < MOUNT_ANGLE_EXP )
  14049. {
  14050. return true;
  14051. }
  14052. else
  14053. {
  14054. return false;
  14055. }
  14056. }
  14057. }
  14058. }
  14059. else
  14060. {
  14061. return false;
  14062. }
  14063. }
  14064.  
  14065. public function FollowActor( actor : CActor )
  14066. {
  14067. var l_aiTreeDecorator : CAIPlayerActionDecorator;
  14068. var l_aiTree_onFoot : CAIFollowSideBySideAction;
  14069. var l_aiTree_onHorse : CAIRiderFollowSideBySideAction;
  14070. var l_success : bool = false;
  14071.  
  14072. actor.AddTag( 'playerFollowing' );
  14073.  
  14074. if( thePlayer.IsUsingHorse() )
  14075. {
  14076. l_aiTree_onHorse = new CAIRiderFollowSideBySideAction in this;
  14077. l_aiTree_onHorse.OnCreated();
  14078.  
  14079. l_aiTree_onHorse.params.targetTag = 'playerFollowing';
  14080. }
  14081. else
  14082. {
  14083. l_aiTree_onFoot = new CAIFollowSideBySideAction in this;
  14084. l_aiTree_onFoot.OnCreated();
  14085.  
  14086. l_aiTree_onFoot.params.targetTag = 'playerFollowing';
  14087. }
  14088.  
  14089. l_aiTreeDecorator = new CAIPlayerActionDecorator in this;
  14090. l_aiTreeDecorator.OnCreated();
  14091. l_aiTreeDecorator.interruptOnInput = false;
  14092.  
  14093. if( thePlayer.IsUsingHorse() )
  14094. l_aiTreeDecorator.scriptedAction = l_aiTree_onHorse;
  14095. else
  14096. l_aiTreeDecorator.scriptedAction = l_aiTree_onFoot;
  14097.  
  14098. if( l_aiTreeDecorator )
  14099. l_success = ForceAIBehavior( l_aiTreeDecorator, BTAP_Emergency );
  14100. else if( thePlayer.IsUsingHorse() )
  14101. l_success = ForceAIBehavior( l_aiTree_onHorse, BTAP_Emergency );
  14102. else
  14103. l_success = ForceAIBehavior( l_aiTree_onFoot, BTAP_Emergency );
  14104.  
  14105. if ( l_success )
  14106. {
  14107. GetMovingAgentComponent().SetGameplayRelativeMoveSpeed( 0.0f );
  14108. }
  14109. }
  14110.  
  14111. public function SetCanFollowNpc( val : bool, actor : CActor ) { canFollowNpc = val; actorToFollow = actor; }
  14112. public function CanFollowNpc() : bool { return canFollowNpc; }
  14113. public function GetActorToFollow() : CActor { return actorToFollow; }
  14114.  
  14115.  
  14116.  
  14117.  
  14118.  
  14119.  
  14120.  
  14121. public function SetIsSwimming ( toggle : bool )
  14122. {
  14123. if( isSwimming != toggle )
  14124. {
  14125. thePlayer.substateManager.SetBehaviorParamBool( 'isSwimmingForOverlay', toggle );
  14126. isSwimming = toggle;
  14127. }
  14128. }
  14129.  
  14130.  
  14131.  
  14132.  
  14133.  
  14134.  
  14135.  
  14136. public function RepairItemUsingConsumable(item, consumable : SItemUniqueId) : bool
  14137. {
  14138. var curr, max, repairValue, itemValue, repairBonus, newDurability : float;
  14139.  
  14140.  
  14141. if(!inv.IsIdValid(item) || !inv.IsIdValid(consumable) || !inv.HasItemDurability(item))
  14142. return false;
  14143.  
  14144. curr = inv.GetItemDurability(item);
  14145. max = inv.GetItemMaxDurability(item);
  14146.  
  14147.  
  14148. if(curr > max)
  14149. return false;
  14150.  
  14151.  
  14152. if( (inv.IsItemAnyArmor(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_ARMOR)) ||
  14153. (inv.IsItemSilverSwordUsableByPlayer(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_SILVER)) ||
  14154. (inv.IsItemSteelSwordUsableByPlayer(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_STEEL)) )
  14155. {
  14156.  
  14157. itemValue = CalculateAttributeValue(inv.GetItemAttributeValue(consumable, 'durabilityRepairValue'));
  14158. if(itemValue <= 0)
  14159. {
  14160. LogAssert(false, "CR4Player.RepairItemUsingConsumable: consumable <<" + inv.GetItemName(consumable) + ">> has <=0 durabilityRepairValue!!!");
  14161. return false;
  14162. }
  14163. repairBonus = CalculateAttributeValue(inv.GetItemAttributeValue(consumable, 'durabilityBonusValue'));
  14164.  
  14165.  
  14166. repairValue = max * itemValue /100;
  14167.  
  14168.  
  14169.  
  14170. newDurability = MinF(max, curr + repairValue);
  14171.  
  14172. inv.SetItemDurabilityScript(item, newDurability);
  14173.  
  14174.  
  14175. inv.RemoveItem(consumable);
  14176.  
  14177. return true;
  14178. }
  14179. return false;
  14180. }
  14181.  
  14182.  
  14183.  
  14184.  
  14185.  
  14186.  
  14187.  
  14188.  
  14189.  
  14190.  
  14191. private function CheckDayNightCycle()
  14192. {
  14193. var time : GameTime;
  14194. var isNight : bool;
  14195.  
  14196.  
  14197. isNight = theGame.envMgr.IsNight();
  14198. if(prevDayNightIsNight != isNight)
  14199. {
  14200. if(isNight)
  14201. OnNightStarted();
  14202. else
  14203. OnDayStarted();
  14204.  
  14205. prevDayNightIsNight = isNight;
  14206. }
  14207.  
  14208.  
  14209. if(isNight)
  14210. time = theGame.envMgr.GetGameTimeTillNextDay();
  14211. else
  14212. time = theGame.envMgr.GetGameTimeTillNextNight();
  14213.  
  14214. AddGameTimeTimer('DayNightCycle', time);
  14215. }
  14216.  
  14217. timer function DayNightCycle(dt : GameTime, id : int)
  14218. {
  14219. CheckDayNightCycle();
  14220. }
  14221.  
  14222. event OnNightStarted()
  14223. {
  14224. var pam : W3PlayerAbilityManager;
  14225.  
  14226. if(CanUseSkill(S_Perk_01))
  14227. {
  14228. pam = (W3PlayerAbilityManager)abilityManager;
  14229. pam.SetPerk01Abilities(false, true);
  14230. }
  14231. }
  14232.  
  14233. event OnDayStarted()
  14234. {
  14235. var pam : W3PlayerAbilityManager;
  14236.  
  14237. if(CanUseSkill(S_Perk_01))
  14238. {
  14239. pam = (W3PlayerAbilityManager)abilityManager;
  14240. pam.SetPerk01Abilities(true, false);
  14241. }
  14242. }
  14243.  
  14244.  
  14245.  
  14246.  
  14247.  
  14248. public function ForceUnlockAllInputActions(alsoQuestLocks : bool)
  14249. {
  14250. if ( inputHandler )
  14251. inputHandler.ForceUnlockAllInputActions(alsoQuestLocks);
  14252. }
  14253.  
  14254. public function SetPrevRawLeftJoyRot()
  14255. {
  14256. prevRawLeftJoyRot = rawLeftJoyRot;
  14257. }
  14258.  
  14259. public function GetPrevRawLeftJoyRot() : float
  14260. {
  14261. return prevRawLeftJoyRot;
  14262. }
  14263.  
  14264. public function GetExplorationInputContext() : name
  14265. {
  14266. return explorationInputContext;
  14267. }
  14268.  
  14269. public function GetCombatInputContext() : name
  14270. {
  14271. return combatInputContext;
  14272. }
  14273.  
  14274.  
  14275.  
  14276.  
  14277.  
  14278. public function SetIsOnBoat(b : bool)
  14279. {
  14280. isOnBoat = b;
  14281. }
  14282.  
  14283. public function IsOnBoat() : bool
  14284. {
  14285. return isOnBoat;
  14286. }
  14287.  
  14288. public function IsInShallowWater() : bool
  14289. {
  14290. return isInShallowWater;
  14291. }
  14292.  
  14293. event OnEnterShallowWater()
  14294. {
  14295. if ( isInShallowWater )
  14296. return false;
  14297.  
  14298. isInShallowWater = true;
  14299. BlockAction( EIAB_Dodge,'ShallowWater', false, false, true );
  14300. if(!gmConfig().enableJumpSprint) { BlockAction( EIAB_Sprint,'ShallowWater', false, false, true ); } // ===== Added by God Mode mod - Module: Sense Run Jump =====
  14301. BlockAction( EIAB_Crossbow,'ShallowWater', false, false, true );
  14302. if(!gmConfig().enableJumpSprint) { BlockAction( EIAB_Jump,'ShallowWater', false, false, true ); } // ===== Added by God Mode mod - Module: Sense Run Jump =====
  14303. SetBehaviorVariable( 'shallowWater',1.0);
  14304. }
  14305. event OnExitShallowWater()
  14306. {
  14307. if ( !isInShallowWater )
  14308. return false;
  14309.  
  14310. isInShallowWater = false;
  14311. BlockAllActions('ShallowWater',false);
  14312. SetBehaviorVariable( 'shallowWater',0.0);
  14313. }
  14314.  
  14315. public function TestIsInSettlement() : bool
  14316. {
  14317. return IsInSettlement();
  14318. }
  14319.  
  14320.  
  14321.  
  14322.  
  14323.  
  14324.  
  14325. public function ProcessGlossaryImageOverride( defaultImage : string, uniqueTag : name ) : string
  14326. {
  14327. var size : int;
  14328. var i : int;
  14329.  
  14330. size = glossaryImageOverride.Size();
  14331.  
  14332. if( size == 0 )
  14333. return defaultImage;
  14334.  
  14335. for( i = 0; i < size; i += 1 )
  14336. {
  14337. if( glossaryImageOverride[i].uniqueTag == uniqueTag )
  14338. {
  14339.  
  14340. if(glossaryImageOverride[i].imageFileName == "GlossaryPictureOverride to journal_roach_q110.png")
  14341. {
  14342. EnableGlossaryImageOverride(uniqueTag, "journal_roach_q110.png", true );
  14343. return "journal_roach_q110.png";
  14344. }
  14345. return glossaryImageOverride[i].imageFileName;
  14346. }
  14347.  
  14348. }
  14349.  
  14350. return defaultImage;
  14351. }
  14352.  
  14353.  
  14354. public function EnableGlossaryImageOverride( uniqueTag : name, imageFileName : string, enable : bool )
  14355. {
  14356. var imageData : SGlossaryImageOverride;
  14357. var size : int;
  14358. var i : int;
  14359.  
  14360. for( i = 0; i < glossaryImageOverride.Size(); i += 1 )
  14361. {
  14362. if( glossaryImageOverride[i].uniqueTag == uniqueTag )
  14363. {
  14364. glossaryImageOverride.Remove(glossaryImageOverride[i]);
  14365. }
  14366. }
  14367.  
  14368. if( enable )
  14369. {
  14370. if( IsNameValid(uniqueTag) && imageFileName != "" )
  14371. {
  14372. glossaryImageOverride.PushBack( SGlossaryImageOverride( uniqueTag, imageFileName ) );
  14373. }
  14374. }
  14375. }
  14376.  
  14377.  
  14378.  
  14379. public function SetWeatherDisplayDisabled( disable : bool )
  14380. {
  14381. disableWeatherDisplay = disable;
  14382. }
  14383.  
  14384. public function GetWeatherDisplayDisabled() : bool
  14385. {
  14386. return disableWeatherDisplay;
  14387. }
  14388.  
  14389.  
  14390.  
  14391.  
  14392.  
  14393. public function SetCurrentMonsterHuntInvestigationArea ( area : W3MonsterHuntInvestigationArea )
  14394. {
  14395. currentMonsterHuntInvestigationArea = area;
  14396. }
  14397.  
  14398.  
  14399.  
  14400.  
  14401.  
  14402.  
  14403. public function RememberCustomHead( headName : name )
  14404. {
  14405. rememberedCustomHead = headName;
  14406. }
  14407.  
  14408. public function GetRememberedCustomHead() : name
  14409. {
  14410. return rememberedCustomHead;
  14411. }
  14412.  
  14413. public function ClearRememberedCustomHead()
  14414. {
  14415. rememberedCustomHead = '';
  14416. }
  14417.  
  14418.  
  14419.  
  14420.  
  14421.  
  14422. public function CreateTutorialInput()
  14423. {
  14424. var prevInputHandler : CPlayerInput;
  14425.  
  14426. prevInputHandler = inputHandler;
  14427. inputHandler = new W3PlayerTutorialInput in this;
  14428. inputHandler.Initialize(false, prevInputHandler);
  14429.  
  14430. if(prevInputHandler)
  14431. delete prevInputHandler;
  14432. }
  14433.  
  14434. public function CreateInput()
  14435. {
  14436. var oldInputHandler : CPlayerInput;
  14437.  
  14438. oldInputHandler = inputHandler;
  14439. inputHandler = new CPlayerInput in this;
  14440. inputHandler.Initialize(false, oldInputHandler);
  14441. }
  14442.  
  14443. timer function TutorialSilverCombat(dt : float, id : int)
  14444. {
  14445. var i : int;
  14446. var actors : array<CActor>;
  14447.  
  14448. if(IsInCombat())
  14449. {
  14450. actors = GetNPCsAndPlayersInRange(20, 1000000, ,FLAG_ExcludePlayer + FLAG_OnlyAliveActors);
  14451. for(i=0; i<actors.Size(); i+=1)
  14452. {
  14453. if(actors[i] && IsRequiredAttitudeBetween(this, actors[i], true) && actors[i].UsesEssence())
  14454. {
  14455. FactsAdd("TutorialShowSilver");
  14456.  
  14457. RemoveTimer('TutorialSilverCombat');
  14458. break;
  14459. }
  14460. }
  14461. }
  14462. }
  14463.  
  14464. private saved var m_bossTag : name;
  14465.  
  14466. public function GetBossTag() : name
  14467. {
  14468. return m_bossTag;
  14469. }
  14470.  
  14471. public function SetBossTag( bossTag : name )
  14472. {
  14473. m_bossTag = bossTag;
  14474. }
  14475.  
  14476. private saved var m_usingCoatOfArms : bool; default m_usingCoatOfArms = false;
  14477.  
  14478. public function IsUsingCoatOfArms() : bool
  14479. {
  14480. return m_usingCoatOfArms;
  14481. }
  14482.  
  14483. public function SetUsingCoatOfArms( using : bool)
  14484. {
  14485. m_usingCoatOfArms = using;
  14486. }
  14487.  
  14488. private saved var m_initialTimeOut : float;
  14489. private saved var m_currentTimeOut : float;
  14490.  
  14491. public function GetInitialTimeOut() : float
  14492. {
  14493. return m_initialTimeOut;
  14494. }
  14495.  
  14496. public function SetInitialTimeOut( timeOut : float )
  14497. {
  14498. m_initialTimeOut = timeOut;
  14499. }
  14500.  
  14501. public function GetCurrentTimeOut() : float
  14502. {
  14503. return m_currentTimeOut;
  14504. }
  14505.  
  14506. public function SetCurrentTimeOut( timeOut : float )
  14507. {
  14508. m_currentTimeOut = timeOut;
  14509. }
  14510.  
  14511.  
  14512.  
  14513.  
  14514.  
  14515.  
  14516. timer function DelayedFinisherInputTimer(dt : float, id : int)
  14517. {
  14518.  
  14519.  
  14520. }
  14521.  
  14522. timer function RemoveFinisherCameraAnimationCheck(dt : float, id : int)
  14523. {
  14524. if ( !isInFinisher && !bLAxisReleased )
  14525. {
  14526. theGame.GetSyncAnimManager().OnRemoveFinisherCameraAnimation();
  14527. RemoveTimer( 'RemoveFinisherCameraAnimationCheck' );
  14528. }
  14529. }
  14530.  
  14531.  
  14532.  
  14533.  
  14534.  
  14535. timer function GameplayFactRemove(dt : float, timerId : int)
  14536. {
  14537. theGame.GameplayFactRemoveFromTimer(timerId);
  14538. }
  14539.  
  14540.  
  14541. timer function GiveStartingItems(dt : float, timerId : int)
  14542. {
  14543. var template : CEntityTemplate;
  14544. var invEntity : CInventoryComponent;
  14545. var entity : CEntity;
  14546. var items : array<SItemUniqueId>;
  14547. var id : SItemUniqueId;
  14548. var i : int;
  14549.  
  14550.  
  14551. if(inv)
  14552. {
  14553. inv.GetAllItems(items);
  14554. if(items.Size() <= 0)
  14555. {
  14556. return;
  14557. }
  14558. }
  14559. else
  14560. {
  14561. return;
  14562. }
  14563.  
  14564.  
  14565. template = (CEntityTemplate)LoadResource("geralt_inventory_release");
  14566. entity = theGame.CreateEntity(template, Vector(0,0,0));
  14567. invEntity = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  14568.  
  14569. invEntity.GetAllItems(items);
  14570. for(i=0; i<items.Size(); i+=1)
  14571. {
  14572. id = invEntity.GiveItemTo(inv, items[i], 0, false, true);
  14573. if ( inv.ItemHasTag(id,'Scabbard') )
  14574. {
  14575. inv.MountItem(id);
  14576. }
  14577. else if(!inv.IsItemFists(id) && inv.GetItemName(id) != 'Cat 1')
  14578. {
  14579. EquipItem(id);
  14580. }
  14581. else if(inv.IsItemSingletonItem(id))
  14582. {
  14583. inv.SingletonItemSetAmmo(id, inv.SingletonItemGetMaxAmmo(id));
  14584. }
  14585. }
  14586.  
  14587. entity.Destroy();
  14588.  
  14589.  
  14590. RemoveTimer('GiveStartingItems');
  14591. }
  14592.  
  14593.  
  14594.  
  14595. timer function Debug_GiveTestingItems(dt : float, optional id : int)
  14596. {
  14597. var template : CEntityTemplate;
  14598. var invTesting : CInventoryComponent;
  14599. var entity : CEntity;
  14600. var items : array<SItemUniqueId>;
  14601. var i : int;
  14602. var slot : EEquipmentSlots;
  14603.  
  14604.  
  14605. if(inv)
  14606. {
  14607. inv.GetAllItems(items);
  14608. if(items.Size() <= 0)
  14609. {
  14610. return;
  14611. }
  14612. }
  14613. else
  14614. {
  14615. return;
  14616. }
  14617.  
  14618. template = (CEntityTemplate)LoadResource("geralt_inventory_internal");
  14619. entity = theGame.CreateEntity(template, Vector(0,0,0));
  14620. invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  14621. invTesting.GiveAllItemsTo(inv, true);
  14622. entity.Destroy();
  14623.  
  14624.  
  14625. RemoveTimer('Debug_GiveTestingItems');
  14626.  
  14627.  
  14628. inv.GetAllItems(items);
  14629.  
  14630. for(i=0; i<items.Size(); i+=1)
  14631. {
  14632. if( inv.IsItemCrossbow(items[i]) || inv.IsItemBomb(items[i]) )
  14633. {
  14634. slot = inv.GetSlotForItemId(items[i]);
  14635. EquipItem(items[i], slot);
  14636.  
  14637. if( (W3PlayerWitcher)this && inv.IsItemCrossbow(items[i]) )
  14638. GetWitcherPlayer().SelectQuickslotItem(slot);
  14639. }
  14640. else if(inv.IsItemBolt(items[i]))
  14641. {
  14642. slot = inv.GetSlotForItemId(items[i]);
  14643. EquipItem(items[i], slot);
  14644. }
  14645.  
  14646. if(inv.IsItemSingletonItem(items[i]))
  14647. {
  14648. inv.SingletonItemSetAmmo(items[i], inv.SingletonItemGetMaxAmmo(items[i]));
  14649. }
  14650. }
  14651. }
  14652.  
  14653.  
  14654. timer function Debug_RemoveTestingItems(dt : float, id : int)
  14655. {
  14656. var template : CEntityTemplate;
  14657. var entity : CEntity;
  14658. var invTesting : CInventoryComponent;
  14659. var ids : array<SItemUniqueId>;
  14660. var i : int;
  14661.  
  14662. template = (CEntityTemplate)LoadResource("geralt_inventory_internal");
  14663. entity = theGame.CreateEntity(template, Vector(0,0,0));
  14664. invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  14665. invTesting.GetAllItems(ids);
  14666.  
  14667. for(i=0; i<ids.Size(); i+=1)
  14668. inv.RemoveItemByName(invTesting.GetItemName(ids[i]), invTesting.GetItemQuantity(ids[i]));
  14669.  
  14670. entity.Destroy();
  14671. RemoveTimer('Debug_RemoveTestingItems');
  14672. }
  14673.  
  14674. timer function Debug_DelayedConsoleCommand(dt : float, id : int)
  14675. {
  14676.  
  14677. inv.AddAnItem('Boots 2 schematic');
  14678. }
  14679.  
  14680. function DBG_SkillSlots()
  14681. {
  14682. ((W3PlayerAbilityManager)abilityManager).DBG_SkillSlots();
  14683. }
  14684.  
  14685.  
  14686.  
  14687.  
  14688.  
  14689. public final function SetPadBacklightColor(r, g, b : int)
  14690. {
  14691. var padBacklightColor : Vector;
  14692.  
  14693. padBacklightColor.X = r / 255;
  14694. padBacklightColor.Y = g / 255;
  14695. padBacklightColor.Z = b / 255;
  14696.  
  14697. SetBacklightColor(padBacklightColor);
  14698. }
  14699.  
  14700. public final function SetPadBacklightColorFromSign(signType : ESignType)
  14701. {
  14702. LogPS4Light("SetPadBacklightColorFromSign... " + signType);
  14703.  
  14704. switch(signType)
  14705. {
  14706. case ST_Yrden: SetPadBacklightColor( 200 , 81 , 255 ); break;
  14707. case ST_Quen: SetPadBacklightColor( 255 , 205 , 68 ); break;
  14708. case ST_Igni: SetPadBacklightColor( 255 , 79 , 10 ); break;
  14709. case ST_Axii: SetPadBacklightColor( 255 , 255 , 255 ); break;
  14710. case ST_Aard: SetPadBacklightColor( 158 , 214 , 255 ); break;
  14711. }
  14712. }
  14713.  
  14714. timer function ResetPadBacklightColorTimer(dt : float, id : int)
  14715. {
  14716. ResetPadBacklightColor();
  14717. }
  14718.  
  14719. public final function ResetPadBacklightColor(optional skipHeldWeapon : bool)
  14720. {
  14721. var weapons : array<SItemUniqueId>;
  14722. var sword : CWitcherSword;
  14723. var healthPercentage : float;
  14724. var tmpBacklight : Vector;
  14725.  
  14726. if(!skipHeldWeapon)
  14727. {
  14728. weapons = inv.GetHeldWeapons();
  14729.  
  14730.  
  14731. if(weapons.Size() > 0)
  14732. {
  14733. sword = (CWitcherSword)inv.GetItemEntityUnsafe(weapons[0]);
  14734. if(sword)
  14735. {
  14736. tmpBacklight.X = sword.padBacklightColor.X / 255.0f;
  14737. tmpBacklight.Y = sword.padBacklightColor.Y / 255.0f;
  14738. tmpBacklight.Z = sword.padBacklightColor.Z / 255.0f;
  14739. tmpBacklight.W = 1.0f;
  14740. SetBacklightColor( tmpBacklight );
  14741. LogPS4Light("Setting light from sword template: " + NoTrailZeros(sword.padBacklightColor.X) + ", " + NoTrailZeros(sword.padBacklightColor.Y) + ", " + NoTrailZeros(sword.padBacklightColor.Z) );
  14742. return;
  14743. }
  14744. }
  14745. }
  14746.  
  14747. healthPercentage = GetStatPercents( BCS_Vitality );
  14748. SetBacklightFromHealth( healthPercentage );
  14749. LogPS4Light("Setting light from health, " + NoTrailZeros(RoundMath(healthPercentage*100)) + "%");
  14750. }
  14751.  
  14752.  
  14753.  
  14754. event OnOpenningDoor()
  14755. {
  14756. if( !thePlayer.IsUsingHorse() )
  14757. {
  14758. RaiseEvent('OpenDoor');
  14759. theSound.SoundEvent("global_door_haptic_open");
  14760. }
  14761. }
  14762.  
  14763. public final function SetLoopingCameraShakeAnimName( n : name )
  14764. {
  14765. loopingCameraShakeAnimName = n;
  14766. }
  14767.  
  14768. public var loopingCameraShakeAnimName : name;
  14769. timer function RemoveQuestCameraShakeTimer( dt : float , id : int)
  14770. {
  14771. RemoveQuestCameraShake( loopingCameraShakeAnimName );
  14772. }
  14773.  
  14774. public function RemoveQuestCameraShake( animName : name )
  14775. {
  14776. var camera : CCustomCamera = theGame.GetGameCamera();
  14777. var animation : SCameraAnimationDefinition;
  14778.  
  14779. camera.StopAnimation( animName );
  14780. }
  14781.  
  14782. public function GetCameraPadding() : float
  14783. {
  14784. if( theGame.IsFocusModeActive() )
  14785. {
  14786. return 0.25;
  14787. }
  14788. else
  14789. {
  14790. return 0.02f;
  14791. }
  14792. }
  14793.  
  14794. public function IsPerformingPhaseChangeAnimation() : bool { return isPerformingPhaseChangeAnimation; }
  14795. public function SetIsPerformingPhaseChangeAnimation( val : bool ) { isPerformingPhaseChangeAnimation = val; }
  14796.  
  14797. private function DealCounterDamageToOlgierd()
  14798. {
  14799. var damage : W3DamageAction;
  14800.  
  14801. damage = new W3DamageAction in this;
  14802.  
  14803. damage.Initialize( thePlayer.GetTarget(), thePlayer.GetTarget(), NULL, this, EHRT_None, CPS_Undefined, false, false, false, true );
  14804. damage.AddDamage( theGame.params.DAMAGE_NAME_DIRECT, thePlayer.GetTarget().GetStatMax( BCS_Vitality ) * 3 / 100 );
  14805. theGame.damageMgr.ProcessAction( damage );
  14806.  
  14807. delete damage;
  14808. }
  14809.  
  14810. timer function PlayDelayedCounterDamageEffect( dt : float, id : int )
  14811. {
  14812. thePlayer.GetTarget().PlayEffect( 'olgierd_energy_blast' );
  14813. }
  14814.  
  14815.  
  14816. public function SetTestAdjustRequestedMovementDirection( val : bool )
  14817. {
  14818. testAdjustRequestedMovementDirection = val;
  14819. }
  14820.  
  14821. event OnVisualDebug( frame : CScriptedRenderFrame, flag : EShowFlags )
  14822. {
  14823. var boneFollow : int;
  14824. var bonePosition : Vector;
  14825. var yrdenEntity : W3YrdenEntity;
  14826.  
  14827. substateManager.OnVisualDebug( frame, flag );
  14828.  
  14829. boneFollow = thePlayer.GetBoneIndex( 'Reference' );
  14830. bonePosition = MatrixGetTranslation( thePlayer.GetBoneWorldMatrixByIndex( boneFollow ) );
  14831. frame.DrawText( "R", bonePosition, Color( 50, 200, 70 ) );
  14832.  
  14833.  
  14834. boneFollow = thePlayer.GetBoneIndex( 'Trajectory' );
  14835. bonePosition = MatrixGetTranslation( thePlayer.GetBoneWorldMatrixByIndex( boneFollow ) );
  14836. frame.DrawSphere( bonePosition, 0.1f, Color( 200, 50, 70 ) );
  14837. frame.DrawText( "T", bonePosition, Color( 200, 50, 70 ) );
  14838.  
  14839.  
  14840.  
  14841.  
  14842. yrdenEntity = (W3YrdenEntity)GetWitcherPlayer().GetSignEntity(ST_Yrden);
  14843. yrdenEntity.OnVisualDebug(frame, flag, false);
  14844.  
  14845. return true;
  14846. }
  14847.  
  14848. timer function PotDrinkTimer(dt : float, id : int)
  14849. {
  14850. inputHandler.PotDrinkTimer(false);
  14851. }
  14852.  
  14853. public function SetIsHorseRacing( val : bool )
  14854. {
  14855. isHorseRacing = val;
  14856. }
  14857.  
  14858. public function GetIsHorseRacing() : bool
  14859. {
  14860. return isHorseRacing;
  14861. }
  14862.  
  14863. public function SetHorseCombatSlowMo( val : bool )
  14864. {
  14865. horseCombatSlowMo = val;
  14866. }
  14867.  
  14868. public function GetHorseCombatSlowMo() : bool
  14869. {
  14870. return horseCombatSlowMo;
  14871. }
  14872.  
  14873. public function SetItemsPerLevelGiven( id : int )
  14874. {
  14875. itemsPerLevelGiven[id] = true;
  14876. }
  14877.  
  14878. private function AddItemPerLevelList()
  14879. {
  14880. var i : int;
  14881.  
  14882. itemsPerLevel.Clear();
  14883. itemsPerLevel.PushBack('O');
  14884. itemsPerLevel.PushBack('No Mans Land sword 2');
  14885. itemsPerLevel.PushBack('No Mans Land sword 3');
  14886. itemsPerLevel.PushBack('Silver sword 2');
  14887. itemsPerLevel.PushBack('Boots 01');
  14888. itemsPerLevel.PushBack('Novigraadan sword 2');
  14889. itemsPerLevel.PushBack('Light armor 01');
  14890. itemsPerLevel.PushBack('Heavy boots 01');
  14891. itemsPerLevel.PushBack('Nilfgaardian sword 3');
  14892. itemsPerLevel.PushBack('Silver sword 3');
  14893. itemsPerLevel.PushBack('Heavy gloves 01');
  14894. itemsPerLevel.PushBack('Skellige sword 2');
  14895. itemsPerLevel.PushBack('Heavy pants 01');
  14896. itemsPerLevel.PushBack('Silver sword 4');
  14897. itemsPerLevel.PushBack('No Mans Land sword 4');
  14898. itemsPerLevel.PushBack('Heavy armor 01');
  14899. itemsPerLevel.PushBack('Heavy boots 02');
  14900. itemsPerLevel.PushBack('Skellige sword 3');
  14901. itemsPerLevel.PushBack('Silver sword 5');
  14902. itemsPerLevel.PushBack('Heavy pants 02');
  14903. itemsPerLevel.PushBack('Heavy gloves 02');
  14904. itemsPerLevel.PushBack('Heavy gloves 02');
  14905. itemsPerLevel.PushBack('Heavy armor 02');
  14906. itemsPerLevel.PushBack('Scoiatael sword 1');
  14907.  
  14908. if ( itemsPerLevelGiven.Size() < 49 )
  14909. {
  14910. itemsPerLevelGiven.Clear();
  14911. for (i = 0; i < itemsPerLevel.Size(); i += 1) { itemsPerLevelGiven.PushBack( false ); }
  14912. }
  14913. }
  14914.  
  14915.  
  14916. public function DealDamageToBoat( dmg : float, index : int, optional globalHitPos : Vector )
  14917. {
  14918. var boat : CBoatDestructionComponent;
  14919.  
  14920. if(usedVehicle)
  14921. {
  14922. boat = (CBoatDestructionComponent) usedVehicle.GetComponentByClassName( 'CBoatDestructionComponent' );
  14923. if( boat )
  14924. {
  14925. boat.DealDamage( dmg, index, globalHitPos );
  14926. }
  14927. }
  14928. }
  14929.  
  14930.  
  14931.  
  14932.  
  14933.  
  14934. public function OnStartTeleportingPlayerToPlayableArea()
  14935. {
  14936. var FADEOUT_INTERVAL : float = 0.5;
  14937.  
  14938.  
  14939. if ( thePlayer.IsUsingHorse() )
  14940. {
  14941. if ( thePlayer.GetUsedHorseComponent().OnCheckHorseJump() )
  14942. {
  14943. thePlayer.GetUsedHorseComponent().SetCanTakeDamageFromFalling( false );
  14944. }
  14945. }
  14946.  
  14947. if ( thePlayer.IsActionAllowed( EIAB_FastTravel ) )
  14948. {
  14949. OnOpenMapToLetPlayerGoBackToPlayableArea();
  14950. }
  14951. else
  14952. {
  14953. theGame.FadeOutAsync( FADEOUT_INTERVAL );
  14954. thePlayer.AddTimer( 'BorderTeleportFadeOutTimer', FADEOUT_INTERVAL, false );
  14955. }
  14956. }
  14957.  
  14958. timer function BorderTeleportFadeOutTimer( dt : float, id : int )
  14959. {
  14960. OnTeleportPlayerToPlayableArea( false );
  14961. }
  14962.  
  14963. public function OnOpenMapToLetPlayerGoBackToPlayableArea()
  14964. {
  14965. var initData : W3MapInitData;
  14966.  
  14967. initData = new W3MapInitData in this;
  14968. initData.SetTriggeredExitEntity( true );
  14969. initData.ignoreSaveSystem = true;
  14970. initData.setDefaultState('FastTravel');
  14971. theGame.RequestMenuWithBackground( 'MapMenu', 'CommonMenu', initData );
  14972. }
  14973.  
  14974. public function OnTeleportPlayerToPlayableArea( afterClosingMap : bool )
  14975. {
  14976. var BLACKSCREEN_INTERVAL : float = 0.1;
  14977. var manager : CCommonMapManager = theGame.GetCommonMapManager();
  14978.  
  14979. thePlayer.TeleportWithRotation( manager.GetBorderTeleportPosition(), manager.GetBorderTeleportRotation() );
  14980. thePlayer.AddTimer( 'BorderTeleportFadeInTimer', BLACKSCREEN_INTERVAL, false );
  14981.  
  14982. theGame.FadeOutAsync( 0 );
  14983. theGame.SetFadeLock('PlayerTeleportation');
  14984. }
  14985.  
  14986. timer function BorderTeleportFadeInTimer( dt : float, id : int )
  14987. {
  14988. theGame.ResetFadeLock('PlayerTeleportation');
  14989. theGame.FadeOutAsync( 0 );
  14990. theGame.FadeInAsync( 2.0f );
  14991. }
  14992.  
  14993. public final function SetLastInstantKillTime(g : GameTime)
  14994. {
  14995. lastInstantKillTime = g;
  14996. }
  14997.  
  14998.  
  14999.  
  15000.  
  15001.  
  15002. timer function TestTimer(dt : float, id : int )
  15003. {
  15004. LogChannel('asdf', "asdf");
  15005. theGame.FadeOutAsync( 5 );
  15006. }
  15007.  
  15008. public final function Debug_ReleaseCriticalStateSaveLocks()
  15009. {
  15010. effectManager.Debug_ReleaseCriticalStateSaveLocks();
  15011. }
  15012.  
  15013. timer function Debug_SpamSpeed(dt : float, id : int)
  15014. {
  15015. if(currentlyMountedHorse)
  15016. {
  15017. LogSpeed("curr player's horse speed: " + NoTrailZeros(currentlyMountedHorse.GetMovingAgentComponent().GetSpeed())) ;
  15018. }
  15019. else
  15020. {
  15021. LogSpeed("curr player speed: " + NoTrailZeros(GetMovingAgentComponent().GetSpeed())) ;
  15022. }
  15023. }
  15024.  
  15025. timer function RemoveInstantKillSloMo(dt : float, id : int)
  15026. {
  15027. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_InstantKill) );
  15028. }
  15029.  
  15030. timer function RemoveForceFinisher(dt : float, id : int)
  15031. {
  15032. forceFinisher = false;
  15033. }
  15034.  
  15035. //++modAHW
  15036. timer function AHWDelaySetAllInvisible( time : float , id : int )
  15037. {
  15038. if (FactsDoesExist('AHW')) AHW.SetAllVisible(false);
  15039. }
  15040. timer function AHWDelayReset( time : float , id : int )
  15041. {
  15042. if (FactsDoesExist('AHW') && !AHW.combatready) AHW.SetAllVisible(false);
  15043. }
  15044. timer function AHWDelaySetSteelInvisible( time : float , id : int )
  15045. {
  15046. if (FactsDoesExist('AHW')) AHW.SetSteelVisible(false);
  15047. }
  15048. timer function AHWDelaySetSilverInvisible( time : float , id : int )
  15049. {
  15050. if (FactsDoesExist('AHW')) AHW.SetSilverVisible(false);
  15051. }
  15052. timer function AHWDelaySetSteelScabbardInvisible( time : float , id : int )
  15053. {
  15054. if (FactsDoesExist('AHW')) AHW.SetSteelScabbardVisible(false);
  15055. }
  15056. timer function AHWDelaySetSilverScabbardInvisible( time : float , id : int )
  15057. {
  15058. if (FactsDoesExist('AHW')) AHW.SetSilverScabbardVisible(false);
  15059. }
  15060. timer function AHWDelaySetCbowInvisible( time : float , id : int )
  15061. {
  15062. if (FactsDoesExist('AHW')) AHW.SetCbowVisible(false);
  15063. }
  15064. timer function AHWDelaySetSteelVisible( time : float , id : int )
  15065. {
  15066. if (FactsDoesExist('AHW')) AHW.SetSteelVisible(true);
  15067. }
  15068. timer function AHWDelaySetSilverVisible( time : float , id : int )
  15069. {
  15070. if (FactsDoesExist('AHW')) AHW.SetSilverVisible(true);
  15071. }
  15072. timer function AHWDelaySetSteelScabbardVisible( time : float , id : int )
  15073. {
  15074. if (FactsDoesExist('AHW')) AHW.SetSteelScabbardVisible(true);
  15075. }
  15076. timer function AHWDelaySetSilverScabbardVisible( time : float , id : int )
  15077. {
  15078. if (FactsDoesExist('AHW')) AHW.SetSilverScabbardVisible(true);
  15079. }
  15080. timer function AHWDelaySetCbowVisible( time : float , id : int )
  15081. {
  15082. if (FactsDoesExist('AHW')) AHW.SetCbowVisible(true);
  15083. }
  15084. //--modAHW
  15085.  
  15086. public final function Debug_ClearAllActionLocks(optional action : EInputActionBlock, optional all : bool)
  15087. {
  15088. inputHandler.Debug_ClearAllActionLocks(action, all);
  15089. }
  15090.  
  15091. function OnFocusedCameraBlendBegin() {}
  15092. function OnFocusedCameraBlendUpdate( progress : float ) {}
  15093. function OnFocusedCameraBlendEnd() {}
  15094.  
  15095. public function GetEtherealCount() : int { return etherealCount; }
  15096. public function IncrementEtherealCount()
  15097. {
  15098. etherealCount += 1;
  15099. if( etherealCount == 6 )
  15100. ResetEtherealCount();
  15101. }
  15102. public function ResetEtherealCount() { etherealCount = 0; }
  15103.  
  15104. public function SetInsideDiveAttackArea( val : bool ) { insideDiveAttackArea = val; }
  15105. public function IsInsideDiveAttackArea() : bool { return insideDiveAttackArea; }
  15106. public function SetDiveAreaNumber( val : int ) { diveAreaNumber = val; }
  15107. public function GetDiveAreaNumber() : int { return diveAreaNumber; }
  15108.  
  15109.  
  15110.  
  15111. public function InitPhantomWeaponMgr()
  15112. {
  15113. if( !phantomWeaponMgr )
  15114. {
  15115. phantomWeaponMgr = new CPhantomWeaponManager in this;
  15116. phantomWeaponMgr.Init( this.GetInventory() );
  15117. }
  15118. }
  15119.  
  15120. public function DestroyPhantomWeaponMgr()
  15121. {
  15122. if( phantomWeaponMgr )
  15123. {
  15124. delete phantomWeaponMgr;
  15125. }
  15126. }
  15127.  
  15128. public function GetPhantomWeaponMgr() : CPhantomWeaponManager
  15129. {
  15130. if( phantomWeaponMgr )
  15131. {
  15132. return phantomWeaponMgr;
  15133. }
  15134. else
  15135. {
  15136. return NULL;
  15137. }
  15138. }
  15139.  
  15140. public timer function DischargeWeaponAfter( td : float, id : int )
  15141. {
  15142. GetPhantomWeaponMgr().DischargeWeapon();
  15143. }
  15144.  
  15145.  
  15146.  
  15147.  
  15148. private var forcedFinisherVictim : CActor;
  15149.  
  15150. timer function PerformFinisher( time : float , id : int )
  15151. {
  15152. var combatTarget : CActor;
  15153. var i : int;
  15154.  
  15155. combatTarget = thePlayer.GetTarget();
  15156.  
  15157. if( combatTarget )
  15158. {
  15159. combatTarget.Kill( 'AutoFinisher', false, thePlayer );
  15160. thePlayer.SetFinisherVictim( combatTarget );
  15161. forcedFinisherVictim = combatTarget;
  15162. thePlayer.CleanCombatActionBuffer();
  15163. thePlayer.OnBlockAllCombatTickets( true );
  15164. moveTargets = thePlayer.GetMoveTargets();
  15165.  
  15166. for( i = 0; i < moveTargets.Size(); i += 1 )
  15167. {
  15168. if( combatTarget != moveTargets[i] )
  15169. moveTargets[i].SignalGameplayEvent( 'InterruptChargeAttack' );
  15170. }
  15171.  
  15172. if( theGame.GetInGameConfigWrapper().GetVarValue( 'Gameplay', 'AutomaticFinishersEnabled' ) == "true" )
  15173. combatTarget.AddAbility( 'ForceFinisher', false );
  15174.  
  15175. if( combatTarget.HasTag( 'ForceFinisher' ) )
  15176. combatTarget.AddAbility( 'ForceFinisher', false );
  15177.  
  15178. combatTarget.SignalGameplayEvent( 'ForceFinisher' );
  15179.  
  15180. thePlayer.FindMoveTarget();
  15181.  
  15182. thePlayer.AddTimer( 'SignalFinisher', 0.2, false );
  15183. }
  15184. }
  15185.  
  15186. timer function SignalFinisher( time : float , id : int )
  15187. {
  15188. forcedFinisherVictim.SignalGameplayEvent( 'Finisher' );
  15189. forcedFinisherVictim = NULL;
  15190. }
  15191.  
  15192.  
  15193.  
  15194. protected var climbingCam : bool; default climbingCam = false;
  15195. event OnAnimEvent_ClimbCameraOn( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  15196. {
  15197. climbingCam = true;
  15198. }
  15199.  
  15200. event OnAnimEvent_ClimbCameraOff( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  15201. {
  15202. climbingCam = false;
  15203. }
  15204.  
  15205.  
  15206.  
  15207. private var ladderCamReset : bool; default ladderCamReset = false;
  15208. public function SetLadderCamReset(b : bool) { ladderCamReset = b; }
  15209. public function GetLadderCamReset() : bool { return ladderCamReset; }
  15210. event OnAnimEvent_LadderCamReset( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  15211. {
  15212. ladderCamReset = true;
  15213. }
  15214.  
  15215.  
  15216.  
  15217. private var tempHorse : CEntity;
  15218. private var isPettingHorse : bool;
  15219.  
  15220. public function TryPetHorse()
  15221. {
  15222. var horseComp : W3HorseComponent;
  15223. var rightPoint, leftPoint, tempPoint1, tempPoint2 : Vector;
  15224. var outPosition, outNormal : Vector;
  15225.  
  15226. isPettingHorse = false;
  15227. tempHorse = horseInteractionSource;
  15228.  
  15229. if( !tempHorse || IsInCombat() || IsAnyWeaponHeld() || IsCiri() )
  15230. return;
  15231.  
  15232. horseComp = ((CNewNPC)tempHorse).GetHorseComponent();
  15233. if( !horseComp )
  15234. return;
  15235.  
  15236. if( horseComp.IsMounted() )
  15237. return;
  15238.  
  15239. if( ((CActor)tempHorse).IsMoving() || VecLength( ((CActor)tempHorse).GetMovingAgentComponent().GetVelocity() ) > 0 )
  15240. return;
  15241.  
  15242. rightPoint = tempHorse.GetWorldPosition() + VecConeRand(tempHorse.GetHeading() - 90, 0, 1,1);
  15243. leftPoint = tempHorse.GetWorldPosition() + VecConeRand(tempHorse.GetHeading() + 90, 0, 1,1);
  15244.  
  15245. if( VecDistance(GetWorldPosition(),rightPoint) >= 1.f && VecDistance(GetWorldPosition(),leftPoint) >= 1.f )
  15246. return;
  15247.  
  15248. if( VecDistance(GetWorldPosition(), rightPoint) < VecDistance(GetWorldPosition(), leftPoint) )
  15249. {
  15250. tempPoint1 = rightPoint;
  15251. tempPoint1.Z += 1.5;
  15252.  
  15253. tempPoint2 = rightPoint;
  15254. tempPoint2.Z -= 1.5;
  15255.  
  15256.  
  15257. if( theGame.GetWorld().StaticTrace( tempPoint1, tempPoint2, outPosition, outNormal ) )
  15258. {
  15259. if( AbsF(outPosition.Z - rightPoint.Z) > 0.12 )
  15260. return;
  15261. }
  15262. else
  15263. return;
  15264.  
  15265.  
  15266. isPettingHorse = true;
  15267. theGame.GetSyncAnimManager().SetupSimpleSyncAnim2( 'PetHorse', thePlayer, tempHorse );
  15268. AddTimer('EnablePlayerCollisions',6.56,false);
  15269. }
  15270. else
  15271. {
  15272. tempPoint1 = leftPoint;
  15273. tempPoint1.Z += 1.5;
  15274.  
  15275. tempPoint2 = leftPoint;
  15276. tempPoint2.Z -= 1.5;
  15277.  
  15278.  
  15279. if( theGame.GetWorld().StaticTrace( tempPoint1, tempPoint2, outPosition, outNormal ) )
  15280. {
  15281. if( AbsF(outPosition.Z - leftPoint.Z) > 0.12 )
  15282. return;
  15283. }
  15284. else
  15285. return;
  15286.  
  15287.  
  15288. isPettingHorse = true;
  15289. theGame.GetSyncAnimManager().SetupSimpleSyncAnim2( 'PetHorse', thePlayer, tempHorse );
  15290. AddTimer('EnablePlayerCollisions',5.03,false);
  15291. }
  15292.  
  15293. horseComp.AllowLookat(false);
  15294. EnableCollisions( false );
  15295. BlockAction( EIAB_Sprint, 'PettingHorse' );
  15296. BlockAction( EIAB_Jump, 'PettingHorse' );
  15297. BlockAction( EIAB_Movement, 'PettingHorse' );
  15298. BlockAction( EIAB_CallHorse, 'PettingHorse' );
  15299. BlockAction( EIAB_MountVehicle, 'PettingHorse' );
  15300. BlockAction( EIAB_DrawWeapon, 'PettingHorse' );
  15301. BlockAction( EIAB_Signs, 'PettingHorse' );
  15302. BlockAction( EIAB_LightAttacks, 'PettingHorse' );
  15303. BlockAction( EIAB_HeavyAttacks, 'PettingHorse' );
  15304. BlockAction( EIAB_ThrowBomb, 'PettingHorse' );
  15305. BlockAction( EIAB_Crossbow, 'PettingHorse' );
  15306. BlockAction( EIAB_UsableItem, 'PettingHorse' );
  15307.  
  15308. tempHorse.SetBehaviorVariable( 'horsePetting', 1.0f );
  15309. }
  15310.  
  15311. timer function EnablePlayerCollisions(dt:float, id:int)
  15312. {
  15313. isPettingHorse = false;
  15314. EnableCollisions( true );
  15315. UnblockAction( EIAB_Sprint, 'PettingHorse' );
  15316. UnblockAction( EIAB_Jump, 'PettingHorse' );
  15317. UnblockAction( EIAB_Movement, 'PettingHorse' );
  15318. UnblockAction( EIAB_CallHorse, 'PettingHorse' );
  15319. UnblockAction( EIAB_MountVehicle, 'PettingHorse' );
  15320. UnblockAction( EIAB_DrawWeapon, 'PettingHorse' );
  15321. UnblockAction( EIAB_Signs, 'PettingHorse' );
  15322. UnblockAction( EIAB_LightAttacks, 'PettingHorse' );
  15323. UnblockAction( EIAB_HeavyAttacks, 'PettingHorse' );
  15324. UnblockAction( EIAB_ThrowBomb, 'PettingHorse' );
  15325. UnblockAction( EIAB_Crossbow, 'PettingHorse' );
  15326. UnblockAction( EIAB_UsableItem, 'PettingHorse' );
  15327.  
  15328. tempHorse.SetBehaviorVariable( 'horsePetting', 0.0f );
  15329. ((W3HorseComponent)((CNewNPC)tempHorse).GetHorseComponent()).AllowLookat(true);
  15330. }
  15331.  
  15332.  
  15333.  
  15334. private var explorationCameraToggle : bool;
  15335. private var combatCameraToggle : bool;
  15336. private var horseCameraToggle : bool;
  15337. private var softLockCameraAssist : bool;
  15338.  
  15339. public function SetExplCamera(b : bool) { explorationCameraToggle = b; }
  15340. public function SetCmbtCamera(b : bool) { combatCameraToggle = b; }
  15341. public function SetHorseCamera(b : bool) { horseCameraToggle = b; }
  15342. public function SetSoftLockCameraAssist(b : bool) { softLockCameraAssist = b; }
  15343.  
  15344. public function GetExplCamera() : bool { return explorationCameraToggle; }
  15345. public function GetCmbtCamera() : bool { return combatCameraToggle; }
  15346. public function GetHorseCamera() : bool { return horseCameraToggle; }
  15347. public function GetSoftLockCameraAssist() : bool { return softLockCameraAssist; }
  15348.  
  15349. public function SetPlayerCameraPreset()
  15350. {
  15351. var inGameConfigWrapper : CInGameConfigWrapper;
  15352.  
  15353. inGameConfigWrapper = theGame.GetInGameConfigWrapper();
  15354. if(inGameConfigWrapper.GetVarValue('Gameplay', 'EnableAlternateExplorationCamera') == "1")
  15355. SetExplCamera(true);
  15356. else
  15357. SetExplCamera(false);
  15358.  
  15359. if(inGameConfigWrapper.GetVarValue('Gameplay', 'EnableAlternateCombatCamera') == "1")
  15360. SetCmbtCamera(true);
  15361. else
  15362. SetCmbtCamera(false);
  15363.  
  15364. if(inGameConfigWrapper.GetVarValue('Gameplay', 'EnableAlternateHorseCamera') == "1")
  15365. SetHorseCamera(true);
  15366. else
  15367. SetHorseCamera(false);
  15368.  
  15369. if(inGameConfigWrapper.GetVarValue('Gameplay', 'SoftLockCameraAssist') == "true")
  15370. SetSoftLockCameraAssist(true);
  15371. else
  15372. SetSoftLockCameraAssist(false);
  15373.  
  15374.  
  15375. if(inGameConfigWrapper.GetVarValue('Controls', 'LeftStickSprint') == "true")
  15376. SetLeftStickSprint(true);
  15377. else
  15378. SetLeftStickSprint(false);
  15379.  
  15380. }
  15381.  
  15382.  
  15383.  
  15384. private var leftStickSprint : bool;
  15385. public function SetLeftStickSprint(b : bool) { leftStickSprint = b; }
  15386. public function GetLeftStickSprint() : bool { return leftStickSprint; }
  15387.  
  15388.  
  15389.  
  15390. private var photomodeHorseKick : bool;
  15391. public function SetPhotoModeHorseKick( b : bool )
  15392. {
  15393. photomodeHorseKick = b;
  15394. }
  15395.  
  15396. public function GetPhotoModeHorseKick() : bool
  15397. {
  15398. return photomodeHorseKick;
  15399. }
  15400.  
  15401.  
  15402.  
  15403. public timer function NGE_DrainIgniStamina(dt:float, id:int)
  15404. {
  15405. var l_cost, l_stamina : float;
  15406.  
  15407. if( CanUseSkill( S_Perk_09 ) )
  15408. {
  15409. l_cost = GetStaminaActionCost(ESAT_Ability, SkillEnumToName( S_Magic_2 ), 0);
  15410. l_stamina = GetStat(BCS_Stamina, true);
  15411.  
  15412. if( l_cost > l_stamina )
  15413. {
  15414. DrainFocus(1);
  15415. }
  15416. else
  15417. {
  15418. DrainStamina( ESAT_Ability, 0, 0, SkillEnumToName( S_Magic_2 ) );
  15419. }
  15420. }
  15421. else
  15422. {
  15423. DrainStamina( ESAT_Ability, 0, 0, SkillEnumToName( S_Magic_2 ) );
  15424. }
  15425. }
  15426.  
  15427.  
  15428.  
  15429.  
  15430. private var lastSelectedItem : SItemUniqueId;
  15431. public function SetLastSelectedRadialItem(item : SItemUniqueId)
  15432. {
  15433. lastSelectedItem = item;
  15434. AddTimer('EquipRadialMenuItem', 1.2f, false);
  15435. }
  15436.  
  15437. timer function EquipRadialMenuItem(dt:float,id:int)
  15438. {
  15439. GetWitcherPlayer().EquipItem( lastSelectedItem, EES_Quickslot1, false);
  15440. GetWitcherPlayer().SelectQuickslotItem( EES_Quickslot1 );
  15441. }
  15442.  
  15443. }
  15444.  
  15445. exec function setcam(a:int, b:bool)
  15446. {
  15447. if(a == 0)
  15448. thePlayer.SetExplCamera(b);
  15449. if(a == 1)
  15450. thePlayer.SetCmbtCamera(b);
  15451. if(a == 2)
  15452. thePlayer.SetHorseCamera(b);
  15453. }
  15454.  
  15455.  
  15456.  
  15457. exec function ttt()
  15458. {
  15459. thePlayer.AddTimer( 'TestTimer', 5, false );
  15460. }
  15461.  
Add Comment
Please, Sign In to add comment