Advertisement
Guest User

help

a guest
Dec 26th, 2017
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 384.11 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.  
  37. private var lookAtPosition : Vector;
  38. private var orientationTarget : EOrientationTarget;
  39. private var customOrientationTarget : EOrientationTarget;
  40. protected var customOrientationStack : array<SCustomOrientationParams>;
  41.  
  42. public var delayOrientationChange : bool;
  43. protected var delayCameraOrientationChange : bool;
  44. private var actionType : int;
  45. private var customOrientationStackIndex : int;
  46.  
  47. private var emptyMoveTargetTimer : float;
  48.  
  49. private var onlyOneEnemyLeft : bool;
  50.  
  51. public var isInFinisher : bool;
  52. private var finisherTarget : CGameplayEntity;
  53.  
  54. private var combatStance : EPlayerCombatStance;
  55.  
  56. public var approachAttack : int;
  57. default approachAttack = 1;
  58. protected var specialAttackCamera : bool;
  59.  
  60. private var specialAttackTimeRatio : float;
  61.  
  62. public saved var itemsPerLevel : array<name>;
  63. public var itemsPerLevelGiven : array<bool>;
  64.  
  65. private var playerTickTimerPhase : int;
  66. default playerTickTimerPhase = 0;
  67.  
  68. protected var evadeHeading : float;
  69.  
  70. public var vehicleCbtMgrAiming : bool;
  71.  
  72. public var specialHeavyChargeDuration : float;
  73. public var specialHeavyStartEngineTime : EngineTime;
  74. public var playedSpecialAttackMissingResourceSound : bool;
  75. public function SetPlayedSpecialAttackMissingResourceSound(b : bool) {playedSpecialAttackMissingResourceSound = b;}
  76.  
  77. public var counterCollisionGroupNames : array<name>;
  78.  
  79. public saved var lastInstantKillTime : GameTime;
  80.  
  81.  
  82. private var noSaveLockCombatActionName : string; default noSaveLockCombatActionName = 'combat_action';
  83. private var noSaveLockCombatAction : int;
  84. private var deathNoSaveLock : int;
  85. private var noSaveLock : int;
  86.  
  87.  
  88. protected saved var newGamePlusInitialized : bool;
  89. default newGamePlusInitialized = false;
  90.  
  91.  
  92. protected var BufferAllSteps : bool;
  93. protected var BufferCombatAction : EBufferActionType;
  94. protected var BufferButtonStage : EButtonStage;
  95.  
  96. default BufferAllSteps = false;
  97. default customOrientationTarget = OT_None;
  98. default hitReactionEffect = true;
  99. default uninterruptedHitsCount = 0;
  100. default uninterruptedHitsCameraStarted = false;
  101. default customOrientationStackIndex = -1;
  102.  
  103.  
  104. private var keepRequestingCriticalAnimStart : bool;
  105.  
  106. default keepRequestingCriticalAnimStart = false;
  107.  
  108.  
  109. private var currentCustomAction : EPlayerExplorationAction;
  110. public var substateManager : CExplorationStateManager;
  111. protected var isOnBoat : bool;
  112. protected var isInShallowWater : bool;
  113. public var medallion : W3MedallionFX;
  114. protected var lastMedallionEffect : float;
  115. private var isInRunAnimation : bool;
  116. public var interiorTracker :CPlayerInteriorTracker;
  117. public var m_SettlementBlockCanter : int;
  118.  
  119.  
  120.  
  121. private var fistFightMinigameEnabled : bool;
  122. private var isFFMinigameToTheDeath : bool;
  123. private var FFMinigameEndsithBS : bool;
  124. public var fistFightTeleportNode : CNode;
  125. public var isStartingFistFightMinigame : bool;
  126. public var GeraltMaxHealth : float;
  127. public var fistsItems : array< SItemUniqueId >;
  128.  
  129. default FFMinigameEndsithBS = false;
  130. default fistFightMinigameEnabled = false;
  131. default isFFMinigameToTheDeath = false;
  132.  
  133.  
  134. private var gwintAiDifficulty : EGwintDifficultyMode; default gwintAiDifficulty = EGDM_Easy;
  135. private var gwintAiAggression : EGwintAggressionMode; default gwintAiAggression = EGAM_Defensive;
  136. private var gwintMinigameState : EMinigameState; default gwintMinigameState = EMS_None;
  137.  
  138.  
  139. import private var horseWithInventory : EntityHandle;
  140. private var currentlyMountedHorse : CNewNPC;
  141. private var horseSummonTimeStamp : float;
  142. private saved var isHorseRacing : bool;
  143. private var horseCombatSlowMo : bool;
  144. default isHorseRacing = false;
  145. default horseCombatSlowMo = true;
  146.  
  147.  
  148. private var HudMessages : array <string>;
  149. protected var fShowToLowStaminaIndication : float;
  150. public var showTooLowAdrenaline : bool;
  151. private var HAXE3Container : W3Container;
  152. private var HAXE3bAutoLoot: bool;
  153. private var bShowHud : bool;
  154. private var dodgeFeedbackTarget : CActor;
  155.  
  156. default HAXE3bAutoLoot = false;
  157. default fShowToLowStaminaIndication = 0.0f;
  158. default bShowHud = true;
  159.  
  160. saved var displayedQuestsGUID : array< CGUID >;
  161. saved var rewardsMultiplier : array< SRewardMultiplier >;
  162. saved var glossaryImageOverride : array< SGlossaryImageOverride >;
  163.  
  164.  
  165. private var prevRawLeftJoyRot : float;
  166. protected var explorationInputContext : name;
  167. protected var combatInputContext : name;
  168. protected var combatFistsInputContext : name;
  169.  
  170.  
  171. private var isInsideInteraction : bool;
  172. private var isInsideHorseInteraction : bool;
  173. public var horseInteractionSource : CEntity;
  174. public var nearbyLockedContainersNoKey : array<W3LockableEntity>;
  175.  
  176.  
  177. private var bMoveTargetChangeAllowed : bool; default bMoveTargetChangeAllowed = true;
  178. private var moveAdj : CMovementAdjustor;
  179. private var defaultLocomotionController : CR4LocomotionPlayerControllerScript;
  180.  
  181.  
  182. private var canFollowNpc : bool;
  183. private var actorToFollow : CActor;
  184. public var terrainPitch : float;
  185. public var steepSlopeNormalPitch : float; default steepSlopeNormalPitch = 65.f;
  186. public var disableSprintTerrainPitch : float; default disableSprintTerrainPitch = 54.f;
  187. private var submergeDepth : float;
  188.  
  189. private var m_useSelectedItemIfSpawned : bool; default m_useSelectedItemIfSpawned = false;
  190.  
  191.  
  192. var navQuery : CNavigationReachabilityQueryInterface;
  193.  
  194.  
  195. public saved var rememberedCustomHead : name;
  196.  
  197.  
  198. public saved var disableWeatherDisplay : bool;
  199.  
  200.  
  201. public saved var proudWalk : bool;
  202. private var etherealCount : int;
  203. default etherealCount = 0;
  204.  
  205.  
  206. public saved var injuredWalk : bool;
  207. public saved var tiedWalk : bool;
  208. private var insideDiveAttackArea : bool;
  209. default insideDiveAttackArea = false;
  210. private var diveAreaNumber : int;
  211. default diveAreaNumber = -1;
  212.  
  213.  
  214. private var flyingBossCamera : bool;
  215. default flyingBossCamera = false;
  216.  
  217. public function SetFlyingBossCamera( val : bool ) { flyingBossCamera = val; }
  218. public function GetFlyingBossCamera() : bool { return flyingBossCamera; }
  219.  
  220.  
  221. public saved var upscaledTooltipState : bool;
  222. default upscaledTooltipState = false;
  223.  
  224.  
  225. private var phantomWeaponMgr : CPhantomWeaponManager;
  226.  
  227.  
  228.  
  229. function EnablePCMode( flag : bool )
  230. {
  231. pcMode = flag;
  232. }
  233.  
  234. public function IsPCModeEnabled() : bool
  235. {
  236. return pcMode && theInput.LastUsedPCInput();
  237. }
  238.  
  239. public function ShouldUsePCModeTargeting() : bool
  240. {
  241. return IsPCModeEnabled() && !lastAxisInputIsMovement;
  242. }
  243.  
  244. public function SetDodgeFeedbackTarget( target : CActor )
  245. {
  246. dodgeFeedbackTarget = target;
  247. }
  248.  
  249. public function GetDodgeFeedbackTarget() : CActor
  250. {
  251. return dodgeFeedbackTarget;
  252. }
  253.  
  254. public function SetSubmergeDepth( depth : float )
  255. {
  256. submergeDepth = depth;
  257. }
  258.  
  259. public function GetSubmergeDepth() : float
  260. {
  261. return submergeDepth;
  262. }
  263.  
  264.  
  265. editable var delayBetweenIllusionOneliners : float;
  266.  
  267. hint delayBetweenIllusionOneliners = "delay in secs between oneliners about illusionary objects";
  268.  
  269. default delayBetweenIllusionOneliners = 5;
  270.  
  271.  
  272. private var battlecry_timeForNext : float;
  273. private var battlecry_delayMin : float; default battlecry_delayMin = 15;
  274. private var battlecry_delayMax : float; default battlecry_delayMax = 60;
  275. private var battlecry_lastTry : name;
  276.  
  277.  
  278. private var previousWeather : name;
  279. private var previousRainStrength : float;
  280.  
  281.  
  282. protected var receivedDamageInCombat : bool;
  283. protected var prevDayNightIsNight : bool;
  284. public var failedFundamentalsFirstAchievementCondition : bool;
  285.  
  286. private var spawnedTime : float;
  287.  
  288. public var currentMonsterHuntInvestigationArea : W3MonsterHuntInvestigationArea;
  289.  
  290. private var isPerformingPhaseChangeAnimation : bool;
  291. default isPerformingPhaseChangeAnimation = false;
  292.  
  293. default receivedDamageInCombat = false;
  294.  
  295.  
  296. public var playerMode : W3PlayerMode;
  297.  
  298.  
  299. protected saved var selectedItemId : SItemUniqueId;
  300. protected saved var blockedRadialSlots : array < SRadialSlotDef >;
  301.  
  302.  
  303. public var enemyCollectionDist : float;
  304. public var findMoveTargetDistMin : float;
  305. public var findMoveTargetDistMax : float;
  306. private var findMoveTargetScaledFrame : float;
  307. public var interactDist : float;
  308. protected var bCanFindTarget : bool;
  309. private var bIsConfirmingEmptyTarget : bool;
  310. private var displayTarget : CGameplayEntity;
  311. private var isShootingFriendly : bool;
  312.  
  313. default findMoveTargetDistMax = 18.f;
  314. default findMoveTargetScaledFrame = 0.5f;
  315. default interactDist = 3.5f;
  316.  
  317.  
  318. private var currentSelectedTarget : CActor;
  319. private var selectedTargetToConfirm : CActor;
  320. private var bConfirmTargetTimerIsEnabled : bool;
  321.  
  322.  
  323. public saved var thrownEntityHandle : EntityHandle;
  324. private var isThrowingItemWithAim : bool;
  325. private saved var isThrowingItem : bool;
  326. private var isThrowHoldPressed : bool;
  327.  
  328.  
  329. private var isAimingCrossbow : bool;
  330.  
  331. default isThrowingItemWithAim = false;
  332.  
  333.  
  334. public var playerAiming : PlayerAiming;
  335.  
  336.  
  337. public var forceDismember : bool;
  338. public var forceDismemberName : name;
  339. public var forceDismemberChance : int;
  340. public var forceDismemberExplosion : bool;
  341.  
  342.  
  343. private var finisherVictim : CActor;
  344. public var forceFinisher : bool;
  345. public var forceFinisherAnimName : name;
  346. public var forceFinisherChance : int;
  347. public var forcedStance : bool;
  348.  
  349.  
  350. private var m_WeaponFXCollisionGroupNames : array <name>;
  351. private var m_CollisionEffect : CEntity;
  352. private var m_LastWeaponTipPos : Vector;
  353. private var m_CollisionFxTemplate : CEntityTemplate;
  354. private var m_RefreshWeaponFXType : bool;
  355. private var m_PlayWoodenFX : bool;
  356.  
  357.  
  358. private var m_activePoster : W3Poster;
  359.  
  360. public function SetActivePoster ( poster : W3Poster )
  361. {
  362. m_activePoster = poster;
  363. }
  364.  
  365. public function RemoveActivePoster ()
  366. {
  367. m_activePoster = NULL;
  368. }
  369.  
  370. public function GetActivePoster () : W3Poster
  371. {
  372. return m_activePoster;
  373. }
  374.  
  375.  
  376.  
  377.  
  378.  
  379. public var horseOnNavMesh : bool;
  380. default horseOnNavMesh = true;
  381.  
  382. public function SetHorseNav( val : bool ) { horseOnNavMesh = val; }
  383.  
  384.  
  385. public var testAdjustRequestedMovementDirection : bool;
  386. default testAdjustRequestedMovementDirection = false;
  387.  
  388.  
  389. default autoState = 'Exploration';
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396. import final function GetEnemiesInRange( out enemies : array< CActor > );
  397. import final function GetVisibleEnemies( out enemies : array< CActor > );
  398. import final function IsEnemyVisible( enemy : CActor ) : bool;
  399.  
  400.  
  401. import final function SetupEnemiesCollection( range, heightTolerance : float,
  402. maxEnemies : int,
  403. optional tag : name,
  404. optional flags : int );
  405.  
  406. import final function IsInInterior() : bool;
  407. import final function IsInSettlement() : bool;
  408. import final function EnterSettlement( isEntering : bool );
  409. import final function ActionDirectControl( controller : CR4LocomotionDirectController ) : bool;
  410. import final function SetPlayerTarget( target : CActor );
  411. import final function SetPlayerCombatTarget( target : CActor );
  412. import final function ObtainTicketFromCombatTarget( ticketName : CName, ticketsCount : int );
  413. import final function FreeTicketAtCombatTarget();
  414. import final function SetScriptMoveTarget( target : CActor );
  415. import final function GetRiderData() : CAIStorageRiderData;
  416. import final function SetIsInCombat( inCombat : bool );
  417. import final function SaveLastMountedHorse( mountedHorse : CActor );
  418.  
  419. import final function SetBacklightFromHealth( healthPercentage : float );
  420. import private final function SetBacklightColor( color : Vector );
  421.  
  422. import final function GetCombatDataComponent() : CCombatDataComponent;
  423.  
  424. import final function GetTemplatePathAndAppearance( out templatePath : string, out appearance : name );
  425.  
  426. import final function HACK_BoatDismountPositionCorrection( slotPos : Vector );
  427.  
  428. import final function HACK_ForceGetBonePosition( boneIndex : int ) : Vector;
  429.  
  430.  
  431. public function GetLevel() : int
  432. {
  433. return 0;
  434. }
  435.  
  436.  
  437.  
  438.  
  439. var targeting : CR4PlayerTargeting;
  440. var targetingPrecalcs : SR4PlayerTargetingPrecalcs;
  441. var targetingIn : SR4PlayerTargetingIn;
  442. var targetingOut : SR4PlayerTargetingOut;
  443. var useNativeTargeting : bool;
  444. default useNativeTargeting = true;
  445.  
  446. var visibleActors : array< CActor >;
  447. var visibleActorsTime : array< float >;
  448.  
  449.  
  450.  
  451. event OnSpawned( spawnData : SEntitySpawnData )
  452. {
  453. var atts : array<name>;
  454. var skill : ESkill;
  455. var i : int;
  456. var item : SItemUniqueId;
  457.  
  458. //---=== modFriendlyHUD ===---
  459. fHUDConfig = new CModFriendlyHUDConfig in this;
  460. fHUDConfig.Init();
  461. //---=== modFriendlyHUD ===---
  462.  
  463. AddAnimEventCallback('ThrowHoldTest', 'OnAnimEvent_ThrowHoldTest');
  464. AddAnimEventCallback('OnWeaponDrawReady', 'OnAnimEvent_OnWeaponDrawReady');
  465. AddAnimEventCallback('OnWeaponHolsterReady', 'OnAnimEvent_OnWeaponHolsterReady');
  466. AddAnimEventCallback('AllowTempLookAt', 'OnAnimEvent_AllowTempLookAt');
  467. AddAnimEventCallback('SlideToTarget', 'OnAnimEvent_SlideToTarget');
  468. AddAnimEventCallback('PlayFinisherBlood', 'OnAnimEvent_PlayFinisherBlood');
  469. AddAnimEventCallback('SlowMo', 'OnAnimEvent_SlowMo');
  470. AddAnimEventCallback('BloodTrailForced', 'OnAnimEvent_BloodTrailForced');
  471. AddAnimEventCallback('FadeOut', 'OnAnimEvent_FadeOut');
  472. AddAnimEventCallback('FadeIn', 'OnAnimEvent_FadeIn');
  473. AddAnimEventCallback('DisallowHitAnim', 'OnAnimEvent_DisallowHitAnim');
  474. AddAnimEventCallback('AllowFall', 'OnAnimEvent_AllowFall');
  475. AddAnimEventCallback('AllowFall2', 'OnAnimEvent_AllowFall2');
  476. AddAnimEventCallback('DettachGround', 'OnAnimEvent_DettachGround');
  477. AddAnimEventCallback('KillWithRagdoll', 'OnAnimEvent_KillWithRagdoll');
  478. AddAnimEventCallback('pad_vibration', 'OnAnimEvent_pad_vibration');
  479. AddAnimEventCallback('pad_vibration_light', 'OnAnimEvent_pad_vibration_light');
  480. AddAnimEventCallback('RemoveBurning', 'OnAnimEvent_RemoveBurning');
  481. AddAnimEventCallback('RemoveTangled', 'OnAnimEvent_RemoveTangled');
  482. AddAnimEventCallback('MoveNoise', 'OnAnimEvent_MoveNoise');
  483.  
  484. AddItemPerLevelList();
  485.  
  486. enemyCollectionDist = findMoveTargetDistMax;
  487.  
  488.  
  489. theGame.RemoveTimeScale('horse_melee');
  490.  
  491.  
  492. if(!spawnData.restored && !((W3ReplacerCiri)this) )
  493. {
  494. AddTimer('GiveStartingItems', 0.00001, true, , , true);
  495.  
  496. if(!theGame.IsFinalBuild())
  497. {
  498.  
  499. AddAbility('GeraltSkills_Testing');
  500. AddTimer('Debug_GiveTestingItems',0.0001,true);
  501. }
  502.  
  503.  
  504. FactsAdd("tut_stash_fresh_playthrough");
  505. }
  506.  
  507. InitTargeting();
  508.  
  509.  
  510. if( spawnData.restored )
  511. {
  512.  
  513.  
  514.  
  515. theGame.GameplayFactsRemove( "in_combat" );
  516. }
  517.  
  518.  
  519.  
  520. if ( !weaponHolster )
  521. {
  522. weaponHolster = new WeaponHolster in this;
  523. }
  524.  
  525. weaponHolster.Initialize( this, spawnData.restored );
  526.  
  527. if ( !interiorTracker )
  528. {
  529. interiorTracker = new CPlayerInteriorTracker in this;
  530. }
  531. interiorTracker.Init( spawnData.restored );
  532.  
  533.  
  534. super.OnSpawned( spawnData );
  535.  
  536.  
  537. medallion = new W3MedallionFX in this;
  538.  
  539. playerMode = new W3PlayerMode in this;
  540. playerMode.Initialize( this );
  541.  
  542.  
  543. playerAiming = new PlayerAiming in this;
  544. playerAiming.Initialize( this );
  545.  
  546.  
  547. navQuery = new CNavigationReachabilityQueryInterface in this;
  548.  
  549.  
  550. EnableFindTarget( true );
  551. AddTimer( 'CombatCheck', 0.2f, true );
  552.  
  553.  
  554. substateManager = ( CExplorationStateManager ) GetComponentByClassName( 'CExplorationStateManager' );
  555.  
  556. findMoveTargetDist = findMoveTargetDistMax;
  557.  
  558. SetupEnemiesCollection( enemyCollectionDist, findMoveTargetDist, 10, 'None', FLAG_Attitude_Neutral + FLAG_Attitude_Hostile + FLAG_Attitude_Friendly + FLAG_OnlyAliveActors );
  559.  
  560.  
  561. inputHandler.RemoveLocksOnSpawn();
  562.  
  563.  
  564. ((CActor) this ).SetInteractionPriority( IP_Prio_0 );
  565.  
  566. prevDayNightIsNight = theGame.envMgr.IsNight();
  567. CheckDayNightCycle();
  568.  
  569.  
  570. EnableVisualDebug( SHOW_AI, true );
  571.  
  572.  
  573. FactsRemove("blocked_illusion_oneliner");
  574.  
  575. SetFailedFundamentalsFirstAchievementCondition(false);
  576. m_CollisionFxTemplate = (CEntityTemplate) LoadResource( 'sword_colision_fx' );
  577. if( m_WeaponFXCollisionGroupNames.Size() == 0 )
  578. {
  579. m_WeaponFXCollisionGroupNames.PushBack('Static');
  580. m_WeaponFXCollisionGroupNames.PushBack('Foliage');
  581. m_WeaponFXCollisionGroupNames.PushBack('Fence');
  582. m_WeaponFXCollisionGroupNames.PushBack('BoatSide');
  583. m_WeaponFXCollisionGroupNames.PushBack('Door');
  584. m_WeaponFXCollisionGroupNames.PushBack('RigidBody');
  585. m_WeaponFXCollisionGroupNames.PushBack('Dynamic');
  586. m_WeaponFXCollisionGroupNames.PushBack('Destructible');
  587. }
  588.  
  589. if ( counterCollisionGroupNames.Size() == 0 )
  590. {
  591. counterCollisionGroupNames.PushBack('Static');
  592. counterCollisionGroupNames.PushBack('Foliage');
  593. counterCollisionGroupNames.PushBack('Fence');
  594. counterCollisionGroupNames.PushBack('Terrain');
  595. counterCollisionGroupNames.PushBack('Door');
  596. counterCollisionGroupNames.PushBack('RigidBody');
  597. counterCollisionGroupNames.PushBack('Dynamic');
  598. counterCollisionGroupNames.PushBack('Destructible');
  599. }
  600.  
  601.  
  602. ResetPadBacklightColor();
  603.  
  604. if( spawnData.restored )
  605. {
  606. if (IsCurrentlyUsingItemL())
  607. {
  608. if (inv.HasItemById( currentlyEquipedItemL ))
  609. {
  610. OnUseSelectedItem();
  611. }
  612. else
  613. {
  614. HideUsableItem(true);
  615. }
  616. }
  617. if ( GetCurrentMeleeWeaponType() == PW_Steel || GetCurrentMeleeWeaponType() == PW_Silver )
  618. {
  619. OnEquipMeleeWeapon(GetCurrentMeleeWeaponType(), true, true);
  620. }
  621.  
  622. AddTimer( 'UnmountCrossbowTimer', 0.01, true );
  623.  
  624. ClearBlockedSlots();
  625. }
  626.  
  627. ((CR4PlayerStateSwimming)this.GetState('Swimming')).OnParentSpawned();
  628.  
  629.  
  630. SetImmortalityMode( AIM_None, AIC_SyncedAnim );
  631.  
  632.  
  633. theGame.GetDefinitionsManager().GetContainedAbilities('DwimeritiumBomb_3', atts);
  634. for(i=0; i<atts.Size(); i+=1)
  635. {
  636. skill = SkillNameToEnum(atts[i]);
  637. if(skill != S_SUndefined)
  638. BlockSkill(skill, false);
  639. }
  640.  
  641.  
  642. this.GetInventory().GetItemEquippedOnSlot( EES_SteelSword, item );
  643. if( this.GetInventory().ItemHasTag( item, 'PhantomWeapon' ) )
  644. {
  645. this.InitPhantomWeaponMgr();
  646. }
  647.  
  648.  
  649. if(FactsQuerySum("mq3036_fact_done") > 0)
  650. BlockAllActions('mq3036', false);
  651.  
  652. spawnedTime = theGame.GetEngineTimeAsSeconds();
  653.  
  654. if ( theGame.GetInGameConfigWrapper().GetVarValue('Gameplay', 'EnableUberMovement' ) == "1" )
  655. theGame.EnableUberMovement( true );
  656. else
  657. theGame.EnableUberMovement( false );
  658.  
  659.  
  660. if ( !FactsDoesExist("gwent_difficulty") )
  661. FactsAdd("gwent_difficulty", 2);
  662.  
  663.  
  664. if(!newGamePlusInitialized && FactsQuerySum("NewGamePlus") > 0)
  665. {
  666. NewGamePlusInitialize();
  667. }
  668.  
  669.  
  670. if( lastInstantKillTime > theGame.GetGameTime() )
  671. {
  672. SetLastInstantKillTime( GameTimeCreate(0) );
  673. }
  674. }
  675.  
  676. public function NewGamePlusInitialize()
  677. {
  678.  
  679. SetLastInstantKillTime( GameTimeCreate(0) );
  680. }
  681.  
  682. public function GetTimeSinceSpawned() : float
  683. {
  684. return theGame.GetEngineTimeAsSeconds() - spawnedTime;
  685. }
  686.  
  687. timer function UnmountCrossbowTimer( dt : float, id : int )
  688. {
  689. var itemId : SItemUniqueId;
  690.  
  691. itemId = this.inv.GetItemFromSlot( 'l_weapon' );
  692. if ( inv.IsIdValid( itemId ) && inv.IsItemCrossbow( itemId ) )
  693. {
  694. rangedWeapon = (Crossbow)( inv.GetItemEntityUnsafe( itemId ) );
  695.  
  696. if (rangedWeapon)
  697. {
  698. rangedWeapon.Initialize( (CActor)( rangedWeapon.GetParentEntity() ) );
  699. OnRangedForceHolster( true, true );
  700. RemoveTimer( 'UnmountCrossbowTimer' );
  701. }
  702. }
  703. else
  704. RemoveTimer( 'UnmountCrossbowTimer' );
  705. }
  706.  
  707. event OnDestroyed()
  708. {
  709. playerAiming.RemoveAimingSloMo();
  710.  
  711. if(rangedWeapon)
  712. rangedWeapon.ClearDeployedEntity(true);
  713.  
  714. ResetPadBacklightColor();
  715.  
  716.  
  717. theGame.ReleaseNoSaveLock( noSaveLock );
  718. }
  719.  
  720.  
  721.  
  722.  
  723.  
  724. public function GetBlockedSlots () : array < SRadialSlotDef >
  725. {
  726. return blockedRadialSlots;
  727. }
  728.  
  729. public function ClearBlockedSlots()
  730. {
  731. var i : int;
  732.  
  733.  
  734.  
  735. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  736. {
  737. if( !IsSwimming() )
  738. {
  739. if ( EnableRadialSlot(blockedRadialSlots[i].slotName, 'swimming'))
  740. {
  741. i-=1;
  742. continue;
  743. }
  744. }
  745. if (!IsUsingVehicle())
  746. {
  747. if ( EnableRadialSlot(blockedRadialSlots[i].slotName, 'useVehicle'))
  748. {
  749. i-=1;
  750. continue;
  751. }
  752. }
  753. if ( !IsCurrentlyUsingItemL() || !IsUsableItemLBlocked() )
  754. {
  755. if ( EnableRadialSlot(blockedRadialSlots[i].slotName, 'usableItemL'))
  756. {
  757. i-=1;
  758. continue;
  759. }
  760. }
  761. if ( !IsThrowingItem() )
  762. {
  763. if ( EnableRadialSlot(blockedRadialSlots[i].slotName, 'throwBomb'))
  764. {
  765. i-=1;
  766. continue;
  767. }
  768. }
  769. }
  770.  
  771.  
  772.  
  773. }
  774.  
  775. public function RestoreBlockedSlots ()
  776. {
  777. var i : int;
  778. var slotsToBlock : array<name>;
  779.  
  780. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  781. {
  782. slotsToBlock.PushBack ( blockedRadialSlots[i].slotName );
  783. }
  784. if ( slotsToBlock.Size() > 0 )
  785. {
  786. EnableRadialSlots ( false, slotsToBlock );
  787. }
  788. }
  789. private function DisableRadialSlot ( slotName : name, sourceName : name ) : bool
  790. {
  791. var i : int;
  792. var k : int;
  793. var slotsToBlock : array<name>;
  794.  
  795. var blockedRadialSlotEntry : SRadialSlotDef;
  796.  
  797. slotsToBlock.PushBack ( slotName );
  798.  
  799. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  800. {
  801. if ( blockedRadialSlots[i].slotName == slotName )
  802. {
  803. if ( sourceName != '' )
  804. {
  805. for ( k = 0; k < blockedRadialSlots[i].disabledBySources.Size(); k += 1 )
  806. {
  807. if ( blockedRadialSlots[i].disabledBySources[k] == sourceName )
  808. {
  809. return false;
  810. }
  811. }
  812. blockedRadialSlots[i].disabledBySources.PushBack ( sourceName );
  813. return false;
  814. }
  815.  
  816. return false;
  817. }
  818. }
  819.  
  820. blockedRadialSlotEntry = InitBlockedRadialSlotEntry ( slotName );
  821.  
  822. if ( sourceName != '' )
  823. {
  824. blockedRadialSlotEntry.disabledBySources.PushBack ( sourceName );
  825. }
  826. blockedRadialSlots.PushBack ( blockedRadialSlotEntry );
  827. EnableRadialSlots ( false, slotsToBlock );
  828. return true;
  829. }
  830.  
  831. public function EnableRadialSlot ( slotName : name, sourceName : name ) : bool
  832. {
  833. var i : int;
  834. var k : int;
  835.  
  836. var slotsToBlock : array<name>;
  837.  
  838. slotsToBlock.PushBack ( slotName );
  839.  
  840. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  841. {
  842. if ( blockedRadialSlots[i].slotName == slotName )
  843. {
  844.  
  845. if ( sourceName != '' )
  846. {
  847. for ( k = 0; k < blockedRadialSlots[i].disabledBySources.Size(); k += 1 )
  848. {
  849. if ( blockedRadialSlots[i].disabledBySources[k] == sourceName )
  850. {
  851. blockedRadialSlots[i].disabledBySources.Remove ( blockedRadialSlots[i].disabledBySources[k] );
  852. }
  853. }
  854. }
  855. if ( blockedRadialSlots[i].disabledBySources.Size() <= 0 )
  856. {
  857. blockedRadialSlots.Remove( blockedRadialSlots[i] );
  858. EnableRadialSlots ( true, slotsToBlock );
  859. return true;
  860. }
  861. return false;
  862. }
  863. }
  864. return false;
  865.  
  866. }
  867.  
  868. private function InitBlockedRadialSlotEntry ( slotName : name ) : SRadialSlotDef
  869. {
  870. var blockedRadialSlotEntry : SRadialSlotDef;
  871.  
  872. blockedRadialSlotEntry.slotName = slotName;
  873.  
  874. return blockedRadialSlotEntry;
  875.  
  876. }
  877.  
  878. public function EnableRadialSlotsWithSource ( enable : bool, slotsToBlock : array < name >, sourceName : name )
  879. {
  880. var i : int;
  881.  
  882. for ( i = 0; i < slotsToBlock.Size(); i+=1 )
  883. {
  884. if ( enable )
  885. {
  886. EnableRadialSlot ( slotsToBlock[i], sourceName );
  887. }
  888. else
  889. {
  890. DisableRadialSlot ( slotsToBlock[i], sourceName );
  891. }
  892. }
  893. if ( blockedRadialSlots.Size() <= 0 )
  894. {
  895. blockedRadialSlots.Clear();
  896. }
  897. }
  898.  
  899. public function IsRadialSlotBlocked ( slotName : name ) : bool
  900. {
  901. var i : int;
  902.  
  903. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  904. {
  905. if ( blockedRadialSlots[i].slotName == slotName )
  906. {
  907. return true;
  908. }
  909. }
  910. return false;
  911. }
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918. public function RepairItem ( rapairKitId : SItemUniqueId, usedOnItem : SItemUniqueId );
  919. public function HasRepairAbleGearEquiped () : bool;
  920. public function HasRepairAbleWaponEquiped () : bool;
  921. public function IsItemRepairAble ( item : SItemUniqueId ) : bool;
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928. public final function ReduceAllOilsAmmo( id : SItemUniqueId )
  929. {
  930. var i : int;
  931. var oils : array< W3Effect_Oil >;
  932.  
  933. oils = inv.GetOilsAppliedOnItem( id );
  934.  
  935. for( i=0; i<oils.Size(); i+=1 )
  936. {
  937. oils[ i ].ReduceAmmo();
  938. }
  939. }
  940.  
  941. public final function ResumeOilBuffs( steel : bool )
  942. {
  943. var item : SItemUniqueId;
  944. var oils : array< CBaseGameplayEffect >;
  945. var buff, recentOil : W3Effect_Oil;
  946. var i : int;
  947.  
  948. item = GetEquippedSword( steel );
  949. oils = GetBuffs( EET_Oil );
  950.  
  951. if( oils.Size() > 1 )
  952. {
  953.  
  954.  
  955. recentOil = inv.GetNewestOilAppliedOnItem( item, false );
  956. }
  957.  
  958. for( i=0; i<oils.Size(); i+=1 )
  959. {
  960. buff = ( W3Effect_Oil ) oils[ i ];
  961.  
  962. if( recentOil && recentOil == buff )
  963. {
  964. continue;
  965. }
  966.  
  967. if(buff && buff.GetSwordItemId() == item )
  968. {
  969. buff.Resume( '' );
  970. }
  971. }
  972.  
  973. if( recentOil )
  974. {
  975. recentOil.Resume( '' );
  976. }
  977. }
  978.  
  979. protected final function PauseOilBuffs( isSteel : bool )
  980. {
  981. var item : SItemUniqueId;
  982. var oils : array< CBaseGameplayEffect >;
  983. var buff : W3Effect_Oil;
  984. var i : int;
  985.  
  986. item = GetEquippedSword( isSteel );
  987. oils = GetBuffs( EET_Oil );
  988.  
  989. for( i=0; i<oils.Size(); i+=1 )
  990. {
  991. buff = ( W3Effect_Oil ) oils[ i ];
  992. if(buff && buff.GetSwordItemId() == item )
  993. {
  994. buff.Pause( '', true );
  995. }
  996. }
  997. }
  998.  
  999. public final function ManageAerondightBuff( apply : bool )
  1000. {
  1001. var aerondight : W3Effect_Aerondight;
  1002. var item : SItemUniqueId;
  1003.  
  1004. item = inv.GetCurrentlyHeldSword();
  1005.  
  1006. if( inv.ItemHasTag( item, 'Aerondight' ) )
  1007. {
  1008. aerondight = (W3Effect_Aerondight)GetBuff( EET_Aerondight );
  1009.  
  1010. if( apply )
  1011. {
  1012. if( !aerondight )
  1013. {
  1014. AddEffectDefault( EET_Aerondight, this, "Aerondight" );
  1015. }
  1016. else
  1017. {
  1018. aerondight.Resume( 'ManageAerondightBuff' );
  1019. }
  1020. }
  1021. else
  1022. {
  1023. aerondight.Pause( 'ManageAerondightBuff' );
  1024. }
  1025. }
  1026. }
  1027.  
  1028.  
  1029. public function ApplyOil( oilId : SItemUniqueId, usedOnItem : SItemUniqueId ) : bool
  1030. {
  1031. var oilAbilities : array< name >;
  1032. var ammo, ammoBonus : float;
  1033. var dm : CDefinitionsManagerAccessor;
  1034. var buffParams : SCustomEffectParams;
  1035. var oilParams : W3OilBuffParams;
  1036. var oilName : name;
  1037. var min, max : SAbilityAttributeValue;
  1038. var i : int;
  1039. var oils : array< W3Effect_Oil >;
  1040. var existingOil : W3Effect_Oil;
  1041.  
  1042. if( !CanApplyOilOnItem( oilId, usedOnItem ) )
  1043. {
  1044. return false;
  1045. }
  1046.  
  1047. dm = theGame.GetDefinitionsManager();
  1048. inv.GetItemAbilitiesWithTag( oilId, theGame.params.OIL_ABILITY_TAG, oilAbilities );
  1049. oilName = inv.GetItemName( oilId );
  1050. oils = inv.GetOilsAppliedOnItem( usedOnItem );
  1051.  
  1052.  
  1053. for( i=0; i<oils.Size(); i+=1 )
  1054. {
  1055. if( oils[ i ].GetOilItemName() == oilName )
  1056. {
  1057. existingOil = oils[ i ];
  1058. break;
  1059. }
  1060. }
  1061.  
  1062.  
  1063. if( !existingOil )
  1064. {
  1065. if( !GetWitcherPlayer() || !GetWitcherPlayer().IsSetBonusActive( EISB_Wolf_1 ) )
  1066. {
  1067. inv.RemoveAllOilsFromItem( usedOnItem );
  1068. }
  1069. else
  1070. {
  1071. dm.GetAbilityAttributeValue( GetSetBonusAbility( EISB_Wolf_1 ), 'max_oils_count', min, max );
  1072. if( inv.GetActiveOilsAppliedOnItemCount( usedOnItem ) >= CalculateAttributeValue( max ) )
  1073. {
  1074. inv.RemoveOldestOilFromItem( usedOnItem );
  1075. }
  1076. }
  1077. }
  1078.  
  1079.  
  1080. ammo = CalculateAttributeValue(inv.GetItemAttributeValue(oilId, 'ammo'));
  1081. if(CanUseSkill(S_Alchemy_s06))
  1082. {
  1083. ammoBonus = CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s06, 'ammo_bonus', false, false));
  1084. ammo *= 1 + ammoBonus * GetSkillLevel(S_Alchemy_s06);
  1085. }
  1086.  
  1087.  
  1088. if( existingOil )
  1089. {
  1090. existingOil.Reapply( RoundMath( ammo ) );
  1091. }
  1092. else
  1093. {
  1094. buffParams.effectType = EET_Oil;
  1095. buffParams.creator = this;
  1096. oilParams = new W3OilBuffParams in this;
  1097. oilParams.iconPath = dm.GetItemIconPath( oilName );
  1098. oilParams.localizedName = dm.GetItemLocalisationKeyName( oilName );
  1099. oilParams.localizedDescription = dm.GetItemLocalisationKeyName( oilName );
  1100. oilParams.sword = usedOnItem;
  1101. oilParams.maxCount = RoundMath( ammo );
  1102. oilParams.currCount = RoundMath( ammo );
  1103. oilParams.oilAbilityName = oilAbilities[ 0 ];
  1104. oilParams.oilItemName = oilName;
  1105. buffParams.buffSpecificParams = oilParams;
  1106.  
  1107. AddEffectCustom( buffParams );
  1108.  
  1109. delete oilParams;
  1110. }
  1111.  
  1112. LogOils("Added oil <<" + oilName + ">> to <<" + inv.GetItemName( usedOnItem ) + ">>");
  1113.  
  1114.  
  1115. SetFailedFundamentalsFirstAchievementCondition( true );
  1116.  
  1117. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnOilApplied );
  1118.  
  1119. if( !inv.IsItemHeld( usedOnItem ) )
  1120. {
  1121. PauseOilBuffs( inv.IsItemSteelSwordUsableByPlayer( usedOnItem ) );
  1122. }
  1123.  
  1124. return true;
  1125. }
  1126.  
  1127.  
  1128. public final function IsEquippedSwordUpgradedWithOil(steel : bool, optional oilName : name) : bool
  1129. {
  1130. var sword : SItemUniqueId;
  1131. var i : int;
  1132. var oils : array< W3Effect_Oil >;
  1133.  
  1134. sword = GetEquippedSword( steel );
  1135. if( !inv.IsIdValid( sword ) )
  1136. {
  1137. return false;
  1138. }
  1139.  
  1140. if( oilName == '' )
  1141. {
  1142. return inv.ItemHasAnyActiveOilApplied( sword );
  1143. }
  1144.  
  1145. oils = inv.GetOilsAppliedOnItem( sword );
  1146. for( i=0; i<oils.Size(); i+=1 )
  1147. {
  1148. if( oils[ i ].GetOilItemName() == oilName )
  1149. {
  1150. return true;
  1151. }
  1152. }
  1153.  
  1154. return false;
  1155. }
  1156.  
  1157. public function CanApplyOilOnItem(oilId : SItemUniqueId, usedOnItem : SItemUniqueId) : bool
  1158. {
  1159. if(inv.ItemHasTag(oilId, theGame.params.TAG_STEEL_OIL) && inv.IsItemSteelSwordUsableByPlayer(usedOnItem))
  1160. return true;
  1161.  
  1162. if(inv.ItemHasTag(oilId, theGame.params.TAG_SILVER_OIL) && inv.IsItemSilverSwordUsableByPlayer(usedOnItem))
  1163. return true;
  1164.  
  1165. return false;
  1166. }
  1167.  
  1168.  
  1169. public final function DidFailFundamentalsFirstAchievementCondition() : bool
  1170. {
  1171. return failedFundamentalsFirstAchievementCondition;
  1172. }
  1173.  
  1174. public final function SetFailedFundamentalsFirstAchievementCondition(b : bool)
  1175. {
  1176. var i : int;
  1177. var npc : CNewNPC;
  1178.  
  1179. failedFundamentalsFirstAchievementCondition = b;
  1180.  
  1181.  
  1182. if(failedFundamentalsFirstAchievementCondition)
  1183. {
  1184. for(i=0; i<hostileEnemies.Size(); i+=1)
  1185. {
  1186. if(hostileEnemies[i].HasTag(theGame.params.MONSTER_HUNT_ACTOR_TAG))
  1187. {
  1188. npc = (CNewNPC)hostileEnemies[i];
  1189. npc.AddTag('failedFundamentalsAchievement');
  1190. npc.AddTimer('FundamentalsAchFailTimer', 30*60, , , , true, true);
  1191. }
  1192. }
  1193. }
  1194. }
  1195.  
  1196. public function IsInCombatFist() : bool
  1197. {
  1198. return this.GetCurrentStateName() == 'CombatFists';
  1199. }
  1200.  
  1201. public function IsInitialized() : bool;
  1202.  
  1203. public function IsCiri() : bool
  1204. {
  1205. return ((W3ReplacerCiri)this);
  1206. }
  1207.  
  1208. protected function WouldLikeToMove() : bool
  1209. {
  1210. var speedVec : Vector;
  1211. var speed, speedMult : float;
  1212.  
  1213.  
  1214. speedVec.X = theInput.GetActionValue( 'GI_AxisLeftX' );
  1215. speedVec.Y = theInput.GetActionValue( 'GI_AxisLeftY' );
  1216. speed = VecLength2D( speedVec );
  1217.  
  1218. return speed > 0.1f;
  1219. }
  1220.  
  1221. function HandleMovement( deltaTime : float )
  1222. {
  1223.  
  1224.  
  1225.  
  1226.  
  1227. if (WouldLikeToMove())
  1228. SetBehaviorVariable( 'playerWouldLikeToMove', 1.0f);
  1229. else
  1230. SetBehaviorVariable( 'playerWouldLikeToMove', 0.0f);
  1231.  
  1232. super.HandleMovement( deltaTime );
  1233. }
  1234.  
  1235. function BattleCryIsReady( ) : bool
  1236. {
  1237. var l_currentTime : float;
  1238.  
  1239. l_currentTime = theGame.GetEngineTimeAsSeconds();
  1240.  
  1241. if( l_currentTime >= battlecry_timeForNext )
  1242. {
  1243. return true;
  1244. }
  1245. return false;
  1246. }
  1247.  
  1248. function PlayBattleCry( _BattleCry : name , _Chance : float, optional _IgnoreDelay, ignoreRepeatCheck : bool )
  1249. {
  1250. var l_randValue : float;
  1251. var fact : int;
  1252.  
  1253. fact = FactsQuerySum("force_stance_normal");
  1254.  
  1255. if( IsSwimming()
  1256. || theGame.IsDialogOrCutscenePlaying()
  1257. || IsInNonGameplayCutscene()
  1258. || IsInGameplayScene()
  1259. || theGame.IsCurrentlyPlayingNonGameplayScene()
  1260. || theGame.IsFading()
  1261. || theGame.IsBlackscreen()
  1262. || FactsQuerySum("force_stance_normal") > 0 )
  1263. {
  1264. return;
  1265. }
  1266.  
  1267.  
  1268. if ( !ignoreRepeatCheck )
  1269. {
  1270. if( battlecry_lastTry == _BattleCry )
  1271. return;
  1272. }
  1273.  
  1274. battlecry_lastTry = _BattleCry;
  1275.  
  1276. l_randValue = RandF();
  1277.  
  1278.  
  1279. if( l_randValue < _Chance && ( _IgnoreDelay || BattleCryIsReady() ) )
  1280. {
  1281. thePlayer.PlayVoiceset( 90, _BattleCry );
  1282.  
  1283. battlecry_timeForNext = theGame.GetEngineTimeAsSeconds() + RandRangeF( battlecry_delayMax, battlecry_delayMin );
  1284. }
  1285.  
  1286. }
  1287.  
  1288. public final function OnWeatherChanged()
  1289. {
  1290. if( IsInInterior()
  1291. || GetCurrentStateName() != 'Exploration'
  1292. || theGame.IsDialogOrCutscenePlaying()
  1293. || IsInNonGameplayCutscene()
  1294. || IsInGameplayScene()
  1295. || theGame.IsCurrentlyPlayingNonGameplayScene()
  1296. || theGame.IsFading()
  1297. || theGame.IsBlackscreen()
  1298. || GetTimeSinceSpawned() < 60 )
  1299. {
  1300. return;
  1301. }
  1302.  
  1303. AddTimer( 'CommentOnWeather', 1 );
  1304. }
  1305.  
  1306. public final timer function CommentOnWeather( _Delta : float, _Id : int )
  1307. {
  1308. var l_weather : name;
  1309. var l_currentArea : EAreaName;
  1310. var l_rand : float;
  1311.  
  1312. l_weather = GetWeatherConditionName();
  1313.  
  1314. l_currentArea = theGame.GetCommonMapManager().GetCurrentArea();
  1315.  
  1316. switch ( l_weather )
  1317. {
  1318. case 'WT_Clear':
  1319.  
  1320. l_rand = RandF();
  1321.  
  1322. if( l_rand > 0.66f && !AreaIsCold() && theGame.envMgr.IsDay() )
  1323. {
  1324. thePlayer.PlayVoiceset( 90, 'WeatherHot' );
  1325. }
  1326. else if ( l_rand > 0.33f )
  1327. {
  1328. thePlayer.PlayVoiceset( 90, 'WeatherClearingUp' );
  1329. }
  1330. break;
  1331.  
  1332. case 'WT_Rain_Storm':
  1333. thePlayer.PlayVoiceset( 90, 'WeatherStormy' );
  1334. break;
  1335.  
  1336. case 'WT_Light_Clouds':
  1337. if( previousRainStrength < GetRainStrength() )
  1338. {
  1339. thePlayer.PlayVoiceset( 90, 'WeatherLooksLikeRain' );
  1340. }
  1341. else if( AreaIsCold() && previousWeather == 'WT_Clear' )
  1342. {
  1343. thePlayer.PlayVoiceset( 90, 'WeatherCold' );
  1344. }
  1345. break;
  1346.  
  1347. case 'WT_Mid_Clouds':
  1348. if( previousRainStrength < GetRainStrength() )
  1349. {
  1350. thePlayer.PlayVoiceset( 90, 'WeatherRaining' );
  1351. }
  1352. else if( AreaIsCold() && previousWeather == 'WT_Clear' )
  1353. {
  1354. thePlayer.PlayVoiceset( 90, 'WeatherCold' );
  1355. }
  1356. break;
  1357.  
  1358. case 'WT_Mid_Clouds_Dark':
  1359. if( previousWeather != 'WT_Heavy_Clouds' && previousWeather != 'WT_Heavy_Clouds_Dark' )
  1360. thePlayer.PlayVoiceset( 90, 'WeatherWindy' );
  1361. break;
  1362.  
  1363. case 'WT_Heavy_Clouds':
  1364. if( previousWeather != 'WT_Mid_Clouds_Dark' && previousWeather != 'WT_Heavy_Clouds_Dark' )
  1365. thePlayer.PlayVoiceset( 90, 'WeatherWindy' );
  1366. break;
  1367.  
  1368. case 'WT_Heavy_Clouds_Dark':
  1369. if( thePlayer.IsOnBoat() )
  1370. {
  1371. thePlayer.PlayVoiceset( 90, 'WeatherSeaWillStorm' );
  1372. }
  1373. else if( previousRainStrength < GetRainStrength() )
  1374. {
  1375. thePlayer.PlayVoiceset( 90, 'WeatherLooksLikeRain' );
  1376. }
  1377. else
  1378. {
  1379. thePlayer.PlayVoiceset( 90, 'WeatherWindy' );
  1380. }
  1381. break;
  1382.  
  1383. case 'WT_Snow':
  1384. if( RandF() > 0.5f )
  1385. thePlayer.PlayVoiceset( 90, 'WeatherSnowy' );
  1386. else
  1387. thePlayer.PlayVoiceset( 90, 'WeatherCold' );
  1388. break;
  1389. }
  1390.  
  1391. previousRainStrength = GetRainStrength();
  1392. previousWeather = l_weather;
  1393. }
  1394.  
  1395. function CanUpdateMovement() : bool
  1396. {
  1397. if ( rangedWeapon
  1398. && GetBehaviorVariable( 'fullBodyAnimWeight' ) >= 1.f
  1399. && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  1400. return false;
  1401.  
  1402. return true;
  1403. }
  1404.  
  1405. public function SetDefaultLocomotionController()
  1406. {
  1407. if( !defaultLocomotionController )
  1408. {
  1409. defaultLocomotionController = new CR4LocomotionPlayerControllerScript in this;
  1410. }
  1411.  
  1412. ActionDirectControl( defaultLocomotionController );
  1413. }
  1414.  
  1415. event OnPlayerTickTimer( deltaTime : float )
  1416. {
  1417. var focusModeController : CFocusModeController;
  1418. var cnt : int;
  1419.  
  1420. super.OnPlayerTickTimer( deltaTime );
  1421.  
  1422. HandleMovement( deltaTime );
  1423.  
  1424. if ( playerAiming.GetCurrentStateName() == 'Aiming' )
  1425. {
  1426. FindTarget();
  1427. FindNonActorTarget( false );
  1428. UpdateDisplayTarget();
  1429. UpdateLookAtTarget();
  1430. }
  1431. else
  1432. {
  1433. if( playerTickTimerPhase == 0 )
  1434. {
  1435. FindTarget();
  1436. }
  1437. else if( playerTickTimerPhase == 1 )
  1438. {
  1439. FindNonActorTarget( false );
  1440. }
  1441. else if ( playerTickTimerPhase == 2 )
  1442. {
  1443. UpdateDisplayTarget();
  1444. UpdateLookAtTarget();
  1445. }
  1446. }
  1447.  
  1448.  
  1449.  
  1450. playerTickTimerPhase = ( playerTickTimerPhase + 1 ) % 3;
  1451.  
  1452. focusModeController = theGame.GetFocusModeController();
  1453. focusModeController.UpdateFocusInteractions( deltaTime );
  1454.  
  1455.  
  1456. cnt = (int)( effectManager.GetCriticalBuffsCount() > 0 );
  1457. SetBehaviorVariable('hasCriticalBuff', cnt);
  1458. }
  1459.  
  1460. event OnDeath( damageAction : W3DamageAction )
  1461. {
  1462. super.OnDeath( damageAction );
  1463.  
  1464. RemoveTimer('RequestCriticalAnimStart');
  1465.  
  1466. EnableFindTarget( false );
  1467. BlockAllActions('Death', true);
  1468.  
  1469. EnableHardLock( false );
  1470.  
  1471. theGame.CreateNoSaveLock( 'player_death', deathNoSaveLock, false, false );
  1472. theGame.SetDeathSaveLockId( deathNoSaveLock );
  1473.  
  1474. ClearHostileEnemiesList();
  1475. RemoveReactions();
  1476. SetPlayerCombatTarget(NULL);
  1477. OnEnableAimingMode( false );
  1478.  
  1479. theGame.EnableFreeCamera( false );
  1480. }
  1481.  
  1482.  
  1483. function OnRevived()
  1484. {
  1485. super.OnRevived();
  1486. BlockAllActions('Death', false);
  1487.  
  1488. theGame.ReleaseNoSaveLock(deathNoSaveLock);
  1489.  
  1490. this.RestartReactionsIfNeeded();
  1491. }
  1492.  
  1493. public function CanStartTalk() : bool
  1494. {
  1495. if ( beingWarnedBy.Size() > 0 )
  1496. return false;
  1497.  
  1498. return super.CanStartTalk();
  1499. }
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506. public function AddCounterTimeStamp(time : EngineTime) {counterTimestamps.PushBack(time);}
  1507.  
  1508.  
  1509. public function CheckCounterSpamming(attacker : CActor) : bool
  1510. {
  1511. var counterWindowStartTime : EngineTime;
  1512. var i, spamCounter : int;
  1513. var reflexAction : bool;
  1514. var testEngineTime : EngineTime;
  1515.  
  1516. if(!attacker)
  1517. return false;
  1518.  
  1519. counterWindowStartTime = ((CNewNPC)attacker).GetCounterWindowStartTime();
  1520. spamCounter = 0;
  1521. reflexAction = false;
  1522.  
  1523.  
  1524. if ( counterWindowStartTime == testEngineTime )
  1525. {
  1526. return false;
  1527. }
  1528.  
  1529. for(i = counterTimestamps.Size() - 1; i>=0; i-=1)
  1530. {
  1531.  
  1532. if(counterTimestamps[i] >= (counterWindowStartTime - EngineTimeFromFloat(0.4)) )
  1533. {
  1534. spamCounter += 1;
  1535. }
  1536.  
  1537. else
  1538. {
  1539. counterTimestamps.Remove(counterTimestamps[i]);
  1540. continue;
  1541. }
  1542.  
  1543.  
  1544. if(!reflexAction && (counterTimestamps[i] >= counterWindowStartTime))
  1545. reflexAction = true;
  1546. }
  1547.  
  1548.  
  1549. if(spamCounter == 1 && reflexAction)
  1550. return true;
  1551.  
  1552. return false;
  1553. }
  1554.  
  1555. protected function PerformCounterCheck(parryInfo: SParryInfo) : bool
  1556. {
  1557. var mult : float;
  1558. var parryType : EParryType;
  1559. var validCounter, useKnockdown : bool;
  1560. var slideDistance, duration : float;
  1561. var playerToTargetRot : EulerAngles;
  1562. var zDifference, mutation8TriggerHP : float;
  1563. var effectType : EEffectType;
  1564. var repelType : EPlayerRepelType = PRT_Random;
  1565. var params : SCustomEffectParams;
  1566. var thisPos, attackerPos : Vector;
  1567. var fistFightCheck, isMutation8 : bool;
  1568. var fistFightCounter : bool;
  1569. var attackerInventory : CInventoryComponent;
  1570. var weaponId : SItemUniqueId;
  1571. var weaponTags : array<name>;
  1572. var playerToAttackerVector : Vector;
  1573. var tracePosStart : Vector;
  1574. var tracePosEnd : Vector;
  1575. var hitPos : Vector;
  1576. var hitNormal : Vector;
  1577. var min, max : SAbilityAttributeValue;
  1578. var npc : CNewNPC;
  1579.  
  1580. if(ShouldProcessTutorial('TutorialDodge') || ShouldProcessTutorial('TutorialCounter'))
  1581. {
  1582. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
  1583. FactsRemove("tut_fight_slomo_ON");
  1584. }
  1585.  
  1586. if ( !parryInfo.canBeParried || parryInfo.attacker.HasAbility( 'CannotBeCountered' ) )
  1587. return false;
  1588.  
  1589. fistFightCheck = FistFightCheck( parryInfo.target, parryInfo.attacker, fistFightCounter );
  1590.  
  1591. if( ParryCounterCheck() && parryInfo.targetToAttackerAngleAbs < theGame.params.PARRY_HALF_ANGLE && fistFightCheck )
  1592. {
  1593.  
  1594. validCounter = CheckCounterSpamming(parryInfo.attacker);
  1595.  
  1596. if(validCounter)
  1597. {
  1598. if ( IsInCombatActionFriendly() )
  1599. RaiseEvent('CombatActionFriendlyEnd');
  1600.  
  1601. SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
  1602. SetBehaviorVariable( 'counter', (float)validCounter);
  1603.  
  1604.  
  1605.  
  1606. SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
  1607. SetBehaviorVariable( 'counter', (float)validCounter);
  1608. this.SetBehaviorVariable( 'combatActionType', (int)CAT_Parry );
  1609.  
  1610.  
  1611. if ( !fistFightCounter )
  1612. {
  1613. attackerInventory = parryInfo.attacker.GetInventory();
  1614. weaponId = attackerInventory.GetItemFromSlot('r_weapon');
  1615. attackerInventory.GetItemTags( weaponId , weaponTags );
  1616.  
  1617. if( GetWitcherPlayer().IsMutationActive( EPMT_Mutation8 ) )
  1618. {
  1619. isMutation8 = true;
  1620. theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Mutation8', 'hp_perc_trigger', min, max );
  1621. mutation8TriggerHP = min.valueMultiplicative;
  1622. }
  1623.  
  1624.  
  1625.  
  1626. npc = (CNewNPC)parryInfo.attacker;
  1627.  
  1628.  
  1629. if ( parryInfo.attacker.HasAbility('mon_gravehag') )
  1630. {
  1631. repelType = PRT_Slash;
  1632. parryInfo.attacker.AddEffectDefault(EET_CounterStrikeHit, this, 'ReflexParryPerformed');
  1633.  
  1634. }
  1635. else if ( npc && !npc.IsHuman() && !npc.HasTag( 'dettlaff_vampire' ) )
  1636. {
  1637. repelType = PRT_SideStepSlash;
  1638. }
  1639. else if ( weaponTags.Contains('spear2h') )
  1640. {
  1641. repelType = PRT_SideStepSlash;
  1642. parryInfo.attacker.AddEffectDefault(EET_CounterStrikeHit, this, "ReflexParryPerformed");
  1643. parryInfo.attacker.SignalGameplayEvent( 'SpearDestruction');
  1644. }
  1645. else if( isMutation8 && npc && !npc.IsImmuneToMutation8Finisher() )
  1646. {
  1647. repelType = PRT_RepelToFinisher;
  1648. npc.AddEffectDefault( EET_CounterStrikeHit, this, "ReflexParryPerformed" );
  1649.  
  1650.  
  1651. SetTarget( npc, true );
  1652.  
  1653. PerformFinisher( 0.f, 0 );
  1654. }
  1655. else
  1656. {
  1657.  
  1658. thisPos = this.GetWorldPosition();
  1659. attackerPos = parryInfo.attacker.GetWorldPosition();
  1660. playerToTargetRot = VecToRotation( thisPos - attackerPos );
  1661. zDifference = thisPos.Z - attackerPos.Z;
  1662.  
  1663. if ( playerToTargetRot.Pitch < -5.f && zDifference > 0.35 )
  1664. {
  1665. repelType = PRT_Kick;
  1666.  
  1667. ragdollTarget = parryInfo.attacker;
  1668. AddTimer( 'ApplyCounterRagdollTimer', 0.3 );
  1669. }
  1670. else
  1671. {
  1672. useKnockdown = false;
  1673. if ( CanUseSkill(S_Sword_s11) )
  1674. {
  1675. if( GetSkillLevel(S_Sword_s11) > 1 && RandRangeF(3,0) < GetWitcherPlayer().GetStat(BCS_Focus) )
  1676. {
  1677. duration = CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s11, 'duration', false, true));
  1678. useKnockdown = true;
  1679. }
  1680. }
  1681. else if ( parryInfo.attacker.IsHuman() )
  1682. {
  1683.  
  1684. tracePosStart = parryInfo.attacker.GetWorldPosition();
  1685. tracePosStart.Z += 1.f;
  1686. playerToAttackerVector = VecNormalize( parryInfo.attacker.GetWorldPosition() - parryInfo.target.GetWorldPosition() );
  1687. tracePosEnd = ( playerToAttackerVector * 0.75f ) + ( playerToAttackerVector * parryInfo.attacker.GetRadius() ) + parryInfo.attacker.GetWorldPosition();
  1688. tracePosEnd.Z += 1.f;
  1689.  
  1690. if ( !theGame.GetWorld().StaticTrace( tracePosStart, tracePosEnd, hitPos, hitNormal, counterCollisionGroupNames ) )
  1691. {
  1692. tracePosStart = tracePosEnd;
  1693. tracePosEnd -= 3.f;
  1694.  
  1695. if ( !theGame.GetWorld().StaticTrace( tracePosStart, tracePosEnd, hitPos, hitNormal, counterCollisionGroupNames ) )
  1696. useKnockdown = true;
  1697. }
  1698. }
  1699.  
  1700. if(useKnockdown && (!parryInfo.attacker.IsImmuneToBuff(EET_HeavyKnockdown) || !parryInfo.attacker.IsImmuneToBuff(EET_Knockdown)))
  1701. {
  1702. if(!parryInfo.attacker.IsImmuneToBuff(EET_HeavyKnockdown))
  1703. {
  1704. params.effectType = EET_HeavyKnockdown;
  1705. }
  1706. else
  1707. {
  1708. params.effectType = EET_Knockdown;
  1709. }
  1710.  
  1711. repelType = PRT_Kick;
  1712. params.creator = this;
  1713. params.sourceName = "ReflexParryPerformed";
  1714. params.duration = duration;
  1715.  
  1716. parryInfo.attacker.AddEffectCustom(params);
  1717. }
  1718. else
  1719. {
  1720. parryInfo.attacker.AddEffectDefault(EET_CounterStrikeHit, this, "ReflexParryPerformed");
  1721. }
  1722. }
  1723. }
  1724.  
  1725. parryInfo.attacker.GetInventory().PlayItemEffect(parryInfo.attackerWeaponId, 'counterattack');
  1726.  
  1727.  
  1728. if ( repelType == PRT_Random )
  1729. if ( RandRange(100) > 50 )
  1730. repelType = PRT_Bash;
  1731. else
  1732. repelType = PRT_Kick;
  1733.  
  1734. this.SetBehaviorVariable( 'repelType', (int)repelType );
  1735. parryInfo.attacker.SetBehaviorVariable( 'repelType', (int)repelType );
  1736. }
  1737. else
  1738. {
  1739. parryInfo.attacker.AddEffectDefault(EET_CounterStrikeHit, this, "ReflexParryPerformed");
  1740. }
  1741.  
  1742.  
  1743. SetParryTarget ( parryInfo.attacker );
  1744. SetSlideTarget( parryInfo.attacker );
  1745. if ( !IsActorLockedToTarget() )
  1746. SetMoveTarget( parryInfo.attacker );
  1747.  
  1748. if ( RaiseForceEvent( 'PerformCounter' ) )
  1749. OnCombatActionStart();
  1750.  
  1751. SetCustomRotation( 'Counter', VecHeading( parryInfo.attacker.GetWorldPosition() - this.GetWorldPosition() ), 0.0f, 0.2f, false );
  1752. AddTimer( 'UpdateCounterRotation', 0.4f, true );
  1753. AddTimer( 'SetCounterRotation', 0.2f );
  1754.  
  1755. IncreaseUninterruptedHitsCount();
  1756.  
  1757.  
  1758. if(IsHeavyAttack(parryInfo.attackActionName))
  1759. mult = theGame.params.HEAVY_STRIKE_COST_MULTIPLIER;
  1760.  
  1761. DrainStamina(ESAT_Counterattack, 0, 0, '', 0, mult);
  1762.  
  1763. theGame.GetGamerProfile().IncStat(ES_CounterattackChain);
  1764.  
  1765. }
  1766. else
  1767. {
  1768. ResetUninterruptedHitsCount();
  1769. }
  1770. return validCounter;
  1771. }
  1772.  
  1773. return false;
  1774. }
  1775.  
  1776. timer function UpdateCounterRotation( dt : float, id : int )
  1777. {
  1778. UpdateCustomRotationHeading( 'Counter', VecHeading( parryTarget.GetWorldPosition() - this.GetWorldPosition() ) );
  1779. }
  1780.  
  1781. timer function SetCounterRotation( dt : float, id : int )
  1782. {
  1783. SetCustomRotation( 'Counter', VecHeading( parryTarget.GetWorldPosition() - this.GetWorldPosition() ), 360.f, 0.2f, false );
  1784. }
  1785.  
  1786. private var parryTarget : CActor;
  1787. private function SetParryTarget( t : CActor )
  1788. {
  1789. parryTarget = t;
  1790. }
  1791.  
  1792. private var ragdollTarget : CActor;
  1793. timer function ApplyCounterRagdollTimer( time : float , id : int)
  1794. {
  1795. var actor : CActor;
  1796.  
  1797. actor = (CActor)ragdollTarget;
  1798.  
  1799. if(actor)
  1800. {
  1801. actor.AddEffectDefault(EET_HeavyKnockdown, this, 'ReflexParryPerformed');
  1802. }
  1803. }
  1804.  
  1805.  
  1806.  
  1807.  
  1808. public function EnableMode( mode : EPlayerMode, enable : bool )
  1809. {
  1810. playerMode.EnableMode( mode, enable );
  1811. }
  1812.  
  1813. public function GetPlayerMode() : W3PlayerMode
  1814. {
  1815. return playerMode;
  1816. }
  1817.  
  1818. private function GetClosestIncomingAttacker() : CActor
  1819. {
  1820. var i, size : int;
  1821. var attackerToPlayerDistances : array< float >;
  1822. var closestAttackerIndex : int;
  1823. var incomingAttackers : array<CActor>;
  1824.  
  1825.  
  1826. if(playerMode && playerMode.combatDataComponent)
  1827. {
  1828. if ( incomingAttackers.Size() <= 0 )
  1829. this.playerMode.combatDataComponent.GetTicketSourceOwners( incomingAttackers, 'TICKET_Charge' );
  1830.  
  1831. if ( incomingAttackers.Size() <= 0 )
  1832. this.playerMode.combatDataComponent.GetTicketSourceOwners( incomingAttackers, 'TICKET_Melee' );
  1833.  
  1834. if ( incomingAttackers.Size() <= 0 )
  1835. this.playerMode.combatDataComponent.GetTicketSourceOwners( incomingAttackers, 'TICKET_Range' );
  1836. }
  1837.  
  1838. size = incomingAttackers.Size();
  1839. attackerToPlayerDistances.Resize( size );
  1840.  
  1841. if ( size > 0 )
  1842. {
  1843. for ( i = incomingAttackers.Size()-1; i >= 0; i -= 1)
  1844. {
  1845. if ( !IsEnemyVisible( incomingAttackers[i] ) )
  1846. {
  1847. incomingAttackers.EraseFast( i );
  1848. }
  1849. }
  1850. }
  1851.  
  1852. if ( size > 0 )
  1853. {
  1854. for ( i = 0; i < size; i += 1 )
  1855. {
  1856. attackerToPlayerDistances[i] = VecDistance( incomingAttackers[i].GetWorldPosition(), this.GetWorldPosition() );
  1857. }
  1858. closestAttackerIndex = ArrayFindMinF( attackerToPlayerDistances );
  1859. return incomingAttackers[ closestAttackerIndex ];
  1860. }
  1861. else
  1862. {
  1863. return NULL;
  1864. }
  1865. }
  1866.  
  1867.  
  1868. timer function CombatCheck( time : float , id : int)
  1869. {
  1870. var i : int;
  1871. var strLevel, temp : string;
  1872. var enemies : array<CActor>;
  1873.  
  1874. UpdateFinishableEnemyList();
  1875. FindMoveTarget();
  1876. playerMode.UpdateCombatMode();
  1877.  
  1878. if( GetPlayerCombatStance() == PCS_Guarded )
  1879. {
  1880. if( GetTarget().GetHealthPercents() > 0.25f )
  1881. {
  1882. PlayBattleCry( 'BattleCryTaunt', 0.2f );
  1883. }
  1884. else
  1885. {
  1886. if( GetTarget().IsHuman() )
  1887. PlayBattleCry( 'BattleCryHumansEnd', 0.3f );
  1888. else
  1889. PlayBattleCry( 'BattleCryMonstersEnd', 0.3f );
  1890. }
  1891. }
  1892.  
  1893. if(IsThreatened() && ShouldProcessTutorial('TutorialMonsterThreatLevels') && FactsQuerySum("q001_nightmare_ended") > 0)
  1894. {
  1895. GetEnemiesInRange(enemies);
  1896. for(i=0; i<enemies.Size(); i+=1)
  1897. {
  1898. strLevel = ((CNewNPC)enemies[i]).GetExperienceDifferenceLevelName(temp);
  1899. if(strLevel == "deadlyLevel" || strLevel == "highLevel")
  1900. {
  1901. FactsAdd("tut_high_threat_monster");
  1902. break;
  1903. }
  1904. }
  1905. }
  1906. }
  1907.  
  1908. public function ReceivedDamageInCombat() : bool
  1909. {
  1910. return receivedDamageInCombat;
  1911. }
  1912.  
  1913. //---=== modFriendlyHUD ===---
  1914. timer function PinEssentialGroupTimer( deltaTime : float, id : int )
  1915. {
  1916. ToggleEssentialModules( !IsHUDGroupEnabledForReason( GetFHUDConfig().essentialModules, "PinEssentialGroup" ), "PinEssentialGroup" );
  1917. }
  1918.  
  1919. timer function EssentialsOnTimer( deltaTime : float, id : int )
  1920. {
  1921. ToggleEssentialModules( true, "EssentialModulesHotkey" );
  1922. }
  1923.  
  1924. timer function MapOnTimer( deltaTime : float, id : int )
  1925. {
  1926. ToggleMinimapModules( true, "MinimapModulesHotkey" );
  1927. }
  1928.  
  1929. timer function QuestsOnTimer( deltaTime : float, id : int )
  1930. {
  1931. ToggleQuestsModules( true, "QuestsModulesHotkey" );
  1932. }
  1933.  
  1934. timer function CharOnTimer( deltaTime : float, id : int )
  1935. {
  1936. ToggleCharacterModules( true, "CharModulesHotkey" );
  1937. }
  1938.  
  1939. timer function DamageOffTimer( deltaTime : float, id : int ) //still needed as workaround
  1940. {
  1941. ToggleHUDModule( "WolfHeadModule", false, "OnDamage" );
  1942. }
  1943.  
  1944. timer function MeditationModulesOnTimer( deltaTime : float, id : int ) //needed for compatibility
  1945. {
  1946. if ( GetFHUDConfig().enableMeditationModules )
  1947. {
  1948. ToggleMeditModules( true, "RealTimeMeditation" );
  1949. }
  1950. }
  1951.  
  1952. timer function MeditationModulesOffTimer( deltaTime : float, id : int ) //needed for compatibility
  1953. {
  1954. if ( GetFHUDConfig().enableMeditationModules )
  1955. {
  1956. ToggleMeditModules( false, "RealTimeMeditation" );
  1957. }
  1958. }
  1959. //---=== modFriendlyHUD ===---
  1960.  
  1961. event OnCombatStart()
  1962. {
  1963. var weaponType : EPlayerWeapon;
  1964.  
  1965. //---=== modFriendlyHUD ===---
  1966. if ( GetFHUDConfig().enableCombatModules )
  1967. {
  1968. ToggleCombatModules( true, "InCombat" );
  1969. }
  1970. //---=== modFriendlyHUD ===---
  1971.  
  1972. theGame.CreateNoSaveLock( 'combat', noSaveLock );
  1973.  
  1974. theGame.GameplayFactsAdd( "in_combat" );
  1975.  
  1976.  
  1977. FactsRemove("statistics_cerberus_sign");
  1978. FactsRemove("statistics_cerberus_petard");
  1979. FactsRemove("statistics_cerberus_bolt");
  1980. FactsRemove("statistics_cerberus_fists");
  1981. FactsRemove("statistics_cerberus_melee");
  1982. FactsRemove("statistics_cerberus_environment");
  1983.  
  1984. BlockAction(EIAB_OpenMeditation, 'InCombat');
  1985. BlockAction(EIAB_HighlightObjective, 'InCombat');
  1986.  
  1987. if ( !this.IsUsingBoat() && GetTarget().GetAttitude(this) == AIA_Hostile )
  1988. {
  1989. weaponType = GetMostConvenientMeleeWeapon( GetTarget() );
  1990.  
  1991. if ( weaponType == PW_Steel || weaponType == PW_Silver )
  1992. this.OnEquipMeleeWeapon( weaponType, false );
  1993. }
  1994. }
  1995.  
  1996.  
  1997. event OnCombatFinished()
  1998. {
  1999. var cnt : int;
  2000.  
  2001. //---=== modFriendlyHUD ===---
  2002. if ( GetFHUDConfig().enableCombatModules )
  2003. {
  2004. ToggleCombatModules( false, "InCombat" );
  2005. }
  2006. //---=== modFriendlyHUD ===---
  2007.  
  2008. reevaluateCurrentWeapon = false;
  2009.  
  2010. thePlayer.HardLockToTarget( false );
  2011.  
  2012. receivedDamageInCombat = false;
  2013.  
  2014. theGame.GameplayFactsRemove( "in_combat" );
  2015.  
  2016.  
  2017. cnt = 0;
  2018. if(FactsQuerySum("statistics_cerberus_sign") > 0)
  2019. cnt += 1;
  2020. if(FactsQuerySum("statistics_cerberus_petard") > 0)
  2021. cnt += 1;
  2022. if(FactsQuerySum("statistics_cerberus_bolt") > 0)
  2023. cnt += 1;
  2024. if(FactsQuerySum("statistics_cerberus_fists") > 0)
  2025. cnt += 1;
  2026. if(FactsQuerySum("statistics_cerberus_melee") > 0)
  2027. cnt += 1;
  2028. if(FactsQuerySum("statistics_cerberus_environment") > 0)
  2029. cnt += 1;
  2030.  
  2031.  
  2032. FactsRemove("statistics_cerberus_sign");
  2033. FactsRemove("statistics_cerberus_petard");
  2034. FactsRemove("statistics_cerberus_bolt");
  2035. FactsRemove("statistics_cerberus_fists");
  2036. FactsRemove("statistics_cerberus_melee");
  2037. FactsRemove("statistics_cerberus_environment");
  2038.  
  2039. if(cnt >= 3)
  2040. theGame.GetGamerProfile().AddAchievement(EA_Cerberus);
  2041.  
  2042.  
  2043. if(theGame.GetTutorialSystem() && FactsQuerySum("TutorialShowSilver") > 0)
  2044. {
  2045. FactsAdd("tut_show_silver_sword", 1);
  2046. FactsRemove("TutorialShowSilver");
  2047. }
  2048. this.SetBehaviorVariable('isInCombatForOverlay',0.f);
  2049. GoToExplorationIfNeeded();
  2050. theGame.ReleaseNoSaveLock( noSaveLock );
  2051. LogChannel( 'OnCombatFinished', "OnCombatFinished: ReleaseNoSaveLock" );
  2052.  
  2053. SetFailedFundamentalsFirstAchievementCondition(false);
  2054.  
  2055. UnblockAction(EIAB_OpenMeditation, 'InCombat');
  2056. UnblockAction(EIAB_HighlightObjective, 'InCombat');
  2057. }
  2058.  
  2059. event OnReactToBeingHit( damageAction : W3DamageAction )
  2060. {
  2061. var weaponType : EPlayerWeapon;
  2062.  
  2063. super.OnReactToBeingHit(damageAction);
  2064. IncHitCounter();
  2065.  
  2066. if ( IsInCombat() && damageAction.attacker && damageAction.attacker == GetTarget() && !( this.IsUsingVehicle() && this.IsOnBoat() ) )
  2067. {
  2068. weaponType = GetMostConvenientMeleeWeapon( GetTarget() );
  2069. if ( weaponType != PW_Fists && weaponType != PW_None && weaponType != this.GetCurrentMeleeWeaponType() )
  2070. OnEquipMeleeWeapon( weaponType, false );
  2071. }
  2072. }
  2073.  
  2074.  
  2075. public function ReceivedCombatDamage()
  2076. {
  2077. receivedDamageInCombat = true;
  2078. }
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085. timer function UninterruptedHitsResetOnIdle(dt : float, id : int)
  2086. {
  2087. ResetUninterruptedHitsCount();
  2088. }
  2089.  
  2090. public function ResetUninterruptedHitsCount()
  2091. {
  2092. uninterruptedHitsCount = 0;
  2093. LogUnitAtt("Uninterrupted attacks reset!!!!");
  2094. }
  2095.  
  2096. public function IncreaseUninterruptedHitsCount()
  2097. {
  2098. uninterruptedHitsCount += 1;
  2099. LogUnitAtt("Uninterrupted attacks count increased to " + uninterruptedHitsCount);
  2100.  
  2101. if(uninterruptedHitsCount == 4)
  2102. AddTimer('StartUninterruptedBlurr', 1, false);
  2103.  
  2104.  
  2105. AddTimer('UninterruptedHitsResetOnIdle', 4.f, false);
  2106. }
  2107.  
  2108. timer function StartUninterruptedBlurr(dt : float, id : int)
  2109. {
  2110. var changed : bool;
  2111. var movingAgent : CMovingPhysicalAgentComponent;
  2112. var target : CActor;
  2113.  
  2114.  
  2115. if(uninterruptedHitsCount < 4)
  2116. {
  2117. LogUnitAtt("Stopping camera effect");
  2118. thePlayer.StopEffect(uninterruptedHitsCurrentCameraEffect);
  2119. uninterruptedHitsCurrentCameraEffect = '';
  2120. uninterruptedHitsCameraStarted = false;
  2121. RemoveTimer('StartUninterruptedBlurr');
  2122. }
  2123. else
  2124. {
  2125. target = GetTarget();
  2126.  
  2127. if( target )
  2128. {
  2129. movingAgent = ( (CMovingPhysicalAgentComponent) (target.GetMovingAgentComponent()) );
  2130. }
  2131.  
  2132. if(!uninterruptedHitsCameraStarted)
  2133. {
  2134. LogUnitAtt("Starting camera effect");
  2135. AddTimer('StartUninterruptedBlurr', 0.001, true);
  2136. if(movingAgent && movingAgent.GetCapsuleHeight() > 2)
  2137. uninterruptedHitsCurrentCameraEffect = theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_BIG_ENEMY;
  2138. else
  2139. uninterruptedHitsCurrentCameraEffect = theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_REGULAR_ENEMY;
  2140. thePlayer.PlayEffect(uninterruptedHitsCurrentCameraEffect);
  2141. uninterruptedHitsCameraStarted = true;
  2142. }
  2143. else
  2144. {
  2145. changed = false;
  2146. if(movingAgent && movingAgent.GetCapsuleHeight() > 2 && uninterruptedHitsCurrentCameraEffect != theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_BIG_ENEMY)
  2147. changed = true;
  2148. else if(!movingAgent || ( movingAgent.GetCapsuleHeight() <= 2 && uninterruptedHitsCurrentCameraEffect != theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_REGULAR_ENEMY) )
  2149. changed = true;
  2150.  
  2151.  
  2152. if(changed)
  2153. {
  2154.  
  2155. thePlayer.StopEffect(uninterruptedHitsCurrentCameraEffect);
  2156.  
  2157.  
  2158. if(uninterruptedHitsCurrentCameraEffect == theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_BIG_ENEMY)
  2159. uninterruptedHitsCurrentCameraEffect = theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_REGULAR_ENEMY;
  2160. else
  2161. uninterruptedHitsCurrentCameraEffect = theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_BIG_ENEMY;
  2162.  
  2163.  
  2164. thePlayer.PlayEffect(uninterruptedHitsCurrentCameraEffect);
  2165. }
  2166. }
  2167. }
  2168. }
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174. private var playerActionEventListeners : array<CGameplayEntity>;
  2175. private var playerActionEventBlockingListeners : array<CGameplayEntity>;
  2176.  
  2177. private function PlayerActionBlockGameplayActions( sourceName : name, lock : bool, isFromPlace : bool )
  2178. {
  2179. if ( lock )
  2180. {
  2181. thePlayer.BlockAction( EIAB_Signs, sourceName, false, false, isFromPlace );
  2182. thePlayer.BlockAction( EIAB_DrawWeapon, sourceName, false, false, isFromPlace );
  2183. thePlayer.BlockAction( EIAB_CallHorse, sourceName, false, false, isFromPlace );
  2184. thePlayer.BlockAction( EIAB_FastTravel, sourceName, false, false, isFromPlace );
  2185. thePlayer.BlockAction( EIAB_Fists, sourceName, false, false, isFromPlace );
  2186. thePlayer.BlockAction( EIAB_InteractionAction, sourceName, false, false, isFromPlace );
  2187. thePlayer.DisableCombatState();
  2188. }
  2189. else
  2190. {
  2191. thePlayer.UnblockAction( EIAB_Signs, sourceName );
  2192. thePlayer.UnblockAction( EIAB_DrawWeapon, sourceName );
  2193. thePlayer.UnblockAction( EIAB_CallHorse, sourceName );
  2194. thePlayer.UnblockAction( EIAB_FastTravel, sourceName );
  2195. thePlayer.UnblockAction( EIAB_Fists, sourceName );
  2196. thePlayer.UnblockAction( EIAB_InteractionAction, sourceName );
  2197. }
  2198. }
  2199.  
  2200. public function GetPlayerActionEventListeners() : array<CGameplayEntity>
  2201. {
  2202. return playerActionEventListeners;
  2203. }
  2204.  
  2205.  
  2206. public function RegisterForPlayerAction( listener : CGameplayEntity, isLockedByPlace : bool )
  2207. {
  2208. if ( !playerActionEventListeners.Contains( listener ) )
  2209. {
  2210. playerActionEventListeners.PushBack( listener );
  2211. }
  2212. if ( listener.ShouldBlockGameplayActionsOnInteraction() )
  2213. {
  2214. if ( !playerActionEventBlockingListeners.Contains( listener ) )
  2215. {
  2216. playerActionEventBlockingListeners.PushBack( listener );
  2217. }
  2218. if ( playerActionEventBlockingListeners.Size() == 1 )
  2219. {
  2220. PlayerActionBlockGameplayActions( 'PlayerAction', true, isLockedByPlace );
  2221. }
  2222. }
  2223. }
  2224.  
  2225.  
  2226. public function UnregisterForPlayerAction( listener : CGameplayEntity, isLockedByPlace : bool )
  2227. {
  2228. playerActionEventListeners.Remove( listener );
  2229. playerActionEventBlockingListeners.Remove( listener );
  2230. if ( playerActionEventBlockingListeners.Size() == 0 )
  2231. {
  2232. PlayerActionBlockGameplayActions( 'PlayerAction', false, isLockedByPlace );
  2233. }
  2234. }
  2235.  
  2236. event OnPlayerActionStart()
  2237. {
  2238.  
  2239. thePlayer.SetBehaviorVariable( 'inJumpState', 1.f );
  2240. }
  2241.  
  2242. event OnPlayerActionEnd()
  2243. {
  2244. var i : int;
  2245. for ( i = playerActionEventListeners.Size() - 1; i >= 0; i-=1 )
  2246. {
  2247. playerActionEventListeners[i].OnPlayerActionEnd();
  2248. }
  2249. currentCustomAction = PEA_None;
  2250.  
  2251.  
  2252. thePlayer.SetBehaviorVariable( 'inJumpState', 0.f );
  2253. }
  2254.  
  2255. event OnPlayerActionStartFinished()
  2256. {
  2257. var i : int;
  2258. for ( i = playerActionEventListeners.Size() - 1; i >= 0; i-=1 )
  2259. {
  2260. playerActionEventListeners[i].OnPlayerActionStartFinished();
  2261. }
  2262. }
  2263.  
  2264. function PlayerStartAction( playerAction : EPlayerExplorationAction, optional animName : name ) : bool
  2265. {
  2266. if ( playerAction == PEA_SlotAnimation && !IsNameValid(animName) )
  2267. {
  2268. return false;
  2269. }
  2270.  
  2271. SetBehaviorVariable( 'playerStopAction', 0.0);
  2272. SetBehaviorVariable( 'playerExplorationAction', (float)(int)playerAction);
  2273.  
  2274.  
  2275.  
  2276. if ( RaiseForceEvent('playerActionStart') )
  2277. {
  2278. currentCustomAction = playerAction;
  2279. if ( playerAction == PEA_SlotAnimation )
  2280. {
  2281. playerActionSlotAnimName = animName;
  2282. AddTimer('PlayActionAnimWorkaround',0,false);
  2283. }
  2284. return true;
  2285. }
  2286. return false;
  2287. }
  2288.  
  2289. private var playerActionSlotAnimName : name;
  2290.  
  2291. timer function PlayActionAnimWorkaround( dt : float , id : int)
  2292. {
  2293. this.ActionPlaySlotAnimationAsync('PLAYER_ACTION_SLOT',playerActionSlotAnimName, 0.2, 0.2, true);
  2294. }
  2295.  
  2296. function PlayerStopAction( playerAction : EPlayerExplorationAction )
  2297. {
  2298. SetBehaviorVariable( 'playerExplorationAction', (float)(int)playerAction);
  2299. SetBehaviorVariable( 'playerStopAction', 1.0);
  2300. currentCustomAction = PEA_None;
  2301. }
  2302.  
  2303. function GetPlayerAction() : EPlayerExplorationAction
  2304. {
  2305. return currentCustomAction;
  2306. }
  2307.  
  2308. function MedallionPing()
  2309. {
  2310. var currTime : float = theGame.GetEngineTimeAsSeconds();
  2311.  
  2312. if ( lastMedallionEffect < currTime )
  2313. {
  2314. lastMedallionEffect = theGame.GetEngineTimeAsSeconds() + medallion.effectDuration;
  2315. medallion.TriggerMedallionFX();
  2316. }
  2317. }
  2318.  
  2319.  
  2320.  
  2321.  
  2322.  
  2323. public function CanPerformPlayerAction(optional alsoOutsideExplorationState : bool) : bool
  2324. {
  2325.  
  2326. if(!alsoOutsideExplorationState && GetCurrentStateName() != 'Exploration')
  2327. return false;
  2328.  
  2329. if( isInAir || (substateManager && !substateManager.CanInteract()) || IsInCombatAction() || GetCriticalBuffsCount() > 0)
  2330. return false;
  2331.  
  2332. return true;
  2333. }
  2334.  
  2335.  
  2336. event OnItemGiven(data : SItemChangedData)
  2337. {
  2338. var keyName : name;
  2339. var i : int;
  2340. var hud : CR4ScriptedHud;
  2341. var message : string;
  2342. var inve : CInventoryComponent;
  2343.  
  2344. if(data.informGui)
  2345. {
  2346. hud = (CR4ScriptedHud)theGame.GetHud();
  2347. if(hud)
  2348. {
  2349. message = GetLocStringByKeyExt("panel_common_item_received") + ": " + GetLocStringByKeyExt(inv.GetItemLocalizedNameByUniqueID(data.ids[0]));
  2350. if(data.quantity > 1)
  2351. message += " x" + data.quantity;
  2352. hud.HudConsoleMsg(message);
  2353. }
  2354. }
  2355.  
  2356. inve = GetInventory();
  2357.  
  2358.  
  2359. if(inve.ItemHasTag(data.ids[0], 'key'))
  2360. {
  2361. keyName = inve.GetItemName(data.ids[0]);
  2362. for(i=nearbyLockedContainersNoKey.Size()-1; i>=0; i-=1)
  2363. {
  2364. if(nearbyLockedContainersNoKey[i].GetKeyName() == keyName && nearbyLockedContainersNoKey[i].IsEnabled())
  2365. {
  2366. nearbyLockedContainersNoKey[i].UpdateComponents("Unlock");
  2367. nearbyLockedContainersNoKey.Remove(nearbyLockedContainersNoKey[i]);
  2368. }
  2369. }
  2370. }
  2371.  
  2372.  
  2373. if(inve.IsItemAlchemyItem(data.ids[0]))
  2374. {
  2375. UpgradeAlchemyItem(data.ids[0], CanUseSkill(S_Perk_08));
  2376. }
  2377.  
  2378. if(inve.ItemHasTag(data.ids[0], theGame.params.TAG_OFIR_SET))
  2379. CheckOfirSetAchievement();
  2380. }
  2381.  
  2382. private final function CheckOfirSetAchievement()
  2383. {
  2384. var hasArmor, hasBoots, hasGloves, hasPants, hasSword, hasSaddle, hasBag, hasBlinders : bool;
  2385.  
  2386.  
  2387. CheckOfirItems(GetInventory(), hasArmor, hasBoots, hasGloves, hasPants, hasSword, hasSaddle, hasBag, hasBlinders);
  2388.  
  2389.  
  2390. CheckOfirItems(GetWitcherPlayer().GetHorseManager().GetInventoryComponent(), hasArmor, hasBoots, hasGloves, hasPants, hasSword, hasSaddle, hasBag, hasBlinders);
  2391.  
  2392. if(hasArmor && hasBoots && hasGloves && hasPants && hasSword && hasSaddle && hasBag && hasBlinders)
  2393. theGame.GetGamerProfile().AddAchievement(EA_LatestFashion);
  2394. }
  2395.  
  2396. 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)
  2397. {
  2398. var ofirs : array<SItemUniqueId>;
  2399. var i : int;
  2400.  
  2401. ofirs = inv.GetItemsByTag(theGame.params.TAG_OFIR_SET);
  2402. for(i=0; i<ofirs.Size(); i+=1)
  2403. {
  2404. if(inv.IsItemChestArmor(ofirs[i]))
  2405. {
  2406. hasArmor = true;
  2407. continue;
  2408. }
  2409. else if(inv.IsItemBoots(ofirs[i]))
  2410. {
  2411. hasBoots = true;
  2412. continue;
  2413. }
  2414. else if(inv.IsItemGloves(ofirs[i]))
  2415. {
  2416. hasGloves = true;
  2417. continue;
  2418. }
  2419. else if(inv.IsItemPants(ofirs[i]))
  2420. {
  2421. hasPants = true;
  2422. continue;
  2423. }
  2424. else if(inv.IsItemSteelSwordUsableByPlayer(ofirs[i]))
  2425. {
  2426. hasSword = true;
  2427. continue;
  2428. }
  2429. else if(inv.IsItemSilverSwordUsableByPlayer(ofirs[i]))
  2430. {
  2431. hasSword = true;
  2432. continue;
  2433. }
  2434. else if(inv.IsItemSaddle(ofirs[i]))
  2435. {
  2436. hasSaddle = true;
  2437. continue;
  2438. }
  2439. else if(inv.IsItemHorseBag(ofirs[i]))
  2440. {
  2441. hasBag = true;
  2442. continue;
  2443. }
  2444. else if(inv.IsItemBlinders(ofirs[i]))
  2445. {
  2446. hasBlinders = true;
  2447. continue;
  2448. }
  2449. }
  2450. }
  2451.  
  2452.  
  2453. public function ChangeAlchemyItemsAbilities(upgrade : bool)
  2454. {
  2455. var i : int;
  2456. var dm : CDefinitionsManagerAccessor;
  2457. var items : array<SItemUniqueId>;
  2458.  
  2459. inv.GetAllItems(items);
  2460. dm = theGame.GetDefinitionsManager();
  2461.  
  2462. for(i=0; i<items.Size(); i+=1)
  2463. if(inv.IsItemAlchemyItem(items[i]))
  2464. UpgradeAlchemyItem(items[i], upgrade);
  2465. }
  2466.  
  2467.  
  2468. public function UpgradeAlchemyItem(itemID : SItemUniqueId, upgrade : bool)
  2469. {
  2470. var j, currLevel, otherLevel : int;
  2471. var dm : CDefinitionsManagerAccessor;
  2472. var abs, currAbilities, otherAbilities : array<name>;
  2473. var min, max : SAbilityAttributeValue;
  2474.  
  2475. if(!inv.IsItemAlchemyItem(itemID))
  2476. return;
  2477.  
  2478.  
  2479. currLevel = (int)CalculateAttributeValue(inv.GetItemAttributeValue(itemID, 'level'));
  2480.  
  2481.  
  2482. if(currLevel == 3 || currLevel == 2 || currLevel < 2 || currLevel > 3)
  2483. return;
  2484.  
  2485.  
  2486. currAbilities = inv.GetItemAbilitiesWithAttribute(itemID, 'level', currLevel);
  2487.  
  2488.  
  2489. inv.GetItemContainedAbilities(itemID, abs);
  2490. dm = theGame.GetDefinitionsManager();
  2491. for(j=0; j<abs.Size(); j+=1)
  2492. {
  2493. dm.GetAbilityAttributeValue(abs[j], 'level', min, max);
  2494. otherLevel = (int)CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  2495. if( (otherLevel == 2 || otherLevel == 3) && otherLevel != currLevel)
  2496. otherAbilities.PushBack(abs[j]);
  2497. }
  2498.  
  2499.  
  2500. if(otherAbilities.Size() == 0)
  2501. {
  2502. LogAssert(false, "CR4Player.UpgradeAlchemyItem: cannot find ability to swap to from <<" + currAbilities[0] + ">> on item <<" + inv.GetItemName(itemID) + ">> !!!");
  2503. }
  2504. else
  2505. {
  2506. for(j=0; j<currAbilities.Size(); j+=1)
  2507. inv.RemoveItemBaseAbility(itemID, currAbilities[j]);
  2508.  
  2509. for(j=0; j<otherAbilities.Size(); j+=1)
  2510. inv.AddItemBaseAbility(itemID, otherAbilities[j]);
  2511. }
  2512. }
  2513.  
  2514.  
  2515.  
  2516.  
  2517.  
  2518. public function MovAdjRotateToTarget( ticket : SMovementAdjustmentRequestTicket )
  2519. {
  2520. var movementAdjustor : CMovementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  2521. var localOrientationTarget : EOrientationTarget = GetOrientationTarget();
  2522.  
  2523. if ( localOrientationTarget == OT_CustomHeading )
  2524. {
  2525. movementAdjustor.RotateTo( ticket, GetOrientationTargetCustomHeading() );
  2526. }
  2527. else if ( localOrientationTarget == OT_Actor )
  2528. {
  2529. if ( slideTarget )
  2530. movementAdjustor.RotateTowards( ticket, slideTarget );
  2531. else if ( lAxisReleasedAfterCounter )
  2532. movementAdjustor.RotateTo( ticket, GetHeading() );
  2533. else
  2534. movementAdjustor.RotateTo( ticket, GetCombatActionHeading() );
  2535. }
  2536. else if ( localOrientationTarget == OT_Player )
  2537. {
  2538. if ( bLAxisReleased )
  2539. movementAdjustor.RotateTo( ticket, GetHeading() );
  2540. else
  2541. movementAdjustor.RotateTo( ticket, rawPlayerHeading );
  2542. }
  2543. else if ( localOrientationTarget == OT_CameraOffset )
  2544. {
  2545.  
  2546. movementAdjustor.RotateTo( ticket, VecHeading( theCamera.GetCameraDirection() ) );
  2547. }
  2548. else
  2549. {
  2550.  
  2551. movementAdjustor.RotateTo( ticket, rawCameraHeading );
  2552. }
  2553.  
  2554. }
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560. public function UpdateLookAtTarget()
  2561. {
  2562. var localOrientationTarget : EOrientationTarget;
  2563. var playerRot : EulerAngles;
  2564. var lookAtActive : Float;
  2565. var lookAtTarget : Vector;
  2566. var headBoneIdx : int;
  2567. var tempComponent : CDrawableComponent;
  2568. var entityHeight : float;
  2569. var useTorsoBone : bool;
  2570.  
  2571. var angles : EulerAngles;
  2572. var dir : Vector;
  2573. var camZ : float;
  2574.  
  2575. var target : CActor;
  2576.  
  2577. lookAtActive = 0.0f;
  2578.  
  2579. localOrientationTarget = GetOrientationTarget();
  2580.  
  2581. if ( localOrientationTarget == OT_Player || localOrientationTarget == OT_CustomHeading )
  2582. {
  2583.  
  2584.  
  2585.  
  2586.  
  2587. if ( localOrientationTarget == OT_Player )
  2588. angles = VecToRotation( GetHeadingVector() );
  2589. else if ( customOrientationInfoStack.Size() > 0 )
  2590. angles = VecToRotation( VecFromHeading( customOrientationInfoStack[ customOrientationInfoStack.Size() - 1 ].customHeading ) );
  2591. else
  2592. angles = VecToRotation( GetHeadingVector() );
  2593.  
  2594.  
  2595. dir = RotForward( angles );
  2596. lookAtTarget = dir * 30.f + this.GetWorldPosition();
  2597. lookAtTarget.Z += 1.6f;
  2598. lookAtActive = 1.0f;
  2599. }
  2600. else if ( localOrientationTarget == OT_Camera )
  2601. {
  2602. headBoneIdx = GetHeadBoneIndex();
  2603. if ( headBoneIdx >= 0 )
  2604. {
  2605. lookAtTarget = MatrixGetTranslation( GetBoneWorldMatrixByIndex( headBoneIdx ) );
  2606. }
  2607. else
  2608. {
  2609. lookAtTarget = GetWorldPosition();
  2610. lookAtTarget.Z += 1.6f;
  2611. }
  2612. lookAtTarget += theCamera.GetCameraDirection() * 100.f;
  2613. lookAtActive = 1.0f;
  2614. }
  2615. else if ( localOrientationTarget == OT_CameraOffset )
  2616. {
  2617.  
  2618.  
  2619. dir = theCamera.GetCameraDirection();
  2620. angles = VecToRotation( dir );
  2621. angles.Pitch = -angles.Pitch + oTCameraPitchOffset;
  2622. angles.Yaw -= oTCameraOffset;
  2623. dir = RotForward( angles );
  2624.  
  2625. lookAtTarget = dir * 30.f + this.GetWorldPosition();
  2626. lookAtTarget.Z += 1.6f;
  2627. lookAtActive = 1.0f;
  2628. }
  2629. else if ( localOrientationTarget == OT_Actor )
  2630. {
  2631. if ( IsInCombatAction() )
  2632. {
  2633. if ( ( ( ( W3PlayerWitcher )this ).GetCurrentlyCastSign() != ST_None && GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign )
  2634. || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_ItemThrow )
  2635.  
  2636. useTorsoBone = true;
  2637. }
  2638.  
  2639. if ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  2640. useTorsoBone = true;
  2641.  
  2642. if ( tempLookAtTarget && (CActor)(tempLookAtTarget) )
  2643. {
  2644. lookAtTarget = ProcessLookAtTargetPosition( tempLookAtTarget, useTorsoBone );
  2645. lookAtActive = 1.0f;
  2646. }
  2647.  
  2648. if ( GetDisplayTarget() && IsDisplayTargetTargetable() )
  2649. {
  2650. lookAtTarget = ProcessLookAtTargetPosition( GetDisplayTarget(), useTorsoBone );
  2651. lookAtActive = 1.0f;
  2652. }
  2653. else
  2654. {
  2655.  
  2656.  
  2657. if ( slideTarget )
  2658. {
  2659. lookAtTarget = ProcessLookAtTargetPosition( slideTarget, useTorsoBone );
  2660. }
  2661. else
  2662. {
  2663. target = GetTarget();
  2664. if ( target )
  2665. {
  2666. lookAtTarget = ProcessLookAtTargetPosition( target, useTorsoBone );
  2667. }
  2668. }
  2669.  
  2670. lookAtActive = 1.0f;
  2671. }
  2672.  
  2673. if ( !slideTarget && !IsUsingVehicle() )
  2674. {
  2675.  
  2676. playerRot = GetWorldRotation();
  2677. lookAtTarget = GetWorldPosition() + VecFromHeading( playerRot.Yaw ) * 100.0f;
  2678. lookAtActive = 0.0f;
  2679. }
  2680.  
  2681. if ( useTorsoBone )
  2682. lookAtTarget.Z += 0.2f;
  2683. }
  2684.  
  2685.  
  2686.  
  2687.  
  2688. GetVisualDebug().AddSphere('lookAtTarget', 1.f, lookAtTarget, true, Color(255,0,0), 3.0f );
  2689. SetLookAtPosition( lookAtTarget );
  2690. UpdateLookAtVariables( lookAtActive, lookAtTarget );
  2691. }
  2692.  
  2693. private function ProcessLookAtTargetPosition( ent : CGameplayEntity, useTorsoBone : bool ) : Vector
  2694. {
  2695. var boneIdx : int;
  2696. var actor : CActor;
  2697. var lookAtTarget : Vector;
  2698. var tempComponent : CDrawableComponent;
  2699. var box : Box;
  2700. var entityHeight : float;
  2701. var entityPos : Vector;
  2702. var predictedPos : Vector;
  2703. var z : float;
  2704. var entMat : Matrix;
  2705.  
  2706. actor = (CActor)(ent);
  2707. entityPos = ent.GetWorldPosition();
  2708. lookAtTarget = entityPos;
  2709.  
  2710. if ( actor )
  2711. {
  2712. if ( useTorsoBone )
  2713. boneIdx = actor.GetTorsoBoneIndex();
  2714. else
  2715. boneIdx = actor.GetHeadBoneIndex();
  2716. }
  2717. else
  2718. boneIdx = -1;
  2719.  
  2720. if ( !( ent.aimVector.X == 0 && ent.aimVector.Y == 0 && ent.aimVector.Z == 0 ) )
  2721. {
  2722. entMat = ent.GetLocalToWorld();
  2723. lookAtTarget = VecTransform( entMat, ent.aimVector );
  2724. }
  2725. else if ( boneIdx >= 0 )
  2726. {
  2727. lookAtTarget = MatrixGetTranslation( ent.GetBoneWorldMatrixByIndex( boneIdx ) );
  2728. }
  2729. else
  2730. {
  2731. if ( actor )
  2732. lookAtTarget.Z += ( ((CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent()).GetCapsuleHeight() * 0.5 );
  2733. else
  2734. {
  2735. tempComponent = (CDrawableComponent)( ent.GetComponentByClassName('CDrawableComponent') );
  2736. if ( tempComponent.GetObjectBoundingVolume( box ) )
  2737. {
  2738. entityHeight = box.Max.Z - box.Min.Z;
  2739. lookAtTarget = lookAtTarget + Vector(0,0,entityHeight/2);
  2740. }
  2741. }
  2742. }
  2743. z = ((CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent()).GetCapsuleHeight();
  2744. if ( actor )
  2745. {
  2746. if ( PredictLookAtTargetPosition( actor, lookAtTarget.Z - entityPos.Z, predictedPos ) )
  2747. lookAtTarget = predictedPos;
  2748. }
  2749.  
  2750. return lookAtTarget;
  2751. }
  2752.  
  2753.  
  2754. private function PredictLookAtTargetPosition( targetActor : CActor, zOffSet : float, out predictedPos : Vector ) : bool
  2755. {
  2756. var virtualPos : Vector;
  2757. var i : int;
  2758. var dist : float;
  2759. var deltaTime : float;
  2760. var projSpeed : float;
  2761. var projSpeedInt : Vector;
  2762. var projAngle : float;
  2763.  
  2764. var e3Hack : bool;
  2765. var currentTimeInCurve : float;
  2766. e3Hack = false;
  2767.  
  2768. if ( rangedWeapon
  2769. && rangedWeapon.GetDeployedEntity()
  2770. && ( rangedWeapon.GetCurrentStateName() == 'State_WeaponAim' || rangedWeapon.GetCurrentStateName() == 'State_WeaponShoot' ) )
  2771. {
  2772. projSpeed = rangedWeapon.GetDeployedEntity().projSpeed;
  2773.  
  2774. virtualPos = targetActor.GetWorldPosition();
  2775.  
  2776. if ( e3Hack && targetActor.HasTag( 'e3_griffin' ) )
  2777. {
  2778. for ( i = 0; i < 10; i += 1 )
  2779. {
  2780. dist = VecDistance( rangedWeapon.GetDeployedEntity().GetWorldPosition(), virtualPos );
  2781. deltaTime = dist/projSpeed;
  2782. virtualPos = targetActor.PredictWorldPosition( deltaTime );
  2783. }
  2784. }
  2785. else
  2786. return false;
  2787.  
  2788. virtualPos.Z += zOffSet;
  2789. predictedPos = virtualPos;
  2790. GetVisualDebug().AddSphere('CrossbowPredictedPos', 1.0f, virtualPos , true, Color(255,50,50), 5.0f );
  2791. return true;
  2792. }
  2793. return false;
  2794. }
  2795.  
  2796. public function SetLookAtPosition( vec : Vector )
  2797. {
  2798. lookAtPosition = vec;
  2799. }
  2800.  
  2801. public function GetLookAtPosition() : Vector
  2802. {
  2803. return lookAtPosition;
  2804. }
  2805.  
  2806.  
  2807.  
  2808.  
  2809.  
  2810. event OnBlockingSceneEnded( optional output : CStorySceneOutput)
  2811. {
  2812.  
  2813. SetImmortalityMode( AIM_None, AIC_SyncedAnim );
  2814. super.OnBlockingSceneEnded(output);
  2815. }
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821. function GetCurrentMeleeWeaponName() : name
  2822. {
  2823. return weaponHolster.GetCurrentMeleeWeaponName();
  2824. }
  2825.  
  2826. public function GetCurrentMeleeWeaponType() : EPlayerWeapon
  2827. {
  2828. return weaponHolster.GetCurrentMeleeWeapon();
  2829. }
  2830.  
  2831. public function OnMeleeForceHolster(ignoreActionLock : bool)
  2832. {
  2833. weaponHolster.HolsterWeapon(ignoreActionLock, true);
  2834. }
  2835.  
  2836. event OnForcedHolsterWeapon()
  2837. {
  2838. weaponHolster.OnForcedHolsterWeapon();
  2839. }
  2840.  
  2841. event OnEquippedItem( category : name, slotName : name )
  2842. {
  2843. var weaponType : EPlayerWeapon;
  2844.  
  2845. if ( slotName == 'r_weapon' )
  2846. {
  2847. switch ( category )
  2848. {
  2849. case 'None' :
  2850. weaponType = PW_None;
  2851. break;
  2852. case 'fist' :
  2853. weaponType = PW_Fists;
  2854. break;
  2855. case 'steelsword' :
  2856. weaponType = PW_Steel;
  2857. break;
  2858. case 'silversword' :
  2859. weaponType = PW_Silver;
  2860. break;
  2861. default :
  2862. return true;
  2863. }
  2864.  
  2865. weaponHolster.OnEquippedMeleeWeapon( weaponType );
  2866. }
  2867. }
  2868.  
  2869. private var isHoldingDeadlySword : bool;
  2870. public function ProcessIsHoldingDeadlySword()
  2871. {
  2872. isHoldingDeadlySword = IsDeadlySwordHeld();
  2873. }
  2874.  
  2875. public function IsHoldingDeadlySword() : bool
  2876. {
  2877. return isHoldingDeadlySword;
  2878. }
  2879.  
  2880. event OnHolsteredItem( category : name, slotName : name )
  2881. {
  2882. var weaponType : EPlayerWeapon;
  2883.  
  2884.  
  2885. if ( slotName == 'r_weapon' && (category == 'steelsword' || category == 'silversword') )
  2886. {
  2887. if( category == 'silversword' )
  2888. {
  2889. ManageAerondightBuff( false );
  2890. }
  2891.  
  2892. GetBuff( EET_LynxSetBonus ).Pause( 'drawing weapon' );
  2893.  
  2894. PauseOilBuffs( category == 'steelsword' );
  2895. }
  2896.  
  2897. if ( slotName == 'r_weapon' )
  2898. {
  2899. weaponType = weaponHolster.GetCurrentMeleeWeapon();
  2900. switch ( category )
  2901. {
  2902. case 'fist' :
  2903. if ( weaponType == PW_Fists )
  2904. weaponHolster.OnEquippedMeleeWeapon( PW_None );
  2905. return true;
  2906. case 'steelsword' :
  2907. if ( weaponType == PW_Steel )
  2908. weaponHolster.OnEquippedMeleeWeapon( PW_None );
  2909. return true;
  2910. case 'silversword' :
  2911. if ( weaponType == PW_Silver )
  2912. weaponHolster.OnEquippedMeleeWeapon( PW_None );
  2913. return true;
  2914. default :
  2915. return true;
  2916. }
  2917. }
  2918. }
  2919.  
  2920. event OnEquipMeleeWeapon( weaponType : EPlayerWeapon, ignoreActionLock : bool, optional sheatheIfAlreadyEquipped : bool )
  2921. {
  2922. RemoveTimer( 'DelayedSheathSword' );
  2923.  
  2924. weaponHolster.OnEquipMeleeWeapon( weaponType, ignoreActionLock, sheatheIfAlreadyEquipped );
  2925.  
  2926.  
  2927.  
  2928. m_RefreshWeaponFXType = true;
  2929. }
  2930.  
  2931. event OnHolsterLeftHandItem()
  2932. {
  2933. weaponHolster.OnHolsterLeftHandItem();
  2934. }
  2935.  
  2936. timer function DelayedTryToReequipWeapon( dt: float, id : int )
  2937. {
  2938. var weaponType : EPlayerWeapon;
  2939.  
  2940. if( IsInCombat() && GetTarget() )
  2941. {
  2942. weaponType = GetMostConvenientMeleeWeapon( GetTarget() );
  2943.  
  2944. if ( weaponType == PW_Steel || weaponType == PW_Silver )
  2945. weaponHolster.OnEquipMeleeWeapon( weaponType, false );
  2946. }
  2947. }
  2948.  
  2949. timer function DelayedSheathSword( dt: float, id : int )
  2950. {
  2951. if ( !IsCombatMusicEnabled() )
  2952. {
  2953. if ( IsInCombatAction() || !IsActionAllowed( EIAB_DrawWeapon ) )
  2954. {
  2955. LogChannel( 'OnCombatFinished', "DelayedSheathSword: Sheath pushed to buffer" );
  2956. PushCombatActionOnBuffer(EBAT_Sheathe_Sword,BS_Pressed);
  2957. }
  2958. else
  2959. {
  2960. LogChannel( 'OnCombatFinished', "DelayedSheathSword: Sheath successful" );
  2961. OnEquipMeleeWeapon( PW_None, false );
  2962. }
  2963. }
  2964. }
  2965.  
  2966. protected function ShouldAutoSheathSwordInstantly() : bool
  2967. {
  2968. var enemies : array<CActor>;
  2969. var i : int;
  2970.  
  2971. GetEnemiesInRange( enemies );
  2972.  
  2973. for ( i = 0; i < enemies.Size(); i += 1 )
  2974. {
  2975. if ( IsThreat( enemies[i] ) &&
  2976. VecDistance( enemies[i].GetWorldPosition(), this.GetWorldPosition() ) <= findMoveTargetDist )
  2977. {
  2978. return false;
  2979. }
  2980. }
  2981.  
  2982. return true;
  2983. }
  2984.  
  2985. public function PrepareToAttack( optional target : CActor, optional action : EBufferActionType )
  2986. {
  2987. var weaponType : EPlayerWeapon;
  2988.  
  2989. if( IsInAir() || !GetBIsCombatActionAllowed() )
  2990. {
  2991. return ;
  2992. }
  2993.  
  2994. if( !target )
  2995. {
  2996. target = (CActor)displayTarget;
  2997. }
  2998. if( !target && IsCombatMusicEnabled() )
  2999. {
  3000. target = moveTarget;
  3001. }
  3002. if( !target )
  3003. {
  3004. if ( this.GetCurrentStateName() == 'Exploration' )
  3005. {
  3006. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  3007. thePlayer.CanAttackWhenNotInCombat( action, false, target );
  3008. }
  3009. }
  3010.  
  3011. weaponHolster.TryToPrepareMeleeWeaponToAttack();
  3012.  
  3013.  
  3014. {
  3015. weaponType = GetCurrentMeleeWeaponType();
  3016.  
  3017. if ( weaponType == PW_None )
  3018. {
  3019.  
  3020. weaponType = GetMostConvenientMeleeWeapon( target );
  3021. }
  3022.  
  3023.  
  3024. if( !OnStateCanGoToCombat() )
  3025. {
  3026. return;
  3027. }
  3028.  
  3029. GoToCombat( weaponType );
  3030. }
  3031. }
  3032.  
  3033. public function DisplayCannotAttackMessage( actor : CActor ) : bool
  3034. {
  3035. if ( actor && ( actor.GetMovingAgentComponent().GetName() == "child_base" || ((CNewNPC)actor).GetNPCType() == ENGT_Quest ) )
  3036. {
  3037. DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_cant_attack_this_target"));
  3038. return true;
  3039. }
  3040.  
  3041. return false;
  3042. }
  3043.  
  3044. public function GetMostConvenientMeleeWeapon( targetToDrawAgainst : CActor, optional ignoreActionLock : bool ) : EPlayerWeapon
  3045. {
  3046. return weaponHolster.GetMostConvenientMeleeWeapon( targetToDrawAgainst, ignoreActionLock );
  3047. }
  3048.  
  3049. private var reevaluateCurrentWeapon : bool;
  3050.  
  3051. event OnTargetWeaponDrawn()
  3052. {
  3053. var weaponType : EPlayerWeapon = this.GetCurrentMeleeWeaponType();
  3054. if ( weaponType == PW_Fists )
  3055. reevaluateCurrentWeapon = true;
  3056. }
  3057.  
  3058. public function GoToCombatIfNeeded( optional enemy : CActor ) : bool
  3059. {
  3060. var weaponType : EPlayerWeapon;
  3061. var target : CActor;
  3062.  
  3063. if( !enemy && IsInCombat() )
  3064. {
  3065. target = GetTarget();
  3066.  
  3067. if ( target )
  3068. enemy = target;
  3069. else
  3070. enemy = moveTarget;
  3071. }
  3072.  
  3073.  
  3074. if( !ShouldGoToCombat( enemy ) )
  3075. {
  3076. return false;
  3077. }
  3078.  
  3079. weaponType = this.GetCurrentMeleeWeaponType();
  3080.  
  3081. if ( weaponType == PW_None || ( reevaluateCurrentWeapon && weaponType == PW_Fists ) || ( !IsInCombat() && weaponHolster.IsOnTheMiddleOfHolstering() ) )
  3082. {
  3083.  
  3084. weaponType = weaponHolster.GetMostConvenientMeleeWeapon( enemy );
  3085. reevaluateCurrentWeapon = false;
  3086. }
  3087.  
  3088.  
  3089. GoToCombat( weaponType );
  3090.  
  3091.  
  3092. return true;
  3093. }
  3094.  
  3095. public function GoToCombatIfWanted( ) : bool
  3096. {
  3097. var weaponType : EPlayerWeapon;
  3098. var target : CActor;
  3099. var enemy : CActor;
  3100.  
  3101.  
  3102. if( !IsInCombat() )
  3103. {
  3104. return false;
  3105. }
  3106.  
  3107. target = GetTarget();
  3108.  
  3109. if ( target )
  3110. enemy = target;
  3111. else
  3112. enemy = moveTarget;
  3113.  
  3114. weaponType = this.GetCurrentMeleeWeaponType();
  3115.  
  3116. if ( weaponType == PW_None || ( !IsInCombat() && weaponHolster.IsOnTheMiddleOfHolstering() ) )
  3117. {
  3118.  
  3119. weaponType = weaponHolster.GetMostConvenientMeleeWeapon( enemy );
  3120. }
  3121.  
  3122.  
  3123. GoToCombat( weaponType );
  3124.  
  3125.  
  3126. return true;
  3127. }
  3128.  
  3129. public function GoToExplorationIfNeeded() : bool
  3130. {
  3131.  
  3132.  
  3133. if( ! IsInCombatState() )
  3134. {
  3135. return false;
  3136. }
  3137.  
  3138. if( !ShouldGoToExploration() )
  3139. {
  3140. return false;
  3141. }
  3142.  
  3143.  
  3144. weaponHolster.EndedCombat();
  3145.  
  3146.  
  3147. GotoState( 'Exploration' );
  3148. return true;
  3149. }
  3150.  
  3151. event OnStateCanGoToCombat()
  3152. {
  3153. return false;
  3154. }
  3155.  
  3156. event OnStateCanUpdateExplorationSubstates()
  3157. {
  3158. return false;
  3159. }
  3160.  
  3161. private function ShouldGoToCombat( optional enemy : CActor ) : bool
  3162. {
  3163. var currentStateName : name;
  3164.  
  3165.  
  3166. if( !OnStateCanGoToCombat() )
  3167. {
  3168. return false;
  3169. }
  3170.  
  3171. currentStateName = GetCurrentStateName();
  3172.  
  3173. if( currentStateName == 'AimThrow' )
  3174. {
  3175. return false;
  3176. }
  3177.  
  3178. if( currentStateName == 'Swimming' )
  3179. {
  3180. return false;
  3181. }
  3182.  
  3183. if( currentStateName == 'TraverseExploration' )
  3184. {
  3185. return false;
  3186. }
  3187.  
  3188.  
  3189.  
  3190.  
  3191.  
  3192.  
  3193. if ( !enemy )
  3194. {
  3195. return playerMode.combatMode;
  3196. }
  3197.  
  3198.  
  3199.  
  3200.  
  3201.  
  3202. return true;
  3203. }
  3204.  
  3205. private function ShouldGoToExploration() : bool
  3206. {
  3207. if ( IsInCombat() )
  3208. {
  3209. return false;
  3210. }
  3211.  
  3212. if ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  3213. {
  3214. return false;
  3215. }
  3216. if( IsFistFightMinigameEnabled() )
  3217. {
  3218. return false;
  3219. }
  3220. if( IsKnockedUnconscious() )
  3221. {
  3222. return false;
  3223. }
  3224. if( IsInCombatAction() )
  3225. {
  3226. return false;
  3227. }
  3228. if( GetCriticalBuffsCount() > 0 )
  3229. {
  3230. return false;
  3231. }
  3232.  
  3233. return true;
  3234. }
  3235.  
  3236. private function GoToCombat( weaponType : EPlayerWeapon, optional initialAction : EInitialAction )
  3237. {
  3238.  
  3239. switch( weaponType )
  3240. {
  3241. case PW_Silver:
  3242. ((W3PlayerWitcherStateCombatSilver) GetState('CombatSilver')).SetupState( initialAction );
  3243. GoToStateIfNew( 'CombatSilver' );
  3244. break;
  3245. case PW_Steel:
  3246. ((W3PlayerWitcherStateCombatSteel) GetState('CombatSteel')).SetupState( initialAction );
  3247. GoToStateIfNew( 'CombatSteel' );
  3248. break;
  3249. case PW_Fists:
  3250. case PW_None:
  3251. default :
  3252. ((W3PlayerWitcherStateCombatFists) GetState('CombatFists')).SetupState( initialAction );
  3253. GoToStateIfNew( 'CombatFists' );
  3254. break;
  3255. }
  3256. }
  3257.  
  3258. public function GoToStateIfNew( newState : name, optional keepStack : bool, optional forceEvents : bool )
  3259. {
  3260. if( newState != GetCurrentStateName() )
  3261. {
  3262. GotoState( newState, keepStack, forceEvents );
  3263. }
  3264. }
  3265.  
  3266.  
  3267. public function GotoState( newState : name, optional keepStack : bool, optional forceEvents : bool )
  3268. {
  3269.  
  3270.  
  3271. super.GotoState( newState, keepStack, forceEvents );
  3272.  
  3273. }
  3274.  
  3275. public function IsThisACombatSuperState( stateName : name ) : bool
  3276. {
  3277. return stateName == 'Combat' || stateName == 'CombatSteel' || stateName == 'CombatSilver' || stateName == 'CombatFists';
  3278. }
  3279.  
  3280. public function GetWeaponHolster() : WeaponHolster
  3281. {
  3282. return weaponHolster;
  3283. }
  3284.  
  3285. public function AbortSign()
  3286. {
  3287. var playerWitcher : W3PlayerWitcher;
  3288. var sign : W3SignEntity;
  3289.  
  3290. playerWitcher = (W3PlayerWitcher)this;
  3291.  
  3292. if(playerWitcher)
  3293. {
  3294. sign = (W3SignEntity)playerWitcher.GetCurrentSignEntity();
  3295. if (sign)
  3296. {
  3297. sign.OnSignAborted();
  3298. }
  3299. }
  3300. }
  3301.  
  3302.  
  3303.  
  3304.  
  3305. protected var disableActionBlend : bool;
  3306.  
  3307.  
  3308.  
  3309.  
  3310. event OnAnimEvent_DisallowHitAnim( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3311. {
  3312. if ( animEventType == AET_DurationEnd )
  3313. {
  3314. if ( ( BufferCombatAction == EBAT_Dodge || BufferCombatAction == EBAT_Roll )
  3315. && IsInCombatAction()
  3316. && GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
  3317. {
  3318.  
  3319. ( (CR4Player)this ).ProcessCombatActionBuffer();
  3320. disableActionBlend = true;
  3321. }
  3322. }
  3323. else if ( IsInCombatAction() && GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Dodge && animEventType == AET_DurationStart )
  3324. {
  3325. disableActionBlend = false;
  3326. }
  3327.  
  3328. super.OnAnimEvent_DisallowHitAnim( animEventName, animEventType, animInfo );
  3329. }
  3330.  
  3331.  
  3332. event OnAnimEvent_FadeOut( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3333. {
  3334. theGame.FadeOutAsync( 0.2, Color( 0, 0, 0, 1 ) );
  3335. }
  3336.  
  3337. event OnAnimEvent_FadeIn( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3338. {
  3339. theGame.FadeInAsync( 0.4 );
  3340. }
  3341.  
  3342. event OnAnimEvent_BloodTrailForced( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3343. {
  3344. var bloodTrailParam : CBloodTrailEffect;
  3345. var weaponId : SItemUniqueId;
  3346.  
  3347. if ( isInFinisher )
  3348. {
  3349. bloodTrailParam = (CBloodTrailEffect)(GetFinisherVictim()).GetGameplayEntityParam( 'CBloodTrailEffect' );
  3350. weaponId = this.inv.GetItemFromSlot('r_weapon');
  3351. if ( bloodTrailParam )
  3352. thePlayer.inv.PlayItemEffect( weaponId, bloodTrailParam.GetEffectName() );
  3353. }
  3354. }
  3355.  
  3356. event OnAnimEvent_SlowMo( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3357. {
  3358. if ( isInFinisher && DisableManualCameraControlStackHasSource( 'Finisher' ) )
  3359. {
  3360. if( animEventType != AET_DurationEnd )
  3361. theGame.SetTimeScale( 0.1f, 'AnimEventSlomoMo', 1000, true );
  3362. else
  3363. theGame.RemoveTimeScale( 'AnimEventSlomoMo' );
  3364. }
  3365. }
  3366.  
  3367. event OnAnimEvent_PlayFinisherBlood( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3368. {
  3369. if ( isInFinisher )
  3370. {
  3371. SpawnFinisherBlood();
  3372. }
  3373. }
  3374.  
  3375. event OnAnimEvent_OnWeaponDrawReady( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3376. {
  3377. weaponHolster.OnWeaponDrawReady();
  3378. }
  3379.  
  3380. event OnAnimEvent_OnWeaponHolsterReady( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3381. {
  3382. weaponHolster.OnWeaponHolsterReady();
  3383. }
  3384.  
  3385. event OnAnimEvent_ThrowHoldTest( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3386. {
  3387. var thrownEntity : CThrowable;
  3388.  
  3389. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  3390.  
  3391. if( IsThrowHold() )
  3392. {
  3393. SetBehaviorVariable( 'throwStage', (int)TS_Loop );
  3394. PushState( 'AimThrow' );
  3395. thrownEntity.StartAiming();
  3396. }
  3397. else
  3398. {
  3399. BombThrowRelease();
  3400. SetCombatIdleStance( 1.f );
  3401. }
  3402. }
  3403.  
  3404. event OnAnimEvent_AllowTempLookAt( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3405. {
  3406. if( animEventType == AET_DurationStart )
  3407. SetTempLookAtTarget( slideTarget );
  3408. else if( animEventType == AET_DurationEnd )
  3409. SetTempLookAtTarget( NULL );
  3410. }
  3411.  
  3412. protected var slideNPC : CNewNPC;
  3413. protected var minSlideDistance : float;
  3414. protected var maxSlideDistance : float;
  3415. protected var slideTicket : SMovementAdjustmentRequestTicket;
  3416.  
  3417. event OnAnimEvent_SlideToTarget( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3418. {
  3419. var movementAdjustor : CMovementAdjustor;
  3420.  
  3421. if( animEventType == AET_DurationStart )
  3422. {
  3423. slideNPC = (CNewNPC)slideTarget;
  3424. }
  3425.  
  3426. if( !slideNPC )
  3427. {
  3428. return false;
  3429. }
  3430.  
  3431. if( animEventType == AET_DurationStart && slideNPC.GetGameplayVisibility() )
  3432. {
  3433. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  3434. slideTicket = movementAdjustor.GetRequest( 'SlideToTarget' );
  3435. movementAdjustor.CancelByName( 'SlideToTarget' );
  3436. slideTicket = movementAdjustor.CreateNewRequest( 'SlideToTarget' );
  3437. movementAdjustor.BindToEventAnimInfo( slideTicket, animInfo );
  3438.  
  3439. movementAdjustor.MaxLocationAdjustmentSpeed( slideTicket, 1000000 );
  3440. movementAdjustor.ScaleAnimation( slideTicket );
  3441. minSlideDistance = ((CMovingPhysicalAgentComponent)this.GetMovingAgentComponent()).GetCapsuleRadius()+((CMovingPhysicalAgentComponent)slideNPC.GetMovingAgentComponent()).GetCapsuleRadius();
  3442. if( IsInCombatFist() )
  3443. {
  3444. maxSlideDistance = 1000.0f;
  3445. }
  3446. else
  3447. {
  3448. maxSlideDistance = minSlideDistance;
  3449. }
  3450. movementAdjustor.SlideTowards( slideTicket, slideTarget, minSlideDistance, maxSlideDistance );
  3451. }
  3452. else if( !slideNPC.GetGameplayVisibility() )
  3453. {
  3454. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  3455. movementAdjustor.CancelByName( 'SlideToTarget' );
  3456. slideNPC = NULL;
  3457. }
  3458. else
  3459. {
  3460. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  3461. movementAdjustor.SlideTowards( slideTicket, slideTarget, minSlideDistance, maxSlideDistance );
  3462. }
  3463. }
  3464.  
  3465. event OnAnimEvent_ActionBlend( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3466. {
  3467. }
  3468.  
  3469.  
  3470. event OnAnimEvent_SubstateManager( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3471. {
  3472.  
  3473. substateManager.OnAnimEvent( animEventName, animEventType, animInfo );
  3474. }
  3475.  
  3476. event OnAnimEvent_AllowFall( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3477. {
  3478. if ( !substateManager.m_OwnerMAC.IsOnGround() )
  3479. {
  3480. substateManager.m_SharedDataO.SetFallFromCritical( true );
  3481. substateManager.m_MoverO.SetVelocity( -6.0f * GetWorldForward() );
  3482. substateManager.QueueStateExternal( 'Jump' );
  3483. RemoveBuff( EET_Knockdown, true );
  3484. RemoveBuff( EET_HeavyKnockdown, true );
  3485. return true;
  3486. }
  3487. return false;
  3488. }
  3489.  
  3490. event OnAnimEvent_AllowFall2( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3491. {
  3492. if ( !substateManager.m_OwnerMAC.IsOnGround() )
  3493. {
  3494.  
  3495.  
  3496. substateManager.QueueStateExternal( 'Jump' );
  3497. RemoveBuff( EET_Knockdown, true );
  3498. RemoveBuff( EET_HeavyKnockdown, true );
  3499. }
  3500. if( substateManager.StateWantsAndCanEnter( 'Slide' ) )
  3501. {
  3502. substateManager.QueueStateExternal( 'Slide' );
  3503. }
  3504. }
  3505.  
  3506. event OnAnimEvent_DettachGround( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3507. {
  3508.  
  3509. }
  3510.  
  3511.  
  3512. event OnAnimEvent_pad_vibration( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3513. {
  3514. var witcher : W3PlayerWitcher;
  3515.  
  3516. theGame.VibrateControllerHard();
  3517.  
  3518.  
  3519. witcher = GetWitcherPlayer();
  3520. if(isInFinisher && witcher)
  3521. {
  3522. if(HasAbility('Runeword 10 _Stats', true) && !witcher.runeword10TriggerredOnFinisher && ((bool)theGame.GetInGameConfigWrapper().GetVarValue('Gameplay', 'AutomaticFinishersEnabled')) == true)
  3523. {
  3524. witcher.Runeword10Triggerred();
  3525. witcher.runeword10TriggerredOnFinisher = true;
  3526. }
  3527. else if(HasAbility('Runeword 12 _Stats', true) && !witcher.runeword12TriggerredOnFinisher)
  3528. {
  3529. witcher.Runeword12Triggerred();
  3530. witcher.runeword12TriggerredOnFinisher = true;
  3531. }
  3532. }
  3533. }
  3534.  
  3535.  
  3536. event OnAnimEvent_pad_vibration_light( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3537. {
  3538.  
  3539. }
  3540.  
  3541. event OnAnimEvent_KillWithRagdoll( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3542. {
  3543.  
  3544.  
  3545. }
  3546.  
  3547. event OnAnimEvent_RemoveBurning( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3548. {
  3549. thePlayer.AddBuffImmunity(EET_Burning, 'AnimEvent_RemoveBurning', true);
  3550. }
  3551.  
  3552. event OnAnimEvent_RemoveTangled( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3553. {
  3554. if ( this.HasBuff( EET_Tangled ) )
  3555. {
  3556. this.StopEffect('black_spider_web');
  3557. this.PlayEffectSingle('black_spider_web_break');
  3558. }
  3559. }
  3560.  
  3561.  
  3562. event OnAnimEvent_MoveNoise( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3563. {
  3564. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'MoveNoise', -1, 30.0f, -1.f, -1, true );
  3565. }
  3566.  
  3567.  
  3568. event OnBehaviorGraphNotification( notificationName : name, stateName : name )
  3569. {
  3570. substateManager.OnBehaviorGraphNotification( notificationName, stateName );
  3571.  
  3572. if( notificationName == 'PlayerRunActivate' )
  3573. {
  3574. isInRunAnimation = true;
  3575. }
  3576. else if( notificationName == 'PlayerRunDeactivate' )
  3577. {
  3578. isInRunAnimation = false;
  3579. }
  3580. }
  3581.  
  3582. event OnEnumAnimEvent( animEventName : name, variant : SEnumVariant, animEventType : EAnimationEventType, animEventDuration : float, animInfo : SAnimationEventAnimInfo )
  3583. {
  3584. var movementAdjustor : CMovementAdjustor;
  3585. var ticket : SMovementAdjustmentRequestTicket;
  3586. var rotationRate : ERotationRate;
  3587.  
  3588. if ( animEventName == 'RotateToTarget' )
  3589. {
  3590.  
  3591. rotationRate = GetRotationRateFromAnimEvent( variant.enumValue );
  3592.  
  3593. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  3594. if ( animEventType == AET_DurationStart || animEventType == AET_DurationStartInTheMiddle )
  3595. {
  3596.  
  3597.  
  3598. if (! movementAdjustor.IsRequestActive( movementAdjustor.GetRequest( 'RotateToTarget' ) ) )
  3599. {
  3600.  
  3601. ticket = movementAdjustor.CreateNewRequest( 'RotateToTarget' );
  3602.  
  3603.  
  3604. if ((int)rotationRate == 0)
  3605. movementAdjustor.AdjustmentDuration( ticket, animEventDuration );
  3606. else
  3607. {
  3608. movementAdjustor.Continuous( ticket );
  3609. movementAdjustor.BindToEvent( ticket, 'RotateToTarget' );
  3610. }
  3611.  
  3612. movementAdjustor.DontUseSourceAnimation( ticket );
  3613. movementAdjustor.ReplaceRotation( ticket );
  3614. }
  3615. else
  3616. {
  3617.  
  3618. ticket = movementAdjustor.GetRequest( 'RotateToTarget' );
  3619. }
  3620. MovAdjRotateToTarget( ticket );
  3621.  
  3622. if ((int)rotationRate > 0)
  3623. {
  3624. movementAdjustor.MaxRotationAdjustmentSpeed( ticket, (float)((int)rotationRate) );
  3625. }
  3626. }
  3627. else if ( animEventType == AET_DurationEnd )
  3628. {
  3629.  
  3630.  
  3631. }
  3632. else
  3633. {
  3634.  
  3635. ticket = movementAdjustor.GetRequest( 'RotateToTarget' );
  3636. MovAdjRotateToTarget( ticket );
  3637. }
  3638. }
  3639. super.OnEnumAnimEvent(animEventName, variant, animEventType, animEventDuration, animInfo);
  3640. }
  3641.  
  3642. event OnTeleported()
  3643. {
  3644. if( substateManager )
  3645. {
  3646. substateManager.OnTeleported();
  3647. }
  3648. }
  3649.  
  3650.  
  3651.  
  3652.  
  3653.  
  3654.  
  3655. event OnStartFistfightMinigame()
  3656. {
  3657. super.OnStartFistfightMinigame();
  3658.  
  3659.  
  3660. SetFistFightMinigameEnabled( true );
  3661. FistFightHealthChange( true );
  3662. thePlayer.GetPlayerMode().ForceCombatMode( FCMR_QuestFunction );
  3663. SetImmortalityMode(AIM_Unconscious, AIC_Fistfight);
  3664. thePlayer.SetBehaviorVariable( 'playerWeaponLatent', (int)PW_Fists );
  3665. GotoCombatStateWithAction( IA_None );
  3666. ((CMovingAgentComponent)this.GetMovingAgentComponent()).SnapToNavigableSpace( true );
  3667. EquipGeraltFistfightWeapon( true );
  3668. BlockAction( EIAB_RadialMenu, 'FistfightMinigame' ,,true);
  3669. BlockAction( EIAB_Signs, 'FistfightMinigame' ,,true);
  3670. BlockAction( EIAB_ThrowBomb, 'FistfightMinigame' ,,true);
  3671. BlockAction( EIAB_UsableItem, 'FistfightMinigame' ,,true);
  3672. BlockAction( EIAB_Crossbow, 'FistfightMinigame' ,,true);
  3673. BlockAction( EIAB_DrawWeapon, 'FistfightMinigame' ,,true);
  3674. BlockAction( EIAB_RunAndSprint, 'FistfightMinigame' ,,true);
  3675. BlockAction( EIAB_SwordAttack, 'FistfightMinigame' ,,true);
  3676. BlockAction( EIAB_CallHorse, 'FistfightMinigame' ,,true);
  3677. BlockAction( EIAB_Roll, 'FistfightMinigame' ,,true);
  3678. BlockAction( EIAB_Interactions, 'FistfightMinigame' ,,true);
  3679. BlockAction( EIAB_Explorations, 'FistfightMinigame' ,,true);
  3680. BlockAction( EIAB_OpenInventory, 'FistfightMinigame' ,,true);
  3681. BlockAction( EIAB_QuickSlots, 'FistfightMinigame' ,,true);
  3682. BlockAction( EIAB_OpenCharacterPanel, 'FistfightMinigame' ,,true);
  3683. }
  3684.  
  3685. event OnEndFistfightMinigame()
  3686. {
  3687. ((CMovingAgentComponent)this.GetMovingAgentComponent()).SnapToNavigableSpace( false );
  3688. FistFightHealthChange( false );
  3689. thePlayer.GetPlayerMode().ReleaseForceCombatMode( FCMR_QuestFunction );
  3690. EquipGeraltFistfightWeapon( false );
  3691. SetFistFightMinigameEnabled( false );
  3692. SetImmortalityMode(AIM_None, AIC_Fistfight);
  3693. BlockAllActions('FistfightMinigame',false);
  3694.  
  3695. super.OnEndFistfightMinigame();
  3696. }
  3697.  
  3698. public function GetFistFightFinisher( out masterAnimName, slaveAnimIndex : name )
  3699. {
  3700. var index : int;
  3701.  
  3702. index = RandRange(1);
  3703. switch ( index )
  3704. {
  3705. case 0 : masterAnimName = 'man_fistfight_finisher_1_win'; slaveAnimIndex = 'man_fistfight_finisher_1_looser';
  3706. }
  3707. }
  3708.  
  3709. public function SetFistFightMinigameEnabled( flag : bool )
  3710. {
  3711. fistFightMinigameEnabled = flag;
  3712. }
  3713.  
  3714. public function SetFistFightParams( toDeath : bool, endsWithBS : bool )
  3715. {
  3716. isFFMinigameToTheDeath = toDeath;
  3717. FFMinigameEndsithBS = endsWithBS;
  3718. }
  3719.  
  3720. public function IsFistFightMinigameEnabled() : bool
  3721. {
  3722. return fistFightMinigameEnabled;
  3723. }
  3724.  
  3725. public function IsFistFightMinigameToTheDeath() : bool
  3726. {
  3727. return isFFMinigameToTheDeath;
  3728. }
  3729.  
  3730. public function FistFightHealthChange( val : bool )
  3731. {
  3732. if( val == true )
  3733. {
  3734. GeraltMaxHealth = thePlayer.GetStatMax(BCS_Vitality);
  3735. ClampGeraltMaxHealth( 2000 );
  3736. SetHealthPerc( 100 );
  3737. }
  3738. else
  3739. {
  3740. ClampGeraltMaxHealth( GeraltMaxHealth );
  3741. SetHealthPerc( 100 );
  3742. }
  3743.  
  3744. }
  3745.  
  3746. function ClampGeraltMaxHealth( val : float )
  3747. {
  3748. thePlayer.abilityManager.SetStatPointMax( BCS_Vitality, val );
  3749. }
  3750.  
  3751. function EquipGeraltFistfightWeapon( val : bool )
  3752. {
  3753. if ( val )
  3754. {
  3755. fistsItems = thePlayer.GetInventory().AddAnItem( 'Geralt Fistfight Fists', 1, true, true );
  3756. thePlayer.GetInventory().MountItem( fistsItems[0] , true );
  3757. }
  3758. else
  3759. {
  3760. thePlayer.GetInventory().DropItem( fistsItems[0], true );
  3761. }
  3762. }
  3763.  
  3764.  
  3765.  
  3766.  
  3767. public function GetGwintAiDifficulty() : EGwintDifficultyMode
  3768. {
  3769. return gwintAiDifficulty;
  3770. }
  3771.  
  3772. public function SetGwintAiDifficulty( difficulty : EGwintDifficultyMode )
  3773. {
  3774. gwintAiDifficulty = difficulty;
  3775. }
  3776.  
  3777. public function GetGwintAiAggression() : EGwintAggressionMode
  3778. {
  3779. return gwintAiAggression;
  3780. }
  3781.  
  3782. public function SetGwintAiAggression( aggression : EGwintAggressionMode )
  3783. {
  3784. gwintAiAggression = aggression;
  3785. }
  3786.  
  3787. public function GetGwintMinigameState() : EMinigameState
  3788. {
  3789. return gwintMinigameState;
  3790. }
  3791.  
  3792. public function SetGwintMinigameState( minigameState : EMinigameState )
  3793. {
  3794. gwintMinigameState = minigameState;
  3795. }
  3796.  
  3797. public function OnGwintGameRequested( deckName : name, forceFaction : eGwintFaction )
  3798. {
  3799. var gwintManager:CR4GwintManager;
  3800. gwintManager = theGame.GetGwintManager();
  3801.  
  3802. gwintMinigameState = EMS_None;
  3803.  
  3804. gwintManager.SetEnemyDeckByName(deckName);
  3805. gwintManager.SetForcedFaction(forceFaction);
  3806.  
  3807. if (gwintManager.GetHasDoneTutorial() || !theGame.GetTutorialSystem().AreMessagesEnabled())
  3808. {
  3809. gwintManager.gameRequested = true;
  3810. theGame.RequestMenu( 'DeckBuilder' );
  3811. }
  3812. else
  3813. {
  3814. theGame.GetGuiManager().ShowUserDialog( UMID_SkipGwintTutorial, "gwint_tutorial_play_query_title", "gwint_tutorial_play_query", UDB_YesNo );
  3815. }
  3816. }
  3817.  
  3818. public function StartGwint_TutorialOrSkip( skipTutorial : bool )
  3819. {
  3820. var gwintManager : CR4GwintManager;
  3821.  
  3822. if( skipTutorial )
  3823. {
  3824. gwintManager = theGame.GetGwintManager();
  3825. gwintManager.gameRequested = true;
  3826. gwintManager.SetHasDoneTutorial(true);
  3827. gwintManager.SetHasDoneDeckTutorial(true);
  3828. theGame.RequestMenu( 'DeckBuilder' );
  3829. }
  3830. else
  3831. {
  3832. theGame.RequestMenu( 'GwintGame' );
  3833. }
  3834. }
  3835.  
  3836. private var gwintCardNumbersArray : array<int>;
  3837.  
  3838. public function InitGwintCardNumbersArray( arr : array<int> )
  3839. {
  3840. gwintCardNumbersArray.Clear();
  3841. gwintCardNumbersArray = arr;
  3842. }
  3843.  
  3844. public function GetCardNumbersArray() : array<int>
  3845. {
  3846. return gwintCardNumbersArray;
  3847. }
  3848.  
  3849.  
  3850.  
  3851.  
  3852. protected var customCameraStack : array<SCustomCameraParams>;
  3853.  
  3854. public function AddCustomCamToStack( customCameraParams : SCustomCameraParams ) : int
  3855. {
  3856. if( customCameraParams.useCustomCamera )
  3857. {
  3858. if ( customCameraParams.cameraParams.enums[0].enumType != 'ECustomCameraType' )
  3859. {
  3860. LogChannel( 'CustomCamera', "ERROR: Selected enum is not a custom camera!!!" );
  3861. return -1;
  3862. }
  3863. else
  3864. {
  3865. customCameraStack.PushBack( customCameraParams );
  3866. return ( customCameraStack.Size() - 1 );
  3867. }
  3868. }
  3869.  
  3870. return 0;
  3871. }
  3872.  
  3873. public function DisableCustomCamInStack( customCameraStackIndex : int )
  3874. {
  3875. if ( customCameraStackIndex != -1 )
  3876. customCameraStack[customCameraStackIndex].useCustomCamera = false;
  3877. else
  3878. LogChannel( 'CustomCamera', "ERROR: Custom camera to disable does not exist!!!" );
  3879. }
  3880.  
  3881. event OnInteriorStateChanged( inInterior : bool )
  3882. {
  3883. interiorCamera = inInterior;
  3884. }
  3885.  
  3886. event OnModifyPlayerSpeed( flag : bool )
  3887. {
  3888. modifyPlayerSpeed = flag;
  3889. SetBehaviorVariable( 'modifyPlayerSpeed', (float)modifyPlayerSpeed );
  3890. }
  3891.  
  3892. event OnGameCameraTick( out moveData : SCameraMovementData, dt : float )
  3893. {
  3894. var targetRotation : EulerAngles;
  3895. var dist : float;
  3896.  
  3897. if( thePlayer.IsInCombat() )
  3898. {
  3899. dist = VecDistance2D( thePlayer.GetWorldPosition(), thePlayer.GetTarget().GetWorldPosition() );
  3900. thePlayer.GetVisualDebug().AddText( 'dbg', dist, thePlayer.GetWorldPosition() + Vector( 0.f,0.f,2.f ), true, , Color( 0, 255, 0 ) );
  3901. }
  3902.  
  3903. if ( isStartingFistFightMinigame )
  3904. {
  3905. moveData.pivotRotationValue = fistFightTeleportNode.GetWorldRotation();
  3906. isStartingFistFightMinigame = false;
  3907. }
  3908.  
  3909.  
  3910. if( substateManager.UpdateCameraIfNeeded( moveData, dt ) )
  3911. {
  3912. return true;
  3913. }
  3914.  
  3915.  
  3916. if ( theGame.IsFocusModeActive() )
  3917. {
  3918. theGame.GetGameCamera().ChangePivotRotationController( 'Exploration' );
  3919. theGame.GetGameCamera().ChangePivotDistanceController( 'Default' );
  3920. theGame.GetGameCamera().ChangePivotPositionController( 'Default' );
  3921.  
  3922.  
  3923. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  3924. moveData.pivotDistanceController = theGame.GetGameCamera().GetActivePivotDistanceController();
  3925. moveData.pivotPositionController = theGame.GetGameCamera().GetActivePivotPositionController();
  3926.  
  3927.  
  3928.  
  3929. moveData.pivotPositionController.SetDesiredPosition( thePlayer.GetWorldPosition() );
  3930.  
  3931. moveData.pivotRotationController.SetDesiredPitch( -10.0f );
  3932. moveData.pivotRotationController.maxPitch = 50.0;
  3933.  
  3934. moveData.pivotDistanceController.SetDesiredDistance( 3.5f );
  3935.  
  3936. if ( !interiorCamera )
  3937. {
  3938. moveData.pivotPositionController.offsetZ = 1.5f;
  3939. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( 0.5f, 2.0f, 0.3f ), 0.20f, dt );
  3940. }
  3941. else
  3942. {
  3943. moveData.pivotPositionController.offsetZ = 1.3f;
  3944. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( 0.5f, 2.3f, 0.5f ), 0.3f, dt );
  3945. }
  3946.  
  3947. return true;
  3948. }
  3949.  
  3950.  
  3951.  
  3952.  
  3953. if( substateManager.m_SharedDataO.IsForceHeading( targetRotation ) )
  3954. {
  3955. moveData.pivotRotationController.SetDesiredHeading( targetRotation.Yaw );
  3956. moveData.pivotRotationController.SetDesiredPitch( targetRotation.Pitch );
  3957. moveData.pivotRotationValue.Yaw = LerpAngleF( 2.1f * dt, moveData.pivotRotationValue.Yaw, targetRotation.Yaw );
  3958. moveData.pivotRotationValue.Pitch = LerpAngleF( 1.0f * dt, moveData.pivotRotationValue.Pitch, targetRotation.Pitch );
  3959.  
  3960. }
  3961.  
  3962.  
  3963. if( customCameraStack.Size() > 0 )
  3964. {
  3965.  
  3966.  
  3967. }
  3968.  
  3969. return false;
  3970. }
  3971.  
  3972. private var questCameraRequest : SQuestCameraRequest;
  3973. private var cameraRequestTimeStamp : float;
  3974.  
  3975. public function RequestQuestCamera( camera : SQuestCameraRequest )
  3976. {
  3977. questCameraRequest = camera;
  3978. questCameraRequest.requestTimeStamp = theGame.GetEngineTimeAsSeconds();
  3979. }
  3980.  
  3981. public function ResetQuestCameraRequest()
  3982. {
  3983. var cameraRequest : SQuestCameraRequest;
  3984.  
  3985. questCameraRequest = cameraRequest;
  3986. }
  3987.  
  3988. event OnGameCameraPostTick( out moveData : SCameraMovementData, dt : float )
  3989. {
  3990. var ent : CEntity;
  3991. var playerPos : Vector;
  3992. var angles : EulerAngles;
  3993.  
  3994. var distance : float;
  3995.  
  3996.  
  3997.  
  3998. if ( questCameraRequest.requestTimeStamp > 0 )
  3999. {
  4000. if ( questCameraRequest.duration > 0 && questCameraRequest.requestTimeStamp + questCameraRequest.duration < theGame.GetEngineTimeAsSeconds() )
  4001. {
  4002. ResetQuestCameraRequest();
  4003. return false;
  4004. }
  4005.  
  4006. if( questCameraRequest.lookAtTag )
  4007. {
  4008. ent = theGame.GetEntityByTag( questCameraRequest.lookAtTag );
  4009. playerPos = GetWorldPosition();
  4010. playerPos.Z += 1.8f;
  4011.  
  4012. angles = VecToRotation( ent.GetWorldPosition() - playerPos );
  4013.  
  4014. moveData.pivotRotationController.SetDesiredHeading( angles.Yaw );
  4015. moveData.pivotRotationController.SetDesiredPitch( -angles.Pitch );
  4016. }
  4017. else
  4018. {
  4019. if( questCameraRequest.requestYaw )
  4020. {
  4021. angles = GetWorldRotation();
  4022. moveData.pivotRotationController.SetDesiredHeading( angles.Yaw + questCameraRequest.yaw );
  4023. }
  4024.  
  4025. if( questCameraRequest.requestPitch )
  4026. {
  4027. moveData.pivotRotationController.SetDesiredPitch( questCameraRequest.pitch );
  4028. }
  4029. }
  4030. }
  4031. }
  4032.  
  4033. var wasRunning : bool;
  4034. var vel : float;
  4035. var smoothTime : float;
  4036.  
  4037. var constDamper : ConstDamper;
  4038. var rotMultVel : float;
  4039.  
  4040. public function UpdateCameraInterior( out moveData : SCameraMovementData, timeDelta : float )
  4041. {
  4042. var camDist : float;
  4043. var camOffset : float;
  4044. var rotMultDest : float;
  4045. var rotMult : float;
  4046. var angles : EulerAngles;
  4047.  
  4048. theGame.GetGameCamera().ChangePivotRotationController( 'ExplorationInterior' );
  4049. theGame.GetGameCamera().ChangePivotDistanceController( 'Default' );
  4050. theGame.GetGameCamera().ChangePivotPositionController( 'Default' );
  4051.  
  4052.  
  4053. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  4054. moveData.pivotDistanceController = theGame.GetGameCamera().GetActivePivotDistanceController();
  4055. moveData.pivotPositionController = theGame.GetGameCamera().GetActivePivotPositionController();
  4056.  
  4057.  
  4058. moveData.pivotPositionController.SetDesiredPosition( GetWorldPosition(), 15.f );
  4059.  
  4060. if ( !constDamper )
  4061. {
  4062. constDamper = new ConstDamper in this;
  4063. constDamper.SetDamp( 0.35f );
  4064. }
  4065.  
  4066. if ( rawPlayerSpeed <= 0 || AbsF( AngleDistance( rawPlayerHeading, GetHeading() ) ) > 135 )
  4067. constDamper.Reset();
  4068. else if ( theGame.IsUberMovementEnabled() )
  4069. rotMult = 0.5f;
  4070. else
  4071. rotMult = 1.f;
  4072.  
  4073. rotMult = constDamper.UpdateAndGet( timeDelta, rotMult );
  4074.  
  4075.  
  4076.  
  4077. if ( AbsF( AngleDistance( GetHeading(), moveData.pivotRotationValue.Yaw ) ) < 135.f && rawPlayerSpeed > 0 )
  4078. moveData.pivotRotationController.SetDesiredHeading( GetHeading(), rotMult );
  4079. else
  4080. moveData.pivotRotationController.SetDesiredHeading( moveData.pivotRotationValue.Yaw );
  4081.  
  4082. moveData.pivotDistanceController.SetDesiredDistance( 1.5f );
  4083.  
  4084. angles = VecToRotation( GetMovingAgentComponent().GetVelocity() );
  4085. if ( AbsF( angles.Pitch ) < 8.f || bLAxisReleased )
  4086. moveData.pivotRotationController.SetDesiredPitch( -10.f );
  4087. else
  4088. moveData.pivotRotationController.SetDesiredPitch( -angles.Pitch - 18.f );
  4089.  
  4090. if ( IsGuarded() )
  4091. moveData.pivotPositionController.offsetZ = 1.0f;
  4092. else
  4093. moveData.pivotPositionController.offsetZ = 1.3f;
  4094.  
  4095.  
  4096.  
  4097. if ( playerMoveType >= PMT_Run )
  4098. {
  4099.  
  4100. camDist = -0.5f;
  4101. camOffset = 0.25;
  4102.  
  4103. if ( !wasRunning )
  4104. {
  4105. smoothTime = 1.f;
  4106. wasRunning = true;
  4107. }
  4108. DampFloatSpring( smoothTime, vel, 0.1, 0.5, timeDelta );
  4109. }
  4110. else
  4111. {
  4112.  
  4113. camDist = 0.f;
  4114. camOffset = 0.4f;
  4115. smoothTime = 0.2f;
  4116. wasRunning = false;
  4117. }
  4118.  
  4119.  
  4120.  
  4121. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( 0.3f, camDist, 0.3f ), smoothTime, timeDelta );
  4122.  
  4123.  
  4124.  
  4125.  
  4126.  
  4127. }
  4128.  
  4129.  
  4130. var wasBRAxisPushed : bool;
  4131. protected function UpdateCameraChanneledSign( out moveData : SCameraMovementData, timeDelta : float ) : bool
  4132. {
  4133. var screenSpaceOffset : float;
  4134. var screenSpaceOffsetFwd : float;
  4135. var screenSpaceOffsetUp : float;
  4136. var heading : float;
  4137. var pitch : float;
  4138. var playerToTargetRot : EulerAngles;
  4139. var rightOffset : float = -20.f;
  4140. var leftOffset : float = 15.f;
  4141. var angles : EulerAngles;
  4142.  
  4143. var vec : Vector;
  4144.  
  4145. if( this.IsCurrentSignChanneled() && this.GetCurrentlyCastSign() != ST_Quen && this.GetCurrentlyCastSign() != ST_Yrden )
  4146. {
  4147. theGame.GetGameCamera().ChangePivotRotationController( 'SignChannel' );
  4148. theGame.GetGameCamera().ChangePivotDistanceController( 'SignChannel' );
  4149.  
  4150. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  4151. moveData.pivotDistanceController = theGame.GetGameCamera().GetActivePivotDistanceController();
  4152.  
  4153.  
  4154. if ( GetCurrentlyCastSign() == ST_Axii )
  4155. leftOffset = 32.f;
  4156.  
  4157. if ( oTCameraOffset != leftOffset && oTCameraOffset != rightOffset )
  4158. {
  4159. if( ( interiorCamera && !moveTarget )
  4160. || ( AngleDistance( GetHeading(), moveData.pivotRotationValue.Yaw ) < 0 ) )
  4161. oTCameraOffset = leftOffset;
  4162. else
  4163. oTCameraOffset = rightOffset;
  4164. }
  4165.  
  4166. if ( oTCameraOffset == leftOffset )
  4167. {
  4168. screenSpaceOffset = 0.65f;
  4169. oTCameraPitchOffset = 13.f;
  4170.  
  4171. }
  4172. else if ( oTCameraOffset == rightOffset )
  4173. {
  4174. screenSpaceOffset = -0.65f;
  4175. oTCameraPitchOffset = 13.f;
  4176.  
  4177. }
  4178.  
  4179. moveData.pivotPositionController.offsetZ = 1.3f;
  4180.  
  4181. if ( !delayCameraOrientationChange )
  4182. {
  4183. if ( GetOrientationTarget() == OT_Camera || GetOrientationTarget() == OT_CameraOffset )
  4184. {
  4185. if ( bRAxisReleased )
  4186. {
  4187. heading = moveData.pivotRotationValue.Yaw;
  4188. pitch = moveData.pivotRotationValue.Pitch;
  4189. }
  4190. else
  4191. {
  4192. heading = moveData.pivotRotationValue.Yaw + oTCameraOffset;
  4193. pitch = moveData.pivotRotationValue.Pitch;
  4194. }
  4195. }
  4196. else if ( GetOrientationTarget() == OT_Actor )
  4197. {
  4198. if ( GetDisplayTarget() )
  4199. vec = GetDisplayTarget().GetWorldPosition() - GetWorldPosition();
  4200. else if ( slideTarget )
  4201. vec = slideTarget.GetWorldPosition() - GetWorldPosition();
  4202. else if ( GetTarget() )
  4203. vec = GetTarget().GetWorldPosition() - GetWorldPosition();
  4204. else
  4205. vec = GetHeadingVector();
  4206.  
  4207. angles = VecToRotation( vec );
  4208. heading = angles.Yaw + oTCameraOffset;
  4209. pitch = -angles.Pitch - oTCameraPitchOffset;
  4210. }
  4211. else
  4212. {
  4213. angles = VecToRotation( GetHeadingVector() );
  4214. heading = angles.Yaw + oTCameraOffset;
  4215. pitch = -angles.Pitch - oTCameraPitchOffset;
  4216. }
  4217.  
  4218. if ( !wasBRAxisPushed && ( !bRAxisReleased ) )
  4219. wasBRAxisPushed = true;
  4220.  
  4221. moveData.pivotRotationController.SetDesiredHeading( heading , 2.f );
  4222. moveData.pivotRotationController.SetDesiredPitch( pitch );
  4223. }
  4224. else
  4225. {
  4226. moveData.pivotRotationController.SetDesiredHeading( moveData.pivotRotationValue.Yaw, 1.f );
  4227. moveData.pivotRotationController.SetDesiredPitch( -oTCameraPitchOffset );
  4228. }
  4229.  
  4230. if ( moveData.pivotRotationValue.Pitch <= 5.f && moveData.pivotRotationValue.Pitch >= -15.f )
  4231. {
  4232. screenSpaceOffsetFwd = 1.8;
  4233. screenSpaceOffsetUp = 0.4;
  4234. }
  4235. else if ( moveData.pivotRotationValue.Pitch > 0 )
  4236. {
  4237. screenSpaceOffsetFwd = moveData.pivotRotationValue.Pitch*0.00727 + 1.275f;
  4238. screenSpaceOffsetFwd = ClampF( screenSpaceOffsetFwd, 1.5, 2.2 );
  4239.  
  4240. screenSpaceOffsetUp = -moveData.pivotRotationValue.Pitch*0.00727 + 0.4363f;
  4241. screenSpaceOffsetUp = ClampF( screenSpaceOffsetUp, 0, 0.3 );
  4242. }
  4243. else
  4244. {
  4245. if ( GetCurrentlyCastSign() == ST_Axii )
  4246. {
  4247. screenSpaceOffsetFwd = -moveData.pivotRotationValue.Pitch*0.0425 + 0.8625f;
  4248. screenSpaceOffsetFwd = ClampF( screenSpaceOffsetFwd, 1.5, 2.3 );
  4249. }
  4250. else
  4251. {
  4252. screenSpaceOffsetFwd = -moveData.pivotRotationValue.Pitch*0.035 + 0.75f;
  4253. screenSpaceOffsetFwd = ClampF( screenSpaceOffsetFwd, 1.5, 2.6 );
  4254. }
  4255. screenSpaceOffsetUp = -moveData.pivotRotationValue.Pitch*0.005 + 0.325f;
  4256. screenSpaceOffsetUp = ClampF( screenSpaceOffsetUp, 0.4, 0.5 );
  4257. }
  4258.  
  4259. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( screenSpaceOffset, screenSpaceOffsetFwd, screenSpaceOffsetUp ), 0.25f, timeDelta );
  4260. moveData.pivotDistanceController.SetDesiredDistance( 2.8f, 5.f );
  4261. moveData.pivotPositionController.SetDesiredPosition( GetWorldPosition() );
  4262.  
  4263. return true;
  4264. }
  4265. else
  4266. {
  4267. this.wasBRAxisPushed = false;
  4268.  
  4269. return false;
  4270. }
  4271. }
  4272.  
  4273. protected function UpdateCameraForSpecialAttack( out moveData : SCameraMovementData, timeDelta : float ) : bool
  4274. {
  4275. var screenSpaceOffset : float;
  4276. var tempHeading : float;
  4277. var cameraOffsetLeft : float;
  4278. var cameraOffsetRight : float;
  4279.  
  4280. if ( !specialAttackCamera )
  4281. return false;
  4282.  
  4283. theGame.GetGameCamera().ForceManualControlHorTimeout();
  4284. theGame.GetGameCamera().ForceManualControlVerTimeout();
  4285.  
  4286.  
  4287. cameraOffsetLeft = 30.f;
  4288. cameraOffsetRight = -30.f;
  4289.  
  4290.  
  4291.  
  4292.  
  4293.  
  4294.  
  4295.  
  4296. theGame.GetGameCamera().ChangePivotRotationController( 'SignChannel' );
  4297. theGame.GetGameCamera().ChangePivotDistanceController( 'SignChannel' );
  4298.  
  4299. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  4300. moveData.pivotDistanceController = theGame.GetGameCamera().GetActivePivotDistanceController();
  4301.  
  4302. if ( slideTarget )
  4303. tempHeading = VecHeading( slideTarget.GetWorldPosition() - GetWorldPosition() );
  4304. else
  4305. tempHeading = GetHeading();
  4306.  
  4307. oTCameraPitchOffset = 0.f;
  4308.  
  4309. if( ( interiorCamera && !moveTarget )
  4310. || ( AngleDistance( tempHeading, moveData.pivotRotationValue.Yaw ) < 0 ) )
  4311. oTCameraOffset = cameraOffsetLeft;
  4312. else
  4313. oTCameraOffset = cameraOffsetRight;
  4314.  
  4315. if ( oTCameraOffset == cameraOffsetLeft )
  4316. {
  4317. if ( delayCameraOrientationChange || delayOrientationChange )
  4318. {
  4319. screenSpaceOffset = 0.75f;
  4320. moveData.pivotDistanceController.SetDesiredDistance( 1.6f, 3.f );
  4321. moveData.pivotPositionController.offsetZ = 1.4f;
  4322. moveData.pivotRotationController.SetDesiredPitch( -15.f );
  4323. }
  4324. else
  4325. {
  4326. screenSpaceOffset = 0.7f;
  4327. moveData.pivotDistanceController.SetDesiredDistance( 3.25f );
  4328. moveData.pivotPositionController.offsetZ = 1.2f;
  4329. moveData.pivotRotationController.SetDesiredPitch( -10.f );
  4330. }
  4331. }
  4332. else if ( oTCameraOffset == cameraOffsetRight )
  4333. {
  4334. if ( delayCameraOrientationChange || delayOrientationChange )
  4335. {
  4336. screenSpaceOffset = -0.85f;
  4337. moveData.pivotDistanceController.SetDesiredDistance( 1.6f, 3.f );
  4338. moveData.pivotPositionController.offsetZ = 1.4f;
  4339. moveData.pivotRotationController.SetDesiredPitch( -15.f );
  4340. }
  4341. else
  4342. {
  4343. screenSpaceOffset = -0.8f;
  4344. moveData.pivotDistanceController.SetDesiredDistance( 3.25f );
  4345. moveData.pivotPositionController.offsetZ = 1.2f;
  4346. moveData.pivotRotationController.SetDesiredPitch( -10.f );
  4347. }
  4348. }
  4349. else
  4350. {
  4351. moveData.pivotDistanceController.SetDesiredDistance( 1.25f, 3.f );
  4352. moveData.pivotPositionController.offsetZ = 1.3f;
  4353. moveData.pivotRotationController.SetDesiredPitch( -5.5f );
  4354. }
  4355.  
  4356. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( screenSpaceOffset, 0.f, 0.f ), 1.f, timeDelta );
  4357.  
  4358. if ( !delayCameraOrientationChange )
  4359. {
  4360. if ( moveTarget )
  4361. moveData.pivotRotationController.SetDesiredHeading( GetHeading() + oTCameraOffset, 0.5f );
  4362. else
  4363. moveData.pivotRotationController.SetDesiredHeading( GetHeading() + oTCameraOffset, 1.f );
  4364. }
  4365. else
  4366. moveData.pivotRotationController.SetDesiredHeading( moveData.pivotRotationValue.Yaw, 1.f );
  4367.  
  4368. moveData.pivotPositionController.SetDesiredPosition( GetWorldPosition() );
  4369.  
  4370. return true;
  4371. }
  4372.  
  4373.  
  4374. private var fovVel : float;
  4375. private var sprintOffset : Vector;
  4376. private var previousOffset : bool;
  4377. private var previousRotationVelocity : float;
  4378. private var pivotRotationTimeStamp : float;
  4379. protected function UpdateCameraSprint( out moveData : SCameraMovementData, timeDelta : float )
  4380. {
  4381. var angleDiff : float;
  4382. var camOffsetVector : Vector;
  4383. var smoothSpeed : float;
  4384. var camera : CCustomCamera;
  4385. var camAngularSpeed : float;
  4386.  
  4387. var playerToCamAngle : float;
  4388. var useExplorationSprintCam : bool;
  4389.  
  4390. camera = theGame.GetGameCamera();
  4391. if( camera )
  4392. {
  4393. if ( sprintingCamera )
  4394. {
  4395.  
  4396. if( thePlayer.GetAutoCameraCenter() )
  4397. {
  4398. theGame.GetGameCamera().ForceManualControlVerTimeout();
  4399. }
  4400.  
  4401. playerToCamAngle = AbsF( AngleDistance( GetHeading(), moveData.pivotRotationValue.Yaw ) );
  4402.  
  4403.  
  4404. useExplorationSprintCam = false;
  4405.  
  4406. if ( useExplorationSprintCam )
  4407. {
  4408. if ( playerToCamAngle <= 45 )
  4409. {
  4410. theGame.GetGameCamera().ChangePivotRotationController( 'Sprint' );
  4411.  
  4412. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  4413.  
  4414. moveData.pivotRotationController.SetDesiredHeading( GetHeading(), 0.25f );
  4415. moveData.pivotRotationController.SetDesiredPitch( -3.5f, 0.5f );
  4416. thePlayer.EnableManualCameraControl( true, 'Sprint' );
  4417. }
  4418. else
  4419. {
  4420. thePlayer.EnableManualCameraControl( false, 'Sprint' );
  4421. }
  4422. }
  4423. else
  4424. {
  4425. if ( theGame.IsUberMovementEnabled() )
  4426. moveData.pivotRotationController.SetDesiredHeading( GetHeading(), 0.35f );
  4427.  
  4428. thePlayer.EnableManualCameraControl( true, 'Sprint' );
  4429. }
  4430.  
  4431. if ( bRAxisReleased )
  4432. {
  4433. if ( AbsF( rawLeftJoyRot ) > 25 )
  4434. angleDiff = AngleDistance( GetHeading(), moveData.pivotRotationValue.Yaw );
  4435.  
  4436. pivotRotationTimeStamp = theGame.GetEngineTimeAsSeconds();
  4437. previousRotationVelocity = 0.f;
  4438. }
  4439. else
  4440. {
  4441. if ( previousRotationVelocity <= 0 && AbsF( moveData.pivotRotationVelocity.Yaw ) > 250 )
  4442. {
  4443. pivotRotationTimeStamp = theGame.GetEngineTimeAsSeconds();
  4444. previousRotationVelocity = AbsF( moveData.pivotRotationVelocity.Yaw );
  4445. }
  4446. }
  4447.  
  4448. if ( pivotRotationTimeStamp + 0.4f <= theGame.GetEngineTimeAsSeconds() && AbsF( moveData.pivotRotationVelocity.Yaw ) > 250 )
  4449. angleDiff = VecHeading( rawRightJoyVec );
  4450.  
  4451. if ( useExplorationSprintCam )
  4452. {
  4453. if ( playerToCamAngle > 90 )
  4454. {
  4455. camOffsetVector.X = 0.f;
  4456. smoothSpeed = 1.f;
  4457. }
  4458. else if ( angleDiff > 15.f )
  4459. {
  4460. camOffsetVector.X = -0.8;
  4461. smoothSpeed = 1.f;
  4462. previousOffset = true;
  4463. }
  4464. else if ( angleDiff < -15.f )
  4465. {
  4466. camOffsetVector.X = 0.475f;
  4467. smoothSpeed = 1.5f;
  4468. previousOffset = false;
  4469. }
  4470. else
  4471. {
  4472. if ( previousOffset )
  4473. {
  4474. camOffsetVector.X = -0.8;
  4475. smoothSpeed = 1.5f;
  4476. }
  4477. else
  4478. {
  4479. camOffsetVector.X = 0.475f;
  4480. smoothSpeed = 1.5f;
  4481. }
  4482. }
  4483.  
  4484. camOffsetVector.Y = 1.4f;
  4485. camOffsetVector.Z = 0.275f;
  4486. }
  4487. else
  4488. {
  4489.  
  4490. smoothSpeed = 0.75f;
  4491.  
  4492. camOffsetVector.X = 0.f;
  4493. camOffsetVector.Y = 1.f;
  4494. camOffsetVector.Z = 0.2f;
  4495. moveData.pivotRotationController.SetDesiredPitch( -10.f, 0.5f );
  4496. }
  4497.  
  4498. DampVectorConst( sprintOffset, camOffsetVector, smoothSpeed, timeDelta );
  4499.  
  4500. moveData.cameraLocalSpaceOffset = sprintOffset;
  4501.  
  4502. DampFloatSpring( camera.fov, fovVel, 70.f, 1.0, timeDelta );
  4503. }
  4504. else
  4505. {
  4506. sprintOffset = moveData.cameraLocalSpaceOffset;
  4507. DampFloatSpring( camera.fov, fovVel, 60.f, 1.0, timeDelta );
  4508. previousOffset = false;
  4509. }
  4510. }
  4511. }
  4512.  
  4513. function EnableSprintingCamera( flag : bool )
  4514. {
  4515. if( !theGame.IsUberMovementEnabled() && !useSprintingCameraAnim )
  4516. {
  4517. return;
  4518. }
  4519.  
  4520. super.EnableSprintingCamera( flag );
  4521.  
  4522. if ( !flag )
  4523. {
  4524. thePlayer.EnableManualCameraControl( true, 'Sprint' );
  4525. }
  4526. }
  4527.  
  4528. protected function UpdateCameraCombatActionButNotInCombat( out moveData : SCameraMovementData, timeDelta : float )
  4529. {
  4530. var vel : Vector;
  4531. var heading : float;
  4532. var pitch : float;
  4533. var headingMult : float;
  4534. var pitchMult : float;
  4535. var camOffset : Vector;
  4536. var buff : CBaseGameplayEffect;
  4537. var runningAndAlertNear : bool;
  4538. var desiredDist : float;
  4539.  
  4540. if ( ( !IsCurrentSignChanneled() || GetCurrentlyCastSign() == ST_Quen || GetCurrentlyCastSign() == ST_Yrden ) && !specialAttackCamera && !IsInCombatActionFriendly() )
  4541. {
  4542. buff = GetCurrentlyAnimatedCS();
  4543. runningAndAlertNear = GetPlayerCombatStance() == PCS_AlertNear && playerMoveType == PMT_Run && !GetDisplayTarget();
  4544. if ( runningAndAlertNear ||
  4545. ( GetPlayerCombatStance() == PCS_AlertFar && !IsInCombatAction() && !buff ) )
  4546. {
  4547. camOffset.X = 0.f;
  4548. camOffset.Y = 0.f;
  4549. camOffset.Z = -0.1f;
  4550.  
  4551. if ( runningAndAlertNear )
  4552. {
  4553. moveData.pivotDistanceController.SetDesiredDistance( 4.f );
  4554. moveData.pivotPositionController.offsetZ = 1.5f;
  4555. }
  4556. }
  4557. else
  4558. {
  4559. camOffset.X = 0.f;
  4560. camOffset.Y = -1.5f;
  4561. camOffset.Z = -0.2f;
  4562. }
  4563.  
  4564. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( camOffset.X, camOffset.Y, camOffset.Z ), 0.4f, timeDelta );
  4565. sprintOffset = moveData.cameraLocalSpaceOffset;
  4566. heading = moveData.pivotRotationValue.Yaw;
  4567.  
  4568. if ( GetOrientationTarget() == OT_Camera || GetOrientationTarget() == OT_CameraOffset )
  4569. pitch = moveData.pivotRotationValue.Pitch;
  4570. else if ( lastAxisInputIsMovement
  4571. || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack
  4572. || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_SpecialAttack
  4573. || ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign && !IsCurrentSignChanneled() && GetCurrentlyCastSign() == ST_Quen ) )
  4574. {
  4575. theGame.GetGameCamera().ForceManualControlVerTimeout();
  4576. pitch = -20.f;
  4577. }
  4578. else
  4579. pitch = moveData.pivotRotationValue.Pitch;
  4580.  
  4581. headingMult = 1.f;
  4582. pitchMult = 1.f;
  4583.  
  4584.  
  4585. if( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign
  4586. && ( GetEquippedSign() == ST_Aard || GetEquippedSign() == ST_Yrden )
  4587. && GetBehaviorVariable( 'alternateSignCast' ) == 1 )
  4588. {
  4589.  
  4590. theGame.GetGameCamera().ForceManualControlVerTimeout();
  4591. pitch = -20.f;
  4592.  
  4593.  
  4594. }
  4595.  
  4596.  
  4597.  
  4598.  
  4599.  
  4600.  
  4601.  
  4602. if ( IsCurrentSignChanneled() && GetCurrentlyCastSign() == ST_Quen )
  4603. {
  4604. pitch = moveData.pivotRotationValue.Pitch;
  4605. }
  4606.  
  4607. moveData.pivotRotationController.SetDesiredHeading( heading, );
  4608. moveData.pivotRotationController.SetDesiredPitch( pitch );
  4609. }
  4610. }
  4611.  
  4612.  
  4613.  
  4614. event OnGameCameraExplorationRotCtrlChange()
  4615. {
  4616. if( substateManager )
  4617. {
  4618. return substateManager.OnGameCameraExplorationRotCtrlChange( );
  4619. }
  4620.  
  4621. return false;
  4622. }
  4623.  
  4624.  
  4625.  
  4626.  
  4627.  
  4628.  
  4629. function SetCustomRotation( customRotationName : name, rotHeading : float, rotSpeed : float, activeTime : float, rotateExistingDeltaLocation : bool )
  4630. {
  4631. var movementAdjustor : CMovementAdjustor;
  4632. var ticket : SMovementAdjustmentRequestTicket;
  4633.  
  4634. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  4635. ticket = movementAdjustor.GetRequest( customRotationName );
  4636. movementAdjustor.Cancel( ticket );
  4637. ticket = movementAdjustor.CreateNewRequest( customRotationName );
  4638. movementAdjustor.Continuous( ticket );
  4639. movementAdjustor.ReplaceRotation( ticket );
  4640. movementAdjustor.RotateTo( ticket, rotHeading );
  4641. movementAdjustor.MaxRotationAdjustmentSpeed( ticket, rotSpeed );
  4642. if (rotSpeed == 0.0f)
  4643. {
  4644. movementAdjustor.AdjustmentDuration( ticket, activeTime );
  4645. }
  4646. movementAdjustor.KeepActiveFor( ticket, activeTime );
  4647. movementAdjustor.RotateExistingDeltaLocation( ticket, rotateExistingDeltaLocation );
  4648. }
  4649.  
  4650. function UpdateCustomRotationHeading( customRotationName : name, rotHeading : float )
  4651. {
  4652. var movementAdjustor : CMovementAdjustor;
  4653. var ticket : SMovementAdjustmentRequestTicket;
  4654.  
  4655. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  4656. ticket = movementAdjustor.GetRequest( customRotationName );
  4657. movementAdjustor.RotateTo( ticket, rotHeading );
  4658. }
  4659.  
  4660. function SetCustomRotationTowards( customRotationName : name, target : CActor, rotSpeed : float, optional activeTime : float )
  4661. {
  4662. var movementAdjustor : CMovementAdjustor;
  4663. var ticket : SMovementAdjustmentRequestTicket;
  4664.  
  4665. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  4666. ticket = movementAdjustor.GetRequest( customRotationName );
  4667. movementAdjustor.Cancel( ticket );
  4668. ticket = movementAdjustor.CreateNewRequest( customRotationName );
  4669. movementAdjustor.Continuous( ticket );
  4670. movementAdjustor.ReplaceRotation( ticket );
  4671. movementAdjustor.RotateTowards( ticket, target );
  4672. movementAdjustor.MaxRotationAdjustmentSpeed( ticket, rotSpeed );
  4673. if (activeTime > 0.0f)
  4674. {
  4675. movementAdjustor.KeepActiveFor( ticket, activeTime );
  4676. }
  4677. else
  4678. {
  4679. movementAdjustor.DontEnd( ticket );
  4680. }
  4681. }
  4682.  
  4683.  
  4684. function CustomLockMovement( customMovementName : name, heading : float )
  4685. {
  4686. var movementAdjustor : CMovementAdjustor;
  4687. var ticket : SMovementAdjustmentRequestTicket;
  4688.  
  4689. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  4690. ticket = movementAdjustor.GetRequest( customMovementName );
  4691. movementAdjustor.Cancel( ticket );
  4692. ticket = movementAdjustor.CreateNewRequest( customMovementName );
  4693. movementAdjustor.Continuous( ticket );
  4694. movementAdjustor.DontEnd( ticket );
  4695. movementAdjustor.LockMovementInDirection( ticket, heading );
  4696. }
  4697.  
  4698. function BindMovementAdjustmentToEvent( customRotationName : name, eventName : CName )
  4699. {
  4700. var movementAdjustor : CMovementAdjustor;
  4701. var ticket : SMovementAdjustmentRequestTicket;
  4702.  
  4703. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  4704. ticket = movementAdjustor.GetRequest( customRotationName );
  4705. movementAdjustor.BindToEvent( ticket, eventName );
  4706. }
  4707.  
  4708. function UpdateCustomLockMovementHeading( customMovementName : name, heading : float )
  4709. {
  4710. var movementAdjustor : CMovementAdjustor;
  4711. var ticket : SMovementAdjustmentRequestTicket;
  4712.  
  4713. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  4714. ticket = movementAdjustor.GetRequest( customMovementName );
  4715. movementAdjustor.LockMovementInDirection( ticket, heading );
  4716. }
  4717.  
  4718. function CustomLockDistance( customMovementName : name, maintainDistanceTo : CNode, minDist, maxDist : float )
  4719. {
  4720. var movementAdjustor : CMovementAdjustor;
  4721. var ticket : SMovementAdjustmentRequestTicket;
  4722.  
  4723. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  4724. ticket = movementAdjustor.GetRequest( customMovementName );
  4725. movementAdjustor.Cancel( ticket );
  4726. ticket = movementAdjustor.CreateNewRequest( customMovementName );
  4727. movementAdjustor.Continuous( ticket );
  4728. movementAdjustor.SlideTowards( ticket, maintainDistanceTo, minDist, maxDist );
  4729. }
  4730.  
  4731. function UpdateCustomLockDistance( customMovementName : name, maintainDistanceTo : CNode, minDist, maxDist : float )
  4732. {
  4733. var movementAdjustor : CMovementAdjustor;
  4734. var ticket : SMovementAdjustmentRequestTicket;
  4735.  
  4736. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  4737. ticket = movementAdjustor.GetRequest( customMovementName );
  4738. movementAdjustor.SlideTowards( ticket, maintainDistanceTo, minDist, maxDist );
  4739. }
  4740.  
  4741. private var disableManualCameraControlStack : array<name>;
  4742. public function EnableManualCameraControl( enable : bool, sourceName : name )
  4743. {
  4744. if ( !enable )
  4745. {
  4746. if ( !disableManualCameraControlStack.Contains( sourceName ) )
  4747. {
  4748. disableManualCameraControlStack.PushBack( sourceName );
  4749. }
  4750. }
  4751. else
  4752. {
  4753. disableManualCameraControlStack.Remove( sourceName );
  4754. }
  4755.  
  4756. if ( disableManualCameraControlStack.Size() > 0 )
  4757. theGame.GetGameCamera().EnableManualControl( false );
  4758. else
  4759. theGame.GetGameCamera().EnableManualControl( true );
  4760. }
  4761.  
  4762. public function IsCameraControlDisabled( optional disabledBySourceName : name ) : bool
  4763. {
  4764. if ( disabledBySourceName )
  4765. return disableManualCameraControlStack.Contains( disabledBySourceName );
  4766. else
  4767. return disableManualCameraControlStack.Size() > 0;
  4768. }
  4769.  
  4770. public function DisableManualCameraControlStackHasSource( sourceName : name ) : bool
  4771. {
  4772. return disableManualCameraControlStack.Contains( sourceName );
  4773. }
  4774.  
  4775. public function ClearDisableManualCameraControlStack()
  4776. {
  4777. disableManualCameraControlStack.Clear();
  4778. theGame.GetGameCamera().EnableManualControl( true );
  4779. }
  4780.  
  4781. function SetOrientationTarget( target : EOrientationTarget )
  4782. {
  4783. if ( IsPCModeEnabled() && target == OT_Player )
  4784. {
  4785. target = OT_Camera;
  4786. }
  4787.  
  4788. orientationTarget = target;
  4789. }
  4790.  
  4791. function GetOrientationTarget() : EOrientationTarget
  4792. {
  4793. return orientationTarget;
  4794. }
  4795.  
  4796. var customOrientationInfoStack : array<SCustomOrientationInfo>;
  4797. public function AddCustomOrientationTarget( orientationTarget : EOrientationTarget, sourceName : name )
  4798. {
  4799. var customOrientationInfo : SCustomOrientationInfo;
  4800. var i : int;
  4801.  
  4802. if ( customOrientationInfoStack.Size() > 0 )
  4803. {
  4804. for( i = customOrientationInfoStack.Size()-1; i>=0; i-=1 )
  4805. {
  4806. if ( customOrientationInfoStack[i].sourceName == sourceName )
  4807. customOrientationInfoStack.Erase(i);
  4808. }
  4809. }
  4810.  
  4811. customOrientationInfo.sourceName = sourceName;
  4812. customOrientationInfo.orientationTarget = orientationTarget;
  4813. customOrientationInfoStack.PushBack( customOrientationInfo );
  4814. SetOrientationTarget( orientationTarget );
  4815. }
  4816.  
  4817. public function RemoveCustomOrientationTarget( sourceName : name )
  4818. {
  4819. var customOrientationInfo : SCustomOrientationInfo;
  4820. var i : int;
  4821.  
  4822. if ( customOrientationInfoStack.Size() > 0 )
  4823. {
  4824. for( i = customOrientationInfoStack.Size()-1; i>=0; i-=1 )
  4825. {
  4826. if ( customOrientationInfoStack[i].sourceName == sourceName )
  4827. customOrientationInfoStack.Erase(i);
  4828. }
  4829. }
  4830. else
  4831. LogChannel( 'CustomOrienatation', "ERROR: Custom orientation cannot be removed, stack is already empty!!!" );
  4832. }
  4833.  
  4834. protected function ClearCustomOrientationInfoStack()
  4835. {
  4836. customOrientationInfoStack.Clear();
  4837. }
  4838.  
  4839. protected function GetCustomOrientationTarget( out infoStack : SCustomOrientationInfo ) : bool
  4840. {
  4841. var size : int;
  4842.  
  4843. size = customOrientationInfoStack.Size();
  4844.  
  4845. if ( size <= 0 )
  4846. return false;
  4847. else
  4848. {
  4849. infoStack = customOrientationInfoStack[ size - 1 ];
  4850. return true;
  4851. }
  4852. }
  4853.  
  4854. public function SetOrientationTargetCustomHeading( heading : float, sourceName : name ) : bool
  4855. {
  4856. var i : int;
  4857. if ( customOrientationInfoStack.Size() > 0 )
  4858. {
  4859. for( i = customOrientationInfoStack.Size()-1; i>=0; i-=1 )
  4860. {
  4861. if ( customOrientationInfoStack[i].sourceName == sourceName )
  4862. {
  4863. customOrientationInfoStack[i].customHeading = heading;
  4864. return true;
  4865. }
  4866. }
  4867. }
  4868.  
  4869. LogChannel( 'SetOrientationTargetCustomHeading', "ERROR: Cannot set customHeading because stack is empty or sourceName is not found!!!" );
  4870. return false;
  4871. }
  4872.  
  4873.  
  4874. public function GetOrientationTargetCustomHeading() : float
  4875. {
  4876. var i : int;
  4877. if ( customOrientationInfoStack.Size() > 0 )
  4878. {
  4879. for( i = customOrientationInfoStack.Size()-1; i>=0; i-=1 )
  4880. {
  4881. if ( customOrientationInfoStack[i].orientationTarget == OT_CustomHeading )
  4882. {
  4883. return customOrientationInfoStack[i].customHeading;
  4884. }
  4885. }
  4886. }
  4887.  
  4888. LogChannel( 'SetOrientationTargetCustomHeading', "ERROR: Cannot get customHeading because stack is empty or no OT_CustomHeading in stack!!!" );
  4889. return -1.f;
  4890. }
  4891.  
  4892. public function GetCombatActionOrientationTarget( combatActionType : ECombatActionType ) : EOrientationTarget
  4893. {
  4894. var newCustomOrientationTarget : EOrientationTarget;
  4895. var targetEnt : CGameplayEntity;
  4896. var targetActor : CActor;
  4897.  
  4898. if ( GetCurrentStateName() == 'AimThrow' )
  4899. newCustomOrientationTarget = OT_CameraOffset;
  4900. else
  4901. {
  4902. targetEnt = GetDisplayTarget();
  4903. targetActor = (CActor)targetEnt;
  4904.  
  4905. if ( targetEnt )
  4906. {
  4907. if ( targetActor )
  4908. {
  4909. if ( moveTarget )
  4910. newCustomOrientationTarget = OT_Actor;
  4911. else
  4912. {
  4913. if ( this.IsSwimming() )
  4914. newCustomOrientationTarget = OT_Camera;
  4915. else if ( lastAxisInputIsMovement )
  4916. newCustomOrientationTarget = OT_Player;
  4917. else
  4918. newCustomOrientationTarget = OT_Actor;
  4919. }
  4920. }
  4921. else
  4922. {
  4923. if ( combatActionType == CAT_Crossbow && targetEnt.HasTag( 'softLock_Bolt' ) )
  4924. newCustomOrientationTarget = OT_Actor;
  4925. else
  4926. {
  4927. if ( this.IsSwimming() )
  4928. newCustomOrientationTarget = OT_Camera;
  4929. else if ( lastAxisInputIsMovement )
  4930. newCustomOrientationTarget = OT_Player;
  4931. else
  4932. newCustomOrientationTarget = OT_Camera;
  4933.  
  4934. }
  4935. }
  4936. }
  4937. else
  4938. {
  4939. if ( IsUsingVehicle() )
  4940. newCustomOrientationTarget = OT_Camera;
  4941. else if ( lastAxisInputIsMovement )
  4942. {
  4943. if ( this.IsSwimming() )
  4944. {
  4945.  
  4946.  
  4947. newCustomOrientationTarget = OT_Camera;
  4948.  
  4949.  
  4950. }
  4951. else
  4952. newCustomOrientationTarget = OT_Player;
  4953.  
  4954. }
  4955. else
  4956. newCustomOrientationTarget = OT_Camera;
  4957. }
  4958. }
  4959.  
  4960. return newCustomOrientationTarget;
  4961. }
  4962.  
  4963. public function GetOrientationTargetHeading( orientationTarget : EOrientationTarget ) : float
  4964. {
  4965. var heading : float;
  4966.  
  4967. if( orientationTarget == OT_Camera )
  4968. heading = VecHeading( theCamera.GetCameraDirection() );
  4969. else if( orientationTarget == OT_CameraOffset )
  4970. heading = VecHeading( theCamera.GetCameraDirection() ) - oTCameraOffset;
  4971. else if( orientationTarget == OT_CustomHeading )
  4972. heading = GetOrientationTargetCustomHeading();
  4973. else if ( GetDisplayTarget() && orientationTarget == OT_Actor )
  4974. {
  4975. if ( (CActor)( GetDisplayTarget() ) )
  4976. {
  4977.  
  4978. heading = VecHeading( GetDisplayTarget().GetWorldPosition() - GetWorldPosition() );
  4979.  
  4980.  
  4981. }
  4982. else
  4983. {
  4984. if ( GetDisplayTarget().HasTag( 'softLock_Bolt' ) )
  4985. heading = VecHeading( GetDisplayTarget().GetWorldPosition() - GetWorldPosition() );
  4986. else
  4987. heading = GetHeading();
  4988. }
  4989. }
  4990. else
  4991. heading = GetHeading();
  4992.  
  4993. return heading;
  4994. }
  4995.  
  4996. event OnDelayOrientationChange()
  4997. {
  4998. var delayOrientation : bool;
  4999. var delayCameraRotation : bool;
  5000. var moveData : SCameraMovementData;
  5001. var time : float;
  5002.  
  5003. time = 0.01f;
  5004.  
  5005. if ( theInput.GetActionValue( 'CastSignHold' ) == 1.f )
  5006. {
  5007. actionType = 0;
  5008. if ( moveTarget )
  5009. delayOrientation = true;
  5010. else
  5011. {
  5012. if ( !GetBIsCombatActionAllowed() )
  5013. delayOrientation = true;
  5014. }
  5015.  
  5016.  
  5017. }
  5018. else if ( theInput.GetActionValue( 'ThrowItemHold' ) == 1.f )
  5019. {
  5020. actionType = 3;
  5021. delayOrientation = true;
  5022. }
  5023. else if ( theInput.GetActionValue( 'SpecialAttackHeavy' ) == 1.f )
  5024. {
  5025. actionType = 2;
  5026. if ( !slideTarget )
  5027. delayOrientation = true;
  5028. else
  5029. delayOrientation = true;
  5030. }
  5031. else if ( IsGuarded() && !moveTarget )
  5032. {
  5033. actionType = 1;
  5034. delayOrientation = true;
  5035. }
  5036.  
  5037. if ( delayOrientation )
  5038. {
  5039. delayOrientationChange = true;
  5040. theGame.GetGameCamera().ForceManualControlHorTimeout();
  5041. theGame.GetGameCamera().ForceManualControlVerTimeout();
  5042. AddTimer( 'DelayOrientationChangeTimer', time, true );
  5043. }
  5044.  
  5045. if ( delayCameraRotation )
  5046. {
  5047. delayCameraOrientationChange = true;
  5048. theGame.GetGameCamera().ForceManualControlHorTimeout();
  5049. theGame.GetGameCamera().ForceManualControlVerTimeout();
  5050. AddTimer( 'DelayOrientationChangeTimer', time, true );
  5051. }
  5052. }
  5053.  
  5054.  
  5055. event OnDelayOrientationChangeOff()
  5056. {
  5057. delayOrientationChange = false;
  5058. delayCameraOrientationChange = false;
  5059. RemoveTimer( 'DelayOrientationChangeTimer' );
  5060.  
  5061.  
  5062.  
  5063. }
  5064.  
  5065. timer function DelayOrientationChangeTimer( time : float , id : int)
  5066. {
  5067. if ( ( actionType == 0 && theInput.GetActionValue( 'CastSignHold' ) == 0.f )
  5068. || ( actionType == 2 && theInput.GetActionValue( 'SpecialAttackHeavy' ) == 0.f )
  5069. || ( actionType == 3 && theInput.GetActionValue( 'ThrowItemHold' ) == 0.f )
  5070. || ( actionType == 1 && !IsGuarded() )
  5071. || ( VecLength( rawRightJoyVec ) > 0.f ) )
  5072. {
  5073. OnDelayOrientationChangeOff();
  5074. }
  5075. }
  5076.  
  5077. public function SetCombatActionHeading( heading : float )
  5078. {
  5079. combatActionHeading = heading;
  5080. }
  5081.  
  5082. public function GetCombatActionHeading() : float
  5083. {
  5084. return combatActionHeading;
  5085. }
  5086.  
  5087. protected function EnableCloseCombatCharacterRadius( flag : bool )
  5088. {
  5089. var actor : CActor;
  5090.  
  5091. actor = (CActor)slideTarget;
  5092. if ( flag )
  5093. {
  5094. this.GetMovingAgentComponent().SetVirtualRadius( 'CloseCombatCharacterRadius' );
  5095. if(actor)
  5096. actor.GetMovingAgentComponent().SetVirtualRadius( 'CloseCombatCharacterRadius' );
  5097. }
  5098. else
  5099. {
  5100. if ( this.IsInCombat() )
  5101. {
  5102. GetMovingAgentComponent().SetVirtualRadius( 'CombatCharacterRadius' );
  5103. if(actor)
  5104. actor.GetMovingAgentComponent().SetVirtualRadius( 'CombatCharacterRadius' );
  5105. }
  5106. else
  5107. {
  5108. this.GetMovingAgentComponent().ResetVirtualRadius();
  5109. if(actor)
  5110. actor.GetMovingAgentComponent().ResetVirtualRadius();
  5111. }
  5112. }
  5113. }
  5114.  
  5115.  
  5116.  
  5117.  
  5118.  
  5119.  
  5120. private var isSnappedToNavMesh : bool;
  5121. private var snapToNavMeshCachedFlag : bool;
  5122. public function SnapToNavMesh( flag : bool )
  5123. {
  5124. var comp : CMovingAgentComponent;
  5125.  
  5126. comp = (CMovingAgentComponent)this.GetMovingAgentComponent();
  5127.  
  5128. if ( comp )
  5129. {
  5130. comp.SnapToNavigableSpace( flag );
  5131. isSnappedToNavMesh = flag;
  5132. }
  5133. else
  5134. {
  5135. snapToNavMeshCachedFlag = flag;
  5136. AddTimer( 'DelayedSnapToNavMesh', 0.2f );
  5137. }
  5138. }
  5139.  
  5140. public final function PlayRuneword4FX(optional weaponType : EPlayerWeapon)
  5141. {
  5142. var hasSwordDrawn : bool;
  5143. var sword : SItemUniqueId;
  5144.  
  5145.  
  5146.  
  5147.  
  5148. if(abilityManager.GetOverhealBonus() > (0.005 * GetStatMax(BCS_Vitality)))
  5149. {
  5150. hasSwordDrawn = HasAbility('Runeword 4 _Stats', true);
  5151.  
  5152. if(!hasSwordDrawn && GetWitcherPlayer())
  5153. {
  5154. if(weaponType == PW_Steel)
  5155. {
  5156. if(GetWitcherPlayer().GetItemEquippedOnSlot(EES_SteelSword, sword))
  5157. hasSwordDrawn = inv.ItemHasAbility(sword, 'Runeword 4 _Stats');
  5158. }
  5159. else if(weaponType == PW_Silver)
  5160. {
  5161. if(GetWitcherPlayer().GetItemEquippedOnSlot(EES_SilverSword, sword))
  5162. hasSwordDrawn = inv.ItemHasAbility(sword, 'Runeword 4 _Stats');
  5163. }
  5164. }
  5165.  
  5166. if(hasSwordDrawn)
  5167. {
  5168. if(!IsEffectActive('runeword_4', true))
  5169. PlayEffect('runeword_4');
  5170. }
  5171. }
  5172. }
  5173.  
  5174. timer function DelayedSnapToNavMesh( dt : float, id : int)
  5175. {
  5176. SnapToNavMesh( snapToNavMeshCachedFlag );
  5177. }
  5178.  
  5179. saved var navMeshSnapInfoStack : array<name>;
  5180. public function EnableSnapToNavMesh( source : name, enable : bool )
  5181. {
  5182. if ( enable )
  5183. {
  5184. if ( !navMeshSnapInfoStack.Contains( source ) )
  5185. navMeshSnapInfoStack.PushBack( source );
  5186. }
  5187. else
  5188. {
  5189. if ( navMeshSnapInfoStack.Contains( source ) )
  5190. navMeshSnapInfoStack.Remove( source );
  5191. }
  5192.  
  5193. if ( navMeshSnapInfoStack.Size() > 0 )
  5194. SnapToNavMesh( true );
  5195. else
  5196. SnapToNavMesh( false );
  5197. }
  5198.  
  5199. public function ForceRemoveAllNavMeshSnaps()
  5200. {
  5201. navMeshSnapInfoStack.Clear();
  5202. SnapToNavMesh( false );
  5203. }
  5204.  
  5205. public function CanSprint( speed : float ) : bool
  5206. {
  5207. if( speed <= 0.8f )
  5208. {
  5209. return false;
  5210. }
  5211.  
  5212. if ( thePlayer.GetIsSprintToggled() )
  5213. {
  5214. }
  5215. else if ( !sprintActionPressed )
  5216. {
  5217. return false;
  5218. }
  5219. else if( !theInput.IsActionPressed('Sprint') || ( theInput.LastUsedGamepad() && IsInsideInteraction() && GetHowLongSprintButtonWasPressed() < 0.12 ) )
  5220. {
  5221. return false;
  5222. }
  5223.  
  5224. if ( thePlayer.HasBuff( EET_OverEncumbered ) )
  5225. {
  5226. return false;
  5227. }
  5228. if ( !IsSwimming() )
  5229. {
  5230. if ( ShouldUseStaminaWhileSprinting() && !GetIsSprinting() && !IsInCombat() && GetStatPercents(BCS_Stamina) <= 0.9 )
  5231. {
  5232. return false;
  5233. }
  5234. if( ( !IsCombatMusicEnabled() || IsInFistFightMiniGame() ) && ( !IsActionAllowed(EIAB_RunAndSprint) || !IsActionAllowed(EIAB_Sprint) ) )
  5235. {
  5236. return false;
  5237. }
  5238. if( IsTerrainTooSteepToRunUp() )
  5239. {
  5240. return false;
  5241. }
  5242. if( IsInCombatAction() )
  5243. {
  5244. return false;
  5245. }
  5246. if( IsInAir() )
  5247. {
  5248. return false;
  5249. }
  5250. }
  5251. if( theGame.IsFocusModeActive() )
  5252. {
  5253. return false;
  5254. }
  5255.  
  5256. return true;
  5257. }
  5258.  
  5259.  
  5260. public function SetTerrainPitch( pitch : float )
  5261. {
  5262. terrainPitch = pitch;
  5263. }
  5264.  
  5265. public function IsTerrainTooSteepToRunUp() : bool
  5266. {
  5267. return terrainPitch <= disableSprintTerrainPitch;
  5268. }
  5269.  
  5270. public function SetTempLookAtTarget( actor : CGameplayEntity )
  5271. {
  5272. tempLookAtTarget = actor;
  5273. }
  5274.  
  5275. private var beingWarnedBy : array<CActor>;
  5276.  
  5277. event OnBeingWarnedStart( sender : CActor )
  5278. {
  5279. if ( !beingWarnedBy.Contains(sender) )
  5280. beingWarnedBy.PushBack(sender);
  5281. }
  5282. event OnBeingWarnedStop( sender : CActor )
  5283. {
  5284. beingWarnedBy.Remove(sender);
  5285. }
  5286.  
  5287. event OnCanFindPath( sender : CActor )
  5288. {
  5289. AddCanFindPathEnemyToList(sender,true);
  5290. }
  5291. event OnCannotFindPath( sender : CActor )
  5292. {
  5293. AddCanFindPathEnemyToList(sender,false);
  5294. }
  5295. event OnBecomeAwareAndCanAttack( sender : CActor )
  5296. {
  5297. AddEnemyToHostileEnemiesList( sender, true );
  5298. OnApproachAttack( sender );
  5299. }
  5300. event OnBecomeUnawareOrCannotAttack( sender : CActor )
  5301. {
  5302. AddEnemyToHostileEnemiesList( sender, false );
  5303. OnApproachAttackEnd( sender );
  5304. OnCannotFindPath(sender);
  5305. }
  5306. event OnApproachAttack( sender : CActor )
  5307. {
  5308. AddEnemyToHostileEnemiesList( sender, true );
  5309. super.OnApproachAttack( sender );
  5310. }
  5311. event OnApproachAttackEnd( sender : CActor )
  5312. {
  5313. AddEnemyToHostileEnemiesList( sender, false );
  5314. super.OnApproachAttackEnd( sender );
  5315. }
  5316. event OnAttack( sender : CActor )
  5317. {
  5318. super.OnAttack( sender );
  5319. }
  5320. event OnAttackEnd( sender : CActor )
  5321. {
  5322. super.OnAttackEnd( sender );
  5323. }
  5324.  
  5325. event OnHitCeiling()
  5326. {
  5327. substateManager.ReactOnHitCeiling();
  5328. }
  5329.  
  5330. protected var hostileEnemies : array<CActor>;
  5331. private var hostileMonsters : array<CActor>;
  5332. function AddEnemyToHostileEnemiesList( actor : CActor, add : bool )
  5333. {
  5334. if ( add )
  5335. {
  5336. RemoveTimer( 'RemoveEnemyFromHostileEnemiesListTimer' );
  5337. if ( !hostileEnemies.Contains( actor ) )
  5338. {
  5339. hostileEnemies.PushBack( actor );
  5340.  
  5341. if( !actor.IsHuman() )
  5342. hostileMonsters.PushBack( actor );
  5343. }
  5344. }
  5345. else
  5346. {
  5347. if ( hostileEnemies.Size() == 1 )
  5348. {
  5349. if ( !actor.IsAlive() || actor.IsKnockedUnconscious() )
  5350. {
  5351. hostileEnemies.Remove( actor );
  5352. if( !actor.IsHuman() )
  5353. hostileMonsters.Remove( actor );
  5354. }
  5355. else
  5356. {
  5357.  
  5358. if( hostileEnemyToRemove )
  5359. {
  5360. hostileEnemies.Remove( hostileEnemyToRemove );
  5361. if( !hostileEnemyToRemove.IsHuman() )
  5362. hostileMonsters.Remove( hostileEnemyToRemove );
  5363. }
  5364. hostileEnemyToRemove = actor;
  5365. AddTimer( 'RemoveEnemyFromHostileEnemiesListTimer', 3.f );
  5366. }
  5367. }
  5368. else
  5369. {
  5370. hostileEnemies.Remove( actor );
  5371. if( !actor.IsHuman() )
  5372. hostileMonsters.Remove( actor );
  5373. }
  5374. }
  5375. }
  5376.  
  5377.  
  5378.  
  5379. public function ShouldEnableCombatMusic() : bool
  5380. {
  5381. var moveTargetNPC : CNewNPC;
  5382.  
  5383. if ( thePlayer.GetPlayerMode().GetForceCombatMode() )
  5384. return true;
  5385. else if ( !IsCombatMusicEnabled() )
  5386. {
  5387. if ( IsInCombat() )
  5388. return true;
  5389. else if ( IsThreatened() )
  5390. {
  5391. moveTargetNPC = (CNewNPC)moveTarget;
  5392. if ( moveTargetNPC.IsRanged() && hostileEnemies.Contains( moveTargetNPC ) )
  5393. return true;
  5394. else
  5395. return false;
  5396. }
  5397. else
  5398. return false;
  5399. }
  5400. else if ( ( thePlayer.IsThreatened() && ( hostileEnemies.Size() > 0 || thePlayer.GetPlayerCombatStance() == PCS_AlertNear ) )
  5401. || IsInCombat()
  5402. || finishableEnemiesList.Size() > 0
  5403. || isInFinisher )
  5404. return true;
  5405. else
  5406. return false;
  5407.  
  5408. }
  5409.  
  5410. public var canFindPathEnemiesList : array<CActor>;
  5411. public var disablecanFindPathEnemiesListUpdate : bool;
  5412. private var lastCanFindPathEnemy : CActor;
  5413. private var cachedMoveTarget : CActor;
  5414. private var reachabilityTestId : int;
  5415. private var reachabilityTestId2 : int;
  5416. function AddCanFindPathEnemyToList( actor : CActor, add : bool )
  5417. {
  5418. if ( disablecanFindPathEnemiesListUpdate )
  5419. return;
  5420.  
  5421. if ( add && !canFindPathEnemiesList.Contains( actor ) )
  5422. {
  5423. canFindPathEnemiesList.PushBack(actor);
  5424. }
  5425. else if ( !add )
  5426. {
  5427. canFindPathEnemiesList.Remove(actor);
  5428.  
  5429. if ( canFindPathEnemiesList.Size() <= 0 )
  5430. playerMode.UpdateCombatMode();
  5431. }
  5432. }
  5433.  
  5434. public function ClearCanFindPathEnemiesList( dt : float, id : int )
  5435. {
  5436. canFindPathEnemiesList.Clear();
  5437. }
  5438.  
  5439. public var finishableEnemiesList : array<CActor>;
  5440. function AddToFinishableEnemyList( actor : CActor, add : bool )
  5441. {
  5442. if ( add && !finishableEnemiesList.Contains( actor ) )
  5443. {
  5444. finishableEnemiesList.PushBack(actor);
  5445. }
  5446. else if ( !add )
  5447. {
  5448. finishableEnemiesList.Remove(actor);
  5449. }
  5450. }
  5451.  
  5452. private function UpdateFinishableEnemyList()
  5453. {
  5454. var i : int;
  5455. i = 0;
  5456. while ( i < finishableEnemiesList.Size() )
  5457. {
  5458. if ( !finishableEnemiesList[ i ] )
  5459. {
  5460. finishableEnemiesList.EraseFast( i );
  5461. }
  5462. else
  5463. {
  5464. i += 1;
  5465. }
  5466. }
  5467. }
  5468.  
  5469. private timer function ClearFinishableEnemyList( dt : float, id : int )
  5470. {
  5471. finishableEnemiesList.Clear();
  5472. }
  5473.  
  5474. private var hostileEnemyToRemove : CActor;
  5475. private timer function RemoveEnemyFromHostileEnemiesListTimer( time : float , id : int)
  5476. {
  5477. hostileEnemies.Remove( hostileEnemyToRemove );
  5478.  
  5479. if( hostileEnemyToRemove.IsMonster() )
  5480. hostileMonsters.Remove( hostileEnemyToRemove );
  5481.  
  5482. hostileEnemyToRemove = NULL;
  5483. }
  5484.  
  5485. private function ClearHostileEnemiesList()
  5486. {
  5487. hostileEnemies.Clear();
  5488. hostileMonsters.Clear();
  5489. canFindPathEnemiesList.Clear();
  5490. }
  5491.  
  5492. private var moveTargets : array<CActor>;
  5493. public function GetMoveTargets() : array<CActor> { return moveTargets; }
  5494. public function GetNumberOfMoveTargets() : int { return moveTargets.Size(); }
  5495. public function GetHostileEnemies() : array<CActor> { return hostileEnemies; }
  5496. public function GetHostileEnemiesCount() : int { return hostileEnemies.Size(); }
  5497.  
  5498. protected var enableStrafe : bool;
  5499.  
  5500.  
  5501. public function FindMoveTarget()
  5502. {
  5503. var moveTargetDists : array<float>;
  5504. var moveTargetCanPathFinds : array<bool>;
  5505. var aPotentialMoveTargetCanFindPath : bool;
  5506.  
  5507. var newMoveTarget : CActor;
  5508. var actors : array<CActor>;
  5509. var currentHeading : float;
  5510. var size, i : int;
  5511. var playerToNewMoveTargetDist : float;
  5512. var playerToMoveTargetDist : float;
  5513. var confirmEmptyMoveTarget : bool;
  5514. var newEmptyMoveTargetTimer : float;
  5515. var wasVisibleInFullFrame : bool;
  5516. var setIsThreatened : bool;
  5517.  
  5518. var enemysTarget : CActor;
  5519. var isEnemyInCombat : bool;
  5520. var potentialMoveTargets : array<CActor>;
  5521. var onlyThreatTargets : bool;
  5522.  
  5523. thePlayer.SetupEnemiesCollection( enemyCollectionDist, enemyCollectionDist, 10, 'None', FLAG_Attitude_Neutral + FLAG_Attitude_Hostile + FLAG_Attitude_Friendly + FLAG_OnlyAliveActors );
  5524.  
  5525.  
  5526.  
  5527.  
  5528. if ( GetCurrentStateName() != 'PlayerDialogScene' && IsAlive() )
  5529. {
  5530. GetVisibleEnemies( actors );
  5531.  
  5532.  
  5533. if ( hostileEnemies.Size() > 0 )
  5534. {
  5535. for( i=0; i < hostileEnemies.Size() ; i+=1 )
  5536. {
  5537. if ( !actors.Contains( hostileEnemies[i] ) )
  5538. actors.PushBack( hostileEnemies[i] );
  5539. }
  5540. }
  5541.  
  5542.  
  5543. if ( finishableEnemiesList.Size() > 0 )
  5544. {
  5545. for( i=0; i < finishableEnemiesList.Size() ; i+=1 )
  5546. {
  5547. if ( !actors.Contains( finishableEnemiesList[i] ) )
  5548. actors.PushBack( finishableEnemiesList[i] );
  5549. }
  5550. }
  5551.  
  5552.  
  5553. if ( moveTarget && !actors.Contains( moveTarget ) )
  5554. actors.PushBack( moveTarget );
  5555.  
  5556. FilterActors( actors, onlyThreatTargets, false );
  5557.  
  5558.  
  5559. if ( actors.Size() > 0 )
  5560. {
  5561. setIsThreatened = false;
  5562.  
  5563. if ( onlyThreatTargets )
  5564. {
  5565. setIsThreatened = true;
  5566. }
  5567. else
  5568. {
  5569. for( i=0; i < actors.Size() ; i+=1 )
  5570. {
  5571. if ( IsThreat( actors[i] ) )
  5572. {
  5573. setIsThreatened = true;
  5574. break;
  5575. }
  5576. else
  5577. {
  5578. enemysTarget = actors[i].GetTarget();
  5579. isEnemyInCombat = actors[i].IsInCombat();
  5580. if ( isEnemyInCombat && enemysTarget && GetAttitudeBetween( enemysTarget, this ) == AIA_Friendly && enemysTarget.isPlayerFollower )
  5581. {
  5582. setIsThreatened = true;
  5583. break;
  5584. }
  5585. }
  5586. }
  5587. }
  5588.  
  5589.  
  5590. for( i = actors.Size()-1; i>=0; i-=1 )
  5591. {
  5592. if ( ( !actors[i].IsAlive() && !finishableEnemiesList.Contains( actors[i] ) )
  5593. || actors[i].IsKnockedUnconscious()
  5594. || this.GetUsedVehicle() == actors[i]
  5595. || !actors[i].CanBeTargeted() )
  5596. {
  5597. actors.EraseFast(i);
  5598. }
  5599. else if ( !IsThreatened() )
  5600. {
  5601. if ( !WasVisibleInScaledFrame( actors[i], 1.f, 1.f ) )
  5602. actors.EraseFast(i);
  5603. }
  5604. }
  5605. }
  5606. else if ( moveTarget && IsThreat( moveTarget ) )
  5607. setIsThreatened = true;
  5608.  
  5609. else
  5610. setIsThreatened = false;
  5611.  
  5612.  
  5613. if ( setIsThreatened )
  5614. {
  5615. enemyCollectionDist = 50.f;
  5616. SetIsThreatened( true );
  5617. }
  5618. else
  5619. {
  5620. if ( IsThreatened() )
  5621. AddTimer( 'finishableEnemiesList', 1.f );
  5622.  
  5623. enemyCollectionDist = findMoveTargetDistMax;
  5624. SetIsThreatened( false );
  5625. }
  5626.  
  5627. moveTargets = actors;
  5628. potentialMoveTargets = moveTargets;
  5629.  
  5630.  
  5631. if ( !moveTarget )
  5632. enableStrafe = false;
  5633.  
  5634. if ( potentialMoveTargets.Size() > 0 )
  5635. {
  5636. for ( i = 0; i < potentialMoveTargets.Size(); i += 1 )
  5637. {
  5638. if ( potentialMoveTargets[i].CanBeStrafed() )
  5639. enableStrafe = true;
  5640.  
  5641. if ( !potentialMoveTargets[i].GetGameplayVisibility() )
  5642. moveTargetDists.PushBack( 100.f );
  5643. else
  5644. moveTargetDists.PushBack( VecDistance( potentialMoveTargets[i].GetNearestPointInPersonalSpace( GetWorldPosition() ), GetWorldPosition() ) );
  5645.  
  5646. if ( canFindPathEnemiesList.Contains( potentialMoveTargets[i] ) )
  5647. {
  5648. moveTargetCanPathFinds.PushBack( true );
  5649. aPotentialMoveTargetCanFindPath = true;
  5650. }
  5651. else
  5652. {
  5653. moveTargetCanPathFinds.PushBack( false );
  5654. }
  5655. }
  5656.  
  5657. if ( aPotentialMoveTargetCanFindPath )
  5658. {
  5659. for ( i = moveTargetCanPathFinds.Size()-1 ; i >= 0; i-=1 )
  5660. {
  5661. if ( !moveTargetCanPathFinds[i] )
  5662. {
  5663. moveTargetCanPathFinds.EraseFast(i);
  5664. potentialMoveTargets.EraseFast(i);
  5665. moveTargetDists.EraseFast(i);
  5666. }
  5667. }
  5668. }
  5669.  
  5670. if ( moveTargetDists.Size() > 0 )
  5671. newMoveTarget = potentialMoveTargets[ ArrayFindMinF( moveTargetDists ) ];
  5672. }
  5673.  
  5674. if ( newMoveTarget && newMoveTarget != moveTarget )
  5675. {
  5676. if ( moveTarget )
  5677. {
  5678. playerToNewMoveTargetDist = VecDistance( newMoveTarget.GetNearestPointInPersonalSpace( GetWorldPosition() ), GetWorldPosition() );
  5679. playerToMoveTargetDist = VecDistance( moveTarget.GetNearestPointInPersonalSpace( GetWorldPosition() ), GetWorldPosition() );
  5680. wasVisibleInFullFrame = WasVisibleInScaledFrame( moveTarget, 1.f, 1.f ) ;
  5681.  
  5682. if ( !IsThreat( moveTarget )
  5683. || !wasVisibleInFullFrame
  5684. || !IsEnemyVisible( moveTarget )
  5685. || ( !moveTarget.IsAlive() && !finishableEnemiesList.Contains( moveTarget ) )
  5686. || !moveTarget.GetGameplayVisibility()
  5687. || ( moveTarget.IsAlive() && moveTarget.IsKnockedUnconscious() )
  5688. || ( wasVisibleInFullFrame && IsEnemyVisible( moveTarget ) && playerToNewMoveTargetDist < playerToMoveTargetDist - 0.25f ) )
  5689. {
  5690. SetMoveTarget( newMoveTarget );
  5691. }
  5692. }
  5693. else
  5694. SetMoveTarget( newMoveTarget );
  5695. }
  5696.  
  5697.  
  5698. if ( !IsThreatened() )
  5699. {
  5700. if ( moveTarget
  5701. && ( ( !moveTarget.IsAlive() && !finishableEnemiesList.Contains( moveTarget ) ) || !WasVisibleInScaledFrame( moveTarget, 0.8f, 1.f ) || VecDistance( moveTarget.GetWorldPosition(), this.GetWorldPosition() ) > theGame.params.MAX_THROW_RANGE ) )
  5702. {
  5703. confirmEmptyMoveTarget = true;
  5704. newEmptyMoveTargetTimer = 0.f;
  5705. }
  5706. }
  5707.  
  5708. else if ( moveTarget && ( IsThreat( moveTarget ) || finishableEnemiesList.Contains( moveTarget ) ) )
  5709. {
  5710. if ( !IsEnemyVisible( moveTarget ) )
  5711. {
  5712. confirmEmptyMoveTarget = true;
  5713. newEmptyMoveTargetTimer = 5.f;
  5714. }
  5715. else
  5716. SetMoveTarget( moveTarget );
  5717. }
  5718. else if ( IsInCombat() )
  5719. {
  5720. confirmEmptyMoveTarget = true;
  5721. newEmptyMoveTargetTimer = 1.0f;
  5722. }
  5723.  
  5724. if ( confirmEmptyMoveTarget )
  5725. {
  5726. if ( newEmptyMoveTargetTimer < emptyMoveTargetTimer )
  5727. {
  5728. bIsConfirmingEmptyTarget = false;
  5729. emptyMoveTargetTimer = newEmptyMoveTargetTimer;
  5730. }
  5731.  
  5732. ConfirmEmptyMoveTarget( newEmptyMoveTargetTimer );
  5733. }
  5734. }
  5735. else
  5736. SetIsThreatened( false );
  5737.  
  5738.  
  5739. if ( IsThreatened() && !IsInFistFightMiniGame() )
  5740. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'CombatNearbyAction', 5.0, 18.0f, -1.f, -1, true );
  5741. else
  5742. theGame.GetBehTreeReactionManager().RemoveReactionEvent( this, 'CombatNearbyAction');
  5743.  
  5744.  
  5745. theSound.SoundParameter( "monster_count", hostileMonsters.Size() );
  5746. }
  5747.  
  5748. private function ConfirmEmptyMoveTarget( timeDelta : float )
  5749. {
  5750. if ( !bIsConfirmingEmptyTarget )
  5751. {
  5752. bIsConfirmingEmptyTarget = true;
  5753. AddTimer( 'ConfirmEmptyTargetTimer', timeDelta );
  5754. }
  5755. }
  5756.  
  5757. private timer function ConfirmEmptyTargetTimer( time : float , id : int)
  5758. {
  5759. SetMoveTarget( NULL );
  5760. }
  5761.  
  5762.  
  5763. var isInCombatReason : int;
  5764. var canFindPathToEnemy : bool;
  5765. var combatModeEnt : CEntity;
  5766. var navDist : float;
  5767. var directDist : float;
  5768. var reachableEnemyWasTooFar : bool;
  5769. var reachableEnemyWasTooFarTimeStamp : float;
  5770. var reachablilityFailed : bool;
  5771. var reachablilityFailedTimeStamp : float;
  5772. public function ShouldEnableCombat( out unableToPathFind : bool, forceCombatMode : bool ) : bool
  5773. {
  5774. var shouldFindPathToNPCs : bool;
  5775. var playerToTargetDist : float;
  5776. var canFindPathToTarget : bool;
  5777. var moveTargetNPC : CNewNPC;
  5778. var currentTime : float;
  5779. var currentTime2 : float;
  5780. var isReachableEnemyTooFar : bool;
  5781. var reachableEnemyWasTooFarTimeStampDelta : float;
  5782. var reachablilityFailedTimeStampDelta : float;
  5783. var currentTimeTemp : float;
  5784.  
  5785.  
  5786.  
  5787. if ( forceCombatMode && isSnappedToNavMesh )
  5788. return true;
  5789.  
  5790. if ( !IsThreatened() )
  5791. {
  5792. reachableEnemyWasTooFar = false;
  5793. reachablilityFailed = false;
  5794. isInCombatReason = 0;
  5795. return false;
  5796. }
  5797.  
  5798. if( thePlayer.substateManager.GetStateCur() != 'CombatExploration' && !thePlayer.substateManager.CanChangeToState( 'CombatExploration' )
  5799. && thePlayer.substateManager.GetStateCur() != 'Ragdoll' )
  5800. {
  5801. reachableEnemyWasTooFar = false;
  5802. reachablilityFailed = false;
  5803. isInCombatReason = 0;
  5804. return false;
  5805. }
  5806.  
  5807. if ( moveTarget )
  5808. {
  5809. canFindPathToEnemy = CanFindPathToTarget( unableToPathFind );
  5810. currentTimeTemp = EngineTimeToFloat( theGame.GetEngineTime() );
  5811.  
  5812. if ( canFindPathToEnemy )
  5813. isReachableEnemyTooFar = IsReachableEnemyTooFar();
  5814.  
  5815. if ( IsInCombat() )
  5816. {
  5817. if ( canFindPathToEnemy )
  5818. {
  5819. if ( forceCombatMode )
  5820. return true;
  5821.  
  5822. reachablilityFailed = false;
  5823. reachablilityFailedTimeStamp = currentTimeTemp;
  5824.  
  5825. if ( reachableEnemyWasTooFar )
  5826. {
  5827. if ( isReachableEnemyTooFar )
  5828. {
  5829. currentTime = currentTimeTemp;
  5830.  
  5831. if ( GetIsSprinting() )
  5832. reachableEnemyWasTooFarTimeStampDelta = 0.f;
  5833. else
  5834. reachableEnemyWasTooFarTimeStampDelta = 3.f;
  5835.  
  5836. if ( currentTime > reachableEnemyWasTooFarTimeStamp + reachableEnemyWasTooFarTimeStampDelta )
  5837. {
  5838. isInCombatReason = 0;
  5839. unableToPathFind = true;
  5840. return false;
  5841. }
  5842. }
  5843. else
  5844. reachableEnemyWasTooFar = false;
  5845. }
  5846. else
  5847. {
  5848. if ( isReachableEnemyTooFar )
  5849. {
  5850. reachableEnemyWasTooFar = true;
  5851. reachableEnemyWasTooFarTimeStamp = currentTimeTemp;
  5852. }
  5853. else
  5854. reachableEnemyWasTooFar = false;
  5855. }
  5856.  
  5857. return true;
  5858. }
  5859. else
  5860. {
  5861. reachableEnemyWasTooFar = false;
  5862. reachableEnemyWasTooFarTimeStamp = currentTimeTemp;
  5863.  
  5864. if ( reachablilityFailed )
  5865. {
  5866. if ( IsEnemyTooHighToReach() )
  5867. reachablilityFailedTimeStampDelta = 1.f;
  5868. else
  5869. reachablilityFailedTimeStampDelta = 5.f;
  5870.  
  5871. currentTime2 = currentTimeTemp;
  5872. if ( currentTime2 > reachablilityFailedTimeStamp + reachablilityFailedTimeStampDelta )
  5873. {
  5874. unableToPathFind = true;
  5875. return false;
  5876. }
  5877. }
  5878. else
  5879. {
  5880. reachablilityFailed = true;
  5881. reachablilityFailedTimeStamp = currentTimeTemp;
  5882. }
  5883.  
  5884. return true;
  5885. }
  5886. }
  5887. else if ( canFindPathToEnemy )
  5888. {
  5889. if ( forceCombatMode )
  5890. {
  5891. reachableEnemyWasTooFar = false;
  5892. return true;
  5893. }
  5894.  
  5895. reachablilityFailed = false;
  5896. reachablilityFailedTimeStamp = currentTimeTemp;
  5897.  
  5898. moveTargetNPC = (CNewNPC)moveTarget;
  5899. playerToTargetDist = VecDistance( moveTarget.GetWorldPosition(), this.GetWorldPosition() );
  5900.  
  5901. if ( reachableEnemyWasTooFar
  5902. && ( isReachableEnemyTooFar || !theGame.GetWorld().NavigationLineTest( this.GetWorldPosition(), moveTarget.GetWorldPosition(), 0.4f ) ) )
  5903. {
  5904. isInCombatReason = 0;
  5905. return false;
  5906. }
  5907. else if ( playerToTargetDist <= findMoveTargetDistMin )
  5908. isInCombatReason = 1;
  5909. else if ( ( moveTargetNPC.GetCurrentStance() == NS_Fly || moveTargetNPC.IsRanged() ) && hostileEnemies.Contains( moveTarget ) )
  5910. isInCombatReason = 2;
  5911. else
  5912. {
  5913. isInCombatReason = 0;
  5914. return false;
  5915. }
  5916.  
  5917. reachableEnemyWasTooFar = false;
  5918. return true;
  5919. }
  5920. }
  5921. else
  5922. {
  5923. reachableEnemyWasTooFar = false;
  5924. reachablilityFailed = false;
  5925. }
  5926.  
  5927. isInCombatReason = 0;
  5928. return false;
  5929. }
  5930.  
  5931. private function CanFindPathToTarget( out unableToPathFind : bool, optional forcedTarget : CNewNPC ) : bool
  5932. {
  5933. var moveTargetNPC : CNewNPC;
  5934. var moveTargetsTemp : array<CActor>;
  5935. var i : int;
  5936. var safeSpotTolerance : float;
  5937. var ent : CEntity;
  5938.  
  5939. moveTargetsTemp = moveTargets;
  5940.  
  5941. for ( i = 0; i < moveTargetsTemp.Size(); i += 1 )
  5942. {
  5943. moveTargetNPC = (CNewNPC)moveTargetsTemp[i];
  5944.  
  5945. if ( moveTargetNPC && moveTargetNPC.GetCurrentStance() == NS_Fly )
  5946. {
  5947. isInCombatReason = 2;
  5948. return true;
  5949. }
  5950. }
  5951.  
  5952. switch ( navQuery.GetLastOutput( 0.4 ) )
  5953. {
  5954. case EAsyncTastResult_Failure:
  5955. {
  5956. isInCombatReason = 0;
  5957. return false;
  5958. }
  5959. case EAsyncTastResult_Success:
  5960. {
  5961. ent = navQuery.GetOutputClosestEntity();
  5962.  
  5963. if ( ent )
  5964. combatModeEnt = moveTarget;
  5965.  
  5966. navDist = navQuery.GetOutputClosestDistance();
  5967.  
  5968. isInCombatReason = 1;
  5969. return true;
  5970. }
  5971. case EAsyncTastResult_Pending:
  5972. {
  5973. return canFindPathToEnemy;
  5974. }
  5975. case EAsyncTastResult_Invalidated:
  5976. {
  5977. if ( IsInCombat() )
  5978. {
  5979. if ( IsEnemyTooHighToReach() )
  5980. safeSpotTolerance = 0.f;
  5981. else
  5982. safeSpotTolerance = 3.f;
  5983. }
  5984. else
  5985. safeSpotTolerance = 0.f;
  5986.  
  5987. switch( navQuery.TestActorsList( ENavigationReachability_Any, this, moveTargetsTemp, safeSpotTolerance, 75.0 ) )
  5988. {
  5989. case EAsyncTastResult_Failure:
  5990. {
  5991. isInCombatReason = 0;
  5992. return false;
  5993. }
  5994. case EAsyncTastResult_Success:
  5995. {
  5996. ent = navQuery.GetOutputClosestEntity();
  5997.  
  5998. if ( ent )
  5999. combatModeEnt = moveTarget;
  6000.  
  6001. navDist = navQuery.GetOutputClosestDistance();
  6002.  
  6003. isInCombatReason = 1;
  6004. return true;
  6005. }
  6006. case EAsyncTastResult_Pending:
  6007. {
  6008. return canFindPathToEnemy;
  6009. }
  6010. case EAsyncTastResult_Invalidated:
  6011. {
  6012. if ( IsInCombat() )
  6013. return true;
  6014. else
  6015. return false;
  6016. }
  6017. }
  6018. }
  6019. }
  6020. }
  6021.  
  6022. private function IsReachableEnemyTooFar() : bool
  6023. {
  6024.  
  6025. var navDistLimit : float = findMoveTargetDist;
  6026. var navDistDivisor : float = 2.f;
  6027. var playerToTargetVector : Vector;
  6028.  
  6029. directDist = VecDistance( combatModeEnt.GetWorldPosition(), thePlayer.GetWorldPosition() );
  6030. playerToTargetVector = this.GetWorldPosition() - combatModeEnt.GetWorldPosition();
  6031.  
  6032. if ( playerMode.GetForceCombatMode() || isInCombatReason == 2 )
  6033. return false;
  6034.  
  6035. if ( ( playerToTargetVector.Z < 0.5 && navDist > navDistLimit && directDist < navDist/navDistDivisor ) )
  6036. return true;
  6037. else
  6038. return false;
  6039. }
  6040.  
  6041. private function IsEnemyTooHighToReach() : bool
  6042. {
  6043. var playerToTargetVector : Vector;
  6044.  
  6045. playerToTargetVector = this.GetWorldPosition() - combatModeEnt.GetWorldPosition();
  6046.  
  6047. if ( playerToTargetVector.Z < -0.5f && !theGame.GetWorld().NavigationLineTest( this.GetWorldPosition(), combatModeEnt.GetWorldPosition(), 0.4f ) )
  6048. return true;
  6049. else
  6050. return false;
  6051. }
  6052.  
  6053.  
  6054. public function LockToMoveTarget( lockTime : float )
  6055. {
  6056.  
  6057. }
  6058.  
  6059. private timer function DisableLockToMoveTargetTimer( time : float , id : int)
  6060. {
  6061. if ( !this.IsActorLockedToTarget() )
  6062. {
  6063. SetMoveTargetChangeAllowed( true );
  6064. }
  6065. }
  6066.  
  6067. public function SetMoveTargetChangeAllowed( flag : bool )
  6068. {
  6069.  
  6070. }
  6071.  
  6072. public function IsMoveTargetChangeAllowed() : bool
  6073. {
  6074. return bMoveTargetChangeAllowed;
  6075. }
  6076.  
  6077. public function SetMoveTarget( actor : CActor )
  6078. {
  6079. if ( !actor && ForceCombatModeOverride() )
  6080. return;
  6081.  
  6082. if ( IsMoveTargetChangeAllowed()
  6083. && moveTarget != actor )
  6084. {
  6085. moveTarget = actor;
  6086. bIsConfirmingEmptyTarget = false;
  6087. RemoveTimer( 'ConfirmEmptyTargetTimer' );
  6088.  
  6089. if ( !moveTarget )
  6090. SetScriptMoveTarget( moveTarget );
  6091. }
  6092. }
  6093.  
  6094. private var isThreatened : bool;
  6095. protected function SetIsThreatened( flag : bool )
  6096. {
  6097. var allowSetIsThreatened : bool;
  6098.  
  6099. allowSetIsThreatened = true;
  6100. if ( ForceCombatModeOverride() )
  6101. {
  6102. if ( flag || !moveTarget )
  6103. allowSetIsThreatened = true;
  6104. else
  6105. allowSetIsThreatened = false;
  6106. }
  6107.  
  6108. if ( allowSetIsThreatened )
  6109. {
  6110. isThreatened = flag;
  6111. }
  6112. }
  6113.  
  6114. public function ForceCombatModeOverride() : bool
  6115. {
  6116. if( this.GetPlayerMode().GetForceCombatMode()
  6117. && canFindPathToEnemy
  6118. && theGame.GetGlobalAttitude( GetBaseAttitudeGroup(), moveTarget.GetBaseAttitudeGroup() ) == AIA_Hostile )
  6119. return true;
  6120. else
  6121. return false;
  6122. }
  6123.  
  6124. public function IsThreatened() : bool { return isThreatened; }
  6125.  
  6126. public function EnableFindTarget( flag : bool )
  6127. {
  6128. var target : CActor;
  6129.  
  6130. if( IsActorLockedToTarget() )
  6131. {
  6132. target = GetTarget();
  6133.  
  6134. if ( target && target.IsAlive() )
  6135. bCanFindTarget = flag;
  6136. else
  6137. bCanFindTarget = true;
  6138. }
  6139. else
  6140. bCanFindTarget = flag;
  6141. }
  6142.  
  6143. public function UpdateDisplayTarget( optional forceUpdate : bool, optional forceNullActor : bool )
  6144. {
  6145. var hud : CR4ScriptedHud;
  6146. var tempTarget : CGameplayEntity;
  6147. var angleDist1 : float;
  6148. var angleDist2 : float;
  6149. var nonActorTargetMult : float;
  6150. var combatActionType : int;
  6151. var currTarget : CActor;
  6152. var interactionTarget : CInteractionComponent;
  6153.  
  6154. var heading : float;
  6155.  
  6156. if(theGame.IsDialogOrCutscenePlaying())
  6157. {
  6158. currentSelectedDisplayTarget = NULL;
  6159.  
  6160. if ( displayTarget )
  6161. ConfirmDisplayTarget( NULL );
  6162.  
  6163. return;
  6164. }
  6165.  
  6166. if ( forceNullActor )
  6167. currTarget = NULL;
  6168. else
  6169. currTarget = GetTarget();
  6170.  
  6171. currentSelectedDisplayTarget = currTarget;
  6172.  
  6173. if ( currTarget && !currTarget.IsTargetableByPlayer() )
  6174. {
  6175. currentSelectedDisplayTarget = NULL;
  6176. ConfirmDisplayTarget( currentSelectedDisplayTarget );
  6177. return;
  6178. }
  6179.  
  6180. nonActorTargetMult = 1.25;
  6181.  
  6182.  
  6183. hud = (CR4ScriptedHud)theGame.GetHud();
  6184.  
  6185. if ( !IsThreatened() )
  6186. {
  6187. if ( !bLAxisReleased || lastAxisInputIsMovement )
  6188. {
  6189. if ( currTarget )
  6190. angleDist1 = AbsF( AngleDistance( this.GetHeading(), VecHeading( currTarget.GetWorldPosition() - this.GetWorldPosition() ) ) );
  6191. else
  6192. angleDist1 = 360;
  6193.  
  6194. if ( nonActorTarget )
  6195. angleDist2 = AbsF( AngleDistance( this.GetHeading(), VecHeading( nonActorTarget.GetWorldPosition() - this.GetWorldPosition() ) ) );
  6196. else
  6197. angleDist2 = 360;
  6198. }
  6199. else
  6200. {
  6201. if ( currTarget )
  6202. angleDist1 = AbsF( AngleDistance( theCamera.GetCameraHeading(), VecHeading( currTarget.GetWorldPosition() - theCamera.GetCameraPosition() ) ) );
  6203. else
  6204. angleDist1 = 360;
  6205.  
  6206. if ( nonActorTarget )
  6207. angleDist2 = AbsF( AngleDistance( theCamera.GetCameraHeading(), VecHeading( nonActorTarget.GetWorldPosition() - theCamera.GetCameraPosition() ) ) );
  6208. else
  6209. angleDist2 = 360;
  6210. }
  6211. }
  6212.  
  6213. else
  6214. {
  6215. if ( !bLAxisReleased )
  6216. {
  6217. if ( ShouldUsePCModeTargeting() )
  6218. {
  6219. if ( currTarget )
  6220. angleDist1 = AbsF( AngleDistance( theCamera.GetCameraHeading(), VecHeading( currTarget.GetWorldPosition() - theCamera.GetCameraPosition() ) ) );
  6221. else
  6222. angleDist1 = 360;
  6223.  
  6224. if ( nonActorTarget && IsInCombatAction() )
  6225. {
  6226. angleDist2 = nonActorTargetMult * AbsF( AngleDistance( theCamera.GetCameraHeading(), VecHeading( nonActorTarget.GetWorldPosition() - theCamera.GetCameraPosition() ) ) );
  6227. }
  6228. else
  6229. angleDist2 = 360;
  6230. }
  6231. else
  6232. {
  6233. if ( currTarget )
  6234. angleDist1 = AbsF( AngleDistance( rawPlayerHeading, VecHeading( currTarget.GetWorldPosition() - this.GetWorldPosition() ) ) );
  6235. else
  6236. angleDist1 = 360;
  6237.  
  6238. if ( nonActorTarget && IsInCombatAction() )
  6239. {
  6240. angleDist2 = nonActorTargetMult * AbsF( AngleDistance( rawPlayerHeading, VecHeading( nonActorTarget.GetWorldPosition() - this.GetWorldPosition() ) ) );
  6241. }
  6242. else
  6243. angleDist2 = 360;
  6244. }
  6245. }
  6246. else
  6247. {
  6248. angleDist1 = 0;
  6249. angleDist2 = 360;
  6250. }
  6251. }
  6252.  
  6253.  
  6254. if ( angleDist1 < angleDist2 )
  6255. tempTarget = currTarget;
  6256. else
  6257. tempTarget = nonActorTarget;
  6258.  
  6259.  
  6260. if ( slideTarget && IsInCombatAction() )
  6261. {
  6262. combatActionType = (int)this.GetBehaviorVariable( 'combatActionType' );
  6263. if ( combatActionType == (int)CAT_Attack
  6264. || ( combatActionType == (int)CAT_SpecialAttack && this.GetBehaviorVariable( 'playerAttackType' ) == 1.f )
  6265. || ( combatActionType == (int)CAT_ItemThrow )
  6266. || ( combatActionType == (int)CAT_CastSign && !IsCurrentSignChanneled() )
  6267. || ( combatActionType == (int)CAT_CastSign && IsCurrentSignChanneled() && GetCurrentlyCastSign() == ST_Axii )
  6268. || ( combatActionType == (int)CAT_CastSign && IsCurrentSignChanneled() && GetCurrentlyCastSign() == ST_Igni )
  6269. || combatActionType == (int)CAT_Dodge
  6270. || combatActionType == (int)CAT_Roll )
  6271. {
  6272. if ( combatActionType == (int)CAT_CastSign && GetCurrentlyCastSign() == ST_Igni && !IsCombatMusicEnabled() )
  6273. currentSelectedDisplayTarget = tempTarget;
  6274. else
  6275. currentSelectedDisplayTarget = slideTarget;
  6276. }
  6277. else
  6278. currentSelectedDisplayTarget = tempTarget;
  6279. }
  6280. else if ( slideTarget
  6281. && this.rangedWeapon
  6282. && this.rangedWeapon.GetCurrentStateName() != 'State_WeaponWait'
  6283. && this.playerAiming.GetCurrentStateName() == 'Waiting' )
  6284. currentSelectedDisplayTarget = slideTarget;
  6285. else
  6286. currentSelectedDisplayTarget = tempTarget;
  6287.  
  6288. interactionTarget = theGame.GetInteractionsManager().GetActiveInteraction();
  6289. if ( interactionTarget && !IsThreatened() && !( this.IsCastingSign() && this.IsCurrentSignChanneled() ) )
  6290. {
  6291. tempTarget = (CGameplayEntity)interactionTarget.GetEntity();
  6292. if ( tempTarget && tempTarget != this.GetUsedVehicle() )
  6293. {
  6294. currentSelectedDisplayTarget = tempTarget;
  6295. SetDisplayTarget( currentSelectedDisplayTarget );
  6296. }
  6297. }
  6298.  
  6299.  
  6300. if ( (CActor)currentSelectedDisplayTarget && !((CActor)currentSelectedDisplayTarget).GetGameplayVisibility() )
  6301. {
  6302. currentSelectedDisplayTarget = NULL;
  6303. }
  6304.  
  6305. if ( displayTarget != currentSelectedDisplayTarget )
  6306. {
  6307. if ( forceUpdate )
  6308. SetDisplayTarget( currentSelectedDisplayTarget );
  6309. else
  6310. ConfirmDisplayTarget( currentSelectedDisplayTarget );
  6311. }
  6312. }
  6313.  
  6314. private var bConfirmDisplayTargetTimerEnabled : bool;
  6315. private var displayTargetToConfirm : CGameplayEntity;
  6316. private var currentSelectedDisplayTarget : CGameplayEntity;
  6317.  
  6318. private function ConfirmDisplayTarget( targetToConfirm : CGameplayEntity )
  6319. {
  6320. if ( targetToConfirm != displayTarget )
  6321. {
  6322. displayTargetToConfirm = targetToConfirm;
  6323. if( !bConfirmDisplayTargetTimerEnabled )
  6324. {
  6325. bConfirmDisplayTargetTimerEnabled = true;
  6326.  
  6327. if ( targetToConfirm )
  6328. AddTimer( 'ConfirmDisplayTargetTimer', 0.1f );
  6329. else
  6330. AddTimer( 'ConfirmDisplayTargetTimer', 0.f );
  6331. }
  6332. }
  6333. }
  6334.  
  6335. private timer function ConfirmDisplayTargetTimer( time : float, optional id : int)
  6336. {
  6337. if ( displayTargetToConfirm == currentSelectedDisplayTarget )
  6338. SetDisplayTarget( displayTargetToConfirm );
  6339.  
  6340. bConfirmDisplayTargetTimerEnabled = false;
  6341. }
  6342.  
  6343.  
  6344. protected function SetDisplayTarget( e : CGameplayEntity )
  6345. {
  6346. var displayTargetActor : CActor;
  6347.  
  6348. if ( e != displayTarget )
  6349. {
  6350. displayTarget = e;
  6351. displayTargetActor = (CActor)displayTarget;
  6352. SetPlayerCombatTarget( displayTargetActor );
  6353.  
  6354. if ( displayTargetActor && !displayTargetActor.IsTargetableByPlayer())
  6355. {
  6356. isDisplayTargetTargetable = false;
  6357. }
  6358. else if ( !displayTargetActor && displayTarget != nonActorTarget )
  6359. {
  6360. isDisplayTargetTargetable = false;
  6361. }
  6362. else
  6363. {
  6364. isDisplayTargetTargetable = true;
  6365. }
  6366. }
  6367. }
  6368.  
  6369. public function GetDisplayTarget() : CGameplayEntity { return displayTarget; }
  6370.  
  6371. private var isDisplayTargetTargetable : bool;
  6372. public function IsDisplayTargetTargetable() : bool
  6373. {
  6374. return isDisplayTargetTargetable;
  6375. }
  6376.  
  6377. public var radialSlots : array<name>;
  6378. public function EnableRadialSlots( enable : bool, slotNames : array<name> )
  6379. {
  6380. var hud : CR4ScriptedHud;
  6381. var module : CR4HudModuleRadialMenu;
  6382. var i : int;
  6383.  
  6384. hud = (CR4ScriptedHud)theGame.GetHud();
  6385. module = (CR4HudModuleRadialMenu)hud.GetHudModule("RadialMenuModule");
  6386.  
  6387. for(i=0; i<slotNames.Size(); i+=1)
  6388. {
  6389. module.SetDesaturated( !enable, slotNames[i] );
  6390. }
  6391. }
  6392.  
  6393. public function IsEnemyInCone( source : CActor, coneHeading : Vector, coneDist, coneAngle : float, out newLockTarget : CActor ) : bool
  6394. {
  6395. var targets : array<CActor>;
  6396. var sourceToTargetDists : array<float>;
  6397. var i : int;
  6398. var targetingInfo : STargetingInfo;
  6399.  
  6400.  
  6401.  
  6402. targets = GetMoveTargets();
  6403.  
  6404. if ( targets.Size() > 0 )
  6405. {
  6406. targetingInfo.source = this;
  6407. targetingInfo.canBeTargetedCheck = true;
  6408. targetingInfo.coneCheck = true;
  6409. targetingInfo.coneHalfAngleCos = CosF( Deg2Rad( coneAngle * 0.5f ) );
  6410. targetingInfo.coneDist = coneDist;
  6411. targetingInfo.coneHeadingVector = coneHeading;
  6412. targetingInfo.distCheck = true;
  6413. targetingInfo.invisibleCheck = true;
  6414. targetingInfo.navMeshCheck = true;
  6415. targetingInfo.inFrameCheck = false;
  6416. targetingInfo.frameScaleX = 1.f;
  6417. targetingInfo.frameScaleY = 1.f;
  6418. targetingInfo.knockDownCheck = false;
  6419. targetingInfo.knockDownCheckDist = 1.5f;
  6420. targetingInfo.rsHeadingCheck = false;
  6421. targetingInfo.rsHeadingLimitCos = 1.0f;
  6422.  
  6423. for( i = targets.Size() - 1; i >= 0; i -= 1 )
  6424. {
  6425. targetingInfo.targetEntity = targets[i];
  6426. if ( !IsEntityTargetable( targetingInfo ) )
  6427. targets.Erase( i );
  6428. }
  6429.  
  6430. for ( i = 0; i < targets.Size(); i += 1 )
  6431. sourceToTargetDists.PushBack( VecDistance( source.GetWorldPosition(), targets[i].GetWorldPosition() ) );
  6432.  
  6433. if(sourceToTargetDists.Size() > 0)
  6434. newLockTarget = targets[ ArrayFindMinF( sourceToTargetDists ) ];
  6435. else
  6436. newLockTarget = NULL;
  6437. }
  6438.  
  6439. return targets.Size() > 0;
  6440. }
  6441.  
  6442. public function GetScreenSpaceLockTarget( sourceEnt : CGameplayEntity, coneAngle, coneDist, coneHeading : float, optional inFrameCheck : bool ) : CActor
  6443. {
  6444. var source : CActor;
  6445. var sourcePos, targetPos : Vector;
  6446. var targets : array<CActor>;
  6447. var sourceToTargetDists : array<float>;
  6448. var sourceCoord : Vector;
  6449. var targetCoord : Vector;
  6450. var i : int;
  6451. var angleDiff : float;
  6452. var sourceToTargetHeading : float;
  6453. var sourceToTargetDist : float;
  6454. var size : float;
  6455. var targetingDist : float;
  6456. var targetingInfo : STargetingInfo;
  6457.  
  6458. var temp : int;
  6459.  
  6460.  
  6461.  
  6462.  
  6463. source = (CActor)sourceEnt;
  6464.  
  6465. targets = GetMoveTargets();
  6466.  
  6467. if ( this.IsPCModeEnabled() )
  6468. {
  6469. if ( ( coneHeading > -45.f && coneHeading < 45.f )
  6470. || coneHeading > 135.f
  6471. || coneHeading < -135.f )
  6472. {
  6473. if ( coneHeading > 0 )
  6474. coneHeading = 180 - coneHeading;
  6475. else
  6476. coneHeading = 180 + coneHeading;
  6477. }
  6478. }
  6479.  
  6480.  
  6481.  
  6482. for( i = targets.Size() - 1; i >= 0; i -= 1 )
  6483. {
  6484. if ( ( !targets[i].GetGameplayVisibility() || !IsThreat( targets[i] ) || !IsEnemyVisible( targets[i] ) || !this.CanBeTargetedIfSwimming( targets[i] ) )
  6485. && ( !IsCastingSign() || GetCurrentlyCastSign() != ST_Axii ) )
  6486. targets.Erase(i);
  6487. }
  6488.  
  6489. if ( source )
  6490. {
  6491. temp = source.GetTorsoBoneIndex();
  6492.  
  6493. if ( temp < 0 )
  6494. sourcePos = source.GetWorldPosition();
  6495. else
  6496. sourcePos = MatrixGetTranslation( source.GetBoneWorldMatrixByIndex( source.GetTorsoBoneIndex() ) );
  6497. }
  6498. else
  6499. sourcePos = sourceEnt.GetWorldPosition();
  6500.  
  6501. theCamera.WorldVectorToViewRatio( sourcePos, sourceCoord.X , sourceCoord.Y );
  6502.  
  6503.  
  6504. targetingDist = softLockDistVehicle;
  6505.  
  6506. if ( targets.Size() > 0 )
  6507. {
  6508. targetingInfo.source = this;
  6509. targetingInfo.canBeTargetedCheck = true;
  6510. targetingInfo.coneCheck = false;
  6511. targetingInfo.coneHalfAngleCos = 0.86602540378f;
  6512. targetingInfo.coneDist = targetingDist;
  6513. targetingInfo.coneHeadingVector = Vector( 0.0f, 1.0f, 0.0f );
  6514. targetingInfo.distCheck = true;
  6515. targetingInfo.invisibleCheck = true;
  6516. targetingInfo.navMeshCheck = false;
  6517.  
  6518. if ( inFrameCheck )
  6519. targetingInfo.inFrameCheck = true;
  6520. else
  6521. targetingInfo.inFrameCheck = false;
  6522.  
  6523. targetingInfo.frameScaleX = 1.f;
  6524. targetingInfo.frameScaleY = 1.f;
  6525. targetingInfo.knockDownCheck = false;
  6526. targetingInfo.knockDownCheckDist = softLockDist;
  6527. if ( bRAxisReleased )
  6528. targetingInfo.rsHeadingCheck = false;
  6529. else
  6530. targetingInfo.rsHeadingCheck = true;
  6531. targetingInfo.rsHeadingLimitCos = -0.5f;
  6532.  
  6533. for( i = targets.Size() - 1; i >= 0; i -= 1 )
  6534. {
  6535. temp = targets[i].GetTorsoBoneIndex();
  6536.  
  6537. if ( temp < 0 )
  6538. targetPos = targets[i].GetWorldPosition();
  6539. else
  6540. targetPos = MatrixGetTranslation( targets[i].GetBoneWorldMatrixByIndex( targets[i].GetTorsoBoneIndex() ) );
  6541.  
  6542. theCamera.WorldVectorToViewRatio( targetPos, targetCoord.X, targetCoord.Y );
  6543. sourceToTargetHeading = VecHeading( targetCoord - sourceCoord );
  6544. angleDiff = AbsF( AngleDistance( coneHeading, sourceToTargetHeading ) );
  6545.  
  6546. targetingInfo.targetEntity = targets[i];
  6547. if ( !IsEntityTargetable( targetingInfo ) )
  6548. targets.Erase( i );
  6549. else if ( !bRAxisReleased && angleDiff > ( coneAngle * 0.5 ) )
  6550. targets.Erase( i );
  6551. else if ( targets[i] == sourceEnt )
  6552. targets.Erase( i );
  6553.  
  6554.  
  6555. }
  6556. }
  6557.  
  6558. size = targets.Size();
  6559. if ( size > 0 )
  6560. {
  6561. for ( i = 0; i < targets.Size(); i += 1 )
  6562. {
  6563. temp = targets[i].GetTorsoBoneIndex();
  6564.  
  6565. if ( temp < 0 )
  6566. targetPos = targets[i].GetWorldPosition();
  6567. else
  6568. targetPos = MatrixGetTranslation( targets[i].GetBoneWorldMatrixByIndex( targets[i].GetTorsoBoneIndex() ) );
  6569.  
  6570. theCamera.WorldVectorToViewRatio( targetPos, targetCoord.X, targetCoord.Y );
  6571. sourceToTargetHeading = AbsF( VecHeading( targetCoord - sourceCoord ) );
  6572. angleDiff = AngleDistance( 180, sourceToTargetHeading );
  6573. sourceToTargetDist = VecDistance2D( sourceCoord, targetCoord );
  6574.  
  6575. sourceToTargetDists.PushBack( SinF( Deg2Rad( angleDiff ) ) * sourceToTargetDist );
  6576. }
  6577. }
  6578.  
  6579. if ( targets.Size() > 0 )
  6580. return targets[ ArrayFindMinF( sourceToTargetDists ) ];
  6581. else
  6582. return NULL;
  6583. }
  6584.  
  6585. public function IsEntityTargetable( out info : STargetingInfo, optional usePrecalcs : bool ) : bool
  6586. {
  6587. var playerHasBlockingBuffs : bool;
  6588. var sourceActor : CActor;
  6589. var targetEntity : CEntity;
  6590. var targetActor : CActor;
  6591. var targetNPC : CNewNPC;
  6592. var sourcePosition : Vector;
  6593. var targetPosition : Vector;
  6594. var direction : Vector;
  6595. var sourceToTargetDist : float;
  6596. var sourceCapsuleRadius : float;
  6597. var mpac : CMovingPhysicalAgentComponent;
  6598.  
  6599. var coneDistSq : float;
  6600. var knockDownCheckDistSq : float;
  6601. var sourceToTargetAngleDist : float;
  6602. var b : bool;
  6603. var infoSourceWorldPos : Vector;
  6604. var infoTargetWorldPos : Vector;
  6605. var finishEnabled : bool;
  6606.  
  6607. if ( usePrecalcs )
  6608. {
  6609. playerHasBlockingBuffs = targetingIn.playerHasBlockingBuffs;
  6610. }
  6611. else
  6612. {
  6613. playerHasBlockingBuffs = thePlayer.HasBuff( EET_Confusion ) || thePlayer.HasBuff( EET_Hypnotized ) || thePlayer.HasBuff( EET_Blindness ) || thePlayer.HasBuff( EET_WraithBlindness );
  6614. }
  6615. if ( playerHasBlockingBuffs )
  6616. {
  6617. return false;
  6618. }
  6619.  
  6620. sourceActor = info.source;
  6621. targetEntity = info.targetEntity;
  6622. if ( !sourceActor || !targetEntity )
  6623. {
  6624. return false;
  6625. }
  6626.  
  6627. targetActor = (CActor)targetEntity;
  6628.  
  6629.  
  6630. if ( info.canBeTargetedCheck && !targetActor.CanBeTargeted() )
  6631. {
  6632. return false;
  6633. }
  6634.  
  6635.  
  6636. if ( info.invisibleCheck && !targetActor.GetGameplayVisibility() )
  6637. {
  6638. return false;
  6639. }
  6640.  
  6641. sourcePosition = sourceActor.GetWorldPosition();
  6642. targetPosition = targetEntity.GetWorldPosition();
  6643.  
  6644. if ( targetActor )
  6645. {
  6646. {
  6647. targetNPC = (CNewNPC)targetActor;
  6648. if ( targetNPC )
  6649. {
  6650. if ( targetNPC.IsHorse() && !targetNPC.GetHorseComponent().IsDismounted() )
  6651. {
  6652. return false;
  6653. }
  6654. }
  6655. }
  6656. }
  6657.  
  6658. if ( info.distCheck || info.knockDownCheck )
  6659. {
  6660. if ( usePrecalcs )
  6661. {
  6662. if ( targetActor )
  6663. {
  6664.  
  6665. sourceToTargetDist = Distance2DBetweenCapsuleAndPoint( targetActor, sourceActor ) - targetingPrecalcs.playerRadius;
  6666. }
  6667. else
  6668. {
  6669. sourceToTargetDist = VecDistance2D( sourcePosition, targetPosition ) - targetingPrecalcs.playerRadius;
  6670. }
  6671. }
  6672. else
  6673. {
  6674. if ( targetActor )
  6675. {
  6676. sourceToTargetDist = Distance2DBetweenCapsules( sourceActor, targetActor );
  6677. }
  6678. else
  6679. {
  6680. sourceToTargetDist = Distance2DBetweenCapsuleAndPoint( sourceActor, targetEntity );
  6681. }
  6682. }
  6683. }
  6684.  
  6685.  
  6686. if ( info.distCheck )
  6687. {
  6688. if ( sourceToTargetDist >= info.coneDist )
  6689. {
  6690. return false;
  6691. }
  6692. }
  6693.  
  6694.  
  6695. if ( info.coneCheck || info.rsHeadingCheck )
  6696. {
  6697. direction = VecNormalize2D( targetPosition - sourcePosition );
  6698. }
  6699.  
  6700.  
  6701. if ( info.coneCheck )
  6702. {
  6703. if ( VecDot2D( direction, info.coneHeadingVector ) < info.coneHalfAngleCos )
  6704. {
  6705. return false;
  6706. }
  6707. }
  6708.  
  6709.  
  6710. if ( info.rsHeadingCheck )
  6711. {
  6712. if ( usePrecalcs )
  6713. {
  6714. if ( VecDot2D( direction, targetingIn.lookAtDirection ) < info.rsHeadingLimitCos )
  6715. {
  6716. return false;
  6717. }
  6718. }
  6719. else
  6720. {
  6721. if ( VecDot2D( direction, VecNormalize2D( GetLookAtPosition() - sourcePosition ) ) < info.rsHeadingLimitCos )
  6722. {
  6723. return false;
  6724. }
  6725. }
  6726. }
  6727.  
  6728.  
  6729. if ( info.inFrameCheck && !WasVisibleInScaledFrame( targetEntity, info.frameScaleX, info.frameScaleY ) )
  6730. {
  6731. return false;
  6732. }
  6733.  
  6734.  
  6735. if ( info.navMeshCheck && !IsSwimming() )
  6736. {
  6737. sourceCapsuleRadius = 0.1f;
  6738. if ( usePrecalcs )
  6739. {
  6740. sourceCapsuleRadius = targetingPrecalcs.playerRadius;
  6741. }
  6742. else
  6743. {
  6744. mpac = (CMovingPhysicalAgentComponent)sourceActor.GetMovingAgentComponent();
  6745. if ( mpac )
  6746. {
  6747. sourceCapsuleRadius = mpac.GetCapsuleRadius();
  6748. }
  6749. }
  6750. if ( !theGame.GetWorld().NavigationLineTest( sourcePosition, targetPosition, sourceCapsuleRadius ) )
  6751. {
  6752. return false;
  6753. }
  6754. }
  6755.  
  6756.  
  6757. if ( info.knockDownCheck )
  6758. {
  6759.  
  6760. if ( targetActor && !targetActor.IsAlive() )
  6761. {
  6762.  
  6763. finishEnabled = targetActor.GetComponent( 'Finish' ).IsEnabled();
  6764. if ( finishEnabled )
  6765. {
  6766.  
  6767. if ( finishableEnemiesList.Contains( targetActor ) )
  6768. {
  6769.  
  6770. if ( sourceToTargetDist >= info.knockDownCheckDist )
  6771. {
  6772. return false;
  6773. }
  6774. }
  6775. }
  6776. }
  6777. }
  6778.  
  6779. return true;
  6780. }
  6781.  
  6782. public function CanBeTargetedIfSwimming( actor : CActor, optional usePrecalcs : bool ) : bool
  6783. {
  6784. var subDepth : float;
  6785. var isDiving : bool;
  6786.  
  6787. if ( !actor )
  6788. {
  6789. return false;
  6790. }
  6791.  
  6792. if ( usePrecalcs )
  6793. {
  6794. isDiving = targetingIn.isDiving;
  6795. }
  6796. else
  6797. {
  6798. isDiving = IsSwimming() && OnCheckDiving();
  6799. }
  6800.  
  6801. subDepth = ((CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent()).GetSubmergeDepth();
  6802.  
  6803. if ( isDiving )
  6804. {
  6805. return ( subDepth < -1.0f );
  6806. }
  6807. else
  6808. {
  6809. return ( subDepth >= -1.0f );
  6810. }
  6811. }
  6812.  
  6813.  
  6814. private function FilterActors( out targets : array<CActor>, out onlyThreatsReturned : bool, optional usePrecalcs : bool )
  6815. {
  6816. var i : int;
  6817. var size : int;
  6818. var foundThreat : bool;
  6819. var foundNonThreat : bool;
  6820. var threatsCount : int;
  6821. var tmpActor : CActor;
  6822.  
  6823. foundThreat = false;
  6824. foundNonThreat = false;
  6825.  
  6826. size = targets.Size();
  6827. i = 0;
  6828. threatsCount = 0;
  6829.  
  6830.  
  6831. for ( i = 0; i < size; i+=1 )
  6832. {
  6833. if( IsThreat( targets[ i ], usePrecalcs ) )
  6834. {
  6835. foundThreat = true;
  6836. if ( i != threatsCount )
  6837. {
  6838. tmpActor = targets[ i ];
  6839. targets[ i ] = targets[ threatsCount ];
  6840. targets[ threatsCount ] = tmpActor;
  6841. }
  6842. threatsCount += 1;
  6843. }
  6844. else
  6845. {
  6846. foundNonThreat = true;
  6847. }
  6848. }
  6849.  
  6850. if ( foundThreat )
  6851. {
  6852. onlyThreatsReturned = true;
  6853. if ( foundNonThreat )
  6854. {
  6855. targets.Resize( threatsCount );
  6856. }
  6857. }
  6858. }
  6859.  
  6860. private function InternalFindTargetsInCone( out targets : array< CActor >, out outHeadingVector : Vector, optional usePrecalcs : bool )
  6861. {
  6862. var size, i : int;
  6863. var coneHalfAngleDot : float;
  6864. var coneHeading : float;
  6865. var coneHeadingVector : Vector;
  6866. var position : Vector;
  6867. var direction : Vector;
  6868. var onlyThreatTargetsFound : bool;
  6869.  
  6870. targets.Clear();
  6871. GetVisibleEnemies( targets );
  6872.  
  6873.  
  6874. for( i = 0; i < finishableEnemiesList.Size() ; i+=1 )
  6875. {
  6876. if ( !targets.Contains( finishableEnemiesList[i] ) )
  6877. {
  6878. targets.PushBack( finishableEnemiesList[i] );
  6879. }
  6880. }
  6881.  
  6882. onlyThreatTargetsFound = false;
  6883. FilterActors( targets, onlyThreatTargetsFound, true );
  6884.  
  6885. if ( IsCombatMusicEnabled() && targets.Size() > 0 && !onlyThreatTargetsFound && !IsThreat( targets[0], usePrecalcs ) )
  6886. {
  6887. targets.Clear();
  6888. }
  6889.  
  6890. coneHeading = 0.0f;
  6891. coneHalfAngleDot = 0.0f;
  6892. if ( ( orientationTarget == OT_Camera ) || ( orientationTarget == OT_CameraOffset ) )
  6893. {
  6894. if ( usePrecalcs )
  6895. {
  6896. coneHeading = targetingPrecalcs.cameraHeading;
  6897. }
  6898. else
  6899. {
  6900. coneHeading = theGame.GetGameCamera().GetHeading();
  6901. }
  6902. coneHalfAngleDot = 0.5f;
  6903. }
  6904. else
  6905. {
  6906. if ( IsSwimming() )
  6907. {
  6908. if ( usePrecalcs )
  6909. {
  6910. coneHeading = targetingPrecalcs.cameraHeading;
  6911. }
  6912. else
  6913. {
  6914. coneHeading = theGame.GetGameCamera().GetHeading();
  6915. }
  6916. coneHalfAngleDot = 0.17364817766f;
  6917. }
  6918. else if ( bLAxisReleased )
  6919. {
  6920. if( IsInCombatAction() )
  6921. {
  6922. coneHeading = GetCombatActionHeading();
  6923. }
  6924. else
  6925. {
  6926. if ( ShouldUsePCModeTargeting() )
  6927. coneHeading = theGame.GetGameCamera().GetHeading();
  6928. else
  6929. coneHeading = cachedRawPlayerHeading;
  6930. }
  6931.  
  6932. if ( IsInCombat() )
  6933. {
  6934. if ( ShouldUsePCModeTargeting() )
  6935. coneHalfAngleDot = -1;
  6936. else
  6937. coneHalfAngleDot = 0.17364817766f;
  6938. }
  6939. else
  6940. {
  6941. coneHalfAngleDot = -1.0f;
  6942. }
  6943. }
  6944. else
  6945. {
  6946. if( IsInCombatAction() )
  6947. {
  6948. coneHeading = GetCombatActionHeading();
  6949. }
  6950. else
  6951. {
  6952. if ( ShouldUsePCModeTargeting() )
  6953. coneHeading = theGame.GetGameCamera().GetHeading();
  6954. else
  6955. coneHeading = cachedRawPlayerHeading;
  6956. }
  6957.  
  6958. if ( ShouldUsePCModeTargeting() )
  6959. coneHalfAngleDot = -1;
  6960. else
  6961. coneHalfAngleDot = 0.17364817766f;
  6962. }
  6963.  
  6964. coneHeadingVector = VecFromHeading( coneHeading );
  6965. position = this.GetWorldPosition();
  6966.  
  6967. for ( i = targets.Size() - 1; i >= 0; i -= 1 )
  6968. {
  6969. if ( !targets[i] )
  6970. {
  6971. targets.EraseFast(i);
  6972. continue;
  6973. }
  6974.  
  6975. direction = VecNormalize2D( targets[i].GetWorldPosition() - position );
  6976.  
  6977. if ( VecDot2D( coneHeadingVector, direction ) < coneHalfAngleDot )
  6978. {
  6979. targets.EraseFast( i );
  6980. }
  6981. }
  6982. }
  6983.  
  6984. outHeadingVector = coneHeadingVector;
  6985. }
  6986.  
  6987.  
  6988.  
  6989.  
  6990. function InitTargeting()
  6991. {
  6992. var consts : SR4PlayerTargetingConsts;
  6993.  
  6994. if ( !targeting )
  6995. {
  6996. targeting = new CR4PlayerTargeting in this;
  6997. }
  6998. if ( targeting )
  6999. {
  7000. consts.softLockDistance = this.softLockDist;
  7001. consts.softLockFrameSize = this.softLockFrameSize;
  7002. targeting.SetConsts( consts );
  7003. }
  7004. }
  7005.  
  7006. function PrepareTargetingIn( actionCheck : bool, bufferActionType : EBufferActionType, actionInput : bool )
  7007. {
  7008. var coneDist : float;
  7009.  
  7010. if ( actionCheck && bufferActionType == EBAT_ItemUse )
  7011. {
  7012. coneDist = findMoveTargetDist;
  7013. }
  7014. else if ( IsSwimming() )
  7015. {
  7016. coneDist = theGame.params.MAX_THROW_RANGE;
  7017. }
  7018. else if ( ( GetPlayerCombatStance() == PCS_AlertNear ) && ( ( playerMoveType == PMT_Walk ) || ( playerMoveType == PMT_Idle ) ) )
  7019. {
  7020. coneDist = softLockDist;
  7021. }
  7022. else
  7023. {
  7024. coneDist = findMoveTargetDist;
  7025. }
  7026.  
  7027. targetingIn.canFindTarget = this.bCanFindTarget;
  7028. targetingIn.playerHasBlockingBuffs = thePlayer.HasBuff( EET_Confusion ) || thePlayer.HasBuff( EET_Hypnotized ) || thePlayer.HasBuff( EET_Blindness ) || thePlayer.HasBuff( EET_WraithBlindness );
  7029. targetingIn.isHardLockedToTarget = this.IsHardLockEnabled();
  7030. targetingIn.isActorLockedToTarget = this.IsActorLockedToTarget();
  7031. targetingIn.isCameraLockedToTarget = this.IsCameraLockedToTarget();
  7032. targetingIn.actionCheck = actionCheck;
  7033. targetingIn.actionInput = actionInput;
  7034. targetingIn.isInCombatAction = this.IsInCombatAction();
  7035. targetingIn.isLAxisReleased = this.bLAxisReleased;
  7036. targetingIn.isLAxisReleasedAfterCounter = this.lAxisReleasedAfterCounter;
  7037. targetingIn.isLAxisReleasedAfterCounterNoCA = this.lAxisReleasedAfterCounterNoCA;
  7038. targetingIn.lastAxisInputIsMovement = this.lastAxisInputIsMovement;
  7039. targetingIn.isAiming = this.playerAiming.GetCurrentStateName() == 'Aiming';
  7040. targetingIn.isSwimming = this.IsSwimming();
  7041. targetingIn.isDiving = this.IsSwimming() && OnCheckDiving();
  7042. targetingIn.isThreatened = this.IsThreatened();
  7043. targetingIn.isCombatMusicEnabled = this.IsCombatMusicEnabled();
  7044. targetingIn.isPcModeEnabled = this.IsPCModeEnabled();
  7045. targetingIn.isInParryOrCounter = this.isInParryOrCounter;
  7046. targetingIn.shouldUsePcModeTargeting = this.ShouldUsePCModeTargeting();
  7047. targetingIn.bufferActionType = bufferActionType;
  7048. targetingIn.orientationTarget = this.GetOrientationTarget();
  7049. targetingIn.coneDist = coneDist;
  7050. targetingIn.findMoveTargetDist = this.findMoveTargetDist;
  7051. targetingIn.cachedRawPlayerHeading = this.cachedRawPlayerHeading;
  7052. targetingIn.combatActionHeading = this.GetCombatActionHeading();
  7053. targetingIn.rawPlayerHeadingVector = VecFromHeading( this.rawPlayerHeading );
  7054. targetingIn.lookAtDirection = VecNormalize2D( this.GetLookAtPosition() - GetWorldPosition() );
  7055. targetingIn.moveTarget = this.moveTarget;
  7056. targetingIn.aimingTarget = this.playerAiming.GetAimedTarget();
  7057. targetingIn.displayTarget = (CActor)this.displayTarget;
  7058. targetingIn.finishableEnemies = this.finishableEnemiesList;
  7059. targetingIn.hostileEnemies = this.hostileEnemies;
  7060. targetingIn.defaultSelectionWeights = ProcessSelectionWeights();
  7061. }
  7062.  
  7063. function ResetTargetingOut()
  7064. {
  7065. targetingOut.target = NULL;
  7066. targetingOut.result = false;
  7067. targetingOut.confirmNewTarget = false;
  7068. targetingOut.forceDisableUpdatePosition = false;
  7069. }
  7070.  
  7071. function MakeFindTargetPrecalcs()
  7072. {
  7073. var mpac : CMovingPhysicalAgentComponent;
  7074.  
  7075. targetingPrecalcs.playerPosition = thePlayer.GetWorldPosition();
  7076. targetingPrecalcs.playerHeading = thePlayer.GetHeading();
  7077. targetingPrecalcs.playerHeadingVector = thePlayer.GetHeadingVector();
  7078. targetingPrecalcs.playerHeadingVector.Z = 0;
  7079. targetingPrecalcs.playerHeadingVector = VecNormalize2D( targetingPrecalcs.playerHeadingVector );
  7080.  
  7081. targetingPrecalcs.playerRadius = 0.5f;
  7082. mpac = (CMovingPhysicalAgentComponent)thePlayer.GetMovingAgentComponent();
  7083. if ( mpac )
  7084. {
  7085. targetingPrecalcs.playerRadius = mpac.GetCapsuleRadius();
  7086. }
  7087.  
  7088. targetingPrecalcs.cameraPosition = theCamera.GetCameraPosition();
  7089. targetingPrecalcs.cameraDirection = theCamera.GetCameraDirection();
  7090. targetingPrecalcs.cameraHeadingVector = targetingPrecalcs.cameraDirection;
  7091. targetingPrecalcs.cameraHeadingVector.Z = 0;
  7092. targetingPrecalcs.cameraHeadingVector = VecNormalize2D( targetingPrecalcs.cameraHeadingVector );
  7093. targetingPrecalcs.cameraHeading = VecHeading( targetingPrecalcs.cameraHeadingVector );
  7094. }
  7095.  
  7096. public function GetForceDisableUpdatePosition() : bool
  7097. {
  7098. return targetingOut.forceDisableUpdatePosition;
  7099. }
  7100.  
  7101. public function SetUseNativeTargeting( use : bool )
  7102. {
  7103. useNativeTargeting = use;
  7104. }
  7105.  
  7106. protected function FindTarget( optional actionCheck : bool, optional action : EBufferActionType, optional actionInput : bool ) : CActor
  7107. {
  7108. if ( IsCombatMusicEnabled() && !IsInCombat() && reachableEnemyWasTooFar )
  7109. {
  7110. playerMode.UpdateCombatMode();
  7111. }
  7112.  
  7113. PrepareTargetingIn( actionCheck, action, actionInput );
  7114. if ( useNativeTargeting )
  7115. {
  7116. targeting.BeginFindTarget( targetingIn );
  7117. targeting.FindTarget();
  7118. targeting.EndFindTarget( targetingOut );
  7119. }
  7120. else
  7121. {
  7122. UpdateVisibleActors();
  7123. MakeFindTargetPrecalcs();
  7124. ResetTargetingOut();
  7125. FindTarget_Scripted();
  7126. }
  7127. if ( targetingOut.result )
  7128. {
  7129. if ( targetingOut.confirmNewTarget )
  7130. {
  7131. ConfirmNewTarget( targetingOut.target );
  7132. }
  7133. return targetingOut.target;
  7134. }
  7135. return NULL;
  7136. }
  7137.  
  7138. protected function FindTarget_Scripted()
  7139. {
  7140. var currentTarget : CActor;
  7141. var newTarget : CActor;
  7142. var selectedTarget : CActor;
  7143. var displayTargetActor : CActor;
  7144. var playerPosition : Vector;
  7145. var playerHeadingVector : Vector;
  7146. var cameraPosition : Vector;
  7147. var cameraHeadingVector : Vector;
  7148. var selectionHeadingVector : Vector;
  7149. var targetingInfo : STargetingInfo;
  7150. var selectionWeights : STargetSelectionWeights;
  7151. var targets : array< CActor >;
  7152. var isMoveTargetTargetable : bool;
  7153. var targetChangeFromActionInput : bool;
  7154. var retainCurrentTarget : bool;
  7155.  
  7156.  
  7157.  
  7158. playerPosition = this.GetWorldPosition();
  7159. playerHeadingVector = targetingPrecalcs.playerHeadingVector;
  7160. cameraPosition = theCamera.GetCameraPosition();
  7161. cameraHeadingVector = targetingPrecalcs.cameraHeadingVector;
  7162.  
  7163. currentTarget = GetTarget();
  7164. if ( currentTarget )
  7165. {
  7166. if ( IsHardLockEnabled() && currentTarget.IsAlive() && !currentTarget.IsKnockedUnconscious() )
  7167. {
  7168. if ( VecDistanceSquared( playerPosition, currentTarget.GetWorldPosition() ) > 50.f * 50.0f )
  7169. {
  7170. HardLockToTarget( false );
  7171. }
  7172. else
  7173. {
  7174. targetingOut.target = currentTarget;
  7175. targetingOut.result = true;
  7176. return;
  7177. }
  7178. }
  7179. GetVisualDebug().AddSphere('target', 1.0f, currentTarget.GetWorldPosition(), true, Color( 255, 255, 0 ), 1.0f );
  7180. }
  7181.  
  7182. if ( bCanFindTarget && !IsActorLockedToTarget() )
  7183. {
  7184. if ( !targetingIn.playerHasBlockingBuffs )
  7185. {
  7186. InternalFindTargetsInCone( targets, selectionHeadingVector, true );
  7187. }
  7188.  
  7189. targetingInfo.source = this;
  7190. targetingInfo.canBeTargetedCheck = true;
  7191. targetingInfo.coneCheck = false;
  7192. targetingInfo.coneHalfAngleCos = 1.0f;
  7193. targetingInfo.coneDist = targetingIn.coneDist;
  7194. targetingInfo.distCheck = true;
  7195. targetingInfo.invisibleCheck = true;
  7196. targetingInfo.navMeshCheck = false;
  7197.  
  7198. if ( ShouldUsePCModeTargeting() )
  7199. targetingInfo.inFrameCheck = false;
  7200. else
  7201. targetingInfo.inFrameCheck = true;
  7202.  
  7203. targetingInfo.frameScaleX = 1.0f;
  7204. targetingInfo.frameScaleY = 1.0f;
  7205. targetingInfo.knockDownCheck = false;
  7206. targetingInfo.knockDownCheckDist = 1.5f;
  7207. targetingInfo.rsHeadingCheck = false;
  7208. targetingInfo.rsHeadingLimitCos = 1.0f;
  7209.  
  7210. if ( currentTarget )
  7211. {
  7212. targetingInfo.targetEntity = currentTarget;
  7213. if ( !IsEntityTargetable( targetingInfo, true ) )
  7214. {
  7215. currentTarget = NULL;
  7216. }
  7217. if ( currentTarget && !CanBeTargetedIfSwimming( currentTarget, true ) )
  7218. {
  7219. currentTarget = NULL;
  7220. }
  7221. }
  7222.  
  7223. isMoveTargetTargetable = false;
  7224. if ( moveTarget )
  7225. {
  7226. if ( CanBeTargetedIfSwimming( moveTarget, true ) )
  7227. {
  7228. targetingInfo.targetEntity = moveTarget;
  7229. targetingInfo.coneDist = findMoveTargetDist;
  7230. targetingInfo.inFrameCheck = false;
  7231. if ( IsEntityTargetable( targetingInfo, true ) )
  7232. {
  7233. isMoveTargetTargetable = true;
  7234. }
  7235. }
  7236. }
  7237.  
  7238.  
  7239. targetingInfo.coneDist = targetingIn.coneDist;
  7240.  
  7241. if ( !targetingIn.playerHasBlockingBuffs )
  7242. {
  7243. RemoveNonTargetable( targets, targetingInfo, selectionHeadingVector );
  7244. }
  7245.  
  7246. newTarget = NULL;
  7247. if ( this.playerAiming.GetCurrentStateName() == 'Aiming' )
  7248. {
  7249. newTarget = this.playerAiming.GetAimedTarget();
  7250. if ( !newTarget )
  7251. {
  7252. selectionWeights.angleWeight = 1.f;
  7253. selectionWeights.distanceWeight = 0.f;
  7254. selectionWeights.distanceRingWeight = 0.f;
  7255.  
  7256. selectedTarget = SelectTarget( targets, false, cameraPosition, cameraHeadingVector, selectionWeights, true );
  7257. newTarget = selectedTarget;
  7258. }
  7259. }
  7260. else if ( IsSwimming() )
  7261. {
  7262. selectionWeights.angleWeight = 0.9f;
  7263. selectionWeights.distanceWeight = 0.1f;
  7264. selectionWeights.distanceRingWeight = 0.f;
  7265.  
  7266. selectedTarget = SelectTarget( targets, true, cameraPosition, cameraHeadingVector, selectionWeights, true );
  7267. newTarget = selectedTarget;
  7268. }
  7269. else if ( IsThreatened() )
  7270. {
  7271.  
  7272. if ( IsCameraLockedToTarget() )
  7273. {
  7274. if ( currentTarget && !currentTarget.GetGameplayVisibility() )
  7275. {
  7276. ForceSelectLockTarget();
  7277. }
  7278. }
  7279.  
  7280. displayTargetActor = (CActor)displayTarget;
  7281. selectedTarget = SelectTarget( targets, true, playerPosition, selectionHeadingVector, targetingIn.defaultSelectionWeights, true );
  7282.  
  7283. if ( !selectedTarget )
  7284. {
  7285. targetingOut.forceDisableUpdatePosition = true;
  7286. }
  7287.  
  7288. targetChangeFromActionInput = targetingIn.actionInput && !lAxisReleasedAfterCounter;
  7289. if ( selectedTarget &&
  7290. ( !IsThreat( currentTarget, true ) || ShouldUsePCModeTargeting() || ( !IsInCombatAction() && !lAxisReleasedAfterCounterNoCA ) || targetChangeFromActionInput ) )
  7291. {
  7292. newTarget = selectedTarget;
  7293. }
  7294. else if ( displayTargetActor &&
  7295. ( ( bLAxisReleased && !ShouldUsePCModeTargeting() )|| IsInCombatAction() ) &&
  7296. ( displayTargetActor.IsAlive() || finishableEnemiesList.Contains( displayTargetActor ) ) &&
  7297. displayTargetActor.GetGameplayVisibility() &&
  7298. ( IsEnemyVisible( displayTargetActor ) || finishableEnemiesList.Contains( displayTargetActor ) ) &&
  7299. this.CanBeTargetedIfSwimming( displayTargetActor, true ) &&
  7300. IsThreat( displayTargetActor, true ) &&
  7301. WasVisibleInScaledFrame( displayTargetActor, 1.f, 1.f ) )
  7302. {
  7303. newTarget = displayTargetActor;
  7304. }
  7305.  
  7306.  
  7307. else if ( moveTarget &&
  7308. isMoveTargetTargetable &&
  7309. ( !IsInCombatAction() || isInParryOrCounter || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Dodge || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Roll ) )
  7310. {
  7311. newTarget = moveTarget;
  7312. }
  7313. else
  7314. {
  7315. newTarget = NULL;
  7316. }
  7317. }
  7318. else
  7319. {
  7320. retainCurrentTarget = false;
  7321. if ( lAxisReleasedAfterCounterNoCA )
  7322. {
  7323. if ( lastAxisInputIsMovement && !this.IsSwimming())
  7324. {
  7325. selectionWeights.angleWeight = 0.375f;
  7326. selectionWeights.distanceWeight = 0.275f;
  7327. selectionWeights.distanceRingWeight = 0.35f;
  7328. selectedTarget = SelectTarget( targets, false, playerPosition, playerHeadingVector, selectionWeights, true );
  7329.  
  7330. if ( currentTarget != selectedTarget )
  7331. {
  7332. targetingInfo.targetEntity = currentTarget;
  7333. if ( IsEntityTargetable( targetingInfo, true ) && currentTarget.IsAlive() )
  7334. {
  7335. retainCurrentTarget = true;
  7336. }
  7337. }
  7338. }
  7339. else
  7340. {
  7341. selectionWeights.angleWeight = 0.75f;
  7342. selectionWeights.distanceWeight = 0.125f;
  7343. selectionWeights.distanceRingWeight = 0.125f;
  7344. selectedTarget = SelectTarget( targets, false, cameraPosition, cameraHeadingVector, selectionWeights, true );
  7345. }
  7346. }
  7347. else
  7348. {
  7349. selectionWeights.angleWeight = 0.6f;
  7350. selectionWeights.distanceWeight = 0.4f;
  7351. selectionWeights.distanceRingWeight = 0.f;
  7352. selectedTarget = SelectTarget( targets, true, playerPosition, targetingIn.rawPlayerHeadingVector, selectionWeights, true );
  7353. }
  7354.  
  7355. if ( retainCurrentTarget )
  7356. {
  7357. newTarget = currentTarget;
  7358. }
  7359. else if ( IsInCombatAction() && GetBehaviorVariable( 'isPerformingSpecialAttack' ) == 1.0f )
  7360. {
  7361. newTarget = moveTarget;
  7362. }
  7363. else if ( selectedTarget )
  7364. {
  7365. newTarget = selectedTarget;
  7366. }
  7367. else
  7368. {
  7369. newTarget = NULL;
  7370. }
  7371. }
  7372.  
  7373. targetingOut.confirmNewTarget = true;
  7374. }
  7375. else
  7376. {
  7377. newTarget = NULL;
  7378. }
  7379.  
  7380. targetingOut.result = true;
  7381. targetingOut.target = newTarget;
  7382. }
  7383.  
  7384. function UpdateVisibleActors()
  7385. {
  7386. var i : int;
  7387. var now : float;
  7388.  
  7389. now = theGame.GetEngineTimeAsSeconds();
  7390. for ( i = visibleActors.Size() - 1; i >= 0; i-=1 )
  7391. {
  7392.  
  7393. if ( ( now - visibleActorsTime[i] ) > 1.0f )
  7394. {
  7395. visibleActors.EraseFast( i );
  7396. visibleActorsTime.EraseFast( i );
  7397. }
  7398. }
  7399. }
  7400.  
  7401. function RemoveNonTargetable( out targets : array< CActor >, out info : STargetingInfo, selectionHeadingVector : Vector )
  7402. {
  7403. var i : int;
  7404. var cameraPosition : Vector;
  7405. var cameraDirection : Vector;
  7406. var nonCombatCheck : bool;
  7407. var playerToCamPlaneDist : float;
  7408. var targetToCamPlaneDist : float;
  7409.  
  7410. if ( targets.Size() == 0 )
  7411. {
  7412. return;
  7413. }
  7414.  
  7415. nonCombatCheck = bLAxisReleased && !IsInCombat();
  7416.  
  7417.  
  7418. if ( nonCombatCheck )
  7419. {
  7420. info.coneHeadingVector = targetingPrecalcs.playerHeadingVector;
  7421. if ( lastAxisInputIsMovement )
  7422. {
  7423. info.coneHeadingVector = selectionHeadingVector;
  7424. info.invisibleCheck = false;
  7425. info.coneCheck = true;
  7426. info.coneHalfAngleCos = 0.76604444311f;
  7427. }
  7428. else
  7429. {
  7430. info.invisibleCheck = false;
  7431. info.frameScaleX = 0.9f;
  7432. info.frameScaleY = 0.9f;
  7433. }
  7434. }
  7435. else
  7436. {
  7437. info.coneHeadingVector = Vector( 0.0f, 0.0f, 0.0f );
  7438.  
  7439.  
  7440. if ( IsInCombat() )
  7441. {
  7442. info.inFrameCheck = false;
  7443. }
  7444. else
  7445. {
  7446. if ( !bLAxisReleased )
  7447. {
  7448. info.coneCheck = true;
  7449.  
  7450. if ( this.IsSwimming() )
  7451. info.coneHalfAngleCos = -1;
  7452. else
  7453. info.coneHalfAngleCos = 0.86602540378f;
  7454.  
  7455. info.coneHeadingVector = targetingIn.rawPlayerHeadingVector;
  7456. }
  7457. }
  7458. }
  7459.  
  7460. cameraPosition = theCamera.GetCameraPosition();
  7461. cameraDirection = targetingPrecalcs.cameraDirection;
  7462. playerToCamPlaneDist = VecDot2D( cameraDirection, this.GetWorldPosition() - cameraPosition );
  7463.  
  7464.  
  7465. for( i = targets.Size() - 1; i >= 0; i -= 1 )
  7466. {
  7467. info.targetEntity = targets[i];
  7468.  
  7469. if ( !CanBeTargetedIfSwimming( targets[i], true ) )
  7470. {
  7471. targets.EraseFast( i );
  7472. }
  7473. else if ( !IsEntityTargetable( info, true ) )
  7474. {
  7475. targets.EraseFast( i );
  7476. }
  7477. else
  7478. {
  7479. if ( nonCombatCheck && !lastAxisInputIsMovement )
  7480. {
  7481.  
  7482. targetToCamPlaneDist = VecDot2D( cameraDirection, targets[i].GetWorldPosition() - cameraPosition );
  7483. if ( targetToCamPlaneDist < playerToCamPlaneDist )
  7484. {
  7485. targets.EraseFast( i );
  7486. }
  7487. }
  7488. }
  7489. }
  7490. }
  7491.  
  7492. var combatModeColor : Color;
  7493. public function CombatModeDebug()
  7494. {
  7495. var visualDebug : CVisualDebug = GetVisualDebug();
  7496.  
  7497. var naviQueryMsg : string;
  7498. var naviQueryMsg1 : string;
  7499. var naviQueryMsg2 : string;
  7500.  
  7501. var navSnapMsg : string;
  7502. var i : int;
  7503.  
  7504. if ( IsCombatMusicEnabled() )
  7505. visualDebug.AddText( 'CombatMusic', "CombatMusic : On", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.7f ), true, , Color( 255, 255, 255 ) );
  7506. else
  7507. visualDebug.AddText( 'CombatMusic', "CombatMusic : Off", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.7f ), true, , Color( 0, 0, 0 ) );
  7508.  
  7509. if ( GetPlayerMode().GetForceCombatMode() )
  7510. visualDebug.AddText( 'ForcedCombatMode', "ForcedCombatMode : TRUE", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.6f ), true, , Color( 255, 255, 255 ) );
  7511. else
  7512. visualDebug.AddText( 'ForcedCombatMode', "ForcedCombatMode : FALSE", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.6f ), true, , Color( 0, 0, 0 ) );
  7513.  
  7514.  
  7515. if ( IsThreatened() )
  7516. {
  7517. if ( IsInCombat() )
  7518. visualDebug.AddText( 'CombatMode', "CombatMode : AlertNear/Far", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.5f ), true, , Color( 255, 0, 0 ) );
  7519. else
  7520. visualDebug.AddText( 'CombatMode', "CombatMode : CombatExploration", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.5f ), true, , Color( 255, 255, 0 ) );
  7521. }
  7522. else
  7523. visualDebug.AddText( 'CombatMode', "CombatMode : NormalExploration", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.5f ), true, , Color( 0, 255, 0 ) );
  7524.  
  7525. visualDebug.AddText( 'NaviQuery', naviQueryMsg, combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7526. visualDebug.AddText( 'NaviQuery1', naviQueryMsg1, thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7527. visualDebug.AddText( 'NaviQuery2', naviQueryMsg2, thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7528.  
  7529. if ( isInCombatReason == 0 )
  7530. visualDebug.AddText( 'CombatModeReason', "CombatModeReason : ", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.4f ), true, , Color( 125, 125, 125 ) );
  7531. else if ( isInCombatReason == 1 )
  7532. visualDebug.AddText( 'CombatModeReason', "CombatModeReason : Geralt CAN pathfind to NPC", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.4f ), true, , Color( 255, 0, 0 ) );
  7533. else if ( isInCombatReason == 2 )
  7534. visualDebug.AddText( 'CombatModeReason', "CombatModeReason : An NPC is flying or ranged", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.4f ), true, , Color( 255, 0, 0 ) );
  7535. else if ( isInCombatReason == 2 )
  7536. visualDebug.AddText( 'CombatModeReason', "CombatModeReason : Forced Combat Mode", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.4f ), true, , Color( 255, 0, 0 ) );
  7537.  
  7538. if ( reachableEnemyWasTooFar )
  7539. {
  7540. combatModeColor.Red = 255;
  7541. combatModeColor.Green = 255;
  7542. combatModeColor.Blue = 0;
  7543. }
  7544. else
  7545. {
  7546. combatModeColor.Red = 0;
  7547. combatModeColor.Green = 255;
  7548. combatModeColor.Blue = 0;
  7549. }
  7550.  
  7551. if ( IsThreatened() )
  7552. {
  7553. switch ( navQuery.GetLastOutput( 2.0 ) )
  7554. {
  7555. case EAsyncTastResult_Failure:
  7556. {
  7557. if ( this.playerMode.GetForceCombatMode() )
  7558. {
  7559. if ( isSnappedToNavMesh )
  7560. {
  7561. visualDebug.AddText( 'NaviQuery', "", combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7562. visualDebug.AddText( 'NaviQuery1', "Naviquery : Snapped So no need for query", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7563. visualDebug.AddText( 'NaviQuery2', "Naviquery : Snapped So no need for query", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7564. }
  7565. else
  7566. {
  7567. visualDebug.AddText( 'NaviQuery', "", combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7568. visualDebug.AddText( 'NaviQuery1', "Naviquery : Failed", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7569. visualDebug.AddText( 'NaviQuery2', "Naviquery : Failed", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7570. }
  7571. }
  7572. else
  7573. {
  7574. visualDebug.AddText( 'NaviQuery', "", combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7575. visualDebug.AddText( 'NaviQuery1', "Naviquery : Failed", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7576. visualDebug.AddText( 'NaviQuery2', "Naviquery : Failed", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7577. }
  7578. break;
  7579. }
  7580. case EAsyncTastResult_Success:
  7581. {
  7582. visualDebug.AddText( 'NaviQuery', combatModeEnt.GetName(), combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7583. visualDebug.AddText( 'NaviQuery1', "Naviquery : Success (navDist: " + navDist + ")", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7584. visualDebug.AddText( 'NaviQuery2', "Naviquery : Success (directDist: " + directDist + ")", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7585. break;
  7586. }
  7587. case EAsyncTastResult_Pending:
  7588. {
  7589. visualDebug.AddText( 'NaviQuery', combatModeEnt.GetName(), combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7590. visualDebug.AddText( 'NaviQuery1', "Naviquery : Pending (navDist: " + navDist + ")", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7591. visualDebug.AddText( 'NaviQuery2', "Naviquery : Pending (directDist: " + directDist + ")", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7592. break;
  7593. }
  7594. case EAsyncTastResult_Invalidated:
  7595. {
  7596. visualDebug.AddText( 'NaviQuery', "", combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7597. visualDebug.AddText( 'NaviQuery1', "Naviquery : Invalidated", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7598. visualDebug.AddText( 'NaviQuery2', "Naviquery : Invalidated", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7599. break;
  7600. }
  7601. }
  7602. }
  7603. else
  7604. {
  7605. visualDebug.AddText( 'NaviQuery', "", combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7606. visualDebug.AddText( 'NaviQuery1', "", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7607. visualDebug.AddText( 'NaviQuery2', "", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7608. }
  7609.  
  7610. if ( navMeshSnapInfoStack.Size() > 0 )
  7611. {
  7612. for ( i = navMeshSnapInfoStack.Size()-1; i >= 0; i -= 1 )
  7613. {
  7614. navSnapMsg = navSnapMsg + navMeshSnapInfoStack[i] + " ";
  7615. }
  7616.  
  7617. visualDebug.AddText( 'NavMeshSnap', "NavMeshSnap: Enabled, Sources : " + navSnapMsg, thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.1f ), true, , Color( 255, 255, 255 ) );
  7618. }
  7619. else
  7620. visualDebug.AddText( 'NavMeshSnap', "NavMeshSnap: Disabled" , thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.1f ), true, , Color( 0, 0, 0 ) );
  7621.  
  7622. }
  7623.  
  7624. function IsCombatMusicEnabled() : bool
  7625. {
  7626. if ( theSound.GetCurrentGameState() == ESGS_UnderwaterCombat
  7627. || theSound.GetCurrentGameState() == ESGS_Combat
  7628. || theSound.GetCurrentGameState() == ESGS_CombatMonsterHunt
  7629. || theSound.GetCurrentGameState() == ESGS_FocusUnderwaterCombat )
  7630. return true;
  7631. else
  7632. return false;
  7633. }
  7634.  
  7635. function IsSoundStateCombatMusic( gameState : ESoundGameState ) : bool
  7636. {
  7637. if ( gameState == ESGS_UnderwaterCombat
  7638. || gameState == ESGS_Combat
  7639. || gameState == ESGS_CombatMonsterHunt
  7640. || gameState == ESGS_FocusUnderwaterCombat )
  7641. return true;
  7642. else
  7643. return false;
  7644. }
  7645.  
  7646. private function ConfirmNewTarget( actorToConfirm : CActor )
  7647. {
  7648. var leftJoyRotLimit : float = 1.f;
  7649.  
  7650. var target : CActor;
  7651.  
  7652. target = GetTarget();
  7653.  
  7654.  
  7655. if ( !target
  7656. || !moveTarget
  7657. || ( target && ( !IsThreat( target ) || !target.IsAlive() ) )
  7658. || VecLength( rawLeftJoyVec ) < 0.7f
  7659. || ( 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 ) ) ) )
  7660. || ( !IsInCombatAction() && ( !rangedWeapon || ( rangedWeapon.GetCurrentStateName() != 'State_WeaponHolster' ) ) ))
  7661. {
  7662. SetPrevRawLeftJoyRot();
  7663.  
  7664. if ( actorToConfirm != target )
  7665. {
  7666. SetTarget( actorToConfirm );
  7667. }
  7668. }
  7669. }
  7670.  
  7671. protected function SelectTarget( targets : array< CActor >, useVisibilityCheck : bool, sourcePosition : Vector, headingVector : Vector, selectionWeights : STargetSelectionWeights, optional usePrecalcs : bool ) : CActor
  7672. {
  7673. var i : int;
  7674. var target : CActor;
  7675. var selectedTarget : CActor;
  7676. var currentTarget : CActor;
  7677. var playerPosition : Vector;
  7678. var distanceToPlayer : float;
  7679. var priority : float;
  7680. var maxPriority : float;
  7681. var now : float;
  7682. var remove : bool;
  7683. var visibleActorIndex : int;
  7684.  
  7685. if ( useVisibilityCheck )
  7686. {
  7687. currentTarget = this.GetTarget();
  7688. playerPosition = this.GetWorldPosition();
  7689. now = theGame.GetEngineTimeAsSeconds();
  7690.  
  7691. for ( i = targets.Size() - 1; i >= 0; i-=1 )
  7692. {
  7693. target = targets[ i ];
  7694. if ( target != currentTarget && ( !IsPCModeEnabled() && !WasVisibleInScaledFrame( target, softLockFrameSize, softLockFrameSize ) ) )
  7695. {
  7696. remove = true;
  7697. visibleActorIndex = visibleActors.FindFirst( target );
  7698. if ( visibleActorIndex != -1 )
  7699. {
  7700. if ( usePrecalcs )
  7701. {
  7702. distanceToPlayer = Distance2DBetweenCapsuleAndPoint( target, this ) - targetingPrecalcs.playerRadius;
  7703. }
  7704. else
  7705. {
  7706. distanceToPlayer = Distance2DBetweenCapsules( this, target );
  7707. }
  7708.  
  7709. if ( distanceToPlayer < this.softLockDist && ( now - visibleActorsTime[ i ] ) < 1.0f )
  7710. {
  7711. remove = false;
  7712. }
  7713. }
  7714. if ( remove )
  7715. {
  7716. targets.EraseFast( i );
  7717. }
  7718. }
  7719. else
  7720. {
  7721. visibleActorIndex = visibleActors.FindFirst( target );
  7722. if ( visibleActorIndex == -1 )
  7723. {
  7724. visibleActors.PushBack( target );
  7725. visibleActorsTime.PushBack( now );
  7726. }
  7727. else
  7728. {
  7729. visibleActorsTime[ visibleActorIndex ] = now;
  7730. }
  7731. }
  7732. }
  7733. }
  7734.  
  7735. selectedTarget = NULL;
  7736. maxPriority = -1.0f;
  7737. for( i = targets.Size() - 1; i >= 0; i-=1 )
  7738. {
  7739. priority = CalcSelectionPriority( targets[ i ], selectionWeights, sourcePosition, headingVector );
  7740. if ( priority > maxPriority )
  7741. {
  7742. maxPriority = priority;
  7743. selectedTarget = targets[ i ];
  7744. }
  7745. }
  7746.  
  7747.  
  7748. return selectedTarget;
  7749. }
  7750.  
  7751. function Distance2DBetweenCapsuleAndPoint( actor : CActor, entity : CEntity ) : float
  7752. {
  7753. var distance : float;
  7754. var mpac : CMovingPhysicalAgentComponent;
  7755.  
  7756. distance = VecDistance2D( actor.GetWorldPosition(), entity.GetWorldPosition() );
  7757.  
  7758. mpac = (CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent();
  7759. if ( mpac )
  7760. {
  7761. distance -= mpac.GetCapsuleRadius();
  7762. }
  7763.  
  7764. return distance;
  7765. }
  7766.  
  7767.  
  7768. function Distance2DBetweenCapsules( actor1 : CActor, actor2 : CActor ) : float
  7769. {
  7770. var distance : float;
  7771. var mpac : CMovingPhysicalAgentComponent;
  7772.  
  7773. distance = VecDistance2D( actor1.GetWorldPosition(), actor2.GetWorldPosition() );
  7774.  
  7775. mpac = (CMovingPhysicalAgentComponent)actor1.GetMovingAgentComponent();
  7776. if ( mpac )
  7777. {
  7778. distance -= mpac.GetCapsuleRadius();
  7779. }
  7780.  
  7781. mpac = (CMovingPhysicalAgentComponent)actor2.GetMovingAgentComponent();
  7782. if ( mpac )
  7783. {
  7784. distance -= mpac.GetCapsuleRadius();
  7785. }
  7786.  
  7787. return distance;
  7788. }
  7789.  
  7790. protected function ProcessSelectionWeights() : STargetSelectionWeights
  7791. {
  7792. var selectionWeights : STargetSelectionWeights;
  7793.  
  7794. if ( ShouldUsePCModeTargeting() )
  7795. {
  7796. selectionWeights.angleWeight = 0.75f;
  7797. selectionWeights.distanceWeight = 0.25f;
  7798. selectionWeights.distanceRingWeight = 0.f;
  7799. return selectionWeights;
  7800. }
  7801.  
  7802. if ( IsInCombatAction() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Dodge || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Roll ) )
  7803. {
  7804. selectionWeights.angleWeight = 0.575f;
  7805. selectionWeights.distanceWeight = 0.175f;
  7806. selectionWeights.distanceRingWeight = 0.25f;
  7807. }
  7808. if ( !lAxisReleasedAfterCounter || IsInCombatAction() )
  7809. {
  7810. if ( theInput.GetActionValue( 'ThrowItem' ) == 1.f || ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' ) )
  7811. {
  7812. selectionWeights.angleWeight = 1.f;
  7813. selectionWeights.distanceWeight = 0.f;
  7814. selectionWeights.distanceRingWeight = 0.f;
  7815. }
  7816. else if ( !lAxisReleasedAfterCounter )
  7817. {
  7818. selectionWeights.angleWeight = 0.55f;
  7819. selectionWeights.distanceWeight = 0.45f;
  7820. selectionWeights.distanceRingWeight = 0.f;
  7821. }
  7822. else
  7823. {
  7824. selectionWeights.angleWeight = 0.75f;
  7825. selectionWeights.distanceWeight = 0.25f;
  7826. selectionWeights.distanceRingWeight = 0.f;
  7827. }
  7828. }
  7829. else if( !IsCurrentSignChanneled() )
  7830. {
  7831. selectionWeights.angleWeight = 0.35f;
  7832. selectionWeights.distanceWeight = 0.65f;
  7833. selectionWeights.distanceRingWeight = 0.f;
  7834. }
  7835. else
  7836. {
  7837. selectionWeights.angleWeight = 0.275f;
  7838. selectionWeights.distanceWeight = 0.375f;
  7839. selectionWeights.distanceRingWeight = 0.35f;
  7840. }
  7841.  
  7842. return selectionWeights;
  7843. }
  7844.  
  7845. protected function CalcSelectionPriority( target : CEntity, selectionWeights : STargetSelectionWeights, sourcePosition : Vector, headingVector : Vector ) : float
  7846. {
  7847. var sourceToTarget : Vector;
  7848. var sourceToTargetDist : float;
  7849. var sourceToTargetAngleDiff : float;
  7850. var selectionPriority : float;
  7851.  
  7852. sourceToTarget = target.GetWorldPosition() - sourcePosition;
  7853. sourceToTargetDist = VecLength2D( sourceToTarget );
  7854.  
  7855. if ( sourceToTargetDist < 0.0001f )
  7856. {
  7857. sourceToTarget = Vector( 0.0f, 0.0f, 0.0f );
  7858. }
  7859. else
  7860. {
  7861. sourceToTarget *= ( 1.0f / sourceToTargetDist );
  7862. }
  7863. sourceToTargetAngleDiff = AbsF( Rad2Deg( AcosF( VecDot2D( sourceToTarget, headingVector ) ) ) );
  7864.  
  7865. selectionPriority = ( selectionWeights.angleWeight * ( ( 180 - sourceToTargetAngleDiff ) / 180 ) );
  7866. selectionPriority += selectionWeights.distanceWeight * ( ( softLockDist - sourceToTargetDist ) / softLockDist );
  7867.  
  7868. if ( sourceToTargetDist > 0.f && sourceToTargetDist <= 6.f )
  7869. {
  7870. selectionPriority += selectionWeights.distanceRingWeight * 1.0f;
  7871. }
  7872. else if ( sourceToTargetDist > 6.f && sourceToTargetDist <= softLockDist )
  7873. {
  7874. selectionPriority += selectionWeights.distanceRingWeight * 0.4f;
  7875. }
  7876.  
  7877. return selectionPriority;
  7878. }
  7879.  
  7880. protected function SetTarget( targetActor : CActor, optional forceSetTarget : bool )
  7881. {
  7882. var playerToTargetDistance : float;
  7883. var target : CActor;
  7884. var allow : bool;
  7885.  
  7886. target = GetTarget();
  7887.  
  7888. if ( !IsInNonGameplayCutscene() )
  7889. allow = true;
  7890.  
  7891. if ( allow )
  7892. {
  7893. if ( targetActor )
  7894. {
  7895. if ( ( targetActor.IsAlive() && !targetActor.IsKnockedUnconscious() ) || finishableEnemiesList.Contains( targetActor ) )
  7896. allow = true;
  7897. else
  7898. allow = false;
  7899. }
  7900. else
  7901. allow = true;
  7902. }
  7903.  
  7904. if ( forceSetTarget )
  7905. allow = true;
  7906.  
  7907. if ( allow && target != targetActor )
  7908. allow = true;
  7909. else
  7910. allow = false;
  7911.  
  7912. if ( allow )
  7913. {
  7914. SetPlayerTarget( targetActor );
  7915.  
  7916.  
  7917.  
  7918. }
  7919. }
  7920.  
  7921.  
  7922. public function SetSlideTarget( actor : CGameplayEntity )
  7923. {
  7924.  
  7925.  
  7926.  
  7927. slideTarget = actor;
  7928.  
  7929. if ( slideTarget )
  7930. SetPlayerCombatTarget((CActor)slideTarget);
  7931. else
  7932. Log( "slideTarget = NULL" );
  7933.  
  7934. if ( slideTarget == nonActorTarget )
  7935. UpdateDisplayTarget( true, true );
  7936. else
  7937. UpdateDisplayTarget();
  7938.  
  7939. ConfirmDisplayTargetTimer(0.f);
  7940. }
  7941.  
  7942. event OnForceSelectLockTarget()
  7943. {
  7944. ForceSelectLockTarget();
  7945. }
  7946.  
  7947. private function ForceSelectLockTarget()
  7948. {
  7949. var newMoveTarget : CActor;
  7950. var target : CActor;
  7951.  
  7952. newMoveTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, 90 );
  7953.  
  7954. if ( !newMoveTarget )
  7955. newMoveTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, -90 );
  7956.  
  7957. if ( newMoveTarget )
  7958. {
  7959. thePlayer.ProcessLockTarget( newMoveTarget );
  7960.  
  7961. target = GetTarget();
  7962. if ( target )
  7963. {
  7964. thePlayer.SetSlideTarget( target );
  7965.  
  7966. if ( IsHardLockEnabled() )
  7967. thePlayer.HardLockToTarget( true );
  7968. }
  7969. }
  7970. else
  7971. {
  7972. thePlayer.HardLockToTarget( false );
  7973. }
  7974. }
  7975.  
  7976. public function SetFinisherVictim( actor : CActor )
  7977. {
  7978. finisherVictim = actor;
  7979. }
  7980.  
  7981. public function GetFinisherVictim() : CActor
  7982. {
  7983. return finisherVictim;
  7984. }
  7985.  
  7986. protected function SetNonActorTarget( actor : CGameplayEntity )
  7987. {
  7988. if ( nonActorTarget != actor )
  7989. nonActorTarget = actor;
  7990. }
  7991.  
  7992. timer function DisableTargetHighlightTimer( time : float , id : int)
  7993. {
  7994. var target : CActor;
  7995. target = GetTarget();
  7996.  
  7997. if( target )
  7998. {
  7999. target.StopEffect( 'select_character' );
  8000. }
  8001. }
  8002.  
  8003. public function WasVisibleInScaledFrame( entity : CEntity, frameSizeX : float, frameSizeY : float ) : bool
  8004. {
  8005. var position : Vector;
  8006. var positionFound : bool;
  8007. var inFront : bool;
  8008. var x, y : float;
  8009. var boneIndex : int;
  8010. var actor : CActor;
  8011. var gameplayEntity : CGameplayEntity;
  8012. var gameplayEntityMatrix : Matrix;
  8013. var drawableComp : CDrawableComponent;
  8014. var box : Box;
  8015. var ok : bool;
  8016.  
  8017. if ( !entity )
  8018. {
  8019. return false;
  8020. }
  8021. if ( frameSizeX <= 0.0f && frameSizeY <= 0.0f )
  8022. {
  8023. LogChannel( 'WasVisibleInScaledFrame', "ERROR: WasVisibleInScaledFrame: frameSizeX && frameSizeY are both negative!!!" );
  8024. return false;
  8025. }
  8026.  
  8027. if ( useNativeTargeting )
  8028. {
  8029. return targeting.WasVisibleInScaledFrame( entity, frameSizeX, frameSizeY );
  8030. }
  8031.  
  8032. position = entity.GetWorldPosition();
  8033.  
  8034. actor = (CActor)entity;
  8035. if ( actor )
  8036. {
  8037. boneIndex = entity.GetBoneIndex( 'pelvis' );
  8038. if ( boneIndex == -1 )
  8039. {
  8040. boneIndex = entity.GetBoneIndex( 'k_pelvis_g' );
  8041. }
  8042.  
  8043. if ( boneIndex != -1 )
  8044. {
  8045. position = MatrixGetTranslation( entity.GetBoneWorldMatrixByIndex( boneIndex ) );
  8046. }
  8047. else
  8048. {
  8049. position = entity.GetWorldPosition();
  8050. position.Z += ( (CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent() ).GetCapsuleHeight() * 0.5;
  8051. }
  8052. positionFound = true;
  8053. }
  8054. else
  8055. {
  8056. gameplayEntity = (CGameplayEntity)entity;
  8057. if ( gameplayEntity && !( gameplayEntity.aimVector.X == 0 && gameplayEntity.aimVector.Y == 0 && gameplayEntity.aimVector.Z == 0 ) )
  8058. {
  8059. gameplayEntityMatrix = gameplayEntity.GetLocalToWorld();
  8060. position = VecTransform( gameplayEntityMatrix, gameplayEntity.aimVector );
  8061. positionFound = true;
  8062. }
  8063. }
  8064.  
  8065.  
  8066. if ( !positionFound )
  8067. {
  8068. drawableComp = (CDrawableComponent)entity.GetComponentByClassName( 'CDrawableComponent' );
  8069. if ( drawableComp && drawableComp.GetObjectBoundingVolume( box ) )
  8070. {
  8071. position.Z += ( ( box.Max.Z - box.Min.Z ) * 0.66f );
  8072. }
  8073. }
  8074.  
  8075. inFront = theCamera.WorldVectorToViewRatio( position, x, y );
  8076. if ( !inFront )
  8077. {
  8078. return false;
  8079. }
  8080. x = AbsF( x );
  8081. y = AbsF( y );
  8082.  
  8083. ok = true;
  8084. ok = ok && ( frameSizeX <= 0.0f || x < frameSizeX );
  8085. ok = ok && ( frameSizeY <= 0.0f || y < frameSizeY );
  8086.  
  8087. return ok;
  8088. }
  8089.  
  8090. public function HardLockToTarget( flag : bool )
  8091. {
  8092. if( flag && GetTarget().HasTag( 'NoHardLock' ) )
  8093. return;
  8094.  
  8095. EnableHardLock( flag );
  8096. LockToTarget( flag );
  8097. }
  8098.  
  8099. public function LockToTarget( flag : bool )
  8100. {
  8101. if ( IsHardLockEnabled() && !flag )
  8102. return;
  8103.  
  8104. LockCameraToTarget( flag );
  8105. LockActorToTarget( flag );
  8106. }
  8107.  
  8108. public function LockCameraToTarget( flag : bool )
  8109. {
  8110. if ( flag && !IsCameraLockedToTarget() )
  8111. {
  8112. thePlayer.EnableManualCameraControl( false, 'LockCameraToTarget' );
  8113.  
  8114. SetIsCameraLockedToTarget( flag );
  8115. }
  8116. else if ( !flag && IsCameraLockedToTarget() )
  8117. {
  8118. thePlayer.EnableManualCameraControl( true, 'LockCameraToTarget' );
  8119.  
  8120. SetIsCameraLockedToTarget( flag );
  8121. }
  8122. }
  8123.  
  8124. public function LockActorToTarget( flag : bool, optional withoutIcon : bool )
  8125. {
  8126. var displayTargetActor : CActor;
  8127.  
  8128. if ( flag )
  8129. {
  8130. if ( !IsActorLockedToTarget() )
  8131. {
  8132.  
  8133. SetIsActorLockedToTarget( flag );
  8134. SetMoveTargetChangeAllowed( true );
  8135. SetMoveTarget( GetTarget() );
  8136. SetMoveTargetChangeAllowed( false );
  8137. SetTarget( GetTarget() );
  8138. SetSlideTarget( GetTarget() );
  8139. AddTimer( 'CheckLockTargetIsAlive', 0.5, true );
  8140. }
  8141.  
  8142. if ( IsActorLockedToTarget() )
  8143. {
  8144. displayTargetActor = (CActor)( GetDisplayTarget() );
  8145.  
  8146. if ( displayTargetActor && IsThreat( displayTargetActor ) && !withoutIcon )
  8147. EnableHardLockIcon( flag );
  8148. }
  8149. }
  8150. else if ( !flag && IsActorLockedToTarget() )
  8151. {
  8152. SetIsActorLockedToTarget( flag );
  8153. SetMoveTargetChangeAllowed( true );
  8154. RemoveTimer( 'CheckLockTargetIsAlive' );
  8155. EnableHardLockIcon( flag );
  8156. }
  8157. }
  8158.  
  8159. private function EnableHardLockIcon( flag : bool )
  8160. {
  8161. var hud : CR4ScriptedHud;
  8162. var module : CR4HudModuleEnemyFocus;
  8163.  
  8164. if( GetTarget().HasTag( 'NoHardLockIcon' ) )
  8165. return;
  8166.  
  8167. hud = (CR4ScriptedHud)theGame.GetHud();
  8168. module = (CR4HudModuleEnemyFocus)hud.GetHudModule("EnemyFocusModule");
  8169. module.SetShowHardLock( flag );
  8170. }
  8171.  
  8172. private timer function CheckLockTargetIsAlive( time : float , id : int)
  8173. {
  8174. var vitality : float;
  8175. var essence : float;
  8176. var actor : CActor;
  8177. var target : CActor;
  8178.  
  8179. target = (CActor)GetDisplayTarget();
  8180.  
  8181. if( !target
  8182. || !target.IsAlive()
  8183. || ( !target.GetGameplayVisibility() )
  8184. || !CanBeTargetedIfSwimming( target )
  8185. || (!target.UsesVitality() && !target.UsesEssence()))
  8186. {
  8187. if ( !ProcessLockTarget() )
  8188. HardLockToTarget( false );
  8189. }
  8190. }
  8191.  
  8192.  
  8193.  
  8194.  
  8195.  
  8196.  
  8197. protected function PlayHitAnimation(damageAction : W3DamageAction, animType : EHitReactionType)
  8198. {
  8199. var hitRotation : float;
  8200. var onHitCounter : SAbilityAttributeValue;
  8201. var counter : int;
  8202.  
  8203. if( damageAction.HasAnyCriticalEffect() )
  8204. return;
  8205.  
  8206. if( !substateManager.ReactOnBeingHit() && !IsUsingVehicle() )
  8207. {
  8208. return;
  8209. }
  8210.  
  8211. if ( damageAction.GetHitReactionType() == EHRT_Reflect )
  8212. SetBehaviorVariable( 'isAttackReflected', 1.f );
  8213. else
  8214. SetBehaviorVariable( 'isAttackReflected', 0.f );
  8215.  
  8216. SetBehaviorVariable( 'HitReactionType',(int)animType);
  8217. SetBehaviorVariable( 'HitReactionWeapon', ProcessSwordOrFistHitReaction( this, (CActor)damageAction.attacker ) );
  8218.  
  8219. if (damageAction.attacker)
  8220. {
  8221. super.PlayHitAnimation( damageAction, animType );
  8222. if ( damageAction.attacker.HasAbility( 'IncreaseHitReactionSeverityWithHitCounter' ) )
  8223. {
  8224. counter = GetHitCounter();
  8225. switch ( counter )
  8226. {
  8227. case 2 :
  8228. SetBehaviorVariable( 'HitReactionType', 2 );
  8229. break;
  8230.  
  8231. case 3 :
  8232. AddEffectDefault( EET_Stagger, damageAction.attacker, damageAction.attacker.GetName() );
  8233. break;
  8234.  
  8235. case 4 :
  8236. AddEffectDefault( EET_Knockdown, damageAction.attacker, damageAction.attacker.GetName() );
  8237. break;
  8238.  
  8239. default :
  8240. break;
  8241. }
  8242. }
  8243. SetHitReactionDirection(damageAction.attacker);
  8244. SetDetailedHitReaction(damageAction.GetSwingType(), damageAction.GetSwingDirection());
  8245. }
  8246.  
  8247. RaiseForceEvent( 'Hit' );
  8248. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'ActorInHitReaction', -1, 30.0f, -1.f, -1, true );
  8249.  
  8250. if ( IsUsingBoat() )
  8251. {
  8252. SoundEvent("cmb_play_hit_light");
  8253. return;
  8254. }
  8255.  
  8256. if ( IsUsingVehicle() )
  8257. return;
  8258.  
  8259. if(damageAction.attacker)
  8260. {
  8261. hitRotation = VecHeading( damageAction.attacker.GetWorldPosition() - GetWorldPosition() );
  8262. if ( this.GetBehaviorVariable( 'HitReactionDirection' ) == (float)( (int)EHRD_Back ) )
  8263. hitRotation += 180.f;
  8264.  
  8265.  
  8266. SetCustomRotation( 'Hit', hitRotation, 1080.f, 0.1f, false );
  8267. }
  8268.  
  8269. CriticalEffectAnimationInterrupted("PlayHitAnimation");
  8270. }
  8271.  
  8272. public function ReduceDamage( out damageData : W3DamageAction)
  8273. {
  8274. super.ReduceDamage(damageData);
  8275.  
  8276.  
  8277. if(damageData.attacker == this && (damageData.GetBuffSourceName() == "petard" || (W3Petard)damageData.causer) )
  8278. {
  8279. if ( theGame.CanLog() )
  8280. {
  8281. LogDMHits("CR4Player.ReduceDamage: hitting self with own bomb - damage reduced by 50%", damageData );
  8282. }
  8283. damageData.processedDmg.vitalityDamage = damageData.processedDmg.vitalityDamage / 2;
  8284. damageData.processedDmg.essenceDamage = damageData.processedDmg.essenceDamage / 2;
  8285. }
  8286. }
  8287.  
  8288.  
  8289. public function GetCriticalHitChance( isLightAttack : bool, isHeavyAttack : bool, target : CActor, victimMonsterCategory : EMonsterCategory, isBolt : bool ) : float
  8290. {
  8291. var critChance : float;
  8292. var oilChanceAttribute : name;
  8293. var weapons : array< SItemUniqueId >;
  8294. var i : int;
  8295. var holdsCrossbow : bool;
  8296. var critVal : SAbilityAttributeValue;
  8297.  
  8298. critChance = 0;
  8299.  
  8300.  
  8301. if( FactsQuerySum( 'debug_fact_critical_boy' ) > 0 )
  8302. {
  8303. critChance += 1;
  8304. }
  8305.  
  8306. if( IsInState( 'HorseRiding' ) && ( ( CActor )GetUsedVehicle() ).GetMovingAgentComponent().GetRelativeMoveSpeed() >= 4.0 )
  8307. {
  8308. critChance += 1;
  8309. }
  8310.  
  8311.  
  8312. critChance += CalculateAttributeValue( GetAttributeValue( theGame.params.CRITICAL_HIT_CHANCE ) );
  8313.  
  8314.  
  8315. weapons = inv.GetHeldWeapons();
  8316. for( i=0; i<weapons.Size(); i+=1 )
  8317. {
  8318. holdsCrossbow = ( inv.IsItemCrossbow( weapons[i] ) || inv.IsItemBolt( weapons[i] ) );
  8319. if( holdsCrossbow != isBolt )
  8320. {
  8321. critVal = inv.GetItemAttributeValue( weapons[i], theGame.params.CRITICAL_HIT_CHANCE );
  8322. critChance -= CalculateAttributeValue( critVal );
  8323. }
  8324. }
  8325.  
  8326.  
  8327. if( isHeavyAttack && CanUseSkill( S_Sword_s08 ) )
  8328. {
  8329. critChance += CalculateAttributeValue( GetSkillAttributeValue( S_Sword_s08, theGame.params.CRITICAL_HIT_CHANCE, false, true ) ) * GetSkillLevel( S_Sword_s08 );
  8330. }
  8331. else if( isLightAttack && CanUseSkill( S_Sword_s17 ) )
  8332. {
  8333. critChance += CalculateAttributeValue( GetSkillAttributeValue( S_Sword_s17, theGame.params.CRITICAL_HIT_CHANCE, false, true ) ) * GetSkillLevel( S_Sword_s17 );
  8334. }
  8335.  
  8336. if( target && target.HasBuff( EET_Confusion ) )
  8337. {
  8338. critChance += ( ( W3ConfuseEffect )target.GetBuff( EET_Confusion ) ).GetCriticalHitChanceBonus();
  8339. }
  8340.  
  8341.  
  8342. oilChanceAttribute = MonsterCategoryToCriticalChanceBonus( victimMonsterCategory );
  8343. if( IsNameValid( oilChanceAttribute ) )
  8344. {
  8345. critChance += CalculateAttributeValue( GetAttributeValue( oilChanceAttribute ) );
  8346. }
  8347.  
  8348. return critChance;
  8349. }
  8350.  
  8351.  
  8352. public function GetCriticalHitDamageBonus(weaponId : SItemUniqueId, victimMonsterCategory : EMonsterCategory, isStrikeAtBack : bool) : SAbilityAttributeValue
  8353. {
  8354. var bonus, oilBonus : SAbilityAttributeValue;
  8355. var vsAttributeName : name;
  8356.  
  8357. bonus = super.GetCriticalHitDamageBonus(weaponId, victimMonsterCategory, isStrikeAtBack);
  8358.  
  8359.  
  8360. if( inv.ItemHasActiveOilApplied( weaponId, victimMonsterCategory ) )
  8361. {
  8362. vsAttributeName = MonsterCategoryToCriticalDamageBonus(victimMonsterCategory);
  8363. oilBonus = inv.GetItemAttributeValue(weaponId, vsAttributeName);
  8364. bonus += oilBonus;
  8365. }
  8366.  
  8367. return bonus;
  8368. }
  8369.  
  8370.  
  8371. public function ReactToBeingHit(damageAction : W3DamageAction, optional buffNotApplied : bool) : bool
  8372. {
  8373. var strength : float;
  8374. var animType : EHitReactionType;
  8375. var sup : bool;
  8376. var boat : CBoatComponent;
  8377. var combatActionType : int;
  8378. var attackAction : W3Action_Attack;
  8379. var npc : CNewNPC;
  8380. var shakeCam : bool;
  8381.  
  8382. attackAction = (W3Action_Attack)damageAction;
  8383.  
  8384. if(!damageAction.IsDoTDamage() && (!attackAction || (!attackAction.IsParried() && !attackAction.IsCountered() && !attackAction.WasDodged()) ) )
  8385. {
  8386. npc = (CNewNPC)attackAction.attacker;
  8387. if(npc && npc.IsHeavyAttack(attackAction.GetAttackName()))
  8388. theGame.VibrateControllerVeryHard();
  8389. else
  8390. theGame.VibrateControllerHard();
  8391. }
  8392.  
  8393. if ( (CActor)GetUsedVehicle() && this.playerAiming.GetCurrentStateName() == 'Aiming' )
  8394. {
  8395. OnRangedForceHolster( true, true );
  8396. }
  8397.  
  8398. combatActionType = (int)GetBehaviorVariable( 'combatActionType' );
  8399.  
  8400. if ( thePlayer.IsCurrentlyDodging() && ( combatActionType == (int)CAT_Roll || combatActionType == (int)CAT_CiriDodge ) )
  8401. sup = false;
  8402. else if ( this.GetCurrentStateName() == 'DismountHorse' )
  8403. sup = false;
  8404. else
  8405. sup = super.ReactToBeingHit(damageAction, buffNotApplied);
  8406. sup = false;
  8407.  
  8408. if(damageAction.attacker)
  8409. theTelemetry.LogWithLabelAndValue( TE_FIGHT_HERO_GETS_HIT, damageAction.attacker.ToString(), (int)damageAction.processedDmg.vitalityDamage );
  8410.  
  8411.  
  8412. if(damageAction.DealsAnyDamage())
  8413. {
  8414. if( ((W3PlayerWitcher)this) && GetWitcherPlayer().IsAnyQuenActive() && damageAction.IsDoTDamage())
  8415. {
  8416. shakeCam = false;
  8417. }
  8418. else
  8419. {
  8420. shakeCam = true;
  8421. }
  8422.  
  8423. if(shakeCam)
  8424. {
  8425. animType = ModifyHitSeverityReaction(this, damageAction.GetHitReactionType());
  8426.  
  8427. if(animType == EHRT_Light || animType == EHRT_LightClose)
  8428. strength = 0.1;
  8429. else if(animType == EHRT_Heavy || animType == EHRT_Igni)
  8430. strength = 0.2;
  8431.  
  8432. GCameraShakeLight(strength, false, GetWorldPosition(), 10.0);
  8433. }
  8434.  
  8435. this.HitReactionEffect( 0.25 );
  8436.  
  8437.  
  8438. ResetUninterruptedHitsCount();
  8439. }
  8440.  
  8441.  
  8442. if(!damageAction.IsDoTDamage() && IsThreatened() && ShouldPauseHealthRegenOnHit() && damageAction.DealsAnyDamage() && !damageAction.WasDodged() && attackAction.CanBeParried() && !attackAction.IsParried())
  8443. {
  8444. PauseHPRegenEffects('being_hit', theGame.params.ON_HIT_HP_REGEN_DELAY);
  8445. }
  8446.  
  8447.  
  8448.  
  8449.  
  8450.  
  8451. if(damageAction.processedDmg.vitalityDamage > 0 && !((W3Effect_Toxicity)damageAction.causer))
  8452. ReceivedCombatDamage();
  8453.  
  8454.  
  8455. if(FactsQuerySum("tut_fight_use_slomo") > 0)
  8456. {
  8457. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
  8458. FactsRemove("tut_fight_slomo_ON");
  8459. }
  8460.  
  8461.  
  8462. if( !substateManager.ReactOnBeingHit( damageAction ) )
  8463. {
  8464. GoToCombatIfNeeded();
  8465.  
  8466. }
  8467.  
  8468. return sup;
  8469. }
  8470.  
  8471. protected function ShouldPauseHealthRegenOnHit() : bool
  8472. {
  8473. return true;
  8474. }
  8475.  
  8476. public function PlayHitEffect(damageAction : W3DamageAction)
  8477. {
  8478. super.PlayHitEffect(damageAction);
  8479.  
  8480.  
  8481. if(damageAction.DealsAnyDamage() && !damageAction.IsDoTDamage())
  8482. PlayEffect('hit_screen');
  8483. }
  8484.  
  8485. function HitReactionEffect( interval : float )
  8486. {
  8487. if ( hitReactionEffect )
  8488. {
  8489. PlayEffect( 'radial_blur' );
  8490. hitReactionEffect = false;
  8491. }
  8492. else
  8493. {
  8494. AddTimer( 'HitReactionEffectCooldown', interval, false );
  8495. }
  8496. }
  8497.  
  8498. timer function HitReactionEffectCooldown( td : float , id : int)
  8499. {
  8500. hitReactionEffect = true;
  8501. }
  8502.  
  8503.  
  8504.  
  8505.  
  8506.  
  8507.  
  8508. function PerformParryCheck( parryInfo : SParryInfo) : bool
  8509. {
  8510. var mult : float;
  8511. var parryType : EParryType;
  8512. var parryDir : EPlayerParryDirection;
  8513. var parryHeading : float;
  8514. var fistFightParry : bool;
  8515. var action : W3DamageAction;
  8516. var xmlStaminaDamage : float;
  8517. var xmlStaminaDamageName : name = 'stamina_damage' ;
  8518. var counter : int;
  8519. var onHitCounter : SAbilityAttributeValue;
  8520.  
  8521.  
  8522.  
  8523.  
  8524. if(CanParryAttack() && FistFightCheck( parryInfo.target, parryInfo.attacker, fistFightParry ) )
  8525. {
  8526. parryHeading = GetParryHeading( parryInfo, parryDir ) ;
  8527.  
  8528. SetBehaviorVariable( 'parryDirection', (float)( (int)( parryDir ) ) );
  8529. SetBehaviorVariable( 'parryDirectionOverlay', (float)( (int)( parryDir ) ) );
  8530. SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
  8531.  
  8532. if ( IsInCombatActionFriendly() )
  8533. RaiseEvent('CombatActionFriendlyEnd');
  8534.  
  8535. if ( HasStaminaToParry(parryInfo.attackActionName) )
  8536. {
  8537. this.SetBehaviorVariable( 'combatActionType', (int)CAT_Parry );
  8538.  
  8539. if ( parryInfo.targetToAttackerDist > 3.f && !bLAxisReleased && !thePlayer.IsCiri() )
  8540. {
  8541. if ( !RaiseForceEvent( 'PerformParryOverlay' ) )
  8542. return false;
  8543. else
  8544. {
  8545. ClearCustomOrientationInfoStack();
  8546. IncDefendCounter();
  8547. }
  8548. }
  8549. else
  8550. {
  8551. counter = GetDefendCounter();
  8552. onHitCounter = parryInfo.attacker.GetAttributeValue( 'break_through_parry_on_hit_counter' );
  8553. if ( onHitCounter.valueBase > 0 && counter == onHitCounter.valueBase )
  8554. {
  8555. AddEffectDefault( EET_Stagger, parryInfo.attacker, "Break through parry" );
  8556. }
  8557. else if ( RaiseForceEvent( 'PerformParry' ) )
  8558. {
  8559. OnCombatActionStart();
  8560. ClearCustomOrientationInfoStack();
  8561. SetSlideTarget( parryInfo.attacker );
  8562. SetCustomRotation( 'Parry', parryHeading, 1080.f, 0.1f, false );
  8563. IncDefendCounter();
  8564. }
  8565. else
  8566. return false;
  8567. }
  8568. }
  8569. else
  8570. {
  8571. AddEffectDefault(EET_Stagger, parryInfo.attacker, "Parry");
  8572. return true;
  8573. }
  8574.  
  8575. if ( parryInfo.attacker.IsWeaponHeld( 'fist' ) && !parryInfo.target.IsWeaponHeld( 'fist' ) )
  8576. {
  8577. parryInfo.attacker.ReactToReflectedAttack(parryInfo.target);
  8578. }
  8579. else
  8580. {
  8581. if ( this.IsInFistFightMiniGame() && fistFightParry )
  8582. {
  8583. if ( IsNameValid(xmlStaminaDamageName) )
  8584. {
  8585. xmlStaminaDamage = CalculateAttributeValue(parryInfo.attacker.GetAttributeValue( xmlStaminaDamageName ));
  8586. DrainStamina(ESAT_FixedValue, xmlStaminaDamage);
  8587. }
  8588. }
  8589. else
  8590. {
  8591. DrainStamina(ESAT_Parry, 0, 0, '', 0, mult);
  8592. }
  8593. if(IsLightAttack(parryInfo.attackActionName))
  8594. parryInfo.target.PlayEffectOnHeldWeapon('light_block');
  8595. else
  8596. parryInfo.target.PlayEffectOnHeldWeapon('heavy_block');
  8597. }
  8598. return true;
  8599. }
  8600.  
  8601. return false;
  8602. }
  8603.  
  8604. protected function GetParryHeading( parryInfo : SParryInfo, out parryDir : EPlayerParryDirection ) : float
  8605. {
  8606. var targetToAttackerHeading : float;
  8607. var currToTargetAttackerAngleDiff : float;
  8608.  
  8609. targetToAttackerHeading = VecHeading( parryInfo.attacker.GetWorldPosition() - parryInfo.target.GetWorldPosition() );
  8610. currToTargetAttackerAngleDiff = AngleDistance( VecHeading( parryInfo.target.GetHeadingVector() ), targetToAttackerHeading );
  8611.  
  8612. if ( !parryInfo.target.IsWeaponHeld( 'fist' ) )
  8613. {
  8614. if( currToTargetAttackerAngleDiff > -45 && currToTargetAttackerAngleDiff < 45 )
  8615. {
  8616. parryDir = PPD_Forward;
  8617. return targetToAttackerHeading;
  8618. }
  8619. else if( currToTargetAttackerAngleDiff >= 45 && currToTargetAttackerAngleDiff < 135 )
  8620. {
  8621. parryDir = PPD_Right;
  8622.  
  8623. return targetToAttackerHeading + 90;
  8624. }
  8625. else if( currToTargetAttackerAngleDiff <= -45 && currToTargetAttackerAngleDiff > -135 )
  8626. {
  8627. parryDir = PPD_Left;
  8628.  
  8629. return targetToAttackerHeading - 90;
  8630. }
  8631. else
  8632. {
  8633. parryDir = PPD_Back;
  8634.  
  8635. return targetToAttackerHeading + 180;
  8636. }
  8637. }
  8638. else
  8639. {
  8640. if( currToTargetAttackerAngleDiff > -45 && currToTargetAttackerAngleDiff < 45 )
  8641. {
  8642. parryDir = PPD_Forward;
  8643. return targetToAttackerHeading;
  8644. }
  8645. else if( currToTargetAttackerAngleDiff >= 45 && currToTargetAttackerAngleDiff < 180 )
  8646. {
  8647. parryDir = PPD_Right;
  8648. return targetToAttackerHeading + 90;
  8649. }
  8650. else if( currToTargetAttackerAngleDiff <= -45 && currToTargetAttackerAngleDiff >= -180 )
  8651. {
  8652. parryDir = PPD_Left;
  8653. return targetToAttackerHeading - 90;
  8654. }
  8655. else
  8656. {
  8657. parryDir = PPD_Back;
  8658. return targetToAttackerHeading + 180;
  8659. }
  8660. }
  8661. }
  8662.  
  8663. function ProcessLockTarget( optional newLockTarget : CActor, optional checkLeftStickHeading : bool ) : bool
  8664. {
  8665. var attackerNearestPoint : Vector;
  8666. var playerNearestPoint : Vector;
  8667. var incomingAttacker : CActor;
  8668. var tempLockTarget : CActor;
  8669. var target : CActor;
  8670. var useIncomingAttacker : bool;
  8671.  
  8672. if( newLockTarget.HasTag( 'NoHardLock' ) )
  8673. return false;
  8674.  
  8675. if ( newLockTarget )
  8676. tempLockTarget = newLockTarget;
  8677. else
  8678. {
  8679. incomingAttacker = GetClosestIncomingAttacker();
  8680. if ( incomingAttacker && incomingAttacker.IsAlive() && IsUsingVehicle() )
  8681. {
  8682. tempLockTarget = incomingAttacker;
  8683. useIncomingAttacker = false;
  8684. }
  8685.  
  8686. if ( !useIncomingAttacker )
  8687. {
  8688. target = GetTarget();
  8689. if( target.HasTag('ForceHardLock'))
  8690. {
  8691. return true;
  8692. }
  8693. else if ( target && target.IsAlive() && target.GetGameplayVisibility() && IsEnemyVisible( target ) && IsThreat( target ) && CanBeTargetedIfSwimming( target ) )
  8694. tempLockTarget = FindTarget();
  8695. else
  8696. {
  8697. tempLockTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, 0.f );
  8698. }
  8699. }
  8700. }
  8701.  
  8702. if( tempLockTarget.HasTag( 'NoHardLock' ) )
  8703. return false;
  8704.  
  8705. if ( tempLockTarget )
  8706. {
  8707. if ( IsCombatMusicEnabled() || hostileEnemies.Size() > 0 )
  8708. {
  8709. if ( !IsThreat( tempLockTarget ) )
  8710. tempLockTarget = NULL;
  8711. }
  8712. }
  8713.  
  8714. SetTarget( tempLockTarget, true );
  8715. SetMoveTargetChangeAllowed( true );
  8716. SetMoveTarget( tempLockTarget );
  8717. SetMoveTargetChangeAllowed( false );
  8718. SetSlideTarget( tempLockTarget );
  8719.  
  8720. if ( tempLockTarget )
  8721. {
  8722. if ( this.IsActorLockedToTarget() )
  8723. EnableHardLockIcon( true );
  8724.  
  8725. return true;
  8726. }
  8727. else
  8728. return false;
  8729. }
  8730.  
  8731.  
  8732.  
  8733.  
  8734.  
  8735. event OnTaskSyncAnim( npc : CNewNPC, animNameLeft : name ) {}
  8736.  
  8737.  
  8738. public function IsDoingSpecialAttack(heavy : bool) : bool
  8739. {
  8740. var pat : EPlayerAttackType;
  8741.  
  8742. if(IsInCombatAction() && ( (int)GetBehaviorVariable('combatActionType')) == CAT_SpecialAttack)
  8743. {
  8744. pat = (int)GetBehaviorVariable('playerAttackType');
  8745.  
  8746. if(heavy && pat == PAT_Heavy)
  8747. {
  8748. return true;
  8749. }
  8750. else if(!heavy && pat == PAT_Light)
  8751. {
  8752. return true;
  8753. }
  8754. }
  8755.  
  8756. return false;
  8757. }
  8758.  
  8759. public function SetIsCurrentlyDodging(enable : bool, optional isRolling : bool)
  8760. {
  8761. super.SetIsCurrentlyDodging(enable, isRolling);
  8762.  
  8763. if ( isRolling )
  8764. {
  8765. SetCanPlayHitAnim( false );
  8766. this.AddBuffImmunity( EET_KnockdownTypeApplicator, 'Roll', false );
  8767. this.AddBuffImmunity( EET_Knockdown, 'Roll', false );
  8768. this.AddBuffImmunity( EET_HeavyKnockdown, 'Roll', false );
  8769. this.AddBuffImmunity( EET_Stagger, 'Roll', false );
  8770. }
  8771. else
  8772. {
  8773. SetCanPlayHitAnim( true );
  8774. this.RemoveBuffImmunity( EET_KnockdownTypeApplicator, 'Roll' );
  8775. this.RemoveBuffImmunity( EET_Knockdown, 'Roll' );
  8776. this.RemoveBuffImmunity( EET_HeavyKnockdown, 'Roll' );
  8777. this.RemoveBuffImmunity( EET_Stagger, 'Roll' );
  8778. }
  8779. }
  8780.  
  8781. public function EnableHardLock( flag : bool )
  8782. {
  8783. super.EnableHardLock(flag);
  8784.  
  8785. if(flag && ShouldProcessTutorial('TutorialTargettingWaiting'))
  8786. {
  8787. FactsAdd("tut_hardlocked");
  8788. }
  8789. }
  8790.  
  8791. protected function TestParryAndCounter(data : CPreAttackEventData, weaponId : SItemUniqueId, out parried : bool, out countered : bool) : array<CActor>
  8792. {
  8793. var ret : array<CActor>;
  8794.  
  8795.  
  8796. if(FactsQuerySum('player_is_the_boss') > 0)
  8797. {
  8798.  
  8799.  
  8800. SetDebugAttackRange(data.rangeName);
  8801. RemoveTimer('PostAttackDebugRangeClear');
  8802.  
  8803. return ret;
  8804. }
  8805.  
  8806. ret = super.TestParryAndCounter(data, weaponId, parried, countered);
  8807.  
  8808.  
  8809. if(parried)
  8810. theGame.GetGamerProfile().ResetStat(ES_CounterattackChain);
  8811.  
  8812. return ret;
  8813. }
  8814.  
  8815. public function SetSpecialAttackTimeRatio(f : float)
  8816. {
  8817. LogSpecialHeavy(f);
  8818. specialAttackTimeRatio = f;
  8819. }
  8820.  
  8821. public function GetSpecialAttackTimeRatio() : float
  8822. {
  8823. return specialAttackTimeRatio;
  8824. }
  8825.  
  8826.  
  8827. public function OnSpecialAttackHeavyActionProcess()
  8828. {
  8829.  
  8830. SetSpecialAttackTimeRatio(0.f);
  8831. }
  8832.  
  8833. protected function DoAttack(animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float)
  8834. {
  8835. var shakeStr : float;
  8836. var weapon : EPlayerWeapon;
  8837. var targetActor : CActor;
  8838.  
  8839.  
  8840. if ( animData.attackName == 'attack_heavy_special' )
  8841. {
  8842. if( specialAttackTimeRatio != 1 )
  8843. shakeStr = (specialAttackTimeRatio / 3.333) + 0.2;
  8844. else
  8845. shakeStr = 0.5;
  8846.  
  8847. GCameraShake( shakeStr, false, GetWorldPosition(), 10);
  8848. }
  8849. else if ( IsHeavyAttack(attackActionName) )
  8850. {
  8851. if(parriedBy.Size() > 0)
  8852. shakeStr = 0.2;
  8853. else
  8854. shakeStr = 0.1;
  8855.  
  8856. GCameraShake(shakeStr, false, GetWorldPosition(), 10);
  8857. }
  8858.  
  8859. targetActor = (CActor)slideTarget;
  8860. if ( targetActor && hitTargets.Contains(targetActor) )
  8861. {
  8862. weapon = this.GetMostConvenientMeleeWeapon(targetActor,true);
  8863. if ( this.GetCurrentMeleeWeaponType() != PW_Fists && weapon != this.GetCurrentMeleeWeaponType() )
  8864. {
  8865. if ( weapon == PW_Steel )
  8866. {
  8867. thePlayer.OnEquipMeleeWeapon(PW_Steel,true);
  8868. }
  8869. else if ( weapon == PW_Silver )
  8870. {
  8871. thePlayer.OnEquipMeleeWeapon(PW_Silver,true);
  8872. }
  8873.  
  8874. }
  8875. }
  8876.  
  8877. super.DoAttack(animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime);
  8878. }
  8879.  
  8880.  
  8881.  
  8882. private var confirmCombatStanceTimeStamp : float;
  8883. private var isConfirmingCombatStance : bool;
  8884. final function SetPlayerCombatStance(stance : EPlayerCombatStance, optional force : bool )
  8885. {
  8886. var stanceInt : int;
  8887.  
  8888. if ( !CanChangeCombatStance( stance, force ) )
  8889. return;
  8890.  
  8891. combatStance = stance;
  8892. stanceInt = (int)stance;
  8893.  
  8894. SetBehaviorVariable( 'playerCombatStance' , (float)stanceInt);
  8895. SetBehaviorVariable( 'playerCombatStanceForOverlay' , (float)stanceInt);
  8896. if ( force )
  8897. SetBehaviorVariable( 'forceCombatStance' , 1.f);
  8898. else
  8899. SetBehaviorVariable( 'forceCombatStance' , 0.f);
  8900.  
  8901. if ( stance == PCS_AlertNear )
  8902. this.SetBehaviorVariable('isInCombatForOverlay',1.f);
  8903. else
  8904. this.SetBehaviorVariable('isInCombatForOverlay',0.f);
  8905. }
  8906.  
  8907. private function CanChangeCombatStance( stance : EPlayerCombatStance, optional force : bool ) : bool
  8908. {
  8909. var currTime : float;
  8910.  
  8911. if ( force )
  8912. return true;
  8913.  
  8914. if ( IsInFistFightMiniGame() )
  8915. return true;
  8916.  
  8917. if ( isInHolsterAnim )
  8918. return false;
  8919.  
  8920. if ( ( combatStance == PCS_Normal || combatStance == PCS_AlertFar ) && stance == PCS_AlertNear )
  8921. {
  8922. currTime = theGame.GetEngineTimeAsSeconds();
  8923. if ( !isConfirmingCombatStance )
  8924. {
  8925. isConfirmingCombatStance = true;
  8926. confirmCombatStanceTimeStamp = currTime;
  8927.  
  8928. return false;
  8929. }
  8930. else if ( currTime < confirmCombatStanceTimeStamp + 1.f )
  8931. {
  8932. if ( stance == PCS_AlertNear )
  8933. return false;
  8934. }
  8935. else
  8936. isConfirmingCombatStance = false;
  8937. }
  8938. else
  8939. isConfirmingCombatStance = false;
  8940.  
  8941. return true;
  8942. }
  8943.  
  8944. private var isInHolsterAnim : bool;
  8945. event OnHolsterWeaponStart()
  8946. {
  8947. isInHolsterAnim = true;
  8948. }
  8949.  
  8950. event OnHolsterWeaponEnd()
  8951. {
  8952. isInHolsterAnim = false;
  8953. }
  8954.  
  8955. final function GetPlayerCombatStance() : EPlayerCombatStance
  8956. {
  8957. return combatStance;
  8958. }
  8959.  
  8960. timer function DelayedDisableFindTarget( time : float , id : int)
  8961. {
  8962. if ( GetTarget().IsAlive() )
  8963. {
  8964. EnableFindTarget( false );
  8965. }
  8966. else
  8967. {
  8968. EnableFindTarget( true );
  8969. }
  8970. }
  8971.  
  8972.  
  8973.  
  8974.  
  8975.  
  8976. private var dodgeTimerRunning : bool;
  8977.  
  8978. function StartDodgeTimer()
  8979. {
  8980. dodgeTimerRunning = true;
  8981. thePlayer.AddTimer('DodgeTimer',0.2,false);
  8982. }
  8983.  
  8984. function StopDodgeTimer()
  8985. {
  8986. this.RemoveTimer('DodgeTimer');
  8987. dodgeTimerRunning = false;
  8988. }
  8989.  
  8990. function IsDodgeTimerRunning() : bool
  8991. {
  8992. return dodgeTimerRunning;
  8993. }
  8994.  
  8995. timer function DodgeTimer( dt : float, id : int )
  8996. {
  8997. dodgeTimerRunning = false;
  8998. }
  8999.  
  9000. public function EvadePressed( bufferAction : EBufferActionType )
  9001. {
  9002. }
  9003.  
  9004. public function PerformingCombatAction() : EBufferActionType
  9005. {
  9006. return BufferCombatAction;
  9007. }
  9008.  
  9009. public function PushCombatActionOnBuffer( action : EBufferActionType, stage : EButtonStage, optional allSteps : bool )
  9010. {
  9011. BufferButtonStage = stage;
  9012. BufferCombatAction = action;
  9013. BufferAllSteps = allSteps;
  9014. }
  9015.  
  9016. protected function ProcessCombatActionHeading( action : EBufferActionType ) : float
  9017. {
  9018. var processedActionHeading : float;
  9019.  
  9020. HandleMovement( 0.f );
  9021.  
  9022. if ( ShouldUsePCModeTargeting() )
  9023. return theGame.GetGameCamera().GetHeading();
  9024.  
  9025. if ( lAxisReleasedAfterCounter )
  9026. ResetCachedRawPlayerHeading();
  9027.  
  9028. processedActionHeading = cachedRawPlayerHeading;
  9029.  
  9030. return processedActionHeading;
  9031. }
  9032.  
  9033.  
  9034. function ResetRawPlayerHeading()
  9035. {
  9036. if ( GetDisplayTarget() )
  9037. rawPlayerHeading = VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() );
  9038. else
  9039. rawPlayerHeading = GetHeading();
  9040.  
  9041.  
  9042. }
  9043.  
  9044. function ResetCachedRawPlayerHeading()
  9045. {
  9046. cachedRawPlayerHeading = rawPlayerHeading;
  9047. if ( GetDisplayTarget() && IsDisplayTargetTargetable() && AbsF( AngleDistance( VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() ), this.GetHeading() ) ) < 90.f )
  9048. cachedRawPlayerHeading = VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() );
  9049. else
  9050. cachedRawPlayerHeading = this.GetHeading();
  9051.  
  9052. if ( canResetCachedCombatActionHeading )
  9053. cachedCombatActionHeading = cachedRawPlayerHeading;
  9054. }
  9055.  
  9056. public function GetCombatActionTarget( action : EBufferActionType ) : CGameplayEntity
  9057. {
  9058. var selectedTargetableEntity : CGameplayEntity;
  9059.  
  9060. if ( !this.IsUsingVehicle() )
  9061. selectedTargetableEntity = FindNonActorTarget( true, action );
  9062.  
  9063. if ( selectedTargetableEntity )
  9064. {
  9065. return selectedTargetableEntity;
  9066. }
  9067. else
  9068. {
  9069.  
  9070.  
  9071. if ( !this.IsUsingVehicle() )
  9072. FindTarget( true, action, true );
  9073. else
  9074. ((CR4PlayerStateUseGenericVehicle)this.GetState( 'UseGenericVehicle' )).FindTarget();
  9075.  
  9076. return GetTarget();
  9077. }
  9078. }
  9079.  
  9080.  
  9081. private function FindNonActorTarget( actionCheck : bool, optional action : EBufferActionType ) : CGameplayEntity
  9082. {
  9083. var targetableEntities : array<CGameplayEntity>;
  9084. var selectedTargetableEntity : CGameplayEntity;
  9085. var selectionPriority : array< float >;
  9086. var selectionWeights : STargetSelectionWeights;
  9087. var findEntityDist : float;
  9088. var i, size : int;
  9089. var playerHeading : float;
  9090. var playerInventory : CInventoryComponent;
  9091. var castSignType : ESignType;
  9092. var targetingInfo : STargetingInfo;
  9093. var playerPosition : Vector;
  9094. var cameraPosition : Vector;
  9095. var playerHeadingVector : Vector;
  9096. var rawPlayerHeadingVector : Vector;
  9097.  
  9098. playerPosition = this.GetWorldPosition();
  9099. cameraPosition = theCamera.GetCameraPosition();
  9100. rawPlayerHeadingVector = VecFromHeading( rawPlayerHeading );
  9101.  
  9102. if ( bCanFindTarget && !IsHardLockEnabled() )
  9103. {
  9104. if ( actionCheck && IsInCombat() && action == EBAT_CastSign )
  9105. {
  9106. findEntityDist = 6.f;
  9107. selectionWeights.angleWeight = 0.375f;
  9108. selectionWeights.distanceWeight = 0.275f;
  9109. selectionWeights.distanceRingWeight = 0.35f;
  9110. }
  9111. else if ( !IsInCombat() && lastAxisInputIsMovement )
  9112. {
  9113. findEntityDist = softLockDist;
  9114. selectionWeights.angleWeight = 0.375f;
  9115. selectionWeights.distanceWeight = 0.275f;
  9116. selectionWeights.distanceRingWeight = 0.35f;
  9117. }
  9118. else
  9119. {
  9120. findEntityDist = softLockDist;
  9121. selectionWeights.angleWeight = 0.75f;
  9122. selectionWeights.distanceWeight = 0.125f;
  9123. selectionWeights.distanceRingWeight = 0.125f;
  9124. }
  9125.  
  9126.  
  9127. if ( !IsInCombat() || !bLAxisReleased )
  9128. {
  9129. FindGameplayEntitiesInRange( targetableEntities, this, findEntityDist, 10, theGame.params.TAG_SOFT_LOCK );
  9130. }
  9131.  
  9132. if ( targetableEntities.Size() > 0 )
  9133. {
  9134. playerInventory = this.GetInventory();
  9135. castSignType = this.GetEquippedSign();
  9136.  
  9137. if ( !bLAxisReleased )
  9138. {
  9139. targetingInfo.source = this;
  9140. targetingInfo.canBeTargetedCheck = false;
  9141. targetingInfo.coneCheck = true;
  9142. targetingInfo.coneHalfAngleCos = 0.5f;
  9143. targetingInfo.coneDist = softLockDist;
  9144. targetingInfo.coneHeadingVector = rawPlayerHeadingVector;
  9145. targetingInfo.distCheck = true;
  9146. targetingInfo.invisibleCheck = false;
  9147. targetingInfo.navMeshCheck = false;
  9148. targetingInfo.frameScaleX = 1.0f;
  9149. targetingInfo.frameScaleY = 1.0f;
  9150. targetingInfo.knockDownCheck = false;
  9151. targetingInfo.knockDownCheckDist = 0.0f;
  9152. targetingInfo.rsHeadingCheck = false;
  9153. targetingInfo.rsHeadingLimitCos = 1.0f;
  9154. }
  9155.  
  9156. for( i = targetableEntities.Size()-1; i>=0; i-=1 )
  9157. {
  9158. if ( bLAxisReleased )
  9159. {
  9160. if ( !lastAxisInputIsMovement )
  9161. {
  9162. if ( !WasVisibleInScaledFrame( targetableEntities[i], 0.9f, 0.9f ) )
  9163. {
  9164. targetableEntities.Erase(i);
  9165. continue;
  9166. }
  9167. }
  9168. else if ( !WasVisibleInScaledFrame( targetableEntities[i], 1.f, 1.f ) )
  9169. {
  9170. targetableEntities.Erase(i);
  9171. continue;
  9172. }
  9173. }
  9174. else
  9175. {
  9176. targetingInfo.targetEntity = targetableEntities[i];
  9177. if ( actionCheck && moveTarget )
  9178. {
  9179. targetingInfo.inFrameCheck = false;
  9180. if ( !IsEntityTargetable( targetingInfo ) )
  9181. {
  9182. targetableEntities.Erase(i);
  9183. continue;
  9184. }
  9185. }
  9186. else
  9187. {
  9188. targetingInfo.inFrameCheck = true;
  9189. if ( !IsEntityTargetable( targetingInfo ) )
  9190. {
  9191. targetableEntities.Erase(i);
  9192. continue;
  9193. }
  9194. }
  9195. }
  9196.  
  9197. if ( actionCheck )
  9198. {
  9199. if ( action == EBAT_ItemUse )
  9200. {
  9201. if ( ( playerInventory.IsItemBomb( this.GetSelectedItemId() ) && !targetableEntities[i].HasTag( 'softLock_Bomb' ) )
  9202. || ( playerInventory.IsItemCrossbow( this.GetSelectedItemId() ) && !targetableEntities[i].HasTag( 'softLock_Bolt' ) ) )
  9203. {
  9204. targetableEntities.Erase(i);
  9205. continue;
  9206. }
  9207. }
  9208. else if ( action == EBAT_CastSign )
  9209. {
  9210. if ( ( castSignType == ST_Aard && !targetableEntities[i].HasTag( 'softLock_Aard' ) )
  9211. || ( castSignType == ST_Igni && !targetableEntities[i].HasTag( 'softLock_Igni' ) )
  9212. || ( castSignType == ST_Axii && !targetableEntities[i].HasTag( 'softLock_Axii' ) )
  9213. || castSignType == ST_Yrden
  9214. || castSignType == ST_Quen )
  9215. {
  9216. targetableEntities.Erase(i);
  9217. continue;
  9218. }
  9219. }
  9220. else if ( action == EBAT_LightAttack || action == EBAT_HeavyAttack || action == EBAT_SpecialAttack_Heavy )
  9221. {
  9222. if ( ( IsWeaponHeld( 'fist' ) && !targetableEntities[i].HasTag( 'softLock_Fist' ) ) || ( !IsWeaponHeld( 'fist' ) && !targetableEntities[i].HasTag( 'softLock_Weapon' ) ) )
  9223. {
  9224. targetableEntities.Erase(i);
  9225. continue;
  9226. }
  9227. }
  9228. else
  9229. {
  9230. targetableEntities.Erase(i);
  9231. continue;
  9232. }
  9233. }
  9234. }
  9235. }
  9236.  
  9237. if ( targetableEntities.Size() > 0)
  9238. {
  9239. playerHeading = this.GetHeading();
  9240. playerHeadingVector = this.GetHeadingVector();
  9241. if ( IsInCombat() )
  9242. {
  9243. for( i = 0; i < targetableEntities.Size(); i += 1 )
  9244. {
  9245. if ( bLAxisReleased )
  9246. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, cameraPosition, rawPlayerHeadingVector ) );
  9247. else
  9248. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, rawPlayerHeadingVector ) );
  9249. }
  9250.  
  9251. if ( selectionPriority.Size() > 0 )
  9252. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  9253. }
  9254. else
  9255. {
  9256. if ( bLAxisReleased )
  9257. {
  9258. if ( !lastAxisInputIsMovement )
  9259. {
  9260. for( i = 0; i < targetableEntities.Size(); i += 1 )
  9261. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, cameraPosition, rawPlayerHeadingVector ) );
  9262.  
  9263. if ( selectionPriority.Size() > 0 )
  9264. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  9265. }
  9266. else
  9267. {
  9268. if ( IsInCombatAction() )
  9269. selectedTargetableEntity = nonActorTarget;
  9270. else
  9271. {
  9272. for( i = 0; i < targetableEntities.Size(); i += 1 )
  9273. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, playerHeadingVector ) );
  9274.  
  9275. if ( selectionPriority.Size() > 0 )
  9276. {
  9277. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  9278.  
  9279. targetingInfo.source = this;
  9280. targetingInfo.targetEntity = selectedTargetableEntity;
  9281. targetingInfo.canBeTargetedCheck = false;
  9282. targetingInfo.coneCheck = true;
  9283. targetingInfo.coneHalfAngleCos = 0.0f;
  9284. targetingInfo.coneDist = softLockDist;
  9285. targetingInfo.coneHeadingVector = this.GetHeadingVector();
  9286. targetingInfo.distCheck = true;
  9287. targetingInfo.invisibleCheck = false;
  9288. targetingInfo.navMeshCheck = false;
  9289. targetingInfo.inFrameCheck = false;
  9290. targetingInfo.frameScaleX = 1.0f;
  9291. targetingInfo.frameScaleY = 1.0f;
  9292. targetingInfo.knockDownCheck = false;
  9293. targetingInfo.knockDownCheckDist = 0.0f;
  9294. targetingInfo.rsHeadingCheck = false;
  9295. targetingInfo.rsHeadingLimitCos = 1.0f;
  9296.  
  9297. if ( !IsEntityTargetable( targetingInfo ) )
  9298. selectedTargetableEntity = NULL;
  9299. }
  9300. }
  9301. }
  9302. }
  9303. else
  9304. {
  9305. for( i = 0; i < targetableEntities.Size(); i += 1 )
  9306. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, rawPlayerHeadingVector ) );
  9307.  
  9308. if ( selectionPriority.Size() > 0 )
  9309. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  9310. }
  9311. }
  9312. }
  9313. else
  9314. selectedTargetableEntity = NULL;
  9315. }
  9316.  
  9317. SetNonActorTarget( selectedTargetableEntity );
  9318. return selectedTargetableEntity;
  9319. }
  9320.  
  9321.  
  9322. public function SetupCombatAction( action : EBufferActionType, stage : EButtonStage )
  9323. {
  9324. var weaponType : EPlayerWeapon;
  9325. var canAttackTarget : CGameplayEntity;
  9326. var target : CActor;
  9327.  
  9328.  
  9329. if ( !IsCombatMusicEnabled() )
  9330. {
  9331. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  9332. FindTarget();
  9333. UpdateDisplayTarget( true );
  9334. }
  9335.  
  9336. if ( displayTarget && IsDisplayTargetTargetable() )
  9337. canAttackTarget = displayTarget;
  9338. else if ( GetTarget() )
  9339. canAttackTarget = GetTarget();
  9340. else if( !target && IsCombatMusicEnabled() )
  9341. canAttackTarget = moveTarget;
  9342.  
  9343. target = (CActor)canAttackTarget;
  9344.  
  9345. if ( !AllowAttack( target, action ) )
  9346. return;
  9347.  
  9348. if( ( action != EBAT_ItemUse ) && ( action != EBAT_CastSign ) )
  9349. {
  9350. weaponType = weaponHolster.GetCurrentMeleeWeapon();
  9351. PrepareToAttack( target, action );
  9352.  
  9353.  
  9354. if ( weaponType != weaponHolster.GetCurrentMeleeWeapon() )
  9355. {
  9356.  
  9357. if ( !( weaponType == PW_None && weaponHolster.GetCurrentMeleeWeapon() == PW_Fists ) )
  9358. return;
  9359. }
  9360. }
  9361.  
  9362.  
  9363. if(action == EBAT_SpecialAttack_Heavy && !((W3ReplacerCiri)this) )
  9364. thePlayer.SetAttackActionName(SkillEnumToName(S_Sword_s02));
  9365.  
  9366. CriticalEffectAnimationInterrupted("SetupCombatAction " + action);
  9367. PushCombatActionOnBuffer( action, stage );
  9368.  
  9369. if( GetBIsCombatActionAllowed() )
  9370. {
  9371. ProcessCombatActionBuffer();
  9372. }
  9373. }
  9374.  
  9375. public function AllowAttack( target : CActor, action : EBufferActionType ) : bool
  9376. {
  9377. var newTarget : CActor;
  9378. var canAttackWhenNotInCombat : bool;
  9379. var messageDisplayed : bool;
  9380.  
  9381. var itemId : SItemUniqueId;
  9382. var isShootingCrossbow : bool;
  9383.  
  9384. var isInCorrectState : bool;
  9385.  
  9386. if ( target )
  9387. {
  9388. if ( target.IsTargetableByPlayer())
  9389. {
  9390. if ( !target.IsAttackableByPlayer() )
  9391. {
  9392. DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_cant_attack_this_target"));
  9393. return false;
  9394. }
  9395. }
  9396. }
  9397.  
  9398. if ( this.GetCurrentStateName() == 'Exploration' )
  9399. isInCorrectState = true;
  9400.  
  9401. if ( action == EBAT_ItemUse )
  9402. {
  9403. itemId = thePlayer.GetSelectedItemId();
  9404. if ( inv.IsIdValid(itemId) && inv.IsItemCrossbow(itemId) )
  9405. isShootingCrossbow = true;
  9406.  
  9407. if ( !isInCorrectState )
  9408. {
  9409. if ( this.GetCurrentStateName() == 'AimThrow' && !isShootingCrossbow )
  9410. {
  9411. isInCorrectState = true;
  9412. }
  9413. }
  9414. }
  9415.  
  9416. if ( isInCorrectState )
  9417. canAttackWhenNotInCombat = thePlayer.CanAttackWhenNotInCombat( action, false, newTarget, target );
  9418.  
  9419. if( !target )
  9420. {
  9421. if ( isInCorrectState )
  9422. {
  9423. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  9424. target = newTarget;
  9425. }
  9426. }
  9427.  
  9428. if ( isInCorrectState )
  9429. {
  9430. if ( !canAttackWhenNotInCombat )
  9431. {
  9432. if ( DisplayCannotAttackMessage( target ) )
  9433. messageDisplayed = true;
  9434. else if ( ( action == EBAT_LightAttack || action == EBAT_HeavyAttack )
  9435. && !RaiseAttackFriendlyEvent( target ) )
  9436. messageDisplayed = true;
  9437. else
  9438. {
  9439. if ( !CanRaiseCombatActionFriendlyEvent( isShootingCrossbow ) )
  9440. messageDisplayed = true;
  9441. }
  9442. }
  9443.  
  9444. if ( messageDisplayed )
  9445. {
  9446. theInput.ForceDeactivateAction('ThrowItem');
  9447. theInput.ForceDeactivateAction('ThrowItemHold');
  9448. this.SignalGameplayEvent( 'FriendlyAttackAction' );
  9449. return false;
  9450. }
  9451. }
  9452.  
  9453. return true;
  9454. }
  9455.  
  9456.  
  9457.  
  9458. public function ProcessCombatActionBuffer() : bool
  9459. {
  9460. var actionResult : bool;
  9461. var action : EBufferActionType = this.BufferCombatAction;
  9462. var stage : EButtonStage = this.BufferButtonStage;
  9463. var s : SNotWorkingOutFunctionParametersHackStruct1;
  9464. var allSteps : bool = this.BufferAllSteps;
  9465.  
  9466. if ( IsInCombatActionFriendly() )
  9467. {
  9468. RaiseEvent('CombatActionFriendlyEnd');
  9469. }
  9470.  
  9471.  
  9472. if ( ( action != EBAT_SpecialAttack_Heavy && action != EBAT_ItemUse )
  9473. || ( action == EBAT_SpecialAttack_Heavy && stage == BS_Pressed )
  9474. || ( action == EBAT_ItemUse && stage != BS_Released ) )
  9475. {
  9476. GetMovingAgentComponent().GetMovementAdjustor().CancelAll();
  9477. SetUnpushableTarget( NULL );
  9478. }
  9479.  
  9480.  
  9481. if ( !( action == EBAT_Dodge || action == EBAT_Roll ) )
  9482. {
  9483. SetIsCurrentlyDodging(false);
  9484. }
  9485.  
  9486. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  9487.  
  9488.  
  9489.  
  9490. if ( action == EBAT_ItemUse && GetInventory().IsItemCrossbow( selectedItemId ) )
  9491. {
  9492.  
  9493. if ( rangedWeapon
  9494. && ( ( rangedWeapon.GetCurrentStateName() != 'State_WeaponShoot' && rangedWeapon.GetCurrentStateName() != 'State_WeaponAim' ) || GetIsShootingFriendly() ) )
  9495. {
  9496. SetSlideTarget( GetCombatActionTarget( action ) );
  9497. }
  9498. }
  9499. else if ( !( ( action == EBAT_SpecialAttack_Heavy && stage == BS_Released ) || GetCurrentStateName() == 'AimThrow' ) )
  9500. {
  9501. SetSlideTarget( GetCombatActionTarget( action ) );
  9502. }
  9503.  
  9504. if( !slideTarget )
  9505. LogChannel( 'Targeting', "NO SLIDE TARGET" );
  9506.  
  9507.  
  9508. actionResult = true;
  9509.  
  9510. switch ( action )
  9511. {
  9512. case EBAT_EMPTY :
  9513. {
  9514. this.BufferAllSteps = false;
  9515. return true;
  9516. } break;
  9517.  
  9518. case EBAT_LightAttack :
  9519. {
  9520. if ( IsCiri() )
  9521. return false;
  9522.  
  9523. switch ( stage )
  9524. {
  9525. case BS_Pressed :
  9526. {
  9527.  
  9528.  
  9529.  
  9530.  
  9531.  
  9532.  
  9533. DrainStamina(ESAT_LightAttack);
  9534.  
  9535.  
  9536. thePlayer.BreakPheromoneEffect();
  9537. actionResult = OnPerformAttack(theGame.params.ATTACK_NAME_LIGHT);
  9538.  
  9539. } break;
  9540.  
  9541. default :
  9542. {
  9543. actionResult = false;
  9544. }break;
  9545. }
  9546. }break;
  9547.  
  9548. case EBAT_HeavyAttack :
  9549. {
  9550. if ( IsCiri() )
  9551. return false;
  9552.  
  9553. switch ( stage )
  9554. {
  9555. case BS_Released :
  9556. {
  9557.  
  9558.  
  9559.  
  9560.  
  9561.  
  9562. DrainStamina(ESAT_HeavyAttack);
  9563.  
  9564.  
  9565.  
  9566. thePlayer.BreakPheromoneEffect();
  9567. actionResult = this.OnPerformAttack(theGame.params.ATTACK_NAME_HEAVY);
  9568.  
  9569. } break;
  9570.  
  9571. case BS_Pressed :
  9572. {
  9573. if ( this.GetCurrentStateName() == 'CombatFists' )
  9574. {
  9575.  
  9576.  
  9577.  
  9578.  
  9579.  
  9580. DrainStamina(ESAT_HeavyAttack);
  9581.  
  9582.  
  9583.  
  9584. thePlayer.BreakPheromoneEffect();
  9585. actionResult = this.OnPerformAttack(theGame.params.ATTACK_NAME_HEAVY);
  9586.  
  9587. }
  9588. } break;
  9589.  
  9590. default :
  9591. {
  9592. actionResult = false;
  9593.  
  9594. } break;
  9595. }
  9596. } break;
  9597.  
  9598. case EBAT_ItemUse :
  9599. {
  9600. switch ( stage )
  9601. {
  9602. case BS_Pressed :
  9603. {
  9604. if ( !( (W3PlayerWitcher)this ) ||
  9605. ( !IsInCombatActionFriendly() && !( !GetBIsCombatActionAllowed() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign ) ) ) )
  9606.  
  9607. {
  9608. if ( inv.IsItemCrossbow( selectedItemId ) )
  9609. {
  9610. rangedWeapon = ( Crossbow )( inv.GetItemEntityUnsafe( selectedItemId ) );
  9611. rangedWeapon.OnRangedWeaponPress();
  9612. GetTarget().SignalGameplayEvent( 'Approach' );
  9613. GetTarget().SignalGameplayEvent( 'ShootingCrossbow' );
  9614. }
  9615. else if(inv.IsItemBomb(selectedItemId) && this.inv.SingletonItemGetAmmo(selectedItemId) > 0 )
  9616. {
  9617. if( ((W3PlayerWitcher)this).GetBombDelay( ((W3PlayerWitcher)this).GetItemSlot( selectedItemId ) ) <= 0.0f )
  9618. {
  9619. BombThrowStart();
  9620. GetTarget().SignalGameplayEvent( 'Approach' );
  9621. }
  9622. }
  9623. else
  9624. {
  9625. DrainStamina(ESAT_UsableItem);
  9626. UsableItemStart();
  9627. }
  9628. }
  9629.  
  9630. } if (!allSteps) break;
  9631.  
  9632. case BS_Released:
  9633. {
  9634. if ( !( (W3PlayerWitcher)this ) ||
  9635. ( !IsInCombatActionFriendly() && ( GetBIsCombatActionAllowed() || !( !GetBIsCombatActionAllowed() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign ) ) ) ) )
  9636.  
  9637. {
  9638. if ( inv.IsItemCrossbow( selectedItemId ) )
  9639. {
  9640.  
  9641. rangedWeapon.OnRangedWeaponRelease();
  9642. }
  9643. else if(inv.IsItemBomb(selectedItemId))
  9644. {
  9645. BombThrowRelease();
  9646. }
  9647. else
  9648. {
  9649. UsableItemRelease();
  9650. }
  9651. }
  9652. } break;
  9653.  
  9654. default :
  9655. {
  9656. actionResult = false;
  9657. break;
  9658. }
  9659. }
  9660. } break;
  9661.  
  9662. case EBAT_Dodge :
  9663. {
  9664. switch ( stage )
  9665. {
  9666. case BS_Released :
  9667. {
  9668. theGame.GetBehTreeReactionManager().CreateReactionEvent( this, 'PlayerEvade', 1.0f, 10.0f, -1.0f, -1 );
  9669. thePlayer.BreakPheromoneEffect();
  9670. actionResult = this.OnPerformEvade( PET_Dodge );
  9671. } break;
  9672.  
  9673.  
  9674.  
  9675. default :
  9676. {
  9677. actionResult = false;
  9678. } break;
  9679. }
  9680. } break;
  9681.  
  9682. case EBAT_Roll :
  9683. {
  9684. if ( IsCiri() )
  9685. return false;
  9686.  
  9687. switch ( stage )
  9688. {
  9689. case BS_Released :
  9690. {
  9691. theGame.GetBehTreeReactionManager().CreateReactionEvent( this, 'PlayerEvade', 1.0f, 10.0f, -1.0f, -1 );
  9692. thePlayer.BreakPheromoneEffect();
  9693. actionResult = this.OnPerformEvade( PET_Roll );
  9694. } break;
  9695.  
  9696. case BS_Pressed :
  9697. {
  9698. if ( this.GetBehaviorVariable( 'combatActionType' ) == 2.f )
  9699. {
  9700. if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
  9701. actionResult = this.OnPerformEvade( PET_Pirouette );
  9702. else
  9703. actionResult = this.OnPerformEvade( PET_Roll );
  9704. }
  9705. else
  9706. {
  9707. if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
  9708. {
  9709. actionResult = this.OnPerformEvade( PET_Dodge );
  9710. actionResult = this.OnPerformEvade( PET_Pirouette );
  9711. }
  9712. else
  9713. {
  9714. actionResult = this.OnPerformEvade( PET_Dodge );
  9715. actionResult = this.OnPerformEvade( PET_Roll );
  9716. }
  9717. }
  9718.  
  9719.  
  9720. } break;
  9721.  
  9722. default :
  9723. {
  9724. actionResult = false;
  9725. } break;
  9726. }
  9727. } break;
  9728.  
  9729. case EBAT_Draw_Steel :
  9730. {
  9731. switch ( stage )
  9732. {
  9733. case BS_Pressed :
  9734. {
  9735. if( !IsActionAllowed(EIAB_DrawWeapon) )
  9736. {
  9737. thePlayer.DisplayActionDisallowedHudMessage(EIAB_DrawWeapon);
  9738. actionResult = false;
  9739. break;
  9740. }
  9741. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'steelsword' ) )
  9742. {
  9743. OnEquipMeleeWeapon( PW_Steel, false, true );
  9744. }
  9745.  
  9746. actionResult = false;
  9747.  
  9748. } break;
  9749.  
  9750. default :
  9751. {
  9752. actionResult = false;
  9753. } break;
  9754. }
  9755. } break;
  9756.  
  9757. case EBAT_Draw_Silver :
  9758. {
  9759. switch ( stage )
  9760. {
  9761. case BS_Pressed :
  9762. {
  9763. if( !IsActionAllowed(EIAB_DrawWeapon) )
  9764. {
  9765. thePlayer.DisplayActionDisallowedHudMessage(EIAB_DrawWeapon);
  9766. actionResult = false;
  9767. break;
  9768. }
  9769. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'silversword' ) )
  9770. {
  9771. OnEquipMeleeWeapon( PW_Silver, false, true );
  9772. }
  9773.  
  9774. actionResult = false;
  9775.  
  9776. } break;
  9777.  
  9778. default :
  9779. {
  9780. actionResult = false;
  9781. } break;
  9782. }
  9783. } break;
  9784.  
  9785. case EBAT_Sheathe_Sword :
  9786. {
  9787. switch ( stage )
  9788. {
  9789. case BS_Pressed :
  9790. {
  9791. if( GetCurrentMeleeWeaponType() == PW_Silver )
  9792. {
  9793. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'silversword' ) )
  9794. {
  9795. OnEquipMeleeWeapon( PW_Silver, false, true );
  9796. }
  9797. }
  9798. else if( GetCurrentMeleeWeaponType() == PW_Steel )
  9799. {
  9800. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'steelsword' ) )
  9801. {
  9802. OnEquipMeleeWeapon( PW_Steel, false, true );
  9803. }
  9804. }
  9805.  
  9806. actionResult = false;
  9807.  
  9808. } break;
  9809.  
  9810. default :
  9811. {
  9812. actionResult = false;
  9813. } break;
  9814. }
  9815. } break;
  9816.  
  9817. default:
  9818. return false;
  9819. }
  9820.  
  9821.  
  9822. CleanCombatActionBuffer();
  9823.  
  9824. if (actionResult)
  9825. {
  9826. SetCombatAction( action ) ;
  9827.  
  9828. if(GetWitcherPlayer().IsInFrenzy())
  9829. GetWitcherPlayer().SkillFrenzyFinish(0);
  9830. }
  9831.  
  9832. return true;
  9833. }
  9834.  
  9835. public function CleanCombatActionBuffer()
  9836. {
  9837. BufferCombatAction = EBAT_EMPTY;
  9838. BufferAllSteps = false;
  9839. }
  9840.  
  9841. public function CancelHoldAttacks()
  9842. {
  9843. RemoveTimer( 'IsSpecialLightAttackInputHeld' );
  9844. RemoveTimer( 'IsSpecialHeavyAttackInputHeld' );
  9845. RemoveTimer( 'SpecialAttackLightSustainCost' );
  9846. RemoveTimer( 'SpecialAttackHeavySustainCost' );
  9847. RemoveTimer( 'UpdateSpecialAttackLightHeading' );
  9848. UnblockAction( EIAB_Crossbow, 'SpecialAttack' );
  9849.  
  9850. ResumeStaminaRegen('WhirlSkill');
  9851.  
  9852. if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_SpecialAttack && GetBehaviorVariable( 'isPerformingSpecialAttack' ) == 1.f )
  9853. {
  9854. if( GetBehaviorVariable( 'playerAttackType' ) == (int)PAT_Light )
  9855. {
  9856. SetAttackActionName(SkillEnumToName(S_Sword_s01));
  9857. PushCombatActionOnBuffer( EBAT_SpecialAttack_Light, BS_Released );
  9858. ProcessCombatActionBuffer();
  9859.  
  9860. ((W3PlayerWitcherStateCombatFists) GetState('Combat')).ResetTimeToEndCombat();
  9861.  
  9862. }
  9863. else if( GetBehaviorVariable( 'playerAttackType' ) == (int)PAT_Heavy )
  9864. {
  9865. SetAttackActionName(SkillEnumToName(S_Sword_s02));
  9866. PushCombatActionOnBuffer( EBAT_SpecialAttack_Heavy, BS_Released );
  9867. ProcessCombatActionBuffer();
  9868.  
  9869. }
  9870. }
  9871. }
  9872.  
  9873. public function RaiseAttackFriendlyEvent( actor : CActor ) : bool
  9874. {
  9875. var playerToTargetHeading : float;
  9876.  
  9877. if ( actor && RaiseCombatActionFriendlyEvent() )
  9878. {
  9879. SetBehaviorVariable( 'tauntTypeForOverlay', 0.f );
  9880. SetBehaviorVariable( 'combatActionTypeForOverlay', (int)CAT_Attack );
  9881.  
  9882. if ( actor )
  9883. actor.SignalGameplayEvent('PersonalTauntAction');
  9884. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'TauntAction', -1.0, 4.5f, -1, 9999, true );
  9885.  
  9886. OnCombatActionStart();
  9887.  
  9888. playerToTargetHeading = VecHeading( actor.GetWorldPosition() - GetWorldPosition() );
  9889.  
  9890. SetCustomRotation( 'Attack', playerToTargetHeading, 0.0f, 0.3f, false );
  9891.  
  9892. return true;
  9893. }
  9894.  
  9895. return false;
  9896. }
  9897.  
  9898. public function SendAttackReactionEvent()
  9899. {
  9900. var reactionName : name;
  9901.  
  9902.  
  9903.  
  9904. reactionName = 'AttackAction';
  9905.  
  9906. if ( IsNameValid(reactionName) )
  9907. {
  9908. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, reactionName, -1.0, 8.0f, -1, 5, true );
  9909. }
  9910.  
  9911.  
  9912. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'outOfMyWay', -1.0, 2.0f, -1, 5, true );
  9913. }
  9914.  
  9915. var forceCanAttackWhenNotInCombat : int;
  9916. public function SetForceCanAttackWhenNotInCombat( forceMode : int )
  9917. {
  9918. forceCanAttackWhenNotInCombat = forceMode;
  9919. }
  9920.  
  9921. public function CanAttackWhenNotInCombat( actionType : EBufferActionType, altCast : bool, out newTarget : CActor, optional target : CGameplayEntity ) : bool
  9922. {
  9923. var localTargets : array<CActor>;
  9924. var i, size : int;
  9925. var inputHeading : float;
  9926. var clearanceMin, clearanceMax : float;
  9927. var attackLength : float;
  9928. var attackAngle : float;
  9929. var npc : CNewNPC;
  9930. var canAttackTarget : CGameplayEntity;
  9931. var canAttackTargetActor : CActor;
  9932.  
  9933. if ( target )
  9934. canAttackTarget = target;
  9935. else if ( displayTarget && IsDisplayTargetTargetable() )
  9936. canAttackTarget = displayTarget;
  9937. else
  9938. canAttackTarget = slideTarget;
  9939.  
  9940. canAttackTargetActor = (CActor)canAttackTarget;
  9941.  
  9942. if ( forceCanAttackWhenNotInCombat == 2 )
  9943. return true;
  9944. else if ( forceCanAttackWhenNotInCombat == 1 && ( !canAttackTarget || !canAttackTargetActor.IsHuman() ) )
  9945. return true;
  9946.  
  9947. if ( actionType == EBAT_CastSign )
  9948. {
  9949. if ( thePlayer.GetEquippedSign() != ST_Quen && thePlayer.GetEquippedSign() != ST_Axii )
  9950. {
  9951. if ( CanUseSkill( S_Magic_s20 ) )
  9952. {
  9953. if ( thePlayer.GetEquippedSign() == ST_Aard )
  9954. attackLength = 6.f;
  9955. else if ( thePlayer.GetEquippedSign() == ST_Igni )
  9956. attackLength = 4.f;
  9957. else
  9958. attackLength = 6.f;
  9959. }
  9960. else
  9961. {
  9962. if ( thePlayer.GetEquippedSign() == ST_Aard )
  9963. attackLength = 9.f;
  9964. else if ( thePlayer.GetEquippedSign() == ST_Igni )
  9965. attackLength = 6.f;
  9966. else
  9967. attackLength = 6.f;
  9968. }
  9969.  
  9970. if ( altCast )
  9971. attackAngle = 180.f;
  9972. else
  9973.  
  9974. attackAngle = 90.f;
  9975.  
  9976. if ( !lastAxisInputIsMovement )
  9977. inputHeading = VecHeading( theCamera.GetCameraDirection() );
  9978. else if ( lAxisReleasedAfterCounter )
  9979. inputHeading = GetHeading();
  9980. else
  9981. inputHeading = GetCombatActionHeading();
  9982.  
  9983. clearanceMin = 1.f;
  9984. clearanceMax = attackLength + 1.f;
  9985. }
  9986. else if ( thePlayer.GetEquippedSign() == ST_Axii )
  9987. {
  9988. npc = (CNewNPC)canAttackTarget;
  9989. if ( npc && npc.GetNPCType() == ENGT_Quest && !npc.HasTag(theGame.params.TAG_AXIIABLE_LOWER_CASE) && !npc.HasTag(theGame.params.TAG_AXIIABLE))
  9990. return false;
  9991. else if ( npc && npc.IsUsingHorse() )
  9992. return false;
  9993. else
  9994. return true;
  9995. }
  9996. else
  9997. return true;
  9998. }
  9999. else if ( actionType == EBAT_ItemUse )
  10000. {
  10001. attackLength = theGame.params.MAX_THROW_RANGE;
  10002. attackAngle = 90.f;
  10003.  
  10004. if ( thePlayer.lastAxisInputIsMovement )
  10005. inputHeading = GetCombatActionHeading();
  10006. else
  10007. inputHeading = VecHeading( theCamera.GetCameraDirection() );
  10008.  
  10009. clearanceMin = 0.8f;
  10010. clearanceMax = attackLength + 3.f;
  10011. }
  10012. else
  10013. {
  10014. if ( actionType == EBAT_SpecialAttack_Light || actionType == EBAT_SpecialAttack_Heavy )
  10015. {
  10016. attackLength = 1.9f;
  10017. attackAngle = 90.f;
  10018. }
  10019. else
  10020. {
  10021. if( thePlayer.GetCurrentMeleeWeaponType() == PW_Fists || thePlayer.GetCurrentMeleeWeaponType() == PW_None )
  10022. attackLength = 1.2f;
  10023. else
  10024. attackLength = 1.9f;
  10025.  
  10026. attackAngle = 90.f;
  10027. }
  10028.  
  10029. if ( lastAxisInputIsMovement )
  10030. inputHeading = GetCombatActionHeading();
  10031. else
  10032. inputHeading = VecHeading( theCamera.GetCameraDirection() );
  10033.  
  10034. clearanceMin = attackLength / 2.f;
  10035. clearanceMax = attackLength + 3.f;
  10036. }
  10037.  
  10038.  
  10039. if ( canAttackTarget )
  10040. {
  10041. if ( ( canAttackTargetActor && canAttackTargetActor.IsHuman() ) || canAttackTargetActor.HasTag( 'softLock_Friendly' ) )
  10042. {
  10043. if ( ShouldPerformFriendlyAction( canAttackTargetActor, inputHeading, attackAngle, clearanceMin, clearanceMax ) )
  10044. {
  10045. SetSlideTarget( canAttackTargetActor );
  10046. newTarget = canAttackTargetActor;
  10047. return false;
  10048. }
  10049. }
  10050.  
  10051.  
  10052. }
  10053.  
  10054. return true;
  10055.  
  10056. thePlayer.GetVisibleEnemies( localTargets );
  10057. size = localTargets.Size();
  10058.  
  10059. if ( size > 0 )
  10060. {
  10061. for ( i = size-1; i>=0; i-=1 )
  10062. {
  10063.  
  10064. if ( !localTargets[i].IsHuman() && !localTargets[i].HasTag( 'softLock_Friendly' ) )
  10065. localTargets.Erase(i);
  10066. }
  10067. }
  10068.  
  10069. size = localTargets.Size();
  10070. if ( size > 0 )
  10071. {
  10072. for ( i = 0; i < localTargets.Size(); i += 1 )
  10073. {
  10074. if ( ShouldPerformFriendlyAction( localTargets[i], inputHeading, attackAngle, clearanceMin, clearanceMax ) )
  10075. {
  10076. SetSlideTarget( localTargets[i] );
  10077. newTarget = localTargets[i];
  10078. return false;
  10079. }
  10080. }
  10081. }
  10082.  
  10083. newTarget = NULL;
  10084.  
  10085. return true;
  10086. }
  10087.  
  10088. private function ShouldPerformFriendlyAction( actor : CActor, inputHeading, attackAngle, clearanceMin, clearanceMax : float ) : bool
  10089. {
  10090. var npc : CNewNPC;
  10091. var argh : float;
  10092. var playerToTargetDist : float;
  10093.  
  10094. npc = (CNewNPC)actor;
  10095.  
  10096. if ( npc &&
  10097. ( GetAttitudeBetween(thePlayer, npc) == AIA_Hostile || ( GetAttitudeBetween(thePlayer, npc) == AIA_Neutral && npc.GetNPCType() != ENGT_Guard ) ) )
  10098. {
  10099. }
  10100. else
  10101. {
  10102. playerToTargetDist = VecDistance( this.GetWorldPosition(), actor.PredictWorldPosition( 0.5f ) );
  10103.  
  10104. argh = AbsF( AngleDistance( inputHeading, VecHeading( actor.GetWorldPosition() - thePlayer.GetWorldPosition() ) ) );
  10105.  
  10106. if ( AbsF( AngleDistance( inputHeading, VecHeading( actor.GetWorldPosition() - thePlayer.GetWorldPosition() ) ) ) < attackAngle )
  10107. {
  10108. if ( playerToTargetDist < clearanceMax )
  10109. {
  10110. return true;
  10111. }
  10112. }
  10113. else
  10114. {
  10115. if ( playerToTargetDist < clearanceMin )
  10116. {
  10117. return true;
  10118. }
  10119. }
  10120. }
  10121.  
  10122. return false;
  10123. }
  10124.  
  10125.  
  10126.  
  10127.  
  10128.  
  10129. public function GetHudMessagesSize() : int
  10130. {
  10131. return HudMessages.Size();
  10132. }
  10133.  
  10134. public function GetHudPendingMessage() : string
  10135. {
  10136. return HudMessages[0];
  10137. }
  10138.  
  10139. public function DisplayHudMessage( value : string ) : void
  10140. {
  10141. if (value == "")
  10142. {
  10143. return;
  10144. }
  10145.  
  10146. if( GetHudMessagesSize() > 0 )
  10147. {
  10148. if( HudMessages[HudMessages.Size()-1] == value )
  10149. {
  10150. return;
  10151. }
  10152. }
  10153. HudMessages.PushBack(value);
  10154. }
  10155.  
  10156.  
  10157. private final function DisallowedActionDontShowHack(action : EInputActionBlock, isTimeLock : bool) : bool
  10158. {
  10159. var locks : array< SInputActionLock >;
  10160. var i : int;
  10161.  
  10162.  
  10163. 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)) )
  10164. {
  10165. return true;
  10166. }
  10167.  
  10168.  
  10169. if( action == EIAB_ThrowBomb && ( HasBuff( EET_Hypnotized ) || HasBuff( EET_Confusion ) ) )
  10170. {
  10171. return false;
  10172. }
  10173.  
  10174.  
  10175. if(isTimeLock)
  10176. return false;
  10177.  
  10178.  
  10179. if(action == EIAB_OpenMeditation)
  10180. return false;
  10181.  
  10182.  
  10183. locks = GetActionLocks(action);
  10184. for(i=0; i<locks.Size(); i+=1)
  10185. {
  10186. if(locks[i].isFromQuest || locks[i].isFromPlace)
  10187. return false;
  10188. }
  10189.  
  10190. if ( this.IsCurrentlyUsingItemL() )
  10191. {
  10192. if ( action == EIAB_HeavyAttacks || action == EIAB_Parry )
  10193. return false;
  10194. }
  10195.  
  10196.  
  10197. return true;
  10198. }
  10199.  
  10200. public final function DisplayActionDisallowedHudMessage(action : EInputActionBlock, optional isCombatLock : bool, optional isPlaceLock : bool, optional isTimeLock : bool, optional isDangerous : bool)
  10201. {
  10202. var lockType : name;
  10203.  
  10204. if(action != EIAB_Undefined && DisallowedActionDontShowHack(action, isTimeLock))
  10205. return;
  10206.  
  10207.  
  10208. if(IsInCombat() && !IsActionCombat(action))
  10209. isCombatLock = true;
  10210.  
  10211.  
  10212. if(!isCombatLock && !isPlaceLock && !isTimeLock && action != EIAB_Undefined)
  10213. {
  10214. lockType = inputHandler.GetActionBlockedHudLockType(action);
  10215.  
  10216. if(lockType == 'combat')
  10217. isCombatLock = true;
  10218. else if(lockType == 'place')
  10219. isPlaceLock = true;
  10220. else if(lockType == 'time')
  10221. isTimeLock = true;
  10222. }
  10223.  
  10224. if(isDangerous)
  10225. {
  10226. DisplayHudMessage(GetLocStringByKeyExt( "message_meditation_too_dangerous" ));
  10227. }
  10228. else if(isCombatLock)
  10229. {
  10230. DisplayHudMessage(GetLocStringByKeyExt( "panel_hud_message_actionnotallowed_combat" ));
  10231. }
  10232. else if(isPlaceLock)
  10233. {
  10234. DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_here" ));
  10235. }
  10236. else if(isTimeLock)
  10237. {
  10238. DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_now" ));
  10239. }
  10240. }
  10241.  
  10242.  
  10243. public function RemoveHudMessageByString(msg : string, optional allQueuedInstances : bool)
  10244. {
  10245. var i, j : int;
  10246.  
  10247. for(i=0; i<HudMessages.Size(); i+=1)
  10248. {
  10249. if(HudMessages[i] == msg)
  10250. {
  10251. HudMessages.EraseFast(i);
  10252.  
  10253. if(!allQueuedInstances)
  10254. return;
  10255.  
  10256. break;
  10257. }
  10258. }
  10259.  
  10260.  
  10261. for(j=HudMessages.Size()-1; j >= i; j-=1)
  10262. {
  10263. if(HudMessages[i] == msg)
  10264. {
  10265. HudMessages.EraseFast(i);
  10266. }
  10267. }
  10268. }
  10269.  
  10270. public function RemoveHudMessageByIndex(idx : int)
  10271. {
  10272. if(idx >= 0 && idx < HudMessages.Size())
  10273. HudMessages.Erase(idx);
  10274. }
  10275.  
  10276. function SetSettlementBlockCanter( valueAdd : int )
  10277. {
  10278. m_SettlementBlockCanter += valueAdd;
  10279. }
  10280.  
  10281. var countDownToStart : int;
  10282. default countDownToStart = 0;
  10283.  
  10284. function DisplayRaceStart( countDownSecondsNumber : int )
  10285. {
  10286. var i : int;
  10287. countDownToStart = countDownSecondsNumber;
  10288. for( i = countDownSecondsNumber; i > 0; i -= 1 )
  10289. {
  10290. DisplayHudMessage(IntToString(i));
  10291. }
  10292. DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_race_start"));
  10293. AddTimer('RaceCountdown',1,true);
  10294. }
  10295.  
  10296. timer function RaceCountdown(dt : float, id : int)
  10297. {
  10298. var hud : CR4ScriptedHud;
  10299. var messageModule : CR4HudModuleMessage;
  10300.  
  10301. countDownToStart -= 1;
  10302. hud = (CR4ScriptedHud)theGame.GetHud();
  10303.  
  10304. if( hud )
  10305. {
  10306. messageModule = (CR4HudModuleMessage)hud.GetHudModule("MessageModule");
  10307. if( messageModule )
  10308. {
  10309. messageModule.OnMessageHidden();
  10310. }
  10311. }
  10312.  
  10313. if( countDownToStart <= 0 )
  10314. {
  10315. RemoveTimer('RaceCountdown');
  10316. }
  10317. }
  10318.  
  10319. public function GetCountDownToStart() : int
  10320. {
  10321. return countDownToStart;
  10322. }
  10323.  
  10324. public function HAXE3GetContainer() : W3Container
  10325. {
  10326. return HAXE3Container;
  10327. }
  10328.  
  10329. public function HAXE3SetContainer( container : W3Container) : void
  10330. {
  10331. HAXE3Container = container;
  10332. }
  10333.  
  10334. public function HAXE3GetAutoLoot() : bool
  10335. {
  10336. return HAXE3bAutoLoot;
  10337. }
  10338.  
  10339. public function HAXE3SetAutoLoot( value : bool ) : void
  10340. {
  10341. HAXE3bAutoLoot = value;
  10342. }
  10343.  
  10344. public function GetShowHud() : bool
  10345. {
  10346. return bShowHud;
  10347. }
  10348.  
  10349. public function SetShowHud( value : bool ) : void
  10350. {
  10351. bShowHud = value;
  10352. }
  10353.  
  10354. public function DisplayItemRewardNotification( itemName : name, optional quantity : int ) : void
  10355. {
  10356. var hud : CR4ScriptedHud;
  10357. hud = (CR4ScriptedHud)theGame.GetHud();
  10358. hud.OnItemRecivedDuringScene(itemName, quantity);
  10359. }
  10360.  
  10361. function IsNewQuest( questGuid : CGUID ) : bool
  10362. {
  10363. var i : int;
  10364. for(i = 0; i < displayedQuestsGUID.Size(); i += 1 )
  10365. {
  10366. if( displayedQuestsGUID[i] == questGuid )
  10367. {
  10368. return false;
  10369. }
  10370. }
  10371. displayedQuestsGUID.PushBack(questGuid);
  10372. return true;
  10373. }
  10374.  
  10375. function GetRewardMultiplierData( rewardName : name ) : SRewardMultiplier
  10376. {
  10377. var defaultReward : SRewardMultiplier;
  10378. var i : int;
  10379.  
  10380. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  10381. {
  10382. if( rewardsMultiplier[i].rewardName == rewardName )
  10383. {
  10384. return rewardsMultiplier[i];
  10385. }
  10386. }
  10387.  
  10388. defaultReward.rewardName = rewardName;
  10389. defaultReward.rewardMultiplier = 1.0;
  10390. defaultReward.isItemMultiplier = false;
  10391.  
  10392. return defaultReward;
  10393. }
  10394.  
  10395. function GetRewardMultiplier( rewardName : name ) : float
  10396. {
  10397. var i : int;
  10398. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  10399. {
  10400. if( rewardsMultiplier[i].rewardName == rewardName )
  10401. {
  10402. return rewardsMultiplier[i].rewardMultiplier;
  10403. }
  10404. }
  10405. return 1.0;
  10406. }
  10407.  
  10408. function GetRewardMultiplierExists( rewardName : name ) : bool
  10409. {
  10410. var i : int;
  10411. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  10412. {
  10413. if( rewardsMultiplier[i].rewardName == rewardName )
  10414. {
  10415. return true;
  10416. }
  10417. }
  10418. return false;
  10419. }
  10420.  
  10421. function SetRewardMultiplier( rewardName : name, value : float, optional isItemMultiplier : bool ) : void
  10422. {
  10423. var i : int;
  10424. var rewardMultiplier : SRewardMultiplier;
  10425.  
  10426. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  10427. {
  10428. if( rewardsMultiplier[i].rewardName == rewardName )
  10429. {
  10430. rewardsMultiplier[i].rewardMultiplier = value;
  10431. rewardsMultiplier[i].isItemMultiplier = isItemMultiplier;
  10432. return;
  10433. }
  10434. }
  10435.  
  10436. rewardMultiplier.rewardName = rewardName;
  10437. rewardMultiplier.rewardMultiplier = value;
  10438. rewardMultiplier.isItemMultiplier = isItemMultiplier;
  10439.  
  10440. rewardsMultiplier.PushBack(rewardMultiplier);
  10441. }
  10442.  
  10443. function RemoveRewardMultiplier( rewardName : name ) : void
  10444. {
  10445. var i : int;
  10446. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  10447. {
  10448. if( rewardsMultiplier[i].rewardName == rewardName )
  10449. {
  10450. rewardsMultiplier.Erase(i);
  10451. return;
  10452. }
  10453. }
  10454. }
  10455.  
  10456.  
  10457.  
  10458.  
  10459.  
  10460.  
  10461.  
  10462. public final function TissueExtractorDischarge() : bool
  10463. {
  10464. var ids : array<SItemUniqueId>;
  10465. var chargesLeft, uses, curr, max, red, blue, green : int;
  10466. var i : int;
  10467. var text : string;
  10468.  
  10469. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  10470. if( ids.Size() == 0 )
  10471. {
  10472. return false;
  10473. }
  10474.  
  10475. curr = GetTissueExtractorChargesCurr();
  10476. max = GetTissueExtractorChargesMax();
  10477.  
  10478. if( curr >= max )
  10479. {
  10480.  
  10481. uses = FloorF( ( ( float ) curr ) / ( ( float ) max ) );
  10482. chargesLeft = Max( 0, curr - uses * max );
  10483.  
  10484.  
  10485. inv.SetItemModifierInt( ids[0], 'charges', chargesLeft );
  10486.  
  10487.  
  10488. blue = 0;
  10489. green = 0;
  10490. red = 0;
  10491. for( i=0; i<uses; i+=1 )
  10492. {
  10493. switch( RandRange( 3 ) )
  10494. {
  10495. case 0:
  10496. blue += 1;
  10497. break;
  10498. case 1:
  10499. green += 1;
  10500. break;
  10501. case 2:
  10502. red += 1;
  10503. }
  10504. }
  10505.  
  10506. text = GetLocStringByKeyExt( "message_q705_extractor_extracted" );
  10507.  
  10508. if( blue > 0 )
  10509. {
  10510. inv.AddAnItem( 'Greater mutagen blue', blue, false, true );
  10511. text += "<br/>" + blue + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen blue' ) );
  10512. }
  10513. if( green > 0 )
  10514. {
  10515. inv.AddAnItem( 'Greater mutagen green', green, false, true );
  10516. text += "<br/>" + green + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen green' ) );
  10517. }
  10518. if( red > 0 )
  10519. {
  10520. inv.AddAnItem( 'Greater mutagen red', red, false, true );
  10521. text += "<br/>" + red + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen red' ) );
  10522. }
  10523.  
  10524.  
  10525. theGame.GetGuiManager().ShowNotification( text );
  10526.  
  10527.  
  10528. inv.SetItemModifierInt( ids[0], 'ui_notified', 0 );
  10529.  
  10530. return true;
  10531. }
  10532. else
  10533. {
  10534.  
  10535. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_q705_extractor_too_few_charges" ) );
  10536. }
  10537.  
  10538. return false;
  10539. }
  10540.  
  10541. public final function TissueExtractorIncCharge()
  10542. {
  10543. var ids : array<SItemUniqueId>;
  10544. var uiData : SInventoryItemUIData;
  10545. var curr : int;
  10546.  
  10547. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  10548. if( ids.Size() == 0 )
  10549. {
  10550. return;
  10551. }
  10552.  
  10553. curr = GetTissueExtractorChargesCurr() + 1;
  10554. inv.SetItemModifierInt( ids[0], 'charges', curr );
  10555.  
  10556.  
  10557. if( curr >= GetTissueExtractorChargesMax() )
  10558. {
  10559. uiData = inv.GetInventoryItemUIData( ids[0] );
  10560. uiData.isNew = true;
  10561. inv.SetInventoryItemUIData( ids[0], uiData );
  10562.  
  10563.  
  10564. if( inv.GetItemModifierInt( ids[0], 'ui_notified', 0 ) == 0 )
  10565. {
  10566. inv.SetItemModifierInt( ids[0], 'ui_notified', 1 );
  10567. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_q705_extractor_charged" ), , true );
  10568. }
  10569. }
  10570. }
  10571.  
  10572. public final function GetTissueExtractorChargesCurr() : int
  10573. {
  10574. var ids : array<SItemUniqueId>;
  10575.  
  10576. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  10577. if( ids.Size() == 0 )
  10578. {
  10579. return 0;
  10580. }
  10581.  
  10582. return inv.GetItemModifierInt( ids[0], 'charges', 0 );
  10583. }
  10584.  
  10585. public final function GetTissueExtractorChargesMax() : int
  10586. {
  10587. var ids : array<SItemUniqueId>;
  10588. var val : SAbilityAttributeValue;
  10589.  
  10590. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  10591. if( ids.Size() == 0 )
  10592. {
  10593. return 0;
  10594. }
  10595.  
  10596. val = inv.GetItemAttributeValue( ids[0], 'maxCharges' );
  10597.  
  10598. return FloorF( val.valueBase );
  10599. }
  10600.  
  10601. public function GetEquippedSword(steel : bool) : SItemUniqueId;
  10602.  
  10603. public final function HasRequiredLevelToEquipItem(item : SItemUniqueId) : bool
  10604. {
  10605. if(HasBuff(EET_WolfHour))
  10606. {
  10607. if((inv.GetItemLevel(item) - 2) > GetLevel() )
  10608. return false;
  10609. }
  10610. else
  10611. {
  10612. if(inv.GetItemLevel(item) > GetLevel() )
  10613. return false;
  10614. }
  10615.  
  10616. return true;
  10617. }
  10618.  
  10619. public function SkillReduceBombAmmoBonus()
  10620. {
  10621. var i, ammo, maxAmmo : int;
  10622. var items : array<SItemUniqueId>;
  10623.  
  10624. items = inv.GetSingletonItems();
  10625.  
  10626. for(i=0; i<items.Size(); i+=1)
  10627. {
  10628. ammo = inv.GetItemModifierInt(items[i], 'ammo_current');
  10629.  
  10630.  
  10631. if(ammo > 0)
  10632. {
  10633. maxAmmo = inv.SingletonItemGetMaxAmmo(items[i]);
  10634.  
  10635.  
  10636. if(ammo > maxAmmo)
  10637. {
  10638. inv.SetItemModifierInt(items[i], 'ammo_current', maxAmmo);
  10639. }
  10640. }
  10641. }
  10642. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  10643. }
  10644.  
  10645. public function ConsumeItem( itemId : SItemUniqueId ) : bool
  10646. {
  10647. var params : SCustomEffectParams;
  10648. var buffs : array<SEffectInfo>;
  10649. var i : int;
  10650. var category : name;
  10651. var potionToxicity : float;
  10652.  
  10653. if(!inv.IsIdValid(itemId))
  10654. return false;
  10655.  
  10656.  
  10657. category = inv.GetItemCategory(itemId);
  10658. if(category == 'edibles' || inv.ItemHasTag(itemId, 'Drinks') || ( category == 'alchemy_ingredient' && inv.ItemHasTag(itemId, 'Alcohol')) )
  10659. {
  10660.  
  10661. if(IsFistFightMinigameEnabled())
  10662. {
  10663. DisplayActionDisallowedHudMessage(EIAB_Undefined, false, false, true);
  10664. return false;
  10665. }
  10666.  
  10667.  
  10668. inv.GetItemBuffs(itemId, buffs);
  10669.  
  10670. for(i=0; i<buffs.Size(); i+=1)
  10671. {
  10672. params.effectType = buffs[i].effectType;
  10673. params.creator = this;
  10674. params.sourceName = "edible";
  10675. params.customAbilityName = buffs[i].effectAbilityName;
  10676. AddEffectCustom(params);
  10677. }
  10678.  
  10679.  
  10680. if ( inv.ItemHasTag(itemId, 'Alcohol') )
  10681. {
  10682. potionToxicity = CalculateAttributeValue(inv.GetItemAttributeValue(itemId, 'toxicity'));
  10683. abilityManager.GainStat(BCS_Toxicity, potionToxicity );
  10684. AddEffectDefault(EET_Drunkenness, NULL, inv.GetItemName(itemId));
  10685. }
  10686. PlayItemConsumeSound( itemId );
  10687. }
  10688.  
  10689. if(inv.IsItemFood(itemId))
  10690. FactsAdd("consumed_food_cnt");
  10691.  
  10692.  
  10693. if(!inv.ItemHasTag(itemId, theGame.params.TAG_INFINITE_USE) && !inv.RemoveItem(itemId))
  10694. {
  10695. LogAssert(false,"Failed to remove consumable item from player inventory!" + inv.GetItemName( itemId ) );
  10696. return false;
  10697. }
  10698.  
  10699. return true;
  10700. }
  10701.  
  10702. public function MountVehicle( vehicleEntity : CEntity, mountType : EVehicleMountType, optional vehicleSlot : EVehicleSlot )
  10703. {
  10704. var vehicle : CVehicleComponent;
  10705. vehicle = (CVehicleComponent)(vehicleEntity.GetComponentByClassName('CVehicleComponent'));
  10706.  
  10707. if ( vehicle )
  10708. vehicle.Mount( this, mountType, vehicleSlot );
  10709. }
  10710.  
  10711. public function DismountVehicle( vehicleEntity : CEntity, dismountType : EDismountType )
  10712. {
  10713. var vehicle : CVehicleComponent;
  10714. vehicle = (CVehicleComponent)(vehicleEntity.GetComponentByClassName('CVehicleComponent'));
  10715.  
  10716. if ( vehicle )
  10717. vehicle.IssueCommandToDismount( dismountType );
  10718. }
  10719.  
  10720.  
  10721.  
  10722.  
  10723.  
  10724. protected function ShouldDrainStaminaWhileSprinting() : bool
  10725. {
  10726. if( HasBuff( EET_PolishedGenitals ) && !IsInCombat() && !IsThreatened() )
  10727. {
  10728. return false;
  10729. }
  10730.  
  10731. return super.ShouldDrainStaminaWhileSprinting();
  10732. }
  10733.  
  10734.  
  10735.  
  10736. public function HasStaminaToUseAction(action : EStaminaActionType, optional abilityName : name, optional dt :float, optional multiplier : float) : bool
  10737. {
  10738. var cost : float;
  10739. var ret : bool;
  10740.  
  10741. ret = super.HasStaminaToUseAction(action, abilityName, dt, multiplier);
  10742.  
  10743. if(!ret)
  10744. {
  10745. SetCombatActionHeading( GetHeading() );
  10746.  
  10747. if(multiplier == 0)
  10748. multiplier = 1;
  10749.  
  10750. cost = multiplier * GetStaminaActionCost(action, abilityName, dt);
  10751. SetShowToLowStaminaIndication(cost);
  10752. }
  10753.  
  10754. return ret;
  10755. }
  10756.  
  10757.  
  10758. timer function AbilityManager_FloorStaminaSegment(dt : float, id : int)
  10759. {
  10760. ((W3PlayerAbilityManager)abilityManager).FloorStaminaSegment();
  10761. }
  10762.  
  10763. public function DrainToxicity(amount : float )
  10764. {
  10765. if(abilityManager && abilityManager.IsInitialized() && IsAlive())
  10766. abilityManager.DrainToxicity(amount);
  10767. }
  10768.  
  10769. public function DrainFocus(amount : float )
  10770. {
  10771. if(abilityManager && abilityManager.IsInitialized() && IsAlive())
  10772. abilityManager.DrainFocus(amount);
  10773. }
  10774.  
  10775. public function GetOffenseStat():int
  10776. {
  10777. if(abilityManager && abilityManager.IsInitialized())
  10778. return ((W3PlayerAbilityManager)abilityManager).GetOffenseStat();
  10779.  
  10780. return 0;
  10781. }
  10782.  
  10783. public function GetDefenseStat():int
  10784. {
  10785. if(abilityManager && abilityManager.IsInitialized())
  10786. return ((W3PlayerAbilityManager)abilityManager).GetDefenseStat();
  10787.  
  10788. return 0;
  10789. }
  10790.  
  10791. public function GetSignsStat():float
  10792. {
  10793. if(abilityManager && abilityManager.IsInitialized())
  10794. return ((W3PlayerAbilityManager)abilityManager).GetSignsStat();
  10795.  
  10796. return 0;
  10797. }
  10798.  
  10799.  
  10800.  
  10801.  
  10802.  
  10803. private var inWaterTrigger : bool;
  10804.  
  10805. event OnOceanTriggerEnter()
  10806. {
  10807. inWaterTrigger = true;
  10808. }
  10809.  
  10810. event OnOceanTriggerLeave()
  10811. {
  10812. inWaterTrigger = false;
  10813. }
  10814.  
  10815. public function IsInWaterTrigger() : bool
  10816. {
  10817. return inWaterTrigger;
  10818. }
  10819.  
  10820.  
  10821.  
  10822.  
  10823.  
  10824. public function GetSkillColor(skill : ESkill) : ESkillColor
  10825. {
  10826. if(abilityManager && abilityManager.IsInitialized())
  10827. return ((W3PlayerAbilityManager)abilityManager).GetSkillColor(skill);
  10828.  
  10829. return SC_None;
  10830. }
  10831.  
  10832. public function GetSkillSlotIndexFromSkill(skill : ESkill) : int
  10833. {
  10834. if(abilityManager && abilityManager.IsInitialized())
  10835. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIndexFromSkill(skill);
  10836.  
  10837. return -1;
  10838. }
  10839.  
  10840. public final function GetSkillSlotIndex(slotID : int, checkIfUnlocked : bool) : int
  10841. {
  10842. if(abilityManager && abilityManager.IsInitialized())
  10843. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIndex(slotID, checkIfUnlocked);
  10844.  
  10845. return -1;
  10846. }
  10847.  
  10848. public final function GetSkillSlotIDFromIndex(skillSlotIndex : int) : int
  10849. {
  10850. if(abilityManager && abilityManager.IsInitialized())
  10851. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIDFromIndex(skillSlotIndex);
  10852.  
  10853. return -1;
  10854. }
  10855.  
  10856. public function GetSkillSlotID(skill : ESkill) : int
  10857. {
  10858. if(abilityManager && abilityManager.IsInitialized())
  10859. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotID(skill);
  10860.  
  10861. return -1;
  10862. }
  10863.  
  10864. public function GetSkillGroupBonus(groupID : int) : name
  10865. {
  10866. if(abilityManager && abilityManager.IsInitialized())
  10867. return ((W3PlayerAbilityManager)abilityManager).GetGroupBonus(groupID);
  10868.  
  10869. return '';
  10870. }
  10871.  
  10872. public function GetGroupBonusCount(commonColor : ESkillColor,groupID : int) : int
  10873. {
  10874. if(abilityManager && abilityManager.IsInitialized())
  10875. return ((W3PlayerAbilityManager)abilityManager).GetSkillGroupColorCount(commonColor, groupID);
  10876.  
  10877. return 0;
  10878. }
  10879.  
  10880. public function GetMutagenSlotIDFromGroupID(groupID : int) : int
  10881. {
  10882. if(abilityManager && abilityManager.IsInitialized())
  10883. return ((W3PlayerAbilityManager)abilityManager).GetMutagenSlotIDFromGroupID(groupID);
  10884.  
  10885. return -1;
  10886. }
  10887.  
  10888. public function GetSkillLevel(skill : ESkill) : int
  10889. {
  10890. if(abilityManager && abilityManager.IsInitialized())
  10891. return ((W3PlayerAbilityManager)abilityManager).GetSkillLevel(skill);
  10892.  
  10893. return -1;
  10894. }
  10895.  
  10896. public function GetBoughtSkillLevel(skill : ESkill) : int
  10897. {
  10898. if(abilityManager && abilityManager.IsInitialized())
  10899. return ((W3PlayerAbilityManager)abilityManager).GetBoughtSkillLevel(skill);
  10900.  
  10901. return -1;
  10902. }
  10903.  
  10904. public function AddSkill(skill : ESkill, optional isTemporary : bool)
  10905. {
  10906. if(abilityManager && abilityManager.IsInitialized())
  10907. ((W3PlayerAbilityManager)abilityManager).AddSkill(skill, isTemporary);
  10908. }
  10909.  
  10910. public function AddMultipleSkills(skill : ESkill, optional number : int, optional isTemporary : bool)
  10911. {
  10912. var i : int;
  10913.  
  10914. if(number)
  10915. {
  10916. for( i=0; i<number; i+=1)
  10917. {
  10918. AddSkill(skill,isTemporary);
  10919. }
  10920. }
  10921. else
  10922. {
  10923. AddSkill(skill,isTemporary);
  10924. }
  10925. }
  10926.  
  10927. public function GetSkillAbilityName(skill : ESkill) : name
  10928. {
  10929. if(abilityManager && abilityManager.IsInitialized())
  10930. return ((W3PlayerAbilityManager)abilityManager).GetSkillAbilityName(skill);
  10931.  
  10932. return '';
  10933. }
  10934.  
  10935. public function HasStaminaToUseSkill(skill : ESkill, optional perSec : bool, optional signHack : bool) : bool
  10936. {
  10937. var ret : bool;
  10938. var cost : float;
  10939.  
  10940. cost = GetSkillStaminaUseCost(skill, perSec);
  10941.  
  10942. ret = ( CanUseSkill(skill) && (abilityManager.GetStat(BCS_Stamina, signHack) >= cost) );
  10943.  
  10944.  
  10945. if(!ret && IsSkillSign(skill) && CanUseSkill(S_Perk_09) && GetStat(BCS_Focus) >= 1)
  10946. {
  10947. ret = true;
  10948. }
  10949.  
  10950.  
  10951. if( !ret && IsSkillSign( skill ) && GetWitcherPlayer().HasBuff( EET_GryphonSetBonus ) )
  10952. {
  10953. ret = true;
  10954. }
  10955.  
  10956. if(!ret)
  10957. {
  10958. SetCombatActionHeading( GetHeading() );
  10959. SetShowToLowStaminaIndication(cost);
  10960. }
  10961.  
  10962. return ret;
  10963. }
  10964.  
  10965. protected function GetSkillStaminaUseCost(skill : ESkill, optional perSec : bool) : float
  10966. {
  10967. if(abilityManager && abilityManager.IsInitialized())
  10968. return ((W3PlayerAbilityManager)abilityManager).GetSkillStaminaUseCost(skill, perSec);
  10969.  
  10970. return 0;
  10971. }
  10972.  
  10973.  
  10974. public function GetSkillAttributeValue(skill : ESkill, attributeName : name, addBaseCharAttribute : bool, addSkillModsAttribute : bool) : SAbilityAttributeValue
  10975. {
  10976. var null : SAbilityAttributeValue;
  10977.  
  10978. if(abilityManager && abilityManager.IsInitialized())
  10979. return abilityManager.GetSkillAttributeValue(SkillEnumToName(skill), attributeName, addBaseCharAttribute, addSkillModsAttribute);
  10980.  
  10981. return null;
  10982. }
  10983.  
  10984. public function GetSkillLocalisationKeyName(skill : ESkill) : string
  10985. {
  10986. if(abilityManager && abilityManager.IsInitialized())
  10987. return ((W3PlayerAbilityManager)abilityManager).GetSkillLocalisationKeyName(skill);
  10988.  
  10989. return "";
  10990. }
  10991.  
  10992. public function GetSkillLocalisationKeyDescription(skill : ESkill) : string
  10993. {
  10994. if(abilityManager && abilityManager.IsInitialized())
  10995. return ((W3PlayerAbilityManager)abilityManager).GetSkillLocalisationKeyDescription(skill);
  10996.  
  10997. return "";
  10998. }
  10999.  
  11000. public function GetSkillIconPath(skill : ESkill) : string
  11001. {
  11002. if(abilityManager && abilityManager.IsInitialized())
  11003. return ((W3PlayerAbilityManager)abilityManager).GetSkillIconPath(skill);
  11004.  
  11005. return "";
  11006. }
  11007.  
  11008. public function HasLearnedSkill(skill : ESkill) : bool
  11009. {
  11010. if(abilityManager && abilityManager.IsInitialized())
  11011. return ((W3PlayerAbilityManager)abilityManager).HasLearnedSkill(skill);
  11012.  
  11013. return false;
  11014. }
  11015.  
  11016. public function IsSkillEquipped(skill : ESkill) : bool
  11017. {
  11018. if(abilityManager && abilityManager.IsInitialized())
  11019. return ((W3PlayerAbilityManager)abilityManager).IsSkillEquipped(skill);
  11020.  
  11021. return false;
  11022. }
  11023.  
  11024. public function CanUseSkill(skill : ESkill) : bool
  11025. {
  11026. if(abilityManager && abilityManager.IsInitialized())
  11027. return ((W3PlayerAbilityManager)abilityManager).CanUseSkill(skill);
  11028.  
  11029. return false;
  11030. }
  11031.  
  11032. public function CanLearnSkill(skill : ESkill) : bool
  11033. {
  11034. if(abilityManager && abilityManager.IsInitialized())
  11035. return ((W3PlayerAbilityManager)abilityManager).CanLearnSkill(skill);
  11036.  
  11037. return false;
  11038. }
  11039.  
  11040. public function HasSpentEnoughPoints(skill : ESkill) : bool
  11041. {
  11042. if(abilityManager && abilityManager.IsInitialized())
  11043. return ((W3PlayerAbilityManager)abilityManager).HasSpentEnoughPoints(skill);
  11044.  
  11045. return false;
  11046. }
  11047.  
  11048. public function PathPointsForSkillsPath(skill : ESkill) : int
  11049. {
  11050. if(abilityManager && abilityManager.IsInitialized())
  11051. return ((W3PlayerAbilityManager)abilityManager).PathPointsSpentInSkillPathOfSkill(skill);
  11052.  
  11053. return -1;
  11054. }
  11055.  
  11056. public function GetPlayerSkills() : array<SSkill>
  11057. {
  11058. var null : array<SSkill>;
  11059.  
  11060. if(abilityManager && abilityManager.IsInitialized())
  11061. return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkills();
  11062.  
  11063. return null;
  11064. }
  11065.  
  11066. public function GetPlayerSkill(s : ESkill) : SSkill
  11067. {
  11068. var null : SSkill;
  11069.  
  11070. if(abilityManager && abilityManager.IsInitialized())
  11071. return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkill(s);
  11072.  
  11073. return null;
  11074. }
  11075.  
  11076. public function GetSkillSubPathType(s : ESkill) : ESkillSubPath
  11077. {
  11078. if(abilityManager && abilityManager.IsInitialized())
  11079. return ((W3PlayerAbilityManager)abilityManager).GetSkillSubPathType(s);
  11080.  
  11081. return ESSP_NotSet;
  11082. }
  11083.  
  11084. public function GetSkillSlotsCount() : int
  11085. {
  11086. if(abilityManager && abilityManager.IsInitialized())
  11087. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotsCount();
  11088.  
  11089. return 0;
  11090. }
  11091.  
  11092. public function GetSkillSlots() : array<SSkillSlot>
  11093. {
  11094. var null : array<SSkillSlot>;
  11095.  
  11096. if(abilityManager && abilityManager.IsInitialized())
  11097. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlots();
  11098.  
  11099. return null;
  11100. }
  11101.  
  11102. public function GetPlayerSkillMutagens() : array<SMutagenSlot>
  11103. {
  11104. var null : array<SMutagenSlot>;
  11105.  
  11106. if(abilityManager && abilityManager.IsInitialized())
  11107. return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkillMutagens();
  11108.  
  11109. return null;
  11110. }
  11111.  
  11112.  
  11113.  
  11114.  
  11115. public function BlockSkill(skill : ESkill, block : bool, optional cooldown : float) : bool
  11116. {
  11117. if(abilityManager && abilityManager.IsInitialized())
  11118. return ((W3PlayerAbilityManager)abilityManager).BlockSkill(skill, block, cooldown);
  11119.  
  11120. return false;
  11121. }
  11122.  
  11123. public function IsSkillBlocked(skill : ESkill) : bool
  11124. {
  11125. if(abilityManager && abilityManager.IsInitialized())
  11126. return ((W3PlayerAbilityManager)abilityManager).IsSkillBlocked(skill);
  11127.  
  11128. return false;
  11129. }
  11130.  
  11131.  
  11132. public function EquipSkill(skill : ESkill, slotID : int) : bool
  11133. {
  11134. var ret : bool;
  11135. var groupID : int;
  11136. var pam : W3PlayerAbilityManager;
  11137.  
  11138. if(abilityManager && abilityManager.IsInitialized())
  11139. {
  11140. pam = (W3PlayerAbilityManager)abilityManager;
  11141. ret = pam.EquipSkill(skill, slotID);
  11142. if(ret)
  11143. {
  11144. groupID = pam.GetSkillGroupIdFromSkillSlotId(slotID);
  11145. LogSkillColors("Equipped <<" + GetSkillColor(skill) + ">> skill <<" + skill + ">> to group <<" + groupID + ">>");
  11146. LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
  11147. LogSkillColors("");
  11148. }
  11149.  
  11150. return ret;
  11151. }
  11152.  
  11153. return false;
  11154. }
  11155.  
  11156.  
  11157. public function UnequipSkill(slotID : int) : bool
  11158. {
  11159. var ret : bool;
  11160. var groupID : int;
  11161. var skill : ESkill;
  11162. var pam : W3PlayerAbilityManager;
  11163.  
  11164. if(abilityManager && abilityManager.IsInitialized())
  11165. {
  11166. pam = (W3PlayerAbilityManager)abilityManager;
  11167. GetSkillOnSlot(slotID, skill);
  11168. ret = pam.UnequipSkill(slotID);
  11169. if(ret)
  11170. {
  11171. groupID = pam.GetSkillGroupIdFromSkillSlotId(slotID);
  11172. LogSkillColors("Unequipped <<" + GetSkillColor(skill) + ">> skill <<" + skill + ">> from group <<" + groupID + ">>");
  11173. LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
  11174. LogSkillColors("");
  11175. }
  11176. return ret;
  11177. }
  11178.  
  11179. return false;
  11180. }
  11181.  
  11182.  
  11183. public function GetSkillOnSlot(slotID : int, out skill : ESkill) : bool
  11184. {
  11185. if(abilityManager && abilityManager.IsInitialized())
  11186. return ((W3PlayerAbilityManager)abilityManager).GetSkillOnSlot(slotID, skill);
  11187.  
  11188. skill = S_SUndefined;
  11189. return false;
  11190. }
  11191.  
  11192.  
  11193. public function GetFreeSkillSlot() : int
  11194. {
  11195. var i, size : int;
  11196. var skill : ESkill;
  11197.  
  11198. size = ((W3PlayerAbilityManager)abilityManager).GetSkillSlotsCount();
  11199. for(i=1; i<size; i+=1)
  11200. {
  11201. if(!GetSkillOnSlot(i, skill))
  11202. continue;
  11203.  
  11204. if(skill == S_SUndefined)
  11205. return i;
  11206. }
  11207.  
  11208. return -1;
  11209. }
  11210.  
  11211.  
  11212.  
  11213.  
  11214.  
  11215.  
  11216. protected function Attack( hitTarget : CGameplayEntity, animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float, weaponEntity : CItemEntity)
  11217. {
  11218. var attackAction : W3Action_Attack;
  11219.  
  11220. if(!PrepareAttackAction(hitTarget, animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime, weaponEntity, attackAction))
  11221. return;
  11222.  
  11223. if ( attackAction.IsParried() && ( ((CNewNPC)attackAction.victim).IsShielded(attackAction.attacker) || ((CNewNPC)attackAction.victim).SignalGameplayEventReturnInt('IsDefending',0) == 1 ) )
  11224. {
  11225. thePlayer.SetCanPlayHitAnim(true);
  11226. thePlayer.ReactToReflectedAttack(attackAction.victim);
  11227. }
  11228.  
  11229. theTelemetry.LogWithLabel( TE_FIGHT_PLAYER_ATTACKS, attackAction.GetAttackName() );
  11230.  
  11231.  
  11232. theGame.damageMgr.ProcessAction(attackAction);
  11233.  
  11234. delete attackAction;
  11235. }
  11236.  
  11237. public function IsHeavyAttack(attackName : name) : bool
  11238. {
  11239. var skill : ESkill;
  11240. var sup : bool;
  11241.  
  11242. sup = super.IsHeavyAttack(attackName);
  11243. if(sup)
  11244. return true;
  11245.  
  11246. if ( attackName == 'attack_heavy_special' )
  11247. return true;
  11248.  
  11249. skill = SkillNameToEnum(attackName);
  11250.  
  11251. return skill == S_Sword_2 || skill == S_Sword_s02;
  11252. }
  11253.  
  11254. public function IsLightAttack(attackName : name) : bool
  11255. {
  11256. var skill : ESkill;
  11257. var sup : bool;
  11258.  
  11259. sup = super.IsLightAttack(attackName);
  11260. if(sup)
  11261. return true;
  11262.  
  11263. skill = SkillNameToEnum(attackName);
  11264.  
  11265. return skill == S_Sword_1 || skill == S_Sword_s01;
  11266. }
  11267.  
  11268. public final function ProcessWeaponCollision()
  11269. {
  11270. var l_stateName : name;
  11271.  
  11272. var l_weaponPosition : Vector;
  11273. var l_weaponTipPos : Vector;
  11274. var l_collidingPosition : Vector;
  11275. var l_offset : Vector;
  11276. var l_normal : Vector;
  11277.  
  11278. var l_slotMatrix : Matrix;
  11279.  
  11280. var l_distance : float;
  11281.  
  11282. var l_materialName : name;
  11283. var l_hitComponent : CComponent;
  11284. var l_destructibleCmp : CDestructionSystemComponent;
  11285. var barrel : COilBarrelEntity;
  11286.  
  11287.  
  11288.  
  11289. if( isCurrentlyDodging )
  11290. return;
  11291.  
  11292. l_stateName = GetCurrentStateName();
  11293.  
  11294. if( !attackEventInProgress && l_stateName == 'CombatFists' )
  11295. return;
  11296.  
  11297. CalcEntitySlotMatrix('r_weapon', l_slotMatrix);
  11298.  
  11299. l_weaponPosition = MatrixGetTranslation( l_slotMatrix );
  11300.  
  11301.  
  11302. switch( l_stateName )
  11303. {
  11304. case 'CombatFists':
  11305. l_offset = MatrixGetAxisX( l_slotMatrix );
  11306. l_offset = VecNormalize( l_offset ) * 0.25f;
  11307. break;
  11308.  
  11309. default:
  11310. l_offset = MatrixGetAxisZ( l_slotMatrix );
  11311. l_offset = VecNormalize( l_offset ) * 1.f;
  11312. break;
  11313. }
  11314.  
  11315. l_weaponTipPos = l_weaponPosition + l_offset;
  11316.  
  11317.  
  11318.  
  11319. if( !attackEventInProgress )
  11320. {
  11321.  
  11322. if( m_LastWeaponTipPos == Vector ( 0, 0, 0 ) )
  11323. l_distance = 0;
  11324. else
  11325. l_distance = VecDistance( l_weaponTipPos, m_LastWeaponTipPos ) ;
  11326.  
  11327.  
  11328.  
  11329.  
  11330. m_LastWeaponTipPos = l_weaponTipPos;
  11331. if( l_distance < 0.35f )
  11332. return;
  11333.  
  11334. }
  11335.  
  11336.  
  11337.  
  11338. m_LastWeaponTipPos = l_weaponTipPos;
  11339.  
  11340. if ( !theGame.GetWorld().StaticTraceWithAdditionalInfo( l_weaponPosition, l_weaponTipPos, l_collidingPosition, l_normal, l_materialName, l_hitComponent, m_WeaponFXCollisionGroupNames ) )
  11341. {
  11342.  
  11343. if( l_stateName == 'CombatFists' )
  11344. {
  11345. CalcEntitySlotMatrix('l_weapon', l_slotMatrix);
  11346. l_weaponPosition = MatrixGetTranslation( l_slotMatrix );
  11347. l_offset = MatrixGetAxisX( l_slotMatrix );
  11348. l_offset = VecNormalize( l_offset ) * 0.25f;
  11349. l_weaponTipPos = l_weaponPosition + l_offset;
  11350. if( !theGame.GetWorld().StaticTrace( l_weaponPosition, l_weaponTipPos, l_collidingPosition, l_normal, m_WeaponFXCollisionGroupNames ) )
  11351. {
  11352. return;
  11353. }
  11354. }
  11355. else
  11356. {
  11357. return;
  11358. }
  11359. }
  11360.  
  11361. if( !m_CollisionEffect )
  11362. {
  11363. m_CollisionEffect = theGame.CreateEntity( m_CollisionFxTemplate, l_collidingPosition, EulerAngles(0,0,0) );
  11364. }
  11365.  
  11366. m_CollisionEffect.Teleport( l_collidingPosition );
  11367.  
  11368.  
  11369. switch( l_stateName )
  11370. {
  11371. case 'CombatFists':
  11372. m_CollisionEffect.PlayEffect('fist');
  11373. break;
  11374. default:
  11375.  
  11376. if( m_RefreshWeaponFXType )
  11377. {
  11378. m_PlayWoodenFX = IsSwordWooden();
  11379. m_RefreshWeaponFXType = false;
  11380. }
  11381.  
  11382. if( m_PlayWoodenFX )
  11383. {
  11384. m_CollisionEffect.PlayEffect('wood');
  11385. }
  11386. else
  11387. {
  11388. switch( l_materialName )
  11389. {
  11390. case 'wood_hollow':
  11391. case 'wood_debris':
  11392. case 'wood_solid':
  11393. m_CollisionEffect.PlayEffect('wood');
  11394. break;
  11395. case 'dirt_hard':
  11396. case 'dirt_soil':
  11397. case 'hay':
  11398. m_CollisionEffect.PlayEffect('fist');
  11399. break;
  11400. case 'stone_debris':
  11401. case 'stone_solid':
  11402. case 'clay_tile':
  11403. case 'gravel_large':
  11404. case 'gravel_small':
  11405. case 'metal':
  11406. case 'custom_sword':
  11407. m_CollisionEffect.PlayEffect('sparks');
  11408. break;
  11409. case 'flesh':
  11410. m_CollisionEffect.PlayEffect('blood');
  11411. break;
  11412. default:
  11413. m_CollisionEffect.PlayEffect('wood');
  11414. break;
  11415. }
  11416.  
  11417. }
  11418. break;
  11419. }
  11420.  
  11421.  
  11422. if(l_hitComponent)
  11423. {
  11424. barrel = (COilBarrelEntity)l_hitComponent.GetEntity();
  11425. if(barrel)
  11426. {
  11427. barrel.OnFireHit(NULL);
  11428. return;
  11429. }
  11430. }
  11431.  
  11432.  
  11433. l_destructibleCmp = (CDestructionSystemComponent) l_hitComponent;
  11434. if( l_destructibleCmp && l_stateName != 'CombatFists' )
  11435. {
  11436. l_destructibleCmp.ApplyFracture();
  11437. }
  11438.  
  11439.  
  11440.  
  11441. }
  11442.  
  11443. public function ReactToReflectedAttack( target : CGameplayEntity)
  11444. {
  11445.  
  11446. var hp, dmg : float;
  11447. var action : W3DamageAction;
  11448.  
  11449. super.ReactToReflectedAttack(target);
  11450.  
  11451.  
  11452. theGame.VibrateControllerLight();
  11453. }
  11454.  
  11455.  
  11456.  
  11457.  
  11458.  
  11459.  
  11460. function GetFallDist( out fallDist : float ) : bool
  11461. {
  11462. var fallDiff, jumpTotalDiff : float;
  11463.  
  11464.  
  11465. substateManager.m_SharedDataO.CalculateFallingHeights( fallDiff, jumpTotalDiff );
  11466.  
  11467. if ( fallDiff <= 0 )
  11468. return false;
  11469.  
  11470. fallDist = fallDiff;
  11471. return true;
  11472. }
  11473.  
  11474. function ApplyFallingDamage(heightDiff : float, optional reducing : bool) : float
  11475. {
  11476. var hpPerc : float;
  11477. var tut : STutorialMessage;
  11478.  
  11479. if ( IsSwimming() || FactsQuerySum("block_falling_damage") >= 1 )
  11480. return 0.0f;
  11481.  
  11482. hpPerc = super.ApplyFallingDamage( heightDiff, reducing );
  11483.  
  11484. if(hpPerc > 0)
  11485. {
  11486. theGame.VibrateControllerHard();
  11487.  
  11488. if(IsAlive())
  11489. {
  11490. if(ShouldProcessTutorial('TutorialFallingDamage'))
  11491. {
  11492. FactsSet( "tutorial_falling_damage", 1 );
  11493. }
  11494.  
  11495. if(FactsQuerySum("tutorial_falling_damage") > 1 && ShouldProcessTutorial('TutorialFallingRoll'))
  11496. {
  11497.  
  11498. tut.type = ETMT_Hint;
  11499. tut.tutorialScriptTag = 'TutorialFallingRoll';
  11500. tut.hintPositionType = ETHPT_DefaultGlobal;
  11501. tut.hintDurationType = ETHDT_Long;
  11502. tut.canBeShownInMenus = false;
  11503. tut.glossaryLink = false;
  11504. tut.markAsSeenOnShow = true;
  11505.  
  11506.  
  11507. theGame.GetTutorialSystem().DisplayTutorial(tut);
  11508. }
  11509. }
  11510. }
  11511.  
  11512. return hpPerc;
  11513. }
  11514.  
  11515.  
  11516.  
  11517. public function SetShowToLowStaminaIndication( value : float ) : void
  11518. {
  11519. fShowToLowStaminaIndication = value;
  11520. }
  11521.  
  11522. public function GetShowToLowStaminaIndication() : float
  11523. {
  11524. return fShowToLowStaminaIndication;
  11525. }
  11526.  
  11527. public final function IndicateTooLowAdrenaline()
  11528. {
  11529. SoundEvent("gui_no_adrenaline");
  11530. showTooLowAdrenaline = true;
  11531. }
  11532.  
  11533.  
  11534.  
  11535. protected function GotoCombatStateWithAction( initialAction : EInitialAction, optional initialBuff : CBaseGameplayEffect )
  11536. {
  11537. if ( this.GetCurrentActionType() == ActorAction_Exploration )
  11538. ActionCancelAll();
  11539.  
  11540. ((W3PlayerWitcherStateCombatFists)this.GetState('CombatFists')).SetupState( initialAction, initialBuff );
  11541. this.GotoState( 'CombatFists' );
  11542.  
  11543. }
  11544.  
  11545.  
  11546. public function IsThreat( actor : CActor, optional usePrecalcs : bool ) : bool
  11547. {
  11548. var npc : CNewNPC;
  11549. var dist : float;
  11550. var targetCapsuleHeight : float;
  11551. var isDistanceExpanded : bool;
  11552. var distanceToTarget : float;
  11553. var attitude : EAIAttitude;
  11554.  
  11555. if (!actor)
  11556. {
  11557. return false;
  11558. }
  11559.  
  11560. if ( finishableEnemiesList.Contains( actor ) )
  11561. {
  11562. return true;
  11563. }
  11564.  
  11565. if ( !actor.IsAlive() || actor.IsKnockedUnconscious() )
  11566. {
  11567. return false;
  11568. }
  11569.  
  11570. npc = (CNewNPC)actor;
  11571. if (npc && npc.IsHorse() )
  11572. {
  11573. return false;
  11574. }
  11575.  
  11576. if ( hostileEnemies.Contains( actor ) )
  11577. {
  11578. return true;
  11579. }
  11580.  
  11581.  
  11582. if ( GetAttitudeBetween( this, actor ) == AIA_Hostile )
  11583. {
  11584. if ( usePrecalcs )
  11585. {
  11586. distanceToTarget = Distance2DBetweenCapsuleAndPoint( actor, this ) - targetingPrecalcs.playerRadius;
  11587. }
  11588. else
  11589. {
  11590. distanceToTarget = Distance2DBetweenCapsules( this, actor );
  11591. }
  11592.  
  11593.  
  11594. if ( distanceToTarget < findMoveTargetDist + 5.0f )
  11595. {
  11596. return true;
  11597. }
  11598.  
  11599. if ( actor.IsInCombat() || this.IsHardLockEnabled() )
  11600. {
  11601. targetCapsuleHeight = ( (CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent() ).GetCapsuleHeight();
  11602. if ( targetCapsuleHeight >= 2.0f || npc.GetCurrentStance() == NS_Fly )
  11603. {
  11604.  
  11605. if ( distanceToTarget < 40.0f )
  11606. {
  11607. return true;
  11608. }
  11609. }
  11610. }
  11611. }
  11612.  
  11613. if ( actor.GetAttitudeGroup() == 'npc_charmed' )
  11614. {
  11615. if ( theGame.GetGlobalAttitude( GetBaseAttitudeGroup(), actor.GetBaseAttitudeGroup() ) == AIA_Hostile )
  11616. {
  11617. return true;
  11618. }
  11619. }
  11620.  
  11621. return false;
  11622. }
  11623.  
  11624. function SetBIsCombatActionAllowed ( flag : bool )
  11625. {
  11626. bIsCombatActionAllowed = flag;
  11627.  
  11628. if ( !flag )
  11629. {
  11630. SetBIsInCombatAction(true);
  11631. }
  11632. else
  11633. {
  11634. this.ProcessLAxisCaching();
  11635.  
  11636. }
  11637.  
  11638.  
  11639. }
  11640.  
  11641. function GetBIsCombatActionAllowed() : bool
  11642. {
  11643. return bIsCombatActionAllowed;
  11644. }
  11645.  
  11646. function SetCombatAction( action : EBufferActionType )
  11647. {
  11648. currentCombatAction = action;
  11649. }
  11650.  
  11651. function GetCombatAction() : EBufferActionType
  11652. {
  11653. return currentCombatAction;
  11654. }
  11655.  
  11656. protected function WhenCombatActionIsFinished()
  11657. {
  11658. if(IsThrowingItem() || IsThrowingItemWithAim() )
  11659. {
  11660. if(inv.IsItemBomb(selectedItemId))
  11661. {
  11662. BombThrowAbort();
  11663. }
  11664. else
  11665. {
  11666. ThrowingAbort();
  11667. }
  11668. }
  11669.  
  11670. if ( this.GetCurrentStateName() != 'DismountHorse' )
  11671. OnRangedForceHolster( true );
  11672.  
  11673.  
  11674. }
  11675.  
  11676. public function IsInCombatAction_Attack(): bool
  11677. {
  11678. if ( IsInCombatAction_NonSpecialAttack() || IsInCombatAction_SpecialAttack() )
  11679. return true;
  11680. else
  11681. return false;
  11682. }
  11683.  
  11684. public function IsInCombatAction_NonSpecialAttack(): bool
  11685. {
  11686. if ( IsInCombatAction() && ( GetCombatAction() == EBAT_LightAttack || GetCombatAction() == EBAT_HeavyAttack ) )
  11687. return true;
  11688. else
  11689. return false;
  11690. }
  11691.  
  11692. public function IsInSpecificCombatAction ( specificCombatAction : EBufferActionType ) : bool
  11693. {
  11694. if ( IsInCombatAction() && GetCombatAction() == specificCombatAction )
  11695. return true;
  11696. else
  11697. return false;
  11698. }
  11699.  
  11700. public function IsInRunAnimation() : bool
  11701. {
  11702. return isInRunAnimation;
  11703. }
  11704.  
  11705.  
  11706. public function SetCombatIdleStance( stance : float )
  11707. {
  11708. SetBehaviorVariable( 'combatIdleStance', stance );
  11709. SetBehaviorVariable( 'CombatStanceForOverlay', stance );
  11710.  
  11711. if ( stance == 0.f )
  11712. LogChannel( 'ComboInput', "combatIdleStance = Left" );
  11713. else
  11714. LogChannel( 'ComboInput', "combatIdleStance = Right" );
  11715. }
  11716.  
  11717. public function GetCombatIdleStance() : float
  11718. {
  11719.  
  11720. return GetBehaviorVariable( 'combatIdleStance' );
  11721. }
  11722.  
  11723. protected var isRotatingInPlace : bool;
  11724. event OnRotateInPlaceStart()
  11725. {
  11726. isRotatingInPlace = true;
  11727. }
  11728.  
  11729. event OnRotateInPlaceEnd()
  11730. {
  11731. isRotatingInPlace = false;
  11732. }
  11733.  
  11734. event OnFullyBlendedIdle()
  11735. {
  11736. if ( bLAxisReleased )
  11737. {
  11738. ResetRawPlayerHeading();
  11739. ResetCachedRawPlayerHeading();
  11740. defaultLocomotionController.ResetMoveDirection();
  11741. }
  11742. }
  11743.  
  11744. private var isInIdle : bool;
  11745.  
  11746. event OnPlayerIdleStart()
  11747. {
  11748. isInIdle = true;
  11749. }
  11750.  
  11751. event OnPlayerIdleEnd()
  11752. {
  11753. isInIdle = false;
  11754. }
  11755.  
  11756. public function IsInIdle() : bool
  11757. {
  11758. return isInIdle;
  11759. }
  11760.  
  11761. event OnRunLoopStart()
  11762. {
  11763. EnableRunCamera( true );
  11764. }
  11765.  
  11766. event OnRunLoopEnd()
  11767. {
  11768. EnableRunCamera( false );
  11769. }
  11770.  
  11771. event OnCombatActionStartBehgraph()
  11772. {
  11773. var action : EBufferActionType;
  11774. var cost, delay : float;
  11775.  
  11776.  
  11777.  
  11778.  
  11779. OnCombatActionStart();
  11780.  
  11781. action = PerformingCombatAction();
  11782. switch ( action )
  11783. {
  11784. case EBAT_LightAttack :
  11785. {
  11786. abilityManager.GetStaminaActionCost(ESAT_LightAttack, cost, delay);
  11787. } break;
  11788. case EBAT_HeavyAttack :
  11789. {
  11790. abilityManager.GetStaminaActionCost(ESAT_HeavyAttack, cost, delay);
  11791. } break;
  11792. case EBAT_ItemUse :
  11793. {
  11794. abilityManager.GetStaminaActionCost(ESAT_UsableItem, cost, delay);
  11795. } break;
  11796. case EBAT_Parry :
  11797. {
  11798. abilityManager.GetStaminaActionCost(ESAT_Parry, cost, delay);
  11799. } break;
  11800. case EBAT_Dodge :
  11801. {
  11802. abilityManager.GetStaminaActionCost(ESAT_Dodge, cost, delay);
  11803. } break;
  11804. case EBAT_Roll :
  11805. abilityManager.GetStaminaActionCost(ESAT_Roll, cost, delay);
  11806. break;
  11807. case EBAT_SpecialAttack_Light :
  11808. {
  11809. abilityManager.GetStaminaActionCost(ESAT_Ability, cost, delay, 0,0, GetSkillAbilityName(S_Sword_s01));
  11810. } break;
  11811. case EBAT_SpecialAttack_Heavy :
  11812. {
  11813. abilityManager.GetStaminaActionCost(ESAT_Ability, cost, delay, 0,0, GetSkillAbilityName(S_Sword_s02));
  11814. } break;
  11815. case EBAT_Roll :
  11816. {
  11817. abilityManager.GetStaminaActionCost(ESAT_Evade, cost, delay);
  11818. } break;
  11819.  
  11820. default :
  11821. ;
  11822. }
  11823.  
  11824.  
  11825.  
  11826. if( delay > 0 )
  11827. PauseStaminaRegen( 'InsideCombatAction' );
  11828. }
  11829.  
  11830. public function HolsterUsableItem() : bool
  11831. {
  11832. return holsterUsableItem;
  11833. }
  11834.  
  11835. private var isInGuardedState : bool;
  11836. public function IsInGuardedState() : bool
  11837. {
  11838. return isInGuardedState;
  11839. }
  11840.  
  11841. event OnGuardedStart()
  11842. {
  11843. isInParryOrCounter = true;
  11844. isInGuardedState = true;
  11845. }
  11846.  
  11847. event OnGuardedEnd()
  11848. {
  11849. isInParryOrCounter = false;
  11850. isInGuardedState = false;
  11851. }
  11852.  
  11853. private var restoreUsableItem : bool;
  11854. private var holsterUsableItem : bool;
  11855. event OnCombatActionStart()
  11856. {
  11857.  
  11858.  
  11859. BlockAction( EIAB_UsableItem, 'OnCombatActionStart' );
  11860. BlockAction( EIAB_CallHorse, 'OnCombatActionStart' );
  11861.  
  11862.  
  11863.  
  11864. LogChannel('combatActionAllowed',"FALSE OnCombatActionStart");
  11865. SetBIsCombatActionAllowed( false );
  11866. SetBIsInputAllowed( false, 'OnCombatActionStart' );
  11867.  
  11868.  
  11869. ClearFinishableEnemyList( 0.f, 0 );
  11870.  
  11871. bIsInHitAnim = false;
  11872.  
  11873.  
  11874.  
  11875. if ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  11876. {
  11877. CleanCombatActionBuffer();
  11878. SetIsAimingCrossbow( false );
  11879. OnRangedForceHolster( false, true );
  11880. }
  11881.  
  11882.  
  11883. holsterUsableItem = false;
  11884. if ( thePlayer.IsHoldingItemInLHand() )
  11885. {
  11886. if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign )
  11887. holsterUsableItem = true;
  11888. else if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
  11889. {
  11890. if ( this.GetCurrentStateName() == 'CombatFists' )
  11891. holsterUsableItem = true;
  11892. }
  11893. }
  11894.  
  11895. if ( holsterUsableItem )
  11896. {
  11897. thePlayer.SetPlayerActionToRestore ( PATR_None );
  11898. thePlayer.OnUseSelectedItem( true );
  11899.  
  11900. restoreUsableItem = true;
  11901. }
  11902.  
  11903.  
  11904. if ( GetBehaviorVariable( 'combatActionType' ) != (int)CAT_Attack && GetBehaviorVariable( 'combatActionType' ) != (int)CAT_PreAttack )
  11905. {
  11906. RemoveTimer( 'ProcessAttackTimer' );
  11907. RemoveTimer( 'AttackTimerEnd' );
  11908. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  11909. }
  11910. else
  11911. {
  11912.  
  11913. BlockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  11914. }
  11915.  
  11916.  
  11917. }
  11918.  
  11919. var isInParryOrCounter : bool;
  11920. event OnParryOrCounterStart()
  11921. {
  11922. isInParryOrCounter = true;
  11923. OnCombatActionStartBehgraph();
  11924. }
  11925.  
  11926. event OnParryOrCounterEnd()
  11927. {
  11928. isInParryOrCounter = false;
  11929. OnCombatActionEnd();
  11930. SetBIsInCombatAction( false );
  11931. }
  11932.  
  11933.  
  11934. event OnCombatActionEnd()
  11935. {
  11936. var item : SItemUniqueId;
  11937. var combatActionType : float;
  11938.  
  11939. super.OnCombatActionEnd();
  11940.  
  11941.  
  11942.  
  11943. BlockAllActions( 'OnCombatActionStart', false );
  11944.  
  11945. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  11946.  
  11947.  
  11948. UnblockAction( EIAB_Movement, 'CombatActionFriendly' );
  11949.  
  11950.  
  11951.  
  11952.  
  11953. oTCameraOffset = 0.f;
  11954. oTCameraPitchOffset = 0.f;
  11955.  
  11956.  
  11957. SetBIsCombatActionAllowed( true );
  11958.  
  11959.  
  11960. SetBIsInputAllowed( true, 'OnCombatActionEnd' );
  11961. SetCanPlayHitAnim( true );
  11962. EnableFindTarget( true );
  11963.  
  11964.  
  11965.  
  11966.  
  11967. SetFinisherVictim( NULL );
  11968.  
  11969. OnBlockAllCombatTickets( false );
  11970.  
  11971. LogStamina("CombatActionEnd");
  11972.  
  11973.  
  11974.  
  11975. SetAttackActionName('');
  11976. combatActionType = GetBehaviorVariable('combatActionType');
  11977.  
  11978.  
  11979. if(GetBehaviorVariable('combatActionType') == (int)CAT_SpecialAttack)
  11980. {
  11981. theGame.GetGameCamera().StopAnimation( 'camera_shake_loop_lvl1_1' );
  11982. OnSpecialAttackHeavyActionProcess();
  11983. }
  11984.  
  11985. substateManager.ReactToChanceToFallAndSlide();
  11986. }
  11987.  
  11988. event OnCombatActionFriendlyStart()
  11989. {
  11990. SetBIsInCombatActionFriendly(true);
  11991. BlockAction( EIAB_Movement, 'CombatActionFriendly', false, false, false );
  11992. OnCombatActionStart();
  11993. }
  11994.  
  11995. event OnCombatActionFriendlyEnd()
  11996. {
  11997. SetBIsInCombatActionFriendly(false);
  11998. UnblockAction( EIAB_Movement, 'CombatActionFriendly' );
  11999. OnCombatActionEnd();
  12000. SetBIsInCombatAction(false);
  12001.  
  12002. }
  12003.  
  12004. event OnHitStart()
  12005. {
  12006. var timeLeft : float;
  12007. var currentEffects : array<CBaseGameplayEffect>;
  12008. var none : SAbilityAttributeValue;
  12009.  
  12010. CancelHoldAttacks();
  12011. WhenCombatActionIsFinished();
  12012. if ( isInFinisher )
  12013. {
  12014. if ( finisherTarget )
  12015. ( (CNewNPC)finisherTarget ).SignalGameplayEvent( 'FinisherInterrupt' );
  12016. isInFinisher = false;
  12017. finisherTarget = NULL;
  12018. SetBIsCombatActionAllowed( true );
  12019. }
  12020.  
  12021. bIsInHitAnim = true;
  12022.  
  12023. OnCombatActionStart();
  12024.  
  12025.  
  12026. ResumeStaminaRegen( 'InsideCombatAction' );
  12027.  
  12028. if( GetHealthPercents() < 0.3f )
  12029. {
  12030. PlayBattleCry('BattleCryBadSituation', 0.10f, true );
  12031. }
  12032. else
  12033. {
  12034. PlayBattleCry('BattleCryBadSituation', 0.05f, true );
  12035. }
  12036. }
  12037.  
  12038. event OnHitStartSwimming()
  12039. {
  12040. OnRangedForceHolster( true, true, false );
  12041. }
  12042.  
  12043. private var finisherSaveLock : int;
  12044. event OnFinisherStart()
  12045. {
  12046. var currentEffects : array<CBaseGameplayEffect>;
  12047.  
  12048. theGame.CreateNoSaveLock("Finisher",finisherSaveLock,true,false);
  12049.  
  12050. isInFinisher = true;
  12051.  
  12052. finisherTarget = slideTarget;
  12053. OnCombatActionStart();
  12054.  
  12055. CancelHoldAttacks();
  12056.  
  12057. PlayFinisherCameraAnimation( theGame.GetSyncAnimManager().GetFinisherCameraAnimName() );
  12058. this.AddAnimEventCallback('SyncEvent','OnFinisherAnimEvent_SyncEvent');
  12059. SetImmortalityMode( AIM_Invulnerable, AIC_SyncedAnim );
  12060. }
  12061.  
  12062. public function IsPerformingFinisher() : bool
  12063. {
  12064. return isInFinisher;
  12065. }
  12066.  
  12067. private function PlayFinisherCameraAnimation( cameraAnimName : name )
  12068. {
  12069. var camera : CCustomCamera = theGame.GetGameCamera();
  12070. var animation : SCameraAnimationDefinition;
  12071.  
  12072. if( IsLastEnemyKilled() && theGame.GetWorld().NavigationCircleTest( this.GetWorldPosition(), 3.f ) )
  12073. {
  12074. camera.StopAnimation('camera_shake_hit_lvl3_1' );
  12075.  
  12076. animation.animation = cameraAnimName;
  12077. animation.priority = CAP_Highest;
  12078. animation.blendIn = 0.15f;
  12079. animation.blendOut = 1.0f;
  12080. animation.weight = 1.f;
  12081. animation.speed = 1.0f;
  12082. animation.reset = true;
  12083.  
  12084. camera.PlayAnimation( animation );
  12085.  
  12086.  
  12087. thePlayer.EnableManualCameraControl( false, 'Finisher' );
  12088. }
  12089. }
  12090.  
  12091. public function IsLastEnemyKilled() : bool
  12092. {
  12093. var tempMoveTargets : array<CActor>;
  12094.  
  12095. FindMoveTarget();
  12096. tempMoveTargets = GetMoveTargets();
  12097. if ( tempMoveTargets.Size() <= 0 || !thePlayer.IsThreat( tempMoveTargets[0] ) )
  12098. return true;
  12099.  
  12100. return false;
  12101. }
  12102.  
  12103. event OnFinisherAnimEvent_SyncEvent( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  12104. {
  12105. if ( finisherTarget )
  12106. ( (CNewNPC)finisherTarget ).SignalGameplayEvent('FinisherKill');
  12107. finisherTarget = NULL;
  12108. }
  12109.  
  12110. event OnFinisherEnd()
  12111. {
  12112. isInFinisher = false;
  12113. finisherTarget = NULL;
  12114.  
  12115. theGame.ReleaseNoSaveLock(finisherSaveLock);
  12116.  
  12117. this.RemoveAnimEventCallback('SyncEvent');
  12118.  
  12119.  
  12120. SetImmortalityMode( AIM_None, AIC_SyncedAnim );
  12121. theGame.RemoveTimeScale( 'AnimEventSlomoMo' );
  12122. AddTimer( 'FinisherEndEnableCamera', 0.5f );
  12123.  
  12124. OnCombatActionEnd();
  12125. OnCombatActionEndComplete();
  12126. }
  12127.  
  12128. private timer function FinisherEndEnableCamera( dt : float, id : int )
  12129. {
  12130. thePlayer.EnableManualCameraControl( true, 'Finisher' );
  12131. }
  12132.  
  12133. public function SpawnFinisherBlood()
  12134. {
  12135. var weaponEntity : CEntity;
  12136. var weaponSlotMatrix : Matrix;
  12137. var bloodFxPos : Vector;
  12138. var bloodFxRot : EulerAngles;
  12139. var tempEntity : CEntity;
  12140.  
  12141. weaponEntity = this.GetInventory().GetItemEntityUnsafe( GetInventory().GetItemFromSlot('r_weapon') );
  12142. weaponEntity.CalcEntitySlotMatrix( 'blood_fx_point', weaponSlotMatrix );
  12143. bloodFxPos = MatrixGetTranslation( weaponSlotMatrix );
  12144. bloodFxRot = this.GetWorldRotation();
  12145. tempEntity = theGame.CreateEntity( (CEntityTemplate)LoadResource('finisher_blood'), bloodFxPos, bloodFxRot);
  12146. tempEntity.PlayEffect('crawl_blood');
  12147. }
  12148.  
  12149.  
  12150. event OnCombatActionEndComplete()
  12151. {
  12152. var buff : CBaseGameplayEffect;
  12153.  
  12154. buff = ChooseCurrentCriticalBuffForAnim();
  12155. SetCombatAction( EBAT_EMPTY );
  12156.  
  12157.  
  12158. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart' );
  12159. UnblockAction( EIAB_OpenInventory, 'OnCombatActionStart' );
  12160. UnblockAction( EIAB_UsableItem, 'OnCombatActionStart' );
  12161.  
  12162. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  12163.  
  12164. SetUnpushableTarget( NULL );
  12165. SetBIsInCombatAction(false);
  12166. SetIsCurrentlyDodging(false);
  12167. SetMoveTargetChangeAllowed( true );
  12168. SetCanPlayHitAnim( true );
  12169.  
  12170. SetFinisherVictim( NULL );
  12171.  
  12172. this.RemoveBuffImmunity(EET_Burning, 'AnimEvent_RemoveBurning');
  12173.  
  12174. if ( rangedWeapon && rangedWeapon.GetCurrentStateName() == 'State_WeaponWait' && !buff )
  12175. {
  12176. ClearCustomOrientationInfoStack();
  12177. SetSlideTarget( NULL );
  12178. }
  12179.  
  12180. UnblockAction( EIAB_Crossbow, 'OnForceHolster' );
  12181.  
  12182. specialAttackCamera = false;
  12183.  
  12184. bIsRollAllowed = false;
  12185.  
  12186. if ( bLAxisReleased )
  12187. {
  12188. ResetRawPlayerHeading();
  12189. ResetCachedRawPlayerHeading();
  12190. }
  12191.  
  12192.  
  12193. ReapplyCriticalBuff();
  12194. SetBIsInputAllowed( true, 'OnCombatActionEndComplete' );
  12195.  
  12196.  
  12197. ResumeStaminaRegen( 'InsideCombatAction' );
  12198.  
  12199. bIsInHitAnim = false;
  12200.  
  12201. SetBIsCombatActionAllowed( true );
  12202.  
  12203. m_LastWeaponTipPos = Vector(0, 0, 0, 0 );
  12204.  
  12205.  
  12206. this.AddTimer('FreeTickets',3.f,false);
  12207.  
  12208.  
  12209.  
  12210. }
  12211.  
  12212. event OnMovementFullyBlended()
  12213. {
  12214. SetBehaviorVariable( 'isPerformingSpecialAttack', 0.f );
  12215.  
  12216. if ( restoreUsableItem )
  12217. {
  12218. restoreUsableItem = false;
  12219. SetPlayerActionToRestore ( PATR_Default );
  12220. OnUseSelectedItem();
  12221. }
  12222. }
  12223.  
  12224. event OnCombatMovementStart()
  12225. {
  12226. SetCombatIdleStance( 1.f );
  12227. OnCombatActionEndComplete();
  12228. }
  12229.  
  12230. timer function FreeTickets( dt : float, id : int )
  12231. {
  12232. FreeTicketAtCombatTarget();
  12233. }
  12234.  
  12235.  
  12236.  
  12237. event OnGuardedReleased(){}
  12238. event OnPerformAttack( playerAttackType : name ){}
  12239. event OnPerformEvade( playerEvadeType : EPlayerEvadeType ){}
  12240. event OnInterruptAttack(){}
  12241. event OnPerformGuard(){}
  12242. event OnSpawnHorse(){}
  12243. event OnDismountActionScriptCallback(){}
  12244.  
  12245. event OnHorseSummonStart()
  12246. {
  12247. thePlayer.BlockAction(EIAB_CallHorse, 'HorseSummon');
  12248. thePlayer.BlockAction(EIAB_Signs, 'HorseSummon');
  12249. thePlayer.BlockAction(EIAB_Crossbow, 'HorseSummon');
  12250. thePlayer.BlockAction(EIAB_UsableItem, 'HorseSummon');
  12251. thePlayer.BlockAction(EIAB_ThrowBomb, 'HorseSummon');
  12252. thePlayer.BlockAction(EIAB_SwordAttack, 'HorseSummon');
  12253. thePlayer.BlockAction(EIAB_Jump, 'HorseSummon');
  12254. thePlayer.BlockAction(EIAB_Dodge, 'HorseSummon');
  12255. thePlayer.BlockAction(EIAB_LightAttacks, 'HorseSummon');
  12256. thePlayer.BlockAction(EIAB_HeavyAttacks, 'HorseSummon');
  12257. thePlayer.BlockAction(EIAB_SpecialAttackLight, 'HorseSummon');
  12258. thePlayer.BlockAction(EIAB_SpecialAttackHeavy, 'HorseSummon');
  12259.  
  12260. horseSummonTimeStamp = theGame.GetEngineTimeAsSeconds();
  12261. }
  12262.  
  12263. event OnHorseSummonStop()
  12264. {
  12265. thePlayer.BlockAllActions('HorseSummon',false);
  12266. }
  12267.  
  12268.  
  12269. event OnCombatActionStartVehicle( action : EVehicleCombatAction )
  12270. {
  12271. this.SetBIsCombatActionAllowed( false );
  12272.  
  12273. if ( action != EHCA_ShootCrossbow )
  12274. {
  12275. SetIsAimingCrossbow( false );
  12276. OnRangedForceHolster();
  12277. }
  12278. }
  12279.  
  12280. event OnCombatActionEndVehicle()
  12281. {
  12282. this.SetBIsCombatActionAllowed( true );
  12283. }
  12284.  
  12285.  
  12286.  
  12287.  
  12288.  
  12289. protected function CriticalBuffInformBehavior(buff : CBaseGameplayEffect)
  12290. {
  12291.  
  12292. if( !CanAnimationReactToCriticalState( buff ) )
  12293. {
  12294. return;
  12295. }
  12296.  
  12297.  
  12298.  
  12299.  
  12300. SetBehaviorVariable( 'CriticalStateType', (int)GetBuffCriticalType(buff) );
  12301. SetBehaviorVariable( 'bCriticalState', 1);
  12302.  
  12303. if(CriticalBuffUsesFullBodyAnim(buff))
  12304. RaiseEvent('CriticalState');
  12305.  
  12306. SetBehaviorVariable( 'IsInAir', (int)IsInAir());
  12307.  
  12308. LogCritical("Sending player critical state event for <<" + buff.GetEffectType() + ">>");
  12309.  
  12310.  
  12311. }
  12312.  
  12313. private function CanAnimationReactToCriticalState( buff : CBaseGameplayEffect ) : bool
  12314. {
  12315. var buffCritical : W3CriticalEffect;
  12316. var buffCriticalDOT : W3CriticalDOTEffect;
  12317. var isHeavyCritical : bool;
  12318.  
  12319. isHeavyCritical = false;
  12320.  
  12321.  
  12322. buffCritical = ( W3CriticalEffect ) buff;
  12323. if( buffCritical )
  12324. {
  12325. isHeavyCritical = buffCritical.explorationStateHandling == ECH_HandleNow;
  12326. }
  12327. else
  12328. {
  12329. buffCriticalDOT = ( W3CriticalDOTEffect ) buff;
  12330. if( buffCriticalDOT )
  12331. {
  12332. isHeavyCritical = buffCriticalDOT.explorationStateHandling == ECH_HandleNow;
  12333. }
  12334. }
  12335.  
  12336.  
  12337. if( !isHeavyCritical )
  12338. {
  12339. if( !CanReactToCriticalState() )
  12340. {
  12341. return false;
  12342. }
  12343. }
  12344.  
  12345. return true;
  12346. }
  12347.  
  12348. public function CanReactToCriticalState() : bool
  12349. {
  12350. return substateManager.CanReactToHardCriticalState();
  12351. }
  12352.  
  12353. event OnCriticalStateAnimStart()
  12354. {
  12355. var heading : float;
  12356. var newCritical : ECriticalStateType;
  12357. var newReqCS : CBaseGameplayEffect;
  12358.  
  12359. OnCombatActionEndComplete();
  12360.  
  12361.  
  12362. newReqCS = newRequestedCS;
  12363. if(super.OnCriticalStateAnimStart())
  12364. {
  12365.  
  12366. RemoveTimer( 'IsItemUseInputHeld' );
  12367. keepRequestingCriticalAnimStart = false;
  12368. CancelHoldAttacks();
  12369.  
  12370.  
  12371.  
  12372.  
  12373.  
  12374. if(!IsUsingVehicle())
  12375. {
  12376. newCritical = GetBuffCriticalType(newReqCS);
  12377. if(newCritical == ECST_HeavyKnockdown
  12378. || newCritical == ECST_Knockdown
  12379. || newCritical == ECST_Stagger
  12380. || newCritical == ECST_Ragdoll
  12381. || newCritical == ECST_LongStagger )
  12382. {
  12383. if(newReqCS.GetCreator())
  12384. heading = VecHeading(newReqCS.GetCreator().GetWorldPosition() - GetWorldPosition());
  12385. else
  12386. heading = GetHeading();
  12387.  
  12388.  
  12389. SetCustomRotation( 'Knockdown', heading, 2160.f, 0.1f, true );
  12390.  
  12391. if ( newCritical != ECST_Stagger && newCritical != ECST_LongStagger )
  12392. substateManager.ReactOnCriticalState( true );
  12393. }
  12394. }
  12395.  
  12396. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'CriticalEffectStart', -1, 30.0f, -1.f, -1, true );
  12397. return true;
  12398. }
  12399.  
  12400.  
  12401. return false;
  12402. }
  12403.  
  12404.  
  12405. public function StartCSAnim(buff : CBaseGameplayEffect) : bool
  12406. {
  12407. SetBehaviorVariable( 'bCriticalStopped', 0 );
  12408.  
  12409. if(super.StartCSAnim(buff))
  12410. {
  12411. if(!CriticalBuffUsesFullBodyAnim(buff))
  12412. {
  12413. OnCriticalStateAnimStart();
  12414. }
  12415.  
  12416. ResumeStaminaRegen( 'InsideCombatAction' );
  12417.  
  12418. keepRequestingCriticalAnimStart = true;
  12419. AddTimer('RequestCriticalAnimStart', 0, true);
  12420.  
  12421.  
  12422. return true;
  12423. }
  12424.  
  12425. return false;
  12426. }
  12427.  
  12428. public function CriticalEffectAnimationInterrupted(reason : string) : bool
  12429. {
  12430. var ret : bool;
  12431.  
  12432. LogCriticalPlayer("R4Player.CriticalEffectAnimationInterrupted() - because: " + reason);
  12433.  
  12434. ret = super.CriticalEffectAnimationInterrupted(reason);
  12435.  
  12436. if(ret)
  12437. {
  12438. keepRequestingCriticalAnimStart = false;
  12439. }
  12440.  
  12441. substateManager.ReactOnCriticalState( false );
  12442.  
  12443. return ret;
  12444. }
  12445.  
  12446. public function CriticalStateAnimStopped(forceRemoveBuff : bool)
  12447. {
  12448. LogCriticalPlayer("R4Player.CriticalStateAnimStopped() - forced: " + forceRemoveBuff);
  12449.  
  12450. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'RecoveredFromCriticalEffect', -1, 30.0f, -1.f, -1, true );
  12451. super.CriticalStateAnimStopped(forceRemoveBuff);
  12452.  
  12453. substateManager.ReactOnCriticalState( false );
  12454. }
  12455.  
  12456.  
  12457. timer function RequestCriticalAnimStart(dt : float, id : int)
  12458. {
  12459. if(keepRequestingCriticalAnimStart)
  12460. {
  12461. if(newRequestedCS && newRequestedCS.GetDurationLeft() > 0)
  12462. {
  12463. CriticalBuffInformBehavior(newRequestedCS);
  12464. }
  12465. else
  12466. {
  12467. keepRequestingCriticalAnimStart = false;
  12468. RemoveTimer('RequestCriticalAnimStart');
  12469. }
  12470. }
  12471. else
  12472. {
  12473. RemoveTimer('RequestCriticalAnimStart');
  12474. }
  12475. }
  12476.  
  12477. event OnRagdollUpdate(progress : float)
  12478. {
  12479.  
  12480.  
  12481. SetIsInAir(progress == 0);
  12482. }
  12483.  
  12484.  
  12485. event OnRagdollOnGround()
  12486. {
  12487.  
  12488. TryToEndRagdollOnGround( 0.0f );
  12489. }
  12490.  
  12491. event OnRagdollInAir()
  12492. {
  12493. RemoveTimer('TryToEndRagdollOnGround');
  12494. }
  12495.  
  12496. event OnNoLongerInRagdoll()
  12497. {
  12498. RemoveTimer('TryToEndRagdollOnGround');
  12499. }
  12500.  
  12501. timer function TryToEndRagdollOnGround( td : float, optional id : int)
  12502. {
  12503. var critical : CBaseGameplayEffect;
  12504. var type : EEffectType;
  12505.  
  12506. critical = GetCurrentlyAnimatedCS();
  12507. if(critical)
  12508. {
  12509. type = critical.GetEffectType();
  12510. if(type == EET_Knockdown || type == EET_HeavyKnockdown || type == EET_Ragdoll)
  12511. {
  12512.  
  12513. if (critical.GetTimeActive() >= 2.5f)
  12514. {
  12515. SetIsInAir(false);
  12516. RequestCriticalAnimStop();
  12517. RemoveTimer('TryToEndRagdollOnGround');
  12518. }
  12519. else
  12520. {
  12521. AddTimer('TryToEndRagdollOnGround', 0.2f, true);
  12522. }
  12523. return;
  12524. }
  12525. }
  12526.  
  12527.  
  12528. RemoveTimer('TryToEndRagdollOnGround');
  12529. }
  12530.  
  12531. public function RequestCriticalAnimStop(optional dontSetCriticalToStopped : bool)
  12532. {
  12533. var buff : CBaseGameplayEffect;
  12534.  
  12535. buff = GetCurrentlyAnimatedCS();
  12536. if(buff && !CriticalBuffUsesFullBodyAnim(buff))
  12537. {
  12538. CriticalStateAnimStopped(false);
  12539. }
  12540.  
  12541. if(!buff || !CriticalBuffUsesFullBodyAnim(buff))
  12542. {
  12543. SetBehaviorVariable( 'bCriticalState', 0);
  12544. }
  12545.  
  12546. super.RequestCriticalAnimStop(dontSetCriticalToStopped);
  12547. }
  12548.  
  12549.  
  12550.  
  12551.  
  12552. public function SimulateBuffTimePassing(simulatedTime : float)
  12553. {
  12554. effectManager.SimulateBuffTimePassing(simulatedTime);
  12555. }
  12556.  
  12557. public function AddEffectDefault(effectType : EEffectType, creat : CGameplayEntity, srcName : string, optional isSignEffect : bool) : EEffectInteract
  12558. {
  12559. var params : SCustomEffectParams;
  12560.  
  12561.  
  12562. if(effectType == EET_Stagger || effectType == EET_LongStagger || effectType == EET_Knockdown || effectType == EET_HeavyKnockdown)
  12563. {
  12564. params.effectType = effectType;
  12565. params.creator = creat;
  12566. params.sourceName = srcName;
  12567. params.isSignEffect = isSignEffect;
  12568.  
  12569. if ( effectType == EET_Stagger )
  12570. params.duration = 1.83;
  12571. else if ( effectType == EET_LongStagger )
  12572. params.duration = 4;
  12573. else if ( effectType == EET_Knockdown )
  12574. params.duration = 2.5;
  12575. else if ( effectType == EET_HeavyKnockdown )
  12576. params.duration = 4;
  12577.  
  12578. return super.AddEffectCustom(params);
  12579. }
  12580. else
  12581. {
  12582. return super.AddEffectDefault(effectType, creat, srcName, isSignEffect);
  12583. }
  12584. }
  12585.  
  12586.  
  12587.  
  12588.  
  12589.  
  12590. public function CheatResurrect()
  12591. {
  12592. var items : array< SItemUniqueId >;
  12593. var i, size, itemLevel, maxPrice, itemPrice : int;
  12594. var itemToEquip : SItemUniqueId;
  12595.  
  12596. if(IsAlive())
  12597. return;
  12598.  
  12599.  
  12600. if ( !theGame.GetGuiManager().GetRootMenu() )
  12601. {
  12602. Log(" *** Call this function after DeathScreen appears *** ");
  12603. return;
  12604. }
  12605.  
  12606. SetAlive(true);
  12607.  
  12608. SetKinematic(true);
  12609.  
  12610. EnableFindTarget( true );
  12611. SetBehaviorVariable( 'Ragdoll_Weight', 0.f );
  12612. RaiseForceEvent( 'RecoverFromRagdoll' );
  12613. SetCanPlayHitAnim( true );
  12614. SetBehaviorVariable( 'CriticalStateType', (int)ECST_None );
  12615. GoToStateIfNew('Exploration');
  12616.  
  12617. ( (CDismembermentComponent)this.GetComponent( 'Dismemberment' ) ).ClearVisibleWound();
  12618.  
  12619. SetIsInAir(false);
  12620.  
  12621. theInput.SetContext('Exploration');
  12622.  
  12623. ResetDeathType();
  12624.  
  12625. ForceUnlockAllInputActions(false);
  12626.  
  12627. theGame.CloseMenu('DeathScreenMenu');
  12628.  
  12629.  
  12630. theSound.LeaveGameState(ESGS_Death);
  12631.  
  12632.  
  12633. abilityManager.ForceSetStat(BCS_Vitality, GetStatMax(BCS_Vitality));
  12634. effectManager.StopVitalityRegen();
  12635. abilityManager.ForceSetStat( BCS_Air , 100.f );
  12636. effectManager.StopAirRegen();
  12637. abilityManager.ForceSetStat( BCS_Stamina , 100.f );
  12638. effectManager.StopStaminaRegen();
  12639. abilityManager.ForceSetStat( BCS_Toxicity , 0.f );
  12640. abilityManager.ForceSetStat( BCS_Focus , 0.f );
  12641. GetWitcherPlayer().UpdateEncumbrance();
  12642.  
  12643.  
  12644. if ( !inv.IsThereItemOnSlot( EES_SteelSword ) )
  12645. {
  12646. items = inv.GetItemsByCategory( 'steelsword' );
  12647. }
  12648. else if ( !inv.IsThereItemOnSlot( EES_SilverSword ) )
  12649. {
  12650. items = inv.GetItemsByCategory( 'silversword' );
  12651. }
  12652.  
  12653. size = items.Size();
  12654. maxPrice = -1;
  12655. for ( i = 0; i < size; i += 1 )
  12656. {
  12657. itemPrice = inv.GetItemPrice(items[i]);
  12658. itemLevel = inv.GetItemLevel(items[i]);
  12659. if ( itemLevel <= GetLevel() && itemPrice > maxPrice )
  12660. {
  12661. maxPrice = itemPrice;
  12662. itemToEquip = items[i];
  12663. }
  12664. }
  12665. if( inv.IsIdValid( itemToEquip ) )
  12666. {
  12667. EquipItem( itemToEquip , , true );
  12668. }
  12669.  
  12670. theGame.ReleaseNoSaveLock(deathNoSaveLock);
  12671. }
  12672.  
  12673.  
  12674.  
  12675. public function SetIsInsideInteraction(b : bool) {isInsideInteraction = b;}
  12676. public function IsInsideInteraction() : bool {return isInsideInteraction;}
  12677.  
  12678. public function SetIsInsideHorseInteraction( b : bool, horse : CEntity )
  12679. {
  12680. isInsideHorseInteraction = b;
  12681. horseInteractionSource = horse;
  12682. }
  12683. public function IsInsideHorseInteraction() : bool {return isInsideHorseInteraction;}
  12684.  
  12685.  
  12686. event OnInteractionActivationTest( interactionComponentName : string, activator : CEntity )
  12687. {
  12688. if ( interactionComponentName == "ClimbLadder" )
  12689. {
  12690. if( PlayerHasLadderExplorationReady() )
  12691. {
  12692. return true;
  12693. }
  12694. }
  12695.  
  12696. return false;
  12697. }
  12698.  
  12699. private function PlayerHasLadderExplorationReady() : bool
  12700. {
  12701. if( !substateManager.CanInteract() )
  12702. {
  12703. return false;
  12704. }
  12705.  
  12706. if( !substateManager.m_SharedDataO.HasValidLadderExploration() )
  12707. {
  12708. return false;
  12709. }
  12710.  
  12711. return true;
  12712. }
  12713.  
  12714.  
  12715.  
  12716.  
  12717.  
  12718. public function SetGuarded(flag : bool)
  12719. {
  12720. super.SetGuarded(flag);
  12721.  
  12722. if(flag && FactsQuerySum("tut_fight_use_slomo") > 0)
  12723. {
  12724. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
  12725. FactsRemove("tut_fight_slomo_ON");
  12726. }
  12727. }
  12728.  
  12729.  
  12730. public function IsGuarded() : bool
  12731. {
  12732. return super.IsGuarded() && ( !rangedWeapon || rangedWeapon.GetCurrentStateName() == 'State_WeaponWait' );
  12733. }
  12734.  
  12735.  
  12736.  
  12737.  
  12738. public function GetSelectedItemId() : SItemUniqueId {return selectedItemId;}
  12739. public function ClearSelectedItemId() {selectedItemId = GetInvalidUniqueId();}
  12740.  
  12741. public function IsHoldingItemInLHand() : bool
  12742. {
  12743. return currentlyEquipedItemL != GetInvalidUniqueId();
  12744. }
  12745.  
  12746. public function GetCurrentlyUsedItemL () : W3UsableItem
  12747. {
  12748. return currentlyUsedItemL;
  12749. }
  12750.  
  12751. public function SetPlayerActionToRestore ( actionToRestoreType : EPlayerActionToRestore )
  12752. {
  12753. playerActionToRestore = actionToRestoreType;
  12754. }
  12755.  
  12756. public function IsCurrentlyUsingItemL () : bool
  12757. {
  12758. return currentlyUsingItem;
  12759. }
  12760.  
  12761. function BlockSlotsOnLItemUse ()
  12762. {
  12763. var slotsToBlock : array<name>;
  12764.  
  12765. slotsToBlock.PushBack( 'Slot1' );
  12766. slotsToBlock.PushBack( 'Slot2' );
  12767. slotsToBlock.PushBack( 'Slot3' );
  12768. slotsToBlock.PushBack( 'Slot4' );
  12769. slotsToBlock.PushBack( 'Slot5' );
  12770. slotsToBlock.PushBack( 'Yrden' );
  12771. slotsToBlock.PushBack( 'Quen' );
  12772. slotsToBlock.PushBack( 'Igni' );
  12773. slotsToBlock.PushBack( 'Axii' );
  12774. slotsToBlock.PushBack( 'Aard' );
  12775.  
  12776.  
  12777. EnableRadialSlotsWithSource ( false, slotsToBlock, 'usableItemL' );
  12778. }
  12779.  
  12780. function UnblockSlotsOnLItemUse ()
  12781. {
  12782. var slotsToBlock : array<name>;
  12783.  
  12784. slotsToBlock.PushBack( 'Slot1' );
  12785. slotsToBlock.PushBack( 'Slot2' );
  12786. slotsToBlock.PushBack( 'Slot3' );
  12787. slotsToBlock.PushBack( 'Slot4' );
  12788. slotsToBlock.PushBack( 'Slot5' );
  12789. slotsToBlock.PushBack( 'Yrden' );
  12790. slotsToBlock.PushBack( 'Quen' );
  12791. slotsToBlock.PushBack( 'Igni' );
  12792. slotsToBlock.PushBack( 'Axii' );
  12793. slotsToBlock.PushBack( 'Aard' );
  12794.  
  12795.  
  12796. EnableRadialSlotsWithSource ( true, slotsToBlock, 'usableItemL' );
  12797. }
  12798.  
  12799. function IsUsableItemLBlocked () : bool
  12800. {
  12801. return isUsableItemBlocked;
  12802. }
  12803. function HideUsableItem( optional force : bool )
  12804. {
  12805. if( currentlyEquipedItemL != GetInvalidUniqueId() )
  12806. {
  12807. if( force )
  12808. {
  12809. if( !RaiseForceEvent( 'ItemEndL' ) )
  12810. {
  12811.  
  12812. OnUsingItemsReset();
  12813. }
  12814. return;
  12815.  
  12816. }
  12817. RaiseEvent( 'ItemUseL' );
  12818. }
  12819. }
  12820. function ProcessUsableItemsTransition ( actionToRestore : EPlayerActionToRestore )
  12821. {
  12822. var category : name;
  12823. var signSkill : ESkill;
  12824.  
  12825. category = inv.GetItemCategory ( selectedItemId );
  12826. signSkill = SignEnumToSkillEnum( GetEquippedSign());
  12827.  
  12828. switch ( actionToRestore )
  12829. {
  12830. case PATR_None:
  12831. if ( currentlyUsedItemL )
  12832. {
  12833. inv.UnmountItem( currentlyEquipedItemL, true );
  12834. }
  12835. currentlyEquipedItemL = GetInvalidUniqueId();
  12836. return;
  12837.  
  12838. case PATR_Default:
  12839. if ( IsSlotQuickslot( inv.GetSlotForItemId ( selectedItemId )) && category == 'usable' && currentlyEquipedItemL != selectedItemId )
  12840. {
  12841. if ( currentlyUsedItemL )
  12842. {
  12843. inv.UnmountItem( currentlyEquipedItemL, true );
  12844. }
  12845. currentlyEquipedItemL = GetInvalidUniqueId();
  12846. OnUseSelectedItem();
  12847. return;
  12848. }
  12849. break;
  12850. case PATR_Crossbow:
  12851. if ( inv.IsItemCrossbow ( selectedItemId ) )
  12852. {
  12853. if ( currentlyUsedItemL )
  12854. {
  12855. inv.UnmountItem( currentlyEquipedItemL, true );
  12856. }
  12857. currentlyEquipedItemL = GetInvalidUniqueId();
  12858. SetIsAimingCrossbow( true );
  12859.  
  12860. if ( theInput.IsActionPressed( 'ThrowItem' ) )
  12861. SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  12862. else
  12863. {
  12864. SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  12865. SetupCombatAction( EBAT_ItemUse, BS_Released );
  12866. }
  12867. return;
  12868. }
  12869. break;
  12870. case PATR_CastSign:
  12871. if( signSkill != S_SUndefined && playerActionToRestore == PATR_CastSign )
  12872. {
  12873. if ( currentlyUsedItemL )
  12874. {
  12875. inv.UnmountItem( currentlyEquipedItemL, true );
  12876. }
  12877. currentlyEquipedItemL = GetInvalidUniqueId();
  12878.  
  12879. if( HasStaminaToUseSkill( signSkill, false ) )
  12880. {
  12881. if( GetInvalidUniqueId() != inv.GetItemFromSlot( 'l_weapon' ) )
  12882. PushCombatActionOnBuffer( EBAT_CastSign, BS_Pressed );
  12883. else
  12884. SetupCombatAction( EBAT_CastSign, BS_Pressed );
  12885. }
  12886. else
  12887. {
  12888. thePlayer.SoundEvent("gui_no_stamina");
  12889. }
  12890. return;
  12891. }
  12892. break;
  12893. case PATR_ThrowBomb:
  12894. if ( inv.IsItemBomb ( selectedItemId ) )
  12895. {
  12896. if ( currentlyUsedItemL )
  12897. {
  12898. inv.UnmountItem( currentlyEquipedItemL, true );
  12899. }
  12900. currentlyEquipedItemL = GetInvalidUniqueId();
  12901. PrepareToAttack();
  12902. SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  12903. return;
  12904. }
  12905. break;
  12906. case PATR_CallHorse:
  12907. theGame.OnSpawnPlayerHorse();
  12908. break;
  12909. default:
  12910. if ( currentlyUsedItemL )
  12911. {
  12912. inv.UnmountItem( currentlyEquipedItemL, true );
  12913. }
  12914. currentlyEquipedItemL = GetInvalidUniqueId();
  12915. return;
  12916. }
  12917. if ( currentlyUsedItemL )
  12918. {
  12919. inv.UnmountItem( currentlyEquipedItemL, true );
  12920. }
  12921. currentlyEquipedItemL = GetInvalidUniqueId();
  12922. }
  12923.  
  12924. function GetUsableItemLtransitionAllowed () : bool
  12925. {
  12926. return isUsableItemLtransitionAllowed;
  12927. }
  12928.  
  12929. function SetUsableItemLtransitionAllowed ( isAllowed : bool)
  12930. {
  12931. isUsableItemLtransitionAllowed = isAllowed;
  12932. }
  12933.  
  12934. event OnItemUseLUnBlocked ()
  12935. {
  12936. if ( isUsableItemBlocked )
  12937. {
  12938. isUsableItemBlocked = false;
  12939. UnblockSlotsOnLItemUse ();
  12940. }
  12941. }
  12942.  
  12943. event OnItemUseLBlocked ()
  12944. {
  12945. if ( !isUsableItemBlocked )
  12946. {
  12947. isUsableItemBlocked = true;
  12948. BlockSlotsOnLItemUse ();
  12949. }
  12950. }
  12951.  
  12952. event OnUsingItemsReset()
  12953. {
  12954. if ( currentlyUsingItem )
  12955. {
  12956. OnItemUseLUnBlocked ();
  12957. OnUsingItemsComplete();
  12958. }
  12959. }
  12960. event OnUsingItemsComplete ()
  12961. {
  12962. if ( isUsableItemBlocked )
  12963. {
  12964. OnItemUseLUnBlocked ();
  12965. }
  12966. currentlyUsingItem = false;
  12967. if ( GetUsableItemLtransitionAllowed () )
  12968. {
  12969. ProcessUsableItemsTransition( playerActionToRestore );
  12970. }
  12971. else
  12972. {
  12973. if ( currentlyUsedItemL )
  12974. {
  12975. inv.UnmountItem( currentlyEquipedItemL, true );
  12976. }
  12977. currentlyEquipedItemL = GetInvalidUniqueId();
  12978. }
  12979.  
  12980. SetPlayerActionToRestore ( PATR_Default );
  12981. }
  12982.  
  12983. event OnUseSelectedItem( optional force : bool )
  12984. {
  12985. var category : name;
  12986. var itemEntity : W3UsableItem;
  12987.  
  12988. if ( isUsableItemBlocked && !force )
  12989. {
  12990. return false;
  12991. }
  12992. if ( IsCastingSign() )
  12993. return false;
  12994.  
  12995. if ( currentlyEquipedItemL != GetInvalidUniqueId() )
  12996. {
  12997. SetBehaviorVariable( 'SelectedItemL', (int)GetUsableItemTypeById( currentlyEquipedItemL ), true );
  12998. if ( force )
  12999. {
  13000. if ( RaiseEvent( 'ItemEndL' ) )
  13001. {
  13002. SetUsableItemLtransitionAllowed ( true );
  13003. return true;
  13004. }
  13005. }
  13006. else
  13007. {
  13008. if ( RaiseEvent( 'ItemUseL' ) )
  13009. {
  13010. SetUsableItemLtransitionAllowed ( true );
  13011. return true;
  13012. }
  13013. }
  13014. }
  13015. else
  13016. {
  13017. category = inv.GetItemCategory( selectedItemId );
  13018. if( category != 'usable' )
  13019. {
  13020. return false;
  13021. }
  13022. SetBehaviorVariable( 'SelectedItemL', (int)GetUsableItemTypeById( selectedItemId ), true );
  13023. if( RaiseEvent( 'ItemUseL' ) )
  13024. {
  13025. currentlyEquipedItemL = selectedItemId;
  13026. SetUsableItemLtransitionAllowed ( false );
  13027. currentlyUsingItem = true;
  13028.  
  13029. return true;
  13030. }
  13031. inv.UnmountItem( selectedItemId, true );
  13032. }
  13033. }
  13034.  
  13035. protected saved var currentlyUsingItem : bool;
  13036.  
  13037. public function ProcessUseSelectedItem( itemEntity : W3UsableItem, optional shouldCallOnUsed : bool )
  13038. {
  13039. currentlyUsedItemL = itemEntity;
  13040. DrainStamina(ESAT_UsableItem);
  13041.  
  13042. if ( shouldCallOnUsed )
  13043. {
  13044. currentlyUsedItemL.OnUsed( thePlayer );
  13045. }
  13046. }
  13047.  
  13048. function GetUsableItemTypeById ( itemId : SItemUniqueId ) : EUsableItemType
  13049. {
  13050. var itemName : name;
  13051.  
  13052. itemName = inv.GetItemName ( itemId );
  13053.  
  13054. return theGame.GetDefinitionsManager().GetUsableItemType ( itemName );
  13055.  
  13056. }
  13057.  
  13058.  
  13059. public function StartWaitForItemSpawnAndProccesTask()
  13060. {
  13061. AddTimer( 'WaitForItemSpawnAndProccesTask', 0.001f, true,,,,true );
  13062. }
  13063.  
  13064.  
  13065. public function KillWaitForItemSpawnAndProccesTask()
  13066. {
  13067. RemoveTimer ( 'WaitForItemSpawnAndProccesTask' );
  13068. }
  13069.  
  13070.  
  13071.  
  13072. public function AllowUseSelectedItem()
  13073. {
  13074. m_useSelectedItemIfSpawned = true;
  13075. }
  13076.  
  13077.  
  13078.  
  13079. timer function WaitForItemSpawnAndProccesTask( timeDelta : float , id : int )
  13080. {
  13081. var itemEntity : W3UsableItem;
  13082. var canTaskBeKilled : bool;
  13083. canTaskBeKilled = false;
  13084.  
  13085. if ( IsCastingSign() )
  13086. {
  13087. return;
  13088. }
  13089.  
  13090.  
  13091. if ( selectedItemId == GetInvalidUniqueId() )
  13092. {
  13093. canTaskBeKilled = true;
  13094. }
  13095.  
  13096. itemEntity = (W3UsableItem)inv.GetItemEntityUnsafe( selectedItemId );
  13097. if ( itemEntity && m_useSelectedItemIfSpawned )
  13098. {
  13099.  
  13100. canTaskBeKilled = true;
  13101. m_useSelectedItemIfSpawned = false;
  13102. ProcessUseSelectedItem( itemEntity, true );
  13103. }
  13104.  
  13105. if ( canTaskBeKilled )
  13106. {
  13107. KillWaitForItemSpawnAndProccesTask();
  13108. }
  13109. }
  13110.  
  13111. event OnBombProjectileReleased()
  13112. {
  13113. ResetRawPlayerHeading();
  13114. UnblockAction(EIAB_ThrowBomb, 'BombThrow');
  13115. UnblockAction(EIAB_Crossbow, 'BombThrow');
  13116.  
  13117. if(GetCurrentStateName() == 'AimThrow')
  13118. PopState();
  13119.  
  13120. FactsAdd("ach_bomb", 1, 4 );
  13121. theGame.GetGamerProfile().CheckLearningTheRopes();
  13122. }
  13123.  
  13124. public function SetIsThrowingItemWithAim(b : bool)
  13125. {
  13126. isThrowingItemWithAim = b;
  13127. }
  13128.  
  13129. public function SetIsThrowingItem( flag : bool ) {isThrowingItem = flag;}
  13130. public function IsThrowingItem() : bool {return isThrowingItem;}
  13131. public function IsThrowingItemWithAim() : bool {return isThrowingItemWithAim;}
  13132. public function SetThrowHold(b : bool) {isThrowHoldPressed = b;}
  13133. public function IsThrowHold() : bool {return isThrowHoldPressed;}
  13134. public function SetIsAimingCrossbow( flag : bool ) {isAimingCrossbow = flag;}
  13135. public function GetIsAimingCrossbow() : bool {return isAimingCrossbow;}
  13136.  
  13137. event OnThrowAnimLeave()
  13138. {
  13139. var throwStage : EThrowStage;
  13140. var thrownEntity : CThrowable;
  13141.  
  13142. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  13143.  
  13144. if(thrownEntity && !thrownEntity.WasThrown())
  13145. {
  13146. throwStage = (int)GetBehaviorVariable( 'throwStage', (int)TS_Stop);
  13147. if(inv.IsItemBomb(selectedItemId))
  13148. {
  13149. BombThrowCleanUp();
  13150. }
  13151. else
  13152. {
  13153. ThrowingAbort();
  13154. }
  13155. }
  13156.  
  13157. thrownEntity = NULL;
  13158. SetIsThrowingItem( false );
  13159. SetIsThrowingItemWithAim( false );
  13160.  
  13161. this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
  13162. UnblockAction(EIAB_ThrowBomb, 'BombThrow');
  13163. UnblockAction(EIAB_Crossbow, 'BombThrow');
  13164. }
  13165.  
  13166.  
  13167. protected function BombThrowStart()
  13168. {
  13169. var slideTargetActor : CActor;
  13170.  
  13171. BlockAction( EIAB_ThrowBomb, 'BombThrow' );
  13172. BlockAction(EIAB_Crossbow, 'BombThrow');
  13173.  
  13174. SetBehaviorVariable( 'throwStage', (int)TS_Start );
  13175. SetBehaviorVariable( 'combatActionType', (int)CAT_ItemThrow );
  13176.  
  13177. if ( slideTarget )
  13178. {
  13179. AddCustomOrientationTarget( OT_Actor, 'BombThrow' );
  13180.  
  13181. slideTargetActor = (CActor)( slideTarget );
  13182.  
  13183.  
  13184.  
  13185.  
  13186.  
  13187. }
  13188. else
  13189. {
  13190. if ( lastAxisInputIsMovement )
  13191. AddCustomOrientationTarget( OT_Actor, 'BombThrow' );
  13192. else
  13193. AddCustomOrientationTarget( OT_Camera, 'BombThrow' );
  13194. }
  13195.  
  13196. UpdateLookAtTarget();
  13197. SetCustomRotation( 'Throw', VecHeading( this.GetLookAtPosition() - GetWorldPosition() ), 0.0f, 0.3f, false );
  13198.  
  13199. SetBehaviorVariable( 'itemType', (int)IT_Petard );
  13200.  
  13201. ProcessCanAttackWhenNotInCombatBomb();
  13202.  
  13203. if ( RaiseForceEvent('CombatAction') )
  13204. OnCombatActionStart();
  13205.  
  13206.  
  13207. theTelemetry.LogWithLabel(TE_FIGHT_HERO_THROWS_BOMB, inv.GetItemName( selectedItemId ));
  13208. }
  13209.  
  13210.  
  13211. event OnThrowAnimStart()
  13212. {
  13213. var itemId : SItemUniqueId;
  13214. var thrownEntity : CThrowable;
  13215.  
  13216. this.radialSlots.Clear();
  13217. GetWitcherPlayer().GetItemEquippedOnSlot(EES_Petard1, itemId );
  13218.  
  13219. if( GetSelectedItemId() == itemId )
  13220. {
  13221. this.radialSlots.PushBack( 'Slot2' );
  13222. }
  13223. else
  13224. {
  13225. this.radialSlots.PushBack( 'Slot1' );
  13226. }
  13227. this.radialSlots.PushBack( 'Slot3' );
  13228. this.radialSlots.PushBack( 'Slot4' );
  13229. this.radialSlots.PushBack( 'Slot5' );
  13230. this.EnableRadialSlotsWithSource( false, this.radialSlots, 'throwBomb' );
  13231.  
  13232. thrownEntity = (CThrowable)inv.GetDeploymentItemEntity( selectedItemId,,,true );
  13233. thrownEntity.Initialize( this, selectedItemId );
  13234. EntityHandleSet( thrownEntityHandle, thrownEntity );
  13235. SetIsThrowingItem( true );
  13236. }
  13237.  
  13238. public function BombThrowAbort()
  13239. {
  13240. BombThrowCleanUp();
  13241. UnblockAction( EIAB_ThrowBomb, 'BombThrow' );
  13242. UnblockAction(EIAB_Crossbow, 'BombThrow');
  13243. }
  13244.  
  13245. private function BombThrowCleanUp()
  13246. {
  13247. var throwStage : EThrowStage;
  13248. var thrownEntity : CThrowable;
  13249. var vehicle : CVehicleComponent;
  13250.  
  13251. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  13252.  
  13253. this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
  13254. throwStage = (int)GetBehaviorVariable( 'throwStage', (int)TS_Stop);
  13255.  
  13256. SetBehaviorVariable( 'throwStage', (int)TS_Stop );
  13257.  
  13258. if( GetCurrentStateName() == 'AimThrow')
  13259. {
  13260. PopState();
  13261. thrownEntity.StopAiming( true );
  13262. }
  13263. else if ( this.IsUsingHorse() )
  13264. {
  13265. vehicle = (CVehicleComponent)(GetUsedVehicle().GetComponentByClassName('CVehicleComponent'));
  13266. vehicle.GetUserCombatManager().OnForceItemActionAbort();
  13267. }
  13268.  
  13269.  
  13270. if(thrownEntity && !thrownEntity.WasThrown())
  13271. {
  13272. thrownEntity.BreakAttachment();
  13273. thrownEntity.Destroy();
  13274. }
  13275.  
  13276. thrownEntity = NULL;
  13277. SetIsThrowingItem( false );
  13278. SetIsThrowingItemWithAim( false );
  13279. RemoveCustomOrientationTarget( 'BombThrow' );
  13280. }
  13281.  
  13282. public function ProcessCanAttackWhenNotInCombatBomb()
  13283. {
  13284. var targets : array< CGameplayEntity >;
  13285. var temp, throwVector, throwFrom, throwTo, throwVectorU : Vector;
  13286. var temp_n : name;
  13287. var throwVecLen : float;
  13288. var component : CComponent;
  13289.  
  13290.  
  13291.  
  13292. if( FactsQuerySum( "BombThrowSpecificTargets" ) > 0 )
  13293. {
  13294.  
  13295.  
  13296.  
  13297.  
  13298.  
  13299. throwFrom = playerAiming.GetThrowStartPosition();
  13300. throwTo = playerAiming.GetThrowPosition();
  13301. throwVector = throwTo - throwFrom;
  13302. throwVecLen = VecDistance( throwFrom, throwTo );
  13303. throwVectorU = throwVector / throwVecLen;
  13304. if( theGame.GetWorld().StaticTraceWithAdditionalInfo( throwFrom, throwTo + throwVectorU, temp, temp, temp_n, component ) && component && component.GetEntity().HasTag( 'BombThrowSpecificTarget' ) )
  13305. {
  13306. SetIsShootingFriendly( false );
  13307. }
  13308. else
  13309. {
  13310. SetIsShootingFriendly( true );
  13311. }
  13312. }
  13313. else if( FactsQuerySum( "BombThrowDisallowSpecificTargets" ) > 0 )
  13314. {
  13315.  
  13316. throwFrom = playerAiming.GetThrowStartPosition();
  13317. throwTo = playerAiming.GetThrowPosition();
  13318. throwVector = throwTo - throwFrom;
  13319. throwVecLen = VecDistance( throwFrom, throwTo );
  13320. throwVectorU = throwVector / throwVecLen;
  13321. if( theGame.GetWorld().StaticTraceWithAdditionalInfo( throwFrom, throwTo + throwVectorU, temp, temp, temp_n, component ) && component && component.GetEntity().HasTag( 'BombThrowDisallowedTarget' ) )
  13322. {
  13323. SetIsShootingFriendly( true );
  13324. }
  13325. else
  13326. {
  13327. SetIsShootingFriendly( false );
  13328. }
  13329. }
  13330. else
  13331. {
  13332. SetIsShootingFriendly( false );
  13333. }
  13334.  
  13335. SetBehaviorVariable( 'isShootingFriendly', (float)( GetIsShootingFriendly() ) );
  13336. }
  13337.  
  13338. public function SetIsShootingFriendly( flag : bool )
  13339. {
  13340. isShootingFriendly = flag;
  13341. }
  13342.  
  13343. public function GetIsShootingFriendly() : bool
  13344. {
  13345. return isShootingFriendly;
  13346. }
  13347.  
  13348.  
  13349. protected function UsableItemStart()
  13350. {
  13351. var thrownEntity : CThrowable;
  13352.  
  13353.  
  13354. thrownEntity = (CThrowable)inv.GetDeploymentItemEntity( selectedItemId,,,true );
  13355. thrownEntity.Initialize( this, selectedItemId );
  13356. EntityHandleSet( thrownEntityHandle, thrownEntity );
  13357. SetBehaviorVariable( 'throwStage', (int)TS_Start );
  13358. SetIsThrowingItem( true );
  13359. SetBehaviorVariable( 'combatActionType', (int)CAT_ItemThrow );
  13360.  
  13361. if ( slideTarget )
  13362. {
  13363. AddCustomOrientationTarget( OT_Actor, 'UsableItems' );
  13364. }
  13365. else
  13366. {
  13367. if ( lastAxisInputIsMovement )
  13368. AddCustomOrientationTarget( OT_Actor, 'UsableItems' );
  13369. else
  13370. AddCustomOrientationTarget( OT_Camera, 'UsableItems' );
  13371. }
  13372.  
  13373. SetBehaviorVariable( 'itemType', (int)(-1) );
  13374.  
  13375. if ( RaiseForceEvent('CombatAction') )
  13376. OnCombatActionStart();
  13377. }
  13378.  
  13379. protected function BombThrowRelease()
  13380. {
  13381. var stateName : name;
  13382.  
  13383. stateName = playerAiming.GetCurrentStateName();
  13384. OnDelayOrientationChangeOff();
  13385.  
  13386. if( GetIsShootingFriendly() || ( FactsQuerySum( "BombThrowSpecificTargets" ) > 0 && stateName != 'Aiming' ) )
  13387. {
  13388. BombThrowAbort();
  13389. }
  13390. else
  13391. {
  13392. SetBehaviorVariable( 'throwStage', (int)TS_End );
  13393.  
  13394. if ( stateName == 'Aiming' )
  13395. {
  13396. SetCustomRotation( 'Throw', VecHeading( this.GetLookAtPosition() - GetWorldPosition() ), 0.0f, 0.2f, false );
  13397. }
  13398. }
  13399. }
  13400.  
  13401. protected function UsableItemRelease()
  13402. {
  13403. OnDelayOrientationChangeOff();
  13404. SetBehaviorVariable( 'throwStage', (int)TS_End );
  13405. RemoveCustomOrientationTarget( 'UsableItems' );
  13406. }
  13407.  
  13408.  
  13409. public function ThrowingAbort()
  13410. {
  13411. var thrownEntity : CThrowable;
  13412.  
  13413. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  13414.  
  13415. SetBehaviorVariable( 'throwStage', (int)TS_Stop );
  13416. RaiseEvent( 'actionStop' );
  13417.  
  13418. if( GetCurrentStateName() == 'AimThrow')
  13419. {
  13420. PopState();
  13421. thrownEntity.StopAiming( true );
  13422. }
  13423.  
  13424.  
  13425. if(thrownEntity && !thrownEntity.WasThrown())
  13426. {
  13427. thrownEntity.BreakAttachment();
  13428. thrownEntity.Destroy();
  13429. }
  13430. this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
  13431. }
  13432.  
  13433. public function CanSetupCombatAction_Throw() : bool
  13434. {
  13435.  
  13436. if(!inv.IsIdValid( selectedItemId ))
  13437. return false;
  13438.  
  13439.  
  13440. if(!inv.IsItemSingletonItem(selectedItemId))
  13441. return false;
  13442.  
  13443.  
  13444. if(!GetBIsInputAllowed())
  13445. return false;
  13446.  
  13447.  
  13448. if(inv.GetItemQuantity(GetSelectedItemId()) <= 0 && !inv.ItemHasTag(selectedItemId, theGame.params.TAG_INFINITE_AMMO))
  13449. return false;
  13450.  
  13451.  
  13452. if(!inputHandler.IsActionAllowed(EIAB_ThrowBomb) && GetCurrentStateName() != 'Swimming')
  13453. return false;
  13454.  
  13455. return true;
  13456. }
  13457.  
  13458. public function GetThrownEntity() : CThrowable
  13459. {
  13460. return (CThrowable)EntityHandleGet( thrownEntityHandle );
  13461. }
  13462.  
  13463.  
  13464. event OnWeaponWait() { rangedWeapon.OnWeaponWait(); }
  13465. event OnWeaponDrawStart() { rangedWeapon.OnWeaponDrawStart(); }
  13466. event OnWeaponReloadStart() { rangedWeapon.OnWeaponReloadStart(); }
  13467. event OnWeaponReloadEnd() { rangedWeapon.OnWeaponReloadEnd(); }
  13468. event OnWeaponAimStart() { rangedWeapon.OnWeaponAimStart(); }
  13469. event OnWeaponShootStart() { rangedWeapon.OnWeaponShootStart(); }
  13470. event OnWeaponShootEnd() { rangedWeapon.OnWeaponShootEnd(); }
  13471. event OnWeaponAimEnd() { rangedWeapon.OnWeaponAimEnd(); }
  13472. event OnWeaponHolsterStart() { rangedWeapon.OnWeaponHolsterStart(); }
  13473. event OnWeaponHolsterEnd() { rangedWeapon.OnWeaponHolsterEnd(); }
  13474. event OnWeaponToNormalTransStart() { rangedWeapon.OnWeaponToNormalTransStart(); }
  13475. event OnWeaponToNormalTransEnd() { rangedWeapon.OnWeaponToNormalTransEnd(); }
  13476.  
  13477. event OnEnableAimingMode( enable : bool )
  13478. {
  13479. if( !crossbowDontPopStateHack )
  13480. {
  13481. if ( enable )
  13482. PushState( 'AimThrow' );
  13483. else if ( GetCurrentStateName() == 'AimThrow' )
  13484. PopState();
  13485. }
  13486. }
  13487.  
  13488. event OnRangedForceHolster( optional forceUpperBodyAnim, instant, dropItem : bool )
  13489. {
  13490. if(rangedWeapon)
  13491. rangedWeapon.OnForceHolster( forceUpperBodyAnim, instant, dropItem );
  13492. }
  13493.  
  13494.  
  13495. public function IsCrossbowHeld() : bool
  13496. {
  13497. if (rangedWeapon)
  13498. return rangedWeapon.GetCurrentStateName() != 'State_WeaponWait';
  13499. return false;
  13500. }
  13501.  
  13502.  
  13503. event OnBlockAllCombatTickets( release : bool )
  13504. {
  13505. if (!release )
  13506. ((CR4PlayerStateCombat)GetState('Combat')).OnBlockAllCombatTickets(false);
  13507. }
  13508. event OnForceTicketUpdate() {}
  13509.  
  13510.  
  13511.  
  13512.  
  13513.  
  13514. event OnProcessActionPost(action : W3DamageAction)
  13515. {
  13516. var npc : CNewNPC;
  13517. var attackAction : W3Action_Attack;
  13518. var lifeLeech : float;
  13519.  
  13520. super.OnProcessActionPost(action);
  13521.  
  13522. attackAction = (W3Action_Attack)action;
  13523.  
  13524. if(attackAction)
  13525. {
  13526. npc = (CNewNPC)action.victim;
  13527.  
  13528. if(npc && npc.IsHuman() )
  13529. {
  13530. PlayBattleCry('BattleCryHumansHit', 0.05f );
  13531. }
  13532. else
  13533. {
  13534. PlayBattleCry('BattleCryMonstersHit', 0.05f );
  13535. }
  13536.  
  13537. if(attackAction.IsActionMelee())
  13538. {
  13539.  
  13540. IncreaseUninterruptedHitsCount();
  13541.  
  13542.  
  13543. if( IsLightAttack( attackAction.GetAttackName() ) )
  13544. {
  13545. GCameraShake(0.1, false, GetWorldPosition(), 10);
  13546. }
  13547.  
  13548.  
  13549. if(npc && inv.GetItemName(attackAction.GetWeaponId()) == 'PC Caretaker Shovel')
  13550. {
  13551.  
  13552. lifeLeech = CalculateAttributeValue(inv.GetItemAttributeValue(attackAction.GetWeaponId() ,'lifesteal'));
  13553. if (npc.UsesVitality())
  13554. lifeLeech *= action.processedDmg.vitalityDamage;
  13555. else if (UsesEssence())
  13556. lifeLeech *= action.processedDmg.essenceDamage;
  13557. else
  13558. lifeLeech = 0;
  13559.  
  13560. if ( lifeLeech > 0 )
  13561. {
  13562. inv.PlayItemEffect( attackAction.GetWeaponId(), 'stab_attack' );
  13563. PlayEffect('drain_energy_caretaker_shovel');
  13564. GainStat(BCS_Vitality, lifeLeech);
  13565. }
  13566. }
  13567. }
  13568. }
  13569. }
  13570.  
  13571. public function SetHitReactTransScale(f : float) {hitReactTransScale = f;}
  13572. public function GetHitReactTransScale() : float
  13573. {
  13574. if ( ( (CNewNPC)slideTarget ).GetIsTranslationScaled() )
  13575. return hitReactTransScale;
  13576. else
  13577. return 1.f;
  13578. }
  13579.  
  13580.  
  13581.  
  13582.  
  13583.  
  13584. public function GetHorseWithInventory() : CNewNPC
  13585. {
  13586. return (CNewNPC)EntityHandleGet( horseWithInventory );
  13587. }
  13588. public function GetHorseCurrentlyMounted() : CNewNPC
  13589. {
  13590. return currentlyMountedHorse;
  13591. }
  13592.  
  13593. public function _SetHorseCurrentlyMounted( horse : CNewNPC )
  13594. {
  13595. currentlyMountedHorse = horse;
  13596. }
  13597.  
  13598. public function WasHorseRecentlySummoned() : bool
  13599. {
  13600. if ( horseSummonTimeStamp + 5.f > theGame.GetEngineTimeAsSeconds() )
  13601. return true;
  13602.  
  13603. return false;
  13604. }
  13605.  
  13606. private const var MOUNT_DISTANCE_CBT : float;
  13607. default MOUNT_DISTANCE_CBT = 3.0;
  13608.  
  13609. private const var MOUNT_ANGLE_CBT : float;
  13610. default MOUNT_ANGLE_CBT = 35.0;
  13611.  
  13612. private const var MOUNT_ANGLE_EXP : float;
  13613. default MOUNT_ANGLE_EXP = 45.0;
  13614.  
  13615. public function IsMountingHorseAllowed( optional alwaysAllowedInExploration : bool ) : bool
  13616. {
  13617. var angle : float;
  13618. var distance : float;
  13619.  
  13620. if( IsInsideHorseInteraction() )
  13621. {
  13622. angle = AngleDistance( thePlayer.rawPlayerHeading, VecHeading( thePlayer.horseInteractionSource.GetWorldPosition() - thePlayer.GetWorldPosition() ) );
  13623.  
  13624. if( thePlayer.IsInCombat() )
  13625. {
  13626. if( AbsF( angle ) < MOUNT_ANGLE_CBT )
  13627. {
  13628. distance = VecDistance( thePlayer.GetWorldPosition(), thePlayer.horseInteractionSource.GetWorldPosition() );
  13629.  
  13630. if( distance < MOUNT_DISTANCE_CBT )
  13631. {
  13632. return true;
  13633. }
  13634. else
  13635. {
  13636. return false;
  13637. }
  13638. }
  13639. else
  13640. {
  13641. return false;
  13642. }
  13643.  
  13644. }
  13645. else
  13646. {
  13647. if( alwaysAllowedInExploration )
  13648. {
  13649. return true;
  13650. }
  13651. else
  13652. {
  13653. if( AbsF( angle ) < MOUNT_ANGLE_EXP )
  13654. {
  13655. return true;
  13656. }
  13657. else
  13658. {
  13659. return false;
  13660. }
  13661. }
  13662. }
  13663. }
  13664. else
  13665. {
  13666. return false;
  13667. }
  13668. }
  13669.  
  13670. public function FollowActor( actor : CActor )
  13671. {
  13672. var l_aiTreeDecorator : CAIPlayerActionDecorator;
  13673. var l_aiTree_onFoot : CAIFollowSideBySideAction;
  13674. var l_aiTree_onHorse : CAIRiderFollowSideBySideAction;
  13675. var l_success : bool = false;
  13676.  
  13677. actor.AddTag( 'playerFollowing' );
  13678.  
  13679. if( thePlayer.IsUsingHorse() )
  13680. {
  13681. l_aiTree_onHorse = new CAIRiderFollowSideBySideAction in this;
  13682. l_aiTree_onHorse.OnCreated();
  13683.  
  13684. l_aiTree_onHorse.params.targetTag = 'playerFollowing';
  13685. }
  13686. else
  13687. {
  13688. l_aiTree_onFoot = new CAIFollowSideBySideAction in this;
  13689. l_aiTree_onFoot.OnCreated();
  13690.  
  13691. l_aiTree_onFoot.params.targetTag = 'playerFollowing';
  13692. }
  13693.  
  13694. l_aiTreeDecorator = new CAIPlayerActionDecorator in this;
  13695. l_aiTreeDecorator.OnCreated();
  13696. l_aiTreeDecorator.interruptOnInput = false;
  13697.  
  13698. if( thePlayer.IsUsingHorse() )
  13699. l_aiTreeDecorator.scriptedAction = l_aiTree_onHorse;
  13700. else
  13701. l_aiTreeDecorator.scriptedAction = l_aiTree_onFoot;
  13702.  
  13703. if( l_aiTreeDecorator )
  13704. l_success = ForceAIBehavior( l_aiTreeDecorator, BTAP_Emergency );
  13705. else if( thePlayer.IsUsingHorse() )
  13706. l_success = ForceAIBehavior( l_aiTree_onHorse, BTAP_Emergency );
  13707. else
  13708. l_success = ForceAIBehavior( l_aiTree_onFoot, BTAP_Emergency );
  13709.  
  13710. if ( l_success )
  13711. {
  13712. GetMovingAgentComponent().SetGameplayRelativeMoveSpeed( 0.0f );
  13713. }
  13714. }
  13715.  
  13716. public function SetCanFollowNpc( val : bool, actor : CActor ) { canFollowNpc = val; actorToFollow = actor; }
  13717. public function CanFollowNpc() : bool { return canFollowNpc; }
  13718. public function GetActorToFollow() : CActor { return actorToFollow; }
  13719.  
  13720.  
  13721.  
  13722.  
  13723.  
  13724.  
  13725.  
  13726. public function SetIsSwimming ( toggle : bool )
  13727. {
  13728. if( isSwimming != toggle )
  13729. {
  13730. thePlayer.substateManager.SetBehaviorParamBool( 'isSwimmingForOverlay', toggle );
  13731. isSwimming = toggle;
  13732. }
  13733. }
  13734.  
  13735.  
  13736.  
  13737.  
  13738.  
  13739.  
  13740.  
  13741. public function RepairItemUsingConsumable(item, consumable : SItemUniqueId) : bool
  13742. {
  13743. var curr, max, repairValue, itemValue, repairBonus, newDurability : float;
  13744.  
  13745.  
  13746. if(!inv.IsIdValid(item) || !inv.IsIdValid(consumable) || !inv.HasItemDurability(item))
  13747. return false;
  13748.  
  13749. curr = inv.GetItemDurability(item);
  13750. max = inv.GetItemMaxDurability(item);
  13751.  
  13752.  
  13753. if(curr > max)
  13754. return false;
  13755.  
  13756.  
  13757. if( (inv.IsItemAnyArmor(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_ARMOR)) ||
  13758. (inv.IsItemSilverSwordUsableByPlayer(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_SILVER)) ||
  13759. (inv.IsItemSteelSwordUsableByPlayer(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_STEEL)) )
  13760. {
  13761.  
  13762. itemValue = CalculateAttributeValue(inv.GetItemAttributeValue(consumable, 'durabilityRepairValue'));
  13763. if(itemValue <= 0)
  13764. {
  13765. LogAssert(false, "CR4Player.RepairItemUsingConsumable: consumable <<" + inv.GetItemName(consumable) + ">> has <=0 durabilityRepairValue!!!");
  13766. return false;
  13767. }
  13768. repairBonus = CalculateAttributeValue(inv.GetItemAttributeValue(consumable, 'durabilityBonusValue'));
  13769.  
  13770.  
  13771. repairValue = max * itemValue /100;
  13772.  
  13773.  
  13774.  
  13775. newDurability = MinF(max, curr + repairValue);
  13776.  
  13777. inv.SetItemDurabilityScript(item, newDurability);
  13778.  
  13779.  
  13780. inv.RemoveItem(consumable);
  13781.  
  13782. return true;
  13783. }
  13784. return false;
  13785. }
  13786.  
  13787.  
  13788.  
  13789.  
  13790.  
  13791.  
  13792.  
  13793.  
  13794.  
  13795.  
  13796. private function CheckDayNightCycle()
  13797. {
  13798. var time : GameTime;
  13799. var isNight : bool;
  13800.  
  13801.  
  13802. isNight = theGame.envMgr.IsNight();
  13803. if(prevDayNightIsNight != isNight)
  13804. {
  13805. if(isNight)
  13806. OnNightStarted();
  13807. else
  13808. OnDayStarted();
  13809.  
  13810. prevDayNightIsNight = isNight;
  13811. }
  13812.  
  13813.  
  13814. if(isNight)
  13815. time = theGame.envMgr.GetGameTimeTillNextDay();
  13816. else
  13817. time = theGame.envMgr.GetGameTimeTillNextNight();
  13818.  
  13819. AddGameTimeTimer('DayNightCycle', time);
  13820. }
  13821.  
  13822. timer function DayNightCycle(dt : GameTime, id : int)
  13823. {
  13824. CheckDayNightCycle();
  13825. }
  13826.  
  13827. event OnNightStarted()
  13828. {
  13829. var pam : W3PlayerAbilityManager;
  13830.  
  13831. if(CanUseSkill(S_Perk_01))
  13832. {
  13833. pam = (W3PlayerAbilityManager)abilityManager;
  13834. pam.SetPerk01Abilities(false, true);
  13835. }
  13836. }
  13837.  
  13838. event OnDayStarted()
  13839. {
  13840. var pam : W3PlayerAbilityManager;
  13841.  
  13842. if(CanUseSkill(S_Perk_01))
  13843. {
  13844. pam = (W3PlayerAbilityManager)abilityManager;
  13845. pam.SetPerk01Abilities(true, false);
  13846. }
  13847. }
  13848.  
  13849.  
  13850.  
  13851.  
  13852.  
  13853. public function ForceUnlockAllInputActions(alsoQuestLocks : bool)
  13854. {
  13855. if ( inputHandler )
  13856. inputHandler.ForceUnlockAllInputActions(alsoQuestLocks);
  13857. }
  13858.  
  13859. public function SetPrevRawLeftJoyRot()
  13860. {
  13861. prevRawLeftJoyRot = rawLeftJoyRot;
  13862. }
  13863.  
  13864. public function GetPrevRawLeftJoyRot() : float
  13865. {
  13866. return prevRawLeftJoyRot;
  13867. }
  13868.  
  13869. public function GetExplorationInputContext() : name
  13870. {
  13871. return explorationInputContext;
  13872. }
  13873.  
  13874. public function GetCombatInputContext() : name
  13875. {
  13876. return combatInputContext;
  13877. }
  13878.  
  13879.  
  13880.  
  13881.  
  13882.  
  13883. public function SetIsOnBoat(b : bool)
  13884. {
  13885. isOnBoat = b;
  13886. }
  13887.  
  13888. public function IsOnBoat() : bool
  13889. {
  13890. return isOnBoat;
  13891. }
  13892.  
  13893. public function IsInShallowWater() : bool
  13894. {
  13895. return isInShallowWater;
  13896. }
  13897.  
  13898. event OnEnterShallowWater()
  13899. {
  13900. if ( isInShallowWater )
  13901. return false;
  13902.  
  13903. isInShallowWater = true;
  13904. BlockAction( EIAB_Dodge,'ShallowWater', false, false, true );
  13905. BlockAction( EIAB_Sprint,'ShallowWater', false, false, true );
  13906. BlockAction( EIAB_Crossbow,'ShallowWater', false, false, true );
  13907. BlockAction( EIAB_Jump,'ShallowWater', false, false, true );
  13908. SetBehaviorVariable( 'shallowWater',1.0);
  13909. }
  13910. event OnExitShallowWater()
  13911. {
  13912. if ( !isInShallowWater )
  13913. return false;
  13914.  
  13915. isInShallowWater = false;
  13916. BlockAllActions('ShallowWater',false);
  13917. SetBehaviorVariable( 'shallowWater',0.0);
  13918. }
  13919.  
  13920. public function TestIsInSettlement() : bool
  13921. {
  13922. return IsInSettlement();
  13923. }
  13924.  
  13925.  
  13926.  
  13927.  
  13928.  
  13929.  
  13930. public function ProcessGlossaryImageOverride( defaultImage : string, uniqueTag : name ) : string
  13931. {
  13932. var size : int;
  13933. var i : int;
  13934.  
  13935. size = glossaryImageOverride.Size();
  13936.  
  13937. if( size == 0 )
  13938. return defaultImage;
  13939.  
  13940. for( i = 0; i < size; i += 1 )
  13941. {
  13942. if( glossaryImageOverride[i].uniqueTag == uniqueTag )
  13943. return glossaryImageOverride[i].imageFileName;
  13944.  
  13945. }
  13946.  
  13947. return defaultImage;
  13948. }
  13949.  
  13950.  
  13951. public function EnableGlossaryImageOverride( uniqueTag : name, imageFileName : string, enable : bool )
  13952. {
  13953. var imageData : SGlossaryImageOverride;
  13954. var size : int;
  13955. var i : int;
  13956.  
  13957. for( i = 0; i < glossaryImageOverride.Size(); i += 1 )
  13958. {
  13959. if( glossaryImageOverride[i].uniqueTag == uniqueTag )
  13960. {
  13961. glossaryImageOverride.Remove(glossaryImageOverride[i]);
  13962. }
  13963. }
  13964.  
  13965. if( enable )
  13966. {
  13967. if( IsNameValid(uniqueTag) && imageFileName != "" )
  13968. {
  13969. glossaryImageOverride.PushBack( SGlossaryImageOverride( uniqueTag, imageFileName ) );
  13970. }
  13971. }
  13972. }
  13973.  
  13974.  
  13975.  
  13976. public function SetWeatherDisplayDisabled( disable : bool )
  13977. {
  13978. disableWeatherDisplay = disable;
  13979. }
  13980.  
  13981. public function GetWeatherDisplayDisabled() : bool
  13982. {
  13983. return disableWeatherDisplay;
  13984. }
  13985.  
  13986.  
  13987.  
  13988.  
  13989.  
  13990. public function SetCurrentMonsterHuntInvestigationArea ( area : W3MonsterHuntInvestigationArea )
  13991. {
  13992. currentMonsterHuntInvestigationArea = area;
  13993. }
  13994.  
  13995.  
  13996.  
  13997.  
  13998.  
  13999.  
  14000. public function RememberCustomHead( headName : name )
  14001. {
  14002. rememberedCustomHead = headName;
  14003. }
  14004.  
  14005. public function GetRememberedCustomHead() : name
  14006. {
  14007. return rememberedCustomHead;
  14008. }
  14009.  
  14010. public function ClearRememberedCustomHead()
  14011. {
  14012. rememberedCustomHead = '';
  14013. }
  14014.  
  14015.  
  14016.  
  14017.  
  14018.  
  14019. public function CreateTutorialInput()
  14020. {
  14021. var prevInputHandler : CPlayerInput;
  14022.  
  14023. prevInputHandler = inputHandler;
  14024. inputHandler = new W3PlayerTutorialInput in this;
  14025. inputHandler.Initialize(false, prevInputHandler);
  14026.  
  14027. if(prevInputHandler)
  14028. delete prevInputHandler;
  14029. }
  14030.  
  14031. public function CreateInput()
  14032. {
  14033. var oldInputHandler : CPlayerInput;
  14034.  
  14035. oldInputHandler = inputHandler;
  14036. inputHandler = new CPlayerInput in this;
  14037. inputHandler.Initialize(false, oldInputHandler);
  14038. }
  14039.  
  14040. timer function TutorialSilverCombat(dt : float, id : int)
  14041. {
  14042. var i : int;
  14043. var actors : array<CActor>;
  14044.  
  14045. if(IsInCombat())
  14046. {
  14047. actors = GetNPCsAndPlayersInRange(20, 1000000, ,FLAG_ExcludePlayer + FLAG_OnlyAliveActors);
  14048. for(i=0; i<actors.Size(); i+=1)
  14049. {
  14050. if(actors[i] && IsRequiredAttitudeBetween(this, actors[i], true) && actors[i].UsesEssence())
  14051. {
  14052. FactsAdd("TutorialShowSilver");
  14053.  
  14054. RemoveTimer('TutorialSilverCombat');
  14055. break;
  14056. }
  14057. }
  14058. }
  14059. }
  14060.  
  14061. private saved var m_bossTag : name;
  14062.  
  14063. public function GetBossTag() : name
  14064. {
  14065. return m_bossTag;
  14066. }
  14067.  
  14068. public function SetBossTag( bossTag : name )
  14069. {
  14070. m_bossTag = bossTag;
  14071. }
  14072.  
  14073. private saved var m_usingCoatOfArms : bool; default m_usingCoatOfArms = false;
  14074.  
  14075. public function IsUsingCoatOfArms() : bool
  14076. {
  14077. return m_usingCoatOfArms;
  14078. }
  14079.  
  14080. public function SetUsingCoatOfArms( using : bool)
  14081. {
  14082. m_usingCoatOfArms = using;
  14083. }
  14084.  
  14085. private saved var m_initialTimeOut : float;
  14086. private saved var m_currentTimeOut : float;
  14087.  
  14088. public function GetInitialTimeOut() : float
  14089. {
  14090. return m_initialTimeOut;
  14091. }
  14092.  
  14093. public function SetInitialTimeOut( timeOut : float )
  14094. {
  14095. m_initialTimeOut = timeOut;
  14096. }
  14097.  
  14098. public function GetCurrentTimeOut() : float
  14099. {
  14100. return m_currentTimeOut;
  14101. }
  14102.  
  14103. public function SetCurrentTimeOut( timeOut : float )
  14104. {
  14105. m_currentTimeOut = timeOut;
  14106. }
  14107.  
  14108.  
  14109.  
  14110.  
  14111.  
  14112.  
  14113. timer function DelayedFinisherInputTimer(dt : float, id : int)
  14114. {
  14115.  
  14116.  
  14117. }
  14118.  
  14119. timer function RemoveFinisherCameraAnimationCheck(dt : float, id : int)
  14120. {
  14121. if ( !isInFinisher && !bLAxisReleased )
  14122. {
  14123. theGame.GetSyncAnimManager().OnRemoveFinisherCameraAnimation();
  14124. RemoveTimer( 'RemoveFinisherCameraAnimationCheck' );
  14125. }
  14126. }
  14127.  
  14128.  
  14129.  
  14130.  
  14131.  
  14132. timer function GameplayFactRemove(dt : float, timerId : int)
  14133. {
  14134. theGame.GameplayFactRemoveFromTimer(timerId);
  14135. }
  14136.  
  14137.  
  14138. timer function GiveStartingItems(dt : float, timerId : int)
  14139. {
  14140. var template : CEntityTemplate;
  14141. var invEntity : CInventoryComponent;
  14142. var entity : CEntity;
  14143. var items : array<SItemUniqueId>;
  14144. var id : SItemUniqueId;
  14145. var i : int;
  14146.  
  14147.  
  14148. if(inv)
  14149. {
  14150. inv.GetAllItems(items);
  14151. if(items.Size() <= 0)
  14152. {
  14153. return;
  14154. }
  14155. }
  14156. else
  14157. {
  14158. return;
  14159. }
  14160.  
  14161.  
  14162. template = (CEntityTemplate)LoadResource("geralt_inventory_release");
  14163. entity = theGame.CreateEntity(template, Vector(0,0,0));
  14164. invEntity = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  14165.  
  14166. invEntity.GetAllItems(items);
  14167. for(i=0; i<items.Size(); i+=1)
  14168. {
  14169. id = invEntity.GiveItemTo(inv, items[i], 0, false, true);
  14170. if ( inv.ItemHasTag(id,'Scabbard') )
  14171. {
  14172. inv.MountItem(id);
  14173. }
  14174. else if(!inv.IsItemFists(id) && inv.GetItemName(id) != 'Cat 1')
  14175. {
  14176. EquipItem(id);
  14177. }
  14178. else if(inv.IsItemSingletonItem(id))
  14179. {
  14180. inv.SingletonItemSetAmmo(id, inv.SingletonItemGetMaxAmmo(id));
  14181. }
  14182. }
  14183.  
  14184. entity.Destroy();
  14185.  
  14186.  
  14187. RemoveTimer('GiveStartingItems');
  14188. }
  14189.  
  14190.  
  14191.  
  14192. timer function Debug_GiveTestingItems(dt : float, optional id : int)
  14193. {
  14194. var template : CEntityTemplate;
  14195. var invTesting : CInventoryComponent;
  14196. var entity : CEntity;
  14197. var items : array<SItemUniqueId>;
  14198. var i : int;
  14199. var slot : EEquipmentSlots;
  14200.  
  14201.  
  14202. if(inv)
  14203. {
  14204. inv.GetAllItems(items);
  14205. if(items.Size() <= 0)
  14206. {
  14207. return;
  14208. }
  14209. }
  14210. else
  14211. {
  14212. return;
  14213. }
  14214.  
  14215. template = (CEntityTemplate)LoadResource("geralt_inventory_internal");
  14216. entity = theGame.CreateEntity(template, Vector(0,0,0));
  14217. invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  14218. invTesting.GiveAllItemsTo(inv, true);
  14219. entity.Destroy();
  14220.  
  14221.  
  14222. RemoveTimer('Debug_GiveTestingItems');
  14223.  
  14224.  
  14225. inv.GetAllItems(items);
  14226.  
  14227. for(i=0; i<items.Size(); i+=1)
  14228. {
  14229. if( inv.IsItemCrossbow(items[i]) || inv.IsItemBomb(items[i]) )
  14230. {
  14231. slot = inv.GetSlotForItemId(items[i]);
  14232. EquipItem(items[i], slot);
  14233.  
  14234. if( (W3PlayerWitcher)this && inv.IsItemCrossbow(items[i]) )
  14235. GetWitcherPlayer().SelectQuickslotItem(slot);
  14236. }
  14237. else if(inv.IsItemBolt(items[i]))
  14238. {
  14239. slot = inv.GetSlotForItemId(items[i]);
  14240. EquipItem(items[i], slot);
  14241. }
  14242.  
  14243. if(inv.IsItemSingletonItem(items[i]))
  14244. {
  14245. inv.SingletonItemSetAmmo(items[i], inv.SingletonItemGetMaxAmmo(items[i]));
  14246. }
  14247. }
  14248. }
  14249.  
  14250.  
  14251. timer function Debug_RemoveTestingItems(dt : float, id : int)
  14252. {
  14253. var template : CEntityTemplate;
  14254. var entity : CEntity;
  14255. var invTesting : CInventoryComponent;
  14256. var ids : array<SItemUniqueId>;
  14257. var i : int;
  14258.  
  14259. template = (CEntityTemplate)LoadResource("geralt_inventory_internal");
  14260. entity = theGame.CreateEntity(template, Vector(0,0,0));
  14261. invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  14262. invTesting.GetAllItems(ids);
  14263.  
  14264. for(i=0; i<ids.Size(); i+=1)
  14265. inv.RemoveItemByName(invTesting.GetItemName(ids[i]), invTesting.GetItemQuantity(ids[i]));
  14266.  
  14267. entity.Destroy();
  14268. RemoveTimer('Debug_RemoveTestingItems');
  14269. }
  14270.  
  14271. timer function Debug_DelayedConsoleCommand(dt : float, id : int)
  14272. {
  14273.  
  14274. inv.AddAnItem('Boots 2 schematic');
  14275. }
  14276.  
  14277. function DBG_SkillSlots()
  14278. {
  14279. ((W3PlayerAbilityManager)abilityManager).DBG_SkillSlots();
  14280. }
  14281.  
  14282.  
  14283.  
  14284.  
  14285.  
  14286. public final function SetPadBacklightColor(r, g, b : int)
  14287. {
  14288. var padBacklightColor : Vector;
  14289.  
  14290. padBacklightColor.X = r / 255;
  14291. padBacklightColor.Y = g / 255;
  14292. padBacklightColor.Z = b / 255;
  14293.  
  14294. SetBacklightColor(padBacklightColor);
  14295. }
  14296.  
  14297. public final function SetPadBacklightColorFromSign(signType : ESignType)
  14298. {
  14299. LogPS4Light("SetPadBacklightColorFromSign... " + signType);
  14300.  
  14301. switch(signType)
  14302. {
  14303. case ST_Yrden: SetPadBacklightColor( 200 , 81 , 255 ); break;
  14304. case ST_Quen: SetPadBacklightColor( 255 , 205 , 68 ); break;
  14305. case ST_Igni: SetPadBacklightColor( 255 , 79 , 10 ); break;
  14306. case ST_Axii: SetPadBacklightColor( 255 , 255 , 255 ); break;
  14307. case ST_Aard: SetPadBacklightColor( 158 , 214 , 255 ); break;
  14308. }
  14309. }
  14310.  
  14311. timer function ResetPadBacklightColorTimer(dt : float, id : int)
  14312. {
  14313. ResetPadBacklightColor();
  14314. }
  14315.  
  14316. public final function ResetPadBacklightColor(optional skipHeldWeapon : bool)
  14317. {
  14318. var weapons : array<SItemUniqueId>;
  14319. var sword : CWitcherSword;
  14320. var healthPercentage : float;
  14321. var tmpBacklight : Vector;
  14322.  
  14323. if(!skipHeldWeapon)
  14324. {
  14325. weapons = inv.GetHeldWeapons();
  14326.  
  14327.  
  14328. if(weapons.Size() > 0)
  14329. {
  14330. sword = (CWitcherSword)inv.GetItemEntityUnsafe(weapons[0]);
  14331. if(sword)
  14332. {
  14333. tmpBacklight.X = sword.padBacklightColor.X / 255.0f;
  14334. tmpBacklight.Y = sword.padBacklightColor.Y / 255.0f;
  14335. tmpBacklight.Z = sword.padBacklightColor.Z / 255.0f;
  14336. tmpBacklight.W = 1.0f;
  14337. SetBacklightColor( tmpBacklight );
  14338. LogPS4Light("Setting light from sword template: " + NoTrailZeros(sword.padBacklightColor.X) + ", " + NoTrailZeros(sword.padBacklightColor.Y) + ", " + NoTrailZeros(sword.padBacklightColor.Z) );
  14339. return;
  14340. }
  14341. }
  14342. }
  14343.  
  14344. healthPercentage = GetStatPercents( BCS_Vitality );
  14345. SetBacklightFromHealth( healthPercentage );
  14346. LogPS4Light("Setting light from health, " + NoTrailZeros(RoundMath(healthPercentage*100)) + "%");
  14347. }
  14348.  
  14349.  
  14350.  
  14351. event OnOpenningDoor()
  14352. {
  14353. if( !thePlayer.IsUsingHorse() )
  14354. RaiseEvent('OpenDoor');
  14355. }
  14356.  
  14357. public final function SetLoopingCameraShakeAnimName( n : name )
  14358. {
  14359. loopingCameraShakeAnimName = n;
  14360. }
  14361.  
  14362. public var loopingCameraShakeAnimName : name;
  14363. timer function RemoveQuestCameraShakeTimer( dt : float , id : int)
  14364. {
  14365. RemoveQuestCameraShake( loopingCameraShakeAnimName );
  14366. }
  14367.  
  14368. public function RemoveQuestCameraShake( animName : name )
  14369. {
  14370. var camera : CCustomCamera = theGame.GetGameCamera();
  14371. var animation : SCameraAnimationDefinition;
  14372.  
  14373. camera.StopAnimation( animName );
  14374. }
  14375.  
  14376. public function GetCameraPadding() : float
  14377. {
  14378. if( theGame.IsFocusModeActive() )
  14379. {
  14380. return 0.25;
  14381. }
  14382. else
  14383. {
  14384. return 0.02f;
  14385. }
  14386. }
  14387.  
  14388. public function IsPerformingPhaseChangeAnimation() : bool { return isPerformingPhaseChangeAnimation; }
  14389. public function SetIsPerformingPhaseChangeAnimation( val : bool ) { isPerformingPhaseChangeAnimation = val; }
  14390.  
  14391. private function DealCounterDamageToOlgierd()
  14392. {
  14393. var damage : W3DamageAction;
  14394.  
  14395. damage = new W3DamageAction in this;
  14396.  
  14397. damage.Initialize( thePlayer.GetTarget(), thePlayer.GetTarget(), NULL, this, EHRT_None, CPS_Undefined, false, false, false, true );
  14398. damage.AddDamage( theGame.params.DAMAGE_NAME_DIRECT, thePlayer.GetTarget().GetStatMax( BCS_Vitality ) * 3 / 100 );
  14399. theGame.damageMgr.ProcessAction( damage );
  14400.  
  14401. delete damage;
  14402. }
  14403.  
  14404. timer function PlayDelayedCounterDamageEffect( dt : float, id : int )
  14405. {
  14406. thePlayer.GetTarget().PlayEffect( 'olgierd_energy_blast' );
  14407. }
  14408.  
  14409.  
  14410. public function SetTestAdjustRequestedMovementDirection( val : bool )
  14411. {
  14412. testAdjustRequestedMovementDirection = val;
  14413. }
  14414.  
  14415. event OnVisualDebug( frame : CScriptedRenderFrame, flag : EShowFlags )
  14416. {
  14417. var boneFollow : int;
  14418. var bonePosition : Vector;
  14419. var yrdenEntity : W3YrdenEntity;
  14420.  
  14421. substateManager.OnVisualDebug( frame, flag );
  14422.  
  14423. boneFollow = thePlayer.GetBoneIndex( 'Reference' );
  14424. bonePosition = MatrixGetTranslation( thePlayer.GetBoneWorldMatrixByIndex( boneFollow ) );
  14425. frame.DrawText( "R", bonePosition, Color( 50, 200, 70 ) );
  14426.  
  14427.  
  14428. boneFollow = thePlayer.GetBoneIndex( 'Trajectory' );
  14429. bonePosition = MatrixGetTranslation( thePlayer.GetBoneWorldMatrixByIndex( boneFollow ) );
  14430. frame.DrawSphere( bonePosition, 0.1f, Color( 200, 50, 70 ) );
  14431. frame.DrawText( "T", bonePosition, Color( 200, 50, 70 ) );
  14432.  
  14433.  
  14434.  
  14435.  
  14436. yrdenEntity = (W3YrdenEntity)GetWitcherPlayer().GetSignEntity(ST_Yrden);
  14437. yrdenEntity.OnVisualDebug(frame, flag, false);
  14438.  
  14439. return true;
  14440. }
  14441.  
  14442. timer function PotDrinkTimer(dt : float, id : int)
  14443. {
  14444. inputHandler.PotDrinkTimer(false);
  14445. }
  14446.  
  14447. public function SetIsHorseRacing( val : bool )
  14448. {
  14449. isHorseRacing = val;
  14450. }
  14451.  
  14452. public function GetIsHorseRacing() : bool
  14453. {
  14454. return isHorseRacing;
  14455. }
  14456.  
  14457. public function SetHorseCombatSlowMo( val : bool )
  14458. {
  14459. horseCombatSlowMo = val;
  14460. }
  14461.  
  14462. public function GetHorseCombatSlowMo() : bool
  14463. {
  14464. return horseCombatSlowMo;
  14465. }
  14466.  
  14467. public function SetItemsPerLevelGiven( id : int )
  14468. {
  14469. itemsPerLevelGiven[id] = true;
  14470. }
  14471.  
  14472. private function AddItemPerLevelList()
  14473. {
  14474. var i : int;
  14475.  
  14476. itemsPerLevel.Clear();
  14477. itemsPerLevel.PushBack('O');
  14478. itemsPerLevel.PushBack('No Mans Land sword 2');
  14479. itemsPerLevel.PushBack('No Mans Land sword 3');
  14480. itemsPerLevel.PushBack('Silver sword 2');
  14481. itemsPerLevel.PushBack('Boots 01');
  14482. itemsPerLevel.PushBack('Novigraadan sword 2');
  14483. itemsPerLevel.PushBack('Light armor 01');
  14484. itemsPerLevel.PushBack('Heavy boots 01');
  14485. itemsPerLevel.PushBack('Nilfgaardian sword 3');
  14486. itemsPerLevel.PushBack('Silver sword 3');
  14487. itemsPerLevel.PushBack('Heavy gloves 01');
  14488. itemsPerLevel.PushBack('Skellige sword 2');
  14489. itemsPerLevel.PushBack('Heavy pants 01');
  14490. itemsPerLevel.PushBack('Silver sword 4');
  14491. itemsPerLevel.PushBack('No Mans Land sword 4');
  14492. itemsPerLevel.PushBack('Heavy armor 01');
  14493. itemsPerLevel.PushBack('Heavy boots 02');
  14494. itemsPerLevel.PushBack('Skellige sword 3');
  14495. itemsPerLevel.PushBack('Silver sword 5');
  14496. itemsPerLevel.PushBack('Heavy pants 02');
  14497. itemsPerLevel.PushBack('Heavy gloves 02');
  14498. itemsPerLevel.PushBack('Heavy gloves 02');
  14499. itemsPerLevel.PushBack('Heavy armor 02');
  14500. itemsPerLevel.PushBack('Scoiatael sword 1');
  14501.  
  14502. if ( itemsPerLevelGiven.Size() < 49 )
  14503. {
  14504. itemsPerLevelGiven.Clear();
  14505. for (i = 0; i < itemsPerLevel.Size(); i += 1) { itemsPerLevelGiven.PushBack( false ); }
  14506. }
  14507. }
  14508.  
  14509.  
  14510. public function DealDamageToBoat( dmg : float, index : int, optional globalHitPos : Vector )
  14511. {
  14512. var boat : CBoatDestructionComponent;
  14513.  
  14514. if(usedVehicle)
  14515. {
  14516. boat = (CBoatDestructionComponent) usedVehicle.GetComponentByClassName( 'CBoatDestructionComponent' );
  14517. if( boat )
  14518. {
  14519. boat.DealDamage( dmg, index, globalHitPos );
  14520. }
  14521. }
  14522. }
  14523.  
  14524.  
  14525.  
  14526.  
  14527.  
  14528. public function OnStartTeleportingPlayerToPlayableArea()
  14529. {
  14530. var FADEOUT_INTERVAL : float = 0.5;
  14531.  
  14532.  
  14533. if ( thePlayer.IsUsingHorse() )
  14534. {
  14535. if ( thePlayer.GetUsedHorseComponent().OnCheckHorseJump() )
  14536. {
  14537. thePlayer.GetUsedHorseComponent().SetCanTakeDamageFromFalling( false );
  14538. }
  14539. }
  14540.  
  14541. if ( thePlayer.IsActionAllowed( EIAB_FastTravel ) )
  14542. {
  14543. OnOpenMapToLetPlayerGoBackToPlayableArea();
  14544. }
  14545. else
  14546. {
  14547. theGame.FadeOutAsync( FADEOUT_INTERVAL );
  14548. thePlayer.AddTimer( 'BorderTeleportFadeOutTimer', FADEOUT_INTERVAL, false );
  14549. }
  14550. }
  14551.  
  14552. timer function BorderTeleportFadeOutTimer( dt : float, id : int )
  14553. {
  14554. OnTeleportPlayerToPlayableArea( false );
  14555. }
  14556.  
  14557. public function OnOpenMapToLetPlayerGoBackToPlayableArea()
  14558. {
  14559. var initData : W3MapInitData;
  14560.  
  14561. initData = new W3MapInitData in this;
  14562. initData.SetTriggeredExitEntity( true );
  14563. initData.ignoreSaveSystem = true;
  14564. initData.setDefaultState('FastTravel');
  14565. theGame.RequestMenuWithBackground( 'MapMenu', 'CommonMenu', initData );
  14566. }
  14567.  
  14568. public function OnTeleportPlayerToPlayableArea( afterClosingMap : bool )
  14569. {
  14570. var BLACKSCREEN_INTERVAL : float = 0.1;
  14571. var manager : CCommonMapManager = theGame.GetCommonMapManager();
  14572.  
  14573. thePlayer.TeleportWithRotation( manager.GetBorderTeleportPosition(), manager.GetBorderTeleportRotation() );
  14574. thePlayer.AddTimer( 'BorderTeleportFadeInTimer', BLACKSCREEN_INTERVAL, false );
  14575.  
  14576. theGame.FadeOutAsync( 0 );
  14577. theGame.SetFadeLock('PlayerTeleportation');
  14578. }
  14579.  
  14580. timer function BorderTeleportFadeInTimer( dt : float, id : int )
  14581. {
  14582. theGame.ResetFadeLock('PlayerTeleportation');
  14583. theGame.FadeOutAsync( 0 );
  14584. theGame.FadeInAsync( 2.0f );
  14585. }
  14586.  
  14587. public final function SetLastInstantKillTime(g : GameTime)
  14588. {
  14589. lastInstantKillTime = g;
  14590. }
  14591.  
  14592.  
  14593.  
  14594.  
  14595.  
  14596. timer function TestTimer(dt : float, id : int )
  14597. {
  14598. LogChannel('asdf', "asdf");
  14599. theGame.FadeOutAsync( 5 );
  14600. }
  14601.  
  14602. public final function Debug_ReleaseCriticalStateSaveLocks()
  14603. {
  14604. effectManager.Debug_ReleaseCriticalStateSaveLocks();
  14605. }
  14606.  
  14607. timer function Debug_SpamSpeed(dt : float, id : int)
  14608. {
  14609. if(currentlyMountedHorse)
  14610. {
  14611. LogSpeed("curr player's horse speed: " + NoTrailZeros(currentlyMountedHorse.GetMovingAgentComponent().GetSpeed())) ;
  14612. }
  14613. else
  14614. {
  14615. LogSpeed("curr player speed: " + NoTrailZeros(GetMovingAgentComponent().GetSpeed())) ;
  14616. }
  14617. }
  14618.  
  14619. timer function RemoveInstantKillSloMo(dt : float, id : int)
  14620. {
  14621. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_InstantKill) );
  14622. }
  14623.  
  14624. timer function RemoveForceFinisher(dt : float, id : int)
  14625. {
  14626. forceFinisher = false;
  14627. }
  14628.  
  14629. public final function Debug_ClearAllActionLocks(optional action : EInputActionBlock, optional all : bool)
  14630. {
  14631. inputHandler.Debug_ClearAllActionLocks(action, all);
  14632. }
  14633.  
  14634. function OnFocusedCameraBlendBegin() {}
  14635. function OnFocusedCameraBlendUpdate( progress : float ) {}
  14636. function OnFocusedCameraBlendEnd() {}
  14637.  
  14638. public function GetEtherealCount() : int { return etherealCount; }
  14639. public function IncrementEtherealCount()
  14640. {
  14641. etherealCount += 1;
  14642. if( etherealCount == 6 )
  14643. ResetEtherealCount();
  14644. }
  14645. public function ResetEtherealCount() { etherealCount = 0; }
  14646.  
  14647. public function SetInsideDiveAttackArea( val : bool ) { insideDiveAttackArea = val; }
  14648. public function IsInsideDiveAttackArea() : bool { return insideDiveAttackArea; }
  14649. public function SetDiveAreaNumber( val : int ) { diveAreaNumber = val; }
  14650. public function GetDiveAreaNumber() : int { return diveAreaNumber; }
  14651.  
  14652.  
  14653.  
  14654. public function InitPhantomWeaponMgr()
  14655. {
  14656. if( !phantomWeaponMgr )
  14657. {
  14658. phantomWeaponMgr = new CPhantomWeaponManager in this;
  14659. phantomWeaponMgr.Init( this.GetInventory() );
  14660. }
  14661. }
  14662.  
  14663. public function DestroyPhantomWeaponMgr()
  14664. {
  14665. if( phantomWeaponMgr )
  14666. {
  14667. delete phantomWeaponMgr;
  14668. }
  14669. }
  14670.  
  14671. public function GetPhantomWeaponMgr() : CPhantomWeaponManager
  14672. {
  14673. if( phantomWeaponMgr )
  14674. {
  14675. return phantomWeaponMgr;
  14676. }
  14677. else
  14678. {
  14679. return NULL;
  14680. }
  14681. }
  14682.  
  14683. public timer function DischargeWeaponAfter( td : float, id : int )
  14684. {
  14685. GetPhantomWeaponMgr().DischargeWeapon();
  14686. }
  14687.  
  14688.  
  14689.  
  14690.  
  14691. private var forcedFinisherVictim : CActor;
  14692.  
  14693. timer function PerformFinisher( time : float , id : int )
  14694. {
  14695. var combatTarget : CActor;
  14696. var i : int;
  14697.  
  14698. combatTarget = thePlayer.GetTarget();
  14699.  
  14700. if( combatTarget )
  14701. {
  14702. combatTarget.Kill( 'AutoFinisher', false, thePlayer );
  14703. thePlayer.SetFinisherVictim( combatTarget );
  14704. forcedFinisherVictim = combatTarget;
  14705. thePlayer.CleanCombatActionBuffer();
  14706. thePlayer.OnBlockAllCombatTickets( true );
  14707. moveTargets = thePlayer.GetMoveTargets();
  14708.  
  14709. for( i = 0; i < moveTargets.Size(); i += 1 )
  14710. {
  14711. if( combatTarget != moveTargets[i] )
  14712. moveTargets[i].SignalGameplayEvent( 'InterruptChargeAttack' );
  14713. }
  14714.  
  14715. if( theGame.GetInGameConfigWrapper().GetVarValue( 'Gameplay', 'AutomaticFinishersEnabled' ) == "true" )
  14716. combatTarget.AddAbility( 'ForceFinisher', false );
  14717.  
  14718. if( combatTarget.HasTag( 'ForceFinisher' ) )
  14719. combatTarget.AddAbility( 'ForceFinisher', false );
  14720.  
  14721. combatTarget.SignalGameplayEvent( 'ForceFinisher' );
  14722.  
  14723. thePlayer.FindMoveTarget();
  14724.  
  14725. thePlayer.AddTimer( 'SignalFinisher', 0.2, false );
  14726. }
  14727. }
  14728.  
  14729. timer function SignalFinisher( time : float , id : int )
  14730. {
  14731. forcedFinisherVictim.SignalGameplayEvent( 'Finisher' );
  14732. forcedFinisherVictim = NULL;
  14733. }
  14734. }
  14735.  
  14736. exec function ttt()
  14737. {
  14738. thePlayer.AddTimer( 'TestTimer', 5, false );
  14739. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement