Guest User

Untitled

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