Guest User

Untitled

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