Guest User

r4Player.ws

a guest
Sep 1st, 2021
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 403.97 KB | None | 0 0
  1. /***********************************************************************/
  2. /** © 2015 CD PROJEKT S.A. All rights reserved.
  3. /** THE WITCHER® is a trademark of CD PROJEKT S. A.
  4. /** The Witcher game is based on the prose of Andrzej Sapkowski.
  5. /***********************************************************************/
  6. statemachine abstract import class CR4Player extends CPlayer
  7. {
  8. //---=== modFriendlyHUD ===---
  9. public var fHUDConfig : CModFriendlyHUDConfig;
  10. public saved var newCraftables : array<name>;
  11. //---=== modFriendlyHUD ===---
  12.  
  13. protected var pcGamePlayInitialized : bool;
  14.  
  15.  
  16. private var pcMode : bool;
  17. default pcMode = true;
  18.  
  19.  
  20. protected saved var weaponHolster : WeaponHolster;
  21. public var rangedWeapon : Crossbow;
  22. public var crossbowDontPopStateHack : bool; default crossbowDontPopStateHack = false;
  23.  
  24. private var hitReactTransScale : float;
  25.  
  26. private var bIsCombatActionAllowed : bool;
  27. private var currentCombatAction : EBufferActionType;
  28.  
  29. private var uninterruptedHitsCount : int;
  30. private var uninterruptedHitsCameraStarted : bool;
  31. private var uninterruptedHitsCurrentCameraEffect : name;
  32.  
  33. private var counterTimestamps : array<EngineTime>;
  34.  
  35. private var hitReactionEffect : bool;
  36.  
  37. private var lookAtPosition : Vector;
  38. private var orientationTarget : EOrientationTarget;
  39. private var customOrientationTarget : EOrientationTarget;
  40. protected var customOrientationStack : array<SCustomOrientationParams>;
  41.  
  42. public var delayOrientationChange : bool;
  43. protected var delayCameraOrientationChange : bool;
  44. private var actionType : int;
  45. private var customOrientationStackIndex : int;
  46.  
  47. private var emptyMoveTargetTimer : float;
  48.  
  49. private var onlyOneEnemyLeft : bool;
  50.  
  51. public var isInFinisher : bool;
  52. private var finisherTarget : CGameplayEntity;
  53.  
  54. private var combatStance : EPlayerCombatStance;
  55.  
  56. public var approachAttack : int;
  57. default approachAttack = 1;
  58. protected var specialAttackCamera : bool;
  59.  
  60. private var specialAttackTimeRatio : float;
  61.  
  62. public saved var itemsPerLevel : array<name>;
  63. public var itemsPerLevelGiven : array<bool>;
  64.  
  65. private var playerTickTimerPhase : int;
  66. default playerTickTimerPhase = 0;
  67.  
  68. protected var evadeHeading : float;
  69.  
  70. public var vehicleCbtMgrAiming : bool;
  71.  
  72. public var specialHeavyChargeDuration : float;
  73. public var specialHeavyStartEngineTime : EngineTime;
  74. public var playedSpecialAttackMissingResourceSound : bool;
  75. public function SetPlayedSpecialAttackMissingResourceSound(b : bool) {playedSpecialAttackMissingResourceSound = b;}
  76.  
  77. public var counterCollisionGroupNames : array<name>;
  78.  
  79. public saved var lastInstantKillTime : GameTime;
  80.  
  81.  
  82. private var noSaveLockCombatActionName : string; default noSaveLockCombatActionName = 'combat_action';
  83. private var noSaveLockCombatAction : int;
  84. private var deathNoSaveLock : int;
  85. private var noSaveLock : int;
  86.  
  87.  
  88. protected saved var newGamePlusInitialized : bool;
  89. default newGamePlusInitialized = false;
  90.  
  91.  
  92. protected var BufferAllSteps : bool;
  93. protected var BufferCombatAction : EBufferActionType;
  94. protected var BufferButtonStage : EButtonStage;
  95.  
  96. default BufferAllSteps = false;
  97. default customOrientationTarget = OT_None;
  98. default hitReactionEffect = true;
  99. default uninterruptedHitsCount = 0;
  100. default uninterruptedHitsCameraStarted = false;
  101. default customOrientationStackIndex = -1;
  102.  
  103.  
  104. private var keepRequestingCriticalAnimStart : bool;
  105.  
  106. default keepRequestingCriticalAnimStart = false;
  107.  
  108.  
  109. private var currentCustomAction : EPlayerExplorationAction;
  110. public var substateManager : CExplorationStateManager;
  111. protected var isOnBoat : bool;
  112. protected var isInShallowWater : bool;
  113. public var medallion : W3MedallionFX;
  114. protected var lastMedallionEffect : float;
  115. private var isInRunAnimation : bool;
  116. public var interiorTracker :CPlayerInteriorTracker;
  117. public var m_SettlementBlockCanter : int;
  118.  
  119.  
  120.  
  121. private var fistFightMinigameEnabled : bool;
  122. private var isFFMinigameToTheDeath : bool;
  123. private var FFMinigameEndsithBS : bool;
  124. public var fistFightTeleportNode : CNode;
  125. public var isStartingFistFightMinigame : bool;
  126. public var GeraltMaxHealth : float;
  127. public var fistsItems : array< SItemUniqueId >;
  128.  
  129. default FFMinigameEndsithBS = false;
  130. default fistFightMinigameEnabled = false;
  131. default isFFMinigameToTheDeath = false;
  132.  
  133.  
  134. private var gwintAiDifficulty : EGwintDifficultyMode; default gwintAiDifficulty = EGDM_Easy;
  135. private var gwintAiAggression : EGwintAggressionMode; default gwintAiAggression = EGAM_Defensive;
  136. private var gwintMinigameState : EMinigameState; default gwintMinigameState = EMS_None;
  137.  
  138.  
  139. import private var horseWithInventory : EntityHandle;
  140. private var currentlyMountedHorse : CNewNPC;
  141. private var horseSummonTimeStamp : float;
  142. private saved var isHorseRacing : bool;
  143. private var horseCombatSlowMo : bool;
  144. default isHorseRacing = false;
  145. default horseCombatSlowMo = true;
  146.  
  147.  
  148. private var HudMessages : array <string>;
  149. protected var fShowToLowStaminaIndication : float;
  150. public var showTooLowAdrenaline : bool;
  151. private var HAXE3Container : W3Container;
  152. private var HAXE3bAutoLoot: bool;
  153. private var bShowHud : bool;
  154. private var dodgeFeedbackTarget : CActor;
  155.  
  156. default HAXE3bAutoLoot = false;
  157. default fShowToLowStaminaIndication = 0.0f;
  158. default bShowHud = true;
  159.  
  160. saved var displayedQuestsGUID : array< CGUID >;
  161. saved var rewardsMultiplier : array< SRewardMultiplier >;
  162. saved var glossaryImageOverride : array< SGlossaryImageOverride >;
  163.  
  164.  
  165. private var prevRawLeftJoyRot : float;
  166. protected var explorationInputContext : name;
  167. protected var combatInputContext : name;
  168. protected var combatFistsInputContext : name;
  169.  
  170.  
  171. private var isInsideInteraction : bool;
  172. private var isInsideHorseInteraction : bool;
  173. public var horseInteractionSource : CEntity;
  174. public var nearbyLockedContainersNoKey : array<W3LockableEntity>;
  175.  
  176.  
  177. private var bMoveTargetChangeAllowed : bool; default bMoveTargetChangeAllowed = true;
  178. private var moveAdj : CMovementAdjustor;
  179. private var defaultLocomotionController : CR4LocomotionPlayerControllerScript;
  180.  
  181.  
  182. private var canFollowNpc : bool;
  183. private var actorToFollow : CActor;
  184. public var terrainPitch : float;
  185. public var steepSlopeNormalPitch : float; default steepSlopeNormalPitch = 65.f;
  186. public var disableSprintTerrainPitch : float; default disableSprintTerrainPitch = 54.f;
  187.  
  188. private var submergeDepth : float;
  189.  
  190. private var m_useSelectedItemIfSpawned : bool; default m_useSelectedItemIfSpawned = false;
  191.  
  192.  
  193. var navQuery : CNavigationReachabilityQueryInterface;
  194.  
  195.  
  196. public saved var rememberedCustomHead : name;
  197.  
  198.  
  199. public saved var disableWeatherDisplay : bool;
  200.  
  201.  
  202. public saved var proudWalk : bool;
  203. private var etherealCount : int;
  204. default etherealCount = 0;
  205.  
  206.  
  207. public saved var injuredWalk : bool;
  208. public saved var tiedWalk : bool;
  209. private var insideDiveAttackArea : bool;
  210. default insideDiveAttackArea = false;
  211. private var diveAreaNumber : int;
  212. default diveAreaNumber = -1;
  213.  
  214.  
  215. private var flyingBossCamera : bool;
  216. default flyingBossCamera = false;
  217.  
  218. public function SetFlyingBossCamera( val : bool ) { flyingBossCamera = val; }
  219. public function GetFlyingBossCamera() : bool { return flyingBossCamera; }
  220.  
  221.  
  222. public saved var upscaledTooltipState : bool;
  223. default upscaledTooltipState = false;
  224.  
  225. private var phantomWeaponMgr : CPhantomWeaponManager;
  226.  
  227. // ImmersiveCam++
  228. public var ic : icControl;
  229. public editable var mMeditation : CMeditationUI;
  230. private var slowMoActive : bool;
  231. public var motionSicknessFocusMode : bool;
  232. public var runningLanding : float;
  233. public var sprintSpeed : float;
  234.  
  235. //( interactive camera controls )
  236. private saved var icOffsetAdj : float;
  237. private saved var icDepthAdj : float;
  238. private saved var icHeightAdj : float;
  239. public saved var icHBDepthAdj : float;
  240. public saved var icHBOffsetAdj : float;
  241. public saved var icHBHeightAdj : float;
  242. private saved var icComOffsetAdj : float;
  243. private saved var icComDepthAdj : float;
  244. private saved var icComHeightAdj : float;
  245.  
  246. //(headtracking controls)
  247. private var lookTarget : CActor;
  248. private var savedTarget : CActor;
  249. private var nextlooktime : float;
  250. private var nextchecktime : float;
  251. private var potentiallookattargets : array<CActor>;
  252.  
  253. // (camera control functions)
  254. private function DecreaseOffset() { icOffsetAdj -= 0.02; }
  255. private function IncreaseOffset() { icOffsetAdj += 0.02; }
  256. private function DecreaseDepth() { icDepthAdj -= 0.02; }
  257. private function IncreaseDepth() { icDepthAdj += 0.02; }
  258. private function DecreaseHeight() { icHeightAdj -= 0.02; }
  259. private function IncreaseHeight() { icHeightAdj += 0.02; }
  260. public function DecreaseHBOffset() { icHBOffsetAdj -= 0.01; }
  261. public function IncreaseHBOffset() { icHBOffsetAdj += 0.01; }
  262. public function DecreaseHBDepth() { icHBDepthAdj -= 0.01; }
  263. public function IncreaseHBDepth() { icHBDepthAdj += 0.01; }
  264. public function DecreaseHBHeight() { icHBHeightAdj -= 0.01; }
  265. public function IncreaseHBHeight() { icHBHeightAdj += 0.01; }
  266. private function DecreaseComOffset() { icComOffsetAdj -= 0.05; }
  267. private function IncreaseComOffset() { icComOffsetAdj += 0.05; }
  268. private function DecreaseComDepth() { icComDepthAdj -= 0.05; }
  269. private function IncreaseComDepth() { icComDepthAdj += 0.05; }
  270. private function DecreaseComHeight() { icComHeightAdj -= 0.05; }
  271. private function IncreaseComHeight() { icComHeightAdj += 0.05; }
  272.  
  273. public function ResetExpCam() { icOffsetAdj = 0; icDepthAdj = 0; icHeightAdj = 0;}
  274. public function ResetHBCam() { icHBOffsetAdj = 0; icHBDepthAdj = 0; icHBHeightAdj = 0;}
  275. public function ResetComCam() { icComOffsetAdj = 0; icComDepthAdj = 0; icComHeightAdj = 0;}
  276.  
  277. public function SetExpCam()
  278. {
  279. theGame.GetInGameConfigWrapper().SetVarValue( 'ImmersiveCamPositionsExploration', 'expOffset', FloatToString( ic.expOffset + icOffsetAdj ) );
  280. theGame.GetInGameConfigWrapper().SetVarValue( 'ImmersiveCamPositionsExploration', 'expDepth', FloatToString( ic.expDepth + icDepthAdj ) );
  281. theGame.GetInGameConfigWrapper().SetVarValue( 'ImmersiveCamPositionsExploration', 'expHeight', FloatToString( ic.expHeight + icHeightAdj ) );
  282. theGame.GetInGameConfigWrapper().SetVarValue( 'ImmersiveCamPositionsWS', 'eWSOffset', FloatToString( ic.eWSOffset + icOffsetAdj ) );
  283. theGame.GetInGameConfigWrapper().SetVarValue( 'ImmersiveCamPositionsWS', 'eWSDepth', FloatToString( ic.eWSDepth + icDepthAdj ) );
  284. theGame.GetInGameConfigWrapper().SetVarValue( 'ImmersiveCamPositionsWS', 'eWSHeight', FloatToString( ic.eWSHeight + icHeightAdj ) );
  285. theGame.GetGuiManager().GetInGameConfigBufferedWrapper().SetVarValue( 'ImmersiveCamPositionsExploration', 'expOffset', FloatToString( ic.expOffset + icOffsetAdj ) );
  286. theGame.GetGuiManager().GetInGameConfigBufferedWrapper().SetVarValue( 'ImmersiveCamPositionsExploration', 'expDepth', FloatToString( ic.expDepth + icDepthAdj ) );
  287. theGame.GetGuiManager().GetInGameConfigBufferedWrapper().SetVarValue( 'ImmersiveCamPositionsExploration', 'expHeight', FloatToString( ic.expHeight + icHeightAdj ) );
  288. theGame.GetGuiManager().GetInGameConfigBufferedWrapper().SetVarValue( 'ImmersiveCamPositionsWS', 'eWSOffset', FloatToString( ic.eWSOffset + icOffsetAdj ) );
  289. theGame.GetGuiManager().GetInGameConfigBufferedWrapper().SetVarValue( 'ImmersiveCamPositionsWS', 'eWSDepth', FloatToString( ic.eWSDepth + icDepthAdj ) );
  290. theGame.GetGuiManager().GetInGameConfigBufferedWrapper().SetVarValue( 'ImmersiveCamPositionsWS', 'eWSHeight', FloatToString( ic.eWSHeight + icHeightAdj ) );
  291.  
  292. ResetExpCam();
  293. ic.SetImmCamVars();
  294. thePlayer.DisplayHudMessage("default exploration camera position set");
  295. }
  296.  
  297. public function SetHBCam()
  298. {
  299. theGame.GetInGameConfigWrapper().SetVarValue( 'ImmersiveCamPositionsHorse', 'hbOffset', FloatToString( ic.hbOffset + icHBOffsetAdj ) );
  300. theGame.GetInGameConfigWrapper().SetVarValue( 'ImmersiveCamPositionsHorse', 'hbDepth', FloatToString( ic.hbDepth + icHBDepthAdj ) );
  301. theGame.GetInGameConfigWrapper().SetVarValue( 'ImmersiveCamPositionsHorse', 'hbHeight', FloatToString( ic.hbHeight + icHBHeightAdj ) );
  302. theGame.GetGuiManager().GetInGameConfigBufferedWrapper().SetVarValue( 'ImmersiveCamPositionsHorse', 'hbOffset', FloatToString( ic.hbOffset + icHBOffsetAdj ) );
  303. theGame.GetGuiManager().GetInGameConfigBufferedWrapper().SetVarValue( 'ImmersiveCamPositionsHorse', 'hbDepth', FloatToString( ic.hbDepth + icHBDepthAdj ) );
  304. theGame.GetGuiManager().GetInGameConfigBufferedWrapper().SetVarValue( 'ImmersiveCamPositionsHorse', 'hbHeight', FloatToString( ic.hbHeight + icHBHeightAdj ) );
  305.  
  306. ResetHBCam();
  307. ic.SetImmCamVars();
  308. thePlayer.DisplayHudMessage("default horseback camera position set");
  309. }
  310.  
  311. public function SetComCam()
  312. {
  313. theGame.GetInGameConfigWrapper().SetVarValue( 'ImmersiveCamPositionsCombat', 'comOffset', FloatToString( ic.comOffset + icComOffsetAdj ) );
  314. theGame.GetInGameConfigWrapper().SetVarValue( 'ImmersiveCamPositionsCombat', 'comDepth', FloatToString( ic.comDepth + icComDepthAdj ) );
  315. theGame.GetInGameConfigWrapper().SetVarValue( 'ImmersiveCamPositionsCombat', 'comHeight', FloatToString( ic.comHeight + icComHeightAdj ) );
  316. theGame.GetGuiManager().GetInGameConfigBufferedWrapper().SetVarValue( 'ImmersiveCamPositionsCombat', 'comOffset', FloatToString( ic.comOffset + icComOffsetAdj ) );
  317. theGame.GetGuiManager().GetInGameConfigBufferedWrapper().SetVarValue( 'ImmersiveCamPositionsCombat', 'comDepth', FloatToString( ic.comDepth + icComDepthAdj ) );
  318. theGame.GetGuiManager().GetInGameConfigBufferedWrapper().SetVarValue( 'ImmersiveCamPositionsCombat', 'comHeight', FloatToString( ic.comHeight + icComHeightAdj ) );
  319.  
  320. ResetComCam();
  321. ic.SetImmCamVars();
  322. thePlayer.DisplayHudMessage("default combat camera position set");
  323. }
  324.  
  325. timer function SetImmCamVars(dt : float, id : int)
  326. {
  327. ic.SetImmCamVars();
  328. }
  329.  
  330. public function EnableMotionSicknessFocusMode( active : bool )
  331. {
  332. motionSicknessFocusMode = active;
  333. }
  334.  
  335. // (meditation functions)
  336. public function getMeditation() : CMeditationUI
  337. {
  338. return this.mMeditation;
  339. }
  340.  
  341. public function setMeditation( mMeditation : CMeditationUI)
  342. {
  343. this.mMeditation = mMeditation;
  344. }
  345.  
  346. timer function BeginNewMeditation(dt : float, id : int)
  347. {
  348. this.mMeditation.NewMeditate();
  349. }
  350.  
  351. public function UpdateCameraMeditation( out moveData : SCameraMovementData, timeDelta : float )
  352. {
  353. theGame.GetGameCamera().ChangePivotRotationController( 'ExplorationInterior' );
  354. theGame.GetGameCamera().ChangePivotDistanceController( 'Default' );
  355. theGame.GetGameCamera().ChangePivotPositionController( 'Default' );
  356.  
  357. // HACK
  358. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  359. moveData.pivotDistanceController = theGame.GetGameCamera().GetActivePivotDistanceController();
  360. moveData.pivotPositionController = theGame.GetGameCamera().GetActivePivotPositionController();
  361. // END HACK
  362.  
  363. moveData.pivotPositionController.SetDesiredPosition( GetWorldPosition(), 15.f );
  364.  
  365. moveData.pivotDistanceController.SetDesiredDistance( 3.0 );
  366. moveData.pivotPositionController.offsetZ = 0.3f;
  367.  
  368. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( ic.medOffset , ic.medDepth, ic.medHeight ), 0.6, timeDelta );
  369. }
  370.  
  371. // (headtracking functions)
  372. public function ProcessHeadTracking()
  373. {
  374. var lookDistance : float;
  375. var i : int;
  376. var curtime : float;
  377. var npccount : int;
  378.  
  379. curtime = theGame.GetEngineTimeAsSeconds();
  380.  
  381. if ( !ic.headTracking )
  382. return;
  383.  
  384. if ( IsInInterior() )
  385. lookDistance = ic.intHTDis;
  386. else
  387. lookDistance = ic.extHTDis;
  388.  
  389. if( curtime > nextchecktime )
  390. {
  391. potentiallookattargets = GetActorsInRange(thePlayer, lookDistance, , ,0);
  392. for(i = 0; i < potentiallookattargets.Size(); i += 1)
  393. {
  394. if ( (CNewNPC)potentiallookattargets[i] )
  395. {
  396. lookTarget = potentiallookattargets[i];
  397. npccount = 1;
  398. break;
  399. }
  400. else
  401. npccount = 0;
  402. }
  403. if ( npccount )
  404. {
  405. if ( lookTarget != savedTarget )
  406. {
  407. ((CActor)thePlayer).DisableLookAt();
  408. ((CActor)thePlayer).EnableDynamicLookAt(lookTarget, 2.0);
  409. nextlooktime = theGame.GetEngineTimeAsSeconds() + 2.75;
  410. savedTarget = lookTarget;
  411. }
  412. else if( curtime >= nextlooktime)
  413. {
  414. ((CActor)thePlayer).DisableLookAt();
  415. ((CActor)thePlayer).EnableDynamicLookAt(lookTarget, 10.0);
  416. nextlooktime = theGame.GetEngineTimeAsSeconds() + 12.0;
  417. }
  418. }
  419. else
  420. nextchecktime = theGame.GetEngineTimeAsSeconds() + 0.1;
  421. }
  422.  
  423. }
  424.  
  425. public function DisableHeadTracking()
  426. {
  427. ((CActor)thePlayer).DisableLookAt();
  428. }
  429.  
  430. // (slow mo camera functions)
  431. public function SetSlowMoActive( active : bool )
  432. {
  433. slowMoActive = active;
  434. }
  435.  
  436. public function IsSlowMoActive() : bool
  437. {
  438. return slowMoActive;
  439. }
  440.  
  441. public timer function DeactivateSlowMoCam(dt : float, id : int)
  442. {
  443. ic.SlowMoController(false);
  444. slowMoActive = false;
  445. }
  446.  
  447. event OnStopTimeSlow(duration : float, id : Int32)
  448. {
  449. theGame.RemoveTimeScale(theGame.GetTimescaleSource(7));
  450. slowMoActive = false;
  451. }
  452.  
  453. // (immersive motion functions)
  454. private timer function DeactivateRunningLanding(dt: float, id: int)
  455. {
  456. runningLanding = 0;
  457. }
  458.  
  459. public function EnableRunningLanding(rlSpeed : float, time : float)
  460. {
  461. if( runningLanding == 0)
  462. {
  463. runningLanding = rlSpeed;
  464. AddTimer('DeactivateRunningLanding', time, false);
  465. }
  466. }
  467.  
  468. var slowStartID : int; default slowStartID = -1;
  469. var slowStartActive : bool;
  470.  
  471. private timer function RemoveStartSlow( dt: float, id: int )
  472. {
  473. ResetAnimationSpeedMultiplier(slowStartID);
  474. slowStartID = SetAnimationSpeedMultiplier(0.9);
  475. AddTimer( 'RemoveStartSlow2', 1.0, false );
  476. }
  477.  
  478. private timer function RemoveStartSlow2( dt: float, id: int )
  479. {
  480. ResetAnimationSpeedMultiplier(slowStartID);
  481. slowStartActive = false;
  482. }
  483.  
  484. public function StartSlow()
  485. {
  486. if( !slowStartActive )
  487. {
  488. slowStartActive = true;
  489. slowStartID = SetAnimationSpeedMultiplier(0.8);
  490. AddTimer( 'RemoveStartSlow', 1.0, false );
  491. }
  492. }
  493.  
  494. public function SetSprintSpeed( speed : float )
  495. {
  496. sprintSpeed = speed;
  497. }
  498. // ImmersiveCam--
  499. function EnablePCMode( flag : bool )
  500. {
  501. pcMode = flag;
  502. }
  503.  
  504. public function IsPCModeEnabled() : bool
  505. {
  506. return pcMode && theInput.LastUsedPCInput();
  507. }
  508.  
  509. public function ShouldUsePCModeTargeting() : bool
  510. {
  511. return IsPCModeEnabled() && !lastAxisInputIsMovement;
  512. }
  513.  
  514. public function SetDodgeFeedbackTarget( target : CActor )
  515. {
  516. dodgeFeedbackTarget = target;
  517. }
  518.  
  519. public function GetDodgeFeedbackTarget() : CActor
  520. {
  521. return dodgeFeedbackTarget;
  522. }
  523.  
  524. public function SetSubmergeDepth( depth : float )
  525. {
  526. submergeDepth = depth;
  527. }
  528.  
  529. public function GetSubmergeDepth() : float
  530. {
  531. return submergeDepth;
  532. }
  533.  
  534.  
  535. editable var delayBetweenIllusionOneliners : float;
  536.  
  537. hint delayBetweenIllusionOneliners = "delay in secs between oneliners about illusionary objects";
  538.  
  539. default delayBetweenIllusionOneliners = 5;
  540.  
  541.  
  542. private var battlecry_timeForNext : float;
  543. private var battlecry_delayMin : float; default battlecry_delayMin = 15;
  544. private var battlecry_delayMax : float; default battlecry_delayMax = 60;
  545. private var battlecry_lastTry : name;
  546.  
  547.  
  548. private var previousWeather : name;
  549. private var previousRainStrength : float;
  550.  
  551.  
  552. protected var receivedDamageInCombat : bool;
  553. protected var prevDayNightIsNight : bool;
  554. public var failedFundamentalsFirstAchievementCondition : bool;
  555.  
  556. private var spawnedTime : float;
  557.  
  558. public var currentMonsterHuntInvestigationArea : W3MonsterHuntInvestigationArea;
  559.  
  560. private var isPerformingPhaseChangeAnimation : bool;
  561. default isPerformingPhaseChangeAnimation = false;
  562.  
  563. default receivedDamageInCombat = false;
  564.  
  565.  
  566. public var playerMode : W3PlayerMode;
  567.  
  568.  
  569. protected saved var selectedItemId : SItemUniqueId;
  570. protected saved var blockedRadialSlots : array < SRadialSlotDef >;
  571.  
  572.  
  573. public var enemyCollectionDist : float;
  574. public var findMoveTargetDistMin : float;
  575. public var findMoveTargetDistMax : float;
  576. private var findMoveTargetScaledFrame : float;
  577. public var interactDist : float;
  578. protected var bCanFindTarget : bool;
  579. private var bIsConfirmingEmptyTarget : bool;
  580. private var displayTarget : CGameplayEntity;
  581. private var isShootingFriendly : bool;
  582.  
  583. default findMoveTargetDistMax = 18.f;
  584. default findMoveTargetScaledFrame = 0.5f;
  585. default interactDist = 3.5f;
  586.  
  587.  
  588. private var currentSelectedTarget : CActor;
  589. private var selectedTargetToConfirm : CActor;
  590. private var bConfirmTargetTimerIsEnabled : bool;
  591.  
  592.  
  593. public saved var thrownEntityHandle : EntityHandle;
  594. private var isThrowingItemWithAim : bool;
  595. private saved var isThrowingItem : bool;
  596. private var isThrowHoldPressed : bool;
  597.  
  598.  
  599. private var isAimingCrossbow : bool;
  600.  
  601. default isThrowingItemWithAim = false;
  602.  
  603.  
  604. public var playerAiming : PlayerAiming;
  605.  
  606.  
  607. public var forceDismember : bool;
  608. public var forceDismemberName : name;
  609. public var forceDismemberChance : int;
  610. public var forceDismemberExplosion : bool;
  611.  
  612.  
  613. private var finisherVictim : CActor;
  614. public var forceFinisher : bool;
  615. public var forceFinisherAnimName : name;
  616. public var forceFinisherChance : int;
  617. public var forcedStance : bool;
  618.  
  619.  
  620. private var m_WeaponFXCollisionGroupNames : array <name>;
  621. private var m_CollisionEffect : CEntity;
  622. private var m_LastWeaponTipPos : Vector;
  623. private var m_CollisionFxTemplate : CEntityTemplate;
  624. private var m_RefreshWeaponFXType : bool;
  625. private var m_PlayWoodenFX : bool;
  626.  
  627.  
  628. private var m_activePoster : W3Poster;
  629.  
  630. public function SetActivePoster ( poster : W3Poster )
  631. {
  632. m_activePoster = poster;
  633. }
  634.  
  635. public function RemoveActivePoster ()
  636. {
  637. m_activePoster = NULL;
  638. }
  639.  
  640. public function GetActivePoster () : W3Poster
  641. {
  642. return m_activePoster;
  643. }
  644.  
  645.  
  646.  
  647.  
  648.  
  649. public var horseOnNavMesh : bool;
  650. default horseOnNavMesh = true;
  651.  
  652. public function SetHorseNav( val : bool ) { horseOnNavMesh = val; }
  653.  
  654.  
  655. public var testAdjustRequestedMovementDirection : bool;
  656. default testAdjustRequestedMovementDirection = false;
  657.  
  658.  
  659. default autoState = 'Exploration';
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666. import final function GetEnemiesInRange( out enemies : array< CActor > );
  667. import final function GetVisibleEnemies( out enemies : array< CActor > );
  668. import final function IsEnemyVisible( enemy : CActor ) : bool;
  669.  
  670.  
  671. import final function SetupEnemiesCollection( range, heightTolerance : float,
  672. maxEnemies : int,
  673. optional tag : name,
  674. optional flags : int );
  675.  
  676. import final function IsInInterior() : bool;
  677. import final function IsInSettlement() : bool;
  678. import final function EnterSettlement( isEntering : bool );
  679. import final function ActionDirectControl( controller : CR4LocomotionDirectController ) : bool;
  680. import final function SetPlayerTarget( target : CActor );
  681. import final function SetPlayerCombatTarget( target : CActor );
  682. import final function ObtainTicketFromCombatTarget( ticketName : CName, ticketsCount : int );
  683. import final function FreeTicketAtCombatTarget();
  684. import final function SetScriptMoveTarget( target : CActor );
  685. import final function GetRiderData() : CAIStorageRiderData;
  686. import final function SetIsInCombat( inCombat : bool );
  687. import final function SaveLastMountedHorse( mountedHorse : CActor );
  688.  
  689. import final function SetBacklightFromHealth( healthPercentage : float );
  690. import private final function SetBacklightColor( color : Vector );
  691.  
  692. import final function GetCombatDataComponent() : CCombatDataComponent;
  693.  
  694. import final function GetTemplatePathAndAppearance( out templatePath : string, out appearance : name );
  695.  
  696. import final function HACK_BoatDismountPositionCorrection( slotPos : Vector );
  697.  
  698. import final function HACK_ForceGetBonePosition( boneIndex : int ) : Vector;
  699.  
  700.  
  701. public function GetLevel() : int
  702. {
  703. return 0;
  704. }
  705.  
  706.  
  707.  
  708.  
  709. var targeting : CR4PlayerTargeting;
  710. var targetingPrecalcs : SR4PlayerTargetingPrecalcs;
  711. var targetingIn : SR4PlayerTargetingIn;
  712. var targetingOut : SR4PlayerTargetingOut;
  713. var useNativeTargeting : bool;
  714. default useNativeTargeting = true;
  715.  
  716. var visibleActors : array< CActor >;
  717. var visibleActorsTime : array< float >;
  718.  
  719.  
  720.  
  721. event OnSpawned( spawnData : SEntitySpawnData )
  722. {
  723. var atts : array<name>;
  724. var skill : ESkill;
  725. var i : int;
  726. var item : SItemUniqueId;
  727.  
  728. //---=== modFriendlyHUD ===---
  729. fHUDConfig = new CModFriendlyHUDConfig in this;
  730. fHUDConfig.Init();
  731. //---=== modFriendlyHUD ===---
  732.  
  733. AddAnimEventCallback('ThrowHoldTest', 'OnAnimEvent_ThrowHoldTest');
  734. AddAnimEventCallback('OnWeaponDrawReady', 'OnAnimEvent_OnWeaponDrawReady');
  735. AddAnimEventCallback('OnWeaponHolsterReady', 'OnAnimEvent_OnWeaponHolsterReady');
  736. AddAnimEventCallback('AllowTempLookAt', 'OnAnimEvent_AllowTempLookAt');
  737. AddAnimEventCallback('SlideToTarget', 'OnAnimEvent_SlideToTarget');
  738. AddAnimEventCallback('PlayFinisherBlood', 'OnAnimEvent_PlayFinisherBlood');
  739. AddAnimEventCallback('SlowMo', 'OnAnimEvent_SlowMo');
  740. AddAnimEventCallback('BloodTrailForced', 'OnAnimEvent_BloodTrailForced');
  741. AddAnimEventCallback('FadeOut', 'OnAnimEvent_FadeOut');
  742. AddAnimEventCallback('FadeIn', 'OnAnimEvent_FadeIn');
  743. AddAnimEventCallback('DisallowHitAnim', 'OnAnimEvent_DisallowHitAnim');
  744. AddAnimEventCallback('AllowFall', 'OnAnimEvent_AllowFall');
  745. AddAnimEventCallback('AllowFall2', 'OnAnimEvent_AllowFall2');
  746. AddAnimEventCallback('DettachGround', 'OnAnimEvent_DettachGround');
  747. AddAnimEventCallback('KillWithRagdoll', 'OnAnimEvent_KillWithRagdoll');
  748. AddAnimEventCallback('pad_vibration', 'OnAnimEvent_pad_vibration');
  749. AddAnimEventCallback('pad_vibration_light', 'OnAnimEvent_pad_vibration_light');
  750. AddAnimEventCallback('RemoveBurning', 'OnAnimEvent_RemoveBurning');
  751. AddAnimEventCallback('RemoveTangled', 'OnAnimEvent_RemoveTangled');
  752. AddAnimEventCallback('MoveNoise', 'OnAnimEvent_MoveNoise');
  753.  
  754. AddItemPerLevelList();
  755.  
  756. enemyCollectionDist = findMoveTargetDistMax;
  757.  
  758.  
  759. theGame.RemoveTimeScale('horse_melee');
  760.  
  761.  
  762. if(!spawnData.restored && !((W3ReplacerCiri)this) )
  763. {
  764. AddTimer('GiveStartingItems', 0.00001, true, , , true);
  765.  
  766. if(!theGame.IsFinalBuild())
  767. {
  768. AddAbility('GeraltSkills_Testing');
  769. AddTimer('Debug_GiveTestingItems',0.0001,true);
  770. }
  771.  
  772.  
  773. FactsAdd("tut_stash_fresh_playthrough");
  774. }
  775.  
  776. InitTargeting();
  777.  
  778.  
  779. if( spawnData.restored )
  780. {
  781.  
  782.  
  783.  
  784. theGame.GameplayFactsRemove( "in_combat" );
  785. }
  786.  
  787.  
  788.  
  789. if ( !weaponHolster )
  790. {
  791. weaponHolster = new WeaponHolster in this;
  792. }
  793.  
  794. weaponHolster.Initialize( this, spawnData.restored );
  795.  
  796. if ( !interiorTracker )
  797. {
  798. interiorTracker = new CPlayerInteriorTracker in this;
  799. }
  800. interiorTracker.Init( spawnData.restored );
  801.  
  802.  
  803. super.OnSpawned( spawnData );
  804.  
  805. // ImmersiveCam++
  806. if( ! ic )
  807. {
  808. ic = new icControl in this;
  809. ic.icInit();
  810. }
  811. if( ! mMeditation )
  812. {
  813. mMeditation = new CMeditationUI in this;
  814. }
  815. // ImmersiveCam--
  816.  
  817. medallion = new W3MedallionFX in this;
  818.  
  819. playerMode = new W3PlayerMode in this;
  820. playerMode.Initialize( this );
  821.  
  822.  
  823. playerAiming = new PlayerAiming in this;
  824. playerAiming.Initialize( this );
  825.  
  826.  
  827. navQuery = new CNavigationReachabilityQueryInterface in this;
  828.  
  829.  
  830. EnableFindTarget( true );
  831. AddTimer( 'CombatCheck', 0.2f, true );
  832.  
  833.  
  834. substateManager = ( CExplorationStateManager ) GetComponentByClassName( 'CExplorationStateManager' );
  835.  
  836. findMoveTargetDist = findMoveTargetDistMax;
  837.  
  838. SetupEnemiesCollection( enemyCollectionDist, findMoveTargetDist, 10, 'None', FLAG_Attitude_Neutral + FLAG_Attitude_Hostile + FLAG_Attitude_Friendly + FLAG_OnlyAliveActors );
  839.  
  840.  
  841. inputHandler.RemoveLocksOnSpawn();
  842.  
  843.  
  844. ((CActor) this ).SetInteractionPriority( IP_Prio_0 );
  845.  
  846. prevDayNightIsNight = theGame.envMgr.IsNight();
  847. CheckDayNightCycle();
  848.  
  849.  
  850. EnableVisualDebug( SHOW_AI, true );
  851.  
  852.  
  853. FactsRemove("blocked_illusion_oneliner");
  854.  
  855. SetFailedFundamentalsFirstAchievementCondition(false);
  856. m_CollisionFxTemplate = (CEntityTemplate) LoadResource( 'sword_colision_fx' );
  857. if( m_WeaponFXCollisionGroupNames.Size() == 0 )
  858. {
  859. m_WeaponFXCollisionGroupNames.PushBack('Static');
  860. m_WeaponFXCollisionGroupNames.PushBack('Foliage');
  861. m_WeaponFXCollisionGroupNames.PushBack('Fence');
  862. m_WeaponFXCollisionGroupNames.PushBack('BoatSide');
  863. m_WeaponFXCollisionGroupNames.PushBack('Door');
  864. m_WeaponFXCollisionGroupNames.PushBack('RigidBody');
  865. m_WeaponFXCollisionGroupNames.PushBack('Dynamic');
  866. m_WeaponFXCollisionGroupNames.PushBack('Destructible');
  867. }
  868.  
  869. if ( counterCollisionGroupNames.Size() == 0 )
  870. {
  871. counterCollisionGroupNames.PushBack('Static');
  872. counterCollisionGroupNames.PushBack('Foliage');
  873. counterCollisionGroupNames.PushBack('Fence');
  874. counterCollisionGroupNames.PushBack('Terrain');
  875. counterCollisionGroupNames.PushBack('Door');
  876. counterCollisionGroupNames.PushBack('RigidBody');
  877. counterCollisionGroupNames.PushBack('Dynamic');
  878. counterCollisionGroupNames.PushBack('Destructible');
  879. }
  880.  
  881.  
  882. ResetPadBacklightColor();
  883.  
  884. if( spawnData.restored )
  885. {
  886. if (IsCurrentlyUsingItemL())
  887. {
  888. if (inv.HasItemById( currentlyEquipedItemL ))
  889. {
  890. OnUseSelectedItem();
  891. }
  892. else
  893. {
  894. HideUsableItem(true);
  895. }
  896. }
  897. if ( GetCurrentMeleeWeaponType() == PW_Steel || GetCurrentMeleeWeaponType() == PW_Silver )
  898. {
  899. OnEquipMeleeWeapon(GetCurrentMeleeWeaponType(), true, true);
  900. }
  901.  
  902. AddTimer( 'UnmountCrossbowTimer', 0.01, true );
  903.  
  904. ClearBlockedSlots();
  905. }
  906.  
  907. ((CR4PlayerStateSwimming)this.GetState('Swimming')).OnParentSpawned();
  908.  
  909.  
  910. SetImmortalityMode( AIM_None, AIC_SyncedAnim );
  911.  
  912.  
  913. theGame.GetDefinitionsManager().GetContainedAbilities('DwimeritiumBomb_3', atts);
  914. for(i=0; i<atts.Size(); i+=1)
  915. {
  916. skill = SkillNameToEnum(atts[i]);
  917. if(skill != S_SUndefined)
  918. BlockSkill(skill, false);
  919. }
  920.  
  921.  
  922. this.GetInventory().GetItemEquippedOnSlot( EES_SteelSword, item );
  923. if( this.GetInventory().ItemHasTag( item, 'PhantomWeapon' ) )
  924. {
  925. this.InitPhantomWeaponMgr();
  926. }
  927.  
  928.  
  929. if(FactsQuerySum("mq3036_fact_done") > 0)
  930. BlockAllActions('mq3036', false);
  931.  
  932. spawnedTime = theGame.GetEngineTimeAsSeconds();
  933.  
  934. if ( theGame.GetInGameConfigWrapper().GetVarValue('Gameplay', 'EnableUberMovement' ) == "1" )
  935. theGame.EnableUberMovement( true );
  936. else
  937. theGame.EnableUberMovement( false );
  938.  
  939.  
  940. if ( !FactsDoesExist("gwent_difficulty") )
  941. FactsAdd("gwent_difficulty", 2);
  942.  
  943.  
  944. if(!newGamePlusInitialized && FactsQuerySum("NewGamePlus") > 0)
  945. {
  946. NewGamePlusInitialize();
  947. }
  948.  
  949.  
  950. if( lastInstantKillTime > theGame.GetGameTime() )
  951. {
  952. SetLastInstantKillTime( GameTimeCreate(0) );
  953. }
  954.  
  955. }
  956.  
  957. public function NewGamePlusInitialize()
  958. {
  959. SetLastInstantKillTime( GameTimeCreate(0) );
  960. }
  961.  
  962. public function GetTimeSinceSpawned() : float
  963. {
  964. return theGame.GetEngineTimeAsSeconds() - spawnedTime;
  965. }
  966.  
  967. timer function UnmountCrossbowTimer( dt : float, id : int )
  968. {
  969. var itemId : SItemUniqueId;
  970.  
  971. itemId = this.inv.GetItemFromSlot( 'l_weapon' );
  972. if ( inv.IsIdValid( itemId ) && inv.IsItemCrossbow( itemId ) )
  973. {
  974. rangedWeapon = (Crossbow)( inv.GetItemEntityUnsafe( itemId ) );
  975.  
  976. if (rangedWeapon)
  977. {
  978. rangedWeapon.Initialize( (CActor)( rangedWeapon.GetParentEntity() ) );
  979. OnRangedForceHolster( true, true );
  980. RemoveTimer( 'UnmountCrossbowTimer' );
  981. }
  982. }
  983. else
  984. RemoveTimer( 'UnmountCrossbowTimer' );
  985. }
  986.  
  987. event OnDestroyed()
  988. {
  989. playerAiming.RemoveAimingSloMo();
  990.  
  991. if(rangedWeapon)
  992. rangedWeapon.ClearDeployedEntity(true);
  993.  
  994. ResetPadBacklightColor();
  995.  
  996.  
  997. theGame.ReleaseNoSaveLock( noSaveLock );
  998. }
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004. public function GetBlockedSlots () : array < SRadialSlotDef >
  1005. {
  1006. return blockedRadialSlots;
  1007. }
  1008.  
  1009. public function ClearBlockedSlots()
  1010. {
  1011. var i : int;
  1012.  
  1013.  
  1014.  
  1015. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  1016. {
  1017. if( !IsSwimming() )
  1018. {
  1019. if ( EnableRadialSlot(blockedRadialSlots[i].slotName, 'swimming'))
  1020. {
  1021. i-=1;
  1022. continue;
  1023. }
  1024. }
  1025. if (!IsUsingVehicle())
  1026. {
  1027. if ( EnableRadialSlot(blockedRadialSlots[i].slotName, 'useVehicle'))
  1028. {
  1029. i-=1;
  1030. continue;
  1031. }
  1032. }
  1033. if ( !IsCurrentlyUsingItemL() || !IsUsableItemLBlocked() )
  1034. {
  1035. if ( EnableRadialSlot(blockedRadialSlots[i].slotName, 'usableItemL'))
  1036. {
  1037. i-=1;
  1038. continue;
  1039. }
  1040. }
  1041. if ( !IsThrowingItem() )
  1042. {
  1043. if ( EnableRadialSlot(blockedRadialSlots[i].slotName, 'throwBomb'))
  1044. {
  1045. i-=1;
  1046. continue;
  1047. }
  1048. }
  1049. }
  1050.  
  1051.  
  1052.  
  1053. }
  1054.  
  1055. public function RestoreBlockedSlots ()
  1056. {
  1057. var i : int;
  1058. var slotsToBlock : array<name>;
  1059.  
  1060. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  1061. {
  1062. slotsToBlock.PushBack ( blockedRadialSlots[i].slotName );
  1063. }
  1064. if ( slotsToBlock.Size() > 0 )
  1065. {
  1066. EnableRadialSlots ( false, slotsToBlock );
  1067. }
  1068. }
  1069. private function DisableRadialSlot ( slotName : name, sourceName : name ) : bool
  1070. {
  1071. var i : int;
  1072. var k : int;
  1073. var slotsToBlock : array<name>;
  1074.  
  1075. var blockedRadialSlotEntry : SRadialSlotDef;
  1076.  
  1077. slotsToBlock.PushBack ( slotName );
  1078.  
  1079. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  1080. {
  1081. if ( blockedRadialSlots[i].slotName == slotName )
  1082. {
  1083. if ( sourceName != '' )
  1084. {
  1085. for ( k = 0; k < blockedRadialSlots[i].disabledBySources.Size(); k += 1 )
  1086. {
  1087. if ( blockedRadialSlots[i].disabledBySources[k] == sourceName )
  1088. {
  1089. return false;
  1090. }
  1091. }
  1092. blockedRadialSlots[i].disabledBySources.PushBack ( sourceName );
  1093. return false;
  1094. }
  1095.  
  1096. return false;
  1097. }
  1098. }
  1099.  
  1100. blockedRadialSlotEntry = InitBlockedRadialSlotEntry ( slotName );
  1101.  
  1102. if ( sourceName != '' )
  1103. {
  1104. blockedRadialSlotEntry.disabledBySources.PushBack ( sourceName );
  1105. }
  1106. blockedRadialSlots.PushBack ( blockedRadialSlotEntry );
  1107. EnableRadialSlots ( false, slotsToBlock );
  1108. return true;
  1109. }
  1110.  
  1111. public function EnableRadialSlot ( slotName : name, sourceName : name ) : bool
  1112. {
  1113. var i : int;
  1114. var k : int;
  1115.  
  1116. var slotsToBlock : array<name>;
  1117.  
  1118. slotsToBlock.PushBack ( slotName );
  1119.  
  1120. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  1121. {
  1122. if ( blockedRadialSlots[i].slotName == slotName )
  1123. {
  1124.  
  1125. if ( sourceName != '' )
  1126. {
  1127. for ( k = 0; k < blockedRadialSlots[i].disabledBySources.Size(); k += 1 )
  1128. {
  1129. if ( blockedRadialSlots[i].disabledBySources[k] == sourceName )
  1130. {
  1131. blockedRadialSlots[i].disabledBySources.Remove ( blockedRadialSlots[i].disabledBySources[k] );
  1132. }
  1133. }
  1134. }
  1135. if ( blockedRadialSlots[i].disabledBySources.Size() <= 0 )
  1136. {
  1137. blockedRadialSlots.Remove( blockedRadialSlots[i] );
  1138. EnableRadialSlots ( true, slotsToBlock );
  1139. return true;
  1140. }
  1141. return false;
  1142. }
  1143. }
  1144. return false;
  1145.  
  1146. }
  1147.  
  1148. private function InitBlockedRadialSlotEntry ( slotName : name ) : SRadialSlotDef
  1149. {
  1150. var blockedRadialSlotEntry : SRadialSlotDef;
  1151.  
  1152. blockedRadialSlotEntry.slotName = slotName;
  1153.  
  1154. return blockedRadialSlotEntry;
  1155.  
  1156. }
  1157.  
  1158. public function EnableRadialSlotsWithSource ( enable : bool, slotsToBlock : array < name >, sourceName : name )
  1159. {
  1160. var i : int;
  1161.  
  1162. for ( i = 0; i < slotsToBlock.Size(); i+=1 )
  1163. {
  1164. if ( enable )
  1165. {
  1166. EnableRadialSlot ( slotsToBlock[i], sourceName );
  1167. }
  1168. else
  1169. {
  1170. DisableRadialSlot ( slotsToBlock[i], sourceName );
  1171. }
  1172. }
  1173. if ( blockedRadialSlots.Size() <= 0 )
  1174. {
  1175. blockedRadialSlots.Clear();
  1176. }
  1177. }
  1178.  
  1179. public function IsRadialSlotBlocked ( slotName : name ) : bool
  1180. {
  1181. var i : int;
  1182.  
  1183. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  1184. {
  1185. if ( blockedRadialSlots[i].slotName == slotName )
  1186. {
  1187. return true;
  1188. }
  1189. }
  1190. return false;
  1191. }
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198. public function RepairItem ( rapairKitId : SItemUniqueId, usedOnItem : SItemUniqueId );
  1199. public function HasRepairAbleGearEquiped () : bool;
  1200. public function HasRepairAbleWaponEquiped () : bool;
  1201. public function IsItemRepairAble ( item : SItemUniqueId ) : bool;
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208. public final function ReduceAllOilsAmmo( id : SItemUniqueId )
  1209. {
  1210. var i : int;
  1211. var oils : array< W3Effect_Oil >;
  1212.  
  1213. oils = inv.GetOilsAppliedOnItem( id );
  1214.  
  1215. for( i=0; i<oils.Size(); i+=1 )
  1216. {
  1217. oils[ i ].ReduceAmmo();
  1218. }
  1219. }
  1220.  
  1221. public final function ResumeOilBuffs( steel : bool )
  1222. {
  1223. var item : SItemUniqueId;
  1224. var oils : array< CBaseGameplayEffect >;
  1225. var buff, recentOil : W3Effect_Oil;
  1226. var i : int;
  1227.  
  1228. item = GetEquippedSword( steel );
  1229. oils = GetBuffs( EET_Oil );
  1230.  
  1231. if( oils.Size() > 1 )
  1232. {
  1233.  
  1234.  
  1235. recentOil = inv.GetNewestOilAppliedOnItem( item, false );
  1236. }
  1237.  
  1238. for( i=0; i<oils.Size(); i+=1 )
  1239. {
  1240. buff = ( W3Effect_Oil ) oils[ i ];
  1241.  
  1242. if( recentOil && recentOil == buff )
  1243. {
  1244. continue;
  1245. }
  1246.  
  1247. if(buff && buff.GetSwordItemId() == item )
  1248. {
  1249. buff.Resume( '' );
  1250. }
  1251. }
  1252.  
  1253. if( recentOil )
  1254. {
  1255. recentOil.Resume( '' );
  1256. }
  1257. }
  1258.  
  1259. protected final function PauseOilBuffs( isSteel : bool )
  1260. {
  1261. var item : SItemUniqueId;
  1262. var oils : array< CBaseGameplayEffect >;
  1263. var buff : W3Effect_Oil;
  1264. var i : int;
  1265.  
  1266. item = GetEquippedSword( isSteel );
  1267. oils = GetBuffs( EET_Oil );
  1268.  
  1269. for( i=0; i<oils.Size(); i+=1 )
  1270. {
  1271. buff = ( W3Effect_Oil ) oils[ i ];
  1272. if(buff && buff.GetSwordItemId() == item )
  1273. {
  1274. buff.Pause( '', true );
  1275. }
  1276. }
  1277. }
  1278.  
  1279. public final function ManageAerondightBuff( apply : bool )
  1280. {
  1281. var aerondight : W3Effect_Aerondight;
  1282. var item : SItemUniqueId;
  1283.  
  1284. item = inv.GetCurrentlyHeldSword();
  1285.  
  1286. if( inv.ItemHasTag( item, 'Aerondight' ) )
  1287. {
  1288. aerondight = (W3Effect_Aerondight)GetBuff( EET_Aerondight );
  1289.  
  1290. if( apply )
  1291. {
  1292. if( !aerondight )
  1293. {
  1294. AddEffectDefault( EET_Aerondight, this, "Aerondight" );
  1295. }
  1296. else
  1297. {
  1298. aerondight.Resume( 'ManageAerondightBuff' );
  1299. }
  1300. }
  1301. else
  1302. {
  1303. aerondight.Pause( 'ManageAerondightBuff' );
  1304. }
  1305. }
  1306. }
  1307.  
  1308.  
  1309. public function ApplyOil( oilId : SItemUniqueId, usedOnItem : SItemUniqueId ) : bool
  1310. {
  1311. var oilAbilities : array< name >;
  1312. var ammo, ammoBonus : float;
  1313. var dm : CDefinitionsManagerAccessor;
  1314. var buffParams : SCustomEffectParams;
  1315. var oilParams : W3OilBuffParams;
  1316. var oilName : name;
  1317. var min, max : SAbilityAttributeValue;
  1318. var i : int;
  1319. var oils : array< W3Effect_Oil >;
  1320. var existingOil : W3Effect_Oil;
  1321.  
  1322. if( !CanApplyOilOnItem( oilId, usedOnItem ) )
  1323. {
  1324. return false;
  1325. }
  1326.  
  1327. dm = theGame.GetDefinitionsManager();
  1328. inv.GetItemAbilitiesWithTag( oilId, theGame.params.OIL_ABILITY_TAG, oilAbilities );
  1329. oilName = inv.GetItemName( oilId );
  1330. oils = inv.GetOilsAppliedOnItem( usedOnItem );
  1331.  
  1332.  
  1333. for( i=0; i<oils.Size(); i+=1 )
  1334. {
  1335. if( oils[ i ].GetOilItemName() == oilName )
  1336. {
  1337. existingOil = oils[ i ];
  1338. break;
  1339. }
  1340. }
  1341.  
  1342.  
  1343. if( !existingOil )
  1344. {
  1345. // FCR3 --
  1346. //if( !GetWitcherPlayer() || !GetWitcherPlayer().IsSetBonusActive( EISB_Wolf_1 ) )
  1347. if( !GetWitcherPlayer() || !CanUseSkill(S_Alchemy_s06) )
  1348. // -- FCR3
  1349. {
  1350. inv.RemoveAllOilsFromItem( usedOnItem );
  1351. }
  1352. else
  1353. {
  1354. // FCR3 --
  1355. //dm.GetAbilityAttributeValue( GetSetBonusAbility( EISB_Wolf_1 ), 'max_oils_count', min, max );
  1356. //if( inv.GetActiveOilsAppliedOnItemCount( usedOnItem ) >= CalculateAttributeValue( max ) )
  1357. if( inv.GetActiveOilsAppliedOnItemCount( usedOnItem ) >= GetSkillLevel( S_Alchemy_s06 ) )
  1358. // -- FCR3
  1359. {
  1360. inv.RemoveOldestOilFromItem( usedOnItem );
  1361. }
  1362. }
  1363. }
  1364.  
  1365.  
  1366. ammo = CalculateAttributeValue(inv.GetItemAttributeValue(oilId, 'ammo'));
  1367. if(CanUseSkill(S_Alchemy_s06))
  1368. {
  1369. ammoBonus = CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s06, 'ammo_bonus', false, false));
  1370. ammo *= 1 + ammoBonus * GetSkillLevel(S_Alchemy_s06);
  1371. }
  1372.  
  1373.  
  1374. if( existingOil )
  1375. {
  1376. existingOil.Reapply( RoundMath( ammo ) );
  1377. }
  1378. else
  1379. {
  1380. buffParams.effectType = EET_Oil;
  1381. buffParams.creator = this;
  1382. oilParams = new W3OilBuffParams in this;
  1383. oilParams.iconPath = dm.GetItemIconPath( oilName );
  1384. oilParams.localizedName = dm.GetItemLocalisationKeyName( oilName );
  1385. oilParams.localizedDescription = dm.GetItemLocalisationKeyName( oilName );
  1386. oilParams.sword = usedOnItem;
  1387. oilParams.maxCount = RoundMath( ammo );
  1388. oilParams.currCount = RoundMath( ammo );
  1389. oilParams.oilAbilityName = oilAbilities[ 0 ];
  1390. oilParams.oilItemName = oilName;
  1391. buffParams.buffSpecificParams = oilParams;
  1392.  
  1393. AddEffectCustom( buffParams );
  1394.  
  1395. delete oilParams;
  1396. }
  1397.  
  1398. LogOils("Added oil <<" + oilName + ">> to <<" + inv.GetItemName( usedOnItem ) + ">>");
  1399.  
  1400.  
  1401. SetFailedFundamentalsFirstAchievementCondition( true );
  1402.  
  1403. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnOilApplied );
  1404.  
  1405. if( !inv.IsItemHeld( usedOnItem ) )
  1406. {
  1407. PauseOilBuffs( inv.IsItemSteelSwordUsableByPlayer( usedOnItem ) );
  1408. }
  1409.  
  1410. return true;
  1411. }
  1412.  
  1413.  
  1414. public final function IsEquippedSwordUpgradedWithOil(steel : bool, optional oilName : name) : bool
  1415. {
  1416. var sword : SItemUniqueId;
  1417. var i : int;
  1418. var oils : array< W3Effect_Oil >;
  1419.  
  1420. sword = GetEquippedSword( steel );
  1421. if( !inv.IsIdValid( sword ) )
  1422. {
  1423. return false;
  1424. }
  1425.  
  1426. if( oilName == '' )
  1427. {
  1428. return inv.ItemHasAnyActiveOilApplied( sword );
  1429. }
  1430.  
  1431. oils = inv.GetOilsAppliedOnItem( sword );
  1432. for( i=0; i<oils.Size(); i+=1 )
  1433. {
  1434. if( oils[ i ].GetOilItemName() == oilName )
  1435. {
  1436. return true;
  1437. }
  1438. }
  1439.  
  1440. return false;
  1441. }
  1442.  
  1443. public function CanApplyOilOnItem(oilId : SItemUniqueId, usedOnItem : SItemUniqueId) : bool
  1444. {
  1445. if(inv.ItemHasTag(oilId, theGame.params.TAG_STEEL_OIL) && inv.IsItemSteelSwordUsableByPlayer(usedOnItem))
  1446. return true;
  1447.  
  1448. if(inv.ItemHasTag(oilId, theGame.params.TAG_SILVER_OIL) && inv.IsItemSilverSwordUsableByPlayer(usedOnItem))
  1449. return true;
  1450.  
  1451. return false;
  1452. }
  1453.  
  1454.  
  1455. public final function DidFailFundamentalsFirstAchievementCondition() : bool
  1456. {
  1457. return failedFundamentalsFirstAchievementCondition;
  1458. }
  1459.  
  1460. public final function SetFailedFundamentalsFirstAchievementCondition(b : bool)
  1461. {
  1462. var i : int;
  1463. var npc : CNewNPC;
  1464.  
  1465. failedFundamentalsFirstAchievementCondition = b;
  1466.  
  1467.  
  1468. if(failedFundamentalsFirstAchievementCondition)
  1469. {
  1470. for(i=0; i<hostileEnemies.Size(); i+=1)
  1471. {
  1472. if(hostileEnemies[i].HasTag(theGame.params.MONSTER_HUNT_ACTOR_TAG))
  1473. {
  1474. npc = (CNewNPC)hostileEnemies[i];
  1475. npc.AddTag('failedFundamentalsAchievement');
  1476. npc.AddTimer('FundamentalsAchFailTimer', 30*60, , , , true, true);
  1477. }
  1478. }
  1479. }
  1480. }
  1481.  
  1482. public function IsInCombatFist() : bool
  1483. {
  1484. return this.GetCurrentStateName() == 'CombatFists';
  1485. }
  1486.  
  1487. public function IsInitialized() : bool;
  1488.  
  1489. public function IsCiri() : bool
  1490. {
  1491. return ((W3ReplacerCiri)this);
  1492. }
  1493.  
  1494. protected function WouldLikeToMove() : bool
  1495. {
  1496. var speedVec : Vector;
  1497. var speed, speedMult : float;
  1498.  
  1499.  
  1500. speedVec.X = theInput.GetActionValue( 'GI_AxisLeftX' );
  1501. speedVec.Y = theInput.GetActionValue( 'GI_AxisLeftY' );
  1502. speed = VecLength2D( speedVec );
  1503.  
  1504. return speed > 0.1f;
  1505. }
  1506.  
  1507. function HandleMovement( deltaTime : float )
  1508. {
  1509.  
  1510.  
  1511.  
  1512.  
  1513. if (WouldLikeToMove())
  1514. SetBehaviorVariable( 'playerWouldLikeToMove', 1.0f);
  1515. else
  1516. SetBehaviorVariable( 'playerWouldLikeToMove', 0.0f);
  1517.  
  1518. super.HandleMovement( deltaTime );
  1519. }
  1520.  
  1521. function BattleCryIsReady( ) : bool
  1522. {
  1523. var l_currentTime : float;
  1524.  
  1525. l_currentTime = theGame.GetEngineTimeAsSeconds();
  1526.  
  1527. if( l_currentTime >= battlecry_timeForNext )
  1528. {
  1529. return true;
  1530. }
  1531. return false;
  1532. }
  1533.  
  1534. function PlayBattleCry( _BattleCry : name , _Chance : float, optional _IgnoreDelay, ignoreRepeatCheck : bool )
  1535. {
  1536. var l_randValue : float;
  1537. var fact : int;
  1538.  
  1539. fact = FactsQuerySum("force_stance_normal");
  1540.  
  1541. if( IsSwimming()
  1542. || theGame.IsDialogOrCutscenePlaying()
  1543. || IsInNonGameplayCutscene()
  1544. || IsInGameplayScene()
  1545. || theGame.IsCurrentlyPlayingNonGameplayScene()
  1546. || theGame.IsFading()
  1547. || theGame.IsBlackscreen()
  1548. || FactsQuerySum("force_stance_normal") > 0 )
  1549. {
  1550. return;
  1551. }
  1552.  
  1553.  
  1554. if ( !ignoreRepeatCheck )
  1555. {
  1556. if( battlecry_lastTry == _BattleCry )
  1557. return;
  1558. }
  1559.  
  1560. battlecry_lastTry = _BattleCry;
  1561.  
  1562. l_randValue = RandF();
  1563.  
  1564.  
  1565. if( l_randValue < _Chance && ( _IgnoreDelay || BattleCryIsReady() ) )
  1566. {
  1567. thePlayer.PlayVoiceset( 90, _BattleCry );
  1568.  
  1569. battlecry_timeForNext = theGame.GetEngineTimeAsSeconds() + RandRangeF( battlecry_delayMax, battlecry_delayMin );
  1570. }
  1571.  
  1572. }
  1573.  
  1574. public final function OnWeatherChanged()
  1575. {
  1576. if( IsInInterior()
  1577. || GetCurrentStateName() != 'Exploration'
  1578. || theGame.IsDialogOrCutscenePlaying()
  1579. || IsInNonGameplayCutscene()
  1580. || IsInGameplayScene()
  1581. || theGame.IsCurrentlyPlayingNonGameplayScene()
  1582. || theGame.IsFading()
  1583. || theGame.IsBlackscreen()
  1584. || GetTimeSinceSpawned() < 60 )
  1585. {
  1586. return;
  1587. }
  1588.  
  1589. AddTimer( 'CommentOnWeather', 1 );
  1590. }
  1591.  
  1592. public final timer function CommentOnWeather( _Delta : float, _Id : int )
  1593. {
  1594. var l_weather : name;
  1595. var l_currentArea : EAreaName;
  1596. var l_rand : float;
  1597.  
  1598. l_weather = GetWeatherConditionName();
  1599.  
  1600. l_currentArea = theGame.GetCommonMapManager().GetCurrentArea();
  1601.  
  1602. switch ( l_weather )
  1603. {
  1604. case 'WT_Clear':
  1605.  
  1606. l_rand = RandF();
  1607.  
  1608. if( l_rand > 0.66f && !AreaIsCold() && theGame.envMgr.IsDay() )
  1609. {
  1610. thePlayer.PlayVoiceset( 90, 'WeatherHot' );
  1611. }
  1612. else if ( l_rand > 0.33f )
  1613. {
  1614. thePlayer.PlayVoiceset( 90, 'WeatherClearingUp' );
  1615. }
  1616. break;
  1617.  
  1618. case 'WT_Rain_Storm':
  1619. thePlayer.PlayVoiceset( 90, 'WeatherStormy' );
  1620. break;
  1621.  
  1622. case 'WT_Light_Clouds':
  1623. if( previousRainStrength < GetRainStrength() )
  1624. {
  1625. thePlayer.PlayVoiceset( 90, 'WeatherLooksLikeRain' );
  1626. }
  1627. else if( AreaIsCold() && previousWeather == 'WT_Clear' )
  1628. {
  1629. thePlayer.PlayVoiceset( 90, 'WeatherCold' );
  1630. }
  1631. break;
  1632.  
  1633. case 'WT_Mid_Clouds':
  1634. if( previousRainStrength < GetRainStrength() )
  1635. {
  1636. thePlayer.PlayVoiceset( 90, 'WeatherRaining' );
  1637. }
  1638. else if( AreaIsCold() && previousWeather == 'WT_Clear' )
  1639. {
  1640. thePlayer.PlayVoiceset( 90, 'WeatherCold' );
  1641. }
  1642. break;
  1643.  
  1644. case 'WT_Mid_Clouds_Dark':
  1645. if( previousWeather != 'WT_Heavy_Clouds' && previousWeather != 'WT_Heavy_Clouds_Dark' )
  1646. thePlayer.PlayVoiceset( 90, 'WeatherWindy' );
  1647. break;
  1648.  
  1649. case 'WT_Heavy_Clouds':
  1650. if( previousWeather != 'WT_Mid_Clouds_Dark' && previousWeather != 'WT_Heavy_Clouds_Dark' )
  1651. thePlayer.PlayVoiceset( 90, 'WeatherWindy' );
  1652. break;
  1653.  
  1654. case 'WT_Heavy_Clouds_Dark':
  1655. if( thePlayer.IsOnBoat() )
  1656. {
  1657. thePlayer.PlayVoiceset( 90, 'WeatherSeaWillStorm' );
  1658. }
  1659. else if( previousRainStrength < GetRainStrength() )
  1660. {
  1661. thePlayer.PlayVoiceset( 90, 'WeatherLooksLikeRain' );
  1662. }
  1663. else
  1664. {
  1665. thePlayer.PlayVoiceset( 90, 'WeatherWindy' );
  1666. }
  1667. break;
  1668.  
  1669. case 'WT_Snow':
  1670. if( RandF() > 0.5f )
  1671. thePlayer.PlayVoiceset( 90, 'WeatherSnowy' );
  1672. else
  1673. thePlayer.PlayVoiceset( 90, 'WeatherCold' );
  1674. break;
  1675. }
  1676.  
  1677. previousRainStrength = GetRainStrength();
  1678. previousWeather = l_weather;
  1679. }
  1680.  
  1681. function CanUpdateMovement() : bool
  1682. {
  1683. if ( rangedWeapon
  1684. && GetBehaviorVariable( 'fullBodyAnimWeight' ) >= 1.f
  1685. && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  1686. return false;
  1687.  
  1688. return true;
  1689. }
  1690.  
  1691. public function SetDefaultLocomotionController()
  1692. {
  1693. if( !defaultLocomotionController )
  1694. {
  1695. defaultLocomotionController = new CR4LocomotionPlayerControllerScript in this;
  1696. }
  1697.  
  1698. ActionDirectControl( defaultLocomotionController );
  1699. }
  1700.  
  1701. event OnPlayerTickTimer( deltaTime : float )
  1702. {
  1703. var focusModeController : CFocusModeController;
  1704. var cnt : int;
  1705.  
  1706. super.OnPlayerTickTimer( deltaTime );
  1707.  
  1708. HandleMovement( deltaTime );
  1709.  
  1710. if ( playerAiming.GetCurrentStateName() == 'Aiming' )
  1711. {
  1712. FindTarget();
  1713. FindNonActorTarget( false );
  1714. UpdateDisplayTarget();
  1715. UpdateLookAtTarget();
  1716. }
  1717. else
  1718. {
  1719. if( playerTickTimerPhase == 0 )
  1720. {
  1721. FindTarget();
  1722. }
  1723. else if( playerTickTimerPhase == 1 )
  1724. {
  1725. FindNonActorTarget( false );
  1726. }
  1727. else if ( playerTickTimerPhase == 2 )
  1728. {
  1729. UpdateDisplayTarget();
  1730. UpdateLookAtTarget();
  1731. }
  1732. }
  1733.  
  1734.  
  1735.  
  1736. playerTickTimerPhase = ( playerTickTimerPhase + 1 ) % 3;
  1737.  
  1738. focusModeController = theGame.GetFocusModeController();
  1739. focusModeController.UpdateFocusInteractions( deltaTime );
  1740.  
  1741.  
  1742. cnt = (int)( effectManager.GetCriticalBuffsCount() > 0 );
  1743. SetBehaviorVariable('hasCriticalBuff', cnt);
  1744. // modHoodToggle
  1745. if ( FactsDoesExist("HoodOn") && !HoodToggleButton ) {
  1746. AddTimer( 'TimerHoodOn', 0.1, false );
  1747. HoodToggleButton = true;
  1748. }
  1749. if ( FactsDoesExist("CapeOn") && !CapeToggleButton ) {
  1750. AddTimer( 'TimerCapeOn', 0.1, false );
  1751. CapeToggleButton = true;
  1752. }
  1753. // modHoodToggle
  1754. }
  1755.  
  1756. event OnDeath( damageAction : W3DamageAction )
  1757. {
  1758. super.OnDeath( damageAction );
  1759.  
  1760. RemoveTimer('RequestCriticalAnimStart');
  1761.  
  1762. EnableFindTarget( false );
  1763. BlockAllActions('Death', true);
  1764.  
  1765. EnableHardLock( false );
  1766.  
  1767. theGame.CreateNoSaveLock( 'player_death', deathNoSaveLock, false, false );
  1768. theGame.SetDeathSaveLockId( deathNoSaveLock );
  1769.  
  1770. ClearHostileEnemiesList();
  1771. RemoveReactions();
  1772. SetPlayerCombatTarget(NULL);
  1773. OnEnableAimingMode( false );
  1774.  
  1775. theGame.EnableFreeCamera( false );
  1776. }
  1777.  
  1778.  
  1779. function OnRevived()
  1780. {
  1781. super.OnRevived();
  1782. BlockAllActions('Death', false);
  1783.  
  1784. theGame.ReleaseNoSaveLock(deathNoSaveLock);
  1785.  
  1786. this.RestartReactionsIfNeeded();
  1787. }
  1788.  
  1789. public function CanStartTalk() : bool
  1790. {
  1791. if ( beingWarnedBy.Size() > 0 )
  1792. return false;
  1793.  
  1794. return super.CanStartTalk();
  1795. }
  1796.  
  1797.  
  1798.  
  1799.  
  1800.  
  1801.  
  1802. public function AddCounterTimeStamp(time : EngineTime) {counterTimestamps.PushBack(time);}
  1803.  
  1804.  
  1805. public function CheckCounterSpamming(attacker : CActor) : bool
  1806. {
  1807. var counterWindowStartTime : EngineTime;
  1808. var i, spamCounter : int;
  1809. var reflexAction : bool;
  1810. var testEngineTime : EngineTime;
  1811.  
  1812. if(!attacker)
  1813. return false;
  1814.  
  1815. counterWindowStartTime = ((CNewNPC)attacker).GetCounterWindowStartTime();
  1816. spamCounter = 0;
  1817. reflexAction = false;
  1818.  
  1819.  
  1820. if ( counterWindowStartTime == testEngineTime )
  1821. {
  1822. return false;
  1823. }
  1824.  
  1825. for(i = counterTimestamps.Size() - 1; i>=0; i-=1)
  1826. {
  1827.  
  1828. if(counterTimestamps[i] >= (counterWindowStartTime - EngineTimeFromFloat(0.4)) )
  1829. {
  1830. spamCounter += 1;
  1831. }
  1832.  
  1833. else
  1834. {
  1835. counterTimestamps.Remove(counterTimestamps[i]);
  1836. continue;
  1837. }
  1838.  
  1839.  
  1840. if(!reflexAction && (counterTimestamps[i] >= counterWindowStartTime))
  1841. reflexAction = true;
  1842. }
  1843.  
  1844.  
  1845. if(spamCounter == 1 && reflexAction)
  1846. return true;
  1847.  
  1848. return false;
  1849. }
  1850.  
  1851. protected function PerformCounterCheck(parryInfo: SParryInfo) : bool
  1852. {
  1853. var mult : float;
  1854. var parryType : EParryType;
  1855. var validCounter, useKnockdown : bool;
  1856. var slideDistance, duration : float;
  1857. var playerToTargetRot : EulerAngles;
  1858. var zDifference, mutation8TriggerHP : float;
  1859. var effectType : EEffectType;
  1860. var repelType : EPlayerRepelType = PRT_Random;
  1861. var params : SCustomEffectParams;
  1862. var thisPos, attackerPos : Vector;
  1863. var fistFightCheck, isMutation8 : bool;
  1864. var fistFightCounter : bool;
  1865. var attackerInventory : CInventoryComponent;
  1866. var weaponId : SItemUniqueId;
  1867. var weaponTags : array<name>;
  1868. var playerToAttackerVector : Vector;
  1869. var tracePosStart : Vector;
  1870. var tracePosEnd : Vector;
  1871. var hitPos : Vector;
  1872. var hitNormal : Vector;
  1873. var min, max : SAbilityAttributeValue;
  1874. var npc : CNewNPC;
  1875.  
  1876. if(ShouldProcessTutorial('TutorialDodge') || ShouldProcessTutorial('TutorialCounter'))
  1877. {
  1878. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
  1879. FactsRemove("tut_fight_slomo_ON");
  1880. }
  1881.  
  1882. if ( !parryInfo.canBeParried || parryInfo.attacker.HasAbility( 'CannotBeCountered' ) )
  1883. return false;
  1884.  
  1885. fistFightCheck = FistFightCheck( parryInfo.target, parryInfo.attacker, fistFightCounter );
  1886.  
  1887. if( ParryCounterCheck() && parryInfo.targetToAttackerAngleAbs < theGame.params.PARRY_HALF_ANGLE && fistFightCheck )
  1888. {
  1889.  
  1890. validCounter = CheckCounterSpamming(parryInfo.attacker);
  1891.  
  1892. if(validCounter)
  1893. {
  1894. if ( IsInCombatActionFriendly() )
  1895. RaiseEvent('CombatActionFriendlyEnd');
  1896.  
  1897. SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
  1898. SetBehaviorVariable( 'counter', (float)validCounter);
  1899.  
  1900.  
  1901.  
  1902. SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
  1903. SetBehaviorVariable( 'counter', (float)validCounter);
  1904. this.SetBehaviorVariable( 'combatActionType', (int)CAT_Parry );
  1905.  
  1906.  
  1907. if ( !fistFightCounter )
  1908. {
  1909. attackerInventory = parryInfo.attacker.GetInventory();
  1910. weaponId = attackerInventory.GetItemFromSlot('r_weapon');
  1911. attackerInventory.GetItemTags( weaponId , weaponTags );
  1912.  
  1913. if( GetWitcherPlayer().IsMutationActive( EPMT_Mutation8 ) )
  1914. {
  1915. isMutation8 = true;
  1916. theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Mutation8', 'hp_perc_trigger', min, max );
  1917. mutation8TriggerHP = min.valueMultiplicative;
  1918. }
  1919.  
  1920.  
  1921.  
  1922. npc = (CNewNPC)parryInfo.attacker;
  1923.  
  1924.  
  1925. if ( parryInfo.attacker.HasAbility('mon_gravehag') )
  1926. {
  1927. repelType = PRT_Slash;
  1928. parryInfo.attacker.AddEffectDefault(EET_CounterStrikeHit, this, 'ReflexParryPerformed');
  1929.  
  1930. }
  1931. else if ( npc && !npc.IsHuman() && !npc.HasTag( 'dettlaff_vampire' ) )
  1932. {
  1933. repelType = PRT_SideStepSlash;
  1934. }
  1935. else if ( weaponTags.Contains('spear2h') )
  1936. {
  1937. repelType = PRT_SideStepSlash;
  1938. parryInfo.attacker.AddEffectDefault(EET_CounterStrikeHit, this, "ReflexParryPerformed");
  1939. parryInfo.attacker.SignalGameplayEvent( 'SpearDestruction');
  1940. }
  1941. // FCR3 --
  1942. //else if( isMutation8 && npc && !npc.IsImmuneToMutation8Finisher() )
  1943. else if( isMutation8 && npc && !npc.IsImmuneToMutation8Finisher() && RandRangeF(3,0) < GetWitcherPlayer().GetStat(BCS_Focus) )
  1944. // -- FCR3
  1945. {
  1946. repelType = PRT_RepelToFinisher;
  1947. npc.AddEffectDefault( EET_CounterStrikeHit, this, "ReflexParryPerformed" );
  1948.  
  1949.  
  1950. SetTarget( npc, true );
  1951.  
  1952. PerformFinisher( 0.f, 0 );
  1953. }
  1954. else
  1955. {
  1956.  
  1957. thisPos = this.GetWorldPosition();
  1958. attackerPos = parryInfo.attacker.GetWorldPosition();
  1959. playerToTargetRot = VecToRotation( thisPos - attackerPos );
  1960. zDifference = thisPos.Z - attackerPos.Z;
  1961.  
  1962. if ( playerToTargetRot.Pitch < -5.f && zDifference > 0.35 )
  1963. {
  1964. repelType = PRT_Kick;
  1965.  
  1966. ragdollTarget = parryInfo.attacker;
  1967. AddTimer( 'ApplyCounterRagdollTimer', 0.3 );
  1968. }
  1969. else
  1970. {
  1971. useKnockdown = false;
  1972. if ( CanUseSkill(S_Sword_s11) )
  1973. {
  1974. if( GetSkillLevel(S_Sword_s11) > 1 && RandRangeF(3,0) < GetWitcherPlayer().GetStat(BCS_Focus) )
  1975. {
  1976. duration = CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s11, 'duration', false, true));
  1977. useKnockdown = true;
  1978. }
  1979. }
  1980. else if ( parryInfo.attacker.IsHuman() )
  1981. {
  1982.  
  1983. tracePosStart = parryInfo.attacker.GetWorldPosition();
  1984. tracePosStart.Z += 1.f;
  1985. playerToAttackerVector = VecNormalize( parryInfo.attacker.GetWorldPosition() - parryInfo.target.GetWorldPosition() );
  1986. tracePosEnd = ( playerToAttackerVector * 0.75f ) + ( playerToAttackerVector * parryInfo.attacker.GetRadius() ) + parryInfo.attacker.GetWorldPosition();
  1987. tracePosEnd.Z += 1.f;
  1988.  
  1989. if ( !theGame.GetWorld().StaticTrace( tracePosStart, tracePosEnd, hitPos, hitNormal, counterCollisionGroupNames ) )
  1990. {
  1991. tracePosStart = tracePosEnd;
  1992. tracePosEnd -= 3.f;
  1993.  
  1994. if ( !theGame.GetWorld().StaticTrace( tracePosStart, tracePosEnd, hitPos, hitNormal, counterCollisionGroupNames ) )
  1995. useKnockdown = true;
  1996. }
  1997. }
  1998.  
  1999. if(useKnockdown && (!parryInfo.attacker.IsImmuneToBuff(EET_HeavyKnockdown) || !parryInfo.attacker.IsImmuneToBuff(EET_Knockdown)))
  2000. {
  2001. if(!parryInfo.attacker.IsImmuneToBuff(EET_HeavyKnockdown))
  2002. {
  2003. params.effectType = EET_HeavyKnockdown;
  2004. }
  2005. else
  2006. {
  2007. params.effectType = EET_Knockdown;
  2008. }
  2009.  
  2010. repelType = PRT_Kick;
  2011. params.creator = this;
  2012. params.sourceName = "ReflexParryPerformed";
  2013. params.duration = duration;
  2014.  
  2015. parryInfo.attacker.AddEffectCustom(params);
  2016. }
  2017. else
  2018. {
  2019. parryInfo.attacker.AddEffectDefault(EET_CounterStrikeHit, this, "ReflexParryPerformed");
  2020. }
  2021. }
  2022. }
  2023.  
  2024. parryInfo.attacker.GetInventory().PlayItemEffect(parryInfo.attackerWeaponId, 'counterattack');
  2025.  
  2026.  
  2027. if ( repelType == PRT_Random )
  2028. if ( RandRange(100) > 50 )
  2029. repelType = PRT_Bash;
  2030. else
  2031. repelType = PRT_Kick;
  2032.  
  2033. this.SetBehaviorVariable( 'repelType', (int)repelType );
  2034. parryInfo.attacker.SetBehaviorVariable( 'repelType', (int)repelType );
  2035. }
  2036. else
  2037. {
  2038. parryInfo.attacker.AddEffectDefault(EET_CounterStrikeHit, this, "ReflexParryPerformed");
  2039. }
  2040.  
  2041.  
  2042. SetParryTarget ( parryInfo.attacker );
  2043. SetSlideTarget( parryInfo.attacker );
  2044. if ( !IsActorLockedToTarget() )
  2045. SetMoveTarget( parryInfo.attacker );
  2046.  
  2047. if ( RaiseForceEvent( 'PerformCounter' ) )
  2048. OnCombatActionStart();
  2049.  
  2050. SetCustomRotation( 'Counter', VecHeading( parryInfo.attacker.GetWorldPosition() - this.GetWorldPosition() ), 0.0f, 0.2f, false );
  2051. AddTimer( 'UpdateCounterRotation', 0.4f, true );
  2052. AddTimer( 'SetCounterRotation', 0.2f );
  2053.  
  2054. IncreaseUninterruptedHitsCount();
  2055.  
  2056.  
  2057. if(IsHeavyAttack(parryInfo.attackActionName))
  2058. mult = theGame.params.HEAVY_STRIKE_COST_MULTIPLIER;
  2059.  
  2060. DrainStamina(ESAT_Counterattack, 0, 0, '', 0, mult);
  2061.  
  2062. theGame.GetGamerProfile().IncStat(ES_CounterattackChain);
  2063.  
  2064. }
  2065. else
  2066. {
  2067. ResetUninterruptedHitsCount();
  2068. }
  2069. return validCounter;
  2070. }
  2071.  
  2072. return false;
  2073. }
  2074.  
  2075. timer function UpdateCounterRotation( dt : float, id : int )
  2076. {
  2077. UpdateCustomRotationHeading( 'Counter', VecHeading( parryTarget.GetWorldPosition() - this.GetWorldPosition() ) );
  2078. }
  2079.  
  2080. timer function SetCounterRotation( dt : float, id : int )
  2081. {
  2082. SetCustomRotation( 'Counter', VecHeading( parryTarget.GetWorldPosition() - this.GetWorldPosition() ), 360.f, 0.2f, false );
  2083. }
  2084.  
  2085. private var parryTarget : CActor;
  2086. private function SetParryTarget( t : CActor )
  2087. {
  2088. parryTarget = t;
  2089. }
  2090.  
  2091. private var ragdollTarget : CActor;
  2092. timer function ApplyCounterRagdollTimer( time : float , id : int)
  2093. {
  2094. var actor : CActor;
  2095.  
  2096. actor = (CActor)ragdollTarget;
  2097.  
  2098. if(actor)
  2099. {
  2100. actor.AddEffectDefault(EET_HeavyKnockdown, this, 'ReflexParryPerformed');
  2101. }
  2102. }
  2103.  
  2104.  
  2105.  
  2106.  
  2107. public function EnableMode( mode : EPlayerMode, enable : bool )
  2108. {
  2109. playerMode.EnableMode( mode, enable );
  2110. }
  2111.  
  2112. public function GetPlayerMode() : W3PlayerMode
  2113. {
  2114. return playerMode;
  2115. }
  2116.  
  2117. private function GetClosestIncomingAttacker() : CActor
  2118. {
  2119. var i, size : int;
  2120. var attackerToPlayerDistances : array< float >;
  2121. var closestAttackerIndex : int;
  2122. var incomingAttackers : array<CActor>;
  2123.  
  2124.  
  2125. if(playerMode && playerMode.combatDataComponent)
  2126. {
  2127. if ( incomingAttackers.Size() <= 0 )
  2128. this.playerMode.combatDataComponent.GetTicketSourceOwners( incomingAttackers, 'TICKET_Charge' );
  2129.  
  2130. if ( incomingAttackers.Size() <= 0 )
  2131. this.playerMode.combatDataComponent.GetTicketSourceOwners( incomingAttackers, 'TICKET_Melee' );
  2132.  
  2133. if ( incomingAttackers.Size() <= 0 )
  2134. this.playerMode.combatDataComponent.GetTicketSourceOwners( incomingAttackers, 'TICKET_Range' );
  2135. }
  2136.  
  2137. size = incomingAttackers.Size();
  2138. attackerToPlayerDistances.Resize( size );
  2139.  
  2140. if ( size > 0 )
  2141. {
  2142. for ( i = incomingAttackers.Size()-1; i >= 0; i -= 1)
  2143. {
  2144. if ( !IsEnemyVisible( incomingAttackers[i] ) )
  2145. {
  2146. incomingAttackers.EraseFast( i );
  2147. }
  2148. }
  2149. }
  2150.  
  2151. if ( size > 0 )
  2152. {
  2153. for ( i = 0; i < size; i += 1 )
  2154. {
  2155. attackerToPlayerDistances[i] = VecDistance( incomingAttackers[i].GetWorldPosition(), this.GetWorldPosition() );
  2156. }
  2157. closestAttackerIndex = ArrayFindMinF( attackerToPlayerDistances );
  2158. return incomingAttackers[ closestAttackerIndex ];
  2159. }
  2160. else
  2161. {
  2162. return NULL;
  2163. }
  2164. }
  2165.  
  2166.  
  2167. timer function CombatCheck( time : float , id : int)
  2168. {
  2169. var i : int;
  2170. var strLevel, temp : string;
  2171. var enemies : array<CActor>;
  2172.  
  2173. UpdateFinishableEnemyList();
  2174. FindMoveTarget();
  2175. playerMode.UpdateCombatMode();
  2176.  
  2177. if( GetPlayerCombatStance() == PCS_Guarded )
  2178. {
  2179. if( GetTarget().GetHealthPercents() > 0.25f )
  2180. {
  2181. PlayBattleCry( 'BattleCryTaunt', 0.2f );
  2182. }
  2183. else
  2184. {
  2185. if( GetTarget().IsHuman() )
  2186. PlayBattleCry( 'BattleCryHumansEnd', 0.3f );
  2187. else
  2188. PlayBattleCry( 'BattleCryMonstersEnd', 0.3f );
  2189. }
  2190. }
  2191.  
  2192. if(IsThreatened() && ShouldProcessTutorial('TutorialMonsterThreatLevels') && FactsQuerySum("q001_nightmare_ended") > 0)
  2193. {
  2194. GetEnemiesInRange(enemies);
  2195. for(i=0; i<enemies.Size(); i+=1)
  2196. {
  2197. strLevel = ((CNewNPC)enemies[i]).GetExperienceDifferenceLevelName(temp);
  2198. if(strLevel == "deadlyLevel" || strLevel == "highLevel")
  2199. {
  2200. FactsAdd("tut_high_threat_monster");
  2201. break;
  2202. }
  2203. }
  2204. }
  2205. }
  2206.  
  2207. public function ReceivedDamageInCombat() : bool
  2208. {
  2209. return receivedDamageInCombat;
  2210. }
  2211.  
  2212. //---=== modFriendlyHUD ===---
  2213. timer function PinEssentialGroupTimer( deltaTime : float, id : int )
  2214. {
  2215. ToggleEssentialModules( !IsHUDGroupEnabledForReason( GetFHUDConfig().essentialModules, "PinEssentialGroup" ), "PinEssentialGroup" );
  2216. }
  2217.  
  2218. timer function EssentialsOnTimer( deltaTime : float, id : int )
  2219. {
  2220. ToggleEssentialModules( true, "EssentialModulesHotkey" );
  2221. }
  2222.  
  2223. timer function MapOnTimer( deltaTime : float, id : int )
  2224. {
  2225. ToggleMinimapModules( true, "MinimapModulesHotkey" );
  2226. }
  2227.  
  2228. timer function QuestsOnTimer( deltaTime : float, id : int )
  2229. {
  2230. ToggleQuestsModules( true, "QuestsModulesHotkey" );
  2231. }
  2232.  
  2233. timer function CharOnTimer( deltaTime : float, id : int )
  2234. {
  2235. ToggleCharacterModules( true, "CharModulesHotkey" );
  2236. }
  2237.  
  2238. timer function DamageOffTimer( deltaTime : float, id : int ) //still needed as workaround
  2239. {
  2240. ToggleHUDModule( "WolfHeadModule", false, "OnDamage" );
  2241. }
  2242.  
  2243. timer function MeditationModulesOnTimer( deltaTime : float, id : int ) //needed for compatibility
  2244. {
  2245. if ( GetFHUDConfig().enableMeditationModules )
  2246. {
  2247. ToggleMeditModules( true, "RealTimeMeditation" );
  2248. }
  2249. }
  2250.  
  2251. timer function MeditationModulesOffTimer( deltaTime : float, id : int ) //needed for compatibility
  2252. {
  2253. if ( GetFHUDConfig().enableMeditationModules )
  2254. {
  2255. ToggleMeditModules( false, "RealTimeMeditation" );
  2256. }
  2257. }
  2258. //---=== modFriendlyHUD ===---
  2259.  
  2260. event OnCombatStart()
  2261. {
  2262. var weaponType : EPlayerWeapon;
  2263.  
  2264. //---=== modFriendlyHUD ===---
  2265. if ( GetFHUDConfig().enableCombatModules )
  2266. {
  2267. ToggleCombatModules( true, "InCombat" );
  2268. }
  2269. //---=== modFriendlyHUD ===---
  2270.  
  2271. theGame.CreateNoSaveLock( 'combat', noSaveLock );
  2272.  
  2273. theGame.GameplayFactsAdd( "in_combat" );
  2274.  
  2275.  
  2276. FactsRemove("statistics_cerberus_sign");
  2277. FactsRemove("statistics_cerberus_petard");
  2278. FactsRemove("statistics_cerberus_bolt");
  2279. FactsRemove("statistics_cerberus_fists");
  2280. FactsRemove("statistics_cerberus_melee");
  2281. FactsRemove("statistics_cerberus_environment");
  2282.  
  2283. BlockAction(EIAB_OpenMeditation, 'InCombat');
  2284. BlockAction(EIAB_HighlightObjective, 'InCombat');
  2285.  
  2286. if ( !this.IsUsingBoat() && GetTarget().GetAttitude(this) == AIA_Hostile )
  2287. {
  2288. weaponType = GetMostConvenientMeleeWeapon( GetTarget() );
  2289.  
  2290. if ( weaponType == PW_Steel || weaponType == PW_Silver )
  2291. this.OnEquipMeleeWeapon( weaponType, false );
  2292. }
  2293. }
  2294.  
  2295.  
  2296. event OnCombatFinished()
  2297. {
  2298. var cnt : int;
  2299.  
  2300. //---=== modFriendlyHUD ===---
  2301. if ( GetFHUDConfig().enableCombatModules )
  2302. {
  2303. ToggleCombatModules( false, "InCombat" );
  2304. }
  2305. //---=== modFriendlyHUD ===---
  2306.  
  2307. //---=== modFriendlyHUD ===---
  2308. if ( GetFHUDConfig().enableCombatModules )
  2309. {
  2310. ToggleCombatModules( false, "InCombat" );
  2311. }
  2312. //---=== modFriendlyHUD ===---
  2313.  
  2314. reevaluateCurrentWeapon = false;
  2315.  
  2316. thePlayer.HardLockToTarget( false );
  2317.  
  2318. receivedDamageInCombat = false;
  2319.  
  2320. theGame.GameplayFactsRemove( "in_combat" );
  2321.  
  2322.  
  2323. cnt = 0;
  2324. if(FactsQuerySum("statistics_cerberus_sign") > 0)
  2325. cnt += 1;
  2326. if(FactsQuerySum("statistics_cerberus_petard") > 0)
  2327. cnt += 1;
  2328. if(FactsQuerySum("statistics_cerberus_bolt") > 0)
  2329. cnt += 1;
  2330. if(FactsQuerySum("statistics_cerberus_fists") > 0)
  2331. cnt += 1;
  2332. if(FactsQuerySum("statistics_cerberus_melee") > 0)
  2333. cnt += 1;
  2334. if(FactsQuerySum("statistics_cerberus_environment") > 0)
  2335. cnt += 1;
  2336.  
  2337.  
  2338. FactsRemove("statistics_cerberus_sign");
  2339. FactsRemove("statistics_cerberus_petard");
  2340. FactsRemove("statistics_cerberus_bolt");
  2341. FactsRemove("statistics_cerberus_fists");
  2342. FactsRemove("statistics_cerberus_melee");
  2343. FactsRemove("statistics_cerberus_environment");
  2344.  
  2345. if(cnt >= 3)
  2346. theGame.GetGamerProfile().AddAchievement(EA_Cerberus);
  2347.  
  2348.  
  2349. if(theGame.GetTutorialSystem() && FactsQuerySum("TutorialShowSilver") > 0)
  2350. {
  2351. FactsAdd("tut_show_silver_sword", 1);
  2352. FactsRemove("TutorialShowSilver");
  2353. }
  2354. this.SetBehaviorVariable('isInCombatForOverlay',0.f);
  2355. GoToExplorationIfNeeded();
  2356. theGame.ReleaseNoSaveLock( noSaveLock );
  2357. LogChannel( 'OnCombatFinished', "OnCombatFinished: ReleaseNoSaveLock" );
  2358.  
  2359. SetFailedFundamentalsFirstAchievementCondition(false);
  2360.  
  2361. UnblockAction(EIAB_OpenMeditation, 'InCombat');
  2362. UnblockAction(EIAB_HighlightObjective, 'InCombat');
  2363. }
  2364.  
  2365. event OnReactToBeingHit( damageAction : W3DamageAction )
  2366. {
  2367. var weaponType : EPlayerWeapon;
  2368.  
  2369. super.OnReactToBeingHit(damageAction);
  2370. IncHitCounter();
  2371.  
  2372. if ( IsInCombat() && damageAction.attacker && damageAction.attacker == GetTarget() && !( this.IsUsingVehicle() && this.IsOnBoat() ) )
  2373. {
  2374. weaponType = GetMostConvenientMeleeWeapon( GetTarget() );
  2375. if ( weaponType != PW_Fists && weaponType != PW_None && weaponType != this.GetCurrentMeleeWeaponType() )
  2376. OnEquipMeleeWeapon( weaponType, false );
  2377. }
  2378. }
  2379.  
  2380.  
  2381. public function ReceivedCombatDamage()
  2382. {
  2383. receivedDamageInCombat = true;
  2384. }
  2385.  
  2386.  
  2387.  
  2388.  
  2389.  
  2390.  
  2391. timer function UninterruptedHitsResetOnIdle(dt : float, id : int)
  2392. {
  2393. ResetUninterruptedHitsCount();
  2394. }
  2395.  
  2396. public function ResetUninterruptedHitsCount()
  2397. {
  2398. uninterruptedHitsCount = 0;
  2399. LogUnitAtt("Uninterrupted attacks reset!!!!");
  2400. }
  2401.  
  2402. public function IncreaseUninterruptedHitsCount()
  2403. {
  2404. uninterruptedHitsCount += 1;
  2405. LogUnitAtt("Uninterrupted attacks count increased to " + uninterruptedHitsCount);
  2406.  
  2407. if(uninterruptedHitsCount == 4)
  2408. AddTimer('StartUninterruptedBlurr', 1, false);
  2409.  
  2410.  
  2411. AddTimer('UninterruptedHitsResetOnIdle', 4.f, false);
  2412. }
  2413.  
  2414. timer function StartUninterruptedBlurr(dt : float, id : int)
  2415. {
  2416. var changed : bool;
  2417. var movingAgent : CMovingPhysicalAgentComponent;
  2418. var target : CActor;
  2419.  
  2420.  
  2421. if(uninterruptedHitsCount < 4)
  2422. {
  2423. LogUnitAtt("Stopping camera effect");
  2424. thePlayer.StopEffect(uninterruptedHitsCurrentCameraEffect);
  2425. uninterruptedHitsCurrentCameraEffect = '';
  2426. uninterruptedHitsCameraStarted = false;
  2427. RemoveTimer('StartUninterruptedBlurr');
  2428. }
  2429. else
  2430. {
  2431. target = GetTarget();
  2432.  
  2433. if( target )
  2434. {
  2435. movingAgent = ( (CMovingPhysicalAgentComponent) (target.GetMovingAgentComponent()) );
  2436. }
  2437.  
  2438. if(!uninterruptedHitsCameraStarted)
  2439. {
  2440. LogUnitAtt("Starting camera effect");
  2441. AddTimer('StartUninterruptedBlurr', 0.001, true);
  2442. if(movingAgent && movingAgent.GetCapsuleHeight() > 2)
  2443. uninterruptedHitsCurrentCameraEffect = theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_BIG_ENEMY;
  2444. else
  2445. uninterruptedHitsCurrentCameraEffect = theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_REGULAR_ENEMY;
  2446. thePlayer.PlayEffect(uninterruptedHitsCurrentCameraEffect);
  2447. uninterruptedHitsCameraStarted = true;
  2448. }
  2449. else
  2450. {
  2451. changed = false;
  2452. if(movingAgent && movingAgent.GetCapsuleHeight() > 2 && uninterruptedHitsCurrentCameraEffect != theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_BIG_ENEMY)
  2453. changed = true;
  2454. else if(!movingAgent || ( movingAgent.GetCapsuleHeight() <= 2 && uninterruptedHitsCurrentCameraEffect != theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_REGULAR_ENEMY) )
  2455. changed = true;
  2456.  
  2457.  
  2458. if(changed)
  2459. {
  2460.  
  2461. thePlayer.StopEffect(uninterruptedHitsCurrentCameraEffect);
  2462.  
  2463.  
  2464. if(uninterruptedHitsCurrentCameraEffect == theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_BIG_ENEMY)
  2465. uninterruptedHitsCurrentCameraEffect = theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_REGULAR_ENEMY;
  2466. else
  2467. uninterruptedHitsCurrentCameraEffect = theGame.params.UNINTERRUPTED_HITS_CAMERA_EFFECT_BIG_ENEMY;
  2468.  
  2469.  
  2470. thePlayer.PlayEffect(uninterruptedHitsCurrentCameraEffect);
  2471. }
  2472. }
  2473. }
  2474. }
  2475.  
  2476.  
  2477.  
  2478.  
  2479.  
  2480. private var playerActionEventListeners : array<CGameplayEntity>;
  2481. private var playerActionEventBlockingListeners : array<CGameplayEntity>;
  2482.  
  2483. private function PlayerActionBlockGameplayActions( sourceName : name, lock : bool, isFromPlace : bool )
  2484. {
  2485. if ( lock )
  2486. {
  2487. thePlayer.BlockAction( EIAB_Signs, sourceName, false, false, isFromPlace );
  2488. thePlayer.BlockAction( EIAB_DrawWeapon, sourceName, false, false, isFromPlace );
  2489. thePlayer.BlockAction( EIAB_CallHorse, sourceName, false, false, isFromPlace );
  2490. thePlayer.BlockAction( EIAB_FastTravel, sourceName, false, false, isFromPlace );
  2491. thePlayer.BlockAction( EIAB_Fists, sourceName, false, false, isFromPlace );
  2492. thePlayer.BlockAction( EIAB_InteractionAction, sourceName, false, false, isFromPlace );
  2493. thePlayer.DisableCombatState();
  2494. }
  2495. else
  2496. {
  2497. thePlayer.UnblockAction( EIAB_Signs, sourceName );
  2498. thePlayer.UnblockAction( EIAB_DrawWeapon, sourceName );
  2499. thePlayer.UnblockAction( EIAB_CallHorse, sourceName );
  2500. thePlayer.UnblockAction( EIAB_FastTravel, sourceName );
  2501. thePlayer.UnblockAction( EIAB_Fists, sourceName );
  2502. thePlayer.UnblockAction( EIAB_InteractionAction, sourceName );
  2503. }
  2504. }
  2505.  
  2506. public function GetPlayerActionEventListeners() : array<CGameplayEntity>
  2507. {
  2508. return playerActionEventListeners;
  2509. }
  2510.  
  2511.  
  2512. public function RegisterForPlayerAction( listener : CGameplayEntity, isLockedByPlace : bool )
  2513. {
  2514. if ( !playerActionEventListeners.Contains( listener ) )
  2515. {
  2516. playerActionEventListeners.PushBack( listener );
  2517. }
  2518. if ( listener.ShouldBlockGameplayActionsOnInteraction() )
  2519. {
  2520. if ( !playerActionEventBlockingListeners.Contains( listener ) )
  2521. {
  2522. playerActionEventBlockingListeners.PushBack( listener );
  2523. }
  2524. if ( playerActionEventBlockingListeners.Size() == 1 )
  2525. {
  2526. PlayerActionBlockGameplayActions( 'PlayerAction', true, isLockedByPlace );
  2527. }
  2528. }
  2529. }
  2530.  
  2531.  
  2532. public function UnregisterForPlayerAction( listener : CGameplayEntity, isLockedByPlace : bool )
  2533. {
  2534. playerActionEventListeners.Remove( listener );
  2535. playerActionEventBlockingListeners.Remove( listener );
  2536. if ( playerActionEventBlockingListeners.Size() == 0 )
  2537. {
  2538. PlayerActionBlockGameplayActions( 'PlayerAction', false, isLockedByPlace );
  2539. }
  2540. }
  2541.  
  2542. event OnPlayerActionStart()
  2543. {
  2544.  
  2545. thePlayer.SetBehaviorVariable( 'inJumpState', 1.f );
  2546. }
  2547.  
  2548. event OnPlayerActionEnd()
  2549. {
  2550. var i : int;
  2551. for ( i = playerActionEventListeners.Size() - 1; i >= 0; i-=1 )
  2552. {
  2553. playerActionEventListeners[i].OnPlayerActionEnd();
  2554. }
  2555. currentCustomAction = PEA_None;
  2556.  
  2557.  
  2558. thePlayer.SetBehaviorVariable( 'inJumpState', 0.f );
  2559. }
  2560.  
  2561. event OnPlayerActionStartFinished()
  2562. {
  2563. var i : int;
  2564. for ( i = playerActionEventListeners.Size() - 1; i >= 0; i-=1 )
  2565. {
  2566. playerActionEventListeners[i].OnPlayerActionStartFinished();
  2567. }
  2568. }
  2569.  
  2570. function PlayerStartAction( playerAction : EPlayerExplorationAction, optional animName : name ) : bool
  2571. {
  2572. if ( playerAction == PEA_SlotAnimation && !IsNameValid(animName) )
  2573. {
  2574. return false;
  2575. }
  2576.  
  2577. SetBehaviorVariable( 'playerStopAction', 0.0);
  2578. SetBehaviorVariable( 'playerExplorationAction', (float)(int)playerAction);
  2579.  
  2580.  
  2581.  
  2582. if ( RaiseForceEvent('playerActionStart') )
  2583. {
  2584. currentCustomAction = playerAction;
  2585. if ( playerAction == PEA_SlotAnimation )
  2586. {
  2587. playerActionSlotAnimName = animName;
  2588. AddTimer('PlayActionAnimWorkaround',0,false);
  2589. }
  2590. return true;
  2591. }
  2592. return false;
  2593. }
  2594.  
  2595. private var playerActionSlotAnimName : name;
  2596.  
  2597. timer function PlayActionAnimWorkaround( dt : float , id : int)
  2598. {
  2599. this.ActionPlaySlotAnimationAsync('PLAYER_ACTION_SLOT',playerActionSlotAnimName, 0.2, 0.2, true);
  2600. }
  2601.  
  2602. function PlayerStopAction( playerAction : EPlayerExplorationAction )
  2603. {
  2604. SetBehaviorVariable( 'playerExplorationAction', (float)(int)playerAction);
  2605. SetBehaviorVariable( 'playerStopAction', 1.0);
  2606. currentCustomAction = PEA_None;
  2607. }
  2608.  
  2609. function GetPlayerAction() : EPlayerExplorationAction
  2610. {
  2611. return currentCustomAction;
  2612. }
  2613.  
  2614. function MedallionPing()
  2615. {
  2616. var currTime : float = theGame.GetEngineTimeAsSeconds();
  2617.  
  2618. if ( lastMedallionEffect < currTime )
  2619. {
  2620. lastMedallionEffect = theGame.GetEngineTimeAsSeconds() + medallion.effectDuration;
  2621. medallion.TriggerMedallionFX();
  2622. }
  2623. }
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629. public function CanPerformPlayerAction(optional alsoOutsideExplorationState : bool) : bool
  2630. {
  2631.  
  2632. if(!alsoOutsideExplorationState && GetCurrentStateName() != 'Exploration')
  2633. return false;
  2634.  
  2635. if( isInAir || (substateManager && !substateManager.CanInteract()) || IsInCombatAction() || GetCriticalBuffsCount() > 0)
  2636. return false;
  2637.  
  2638. return true;
  2639. }
  2640.  
  2641.  
  2642. event OnItemGiven(data : SItemChangedData)
  2643. {
  2644. var keyName : name;
  2645. var i : int;
  2646. var hud : CR4ScriptedHud;
  2647. var message : string;
  2648. var inve : CInventoryComponent;
  2649.  
  2650. if(data.informGui)
  2651. {
  2652. hud = (CR4ScriptedHud)theGame.GetHud();
  2653. if(hud)
  2654. {
  2655. message = GetLocStringByKeyExt("panel_common_item_received") + ": " + GetLocStringByKeyExt(inv.GetItemLocalizedNameByUniqueID(data.ids[0]));
  2656. if(data.quantity > 1)
  2657. message += " x" + data.quantity;
  2658. hud.HudConsoleMsg(message);
  2659. }
  2660. }
  2661.  
  2662. inve = GetInventory();
  2663.  
  2664.  
  2665. if(inve.ItemHasTag(data.ids[0], 'key'))
  2666. {
  2667. keyName = inve.GetItemName(data.ids[0]);
  2668. for(i=nearbyLockedContainersNoKey.Size()-1; i>=0; i-=1)
  2669. {
  2670. if(nearbyLockedContainersNoKey[i].GetKeyName() == keyName && nearbyLockedContainersNoKey[i].IsEnabled())
  2671. {
  2672. nearbyLockedContainersNoKey[i].UpdateComponents("Unlock");
  2673. nearbyLockedContainersNoKey.Remove(nearbyLockedContainersNoKey[i]);
  2674. }
  2675. }
  2676. }
  2677.  
  2678.  
  2679. if(inve.IsItemAlchemyItem(data.ids[0]))
  2680. {
  2681. UpgradeAlchemyItem(data.ids[0], CanUseSkill(S_Perk_08));
  2682. }
  2683.  
  2684. if(inve.ItemHasTag(data.ids[0], theGame.params.TAG_OFIR_SET))
  2685. CheckOfirSetAchievement();
  2686. }
  2687.  
  2688. private final function CheckOfirSetAchievement()
  2689. {
  2690. var hasArmor, hasBoots, hasGloves, hasPants, hasSword, hasSaddle, hasBag, hasBlinders : bool;
  2691.  
  2692.  
  2693. CheckOfirItems(GetInventory(), hasArmor, hasBoots, hasGloves, hasPants, hasSword, hasSaddle, hasBag, hasBlinders);
  2694.  
  2695.  
  2696. CheckOfirItems(GetWitcherPlayer().GetHorseManager().GetInventoryComponent(), hasArmor, hasBoots, hasGloves, hasPants, hasSword, hasSaddle, hasBag, hasBlinders);
  2697.  
  2698. if(hasArmor && hasBoots && hasGloves && hasPants && hasSword && hasSaddle && hasBag && hasBlinders)
  2699. theGame.GetGamerProfile().AddAchievement(EA_LatestFashion);
  2700. }
  2701.  
  2702. 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)
  2703. {
  2704. var ofirs : array<SItemUniqueId>;
  2705. var i : int;
  2706.  
  2707. ofirs = inv.GetItemsByTag(theGame.params.TAG_OFIR_SET);
  2708. for(i=0; i<ofirs.Size(); i+=1)
  2709. {
  2710. if(inv.IsItemChestArmor(ofirs[i]))
  2711. {
  2712. hasArmor = true;
  2713. continue;
  2714. }
  2715. else if(inv.IsItemBoots(ofirs[i]))
  2716. {
  2717. hasBoots = true;
  2718. continue;
  2719. }
  2720. else if(inv.IsItemGloves(ofirs[i]))
  2721. {
  2722. hasGloves = true;
  2723. continue;
  2724. }
  2725. else if(inv.IsItemPants(ofirs[i]))
  2726. {
  2727. hasPants = true;
  2728. continue;
  2729. }
  2730. else if(inv.IsItemSteelSwordUsableByPlayer(ofirs[i]))
  2731. {
  2732. hasSword = true;
  2733. continue;
  2734. }
  2735. else if(inv.IsItemSilverSwordUsableByPlayer(ofirs[i]))
  2736. {
  2737. hasSword = true;
  2738. continue;
  2739. }
  2740. else if(inv.IsItemSaddle(ofirs[i]))
  2741. {
  2742. hasSaddle = true;
  2743. continue;
  2744. }
  2745. else if(inv.IsItemHorseBag(ofirs[i]))
  2746. {
  2747. hasBag = true;
  2748. continue;
  2749. }
  2750. else if(inv.IsItemBlinders(ofirs[i]))
  2751. {
  2752. hasBlinders = true;
  2753. continue;
  2754. }
  2755. }
  2756. }
  2757.  
  2758.  
  2759. public function ChangeAlchemyItemsAbilities(upgrade : bool)
  2760. {
  2761. var i : int;
  2762. var dm : CDefinitionsManagerAccessor;
  2763. var items : array<SItemUniqueId>;
  2764.  
  2765. inv.GetAllItems(items);
  2766. dm = theGame.GetDefinitionsManager();
  2767.  
  2768. for(i=0; i<items.Size(); i+=1)
  2769. if(inv.IsItemAlchemyItem(items[i]))
  2770. UpgradeAlchemyItem(items[i], upgrade);
  2771. }
  2772.  
  2773.  
  2774. public function UpgradeAlchemyItem(itemID : SItemUniqueId, upgrade : bool)
  2775. {
  2776. var j, currLevel, otherLevel : int;
  2777. var dm : CDefinitionsManagerAccessor;
  2778. var abs, currAbilities, otherAbilities : array<name>;
  2779. var min, max : SAbilityAttributeValue;
  2780.  
  2781. if(!inv.IsItemAlchemyItem(itemID))
  2782. return;
  2783.  
  2784.  
  2785. currLevel = (int)CalculateAttributeValue(inv.GetItemAttributeValue(itemID, 'level'));
  2786.  
  2787.  
  2788. if(currLevel == 3 || currLevel == 2 || currLevel < 2 || currLevel > 3)
  2789. return;
  2790.  
  2791.  
  2792. currAbilities = inv.GetItemAbilitiesWithAttribute(itemID, 'level', currLevel);
  2793.  
  2794.  
  2795. inv.GetItemContainedAbilities(itemID, abs);
  2796. dm = theGame.GetDefinitionsManager();
  2797. for(j=0; j<abs.Size(); j+=1)
  2798. {
  2799. dm.GetAbilityAttributeValue(abs[j], 'level', min, max);
  2800. otherLevel = (int)CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  2801. if( (otherLevel == 2 || otherLevel == 3) && otherLevel != currLevel)
  2802. otherAbilities.PushBack(abs[j]);
  2803. }
  2804.  
  2805.  
  2806. if(otherAbilities.Size() == 0)
  2807. {
  2808. LogAssert(false, "CR4Player.UpgradeAlchemyItem: cannot find ability to swap to from <<" + currAbilities[0] + ">> on item <<" + inv.GetItemName(itemID) + ">> !!!");
  2809. }
  2810. else
  2811. {
  2812. for(j=0; j<currAbilities.Size(); j+=1)
  2813. inv.RemoveItemBaseAbility(itemID, currAbilities[j]);
  2814.  
  2815. for(j=0; j<otherAbilities.Size(); j+=1)
  2816. inv.AddItemBaseAbility(itemID, otherAbilities[j]);
  2817. }
  2818. }
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824. public function MovAdjRotateToTarget( ticket : SMovementAdjustmentRequestTicket )
  2825. {
  2826. var movementAdjustor : CMovementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  2827. var localOrientationTarget : EOrientationTarget = GetOrientationTarget();
  2828.  
  2829. if ( localOrientationTarget == OT_CustomHeading )
  2830. {
  2831. movementAdjustor.RotateTo( ticket, GetOrientationTargetCustomHeading() );
  2832. }
  2833. else if ( localOrientationTarget == OT_Actor )
  2834. {
  2835. if ( slideTarget )
  2836. movementAdjustor.RotateTowards( ticket, slideTarget );
  2837. else if ( lAxisReleasedAfterCounter )
  2838. movementAdjustor.RotateTo( ticket, GetHeading() );
  2839. else
  2840. movementAdjustor.RotateTo( ticket, GetCombatActionHeading() );
  2841. }
  2842. else if ( localOrientationTarget == OT_Player )
  2843. {
  2844. if ( bLAxisReleased )
  2845. movementAdjustor.RotateTo( ticket, GetHeading() );
  2846. else
  2847. movementAdjustor.RotateTo( ticket, rawPlayerHeading );
  2848. }
  2849. else if ( localOrientationTarget == OT_CameraOffset )
  2850. {
  2851.  
  2852. movementAdjustor.RotateTo( ticket, VecHeading( theCamera.GetCameraDirection() ) );
  2853. }
  2854. else
  2855. {
  2856.  
  2857. movementAdjustor.RotateTo( ticket, rawCameraHeading );
  2858. }
  2859.  
  2860. }
  2861.  
  2862.  
  2863.  
  2864.  
  2865.  
  2866. public function UpdateLookAtTarget()
  2867. {
  2868. var localOrientationTarget : EOrientationTarget;
  2869. var playerRot : EulerAngles;
  2870. var lookAtActive : Float;
  2871. var lookAtTarget : Vector;
  2872. var headBoneIdx : int;
  2873. var tempComponent : CDrawableComponent;
  2874. var entityHeight : float;
  2875. var useTorsoBone : bool;
  2876.  
  2877. var angles : EulerAngles;
  2878. var dir : Vector;
  2879. var camZ : float;
  2880.  
  2881. var target : CActor;
  2882.  
  2883. lookAtActive = 0.0f;
  2884.  
  2885. localOrientationTarget = GetOrientationTarget();
  2886.  
  2887. if ( localOrientationTarget == OT_Player || localOrientationTarget == OT_CustomHeading )
  2888. {
  2889.  
  2890.  
  2891.  
  2892.  
  2893. if ( localOrientationTarget == OT_Player )
  2894. angles = VecToRotation( GetHeadingVector() );
  2895. else if ( customOrientationInfoStack.Size() > 0 )
  2896. angles = VecToRotation( VecFromHeading( customOrientationInfoStack[ customOrientationInfoStack.Size() - 1 ].customHeading ) );
  2897. else
  2898. angles = VecToRotation( GetHeadingVector() );
  2899.  
  2900.  
  2901. dir = RotForward( angles );
  2902. lookAtTarget = dir * 30.f + this.GetWorldPosition();
  2903. lookAtTarget.Z += 1.6f;
  2904. lookAtActive = 1.0f;
  2905. }
  2906. else if ( localOrientationTarget == OT_Camera )
  2907. {
  2908. headBoneIdx = GetHeadBoneIndex();
  2909. if ( headBoneIdx >= 0 )
  2910. {
  2911. lookAtTarget = MatrixGetTranslation( GetBoneWorldMatrixByIndex( headBoneIdx ) );
  2912. }
  2913. else
  2914. {
  2915. lookAtTarget = GetWorldPosition();
  2916. lookAtTarget.Z += 1.6f;
  2917. }
  2918. lookAtTarget += theCamera.GetCameraDirection() * 100.f;
  2919. lookAtActive = 1.0f;
  2920. }
  2921. else if ( localOrientationTarget == OT_CameraOffset )
  2922. {
  2923.  
  2924.  
  2925. dir = theCamera.GetCameraDirection();
  2926. angles = VecToRotation( dir );
  2927. angles.Pitch = -angles.Pitch + oTCameraPitchOffset;
  2928. angles.Yaw -= oTCameraOffset;
  2929. dir = RotForward( angles );
  2930.  
  2931. lookAtTarget = dir * 30.f + this.GetWorldPosition();
  2932. lookAtTarget.Z += 1.6f;
  2933. lookAtActive = 1.0f;
  2934. }
  2935. else if ( localOrientationTarget == OT_Actor )
  2936. {
  2937. if ( IsInCombatAction() )
  2938. {
  2939. if ( ( ( ( W3PlayerWitcher )this ).GetCurrentlyCastSign() != ST_None && GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign )
  2940. || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_ItemThrow )
  2941.  
  2942. useTorsoBone = true;
  2943. }
  2944.  
  2945. if ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  2946. useTorsoBone = true;
  2947.  
  2948. if ( tempLookAtTarget && (CActor)(tempLookAtTarget) )
  2949. {
  2950. lookAtTarget = ProcessLookAtTargetPosition( tempLookAtTarget, useTorsoBone );
  2951. lookAtActive = 1.0f;
  2952. }
  2953.  
  2954. if ( GetDisplayTarget() && IsDisplayTargetTargetable() )
  2955. {
  2956. lookAtTarget = ProcessLookAtTargetPosition( GetDisplayTarget(), useTorsoBone );
  2957. lookAtActive = 1.0f;
  2958. }
  2959. else
  2960. {
  2961.  
  2962.  
  2963. if ( slideTarget )
  2964. {
  2965. lookAtTarget = ProcessLookAtTargetPosition( slideTarget, useTorsoBone );
  2966. }
  2967. else
  2968. {
  2969. target = GetTarget();
  2970. if ( target )
  2971. {
  2972. lookAtTarget = ProcessLookAtTargetPosition( target, useTorsoBone );
  2973. }
  2974. }
  2975.  
  2976. lookAtActive = 1.0f;
  2977. }
  2978.  
  2979. if ( !slideTarget && !IsUsingVehicle() )
  2980. {
  2981.  
  2982. playerRot = GetWorldRotation();
  2983. lookAtTarget = GetWorldPosition() + VecFromHeading( playerRot.Yaw ) * 100.0f;
  2984. lookAtActive = 0.0f;
  2985. }
  2986.  
  2987. if ( useTorsoBone )
  2988. lookAtTarget.Z += 0.2f;
  2989. }
  2990.  
  2991.  
  2992.  
  2993.  
  2994. GetVisualDebug().AddSphere('lookAtTarget', 1.f, lookAtTarget, true, Color(255,0,0), 3.0f );
  2995. SetLookAtPosition( lookAtTarget );
  2996. UpdateLookAtVariables( lookAtActive, lookAtTarget );
  2997. }
  2998.  
  2999. private function ProcessLookAtTargetPosition( ent : CGameplayEntity, useTorsoBone : bool ) : Vector
  3000. {
  3001. var boneIdx : int;
  3002. var actor : CActor;
  3003. var lookAtTarget : Vector;
  3004. var tempComponent : CDrawableComponent;
  3005. var box : Box;
  3006. var entityHeight : float;
  3007. var entityPos : Vector;
  3008. var predictedPos : Vector;
  3009. var z : float;
  3010. var entMat : Matrix;
  3011.  
  3012. actor = (CActor)(ent);
  3013. entityPos = ent.GetWorldPosition();
  3014. lookAtTarget = entityPos;
  3015.  
  3016. if ( actor )
  3017. {
  3018. if ( useTorsoBone )
  3019. boneIdx = actor.GetTorsoBoneIndex();
  3020. else
  3021. boneIdx = actor.GetHeadBoneIndex();
  3022. }
  3023. else
  3024. boneIdx = -1;
  3025.  
  3026. if ( !( ent.aimVector.X == 0 && ent.aimVector.Y == 0 && ent.aimVector.Z == 0 ) )
  3027. {
  3028. entMat = ent.GetLocalToWorld();
  3029. lookAtTarget = VecTransform( entMat, ent.aimVector );
  3030. }
  3031. else if ( boneIdx >= 0 )
  3032. {
  3033. lookAtTarget = MatrixGetTranslation( ent.GetBoneWorldMatrixByIndex( boneIdx ) );
  3034. }
  3035. else
  3036. {
  3037. if ( actor )
  3038. lookAtTarget.Z += ( ((CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent()).GetCapsuleHeight() * 0.5 );
  3039. else
  3040. {
  3041. tempComponent = (CDrawableComponent)( ent.GetComponentByClassName('CDrawableComponent') );
  3042. if ( tempComponent.GetObjectBoundingVolume( box ) )
  3043. {
  3044. entityHeight = box.Max.Z - box.Min.Z;
  3045. lookAtTarget = lookAtTarget + Vector(0,0,entityHeight/2);
  3046. }
  3047. }
  3048. }
  3049. z = ((CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent()).GetCapsuleHeight();
  3050. if ( actor )
  3051. {
  3052. if ( PredictLookAtTargetPosition( actor, lookAtTarget.Z - entityPos.Z, predictedPos ) )
  3053. lookAtTarget = predictedPos;
  3054. }
  3055.  
  3056. return lookAtTarget;
  3057. }
  3058.  
  3059.  
  3060. private function PredictLookAtTargetPosition( targetActor : CActor, zOffSet : float, out predictedPos : Vector ) : bool
  3061. {
  3062. var virtualPos : Vector;
  3063. var i : int;
  3064. var dist : float;
  3065. var deltaTime : float;
  3066. var projSpeed : float;
  3067. var projSpeedInt : Vector;
  3068. var projAngle : float;
  3069.  
  3070. var e3Hack : bool;
  3071. var currentTimeInCurve : float;
  3072. e3Hack = false;
  3073.  
  3074. if ( rangedWeapon
  3075. && rangedWeapon.GetDeployedEntity()
  3076. && ( rangedWeapon.GetCurrentStateName() == 'State_WeaponAim' || rangedWeapon.GetCurrentStateName() == 'State_WeaponShoot' ) )
  3077. {
  3078. projSpeed = rangedWeapon.GetDeployedEntity().projSpeed;
  3079.  
  3080. virtualPos = targetActor.GetWorldPosition();
  3081.  
  3082. if ( e3Hack && targetActor.HasTag( 'e3_griffin' ) )
  3083. {
  3084. for ( i = 0; i < 10; i += 1 )
  3085. {
  3086. dist = VecDistance( rangedWeapon.GetDeployedEntity().GetWorldPosition(), virtualPos );
  3087. deltaTime = dist/projSpeed;
  3088. virtualPos = targetActor.PredictWorldPosition( deltaTime );
  3089. }
  3090. }
  3091. else
  3092. return false;
  3093.  
  3094. virtualPos.Z += zOffSet;
  3095. predictedPos = virtualPos;
  3096. GetVisualDebug().AddSphere('CrossbowPredictedPos', 1.0f, virtualPos , true, Color(255,50,50), 5.0f );
  3097. return true;
  3098. }
  3099. return false;
  3100. }
  3101.  
  3102. public function SetLookAtPosition( vec : Vector )
  3103. {
  3104. lookAtPosition = vec;
  3105. }
  3106.  
  3107. public function GetLookAtPosition() : Vector
  3108. {
  3109. return lookAtPosition;
  3110. }
  3111.  
  3112.  
  3113.  
  3114.  
  3115.  
  3116. event OnBlockingSceneEnded( optional output : CStorySceneOutput)
  3117. {
  3118.  
  3119. SetImmortalityMode( AIM_None, AIC_SyncedAnim );
  3120. super.OnBlockingSceneEnded(output);
  3121. }
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127. function GetCurrentMeleeWeaponName() : name
  3128. {
  3129. return weaponHolster.GetCurrentMeleeWeaponName();
  3130. }
  3131.  
  3132. public function GetCurrentMeleeWeaponType() : EPlayerWeapon
  3133. {
  3134. return weaponHolster.GetCurrentMeleeWeapon();
  3135. }
  3136.  
  3137. public function OnMeleeForceHolster(ignoreActionLock : bool)
  3138. {
  3139. weaponHolster.HolsterWeapon(ignoreActionLock, true);
  3140. }
  3141.  
  3142. event OnForcedHolsterWeapon()
  3143. {
  3144. weaponHolster.OnForcedHolsterWeapon();
  3145. }
  3146.  
  3147. event OnEquippedItem( category : name, slotName : name )
  3148. {
  3149. var weaponType : EPlayerWeapon;
  3150.  
  3151. if ( slotName == 'r_weapon' )
  3152. {
  3153. switch ( category )
  3154. {
  3155. case 'None' :
  3156. weaponType = PW_None;
  3157. break;
  3158. case 'fist' :
  3159. weaponType = PW_Fists;
  3160. break;
  3161. case 'steelsword' :
  3162. weaponType = PW_Steel;
  3163. break;
  3164. case 'silversword' :
  3165. weaponType = PW_Silver;
  3166. break;
  3167. default :
  3168. return true;
  3169. }
  3170.  
  3171. weaponHolster.OnEquippedMeleeWeapon( weaponType );
  3172. }
  3173. }
  3174.  
  3175. private var isHoldingDeadlySword : bool;
  3176. public function ProcessIsHoldingDeadlySword()
  3177. {
  3178. isHoldingDeadlySword = IsDeadlySwordHeld();
  3179. }
  3180.  
  3181. public function IsHoldingDeadlySword() : bool
  3182. {
  3183. return isHoldingDeadlySword;
  3184. }
  3185.  
  3186. event OnHolsteredItem( category : name, slotName : name )
  3187. {
  3188. var weaponType : EPlayerWeapon;
  3189.  
  3190.  
  3191. if ( slotName == 'r_weapon' && (category == 'steelsword' || category == 'silversword') )
  3192. {
  3193. if( category == 'silversword' )
  3194. {
  3195. ManageAerondightBuff( false );
  3196. }
  3197.  
  3198. GetBuff( EET_LynxSetBonus ).Pause( 'drawing weapon' );
  3199.  
  3200. PauseOilBuffs( category == 'steelsword' );
  3201. }
  3202.  
  3203. if ( slotName == 'r_weapon' )
  3204. {
  3205. weaponType = weaponHolster.GetCurrentMeleeWeapon();
  3206. switch ( category )
  3207. {
  3208. case 'fist' :
  3209. if ( weaponType == PW_Fists )
  3210. weaponHolster.OnEquippedMeleeWeapon( PW_None );
  3211. return true;
  3212. case 'steelsword' :
  3213. if ( weaponType == PW_Steel )
  3214. weaponHolster.OnEquippedMeleeWeapon( PW_None );
  3215. return true;
  3216. case 'silversword' :
  3217. if ( weaponType == PW_Silver )
  3218. weaponHolster.OnEquippedMeleeWeapon( PW_None );
  3219. return true;
  3220. default :
  3221. return true;
  3222. }
  3223. }
  3224. }
  3225.  
  3226. event OnEquipMeleeWeapon( weaponType : EPlayerWeapon, ignoreActionLock : bool, optional sheatheIfAlreadyEquipped : bool )
  3227. {
  3228. RemoveTimer( 'DelayedSheathSword' );
  3229.  
  3230. weaponHolster.OnEquipMeleeWeapon( weaponType, ignoreActionLock, sheatheIfAlreadyEquipped );
  3231.  
  3232.  
  3233.  
  3234. m_RefreshWeaponFXType = true;
  3235. }
  3236.  
  3237. event OnHolsterLeftHandItem()
  3238. {
  3239. weaponHolster.OnHolsterLeftHandItem();
  3240. }
  3241.  
  3242. timer function DelayedTryToReequipWeapon( dt: float, id : int )
  3243. {
  3244. var weaponType : EPlayerWeapon;
  3245.  
  3246. if( IsInCombat() && GetTarget() )
  3247. {
  3248. weaponType = GetMostConvenientMeleeWeapon( GetTarget() );
  3249.  
  3250. if ( weaponType == PW_Steel || weaponType == PW_Silver )
  3251. weaponHolster.OnEquipMeleeWeapon( weaponType, false );
  3252. }
  3253. }
  3254.  
  3255. timer function DelayedSheathSword( dt: float, id : int )
  3256. {
  3257. if ( !IsCombatMusicEnabled() )
  3258. {
  3259. if ( IsInCombatAction() || !IsActionAllowed( EIAB_DrawWeapon ) )
  3260. {
  3261. LogChannel( 'OnCombatFinished', "DelayedSheathSword: Sheath pushed to buffer" );
  3262. PushCombatActionOnBuffer(EBAT_Sheathe_Sword,BS_Pressed);
  3263. }
  3264. else
  3265. {
  3266. LogChannel( 'OnCombatFinished', "DelayedSheathSword: Sheath successful" );
  3267. OnEquipMeleeWeapon( PW_None, false );
  3268. }
  3269. }
  3270. }
  3271.  
  3272. protected function ShouldAutoSheathSwordInstantly() : bool
  3273. {
  3274. var enemies : array<CActor>;
  3275. var i : int;
  3276.  
  3277. GetEnemiesInRange( enemies );
  3278.  
  3279. for ( i = 0; i < enemies.Size(); i += 1 )
  3280. {
  3281. if ( IsThreat( enemies[i] ) &&
  3282. VecDistance( enemies[i].GetWorldPosition(), this.GetWorldPosition() ) <= findMoveTargetDist )
  3283. {
  3284. return false;
  3285. }
  3286. }
  3287.  
  3288. return true;
  3289. }
  3290.  
  3291. public function PrepareToAttack( optional target : CActor, optional action : EBufferActionType )
  3292. {
  3293. var weaponType : EPlayerWeapon;
  3294.  
  3295. if( IsInAir() || !GetBIsCombatActionAllowed() )
  3296. {
  3297. return ;
  3298. }
  3299.  
  3300. if( !target )
  3301. {
  3302. target = (CActor)displayTarget;
  3303. }
  3304. if( !target && IsCombatMusicEnabled() )
  3305. {
  3306. target = moveTarget;
  3307. }
  3308. if( !target )
  3309. {
  3310. if ( this.GetCurrentStateName() == 'Exploration' )
  3311. {
  3312. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  3313. thePlayer.CanAttackWhenNotInCombat( action, false, target );
  3314. }
  3315. }
  3316.  
  3317. weaponHolster.TryToPrepareMeleeWeaponToAttack();
  3318.  
  3319.  
  3320. {
  3321. weaponType = GetCurrentMeleeWeaponType();
  3322.  
  3323. if ( weaponType == PW_None )
  3324. {
  3325.  
  3326. weaponType = GetMostConvenientMeleeWeapon( target );
  3327. }
  3328.  
  3329.  
  3330. if( !OnStateCanGoToCombat() )
  3331. {
  3332. return;
  3333. }
  3334.  
  3335. GoToCombat( weaponType );
  3336. }
  3337. }
  3338.  
  3339. public function DisplayCannotAttackMessage( actor : CActor ) : bool
  3340. {
  3341. if ( actor && ( actor.GetMovingAgentComponent().GetName() == "child_base" || ((CNewNPC)actor).GetNPCType() == ENGT_Quest ) )
  3342. {
  3343. DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_cant_attack_this_target"));
  3344. return true;
  3345. }
  3346.  
  3347. return false;
  3348. }
  3349.  
  3350. public function GetMostConvenientMeleeWeapon( targetToDrawAgainst : CActor, optional ignoreActionLock : bool ) : EPlayerWeapon
  3351. {
  3352. return weaponHolster.GetMostConvenientMeleeWeapon( targetToDrawAgainst, ignoreActionLock );
  3353. }
  3354.  
  3355. private var reevaluateCurrentWeapon : bool;
  3356.  
  3357. event OnTargetWeaponDrawn()
  3358. {
  3359. var weaponType : EPlayerWeapon = this.GetCurrentMeleeWeaponType();
  3360. if ( weaponType == PW_Fists )
  3361. reevaluateCurrentWeapon = true;
  3362. }
  3363.  
  3364. public function GoToCombatIfNeeded( optional enemy : CActor ) : bool
  3365. {
  3366. var weaponType : EPlayerWeapon;
  3367. var target : CActor;
  3368.  
  3369. if( !enemy && IsInCombat() )
  3370. {
  3371. target = GetTarget();
  3372.  
  3373. if ( target )
  3374. enemy = target;
  3375. else
  3376. enemy = moveTarget;
  3377. }
  3378.  
  3379.  
  3380. if( !ShouldGoToCombat( enemy ) )
  3381. {
  3382. return false;
  3383. }
  3384.  
  3385. weaponType = this.GetCurrentMeleeWeaponType();
  3386.  
  3387. if ( weaponType == PW_None || ( reevaluateCurrentWeapon && weaponType == PW_Fists ) || ( !IsInCombat() && weaponHolster.IsOnTheMiddleOfHolstering() ) )
  3388. {
  3389.  
  3390. weaponType = weaponHolster.GetMostConvenientMeleeWeapon( enemy );
  3391. reevaluateCurrentWeapon = false;
  3392. }
  3393.  
  3394.  
  3395. GoToCombat( weaponType );
  3396.  
  3397.  
  3398. return true;
  3399. }
  3400.  
  3401. public function GoToCombatIfWanted( ) : bool
  3402. {
  3403. var weaponType : EPlayerWeapon;
  3404. var target : CActor;
  3405. var enemy : CActor;
  3406.  
  3407.  
  3408. if( !IsInCombat() )
  3409. {
  3410. return false;
  3411. }
  3412.  
  3413. target = GetTarget();
  3414.  
  3415. if ( target )
  3416. enemy = target;
  3417. else
  3418. enemy = moveTarget;
  3419.  
  3420. weaponType = this.GetCurrentMeleeWeaponType();
  3421.  
  3422. if ( weaponType == PW_None || ( !IsInCombat() && weaponHolster.IsOnTheMiddleOfHolstering() ) )
  3423. {
  3424.  
  3425. weaponType = weaponHolster.GetMostConvenientMeleeWeapon( enemy );
  3426. }
  3427.  
  3428.  
  3429. GoToCombat( weaponType );
  3430.  
  3431.  
  3432. return true;
  3433. }
  3434.  
  3435. public function GoToExplorationIfNeeded() : bool
  3436. {
  3437.  
  3438.  
  3439. if( ! IsInCombatState() )
  3440. {
  3441. return false;
  3442. }
  3443.  
  3444. if( !ShouldGoToExploration() )
  3445. {
  3446. return false;
  3447. }
  3448.  
  3449.  
  3450. weaponHolster.EndedCombat();
  3451.  
  3452.  
  3453. GotoState( 'Exploration' );
  3454. return true;
  3455. }
  3456.  
  3457. event OnStateCanGoToCombat()
  3458. {
  3459. return false;
  3460. }
  3461.  
  3462. event OnStateCanUpdateExplorationSubstates()
  3463. {
  3464. return false;
  3465. }
  3466.  
  3467. private function ShouldGoToCombat( optional enemy : CActor ) : bool
  3468. {
  3469. var currentStateName : name;
  3470.  
  3471.  
  3472. if( !OnStateCanGoToCombat() )
  3473. {
  3474. return false;
  3475. }
  3476.  
  3477. currentStateName = GetCurrentStateName();
  3478.  
  3479. if( currentStateName == 'AimThrow' )
  3480. {
  3481. return false;
  3482. }
  3483.  
  3484. if( currentStateName == 'Swimming' )
  3485. {
  3486. return false;
  3487. }
  3488.  
  3489. if( currentStateName == 'TraverseExploration' )
  3490. {
  3491. return false;
  3492. }
  3493.  
  3494.  
  3495.  
  3496.  
  3497.  
  3498.  
  3499. if ( !enemy )
  3500. {
  3501. return playerMode.combatMode;
  3502. }
  3503.  
  3504.  
  3505.  
  3506.  
  3507.  
  3508. return true;
  3509. }
  3510.  
  3511. private function ShouldGoToExploration() : bool
  3512. {
  3513. if ( IsInCombat() )
  3514. {
  3515. return false;
  3516. }
  3517.  
  3518. if ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  3519. {
  3520. return false;
  3521. }
  3522. if( IsFistFightMinigameEnabled() )
  3523. {
  3524. return false;
  3525. }
  3526. if( IsKnockedUnconscious() )
  3527. {
  3528. return false;
  3529. }
  3530. if( IsInCombatAction() )
  3531. {
  3532. return false;
  3533. }
  3534. if( GetCriticalBuffsCount() > 0 )
  3535. {
  3536. return false;
  3537. }
  3538.  
  3539. return true;
  3540. }
  3541.  
  3542. private function GoToCombat( weaponType : EPlayerWeapon, optional initialAction : EInitialAction )
  3543. {
  3544.  
  3545. switch( weaponType )
  3546. {
  3547. case PW_Silver:
  3548. ((W3PlayerWitcherStateCombatSilver) GetState('CombatSilver')).SetupState( initialAction );
  3549. GoToStateIfNew( 'CombatSilver' );
  3550. break;
  3551. case PW_Steel:
  3552. ((W3PlayerWitcherStateCombatSteel) GetState('CombatSteel')).SetupState( initialAction );
  3553. GoToStateIfNew( 'CombatSteel' );
  3554. break;
  3555. case PW_Fists:
  3556. case PW_None:
  3557. default :
  3558. ((W3PlayerWitcherStateCombatFists) GetState('CombatFists')).SetupState( initialAction );
  3559. GoToStateIfNew( 'CombatFists' );
  3560. break;
  3561. }
  3562. }
  3563.  
  3564. public function GoToStateIfNew( newState : name, optional keepStack : bool, optional forceEvents : bool )
  3565. {
  3566. if( newState != GetCurrentStateName() )
  3567. {
  3568. GotoState( newState, keepStack, forceEvents );
  3569. }
  3570. }
  3571.  
  3572.  
  3573. public function GotoState( newState : name, optional keepStack : bool, optional forceEvents : bool )
  3574. {
  3575.  
  3576.  
  3577. super.GotoState( newState, keepStack, forceEvents );
  3578.  
  3579. }
  3580.  
  3581. public function IsThisACombatSuperState( stateName : name ) : bool
  3582. {
  3583. return stateName == 'Combat' || stateName == 'CombatSteel' || stateName == 'CombatSilver' || stateName == 'CombatFists';
  3584. }
  3585.  
  3586. public function GetWeaponHolster() : WeaponHolster
  3587. {
  3588. return weaponHolster;
  3589. }
  3590.  
  3591. public function AbortSign()
  3592. {
  3593. var playerWitcher : W3PlayerWitcher;
  3594. var sign : W3SignEntity;
  3595.  
  3596. playerWitcher = (W3PlayerWitcher)this;
  3597.  
  3598. if(playerWitcher)
  3599. {
  3600. sign = (W3SignEntity)playerWitcher.GetCurrentSignEntity();
  3601. if (sign)
  3602. {
  3603. sign.OnSignAborted();
  3604. }
  3605. }
  3606. }
  3607.  
  3608.  
  3609.  
  3610.  
  3611. protected var disableActionBlend : bool;
  3612.  
  3613.  
  3614.  
  3615.  
  3616. event OnAnimEvent_DisallowHitAnim( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3617. {
  3618. if ( animEventType == AET_DurationEnd )
  3619. {
  3620. if ( ( BufferCombatAction == EBAT_Dodge || BufferCombatAction == EBAT_Roll )
  3621. && IsInCombatAction()
  3622. && GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
  3623. {
  3624.  
  3625. ( (CR4Player)this ).ProcessCombatActionBuffer();
  3626. disableActionBlend = true;
  3627. }
  3628. }
  3629. else if ( IsInCombatAction() && GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Dodge && animEventType == AET_DurationStart )
  3630. {
  3631. disableActionBlend = false;
  3632. }
  3633.  
  3634. super.OnAnimEvent_DisallowHitAnim( animEventName, animEventType, animInfo );
  3635. }
  3636.  
  3637.  
  3638. event OnAnimEvent_FadeOut( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3639. {
  3640. theGame.FadeOutAsync( 0.2, Color( 0, 0, 0, 1 ) );
  3641. }
  3642.  
  3643. event OnAnimEvent_FadeIn( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3644. {
  3645. theGame.FadeInAsync( 0.4 );
  3646. }
  3647.  
  3648. event OnAnimEvent_BloodTrailForced( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3649. {
  3650. var bloodTrailParam : CBloodTrailEffect;
  3651. var weaponId : SItemUniqueId;
  3652.  
  3653. if ( isInFinisher )
  3654. {
  3655. bloodTrailParam = (CBloodTrailEffect)(GetFinisherVictim()).GetGameplayEntityParam( 'CBloodTrailEffect' );
  3656. weaponId = this.inv.GetItemFromSlot('r_weapon');
  3657. if ( bloodTrailParam )
  3658. thePlayer.inv.PlayItemEffect( weaponId, bloodTrailParam.GetEffectName() );
  3659. }
  3660. }
  3661.  
  3662. event OnAnimEvent_SlowMo( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3663. {
  3664. if ( isInFinisher && DisableManualCameraControlStackHasSource( 'Finisher' ) )
  3665. {
  3666. if( animEventType != AET_DurationEnd )
  3667. theGame.SetTimeScale( 0.1f, 'AnimEventSlomoMo', 1000, true );
  3668. else
  3669. theGame.RemoveTimeScale( 'AnimEventSlomoMo' );
  3670. }
  3671. }
  3672.  
  3673. event OnAnimEvent_PlayFinisherBlood( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3674. {
  3675. if ( isInFinisher )
  3676. {
  3677. SpawnFinisherBlood();
  3678. }
  3679. }
  3680.  
  3681. event OnAnimEvent_OnWeaponDrawReady( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3682. {
  3683. weaponHolster.OnWeaponDrawReady();
  3684. }
  3685.  
  3686. event OnAnimEvent_OnWeaponHolsterReady( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3687. {
  3688. weaponHolster.OnWeaponHolsterReady();
  3689. }
  3690.  
  3691. event OnAnimEvent_ThrowHoldTest( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3692. {
  3693. var thrownEntity : CThrowable;
  3694.  
  3695. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  3696.  
  3697. if( IsThrowHold() )
  3698. {
  3699. SetBehaviorVariable( 'throwStage', (int)TS_Loop );
  3700. PushState( 'AimThrow' );
  3701. thrownEntity.StartAiming();
  3702. }
  3703. else
  3704. {
  3705. BombThrowRelease();
  3706. SetCombatIdleStance( 1.f );
  3707. }
  3708. }
  3709.  
  3710. event OnAnimEvent_AllowTempLookAt( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3711. {
  3712. if( animEventType == AET_DurationStart )
  3713. SetTempLookAtTarget( slideTarget );
  3714. else if( animEventType == AET_DurationEnd )
  3715. SetTempLookAtTarget( NULL );
  3716. }
  3717.  
  3718. protected var slideNPC : CNewNPC;
  3719. protected var minSlideDistance : float;
  3720. protected var maxSlideDistance : float;
  3721. protected var slideTicket : SMovementAdjustmentRequestTicket;
  3722.  
  3723. event OnAnimEvent_SlideToTarget( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3724. {
  3725. var movementAdjustor : CMovementAdjustor;
  3726.  
  3727. if( animEventType == AET_DurationStart )
  3728. {
  3729. slideNPC = (CNewNPC)slideTarget;
  3730. }
  3731.  
  3732. if( !slideNPC )
  3733. {
  3734. return false;
  3735. }
  3736.  
  3737. if( animEventType == AET_DurationStart && slideNPC.GetGameplayVisibility() )
  3738. {
  3739. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  3740. slideTicket = movementAdjustor.GetRequest( 'SlideToTarget' );
  3741. movementAdjustor.CancelByName( 'SlideToTarget' );
  3742. slideTicket = movementAdjustor.CreateNewRequest( 'SlideToTarget' );
  3743. movementAdjustor.BindToEventAnimInfo( slideTicket, animInfo );
  3744.  
  3745. movementAdjustor.MaxLocationAdjustmentSpeed( slideTicket, 1000000 );
  3746. movementAdjustor.ScaleAnimation( slideTicket );
  3747. minSlideDistance = ((CMovingPhysicalAgentComponent)this.GetMovingAgentComponent()).GetCapsuleRadius()+((CMovingPhysicalAgentComponent)slideNPC.GetMovingAgentComponent()).GetCapsuleRadius();
  3748. if( IsInCombatFist() )
  3749. {
  3750. maxSlideDistance = 1000.0f;
  3751. }
  3752. else
  3753. {
  3754. maxSlideDistance = minSlideDistance;
  3755. }
  3756. movementAdjustor.SlideTowards( slideTicket, slideTarget, minSlideDistance, maxSlideDistance );
  3757. }
  3758. else if( !slideNPC.GetGameplayVisibility() )
  3759. {
  3760. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  3761. movementAdjustor.CancelByName( 'SlideToTarget' );
  3762. slideNPC = NULL;
  3763. }
  3764. else
  3765. {
  3766. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  3767. movementAdjustor.SlideTowards( slideTicket, slideTarget, minSlideDistance, maxSlideDistance );
  3768. }
  3769. }
  3770.  
  3771. event OnAnimEvent_ActionBlend( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3772. {
  3773. }
  3774.  
  3775.  
  3776. event OnAnimEvent_SubstateManager( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3777. {
  3778.  
  3779. substateManager.OnAnimEvent( animEventName, animEventType, animInfo );
  3780. }
  3781.  
  3782. event OnAnimEvent_AllowFall( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3783. {
  3784. if ( !substateManager.m_OwnerMAC.IsOnGround() )
  3785. {
  3786. substateManager.m_SharedDataO.SetFallFromCritical( true );
  3787. substateManager.m_MoverO.SetVelocity( -6.0f * GetWorldForward() );
  3788. substateManager.QueueStateExternal( 'Jump' );
  3789. RemoveBuff( EET_Knockdown, true );
  3790. RemoveBuff( EET_HeavyKnockdown, true );
  3791. return true;
  3792. }
  3793. return false;
  3794. }
  3795.  
  3796. event OnAnimEvent_AllowFall2( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3797. {
  3798. if ( !substateManager.m_OwnerMAC.IsOnGround() )
  3799. {
  3800.  
  3801.  
  3802. substateManager.QueueStateExternal( 'Jump' );
  3803. RemoveBuff( EET_Knockdown, true );
  3804. RemoveBuff( EET_HeavyKnockdown, true );
  3805. }
  3806. if( substateManager.StateWantsAndCanEnter( 'Slide' ) )
  3807. {
  3808. substateManager.QueueStateExternal( 'Slide' );
  3809. }
  3810. }
  3811.  
  3812. event OnAnimEvent_DettachGround( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3813. {
  3814.  
  3815. }
  3816.  
  3817.  
  3818. event OnAnimEvent_pad_vibration( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3819. {
  3820. var witcher : W3PlayerWitcher;
  3821.  
  3822. theGame.VibrateControllerHard();
  3823.  
  3824.  
  3825. witcher = GetWitcherPlayer();
  3826. if(isInFinisher && witcher)
  3827. {
  3828. if(HasAbility('Runeword 10 _Stats', true) && !witcher.runeword10TriggerredOnFinisher && ((bool)theGame.GetInGameConfigWrapper().GetVarValue('Gameplay', 'AutomaticFinishersEnabled')) == true)
  3829. {
  3830. witcher.Runeword10Triggerred();
  3831. witcher.runeword10TriggerredOnFinisher = true;
  3832. }
  3833. else if(HasAbility('Runeword 12 _Stats', true) && !witcher.runeword12TriggerredOnFinisher)
  3834. {
  3835. witcher.Runeword12Triggerred();
  3836. witcher.runeword12TriggerredOnFinisher = true;
  3837. }
  3838. }
  3839. }
  3840.  
  3841.  
  3842. event OnAnimEvent_pad_vibration_light( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3843. {
  3844.  
  3845. }
  3846.  
  3847. event OnAnimEvent_KillWithRagdoll( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3848. {
  3849.  
  3850.  
  3851. }
  3852.  
  3853. event OnAnimEvent_RemoveBurning( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3854. {
  3855. thePlayer.AddBuffImmunity(EET_Burning, 'AnimEvent_RemoveBurning', true);
  3856. }
  3857.  
  3858. event OnAnimEvent_RemoveTangled( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3859. {
  3860. if ( this.HasBuff( EET_Tangled ) )
  3861. {
  3862. this.StopEffect('black_spider_web');
  3863. this.PlayEffectSingle('black_spider_web_break');
  3864. }
  3865. }
  3866.  
  3867.  
  3868. event OnAnimEvent_MoveNoise( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3869. {
  3870. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'MoveNoise', -1, 30.0f, -1.f, -1, true );
  3871. }
  3872.  
  3873.  
  3874. event OnBehaviorGraphNotification( notificationName : name, stateName : name )
  3875. {
  3876. substateManager.OnBehaviorGraphNotification( notificationName, stateName );
  3877.  
  3878. if( notificationName == 'PlayerRunActivate' )
  3879. {
  3880. isInRunAnimation = true;
  3881. }
  3882. else if( notificationName == 'PlayerRunDeactivate' )
  3883. {
  3884. isInRunAnimation = false;
  3885. }
  3886. }
  3887.  
  3888. event OnEnumAnimEvent( animEventName : name, variant : SEnumVariant, animEventType : EAnimationEventType, animEventDuration : float, animInfo : SAnimationEventAnimInfo )
  3889. {
  3890. var movementAdjustor : CMovementAdjustor;
  3891. var ticket : SMovementAdjustmentRequestTicket;
  3892. var rotationRate : ERotationRate;
  3893.  
  3894. if ( animEventName == 'RotateToTarget' )
  3895. {
  3896.  
  3897. rotationRate = GetRotationRateFromAnimEvent( variant.enumValue );
  3898.  
  3899. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  3900. if ( animEventType == AET_DurationStart || animEventType == AET_DurationStartInTheMiddle )
  3901. {
  3902.  
  3903.  
  3904. if (! movementAdjustor.IsRequestActive( movementAdjustor.GetRequest( 'RotateToTarget' ) ) )
  3905. {
  3906.  
  3907. ticket = movementAdjustor.CreateNewRequest( 'RotateToTarget' );
  3908.  
  3909.  
  3910. if ((int)rotationRate == 0)
  3911. movementAdjustor.AdjustmentDuration( ticket, animEventDuration );
  3912. else
  3913. {
  3914. movementAdjustor.Continuous( ticket );
  3915. movementAdjustor.BindToEvent( ticket, 'RotateToTarget' );
  3916. }
  3917.  
  3918. movementAdjustor.DontUseSourceAnimation( ticket );
  3919. movementAdjustor.ReplaceRotation( ticket );
  3920. }
  3921. else
  3922. {
  3923.  
  3924. ticket = movementAdjustor.GetRequest( 'RotateToTarget' );
  3925. }
  3926. MovAdjRotateToTarget( ticket );
  3927.  
  3928. if ((int)rotationRate > 0)
  3929. {
  3930. movementAdjustor.MaxRotationAdjustmentSpeed( ticket, (float)((int)rotationRate) );
  3931. }
  3932. }
  3933. else if ( animEventType == AET_DurationEnd )
  3934. {
  3935.  
  3936.  
  3937. }
  3938. else
  3939. {
  3940.  
  3941. ticket = movementAdjustor.GetRequest( 'RotateToTarget' );
  3942. MovAdjRotateToTarget( ticket );
  3943. }
  3944. }
  3945. super.OnEnumAnimEvent(animEventName, variant, animEventType, animEventDuration, animInfo);
  3946. }
  3947.  
  3948. event OnTeleported()
  3949. {
  3950. if( substateManager )
  3951. {
  3952. substateManager.OnTeleported();
  3953. }
  3954. }
  3955.  
  3956.  
  3957.  
  3958.  
  3959.  
  3960.  
  3961. event OnStartFistfightMinigame()
  3962. {
  3963. super.OnStartFistfightMinigame();
  3964.  
  3965.  
  3966. SetFistFightMinigameEnabled( true );
  3967. FistFightHealthChange( true );
  3968. thePlayer.GetPlayerMode().ForceCombatMode( FCMR_QuestFunction );
  3969. SetImmortalityMode(AIM_Unconscious, AIC_Fistfight);
  3970. thePlayer.SetBehaviorVariable( 'playerWeaponLatent', (int)PW_Fists );
  3971. GotoCombatStateWithAction( IA_None );
  3972. ((CMovingAgentComponent)this.GetMovingAgentComponent()).SnapToNavigableSpace( true );
  3973. EquipGeraltFistfightWeapon( true );
  3974. BlockAction( EIAB_RadialMenu, 'FistfightMinigame' ,,true);
  3975. BlockAction( EIAB_Signs, 'FistfightMinigame' ,,true);
  3976. BlockAction( EIAB_ThrowBomb, 'FistfightMinigame' ,,true);
  3977. BlockAction( EIAB_UsableItem, 'FistfightMinigame' ,,true);
  3978. BlockAction( EIAB_Crossbow, 'FistfightMinigame' ,,true);
  3979. BlockAction( EIAB_DrawWeapon, 'FistfightMinigame' ,,true);
  3980. BlockAction( EIAB_RunAndSprint, 'FistfightMinigame' ,,true);
  3981. BlockAction( EIAB_SwordAttack, 'FistfightMinigame' ,,true);
  3982. BlockAction( EIAB_CallHorse, 'FistfightMinigame' ,,true);
  3983. BlockAction( EIAB_Roll, 'FistfightMinigame' ,,true);
  3984. BlockAction( EIAB_Interactions, 'FistfightMinigame' ,,true);
  3985. BlockAction( EIAB_Explorations, 'FistfightMinigame' ,,true);
  3986. BlockAction( EIAB_OpenInventory, 'FistfightMinigame' ,,true);
  3987. BlockAction( EIAB_QuickSlots, 'FistfightMinigame' ,,true);
  3988. BlockAction( EIAB_OpenCharacterPanel, 'FistfightMinigame' ,,true);
  3989. }
  3990.  
  3991. event OnEndFistfightMinigame()
  3992. {
  3993. ((CMovingAgentComponent)this.GetMovingAgentComponent()).SnapToNavigableSpace( false );
  3994. FistFightHealthChange( false );
  3995. thePlayer.GetPlayerMode().ReleaseForceCombatMode( FCMR_QuestFunction );
  3996. EquipGeraltFistfightWeapon( false );
  3997. SetFistFightMinigameEnabled( false );
  3998. SetImmortalityMode(AIM_None, AIC_Fistfight);
  3999. BlockAllActions('FistfightMinigame',false);
  4000.  
  4001. super.OnEndFistfightMinigame();
  4002. }
  4003.  
  4004. public function GetFistFightFinisher( out masterAnimName, slaveAnimIndex : name )
  4005. {
  4006. var index : int;
  4007.  
  4008. index = RandRange(1);
  4009. switch ( index )
  4010. {
  4011. case 0 : masterAnimName = 'man_fistfight_finisher_1_win'; slaveAnimIndex = 'man_fistfight_finisher_1_looser';
  4012. }
  4013. }
  4014.  
  4015. public function SetFistFightMinigameEnabled( flag : bool )
  4016. {
  4017. fistFightMinigameEnabled = flag;
  4018. }
  4019.  
  4020. public function SetFistFightParams( toDeath : bool, endsWithBS : bool )
  4021. {
  4022. isFFMinigameToTheDeath = toDeath;
  4023. FFMinigameEndsithBS = endsWithBS;
  4024. }
  4025.  
  4026. public function IsFistFightMinigameEnabled() : bool
  4027. {
  4028. return fistFightMinigameEnabled;
  4029. }
  4030.  
  4031. public function IsFistFightMinigameToTheDeath() : bool
  4032. {
  4033. return isFFMinigameToTheDeath;
  4034. }
  4035.  
  4036. public function FistFightHealthChange( val : bool )
  4037. {
  4038. if( val == true )
  4039. {
  4040. GeraltMaxHealth = thePlayer.GetStatMax(BCS_Vitality);
  4041. ClampGeraltMaxHealth( 2000 );
  4042. SetHealthPerc( 100 );
  4043. }
  4044. else
  4045. {
  4046. ClampGeraltMaxHealth( GeraltMaxHealth );
  4047. SetHealthPerc( 100 );
  4048. }
  4049.  
  4050. }
  4051.  
  4052. function ClampGeraltMaxHealth( val : float )
  4053. {
  4054. thePlayer.abilityManager.SetStatPointMax( BCS_Vitality, val );
  4055. }
  4056.  
  4057. function EquipGeraltFistfightWeapon( val : bool )
  4058. {
  4059. if ( val )
  4060. {
  4061. fistsItems = thePlayer.GetInventory().AddAnItem( 'Geralt Fistfight Fists', 1, true, true );
  4062. thePlayer.GetInventory().MountItem( fistsItems[0] , true );
  4063. }
  4064. else
  4065. {
  4066. thePlayer.GetInventory().DropItem( fistsItems[0], true );
  4067. }
  4068. }
  4069.  
  4070.  
  4071.  
  4072.  
  4073. public function GetGwintAiDifficulty() : EGwintDifficultyMode
  4074. {
  4075. return gwintAiDifficulty;
  4076. }
  4077.  
  4078. public function SetGwintAiDifficulty( difficulty : EGwintDifficultyMode )
  4079. {
  4080. gwintAiDifficulty = difficulty;
  4081. }
  4082.  
  4083. public function GetGwintAiAggression() : EGwintAggressionMode
  4084. {
  4085. return gwintAiAggression;
  4086. }
  4087.  
  4088. public function SetGwintAiAggression( aggression : EGwintAggressionMode )
  4089. {
  4090. gwintAiAggression = aggression;
  4091. }
  4092.  
  4093. public function GetGwintMinigameState() : EMinigameState
  4094. {
  4095. return gwintMinigameState;
  4096. }
  4097.  
  4098. public function SetGwintMinigameState( minigameState : EMinigameState )
  4099. {
  4100. gwintMinigameState = minigameState;
  4101. }
  4102.  
  4103. public function OnGwintGameRequested( deckName : name, forceFaction : eGwintFaction )
  4104. {
  4105. var gwintManager:CR4GwintManager;
  4106. gwintManager = theGame.GetGwintManager();
  4107.  
  4108. gwintMinigameState = EMS_None;
  4109.  
  4110. gwintManager.SetEnemyDeckByName(deckName);
  4111. gwintManager.SetForcedFaction(forceFaction);
  4112.  
  4113. if (gwintManager.GetHasDoneTutorial() || !theGame.GetTutorialSystem().AreMessagesEnabled())
  4114. {
  4115. gwintManager.gameRequested = true;
  4116. theGame.RequestMenu( 'DeckBuilder' );
  4117. }
  4118. else
  4119. {
  4120. theGame.GetGuiManager().ShowUserDialog( UMID_SkipGwintTutorial, "gwint_tutorial_play_query_title", "gwint_tutorial_play_query", UDB_YesNo );
  4121. }
  4122. }
  4123.  
  4124. public function StartGwint_TutorialOrSkip( skipTutorial : bool )
  4125. {
  4126. var gwintManager : CR4GwintManager;
  4127.  
  4128. if( skipTutorial )
  4129. {
  4130. gwintManager = theGame.GetGwintManager();
  4131. gwintManager.gameRequested = true;
  4132. gwintManager.SetHasDoneTutorial(true);
  4133. gwintManager.SetHasDoneDeckTutorial(true);
  4134. theGame.RequestMenu( 'DeckBuilder' );
  4135. }
  4136. else
  4137. {
  4138. theGame.RequestMenu( 'GwintGame' );
  4139. }
  4140. }
  4141.  
  4142. private var gwintCardNumbersArray : array<int>;
  4143.  
  4144. public function InitGwintCardNumbersArray( arr : array<int> )
  4145. {
  4146. gwintCardNumbersArray.Clear();
  4147. gwintCardNumbersArray = arr;
  4148. }
  4149.  
  4150. public function GetCardNumbersArray() : array<int>
  4151. {
  4152. return gwintCardNumbersArray;
  4153. }
  4154.  
  4155.  
  4156.  
  4157.  
  4158. protected var customCameraStack : array<SCustomCameraParams>;
  4159.  
  4160. public function AddCustomCamToStack( customCameraParams : SCustomCameraParams ) : int
  4161. {
  4162. if( customCameraParams.useCustomCamera )
  4163. {
  4164. if ( customCameraParams.cameraParams.enums[0].enumType != 'ECustomCameraType' )
  4165. {
  4166. LogChannel( 'CustomCamera', "ERROR: Selected enum is not a custom camera!!!" );
  4167. return -1;
  4168. }
  4169. else
  4170. {
  4171. customCameraStack.PushBack( customCameraParams );
  4172. return ( customCameraStack.Size() - 1 );
  4173. }
  4174. }
  4175.  
  4176. return 0;
  4177. }
  4178.  
  4179. public function DisableCustomCamInStack( customCameraStackIndex : int )
  4180. {
  4181. if ( customCameraStackIndex != -1 )
  4182. customCameraStack[customCameraStackIndex].useCustomCamera = false;
  4183. else
  4184. LogChannel( 'CustomCamera', "ERROR: Custom camera to disable does not exist!!!" );
  4185. }
  4186.  
  4187. event OnInteriorStateChanged( inInterior : bool )
  4188. {
  4189. interiorCamera = inInterior;
  4190. }
  4191.  
  4192. event OnModifyPlayerSpeed( flag : bool )
  4193. {
  4194. modifyPlayerSpeed = flag;
  4195. SetBehaviorVariable( 'modifyPlayerSpeed', (float)modifyPlayerSpeed );
  4196. }
  4197.  
  4198. event OnGameCameraTick( out moveData : SCameraMovementData, dt : float )
  4199. {
  4200. var targetRotation : EulerAngles;
  4201. var dist : float;
  4202.  
  4203. // ImmersiveCam++
  4204. if( this.GetCurrentlyCastSign() == ST_Aard && GetBehaviorVariable( 'alternateSignCast' ) == 1 )
  4205. {
  4206. if( ic.critSloMoCam && thePlayer.IsInCombat() && ic.aardSlowMoFactor < 1.0 && !slowMoActive )
  4207. {
  4208. slowMoActive = true;
  4209. theGame.SetTimeScale( ic.aardSlowMoFactor, theGame.GetTimescaleSource(7), theGame.GetTimescalePriority(7), true);
  4210. AddTimer('OnStopTimeSlow',0.8, true);
  4211. }
  4212. }
  4213.  
  4214. if( this.GetCurrentlyCastSign() == ST_Igni && GetBehaviorVariable( 'alternateSignCast' ) == 1 )
  4215. {
  4216. if( ic.critSloMoCam && thePlayer.IsInCombat() && ic.igniSlowMoFactor < 1.0 && !slowMoActive )
  4217. {
  4218. slowMoActive = true;
  4219. theGame.SetTimeScale( ic.igniSlowMoFactor, theGame.GetTimescaleSource(7), theGame.GetTimescalePriority(7), true);
  4220. AddTimer('OnStopTimeSlow',0.8, true);
  4221. }
  4222. }
  4223.  
  4224. if( thePlayer.IsInCombat() )
  4225. {
  4226. dist = VecDistance2D( thePlayer.GetWorldPosition(), thePlayer.GetTarget().GetWorldPosition() );
  4227. thePlayer.GetVisualDebug().AddText( 'dbg', dist, thePlayer.GetWorldPosition() + Vector( 0.f,0.f,2.f ), true, , Color( 0, 255, 0 ) );
  4228.  
  4229. if( theInput.IsActionPressed( 'CamOffsetIncrease' ) ) IncreaseComOffset();
  4230. if( theInput.IsActionPressed( 'CamOffsetDecrease' ) ) DecreaseComOffset();
  4231. if( theInput.IsActionPressed( 'CamDepthIncrease' ) ) IncreaseComDepth();
  4232. if( theInput.IsActionPressed( 'CamDepthDecrease' ) ) DecreaseComDepth();
  4233. if( theInput.IsActionPressed( 'CamHeightIncrease' ) ) IncreaseComHeight();
  4234. if( theInput.IsActionPressed( 'CamHeightDecrease' ) ) DecreaseComHeight();
  4235. }
  4236. else
  4237. {
  4238. if( theInput.IsActionPressed( 'CamOffsetIncrease' ) ) IncreaseOffset();
  4239. if( theInput.IsActionPressed( 'CamOffsetDecrease' ) ) DecreaseOffset();
  4240. if( theInput.IsActionPressed( 'CamDepthIncrease' ) ) IncreaseDepth();
  4241. if( theInput.IsActionPressed( 'CamDepthDecrease' ) ) DecreaseDepth();
  4242. if( theInput.IsActionPressed( 'CamHeightIncrease' ) ) IncreaseHeight();
  4243. if( theInput.IsActionPressed( 'CamHeightDecrease' ) ) DecreaseHeight();
  4244. }
  4245. // ImmersiveCam--
  4246.  
  4247. if ( isStartingFistFightMinigame )
  4248. {
  4249. moveData.pivotRotationValue = fistFightTeleportNode.GetWorldRotation();
  4250. isStartingFistFightMinigame = false;
  4251. }
  4252.  
  4253. //ImmersiveCam++
  4254. /*
  4255. if( substateManager.UpdateCameraIfNeeded( moveData, dt ) )
  4256. {
  4257. //return true; //ImmersiveCam
  4258. }
  4259. */
  4260.  
  4261. // focusMode camera
  4262. if ( theGame.IsFocusModeActive() && ic.witcherSenseZoom && GetCurrentStateName() == 'Exploration' )
  4263. {
  4264. //restricted movement
  4265. if( ( movementLockType == PMLT_NoSprint || movementLockType == PMLT_NoRun ) && !ic.noInteriorCamChange )
  4266. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( ic.iWSOffset, ic.iWSDepth, ic.iWSHeight ), 0.5f, dt );
  4267. //normal
  4268. else
  4269. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( ic.eWSOffset + icOffsetAdj, ic.eWSDepth + icDepthAdj, ic.eWSHeight + icHeightAdj ), 0.5f, dt );
  4270. }
  4271. // combat camera
  4272. else if( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' || GetCurrentStateName() == 'CombatFists' )
  4273. {
  4274. if ( IsCameraLockedToTarget() )
  4275. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( ic.hlOffset, ic.hlDepth, ic.hlHeight ), 0.60f, dt );
  4276. else
  4277. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( ic.comOffset + icComOffsetAdj, ic.comDepth + icComDepthAdj, ic.comHeight + icComHeightAdj ), 0.60f, dt );
  4278. }
  4279. // clue camera
  4280. else if( GetPlayerAction() == PEA_ExamineGround )
  4281. {
  4282. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( ic.clueOffset + icOffsetAdj, ic.clueDepth + icDepthAdj, ic.clueHeight + icHeightAdj ), 1.f, dt );
  4283. }
  4284. // exploration camera
  4285. else
  4286. {
  4287. //vanilla sprint came
  4288. if( GetIsSprinting() && ic.sprintMode == 2)
  4289. {
  4290. //do nothing - will use vanilla cam for sprint
  4291. }
  4292. //custom sprint cam
  4293. else if ( GetIsSprinting() && ic.sprintMode == 3 )
  4294. {
  4295. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( ic.sprintOffset, ic.sprintDepth, ic.sprintHeight ), 0.60f, dt );
  4296. }
  4297. //restricted movement
  4298. else if( ( movementLockType == PMLT_NoSprint || movementLockType == PMLT_NoRun ) && !ic.noInteriorCamChange )
  4299. {
  4300. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( ic.intOffset, ic.intDepth, ic.intHeight), 0.60f, dt );
  4301. }
  4302. //normal
  4303. else
  4304. {
  4305. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( ic.expOffset + icOffsetAdj, ic.expDepth + icDepthAdj, ic.expHeight + icHeightAdj ), 0.60f, dt );
  4306. }
  4307. }
  4308. // ImmersiveCam--
  4309.  
  4310. return false;
  4311. }
  4312.  
  4313. private var questCameraRequest : SQuestCameraRequest;
  4314. private var cameraRequestTimeStamp : float;
  4315.  
  4316. public function RequestQuestCamera( camera : SQuestCameraRequest )
  4317. {
  4318. questCameraRequest = camera;
  4319. questCameraRequest.requestTimeStamp = theGame.GetEngineTimeAsSeconds();
  4320. }
  4321.  
  4322. public function ResetQuestCameraRequest()
  4323. {
  4324. var cameraRequest : SQuestCameraRequest;
  4325.  
  4326. questCameraRequest = cameraRequest;
  4327. }
  4328.  
  4329. event OnGameCameraPostTick( out moveData : SCameraMovementData, dt : float )
  4330. {
  4331. var ent : CEntity;
  4332. var playerPos : Vector;
  4333. var angles : EulerAngles;
  4334.  
  4335. var distance : float;
  4336.  
  4337.  
  4338.  
  4339. if ( questCameraRequest.requestTimeStamp > 0 )
  4340. {
  4341. if ( questCameraRequest.duration > 0 && questCameraRequest.requestTimeStamp + questCameraRequest.duration < theGame.GetEngineTimeAsSeconds() )
  4342. {
  4343. ResetQuestCameraRequest();
  4344. return false;
  4345. }
  4346.  
  4347. if( questCameraRequest.lookAtTag )
  4348. {
  4349. ent = theGame.GetEntityByTag( questCameraRequest.lookAtTag );
  4350. playerPos = GetWorldPosition();
  4351. playerPos.Z += 1.8f;
  4352.  
  4353. angles = VecToRotation( ent.GetWorldPosition() - playerPos );
  4354.  
  4355. moveData.pivotRotationController.SetDesiredHeading( angles.Yaw );
  4356. moveData.pivotRotationController.SetDesiredPitch( -angles.Pitch );
  4357. }
  4358. else
  4359. {
  4360. if( questCameraRequest.requestYaw )
  4361. {
  4362. angles = GetWorldRotation();
  4363. moveData.pivotRotationController.SetDesiredHeading( angles.Yaw + questCameraRequest.yaw );
  4364. }
  4365.  
  4366. if( questCameraRequest.requestPitch )
  4367. {
  4368. moveData.pivotRotationController.SetDesiredPitch( questCameraRequest.pitch );
  4369. }
  4370. }
  4371. }
  4372.  
  4373. UpdateCameraSprint( moveData, dt ); //ImmersiveCam
  4374. }
  4375.  
  4376. var wasRunning : bool;
  4377. var vel : float;
  4378. var smoothTime : float;
  4379.  
  4380. var constDamper : ConstDamper;
  4381. var rotMultVel : float;
  4382.  
  4383. public function UpdateCameraInterior( out moveData : SCameraMovementData, timeDelta : float )
  4384. {
  4385. var camDist : float;
  4386. var camOffset : float;
  4387. var rotMultDest : float;
  4388. var rotMult : float;
  4389. var angles : EulerAngles;
  4390.  
  4391. theGame.GetGameCamera().ChangePivotRotationController( 'ExplorationInterior' );
  4392. theGame.GetGameCamera().ChangePivotDistanceController( 'Default' );
  4393. theGame.GetGameCamera().ChangePivotPositionController( 'Default' );
  4394.  
  4395.  
  4396. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  4397. moveData.pivotDistanceController = theGame.GetGameCamera().GetActivePivotDistanceController();
  4398. moveData.pivotPositionController = theGame.GetGameCamera().GetActivePivotPositionController();
  4399.  
  4400.  
  4401. moveData.pivotPositionController.SetDesiredPosition( GetWorldPosition(), 15.f );
  4402.  
  4403. if ( !constDamper )
  4404. {
  4405. constDamper = new ConstDamper in this;
  4406. constDamper.SetDamp( 0.35f );
  4407. }
  4408.  
  4409. if ( rawPlayerSpeed <= 0 || AbsF( AngleDistance( rawPlayerHeading, GetHeading() ) ) > 135 )
  4410. constDamper.Reset();
  4411. else if ( theGame.IsUberMovementEnabled() )
  4412. rotMult = 0.5f;
  4413. else
  4414. rotMult = 1.f;
  4415.  
  4416. rotMult = constDamper.UpdateAndGet( timeDelta, rotMult );
  4417.  
  4418.  
  4419.  
  4420. if ( AbsF( AngleDistance( GetHeading(), moveData.pivotRotationValue.Yaw ) ) < 135.f && rawPlayerSpeed > 0 )
  4421. moveData.pivotRotationController.SetDesiredHeading( GetHeading(), rotMult );
  4422. else
  4423. moveData.pivotRotationController.SetDesiredHeading( moveData.pivotRotationValue.Yaw );
  4424.  
  4425. //moveData.pivotDistanceController.SetDesiredDistance( 1.5f ); //ImmersiveCam
  4426.  
  4427. angles = VecToRotation( GetMovingAgentComponent().GetVelocity() );
  4428. if ( AbsF( angles.Pitch ) < 8.f || bLAxisReleased )
  4429. moveData.pivotRotationController.SetDesiredPitch( -10.f );
  4430. else
  4431. moveData.pivotRotationController.SetDesiredPitch( -angles.Pitch - 18.f );
  4432.  
  4433. if ( IsGuarded() )
  4434. moveData.pivotPositionController.offsetZ = 1.0f;
  4435. else
  4436. moveData.pivotPositionController.offsetZ = 1.3f;
  4437.  
  4438.  
  4439.  
  4440. if ( playerMoveType >= PMT_Run )
  4441. {
  4442.  
  4443. camDist = -0.5f;
  4444. camOffset = 0.25;
  4445.  
  4446. if ( !wasRunning )
  4447. {
  4448. smoothTime = 1.f;
  4449. wasRunning = true;
  4450. }
  4451. DampFloatSpring( smoothTime, vel, 0.1, 0.5, timeDelta );
  4452. }
  4453. else
  4454. {
  4455.  
  4456. camDist = 0.f;
  4457. camOffset = 0.4f;
  4458. smoothTime = 0.2f;
  4459. wasRunning = false;
  4460. }
  4461.  
  4462.  
  4463.  
  4464. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( 0.3f, camDist, 0.3f ), smoothTime, timeDelta );
  4465.  
  4466.  
  4467.  
  4468.  
  4469.  
  4470. }
  4471.  
  4472.  
  4473. var wasBRAxisPushed : bool;
  4474. protected function UpdateCameraChanneledSign( out moveData : SCameraMovementData, timeDelta : float ) : bool
  4475. {
  4476. var screenSpaceOffset : float;
  4477. var screenSpaceOffsetFwd : float;
  4478. var screenSpaceOffsetUp : float;
  4479. var heading : float;
  4480. var pitch : float;
  4481. var playerToTargetRot : EulerAngles;
  4482. var rightOffset : float = -20.f;
  4483. var leftOffset : float = 15.f;
  4484. var angles : EulerAngles;
  4485.  
  4486. var vec : Vector;
  4487.  
  4488. if( this.IsCurrentSignChanneled() && this.GetCurrentlyCastSign() != ST_Quen && this.GetCurrentlyCastSign() != ST_Yrden )
  4489. {
  4490. theGame.GetGameCamera().ChangePivotRotationController( 'SignChannel' );
  4491. theGame.GetGameCamera().ChangePivotDistanceController( 'SignChannel' );
  4492.  
  4493. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  4494. moveData.pivotDistanceController = theGame.GetGameCamera().GetActivePivotDistanceController();
  4495.  
  4496.  
  4497. if ( GetCurrentlyCastSign() == ST_Axii )
  4498. leftOffset = 32.f;
  4499.  
  4500. if ( oTCameraOffset != leftOffset && oTCameraOffset != rightOffset )
  4501. {
  4502. if( ( interiorCamera && !moveTarget )
  4503. || ( AngleDistance( GetHeading(), moveData.pivotRotationValue.Yaw ) < 0 ) )
  4504. oTCameraOffset = leftOffset;
  4505. else
  4506. oTCameraOffset = rightOffset;
  4507. }
  4508.  
  4509. if ( oTCameraOffset == leftOffset )
  4510. {
  4511. // ImmersiveCam++
  4512. screenSpaceOffset = ic.fsOffset;
  4513. oTCameraPitchOffset = 13.f;
  4514. // ImmersiveCam--
  4515. }
  4516. else if ( oTCameraOffset == rightOffset )
  4517. {
  4518. // ImmersiveCam++
  4519. screenSpaceOffset = -ic.fsOffset;
  4520. oTCameraPitchOffset = 13.f;
  4521. // ImmersiveCam--
  4522. }
  4523.  
  4524. moveData.pivotPositionController.offsetZ = 1.3f;
  4525.  
  4526. if ( !delayCameraOrientationChange )
  4527. {
  4528. if ( GetOrientationTarget() == OT_Camera || GetOrientationTarget() == OT_CameraOffset )
  4529. {
  4530. if ( bRAxisReleased )
  4531. {
  4532. heading = moveData.pivotRotationValue.Yaw;
  4533. pitch = moveData.pivotRotationValue.Pitch;
  4534. }
  4535. else
  4536. {
  4537. heading = moveData.pivotRotationValue.Yaw + oTCameraOffset;
  4538. pitch = moveData.pivotRotationValue.Pitch;
  4539. }
  4540. }
  4541. else if ( GetOrientationTarget() == OT_Actor )
  4542. {
  4543. if ( GetDisplayTarget() )
  4544. vec = GetDisplayTarget().GetWorldPosition() - GetWorldPosition();
  4545. else if ( slideTarget )
  4546. vec = slideTarget.GetWorldPosition() - GetWorldPosition();
  4547. else if ( GetTarget() )
  4548. vec = GetTarget().GetWorldPosition() - GetWorldPosition();
  4549. else
  4550. vec = GetHeadingVector();
  4551.  
  4552. angles = VecToRotation( vec );
  4553. heading = angles.Yaw + oTCameraOffset;
  4554. pitch = -angles.Pitch - oTCameraPitchOffset;
  4555. }
  4556. else
  4557. {
  4558. angles = VecToRotation( GetHeadingVector() );
  4559. heading = angles.Yaw + oTCameraOffset;
  4560. pitch = -angles.Pitch - oTCameraPitchOffset;
  4561. }
  4562.  
  4563. if ( !wasBRAxisPushed && ( !bRAxisReleased ) )
  4564. wasBRAxisPushed = true;
  4565.  
  4566. moveData.pivotRotationController.SetDesiredHeading( heading , 2.f );
  4567. moveData.pivotRotationController.SetDesiredPitch( pitch );
  4568. }
  4569. else
  4570. {
  4571. moveData.pivotRotationController.SetDesiredHeading( moveData.pivotRotationValue.Yaw, 1.f );
  4572. moveData.pivotRotationController.SetDesiredPitch( -oTCameraPitchOffset );
  4573. }
  4574.  
  4575. if ( moveData.pivotRotationValue.Pitch <= 5.f && moveData.pivotRotationValue.Pitch >= -15.f )
  4576. {
  4577. // ImmersiveCam++
  4578. screenSpaceOffsetFwd = ic.fsDepth;
  4579. screenSpaceOffsetUp = ic.fsHeight;
  4580. // ImmersiveCam--
  4581. }
  4582. else if ( moveData.pivotRotationValue.Pitch > 0 )
  4583. {
  4584. // ImmersiveCam++
  4585. screenSpaceOffsetFwd = moveData.pivotRotationValue.Pitch*0.00727 + 1.275f;
  4586. screenSpaceOffsetFwd = ClampF( screenSpaceOffsetFwd, ic.fsDepth - 0.3, ic.fsDepth + 0.4 );
  4587.  
  4588. screenSpaceOffsetUp = -moveData.pivotRotationValue.Pitch*0.00727 + 0.4363f;
  4589. screenSpaceOffsetUp = ClampF( screenSpaceOffsetUp, ic.fsHeight - 0.4, ic.fsHeight - 0.1 );
  4590. // ImmersiveCam--
  4591. }
  4592. else
  4593. {
  4594. // ImmersiveCam++
  4595. if ( GetCurrentlyCastSign() == ST_Axii )
  4596. {
  4597. screenSpaceOffsetFwd = -moveData.pivotRotationValue.Pitch*0.0425 + 0.8625f;
  4598. screenSpaceOffsetFwd = ClampF( screenSpaceOffsetFwd, ic.fsDepth - 0.3, ic.fsDepth + 0.5 );
  4599. }
  4600. else
  4601. {
  4602. screenSpaceOffsetFwd = -moveData.pivotRotationValue.Pitch*0.035 + 0.75f;
  4603. screenSpaceOffsetFwd = ClampF( screenSpaceOffsetFwd, ic.fsDepth - 0.3, ic.fsDepth + 0.8 );
  4604. }
  4605. screenSpaceOffsetUp = -moveData.pivotRotationValue.Pitch*0.005 + 0.325f;
  4606. screenSpaceOffsetUp = ClampF( screenSpaceOffsetUp, ic.fsHeight, ic.fsHeight + 0.1 );
  4607. // ImmersiveCam--
  4608. }
  4609.  
  4610. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( screenSpaceOffset, screenSpaceOffsetFwd, screenSpaceOffsetUp ), 0.25f, timeDelta );
  4611. moveData.pivotDistanceController.SetDesiredDistance( 2.8f, 5.f );
  4612. moveData.pivotPositionController.SetDesiredPosition( GetWorldPosition() );
  4613.  
  4614. return true;
  4615. }
  4616. else
  4617. {
  4618. this.wasBRAxisPushed = false;
  4619.  
  4620. return false;
  4621. }
  4622. }
  4623.  
  4624. protected function UpdateCameraForSpecialAttack( out moveData : SCameraMovementData, timeDelta : float ) : bool
  4625. {
  4626. var screenSpaceOffset : float;
  4627. var tempHeading : float;
  4628. var cameraOffsetLeft : float;
  4629. var cameraOffsetRight : float;
  4630.  
  4631. if ( !specialAttackCamera )
  4632. return false;
  4633.  
  4634. theGame.GetGameCamera().ForceManualControlHorTimeout();
  4635. theGame.GetGameCamera().ForceManualControlVerTimeout();
  4636.  
  4637.  
  4638. cameraOffsetLeft = 30.f;
  4639. cameraOffsetRight = -30.f;
  4640.  
  4641.  
  4642.  
  4643.  
  4644.  
  4645.  
  4646.  
  4647. theGame.GetGameCamera().ChangePivotRotationController( 'SignChannel' );
  4648. theGame.GetGameCamera().ChangePivotDistanceController( 'SignChannel' );
  4649.  
  4650. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  4651. moveData.pivotDistanceController = theGame.GetGameCamera().GetActivePivotDistanceController();
  4652.  
  4653. if ( slideTarget )
  4654. tempHeading = VecHeading( slideTarget.GetWorldPosition() - GetWorldPosition() );
  4655. else
  4656. tempHeading = GetHeading();
  4657.  
  4658. oTCameraPitchOffset = 0.f;
  4659.  
  4660. if( ( interiorCamera && !moveTarget )
  4661. || ( AngleDistance( tempHeading, moveData.pivotRotationValue.Yaw ) < 0 ) )
  4662. oTCameraOffset = cameraOffsetLeft;
  4663. else
  4664. oTCameraOffset = cameraOffsetRight;
  4665.  
  4666. if ( oTCameraOffset == cameraOffsetLeft )
  4667. {
  4668. if ( delayCameraOrientationChange || delayOrientationChange )
  4669. {
  4670. screenSpaceOffset = 0.75f;
  4671. moveData.pivotDistanceController.SetDesiredDistance( 1.6f, 3.f );
  4672. moveData.pivotPositionController.offsetZ = 1.4f;
  4673. moveData.pivotRotationController.SetDesiredPitch( -15.f );
  4674. }
  4675. else
  4676. {
  4677. screenSpaceOffset = 0.7f;
  4678. moveData.pivotDistanceController.SetDesiredDistance( 3.25f );
  4679. moveData.pivotPositionController.offsetZ = 1.2f;
  4680. moveData.pivotRotationController.SetDesiredPitch( -10.f );
  4681. }
  4682. }
  4683. else if ( oTCameraOffset == cameraOffsetRight )
  4684. {
  4685. if ( delayCameraOrientationChange || delayOrientationChange )
  4686. {
  4687. screenSpaceOffset = -0.85f;
  4688. moveData.pivotDistanceController.SetDesiredDistance( 1.6f, 3.f );
  4689. moveData.pivotPositionController.offsetZ = 1.4f;
  4690. moveData.pivotRotationController.SetDesiredPitch( -15.f );
  4691. }
  4692. else
  4693. {
  4694. screenSpaceOffset = -0.8f;
  4695. moveData.pivotDistanceController.SetDesiredDistance( 3.25f );
  4696. moveData.pivotPositionController.offsetZ = 1.2f;
  4697. moveData.pivotRotationController.SetDesiredPitch( -10.f );
  4698. }
  4699. }
  4700. else
  4701. {
  4702. moveData.pivotDistanceController.SetDesiredDistance( 1.25f, 3.f );
  4703. moveData.pivotPositionController.offsetZ = 1.3f;
  4704. moveData.pivotRotationController.SetDesiredPitch( -5.5f );
  4705. }
  4706.  
  4707. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( screenSpaceOffset, 0.f, 0.f ), 1.f, timeDelta );
  4708.  
  4709. if ( !delayCameraOrientationChange )
  4710. {
  4711. if ( moveTarget )
  4712. moveData.pivotRotationController.SetDesiredHeading( GetHeading() + oTCameraOffset, 0.5f );
  4713. else
  4714. moveData.pivotRotationController.SetDesiredHeading( GetHeading() + oTCameraOffset, 1.f );
  4715. }
  4716. else
  4717. moveData.pivotRotationController.SetDesiredHeading( moveData.pivotRotationValue.Yaw, 1.f );
  4718.  
  4719. moveData.pivotPositionController.SetDesiredPosition( GetWorldPosition() );
  4720.  
  4721. return true;
  4722. }
  4723.  
  4724.  
  4725. private var fovVel : float;
  4726. private var sprintOffset : Vector;
  4727. private var previousOffset : bool;
  4728. private var previousRotationVelocity : float;
  4729. private var pivotRotationTimeStamp : float;
  4730. protected function UpdateCameraSprint( out moveData : SCameraMovementData, timeDelta : float )
  4731. {
  4732. var angleDiff : float;
  4733. var camOffsetVector : Vector;
  4734. var smoothSpeed : float;
  4735. var camera : CCustomCamera;
  4736. var camAngularSpeed : float;
  4737.  
  4738. var playerToCamAngle : float;
  4739. var useExplorationSprintCam : bool;
  4740.  
  4741. camera = theGame.GetGameCamera();
  4742. if( camera )
  4743. {
  4744. if ( sprintingCamera )
  4745. {
  4746.  
  4747. if( thePlayer.GetAutoCameraCenter() )
  4748. {
  4749. theGame.GetGameCamera().ForceManualControlVerTimeout();
  4750. }
  4751.  
  4752. playerToCamAngle = AbsF( AngleDistance( GetHeading(), moveData.pivotRotationValue.Yaw ) );
  4753.  
  4754.  
  4755. useExplorationSprintCam = false;
  4756.  
  4757. if ( useExplorationSprintCam )
  4758. {
  4759. if ( playerToCamAngle <= 45 )
  4760. {
  4761. theGame.GetGameCamera().ChangePivotRotationController( 'Sprint' );
  4762.  
  4763. moveData.pivotRotationController = theGame.GetGameCamera().GetActivePivotRotationController();
  4764.  
  4765. moveData.pivotRotationController.SetDesiredHeading( GetHeading(), 0.25f );
  4766. moveData.pivotRotationController.SetDesiredPitch( -3.5f, 0.5f );
  4767. thePlayer.EnableManualCameraControl( true, 'Sprint' );
  4768. }
  4769. else
  4770. {
  4771. thePlayer.EnableManualCameraControl( false, 'Sprint' );
  4772. }
  4773. }
  4774. else
  4775. {
  4776. if ( theGame.IsUberMovementEnabled() )
  4777. moveData.pivotRotationController.SetDesiredHeading( GetHeading(), 0.35f );
  4778.  
  4779. thePlayer.EnableManualCameraControl( true, 'Sprint' );
  4780. }
  4781.  
  4782. if ( bRAxisReleased )
  4783. {
  4784. if ( AbsF( rawLeftJoyRot ) > 25 )
  4785. angleDiff = AngleDistance( GetHeading(), moveData.pivotRotationValue.Yaw );
  4786.  
  4787. pivotRotationTimeStamp = theGame.GetEngineTimeAsSeconds();
  4788. previousRotationVelocity = 0.f;
  4789. }
  4790. else
  4791. {
  4792. if ( previousRotationVelocity <= 0 && AbsF( moveData.pivotRotationVelocity.Yaw ) > 250 )
  4793. {
  4794. pivotRotationTimeStamp = theGame.GetEngineTimeAsSeconds();
  4795. previousRotationVelocity = AbsF( moveData.pivotRotationVelocity.Yaw );
  4796. }
  4797. }
  4798.  
  4799. if ( pivotRotationTimeStamp + 0.4f <= theGame.GetEngineTimeAsSeconds() && AbsF( moveData.pivotRotationVelocity.Yaw ) > 250 )
  4800. angleDiff = VecHeading( rawRightJoyVec );
  4801.  
  4802. if ( useExplorationSprintCam )
  4803. {
  4804. if ( playerToCamAngle > 90 )
  4805. {
  4806. camOffsetVector.X = 0.f;
  4807. smoothSpeed = 1.f;
  4808. }
  4809. else if ( angleDiff > 15.f )
  4810. {
  4811. camOffsetVector.X = -0.8;
  4812. smoothSpeed = 1.f;
  4813. previousOffset = true;
  4814. }
  4815. else if ( angleDiff < -15.f )
  4816. {
  4817. camOffsetVector.X = 0.475f;
  4818. smoothSpeed = 1.5f;
  4819. previousOffset = false;
  4820. }
  4821. else
  4822. {
  4823. if ( previousOffset )
  4824. {
  4825. camOffsetVector.X = -0.8;
  4826. smoothSpeed = 1.5f;
  4827. }
  4828. else
  4829. {
  4830. camOffsetVector.X = 0.475f;
  4831. smoothSpeed = 1.5f;
  4832. }
  4833. }
  4834.  
  4835. camOffsetVector.Y = 1.4f;
  4836. camOffsetVector.Z = 0.275f;
  4837. }
  4838. else
  4839. {
  4840.  
  4841. smoothSpeed = 0.75f;
  4842.  
  4843. camOffsetVector.X = 0.f;
  4844. camOffsetVector.Y = 1.f;
  4845. camOffsetVector.Z = 0.2f;
  4846. moveData.pivotRotationController.SetDesiredPitch( -10.f, 0.5f );
  4847. }
  4848.  
  4849. DampVectorConst( sprintOffset, camOffsetVector, smoothSpeed, timeDelta );
  4850.  
  4851. moveData.cameraLocalSpaceOffset = sprintOffset;
  4852.  
  4853. DampFloatSpring( camera.fov, fovVel, ic.expFOV, 1.0, timeDelta ); //ImmersiveCam
  4854. }
  4855. else
  4856. {
  4857. sprintOffset = moveData.cameraLocalSpaceOffset;
  4858. DampFloatSpring( camera.fov, fovVel, ic.expFOV, 1.0, timeDelta ); //ImmersiveCam
  4859. previousOffset = false;
  4860. }
  4861. }
  4862. }
  4863.  
  4864. function EnableSprintingCamera( flag : bool )
  4865. {
  4866. //ImmersiveCam++
  4867. /*
  4868. if( !theGame.IsUberMovementEnabled() && !useSprintingCameraAnim )
  4869. {
  4870. return;
  4871. }
  4872. */
  4873. if( !useSprintingCameraAnim )
  4874. {
  4875. return;
  4876. }
  4877. //ImmersiveCam--
  4878.  
  4879. super.EnableSprintingCamera( flag );
  4880.  
  4881. if ( !flag )
  4882. {
  4883. thePlayer.EnableManualCameraControl( true, 'Sprint' );
  4884. }
  4885. }
  4886.  
  4887. protected function UpdateCameraCombatActionButNotInCombat( out moveData : SCameraMovementData, timeDelta : float )
  4888. {
  4889. var vel : Vector;
  4890. var heading : float;
  4891. var pitch : float;
  4892. var headingMult : float;
  4893. var pitchMult : float;
  4894. var camOffset : Vector;
  4895. var buff : CBaseGameplayEffect;
  4896. var runningAndAlertNear : bool;
  4897. var desiredDist : float;
  4898.  
  4899. if ( ( !IsCurrentSignChanneled() || GetCurrentlyCastSign() == ST_Quen || GetCurrentlyCastSign() == ST_Yrden ) && !specialAttackCamera && !IsInCombatActionFriendly() )
  4900. {
  4901. // ImmersiveCam++
  4902. /*
  4903. buff = GetCurrentlyAnimatedCS();
  4904. runningAndAlertNear = GetPlayerCombatStance() == PCS_AlertNear && playerMoveType == PMT_Run && !GetDisplayTarget();
  4905. if ( runningAndAlertNear ||
  4906. ( GetPlayerCombatStance() == PCS_AlertFar && !IsInCombatAction() && !buff ) )
  4907. {
  4908. camOffset.X = 0.f;
  4909. camOffset.Y = 0.f;
  4910. camOffset.Z = -0.1f;
  4911.  
  4912. if ( runningAndAlertNear )
  4913. {
  4914. moveData.pivotDistanceController.SetDesiredDistance( 4.f );
  4915. moveData.pivotPositionController.offsetZ = 1.5f;
  4916. }
  4917. }
  4918. else
  4919. {
  4920. camOffset.X = 0.f;
  4921. camOffset.Y = -1.5f;
  4922. camOffset.Z = -0.2f;
  4923. }
  4924.  
  4925. DampVectorSpring( moveData.cameraLocalSpaceOffset, moveData.cameraLocalSpaceOffsetVel, Vector( camOffset.X, camOffset.Y, camOffset.Z ), 0.4f, timeDelta );
  4926. sprintOffset = moveData.cameraLocalSpaceOffset;
  4927. */
  4928. // ImmersiveCam--
  4929. if( ic.expAutoRot )
  4930. {
  4931. heading = moveData.pivotRotationValue.Yaw;
  4932.  
  4933. if ( GetOrientationTarget() == OT_Camera || GetOrientationTarget() == OT_CameraOffset )
  4934. pitch = moveData.pivotRotationValue.Pitch;
  4935. else if ( lastAxisInputIsMovement
  4936. || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack
  4937. || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_SpecialAttack
  4938. || ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign && !IsCurrentSignChanneled() && GetCurrentlyCastSign() == ST_Quen ) )
  4939. {
  4940. theGame.GetGameCamera().ForceManualControlVerTimeout();
  4941. pitch = -20.f;
  4942. }
  4943. else
  4944. pitch = moveData.pivotRotationValue.Pitch;
  4945.  
  4946. headingMult = 1.f;
  4947. pitchMult = 1.f;
  4948.  
  4949.  
  4950. if( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign
  4951. && ( GetEquippedSign() == ST_Aard || GetEquippedSign() == ST_Yrden )
  4952. && GetBehaviorVariable( 'alternateSignCast' ) == 1 )
  4953. {
  4954.  
  4955. theGame.GetGameCamera().ForceManualControlVerTimeout();
  4956. pitch = -20.f;
  4957.  
  4958.  
  4959. }
  4960.  
  4961.  
  4962.  
  4963.  
  4964.  
  4965.  
  4966.  
  4967. if ( IsCurrentSignChanneled() && GetCurrentlyCastSign() == ST_Quen )
  4968. {
  4969. pitch = moveData.pivotRotationValue.Pitch;
  4970. }
  4971.  
  4972. moveData.pivotRotationController.SetDesiredHeading( heading, );
  4973. moveData.pivotRotationController.SetDesiredPitch( pitch );
  4974. }
  4975. }
  4976. }
  4977.  
  4978.  
  4979.  
  4980. event OnGameCameraExplorationRotCtrlChange()
  4981. {
  4982. if( substateManager )
  4983. {
  4984. return substateManager.OnGameCameraExplorationRotCtrlChange( );
  4985. }
  4986.  
  4987. return false;
  4988. }
  4989.  
  4990.  
  4991.  
  4992.  
  4993.  
  4994.  
  4995. function SetCustomRotation( customRotationName : name, rotHeading : float, rotSpeed : float, activeTime : float, rotateExistingDeltaLocation : bool )
  4996. {
  4997. var movementAdjustor : CMovementAdjustor;
  4998. var ticket : SMovementAdjustmentRequestTicket;
  4999.  
  5000. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  5001. ticket = movementAdjustor.GetRequest( customRotationName );
  5002. movementAdjustor.Cancel( ticket );
  5003. ticket = movementAdjustor.CreateNewRequest( customRotationName );
  5004. movementAdjustor.Continuous( ticket );
  5005. movementAdjustor.ReplaceRotation( ticket );
  5006. movementAdjustor.RotateTo( ticket, rotHeading );
  5007. movementAdjustor.MaxRotationAdjustmentSpeed( ticket, rotSpeed );
  5008. if (rotSpeed == 0.0f)
  5009. {
  5010. movementAdjustor.AdjustmentDuration( ticket, activeTime );
  5011. }
  5012. movementAdjustor.KeepActiveFor( ticket, activeTime );
  5013. movementAdjustor.RotateExistingDeltaLocation( ticket, rotateExistingDeltaLocation );
  5014. }
  5015.  
  5016. function UpdateCustomRotationHeading( customRotationName : name, rotHeading : float )
  5017. {
  5018. var movementAdjustor : CMovementAdjustor;
  5019. var ticket : SMovementAdjustmentRequestTicket;
  5020.  
  5021. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  5022. ticket = movementAdjustor.GetRequest( customRotationName );
  5023. movementAdjustor.RotateTo( ticket, rotHeading );
  5024. }
  5025.  
  5026. function SetCustomRotationTowards( customRotationName : name, target : CActor, rotSpeed : float, optional activeTime : float )
  5027. {
  5028. var movementAdjustor : CMovementAdjustor;
  5029. var ticket : SMovementAdjustmentRequestTicket;
  5030.  
  5031. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  5032. ticket = movementAdjustor.GetRequest( customRotationName );
  5033. movementAdjustor.Cancel( ticket );
  5034. ticket = movementAdjustor.CreateNewRequest( customRotationName );
  5035. movementAdjustor.Continuous( ticket );
  5036. movementAdjustor.ReplaceRotation( ticket );
  5037. movementAdjustor.RotateTowards( ticket, target );
  5038. movementAdjustor.MaxRotationAdjustmentSpeed( ticket, rotSpeed );
  5039. if (activeTime > 0.0f)
  5040. {
  5041. movementAdjustor.KeepActiveFor( ticket, activeTime );
  5042. }
  5043. else
  5044. {
  5045. movementAdjustor.DontEnd( ticket );
  5046. }
  5047. }
  5048.  
  5049.  
  5050. function CustomLockMovement( customMovementName : name, heading : float )
  5051. {
  5052. var movementAdjustor : CMovementAdjustor;
  5053. var ticket : SMovementAdjustmentRequestTicket;
  5054.  
  5055. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  5056. ticket = movementAdjustor.GetRequest( customMovementName );
  5057. movementAdjustor.Cancel( ticket );
  5058. ticket = movementAdjustor.CreateNewRequest( customMovementName );
  5059. movementAdjustor.Continuous( ticket );
  5060. movementAdjustor.DontEnd( ticket );
  5061. movementAdjustor.LockMovementInDirection( ticket, heading );
  5062. }
  5063.  
  5064. function BindMovementAdjustmentToEvent( customRotationName : name, eventName : CName )
  5065. {
  5066. var movementAdjustor : CMovementAdjustor;
  5067. var ticket : SMovementAdjustmentRequestTicket;
  5068.  
  5069. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  5070. ticket = movementAdjustor.GetRequest( customRotationName );
  5071. movementAdjustor.BindToEvent( ticket, eventName );
  5072. }
  5073.  
  5074. function UpdateCustomLockMovementHeading( customMovementName : name, heading : float )
  5075. {
  5076. var movementAdjustor : CMovementAdjustor;
  5077. var ticket : SMovementAdjustmentRequestTicket;
  5078.  
  5079. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  5080. ticket = movementAdjustor.GetRequest( customMovementName );
  5081. movementAdjustor.LockMovementInDirection( ticket, heading );
  5082. }
  5083.  
  5084. function CustomLockDistance( customMovementName : name, maintainDistanceTo : CNode, minDist, maxDist : float )
  5085. {
  5086. var movementAdjustor : CMovementAdjustor;
  5087. var ticket : SMovementAdjustmentRequestTicket;
  5088.  
  5089. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  5090. ticket = movementAdjustor.GetRequest( customMovementName );
  5091. movementAdjustor.Cancel( ticket );
  5092. ticket = movementAdjustor.CreateNewRequest( customMovementName );
  5093. movementAdjustor.Continuous( ticket );
  5094. movementAdjustor.SlideTowards( ticket, maintainDistanceTo, minDist, maxDist );
  5095. }
  5096.  
  5097. function UpdateCustomLockDistance( customMovementName : name, maintainDistanceTo : CNode, minDist, maxDist : float )
  5098. {
  5099. var movementAdjustor : CMovementAdjustor;
  5100. var ticket : SMovementAdjustmentRequestTicket;
  5101.  
  5102. movementAdjustor = GetMovingAgentComponent().GetMovementAdjustor();
  5103. ticket = movementAdjustor.GetRequest( customMovementName );
  5104. movementAdjustor.SlideTowards( ticket, maintainDistanceTo, minDist, maxDist );
  5105. }
  5106.  
  5107. private var disableManualCameraControlStack : array<name>;
  5108. public function EnableManualCameraControl( enable : bool, sourceName : name )
  5109. {
  5110. if ( !enable )
  5111. {
  5112. if ( !disableManualCameraControlStack.Contains( sourceName ) )
  5113. {
  5114. disableManualCameraControlStack.PushBack( sourceName );
  5115. }
  5116. }
  5117. else
  5118. {
  5119. disableManualCameraControlStack.Remove( sourceName );
  5120. }
  5121.  
  5122. if ( disableManualCameraControlStack.Size() > 0 )
  5123. theGame.GetGameCamera().EnableManualControl( false );
  5124. else
  5125. theGame.GetGameCamera().EnableManualControl( true );
  5126. }
  5127.  
  5128. public function IsCameraControlDisabled( optional disabledBySourceName : name ) : bool
  5129. {
  5130. if ( disabledBySourceName )
  5131. return disableManualCameraControlStack.Contains( disabledBySourceName );
  5132. else
  5133. return disableManualCameraControlStack.Size() > 0;
  5134. }
  5135.  
  5136. public function DisableManualCameraControlStackHasSource( sourceName : name ) : bool
  5137. {
  5138. return disableManualCameraControlStack.Contains( sourceName );
  5139. }
  5140.  
  5141. public function ClearDisableManualCameraControlStack()
  5142. {
  5143. disableManualCameraControlStack.Clear();
  5144. theGame.GetGameCamera().EnableManualControl( true );
  5145. }
  5146.  
  5147. function SetOrientationTarget( target : EOrientationTarget )
  5148. {
  5149. if ( IsPCModeEnabled() && target == OT_Player )
  5150. {
  5151. target = OT_Camera;
  5152. }
  5153.  
  5154. orientationTarget = target;
  5155. }
  5156.  
  5157. function GetOrientationTarget() : EOrientationTarget
  5158. {
  5159. return orientationTarget;
  5160. }
  5161.  
  5162. var customOrientationInfoStack : array<SCustomOrientationInfo>;
  5163. public function AddCustomOrientationTarget( orientationTarget : EOrientationTarget, sourceName : name )
  5164. {
  5165. var customOrientationInfo : SCustomOrientationInfo;
  5166. var i : int;
  5167.  
  5168. if ( customOrientationInfoStack.Size() > 0 )
  5169. {
  5170. for( i = customOrientationInfoStack.Size()-1; i>=0; i-=1 )
  5171. {
  5172. if ( customOrientationInfoStack[i].sourceName == sourceName )
  5173. customOrientationInfoStack.Erase(i);
  5174. }
  5175. }
  5176.  
  5177. customOrientationInfo.sourceName = sourceName;
  5178. customOrientationInfo.orientationTarget = orientationTarget;
  5179. customOrientationInfoStack.PushBack( customOrientationInfo );
  5180. SetOrientationTarget( orientationTarget );
  5181. }
  5182.  
  5183. public function RemoveCustomOrientationTarget( sourceName : name )
  5184. {
  5185. var customOrientationInfo : SCustomOrientationInfo;
  5186. var i : int;
  5187.  
  5188. if ( customOrientationInfoStack.Size() > 0 )
  5189. {
  5190. for( i = customOrientationInfoStack.Size()-1; i>=0; i-=1 )
  5191. {
  5192. if ( customOrientationInfoStack[i].sourceName == sourceName )
  5193. customOrientationInfoStack.Erase(i);
  5194. }
  5195. }
  5196. else
  5197. LogChannel( 'CustomOrienatation', "ERROR: Custom orientation cannot be removed, stack is already empty!!!" );
  5198. }
  5199.  
  5200. protected function ClearCustomOrientationInfoStack()
  5201. {
  5202. customOrientationInfoStack.Clear();
  5203. }
  5204.  
  5205. protected function GetCustomOrientationTarget( out infoStack : SCustomOrientationInfo ) : bool
  5206. {
  5207. var size : int;
  5208.  
  5209. size = customOrientationInfoStack.Size();
  5210.  
  5211. if ( size <= 0 )
  5212. return false;
  5213. else
  5214. {
  5215. infoStack = customOrientationInfoStack[ size - 1 ];
  5216. return true;
  5217. }
  5218. }
  5219.  
  5220. public function SetOrientationTargetCustomHeading( heading : float, sourceName : name ) : bool
  5221. {
  5222. var i : int;
  5223. if ( customOrientationInfoStack.Size() > 0 )
  5224. {
  5225. for( i = customOrientationInfoStack.Size()-1; i>=0; i-=1 )
  5226. {
  5227. if ( customOrientationInfoStack[i].sourceName == sourceName )
  5228. {
  5229. customOrientationInfoStack[i].customHeading = heading;
  5230. return true;
  5231. }
  5232. }
  5233. }
  5234.  
  5235. LogChannel( 'SetOrientationTargetCustomHeading', "ERROR: Cannot set customHeading because stack is empty or sourceName is not found!!!" );
  5236. return false;
  5237. }
  5238.  
  5239.  
  5240. public function GetOrientationTargetCustomHeading() : float
  5241. {
  5242. var i : int;
  5243. if ( customOrientationInfoStack.Size() > 0 )
  5244. {
  5245. for( i = customOrientationInfoStack.Size()-1; i>=0; i-=1 )
  5246. {
  5247. if ( customOrientationInfoStack[i].orientationTarget == OT_CustomHeading )
  5248. {
  5249. return customOrientationInfoStack[i].customHeading;
  5250. }
  5251. }
  5252. }
  5253.  
  5254. LogChannel( 'SetOrientationTargetCustomHeading', "ERROR: Cannot get customHeading because stack is empty or no OT_CustomHeading in stack!!!" );
  5255. return -1.f;
  5256. }
  5257.  
  5258. public function GetCombatActionOrientationTarget( combatActionType : ECombatActionType ) : EOrientationTarget
  5259. {
  5260. var newCustomOrientationTarget : EOrientationTarget;
  5261. var targetEnt : CGameplayEntity;
  5262. var targetActor : CActor;
  5263.  
  5264. if ( GetCurrentStateName() == 'AimThrow' )
  5265. newCustomOrientationTarget = OT_CameraOffset;
  5266. else
  5267. {
  5268. targetEnt = GetDisplayTarget();
  5269. targetActor = (CActor)targetEnt;
  5270.  
  5271. if ( targetEnt )
  5272. {
  5273. if ( targetActor )
  5274. {
  5275. if ( moveTarget )
  5276. newCustomOrientationTarget = OT_Actor;
  5277. else
  5278. {
  5279. if ( this.IsSwimming() )
  5280. newCustomOrientationTarget = OT_Camera;
  5281. else if ( lastAxisInputIsMovement )
  5282. newCustomOrientationTarget = OT_Player;
  5283. else
  5284. newCustomOrientationTarget = OT_Actor;
  5285. }
  5286. }
  5287. else
  5288. {
  5289. if ( combatActionType == CAT_Crossbow && targetEnt.HasTag( 'softLock_Bolt' ) )
  5290. newCustomOrientationTarget = OT_Actor;
  5291. else
  5292. {
  5293. if ( this.IsSwimming() )
  5294. newCustomOrientationTarget = OT_Camera;
  5295. else if ( lastAxisInputIsMovement )
  5296. newCustomOrientationTarget = OT_Player;
  5297. else
  5298. newCustomOrientationTarget = OT_Camera;
  5299.  
  5300. }
  5301. }
  5302. }
  5303. else
  5304. {
  5305. if ( IsUsingVehicle() )
  5306. newCustomOrientationTarget = OT_Camera;
  5307. else if ( lastAxisInputIsMovement )
  5308. {
  5309. if ( this.IsSwimming() )
  5310. {
  5311.  
  5312.  
  5313. newCustomOrientationTarget = OT_Camera;
  5314.  
  5315.  
  5316. }
  5317. else
  5318. newCustomOrientationTarget = OT_Player;
  5319.  
  5320. }
  5321. else
  5322. newCustomOrientationTarget = OT_Camera;
  5323. }
  5324. }
  5325.  
  5326. return newCustomOrientationTarget;
  5327. }
  5328.  
  5329. public function GetOrientationTargetHeading( orientationTarget : EOrientationTarget ) : float
  5330. {
  5331. var heading : float;
  5332.  
  5333. if( orientationTarget == OT_Camera )
  5334. heading = VecHeading( theCamera.GetCameraDirection() );
  5335. else if( orientationTarget == OT_CameraOffset )
  5336. heading = VecHeading( theCamera.GetCameraDirection() ) - oTCameraOffset;
  5337. else if( orientationTarget == OT_CustomHeading )
  5338. heading = GetOrientationTargetCustomHeading();
  5339. else if ( GetDisplayTarget() && orientationTarget == OT_Actor )
  5340. {
  5341. if ( (CActor)( GetDisplayTarget() ) )
  5342. {
  5343.  
  5344. heading = VecHeading( GetDisplayTarget().GetWorldPosition() - GetWorldPosition() );
  5345.  
  5346.  
  5347. }
  5348. else
  5349. {
  5350. if ( GetDisplayTarget().HasTag( 'softLock_Bolt' ) )
  5351. heading = VecHeading( GetDisplayTarget().GetWorldPosition() - GetWorldPosition() );
  5352. else
  5353. heading = GetHeading();
  5354. }
  5355. }
  5356. else
  5357. heading = GetHeading();
  5358.  
  5359. return heading;
  5360. }
  5361.  
  5362. event OnDelayOrientationChange()
  5363. {
  5364. var delayOrientation : bool;
  5365. var delayCameraRotation : bool;
  5366. var moveData : SCameraMovementData;
  5367. var time : float;
  5368.  
  5369. time = 0.01f;
  5370.  
  5371. if ( theInput.GetActionValue( 'CastSignHold' ) == 1.f )
  5372. {
  5373. actionType = 0;
  5374. if ( moveTarget )
  5375. delayOrientation = true;
  5376. else
  5377. {
  5378. if ( !GetBIsCombatActionAllowed() )
  5379. delayOrientation = true;
  5380. }
  5381.  
  5382.  
  5383. }
  5384. else if ( theInput.GetActionValue( 'ThrowItemHold' ) == 1.f )
  5385. {
  5386. actionType = 3;
  5387. delayOrientation = true;
  5388. }
  5389. else if ( theInput.GetActionValue( 'SpecialAttackHeavy' ) == 1.f )
  5390. {
  5391. actionType = 2;
  5392. if ( !slideTarget )
  5393. delayOrientation = true;
  5394. else
  5395. delayOrientation = true;
  5396. }
  5397. else if ( IsGuarded() && !moveTarget )
  5398. {
  5399. actionType = 1;
  5400. delayOrientation = true;
  5401. }
  5402.  
  5403. if ( delayOrientation )
  5404. {
  5405. delayOrientationChange = true;
  5406. theGame.GetGameCamera().ForceManualControlHorTimeout();
  5407. theGame.GetGameCamera().ForceManualControlVerTimeout();
  5408. AddTimer( 'DelayOrientationChangeTimer', time, true );
  5409. }
  5410.  
  5411. if ( delayCameraRotation )
  5412. {
  5413. delayCameraOrientationChange = true;
  5414. theGame.GetGameCamera().ForceManualControlHorTimeout();
  5415. theGame.GetGameCamera().ForceManualControlVerTimeout();
  5416. AddTimer( 'DelayOrientationChangeTimer', time, true );
  5417. }
  5418. }
  5419.  
  5420.  
  5421. event OnDelayOrientationChangeOff()
  5422. {
  5423. delayOrientationChange = false;
  5424. delayCameraOrientationChange = false;
  5425. RemoveTimer( 'DelayOrientationChangeTimer' );
  5426.  
  5427.  
  5428.  
  5429. }
  5430.  
  5431. timer function DelayOrientationChangeTimer( time : float , id : int)
  5432. {
  5433. if ( ( actionType == 0 && theInput.GetActionValue( 'CastSignHold' ) == 0.f )
  5434. || ( actionType == 2 && theInput.GetActionValue( 'SpecialAttackHeavy' ) == 0.f )
  5435. || ( actionType == 3 && theInput.GetActionValue( 'ThrowItemHold' ) == 0.f )
  5436. || ( actionType == 1 && !IsGuarded() )
  5437. || ( VecLength( rawRightJoyVec ) > 0.f ) )
  5438. {
  5439. OnDelayOrientationChangeOff();
  5440. }
  5441. }
  5442.  
  5443. public function SetCombatActionHeading( heading : float )
  5444. {
  5445. combatActionHeading = heading;
  5446. }
  5447.  
  5448. public function GetCombatActionHeading() : float
  5449. {
  5450. return combatActionHeading;
  5451. }
  5452.  
  5453. protected function EnableCloseCombatCharacterRadius( flag : bool )
  5454. {
  5455. var actor : CActor;
  5456.  
  5457. actor = (CActor)slideTarget;
  5458. if ( flag )
  5459. {
  5460. this.GetMovingAgentComponent().SetVirtualRadius( 'CloseCombatCharacterRadius' );
  5461. if(actor)
  5462. actor.GetMovingAgentComponent().SetVirtualRadius( 'CloseCombatCharacterRadius' );
  5463. }
  5464. else
  5465. {
  5466. if ( this.IsInCombat() )
  5467. {
  5468. GetMovingAgentComponent().SetVirtualRadius( 'CombatCharacterRadius' );
  5469. if(actor)
  5470. actor.GetMovingAgentComponent().SetVirtualRadius( 'CombatCharacterRadius' );
  5471. }
  5472. else
  5473. {
  5474. this.GetMovingAgentComponent().ResetVirtualRadius();
  5475. if(actor)
  5476. actor.GetMovingAgentComponent().ResetVirtualRadius();
  5477. }
  5478. }
  5479. }
  5480.  
  5481.  
  5482.  
  5483.  
  5484.  
  5485.  
  5486. private var isSnappedToNavMesh : bool;
  5487. private var snapToNavMeshCachedFlag : bool;
  5488. public function SnapToNavMesh( flag : bool )
  5489. {
  5490. var comp : CMovingAgentComponent;
  5491.  
  5492. comp = (CMovingAgentComponent)this.GetMovingAgentComponent();
  5493.  
  5494. if ( comp )
  5495. {
  5496. comp.SnapToNavigableSpace( flag );
  5497. isSnappedToNavMesh = flag;
  5498. }
  5499. else
  5500. {
  5501. snapToNavMeshCachedFlag = flag;
  5502. AddTimer( 'DelayedSnapToNavMesh', 0.2f );
  5503. }
  5504. }
  5505.  
  5506. public final function PlayRuneword4FX(optional weaponType : EPlayerWeapon)
  5507. {
  5508. var hasSwordDrawn : bool;
  5509. var sword : SItemUniqueId;
  5510.  
  5511.  
  5512.  
  5513.  
  5514. if(abilityManager.GetOverhealBonus() > (0.005 * GetStatMax(BCS_Vitality)))
  5515. {
  5516. hasSwordDrawn = HasAbility('Runeword 4 _Stats', true);
  5517.  
  5518. if(!hasSwordDrawn && GetWitcherPlayer())
  5519. {
  5520. if(weaponType == PW_Steel)
  5521. {
  5522. if(GetWitcherPlayer().GetItemEquippedOnSlot(EES_SteelSword, sword))
  5523. hasSwordDrawn = inv.ItemHasAbility(sword, 'Runeword 4 _Stats');
  5524. }
  5525. else if(weaponType == PW_Silver)
  5526. {
  5527. if(GetWitcherPlayer().GetItemEquippedOnSlot(EES_SilverSword, sword))
  5528. hasSwordDrawn = inv.ItemHasAbility(sword, 'Runeword 4 _Stats');
  5529. }
  5530. }
  5531.  
  5532. if(hasSwordDrawn)
  5533. {
  5534. if(!IsEffectActive('runeword_4', true))
  5535. PlayEffect('runeword_4');
  5536. }
  5537. }
  5538. }
  5539.  
  5540. timer function DelayedSnapToNavMesh( dt : float, id : int)
  5541. {
  5542. SnapToNavMesh( snapToNavMeshCachedFlag );
  5543. }
  5544.  
  5545. saved var navMeshSnapInfoStack : array<name>;
  5546. public function EnableSnapToNavMesh( source : name, enable : bool )
  5547. {
  5548. if ( enable )
  5549. {
  5550. if ( !navMeshSnapInfoStack.Contains( source ) )
  5551. navMeshSnapInfoStack.PushBack( source );
  5552. }
  5553. else
  5554. {
  5555. if ( navMeshSnapInfoStack.Contains( source ) )
  5556. navMeshSnapInfoStack.Remove( source );
  5557. }
  5558.  
  5559. if ( navMeshSnapInfoStack.Size() > 0 )
  5560. SnapToNavMesh( true );
  5561. else
  5562. SnapToNavMesh( false );
  5563. }
  5564.  
  5565. public function ForceRemoveAllNavMeshSnaps()
  5566. {
  5567. navMeshSnapInfoStack.Clear();
  5568. SnapToNavMesh( false );
  5569. }
  5570.  
  5571. public function CanSprint( speed : float ) : bool
  5572. {
  5573. if( speed <= 0.8f )
  5574. {
  5575. return false;
  5576. }
  5577.  
  5578. if ( thePlayer.GetIsSprintToggled() )
  5579. {
  5580. }
  5581. else if ( !sprintActionPressed )
  5582. {
  5583. return false;
  5584. }
  5585. else if( !theInput.IsActionPressed('Sprint') || ( theInput.LastUsedGamepad() && IsInsideInteraction() && GetHowLongSprintButtonWasPressed() < 0.12 ) )
  5586. {
  5587. return false;
  5588. }
  5589.  
  5590. if ( thePlayer.HasBuff( EET_OverEncumbered ) )
  5591. {
  5592. return false;
  5593. }
  5594. if ( !IsSwimming() )
  5595. {
  5596. if ( ShouldUseStaminaWhileSprinting() && !GetIsSprinting() && !IsInCombat() && GetStatPercents(BCS_Stamina) <= 0.9 )
  5597. {
  5598. return false;
  5599. }
  5600. if( ( !IsCombatMusicEnabled() || IsInFistFightMiniGame() ) && ( !IsActionAllowed(EIAB_RunAndSprint) || !IsActionAllowed(EIAB_Sprint) ) )
  5601. {
  5602. return false;
  5603. }
  5604. if( IsTerrainTooSteepToRunUp() )
  5605. {
  5606. return false;
  5607. }
  5608. if( IsInCombatAction() )
  5609. {
  5610. return false;
  5611. }
  5612. if( IsInAir() )
  5613. {
  5614. return false;
  5615. }
  5616. }
  5617. if( theGame.IsFocusModeActive() )
  5618. {
  5619. return false;
  5620. }
  5621.  
  5622. return true;
  5623. }
  5624.  
  5625.  
  5626. public function SetTerrainPitch( pitch : float )
  5627. {
  5628. terrainPitch = pitch;
  5629. }
  5630.  
  5631. public function IsTerrainTooSteepToRunUp() : bool
  5632. {
  5633. return terrainPitch <= disableSprintTerrainPitch;
  5634. }
  5635.  
  5636. public function SetTempLookAtTarget( actor : CGameplayEntity )
  5637. {
  5638. tempLookAtTarget = actor;
  5639. }
  5640.  
  5641. private var beingWarnedBy : array<CActor>;
  5642.  
  5643. event OnBeingWarnedStart( sender : CActor )
  5644. {
  5645. if ( !beingWarnedBy.Contains(sender) )
  5646. beingWarnedBy.PushBack(sender);
  5647. }
  5648. event OnBeingWarnedStop( sender : CActor )
  5649. {
  5650. beingWarnedBy.Remove(sender);
  5651. }
  5652.  
  5653. event OnCanFindPath( sender : CActor )
  5654. {
  5655. AddCanFindPathEnemyToList(sender,true);
  5656. }
  5657. event OnCannotFindPath( sender : CActor )
  5658. {
  5659. AddCanFindPathEnemyToList(sender,false);
  5660. }
  5661. event OnBecomeAwareAndCanAttack( sender : CActor )
  5662. {
  5663. AddEnemyToHostileEnemiesList( sender, true );
  5664. OnApproachAttack( sender );
  5665. }
  5666. event OnBecomeUnawareOrCannotAttack( sender : CActor )
  5667. {
  5668. AddEnemyToHostileEnemiesList( sender, false );
  5669. OnApproachAttackEnd( sender );
  5670. OnCannotFindPath(sender);
  5671. }
  5672. event OnApproachAttack( sender : CActor )
  5673. {
  5674. AddEnemyToHostileEnemiesList( sender, true );
  5675. super.OnApproachAttack( sender );
  5676. }
  5677. event OnApproachAttackEnd( sender : CActor )
  5678. {
  5679. AddEnemyToHostileEnemiesList( sender, false );
  5680. super.OnApproachAttackEnd( sender );
  5681. }
  5682. event OnAttack( sender : CActor )
  5683. {
  5684. super.OnAttack( sender );
  5685. }
  5686. event OnAttackEnd( sender : CActor )
  5687. {
  5688. super.OnAttackEnd( sender );
  5689. }
  5690.  
  5691. event OnHitCeiling()
  5692. {
  5693. substateManager.ReactOnHitCeiling();
  5694. }
  5695.  
  5696. protected var hostileEnemies : array<CActor>;
  5697. private var hostileMonsters : array<CActor>;
  5698. function AddEnemyToHostileEnemiesList( actor : CActor, add : bool )
  5699. {
  5700. if ( add )
  5701. {
  5702. RemoveTimer( 'RemoveEnemyFromHostileEnemiesListTimer' );
  5703. if ( !hostileEnemies.Contains( actor ) )
  5704. {
  5705. hostileEnemies.PushBack( actor );
  5706.  
  5707. if( !actor.IsHuman() )
  5708. hostileMonsters.PushBack( actor );
  5709. }
  5710. }
  5711. else
  5712. {
  5713. if ( hostileEnemies.Size() == 1 )
  5714. {
  5715. if ( !actor.IsAlive() || actor.IsKnockedUnconscious() )
  5716. {
  5717. hostileEnemies.Remove( actor );
  5718. if( !actor.IsHuman() )
  5719. hostileMonsters.Remove( actor );
  5720. }
  5721. else
  5722. {
  5723.  
  5724. if( hostileEnemyToRemove )
  5725. {
  5726. hostileEnemies.Remove( hostileEnemyToRemove );
  5727. if( !hostileEnemyToRemove.IsHuman() )
  5728. hostileMonsters.Remove( hostileEnemyToRemove );
  5729. }
  5730. hostileEnemyToRemove = actor;
  5731. AddTimer( 'RemoveEnemyFromHostileEnemiesListTimer', 3.f );
  5732. }
  5733. }
  5734. else
  5735. {
  5736. hostileEnemies.Remove( actor );
  5737. if( !actor.IsHuman() )
  5738. hostileMonsters.Remove( actor );
  5739. }
  5740. }
  5741. }
  5742.  
  5743.  
  5744.  
  5745. public function ShouldEnableCombatMusic() : bool
  5746. {
  5747. var moveTargetNPC : CNewNPC;
  5748.  
  5749. if ( thePlayer.GetPlayerMode().GetForceCombatMode() )
  5750. return true;
  5751. else if ( !IsCombatMusicEnabled() )
  5752. {
  5753. if ( IsInCombat() )
  5754. return true;
  5755. else if ( IsThreatened() )
  5756. {
  5757. moveTargetNPC = (CNewNPC)moveTarget;
  5758. if ( moveTargetNPC.IsRanged() && hostileEnemies.Contains( moveTargetNPC ) )
  5759. return true;
  5760. else
  5761. return false;
  5762. }
  5763. else
  5764. return false;
  5765. }
  5766. else if ( ( thePlayer.IsThreatened() && ( hostileEnemies.Size() > 0 || thePlayer.GetPlayerCombatStance() == PCS_AlertNear ) )
  5767. || IsInCombat()
  5768. || finishableEnemiesList.Size() > 0
  5769. || isInFinisher )
  5770. return true;
  5771. else
  5772. return false;
  5773.  
  5774. }
  5775.  
  5776. public var canFindPathEnemiesList : array<CActor>;
  5777. public var disablecanFindPathEnemiesListUpdate : bool;
  5778. private var lastCanFindPathEnemy : CActor;
  5779. private var cachedMoveTarget : CActor;
  5780. private var reachabilityTestId : int;
  5781. private var reachabilityTestId2 : int;
  5782. function AddCanFindPathEnemyToList( actor : CActor, add : bool )
  5783. {
  5784. if ( disablecanFindPathEnemiesListUpdate )
  5785. return;
  5786.  
  5787. if ( add && !canFindPathEnemiesList.Contains( actor ) )
  5788. {
  5789. canFindPathEnemiesList.PushBack(actor);
  5790. }
  5791. else if ( !add )
  5792. {
  5793. canFindPathEnemiesList.Remove(actor);
  5794.  
  5795. if ( canFindPathEnemiesList.Size() <= 0 )
  5796. playerMode.UpdateCombatMode();
  5797. }
  5798. }
  5799.  
  5800. public function ClearCanFindPathEnemiesList( dt : float, id : int )
  5801. {
  5802. canFindPathEnemiesList.Clear();
  5803. }
  5804.  
  5805. public var finishableEnemiesList : array<CActor>;
  5806. function AddToFinishableEnemyList( actor : CActor, add : bool )
  5807. {
  5808. if ( add && !finishableEnemiesList.Contains( actor ) )
  5809. {
  5810. finishableEnemiesList.PushBack(actor);
  5811. }
  5812. else if ( !add )
  5813. {
  5814. finishableEnemiesList.Remove(actor);
  5815. }
  5816. }
  5817.  
  5818. private function UpdateFinishableEnemyList()
  5819. {
  5820. var i : int;
  5821. i = 0;
  5822. while ( i < finishableEnemiesList.Size() )
  5823. {
  5824. if ( !finishableEnemiesList[ i ] )
  5825. {
  5826. finishableEnemiesList.EraseFast( i );
  5827. }
  5828. else
  5829. {
  5830. i += 1;
  5831. }
  5832. }
  5833. }
  5834.  
  5835. private timer function ClearFinishableEnemyList( dt : float, id : int )
  5836. {
  5837. finishableEnemiesList.Clear();
  5838. }
  5839.  
  5840. private var hostileEnemyToRemove : CActor;
  5841. private timer function RemoveEnemyFromHostileEnemiesListTimer( time : float , id : int)
  5842. {
  5843. hostileEnemies.Remove( hostileEnemyToRemove );
  5844.  
  5845. if( hostileEnemyToRemove.IsMonster() )
  5846. hostileMonsters.Remove( hostileEnemyToRemove );
  5847.  
  5848. hostileEnemyToRemove = NULL;
  5849. }
  5850.  
  5851. private function ClearHostileEnemiesList()
  5852. {
  5853. hostileEnemies.Clear();
  5854. hostileMonsters.Clear();
  5855. canFindPathEnemiesList.Clear();
  5856. }
  5857.  
  5858. private var moveTargets : array<CActor>;
  5859. public function GetMoveTargets() : array<CActor> { return moveTargets; }
  5860. public function GetNumberOfMoveTargets() : int { return moveTargets.Size(); }
  5861. public function GetHostileEnemies() : array<CActor> { return hostileEnemies; }
  5862. public function GetHostileEnemiesCount() : int { return hostileEnemies.Size(); }
  5863.  
  5864. protected var enableStrafe : bool;
  5865.  
  5866.  
  5867. public function FindMoveTarget()
  5868. {
  5869. var moveTargetDists : array<float>;
  5870. var moveTargetCanPathFinds : array<bool>;
  5871. var aPotentialMoveTargetCanFindPath : bool;
  5872.  
  5873. var newMoveTarget : CActor;
  5874. var actors : array<CActor>;
  5875. var currentHeading : float;
  5876. var size, i : int;
  5877. var playerToNewMoveTargetDist : float;
  5878. var playerToMoveTargetDist : float;
  5879. var confirmEmptyMoveTarget : bool;
  5880. var newEmptyMoveTargetTimer : float;
  5881. var wasVisibleInFullFrame : bool;
  5882. var setIsThreatened : bool;
  5883.  
  5884. var enemysTarget : CActor;
  5885. var isEnemyInCombat : bool;
  5886. var potentialMoveTargets : array<CActor>;
  5887. var onlyThreatTargets : bool;
  5888.  
  5889. thePlayer.SetupEnemiesCollection( enemyCollectionDist, enemyCollectionDist, 10, 'None', FLAG_Attitude_Neutral + FLAG_Attitude_Hostile + FLAG_Attitude_Friendly + FLAG_OnlyAliveActors );
  5890.  
  5891.  
  5892.  
  5893.  
  5894. if ( GetCurrentStateName() != 'PlayerDialogScene' && IsAlive() )
  5895. {
  5896. GetVisibleEnemies( actors );
  5897.  
  5898.  
  5899. if ( hostileEnemies.Size() > 0 )
  5900. {
  5901. for( i=0; i < hostileEnemies.Size() ; i+=1 )
  5902. {
  5903. if ( !actors.Contains( hostileEnemies[i] ) )
  5904. actors.PushBack( hostileEnemies[i] );
  5905. }
  5906. }
  5907.  
  5908.  
  5909. if ( finishableEnemiesList.Size() > 0 )
  5910. {
  5911. for( i=0; i < finishableEnemiesList.Size() ; i+=1 )
  5912. {
  5913. if ( !actors.Contains( finishableEnemiesList[i] ) )
  5914. actors.PushBack( finishableEnemiesList[i] );
  5915. }
  5916. }
  5917.  
  5918.  
  5919. if ( moveTarget && !actors.Contains( moveTarget ) )
  5920. actors.PushBack( moveTarget );
  5921.  
  5922. FilterActors( actors, onlyThreatTargets, false );
  5923.  
  5924.  
  5925. if ( actors.Size() > 0 )
  5926. {
  5927. setIsThreatened = false;
  5928.  
  5929. if ( onlyThreatTargets )
  5930. {
  5931. setIsThreatened = true;
  5932. }
  5933. else
  5934. {
  5935. for( i=0; i < actors.Size() ; i+=1 )
  5936. {
  5937. if ( IsThreat( actors[i] ) )
  5938. {
  5939. setIsThreatened = true;
  5940. break;
  5941. }
  5942. else
  5943. {
  5944. enemysTarget = actors[i].GetTarget();
  5945. isEnemyInCombat = actors[i].IsInCombat();
  5946. if ( isEnemyInCombat && enemysTarget && GetAttitudeBetween( enemysTarget, this ) == AIA_Friendly && enemysTarget.isPlayerFollower )
  5947. {
  5948. setIsThreatened = true;
  5949. break;
  5950. }
  5951. }
  5952. }
  5953. }
  5954.  
  5955.  
  5956. for( i = actors.Size()-1; i>=0; i-=1 )
  5957. {
  5958. if ( ( !actors[i].IsAlive() && !finishableEnemiesList.Contains( actors[i] ) )
  5959. || actors[i].IsKnockedUnconscious()
  5960. || this.GetUsedVehicle() == actors[i]
  5961. || !actors[i].CanBeTargeted() )
  5962. {
  5963. actors.EraseFast(i);
  5964. }
  5965. else if ( !IsThreatened() )
  5966. {
  5967. if ( !WasVisibleInScaledFrame( actors[i], 1.f, 1.f ) )
  5968. actors.EraseFast(i);
  5969. }
  5970. }
  5971. }
  5972. else if ( moveTarget && IsThreat( moveTarget ) )
  5973. setIsThreatened = true;
  5974.  
  5975. else
  5976. setIsThreatened = false;
  5977.  
  5978.  
  5979. if ( setIsThreatened )
  5980. {
  5981. enemyCollectionDist = 50.f;
  5982. SetIsThreatened( true );
  5983. }
  5984. else
  5985. {
  5986. if ( IsThreatened() )
  5987. AddTimer( 'finishableEnemiesList', 1.f );
  5988.  
  5989. enemyCollectionDist = findMoveTargetDistMax;
  5990. SetIsThreatened( false );
  5991. }
  5992.  
  5993. moveTargets = actors;
  5994. potentialMoveTargets = moveTargets;
  5995.  
  5996.  
  5997. if ( !moveTarget )
  5998. enableStrafe = false;
  5999.  
  6000. if ( potentialMoveTargets.Size() > 0 )
  6001. {
  6002. for ( i = 0; i < potentialMoveTargets.Size(); i += 1 )
  6003. {
  6004. if ( potentialMoveTargets[i].CanBeStrafed() )
  6005. enableStrafe = true;
  6006.  
  6007. if ( !potentialMoveTargets[i].GetGameplayVisibility() )
  6008. moveTargetDists.PushBack( 100.f );
  6009. else
  6010. moveTargetDists.PushBack( VecDistance( potentialMoveTargets[i].GetNearestPointInPersonalSpace( GetWorldPosition() ), GetWorldPosition() ) );
  6011.  
  6012. if ( canFindPathEnemiesList.Contains( potentialMoveTargets[i] ) )
  6013. {
  6014. moveTargetCanPathFinds.PushBack( true );
  6015. aPotentialMoveTargetCanFindPath = true;
  6016. }
  6017. else
  6018. {
  6019. moveTargetCanPathFinds.PushBack( false );
  6020. }
  6021. }
  6022.  
  6023. if ( aPotentialMoveTargetCanFindPath )
  6024. {
  6025. for ( i = moveTargetCanPathFinds.Size()-1 ; i >= 0; i-=1 )
  6026. {
  6027. if ( !moveTargetCanPathFinds[i] )
  6028. {
  6029. moveTargetCanPathFinds.EraseFast(i);
  6030. potentialMoveTargets.EraseFast(i);
  6031. moveTargetDists.EraseFast(i);
  6032. }
  6033. }
  6034. }
  6035.  
  6036. if ( moveTargetDists.Size() > 0 )
  6037. newMoveTarget = potentialMoveTargets[ ArrayFindMinF( moveTargetDists ) ];
  6038. }
  6039.  
  6040. if ( newMoveTarget && newMoveTarget != moveTarget )
  6041. {
  6042. if ( moveTarget )
  6043. {
  6044. playerToNewMoveTargetDist = VecDistance( newMoveTarget.GetNearestPointInPersonalSpace( GetWorldPosition() ), GetWorldPosition() );
  6045. playerToMoveTargetDist = VecDistance( moveTarget.GetNearestPointInPersonalSpace( GetWorldPosition() ), GetWorldPosition() );
  6046. wasVisibleInFullFrame = WasVisibleInScaledFrame( moveTarget, 1.f, 1.f ) ;
  6047.  
  6048. if ( !IsThreat( moveTarget )
  6049. || !wasVisibleInFullFrame
  6050. || !IsEnemyVisible( moveTarget )
  6051. || ( !moveTarget.IsAlive() && !finishableEnemiesList.Contains( moveTarget ) )
  6052. || !moveTarget.GetGameplayVisibility()
  6053. || ( moveTarget.IsAlive() && moveTarget.IsKnockedUnconscious() )
  6054. || ( wasVisibleInFullFrame && IsEnemyVisible( moveTarget ) && playerToNewMoveTargetDist < playerToMoveTargetDist - 0.25f ) )
  6055. {
  6056. SetMoveTarget( newMoveTarget );
  6057. }
  6058. }
  6059. else
  6060. SetMoveTarget( newMoveTarget );
  6061. }
  6062.  
  6063.  
  6064. if ( !IsThreatened() )
  6065. {
  6066. if ( moveTarget
  6067. && ( ( !moveTarget.IsAlive() && !finishableEnemiesList.Contains( moveTarget ) ) || !WasVisibleInScaledFrame( moveTarget, 0.8f, 1.f ) || VecDistance( moveTarget.GetWorldPosition(), this.GetWorldPosition() ) > theGame.params.MAX_THROW_RANGE ) )
  6068. {
  6069. confirmEmptyMoveTarget = true;
  6070. newEmptyMoveTargetTimer = 0.f;
  6071. }
  6072. }
  6073.  
  6074. else if ( moveTarget && ( IsThreat( moveTarget ) || finishableEnemiesList.Contains( moveTarget ) ) )
  6075. {
  6076. if ( !IsEnemyVisible( moveTarget ) )
  6077. {
  6078. confirmEmptyMoveTarget = true;
  6079. newEmptyMoveTargetTimer = 5.f;
  6080. }
  6081. else
  6082. SetMoveTarget( moveTarget );
  6083. }
  6084. else if ( IsInCombat() )
  6085. {
  6086. confirmEmptyMoveTarget = true;
  6087. newEmptyMoveTargetTimer = 1.0f;
  6088. }
  6089.  
  6090. if ( confirmEmptyMoveTarget )
  6091. {
  6092. if ( newEmptyMoveTargetTimer < emptyMoveTargetTimer )
  6093. {
  6094. bIsConfirmingEmptyTarget = false;
  6095. emptyMoveTargetTimer = newEmptyMoveTargetTimer;
  6096. }
  6097.  
  6098. ConfirmEmptyMoveTarget( newEmptyMoveTargetTimer );
  6099. }
  6100. }
  6101. else
  6102. SetIsThreatened( false );
  6103.  
  6104.  
  6105. if ( IsThreatened() && !IsInFistFightMiniGame() )
  6106. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'CombatNearbyAction', 5.0, 18.0f, -1.f, -1, true );
  6107. else
  6108. theGame.GetBehTreeReactionManager().RemoveReactionEvent( this, 'CombatNearbyAction');
  6109.  
  6110.  
  6111. theSound.SoundParameter( "monster_count", hostileMonsters.Size() );
  6112. }
  6113.  
  6114. private function ConfirmEmptyMoveTarget( timeDelta : float )
  6115. {
  6116. if ( !bIsConfirmingEmptyTarget )
  6117. {
  6118. bIsConfirmingEmptyTarget = true;
  6119. AddTimer( 'ConfirmEmptyTargetTimer', timeDelta );
  6120. }
  6121. }
  6122.  
  6123. private timer function ConfirmEmptyTargetTimer( time : float , id : int)
  6124. {
  6125. SetMoveTarget( NULL );
  6126. }
  6127.  
  6128.  
  6129. var isInCombatReason : int;
  6130. var canFindPathToEnemy : bool;
  6131. var combatModeEnt : CEntity;
  6132. var navDist : float;
  6133. var directDist : float;
  6134. var reachableEnemyWasTooFar : bool;
  6135. var reachableEnemyWasTooFarTimeStamp : float;
  6136. var reachablilityFailed : bool;
  6137. var reachablilityFailedTimeStamp : float;
  6138. public function ShouldEnableCombat( out unableToPathFind : bool, forceCombatMode : bool ) : bool
  6139. {
  6140. var shouldFindPathToNPCs : bool;
  6141. var playerToTargetDist : float;
  6142. var canFindPathToTarget : bool;
  6143. var moveTargetNPC : CNewNPC;
  6144. var currentTime : float;
  6145. var currentTime2 : float;
  6146. var isReachableEnemyTooFar : bool;
  6147. var reachableEnemyWasTooFarTimeStampDelta : float;
  6148. var reachablilityFailedTimeStampDelta : float;
  6149. var currentTimeTemp : float;
  6150.  
  6151.  
  6152.  
  6153. if ( forceCombatMode && isSnappedToNavMesh )
  6154. return true;
  6155.  
  6156. if ( !IsThreatened() )
  6157. {
  6158. reachableEnemyWasTooFar = false;
  6159. reachablilityFailed = false;
  6160. isInCombatReason = 0;
  6161. return false;
  6162. }
  6163.  
  6164. if( thePlayer.substateManager.GetStateCur() != 'CombatExploration' && !thePlayer.substateManager.CanChangeToState( 'CombatExploration' )
  6165. && thePlayer.substateManager.GetStateCur() != 'Ragdoll' )
  6166. {
  6167. reachableEnemyWasTooFar = false;
  6168. reachablilityFailed = false;
  6169. isInCombatReason = 0;
  6170. return false;
  6171. }
  6172.  
  6173. if ( moveTarget )
  6174. {
  6175. canFindPathToEnemy = CanFindPathToTarget( unableToPathFind );
  6176. currentTimeTemp = EngineTimeToFloat( theGame.GetEngineTime() );
  6177.  
  6178. if ( canFindPathToEnemy )
  6179. isReachableEnemyTooFar = IsReachableEnemyTooFar();
  6180.  
  6181. if ( IsInCombat() )
  6182. {
  6183. if ( canFindPathToEnemy )
  6184. {
  6185. if ( forceCombatMode )
  6186. return true;
  6187.  
  6188. reachablilityFailed = false;
  6189. reachablilityFailedTimeStamp = currentTimeTemp;
  6190.  
  6191. if ( reachableEnemyWasTooFar )
  6192. {
  6193. if ( isReachableEnemyTooFar )
  6194. {
  6195. currentTime = currentTimeTemp;
  6196.  
  6197. if ( GetIsSprinting() )
  6198. reachableEnemyWasTooFarTimeStampDelta = 0.f;
  6199. else
  6200. reachableEnemyWasTooFarTimeStampDelta = 3.f;
  6201.  
  6202. if ( currentTime > reachableEnemyWasTooFarTimeStamp + reachableEnemyWasTooFarTimeStampDelta )
  6203. {
  6204. isInCombatReason = 0;
  6205. unableToPathFind = true;
  6206. return false;
  6207. }
  6208. }
  6209. else
  6210. reachableEnemyWasTooFar = false;
  6211. }
  6212. else
  6213. {
  6214. if ( isReachableEnemyTooFar )
  6215. {
  6216. reachableEnemyWasTooFar = true;
  6217. reachableEnemyWasTooFarTimeStamp = currentTimeTemp;
  6218. }
  6219. else
  6220. reachableEnemyWasTooFar = false;
  6221. }
  6222.  
  6223. return true;
  6224. }
  6225. else
  6226. {
  6227. reachableEnemyWasTooFar = false;
  6228. reachableEnemyWasTooFarTimeStamp = currentTimeTemp;
  6229.  
  6230. if ( reachablilityFailed )
  6231. {
  6232. if ( IsEnemyTooHighToReach() )
  6233. reachablilityFailedTimeStampDelta = 1.f;
  6234. else
  6235. reachablilityFailedTimeStampDelta = 5.f;
  6236.  
  6237. currentTime2 = currentTimeTemp;
  6238. if ( currentTime2 > reachablilityFailedTimeStamp + reachablilityFailedTimeStampDelta )
  6239. {
  6240. unableToPathFind = true;
  6241. return false;
  6242. }
  6243. }
  6244. else
  6245. {
  6246. reachablilityFailed = true;
  6247. reachablilityFailedTimeStamp = currentTimeTemp;
  6248. }
  6249.  
  6250. return true;
  6251. }
  6252. }
  6253. else if ( canFindPathToEnemy )
  6254. {
  6255. if ( forceCombatMode )
  6256. {
  6257. reachableEnemyWasTooFar = false;
  6258. return true;
  6259. }
  6260.  
  6261. reachablilityFailed = false;
  6262. reachablilityFailedTimeStamp = currentTimeTemp;
  6263.  
  6264. moveTargetNPC = (CNewNPC)moveTarget;
  6265. playerToTargetDist = VecDistance( moveTarget.GetWorldPosition(), this.GetWorldPosition() );
  6266.  
  6267. if ( reachableEnemyWasTooFar
  6268. && ( isReachableEnemyTooFar || !theGame.GetWorld().NavigationLineTest( this.GetWorldPosition(), moveTarget.GetWorldPosition(), 0.4f ) ) )
  6269. {
  6270. isInCombatReason = 0;
  6271. return false;
  6272. }
  6273. else if ( playerToTargetDist <= findMoveTargetDistMin )
  6274. isInCombatReason = 1;
  6275. else if ( ( moveTargetNPC.GetCurrentStance() == NS_Fly || moveTargetNPC.IsRanged() ) && hostileEnemies.Contains( moveTarget ) )
  6276. isInCombatReason = 2;
  6277. else
  6278. {
  6279. isInCombatReason = 0;
  6280. return false;
  6281. }
  6282.  
  6283. reachableEnemyWasTooFar = false;
  6284. return true;
  6285. }
  6286. }
  6287. else
  6288. {
  6289. reachableEnemyWasTooFar = false;
  6290. reachablilityFailed = false;
  6291. }
  6292.  
  6293. isInCombatReason = 0;
  6294. return false;
  6295. }
  6296.  
  6297. private function CanFindPathToTarget( out unableToPathFind : bool, optional forcedTarget : CNewNPC ) : bool
  6298. {
  6299. var moveTargetNPC : CNewNPC;
  6300. var moveTargetsTemp : array<CActor>;
  6301. var i : int;
  6302. var safeSpotTolerance : float;
  6303. var ent : CEntity;
  6304.  
  6305. moveTargetsTemp = moveTargets;
  6306.  
  6307. for ( i = 0; i < moveTargetsTemp.Size(); i += 1 )
  6308. {
  6309. moveTargetNPC = (CNewNPC)moveTargetsTemp[i];
  6310.  
  6311. if ( moveTargetNPC && moveTargetNPC.GetCurrentStance() == NS_Fly )
  6312. {
  6313. isInCombatReason = 2;
  6314. return true;
  6315. }
  6316. }
  6317.  
  6318. switch ( navQuery.GetLastOutput( 0.4 ) )
  6319. {
  6320. case EAsyncTastResult_Failure:
  6321. {
  6322. isInCombatReason = 0;
  6323. return false;
  6324. }
  6325. case EAsyncTastResult_Success:
  6326. {
  6327. ent = navQuery.GetOutputClosestEntity();
  6328.  
  6329. if ( ent )
  6330. combatModeEnt = moveTarget;
  6331.  
  6332. navDist = navQuery.GetOutputClosestDistance();
  6333.  
  6334. isInCombatReason = 1;
  6335. return true;
  6336. }
  6337. case EAsyncTastResult_Pending:
  6338. {
  6339. return canFindPathToEnemy;
  6340. }
  6341. case EAsyncTastResult_Invalidated:
  6342. {
  6343. if ( IsInCombat() )
  6344. {
  6345. if ( IsEnemyTooHighToReach() )
  6346. safeSpotTolerance = 0.f;
  6347. else
  6348. safeSpotTolerance = 3.f;
  6349. }
  6350. else
  6351. safeSpotTolerance = 0.f;
  6352.  
  6353. switch( navQuery.TestActorsList( ENavigationReachability_Any, this, moveTargetsTemp, safeSpotTolerance, 75.0 ) )
  6354. {
  6355. case EAsyncTastResult_Failure:
  6356. {
  6357. isInCombatReason = 0;
  6358. return false;
  6359. }
  6360. case EAsyncTastResult_Success:
  6361. {
  6362. ent = navQuery.GetOutputClosestEntity();
  6363.  
  6364. if ( ent )
  6365. combatModeEnt = moveTarget;
  6366.  
  6367. navDist = navQuery.GetOutputClosestDistance();
  6368.  
  6369. isInCombatReason = 1;
  6370. return true;
  6371. }
  6372. case EAsyncTastResult_Pending:
  6373. {
  6374. return canFindPathToEnemy;
  6375. }
  6376. case EAsyncTastResult_Invalidated:
  6377. {
  6378. if ( IsInCombat() )
  6379. return true;
  6380. else
  6381. return false;
  6382. }
  6383. }
  6384. }
  6385. }
  6386. }
  6387.  
  6388. private function IsReachableEnemyTooFar() : bool
  6389. {
  6390.  
  6391. var navDistLimit : float = findMoveTargetDist;
  6392. var navDistDivisor : float = 2.f;
  6393. var playerToTargetVector : Vector;
  6394.  
  6395. directDist = VecDistance( combatModeEnt.GetWorldPosition(), thePlayer.GetWorldPosition() );
  6396. playerToTargetVector = this.GetWorldPosition() - combatModeEnt.GetWorldPosition();
  6397.  
  6398. if ( playerMode.GetForceCombatMode() || isInCombatReason == 2 )
  6399. return false;
  6400.  
  6401. if ( ( playerToTargetVector.Z < 0.5 && navDist > navDistLimit && directDist < navDist/navDistDivisor ) )
  6402. return true;
  6403. else
  6404. return false;
  6405. }
  6406.  
  6407. private function IsEnemyTooHighToReach() : bool
  6408. {
  6409. var playerToTargetVector : Vector;
  6410.  
  6411. playerToTargetVector = this.GetWorldPosition() - combatModeEnt.GetWorldPosition();
  6412.  
  6413. if ( playerToTargetVector.Z < -0.5f && !theGame.GetWorld().NavigationLineTest( this.GetWorldPosition(), combatModeEnt.GetWorldPosition(), 0.4f ) )
  6414. return true;
  6415. else
  6416. return false;
  6417. }
  6418.  
  6419.  
  6420. public function LockToMoveTarget( lockTime : float )
  6421. {
  6422.  
  6423. }
  6424.  
  6425. private timer function DisableLockToMoveTargetTimer( time : float , id : int)
  6426. {
  6427. if ( !this.IsActorLockedToTarget() )
  6428. {
  6429. SetMoveTargetChangeAllowed( true );
  6430. }
  6431. }
  6432.  
  6433. public function SetMoveTargetChangeAllowed( flag : bool )
  6434. {
  6435.  
  6436. }
  6437.  
  6438. public function IsMoveTargetChangeAllowed() : bool
  6439. {
  6440. return bMoveTargetChangeAllowed;
  6441. }
  6442.  
  6443. public function SetMoveTarget( actor : CActor )
  6444. {
  6445. if ( !actor && ForceCombatModeOverride() )
  6446. return;
  6447.  
  6448. if ( IsMoveTargetChangeAllowed()
  6449. && moveTarget != actor )
  6450. {
  6451. moveTarget = actor;
  6452. bIsConfirmingEmptyTarget = false;
  6453. RemoveTimer( 'ConfirmEmptyTargetTimer' );
  6454.  
  6455. if ( !moveTarget )
  6456. SetScriptMoveTarget( moveTarget );
  6457. }
  6458. }
  6459.  
  6460. private var isThreatened : bool;
  6461. protected function SetIsThreatened( flag : bool )
  6462. {
  6463. var allowSetIsThreatened : bool;
  6464.  
  6465. allowSetIsThreatened = true;
  6466. if ( ForceCombatModeOverride() )
  6467. {
  6468. if ( flag || !moveTarget )
  6469. allowSetIsThreatened = true;
  6470. else
  6471. allowSetIsThreatened = false;
  6472. }
  6473.  
  6474. if ( allowSetIsThreatened )
  6475. {
  6476. isThreatened = flag;
  6477. }
  6478. }
  6479.  
  6480. public function ForceCombatModeOverride() : bool
  6481. {
  6482. if( this.GetPlayerMode().GetForceCombatMode()
  6483. && canFindPathToEnemy
  6484. && theGame.GetGlobalAttitude( GetBaseAttitudeGroup(), moveTarget.GetBaseAttitudeGroup() ) == AIA_Hostile )
  6485. return true;
  6486. else
  6487. return false;
  6488. }
  6489.  
  6490. public function IsThreatened() : bool { return isThreatened; }
  6491.  
  6492. public function EnableFindTarget( flag : bool )
  6493. {
  6494. var target : CActor;
  6495.  
  6496. if( IsActorLockedToTarget() )
  6497. {
  6498. target = GetTarget();
  6499.  
  6500. if ( target && target.IsAlive() )
  6501. bCanFindTarget = flag;
  6502. else
  6503. bCanFindTarget = true;
  6504. }
  6505. else
  6506. bCanFindTarget = flag;
  6507. }
  6508.  
  6509. public function UpdateDisplayTarget( optional forceUpdate : bool, optional forceNullActor : bool )
  6510. {
  6511. var hud : CR4ScriptedHud;
  6512. var tempTarget : CGameplayEntity;
  6513. var angleDist1 : float;
  6514. var angleDist2 : float;
  6515. var nonActorTargetMult : float;
  6516. var combatActionType : int;
  6517. var currTarget : CActor;
  6518. var interactionTarget : CInteractionComponent;
  6519.  
  6520. var heading : float;
  6521.  
  6522. if(theGame.IsDialogOrCutscenePlaying())
  6523. {
  6524. currentSelectedDisplayTarget = NULL;
  6525.  
  6526. if ( displayTarget )
  6527. ConfirmDisplayTarget( NULL );
  6528.  
  6529. return;
  6530. }
  6531.  
  6532. if ( forceNullActor )
  6533. currTarget = NULL;
  6534. else
  6535. currTarget = GetTarget();
  6536.  
  6537. currentSelectedDisplayTarget = currTarget;
  6538.  
  6539. if ( currTarget && !currTarget.IsTargetableByPlayer() )
  6540. {
  6541. currentSelectedDisplayTarget = NULL;
  6542. ConfirmDisplayTarget( currentSelectedDisplayTarget );
  6543. return;
  6544. }
  6545.  
  6546. nonActorTargetMult = 1.25;
  6547.  
  6548.  
  6549. hud = (CR4ScriptedHud)theGame.GetHud();
  6550.  
  6551. if ( !IsThreatened() )
  6552. {
  6553. if ( !bLAxisReleased || lastAxisInputIsMovement )
  6554. {
  6555. if ( currTarget )
  6556. angleDist1 = AbsF( AngleDistance( this.GetHeading(), VecHeading( currTarget.GetWorldPosition() - this.GetWorldPosition() ) ) );
  6557. else
  6558. angleDist1 = 360;
  6559.  
  6560. if ( nonActorTarget )
  6561. angleDist2 = AbsF( AngleDistance( this.GetHeading(), VecHeading( nonActorTarget.GetWorldPosition() - this.GetWorldPosition() ) ) );
  6562. else
  6563. angleDist2 = 360;
  6564. }
  6565. else
  6566. {
  6567. if ( currTarget )
  6568. angleDist1 = AbsF( AngleDistance( theCamera.GetCameraHeading(), VecHeading( currTarget.GetWorldPosition() - theCamera.GetCameraPosition() ) ) );
  6569. else
  6570. angleDist1 = 360;
  6571.  
  6572. if ( nonActorTarget )
  6573. angleDist2 = AbsF( AngleDistance( theCamera.GetCameraHeading(), VecHeading( nonActorTarget.GetWorldPosition() - theCamera.GetCameraPosition() ) ) );
  6574. else
  6575. angleDist2 = 360;
  6576. }
  6577. }
  6578.  
  6579. else
  6580. {
  6581. if ( !bLAxisReleased )
  6582. {
  6583. if ( ShouldUsePCModeTargeting() )
  6584. {
  6585. if ( currTarget )
  6586. angleDist1 = AbsF( AngleDistance( theCamera.GetCameraHeading(), VecHeading( currTarget.GetWorldPosition() - theCamera.GetCameraPosition() ) ) );
  6587. else
  6588. angleDist1 = 360;
  6589.  
  6590. if ( nonActorTarget && IsInCombatAction() )
  6591. {
  6592. angleDist2 = nonActorTargetMult * AbsF( AngleDistance( theCamera.GetCameraHeading(), VecHeading( nonActorTarget.GetWorldPosition() - theCamera.GetCameraPosition() ) ) );
  6593. }
  6594. else
  6595. angleDist2 = 360;
  6596. }
  6597. else
  6598. {
  6599. if ( currTarget )
  6600. angleDist1 = AbsF( AngleDistance( rawPlayerHeading, VecHeading( currTarget.GetWorldPosition() - this.GetWorldPosition() ) ) );
  6601. else
  6602. angleDist1 = 360;
  6603.  
  6604. if ( nonActorTarget && IsInCombatAction() )
  6605. {
  6606. angleDist2 = nonActorTargetMult * AbsF( AngleDistance( rawPlayerHeading, VecHeading( nonActorTarget.GetWorldPosition() - this.GetWorldPosition() ) ) );
  6607. }
  6608. else
  6609. angleDist2 = 360;
  6610. }
  6611. }
  6612. else
  6613. {
  6614. angleDist1 = 0;
  6615. angleDist2 = 360;
  6616. }
  6617. }
  6618.  
  6619.  
  6620. if ( angleDist1 < angleDist2 )
  6621. tempTarget = currTarget;
  6622. else
  6623. tempTarget = nonActorTarget;
  6624.  
  6625.  
  6626. if ( slideTarget && IsInCombatAction() )
  6627. {
  6628. combatActionType = (int)this.GetBehaviorVariable( 'combatActionType' );
  6629. if ( combatActionType == (int)CAT_Attack
  6630. || ( combatActionType == (int)CAT_SpecialAttack && this.GetBehaviorVariable( 'playerAttackType' ) == 1.f )
  6631. || ( combatActionType == (int)CAT_ItemThrow )
  6632. || ( combatActionType == (int)CAT_CastSign && !IsCurrentSignChanneled() )
  6633. || ( combatActionType == (int)CAT_CastSign && IsCurrentSignChanneled() && GetCurrentlyCastSign() == ST_Axii )
  6634. || ( combatActionType == (int)CAT_CastSign && IsCurrentSignChanneled() && GetCurrentlyCastSign() == ST_Igni )
  6635. || combatActionType == (int)CAT_Dodge
  6636. || combatActionType == (int)CAT_Roll )
  6637. {
  6638. if ( combatActionType == (int)CAT_CastSign && GetCurrentlyCastSign() == ST_Igni && !IsCombatMusicEnabled() )
  6639. currentSelectedDisplayTarget = tempTarget;
  6640. else
  6641. currentSelectedDisplayTarget = slideTarget;
  6642. }
  6643. else
  6644. currentSelectedDisplayTarget = tempTarget;
  6645. }
  6646. else if ( slideTarget
  6647. && this.rangedWeapon
  6648. && this.rangedWeapon.GetCurrentStateName() != 'State_WeaponWait'
  6649. && this.playerAiming.GetCurrentStateName() == 'Waiting' )
  6650. currentSelectedDisplayTarget = slideTarget;
  6651. else
  6652. currentSelectedDisplayTarget = tempTarget;
  6653.  
  6654. interactionTarget = theGame.GetInteractionsManager().GetActiveInteraction();
  6655. if ( interactionTarget && !IsThreatened() && !( this.IsCastingSign() && this.IsCurrentSignChanneled() ) )
  6656. {
  6657. tempTarget = (CGameplayEntity)interactionTarget.GetEntity();
  6658. if ( tempTarget && tempTarget != this.GetUsedVehicle() )
  6659. {
  6660. currentSelectedDisplayTarget = tempTarget;
  6661. SetDisplayTarget( currentSelectedDisplayTarget );
  6662. }
  6663. }
  6664.  
  6665.  
  6666. if ( (CActor)currentSelectedDisplayTarget && !((CActor)currentSelectedDisplayTarget).GetGameplayVisibility() )
  6667. {
  6668. currentSelectedDisplayTarget = NULL;
  6669. }
  6670.  
  6671. if ( displayTarget != currentSelectedDisplayTarget )
  6672. {
  6673. if ( forceUpdate )
  6674. SetDisplayTarget( currentSelectedDisplayTarget );
  6675. else
  6676. ConfirmDisplayTarget( currentSelectedDisplayTarget );
  6677. }
  6678. }
  6679.  
  6680. private var bConfirmDisplayTargetTimerEnabled : bool;
  6681. private var displayTargetToConfirm : CGameplayEntity;
  6682. private var currentSelectedDisplayTarget : CGameplayEntity;
  6683.  
  6684. private function ConfirmDisplayTarget( targetToConfirm : CGameplayEntity )
  6685. {
  6686. if ( targetToConfirm != displayTarget )
  6687. {
  6688. displayTargetToConfirm = targetToConfirm;
  6689. if( !bConfirmDisplayTargetTimerEnabled )
  6690. {
  6691. bConfirmDisplayTargetTimerEnabled = true;
  6692.  
  6693. if ( targetToConfirm )
  6694. AddTimer( 'ConfirmDisplayTargetTimer', 0.1f );
  6695. else
  6696. AddTimer( 'ConfirmDisplayTargetTimer', 0.f );
  6697. }
  6698. }
  6699. }
  6700.  
  6701. private timer function ConfirmDisplayTargetTimer( time : float, optional id : int)
  6702. {
  6703. if ( displayTargetToConfirm == currentSelectedDisplayTarget )
  6704. SetDisplayTarget( displayTargetToConfirm );
  6705.  
  6706. bConfirmDisplayTargetTimerEnabled = false;
  6707. }
  6708.  
  6709.  
  6710. protected function SetDisplayTarget( e : CGameplayEntity )
  6711. {
  6712. var displayTargetActor : CActor;
  6713.  
  6714. if ( e != displayTarget )
  6715. {
  6716. displayTarget = e;
  6717. displayTargetActor = (CActor)displayTarget;
  6718. SetPlayerCombatTarget( displayTargetActor );
  6719.  
  6720. if ( displayTargetActor && !displayTargetActor.IsTargetableByPlayer())
  6721. {
  6722. isDisplayTargetTargetable = false;
  6723. }
  6724. else if ( !displayTargetActor && displayTarget != nonActorTarget )
  6725. {
  6726. isDisplayTargetTargetable = false;
  6727. }
  6728. else
  6729. {
  6730. isDisplayTargetTargetable = true;
  6731. }
  6732. }
  6733. }
  6734.  
  6735. public function GetDisplayTarget() : CGameplayEntity { return displayTarget; }
  6736.  
  6737. private var isDisplayTargetTargetable : bool;
  6738. public function IsDisplayTargetTargetable() : bool
  6739. {
  6740. return isDisplayTargetTargetable;
  6741. }
  6742.  
  6743. public var radialSlots : array<name>;
  6744. public function EnableRadialSlots( enable : bool, slotNames : array<name> )
  6745. {
  6746. var hud : CR4ScriptedHud;
  6747. var module : CR4HudModuleRadialMenu;
  6748. var i : int;
  6749.  
  6750. hud = (CR4ScriptedHud)theGame.GetHud();
  6751. module = (CR4HudModuleRadialMenu)hud.GetHudModule("RadialMenuModule");
  6752.  
  6753. for(i=0; i<slotNames.Size(); i+=1)
  6754. {
  6755. module.SetDesaturated( !enable, slotNames[i] );
  6756. }
  6757. }
  6758.  
  6759. public function IsEnemyInCone( source : CActor, coneHeading : Vector, coneDist, coneAngle : float, out newLockTarget : CActor ) : bool
  6760. {
  6761. var targets : array<CActor>;
  6762. var sourceToTargetDists : array<float>;
  6763. var i : int;
  6764. var targetingInfo : STargetingInfo;
  6765.  
  6766.  
  6767.  
  6768. targets = GetMoveTargets();
  6769.  
  6770. if ( targets.Size() > 0 )
  6771. {
  6772. targetingInfo.source = this;
  6773. targetingInfo.canBeTargetedCheck = true;
  6774. targetingInfo.coneCheck = true;
  6775. targetingInfo.coneHalfAngleCos = CosF( Deg2Rad( coneAngle * 0.5f ) );
  6776. targetingInfo.coneDist = coneDist;
  6777. targetingInfo.coneHeadingVector = coneHeading;
  6778. targetingInfo.distCheck = true;
  6779. targetingInfo.invisibleCheck = true;
  6780. targetingInfo.navMeshCheck = true;
  6781. targetingInfo.inFrameCheck = false;
  6782. targetingInfo.frameScaleX = 1.f;
  6783. targetingInfo.frameScaleY = 1.f;
  6784. targetingInfo.knockDownCheck = false;
  6785. targetingInfo.knockDownCheckDist = 1.5f;
  6786. targetingInfo.rsHeadingCheck = false;
  6787. targetingInfo.rsHeadingLimitCos = 1.0f;
  6788.  
  6789. for( i = targets.Size() - 1; i >= 0; i -= 1 )
  6790. {
  6791. targetingInfo.targetEntity = targets[i];
  6792. if ( !IsEntityTargetable( targetingInfo ) )
  6793. targets.Erase( i );
  6794. }
  6795.  
  6796. for ( i = 0; i < targets.Size(); i += 1 )
  6797. sourceToTargetDists.PushBack( VecDistance( source.GetWorldPosition(), targets[i].GetWorldPosition() ) );
  6798.  
  6799. if(sourceToTargetDists.Size() > 0)
  6800. newLockTarget = targets[ ArrayFindMinF( sourceToTargetDists ) ];
  6801. else
  6802. newLockTarget = NULL;
  6803. }
  6804.  
  6805. return targets.Size() > 0;
  6806. }
  6807.  
  6808. public function GetScreenSpaceLockTarget( sourceEnt : CGameplayEntity, coneAngle, coneDist, coneHeading : float, optional inFrameCheck : bool ) : CActor
  6809. {
  6810. var source : CActor;
  6811. var sourcePos, targetPos : Vector;
  6812. var targets : array<CActor>;
  6813. var sourceToTargetDists : array<float>;
  6814. var sourceCoord : Vector;
  6815. var targetCoord : Vector;
  6816. var i : int;
  6817. var angleDiff : float;
  6818. var sourceToTargetHeading : float;
  6819. var sourceToTargetDist : float;
  6820. var size : float;
  6821. var targetingDist : float;
  6822. var targetingInfo : STargetingInfo;
  6823.  
  6824. var temp : int;
  6825.  
  6826.  
  6827.  
  6828.  
  6829. source = (CActor)sourceEnt;
  6830.  
  6831. targets = GetMoveTargets();
  6832.  
  6833. if ( this.IsPCModeEnabled() )
  6834. {
  6835. if ( ( coneHeading > -45.f && coneHeading < 45.f )
  6836. || coneHeading > 135.f
  6837. || coneHeading < -135.f )
  6838. {
  6839. if ( coneHeading > 0 )
  6840. coneHeading = 180 - coneHeading;
  6841. else
  6842. coneHeading = 180 + coneHeading;
  6843. }
  6844. }
  6845.  
  6846.  
  6847.  
  6848. for( i = targets.Size() - 1; i >= 0; i -= 1 )
  6849. {
  6850. if ( ( !targets[i].GetGameplayVisibility() || !IsThreat( targets[i] ) || !IsEnemyVisible( targets[i] ) || !this.CanBeTargetedIfSwimming( targets[i] ) )
  6851. && ( !IsCastingSign() || GetCurrentlyCastSign() != ST_Axii ) )
  6852. targets.Erase(i);
  6853. }
  6854.  
  6855. if ( source )
  6856. {
  6857. temp = source.GetTorsoBoneIndex();
  6858.  
  6859. if ( temp < 0 )
  6860. sourcePos = source.GetWorldPosition();
  6861. else
  6862. sourcePos = MatrixGetTranslation( source.GetBoneWorldMatrixByIndex( source.GetTorsoBoneIndex() ) );
  6863. }
  6864. else
  6865. sourcePos = sourceEnt.GetWorldPosition();
  6866.  
  6867. theCamera.WorldVectorToViewRatio( sourcePos, sourceCoord.X , sourceCoord.Y );
  6868.  
  6869.  
  6870. targetingDist = softLockDistVehicle;
  6871.  
  6872. if ( targets.Size() > 0 )
  6873. {
  6874. targetingInfo.source = this;
  6875. targetingInfo.canBeTargetedCheck = true;
  6876. targetingInfo.coneCheck = false;
  6877. targetingInfo.coneHalfAngleCos = 0.86602540378f;
  6878. targetingInfo.coneDist = targetingDist;
  6879. targetingInfo.coneHeadingVector = Vector( 0.0f, 1.0f, 0.0f );
  6880. targetingInfo.distCheck = true;
  6881. targetingInfo.invisibleCheck = true;
  6882. targetingInfo.navMeshCheck = false;
  6883.  
  6884. if ( inFrameCheck )
  6885. targetingInfo.inFrameCheck = true;
  6886. else
  6887. targetingInfo.inFrameCheck = false;
  6888.  
  6889. targetingInfo.frameScaleX = 1.f;
  6890. targetingInfo.frameScaleY = 1.f;
  6891. targetingInfo.knockDownCheck = false;
  6892. targetingInfo.knockDownCheckDist = softLockDist;
  6893. if ( bRAxisReleased )
  6894. targetingInfo.rsHeadingCheck = false;
  6895. else
  6896. targetingInfo.rsHeadingCheck = true;
  6897. targetingInfo.rsHeadingLimitCos = -0.5f;
  6898.  
  6899. for( i = targets.Size() - 1; i >= 0; i -= 1 )
  6900. {
  6901. temp = targets[i].GetTorsoBoneIndex();
  6902.  
  6903. if ( temp < 0 )
  6904. targetPos = targets[i].GetWorldPosition();
  6905. else
  6906. targetPos = MatrixGetTranslation( targets[i].GetBoneWorldMatrixByIndex( targets[i].GetTorsoBoneIndex() ) );
  6907.  
  6908. theCamera.WorldVectorToViewRatio( targetPos, targetCoord.X, targetCoord.Y );
  6909. sourceToTargetHeading = VecHeading( targetCoord - sourceCoord );
  6910. angleDiff = AbsF( AngleDistance( coneHeading, sourceToTargetHeading ) );
  6911.  
  6912. targetingInfo.targetEntity = targets[i];
  6913. if ( !IsEntityTargetable( targetingInfo ) )
  6914. targets.Erase( i );
  6915. else if ( !bRAxisReleased && angleDiff > ( coneAngle * 0.5 ) )
  6916. targets.Erase( i );
  6917. else if ( targets[i] == sourceEnt )
  6918. targets.Erase( i );
  6919.  
  6920.  
  6921. }
  6922. }
  6923.  
  6924. size = targets.Size();
  6925. if ( size > 0 )
  6926. {
  6927. for ( i = 0; i < targets.Size(); i += 1 )
  6928. {
  6929. temp = targets[i].GetTorsoBoneIndex();
  6930.  
  6931. if ( temp < 0 )
  6932. targetPos = targets[i].GetWorldPosition();
  6933. else
  6934. targetPos = MatrixGetTranslation( targets[i].GetBoneWorldMatrixByIndex( targets[i].GetTorsoBoneIndex() ) );
  6935.  
  6936. theCamera.WorldVectorToViewRatio( targetPos, targetCoord.X, targetCoord.Y );
  6937. sourceToTargetHeading = AbsF( VecHeading( targetCoord - sourceCoord ) );
  6938. angleDiff = AngleDistance( 180, sourceToTargetHeading );
  6939. sourceToTargetDist = VecDistance2D( sourceCoord, targetCoord );
  6940.  
  6941. sourceToTargetDists.PushBack( SinF( Deg2Rad( angleDiff ) ) * sourceToTargetDist );
  6942. }
  6943. }
  6944.  
  6945. if ( targets.Size() > 0 )
  6946. return targets[ ArrayFindMinF( sourceToTargetDists ) ];
  6947. else
  6948. return NULL;
  6949. }
  6950.  
  6951. public function IsEntityTargetable( out info : STargetingInfo, optional usePrecalcs : bool ) : bool
  6952. {
  6953. var playerHasBlockingBuffs : bool;
  6954. var sourceActor : CActor;
  6955. var targetEntity : CEntity;
  6956. var targetActor : CActor;
  6957. var targetNPC : CNewNPC;
  6958. var sourcePosition : Vector;
  6959. var targetPosition : Vector;
  6960. var direction : Vector;
  6961. var sourceToTargetDist : float;
  6962. var sourceCapsuleRadius : float;
  6963. var mpac : CMovingPhysicalAgentComponent;
  6964.  
  6965. var coneDistSq : float;
  6966. var knockDownCheckDistSq : float;
  6967. var sourceToTargetAngleDist : float;
  6968. var b : bool;
  6969. var infoSourceWorldPos : Vector;
  6970. var infoTargetWorldPos : Vector;
  6971. var finishEnabled : bool;
  6972.  
  6973. if ( usePrecalcs )
  6974. {
  6975. playerHasBlockingBuffs = targetingIn.playerHasBlockingBuffs;
  6976. }
  6977. else
  6978. {
  6979. playerHasBlockingBuffs = thePlayer.HasBuff( EET_Confusion ) || thePlayer.HasBuff( EET_Hypnotized ) || thePlayer.HasBuff( EET_Blindness ) || thePlayer.HasBuff( EET_WraithBlindness );
  6980. }
  6981. if ( playerHasBlockingBuffs )
  6982. {
  6983. return false;
  6984. }
  6985.  
  6986. sourceActor = info.source;
  6987. targetEntity = info.targetEntity;
  6988. if ( !sourceActor || !targetEntity )
  6989. {
  6990. return false;
  6991. }
  6992.  
  6993. targetActor = (CActor)targetEntity;
  6994.  
  6995.  
  6996. if ( info.canBeTargetedCheck && !targetActor.CanBeTargeted() )
  6997. {
  6998. return false;
  6999. }
  7000.  
  7001.  
  7002. if ( info.invisibleCheck && !targetActor.GetGameplayVisibility() )
  7003. {
  7004. return false;
  7005. }
  7006.  
  7007. sourcePosition = sourceActor.GetWorldPosition();
  7008. targetPosition = targetEntity.GetWorldPosition();
  7009.  
  7010. if ( targetActor )
  7011. {
  7012. {
  7013. targetNPC = (CNewNPC)targetActor;
  7014. if ( targetNPC )
  7015. {
  7016. if ( targetNPC.IsHorse() && !targetNPC.GetHorseComponent().IsDismounted() )
  7017. {
  7018. return false;
  7019. }
  7020. }
  7021. }
  7022. }
  7023.  
  7024. if ( info.distCheck || info.knockDownCheck )
  7025. {
  7026. if ( usePrecalcs )
  7027. {
  7028. if ( targetActor )
  7029. {
  7030.  
  7031. sourceToTargetDist = Distance2DBetweenCapsuleAndPoint( targetActor, sourceActor ) - targetingPrecalcs.playerRadius;
  7032. }
  7033. else
  7034. {
  7035. sourceToTargetDist = VecDistance2D( sourcePosition, targetPosition ) - targetingPrecalcs.playerRadius;
  7036. }
  7037. }
  7038. else
  7039. {
  7040. if ( targetActor )
  7041. {
  7042. sourceToTargetDist = Distance2DBetweenCapsules( sourceActor, targetActor );
  7043. }
  7044. else
  7045. {
  7046. sourceToTargetDist = Distance2DBetweenCapsuleAndPoint( sourceActor, targetEntity );
  7047. }
  7048. }
  7049. }
  7050.  
  7051.  
  7052. if ( info.distCheck )
  7053. {
  7054. if ( sourceToTargetDist >= info.coneDist )
  7055. {
  7056. return false;
  7057. }
  7058. }
  7059.  
  7060.  
  7061. if ( info.coneCheck || info.rsHeadingCheck )
  7062. {
  7063. direction = VecNormalize2D( targetPosition - sourcePosition );
  7064. }
  7065.  
  7066.  
  7067. if ( info.coneCheck )
  7068. {
  7069. if ( VecDot2D( direction, info.coneHeadingVector ) < info.coneHalfAngleCos )
  7070. {
  7071. return false;
  7072. }
  7073. }
  7074.  
  7075.  
  7076. if ( info.rsHeadingCheck )
  7077. {
  7078. if ( usePrecalcs )
  7079. {
  7080. if ( VecDot2D( direction, targetingIn.lookAtDirection ) < info.rsHeadingLimitCos )
  7081. {
  7082. return false;
  7083. }
  7084. }
  7085. else
  7086. {
  7087. if ( VecDot2D( direction, VecNormalize2D( GetLookAtPosition() - sourcePosition ) ) < info.rsHeadingLimitCos )
  7088. {
  7089. return false;
  7090. }
  7091. }
  7092. }
  7093.  
  7094.  
  7095. if ( info.inFrameCheck && !WasVisibleInScaledFrame( targetEntity, info.frameScaleX, info.frameScaleY ) )
  7096. {
  7097. return false;
  7098. }
  7099.  
  7100.  
  7101. if ( info.navMeshCheck && !IsSwimming() )
  7102. {
  7103. sourceCapsuleRadius = 0.1f;
  7104. if ( usePrecalcs )
  7105. {
  7106. sourceCapsuleRadius = targetingPrecalcs.playerRadius;
  7107. }
  7108. else
  7109. {
  7110. mpac = (CMovingPhysicalAgentComponent)sourceActor.GetMovingAgentComponent();
  7111. if ( mpac )
  7112. {
  7113. sourceCapsuleRadius = mpac.GetCapsuleRadius();
  7114. }
  7115. }
  7116. if ( !theGame.GetWorld().NavigationLineTest( sourcePosition, targetPosition, sourceCapsuleRadius ) )
  7117. {
  7118. return false;
  7119. }
  7120. }
  7121.  
  7122.  
  7123. if ( info.knockDownCheck )
  7124. {
  7125.  
  7126. if ( targetActor && !targetActor.IsAlive() )
  7127. {
  7128.  
  7129. finishEnabled = targetActor.GetComponent( 'Finish' ).IsEnabled();
  7130. if ( finishEnabled )
  7131. {
  7132.  
  7133. if ( finishableEnemiesList.Contains( targetActor ) )
  7134. {
  7135.  
  7136. if ( sourceToTargetDist >= info.knockDownCheckDist )
  7137. {
  7138. return false;
  7139. }
  7140. }
  7141. }
  7142. }
  7143. }
  7144.  
  7145. return true;
  7146. }
  7147.  
  7148. public function CanBeTargetedIfSwimming( actor : CActor, optional usePrecalcs : bool ) : bool
  7149. {
  7150. var subDepth : float;
  7151. var isDiving : bool;
  7152.  
  7153. if ( !actor )
  7154. {
  7155. return false;
  7156. }
  7157.  
  7158. if ( usePrecalcs )
  7159. {
  7160. isDiving = targetingIn.isDiving;
  7161. }
  7162. else
  7163. {
  7164. isDiving = IsSwimming() && OnCheckDiving();
  7165. }
  7166.  
  7167. subDepth = ((CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent()).GetSubmergeDepth();
  7168.  
  7169. if ( isDiving )
  7170. {
  7171. return ( subDepth < -1.0f );
  7172. }
  7173. else
  7174. {
  7175. return ( subDepth >= -1.0f );
  7176. }
  7177. }
  7178.  
  7179.  
  7180. private function FilterActors( out targets : array<CActor>, out onlyThreatsReturned : bool, optional usePrecalcs : bool )
  7181. {
  7182. var i : int;
  7183. var size : int;
  7184. var foundThreat : bool;
  7185. var foundNonThreat : bool;
  7186. var threatsCount : int;
  7187. var tmpActor : CActor;
  7188.  
  7189. foundThreat = false;
  7190. foundNonThreat = false;
  7191.  
  7192. size = targets.Size();
  7193. i = 0;
  7194. threatsCount = 0;
  7195.  
  7196.  
  7197. for ( i = 0; i < size; i+=1 )
  7198. {
  7199. if( IsThreat( targets[ i ], usePrecalcs ) )
  7200. {
  7201. foundThreat = true;
  7202. if ( i != threatsCount )
  7203. {
  7204. tmpActor = targets[ i ];
  7205. targets[ i ] = targets[ threatsCount ];
  7206. targets[ threatsCount ] = tmpActor;
  7207. }
  7208. threatsCount += 1;
  7209. }
  7210. else
  7211. {
  7212. foundNonThreat = true;
  7213. }
  7214. }
  7215.  
  7216. if ( foundThreat )
  7217. {
  7218. onlyThreatsReturned = true;
  7219. if ( foundNonThreat )
  7220. {
  7221. targets.Resize( threatsCount );
  7222. }
  7223. }
  7224. }
  7225.  
  7226. private function InternalFindTargetsInCone( out targets : array< CActor >, out outHeadingVector : Vector, optional usePrecalcs : bool )
  7227. {
  7228. var size, i : int;
  7229. var coneHalfAngleDot : float;
  7230. var coneHeading : float;
  7231. var coneHeadingVector : Vector;
  7232. var position : Vector;
  7233. var direction : Vector;
  7234. var onlyThreatTargetsFound : bool;
  7235.  
  7236. targets.Clear();
  7237. GetVisibleEnemies( targets );
  7238.  
  7239.  
  7240. for( i = 0; i < finishableEnemiesList.Size() ; i+=1 )
  7241. {
  7242. if ( !targets.Contains( finishableEnemiesList[i] ) )
  7243. {
  7244. targets.PushBack( finishableEnemiesList[i] );
  7245. }
  7246. }
  7247.  
  7248. onlyThreatTargetsFound = false;
  7249. FilterActors( targets, onlyThreatTargetsFound, true );
  7250.  
  7251. if ( IsCombatMusicEnabled() && targets.Size() > 0 && !onlyThreatTargetsFound && !IsThreat( targets[0], usePrecalcs ) )
  7252. {
  7253. targets.Clear();
  7254. }
  7255.  
  7256. coneHeading = 0.0f;
  7257. coneHalfAngleDot = 0.0f;
  7258. if ( ( orientationTarget == OT_Camera ) || ( orientationTarget == OT_CameraOffset ) )
  7259. {
  7260. if ( usePrecalcs )
  7261. {
  7262. coneHeading = targetingPrecalcs.cameraHeading;
  7263. }
  7264. else
  7265. {
  7266. coneHeading = theGame.GetGameCamera().GetHeading();
  7267. }
  7268. coneHalfAngleDot = 0.5f;
  7269. }
  7270. else
  7271. {
  7272. if ( IsSwimming() )
  7273. {
  7274. if ( usePrecalcs )
  7275. {
  7276. coneHeading = targetingPrecalcs.cameraHeading;
  7277. }
  7278. else
  7279. {
  7280. coneHeading = theGame.GetGameCamera().GetHeading();
  7281. }
  7282. coneHalfAngleDot = 0.17364817766f;
  7283. }
  7284. else if ( bLAxisReleased )
  7285. {
  7286. if( IsInCombatAction() )
  7287. {
  7288. coneHeading = GetCombatActionHeading();
  7289. }
  7290. else
  7291. {
  7292. if ( ShouldUsePCModeTargeting() )
  7293. coneHeading = theGame.GetGameCamera().GetHeading();
  7294. else
  7295. coneHeading = cachedRawPlayerHeading;
  7296. }
  7297.  
  7298. if ( IsInCombat() )
  7299. {
  7300. if ( ShouldUsePCModeTargeting() )
  7301. coneHalfAngleDot = -1;
  7302. else
  7303. coneHalfAngleDot = 0.17364817766f;
  7304. }
  7305. else
  7306. {
  7307. coneHalfAngleDot = -1.0f;
  7308. }
  7309. }
  7310. else
  7311. {
  7312. if( IsInCombatAction() )
  7313. {
  7314. coneHeading = GetCombatActionHeading();
  7315. }
  7316. else
  7317. {
  7318. if ( ShouldUsePCModeTargeting() )
  7319. coneHeading = theGame.GetGameCamera().GetHeading();
  7320. else
  7321. coneHeading = cachedRawPlayerHeading;
  7322. }
  7323.  
  7324. if ( ShouldUsePCModeTargeting() )
  7325. coneHalfAngleDot = -1;
  7326. else
  7327. coneHalfAngleDot = 0.17364817766f;
  7328. }
  7329.  
  7330. coneHeadingVector = VecFromHeading( coneHeading );
  7331. position = this.GetWorldPosition();
  7332.  
  7333. for ( i = targets.Size() - 1; i >= 0; i -= 1 )
  7334. {
  7335. if ( !targets[i] )
  7336. {
  7337. targets.EraseFast(i);
  7338. continue;
  7339. }
  7340.  
  7341. direction = VecNormalize2D( targets[i].GetWorldPosition() - position );
  7342.  
  7343. if ( VecDot2D( coneHeadingVector, direction ) < coneHalfAngleDot )
  7344. {
  7345. targets.EraseFast( i );
  7346. }
  7347. }
  7348. }
  7349.  
  7350. outHeadingVector = coneHeadingVector;
  7351. }
  7352.  
  7353.  
  7354.  
  7355.  
  7356. function InitTargeting()
  7357. {
  7358. var consts : SR4PlayerTargetingConsts;
  7359.  
  7360. if ( !targeting )
  7361. {
  7362. targeting = new CR4PlayerTargeting in this;
  7363. }
  7364. if ( targeting )
  7365. {
  7366. consts.softLockDistance = this.softLockDist;
  7367. consts.softLockFrameSize = this.softLockFrameSize;
  7368. targeting.SetConsts( consts );
  7369. }
  7370. }
  7371.  
  7372. function PrepareTargetingIn( actionCheck : bool, bufferActionType : EBufferActionType, actionInput : bool )
  7373. {
  7374. var coneDist : float;
  7375.  
  7376. if ( actionCheck && bufferActionType == EBAT_ItemUse )
  7377. {
  7378. coneDist = findMoveTargetDist;
  7379. }
  7380. else if ( IsSwimming() )
  7381. {
  7382. coneDist = theGame.params.MAX_THROW_RANGE;
  7383. }
  7384. else if ( ( GetPlayerCombatStance() == PCS_AlertNear ) && ( ( playerMoveType == PMT_Walk ) || ( playerMoveType == PMT_Idle ) ) )
  7385. {
  7386. coneDist = softLockDist;
  7387. }
  7388. else
  7389. {
  7390. coneDist = findMoveTargetDist;
  7391. }
  7392.  
  7393. targetingIn.canFindTarget = this.bCanFindTarget;
  7394. targetingIn.playerHasBlockingBuffs = thePlayer.HasBuff( EET_Confusion ) || thePlayer.HasBuff( EET_Hypnotized ) || thePlayer.HasBuff( EET_Blindness ) || thePlayer.HasBuff( EET_WraithBlindness );
  7395. targetingIn.isHardLockedToTarget = this.IsHardLockEnabled();
  7396. targetingIn.isActorLockedToTarget = this.IsActorLockedToTarget();
  7397. targetingIn.isCameraLockedToTarget = this.IsCameraLockedToTarget();
  7398. targetingIn.actionCheck = actionCheck;
  7399. targetingIn.actionInput = actionInput;
  7400. targetingIn.isInCombatAction = this.IsInCombatAction();
  7401. targetingIn.isLAxisReleased = this.bLAxisReleased;
  7402. targetingIn.isLAxisReleasedAfterCounter = this.lAxisReleasedAfterCounter;
  7403. targetingIn.isLAxisReleasedAfterCounterNoCA = this.lAxisReleasedAfterCounterNoCA;
  7404. targetingIn.lastAxisInputIsMovement = this.lastAxisInputIsMovement;
  7405. targetingIn.isAiming = this.playerAiming.GetCurrentStateName() == 'Aiming';
  7406. targetingIn.isSwimming = this.IsSwimming();
  7407. targetingIn.isDiving = this.IsSwimming() && OnCheckDiving();
  7408. targetingIn.isThreatened = this.IsThreatened();
  7409. targetingIn.isCombatMusicEnabled = this.IsCombatMusicEnabled();
  7410. targetingIn.isPcModeEnabled = this.IsPCModeEnabled();
  7411. targetingIn.isInParryOrCounter = this.isInParryOrCounter;
  7412. targetingIn.shouldUsePcModeTargeting = this.ShouldUsePCModeTargeting();
  7413. targetingIn.bufferActionType = bufferActionType;
  7414. targetingIn.orientationTarget = this.GetOrientationTarget();
  7415. targetingIn.coneDist = coneDist;
  7416. targetingIn.findMoveTargetDist = this.findMoveTargetDist;
  7417. targetingIn.cachedRawPlayerHeading = this.cachedRawPlayerHeading;
  7418. targetingIn.combatActionHeading = this.GetCombatActionHeading();
  7419. targetingIn.rawPlayerHeadingVector = VecFromHeading( this.rawPlayerHeading );
  7420. targetingIn.lookAtDirection = VecNormalize2D( this.GetLookAtPosition() - GetWorldPosition() );
  7421. targetingIn.moveTarget = this.moveTarget;
  7422. targetingIn.aimingTarget = this.playerAiming.GetAimedTarget();
  7423. targetingIn.displayTarget = (CActor)this.displayTarget;
  7424. targetingIn.finishableEnemies = this.finishableEnemiesList;
  7425. targetingIn.hostileEnemies = this.hostileEnemies;
  7426. targetingIn.defaultSelectionWeights = ProcessSelectionWeights();
  7427. }
  7428.  
  7429. function ResetTargetingOut()
  7430. {
  7431. targetingOut.target = NULL;
  7432. targetingOut.result = false;
  7433. targetingOut.confirmNewTarget = false;
  7434. targetingOut.forceDisableUpdatePosition = false;
  7435. }
  7436.  
  7437. function MakeFindTargetPrecalcs()
  7438. {
  7439. var mpac : CMovingPhysicalAgentComponent;
  7440.  
  7441. targetingPrecalcs.playerPosition = thePlayer.GetWorldPosition();
  7442. targetingPrecalcs.playerHeading = thePlayer.GetHeading();
  7443. targetingPrecalcs.playerHeadingVector = thePlayer.GetHeadingVector();
  7444. targetingPrecalcs.playerHeadingVector.Z = 0;
  7445. targetingPrecalcs.playerHeadingVector = VecNormalize2D( targetingPrecalcs.playerHeadingVector );
  7446.  
  7447. targetingPrecalcs.playerRadius = 0.5f;
  7448. mpac = (CMovingPhysicalAgentComponent)thePlayer.GetMovingAgentComponent();
  7449. if ( mpac )
  7450. {
  7451. targetingPrecalcs.playerRadius = mpac.GetCapsuleRadius();
  7452. }
  7453.  
  7454. targetingPrecalcs.cameraPosition = theCamera.GetCameraPosition();
  7455. targetingPrecalcs.cameraDirection = theCamera.GetCameraDirection();
  7456. targetingPrecalcs.cameraHeadingVector = targetingPrecalcs.cameraDirection;
  7457. targetingPrecalcs.cameraHeadingVector.Z = 0;
  7458. targetingPrecalcs.cameraHeadingVector = VecNormalize2D( targetingPrecalcs.cameraHeadingVector );
  7459. targetingPrecalcs.cameraHeading = VecHeading( targetingPrecalcs.cameraHeadingVector );
  7460. }
  7461.  
  7462. public function GetForceDisableUpdatePosition() : bool
  7463. {
  7464. return targetingOut.forceDisableUpdatePosition;
  7465. }
  7466.  
  7467. public function SetUseNativeTargeting( use : bool )
  7468. {
  7469. useNativeTargeting = use;
  7470. }
  7471.  
  7472. protected function FindTarget( optional actionCheck : bool, optional action : EBufferActionType, optional actionInput : bool ) : CActor
  7473. {
  7474. if ( IsCombatMusicEnabled() && !IsInCombat() && reachableEnemyWasTooFar )
  7475. {
  7476. playerMode.UpdateCombatMode();
  7477. }
  7478.  
  7479. PrepareTargetingIn( actionCheck, action, actionInput );
  7480. if ( useNativeTargeting )
  7481. {
  7482. targeting.BeginFindTarget( targetingIn );
  7483. targeting.FindTarget();
  7484. targeting.EndFindTarget( targetingOut );
  7485. }
  7486. else
  7487. {
  7488. UpdateVisibleActors();
  7489. MakeFindTargetPrecalcs();
  7490. ResetTargetingOut();
  7491. FindTarget_Scripted();
  7492. }
  7493. if ( targetingOut.result )
  7494. {
  7495. if ( targetingOut.confirmNewTarget )
  7496. {
  7497. ConfirmNewTarget( targetingOut.target );
  7498. }
  7499. return targetingOut.target;
  7500. }
  7501. return NULL;
  7502. }
  7503.  
  7504. protected function FindTarget_Scripted()
  7505. {
  7506. var currentTarget : CActor;
  7507. var newTarget : CActor;
  7508. var selectedTarget : CActor;
  7509. var displayTargetActor : CActor;
  7510. var playerPosition : Vector;
  7511. var playerHeadingVector : Vector;
  7512. var cameraPosition : Vector;
  7513. var cameraHeadingVector : Vector;
  7514. var selectionHeadingVector : Vector;
  7515. var targetingInfo : STargetingInfo;
  7516. var selectionWeights : STargetSelectionWeights;
  7517. var targets : array< CActor >;
  7518. var isMoveTargetTargetable : bool;
  7519. var targetChangeFromActionInput : bool;
  7520. var retainCurrentTarget : bool;
  7521.  
  7522.  
  7523.  
  7524. playerPosition = this.GetWorldPosition();
  7525. playerHeadingVector = targetingPrecalcs.playerHeadingVector;
  7526. cameraPosition = theCamera.GetCameraPosition();
  7527. cameraHeadingVector = targetingPrecalcs.cameraHeadingVector;
  7528.  
  7529. currentTarget = GetTarget();
  7530. if ( currentTarget )
  7531. {
  7532. if ( IsHardLockEnabled() && currentTarget.IsAlive() && !currentTarget.IsKnockedUnconscious() )
  7533. {
  7534. if ( VecDistanceSquared( playerPosition, currentTarget.GetWorldPosition() ) > 50.f * 50.0f )
  7535. {
  7536. HardLockToTarget( false );
  7537. }
  7538. else
  7539. {
  7540. targetingOut.target = currentTarget;
  7541. targetingOut.result = true;
  7542. return;
  7543. }
  7544. }
  7545. GetVisualDebug().AddSphere('target', 1.0f, currentTarget.GetWorldPosition(), true, Color( 255, 255, 0 ), 1.0f );
  7546. }
  7547.  
  7548. if ( bCanFindTarget && !IsActorLockedToTarget() )
  7549. {
  7550. if ( !targetingIn.playerHasBlockingBuffs )
  7551. {
  7552. InternalFindTargetsInCone( targets, selectionHeadingVector, true );
  7553. }
  7554.  
  7555. targetingInfo.source = this;
  7556. targetingInfo.canBeTargetedCheck = true;
  7557. targetingInfo.coneCheck = false;
  7558. targetingInfo.coneHalfAngleCos = 1.0f;
  7559. targetingInfo.coneDist = targetingIn.coneDist;
  7560. targetingInfo.distCheck = true;
  7561. targetingInfo.invisibleCheck = true;
  7562. targetingInfo.navMeshCheck = false;
  7563.  
  7564. if ( ShouldUsePCModeTargeting() )
  7565. targetingInfo.inFrameCheck = false;
  7566. else
  7567. targetingInfo.inFrameCheck = true;
  7568.  
  7569. targetingInfo.frameScaleX = 1.0f;
  7570. targetingInfo.frameScaleY = 1.0f;
  7571. targetingInfo.knockDownCheck = false;
  7572. targetingInfo.knockDownCheckDist = 1.5f;
  7573. targetingInfo.rsHeadingCheck = false;
  7574. targetingInfo.rsHeadingLimitCos = 1.0f;
  7575.  
  7576. if ( currentTarget )
  7577. {
  7578. targetingInfo.targetEntity = currentTarget;
  7579. if ( !IsEntityTargetable( targetingInfo, true ) )
  7580. {
  7581. currentTarget = NULL;
  7582. }
  7583. if ( currentTarget && !CanBeTargetedIfSwimming( currentTarget, true ) )
  7584. {
  7585. currentTarget = NULL;
  7586. }
  7587. }
  7588.  
  7589. isMoveTargetTargetable = false;
  7590. if ( moveTarget )
  7591. {
  7592. if ( CanBeTargetedIfSwimming( moveTarget, true ) )
  7593. {
  7594. targetingInfo.targetEntity = moveTarget;
  7595. targetingInfo.coneDist = findMoveTargetDist;
  7596. targetingInfo.inFrameCheck = false;
  7597. if ( IsEntityTargetable( targetingInfo, true ) )
  7598. {
  7599. isMoveTargetTargetable = true;
  7600. }
  7601. }
  7602. }
  7603.  
  7604.  
  7605. targetingInfo.coneDist = targetingIn.coneDist;
  7606.  
  7607. if ( !targetingIn.playerHasBlockingBuffs )
  7608. {
  7609. RemoveNonTargetable( targets, targetingInfo, selectionHeadingVector );
  7610. }
  7611.  
  7612. newTarget = NULL;
  7613. if ( this.playerAiming.GetCurrentStateName() == 'Aiming' )
  7614. {
  7615. newTarget = this.playerAiming.GetAimedTarget();
  7616. if ( !newTarget )
  7617. {
  7618. selectionWeights.angleWeight = 1.f;
  7619. selectionWeights.distanceWeight = 0.f;
  7620. selectionWeights.distanceRingWeight = 0.f;
  7621.  
  7622. selectedTarget = SelectTarget( targets, false, cameraPosition, cameraHeadingVector, selectionWeights, true );
  7623. newTarget = selectedTarget;
  7624. }
  7625. }
  7626. else if ( IsSwimming() )
  7627. {
  7628. selectionWeights.angleWeight = 0.9f;
  7629. selectionWeights.distanceWeight = 0.1f;
  7630. selectionWeights.distanceRingWeight = 0.f;
  7631.  
  7632. selectedTarget = SelectTarget( targets, true, cameraPosition, cameraHeadingVector, selectionWeights, true );
  7633. newTarget = selectedTarget;
  7634. }
  7635. else if ( IsThreatened() )
  7636. {
  7637.  
  7638. if ( IsCameraLockedToTarget() )
  7639. {
  7640. if ( currentTarget && !currentTarget.GetGameplayVisibility() )
  7641. {
  7642. ForceSelectLockTarget();
  7643. }
  7644. }
  7645.  
  7646. displayTargetActor = (CActor)displayTarget;
  7647. selectedTarget = SelectTarget( targets, true, playerPosition, selectionHeadingVector, targetingIn.defaultSelectionWeights, true );
  7648.  
  7649. if ( !selectedTarget )
  7650. {
  7651. targetingOut.forceDisableUpdatePosition = true;
  7652. }
  7653.  
  7654. targetChangeFromActionInput = targetingIn.actionInput && !lAxisReleasedAfterCounter;
  7655. if ( selectedTarget &&
  7656. ( !IsThreat( currentTarget, true ) || ShouldUsePCModeTargeting() || ( !IsInCombatAction() && !lAxisReleasedAfterCounterNoCA ) || targetChangeFromActionInput ) )
  7657. {
  7658. newTarget = selectedTarget;
  7659. }
  7660. else if ( displayTargetActor &&
  7661. ( ( bLAxisReleased && !ShouldUsePCModeTargeting() )|| IsInCombatAction() ) &&
  7662. ( displayTargetActor.IsAlive() || finishableEnemiesList.Contains( displayTargetActor ) ) &&
  7663. displayTargetActor.GetGameplayVisibility() &&
  7664. ( IsEnemyVisible( displayTargetActor ) || finishableEnemiesList.Contains( displayTargetActor ) ) &&
  7665. this.CanBeTargetedIfSwimming( displayTargetActor, true ) &&
  7666. IsThreat( displayTargetActor, true ) &&
  7667. WasVisibleInScaledFrame( displayTargetActor, 1.f, 1.f ) )
  7668. {
  7669. newTarget = displayTargetActor;
  7670. }
  7671.  
  7672.  
  7673. else if ( moveTarget &&
  7674. isMoveTargetTargetable &&
  7675. ( !IsInCombatAction() || isInParryOrCounter || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Dodge || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Roll ) )
  7676. {
  7677. newTarget = moveTarget;
  7678. }
  7679. else
  7680. {
  7681. newTarget = NULL;
  7682. }
  7683. }
  7684. else
  7685. {
  7686. retainCurrentTarget = false;
  7687. if ( lAxisReleasedAfterCounterNoCA )
  7688. {
  7689. if ( lastAxisInputIsMovement && !this.IsSwimming())
  7690. {
  7691. selectionWeights.angleWeight = 0.375f;
  7692. selectionWeights.distanceWeight = 0.275f;
  7693. selectionWeights.distanceRingWeight = 0.35f;
  7694. selectedTarget = SelectTarget( targets, false, playerPosition, playerHeadingVector, selectionWeights, true );
  7695.  
  7696. if ( currentTarget != selectedTarget )
  7697. {
  7698. targetingInfo.targetEntity = currentTarget;
  7699. if ( IsEntityTargetable( targetingInfo, true ) && currentTarget.IsAlive() )
  7700. {
  7701. retainCurrentTarget = true;
  7702. }
  7703. }
  7704. }
  7705. else
  7706. {
  7707. selectionWeights.angleWeight = 0.75f;
  7708. selectionWeights.distanceWeight = 0.125f;
  7709. selectionWeights.distanceRingWeight = 0.125f;
  7710. selectedTarget = SelectTarget( targets, false, cameraPosition, cameraHeadingVector, selectionWeights, true );
  7711. }
  7712. }
  7713. else
  7714. {
  7715. selectionWeights.angleWeight = 0.6f;
  7716. selectionWeights.distanceWeight = 0.4f;
  7717. selectionWeights.distanceRingWeight = 0.f;
  7718. selectedTarget = SelectTarget( targets, true, playerPosition, targetingIn.rawPlayerHeadingVector, selectionWeights, true );
  7719. }
  7720.  
  7721. if ( retainCurrentTarget )
  7722. {
  7723. newTarget = currentTarget;
  7724. }
  7725. else if ( IsInCombatAction() && GetBehaviorVariable( 'isPerformingSpecialAttack' ) == 1.0f )
  7726. {
  7727. newTarget = moveTarget;
  7728. }
  7729. else if ( selectedTarget )
  7730. {
  7731. newTarget = selectedTarget;
  7732. }
  7733. else
  7734. {
  7735. newTarget = NULL;
  7736. }
  7737. }
  7738.  
  7739. targetingOut.confirmNewTarget = true;
  7740. }
  7741. else
  7742. {
  7743. newTarget = NULL;
  7744. }
  7745.  
  7746. targetingOut.result = true;
  7747. targetingOut.target = newTarget;
  7748. }
  7749.  
  7750. function UpdateVisibleActors()
  7751. {
  7752. var i : int;
  7753. var now : float;
  7754.  
  7755. now = theGame.GetEngineTimeAsSeconds();
  7756. for ( i = visibleActors.Size() - 1; i >= 0; i-=1 )
  7757. {
  7758.  
  7759. if ( ( now - visibleActorsTime[i] ) > 1.0f )
  7760. {
  7761. visibleActors.EraseFast( i );
  7762. visibleActorsTime.EraseFast( i );
  7763. }
  7764. }
  7765. }
  7766.  
  7767. function RemoveNonTargetable( out targets : array< CActor >, out info : STargetingInfo, selectionHeadingVector : Vector )
  7768. {
  7769. var i : int;
  7770. var cameraPosition : Vector;
  7771. var cameraDirection : Vector;
  7772. var nonCombatCheck : bool;
  7773. var playerToCamPlaneDist : float;
  7774. var targetToCamPlaneDist : float;
  7775.  
  7776. if ( targets.Size() == 0 )
  7777. {
  7778. return;
  7779. }
  7780.  
  7781. nonCombatCheck = bLAxisReleased && !IsInCombat();
  7782.  
  7783.  
  7784. if ( nonCombatCheck )
  7785. {
  7786. info.coneHeadingVector = targetingPrecalcs.playerHeadingVector;
  7787. if ( lastAxisInputIsMovement )
  7788. {
  7789. info.coneHeadingVector = selectionHeadingVector;
  7790. info.invisibleCheck = false;
  7791. info.coneCheck = true;
  7792. info.coneHalfAngleCos = 0.76604444311f;
  7793. }
  7794. else
  7795. {
  7796. info.invisibleCheck = false;
  7797. info.frameScaleX = 0.9f;
  7798. info.frameScaleY = 0.9f;
  7799. }
  7800. }
  7801. else
  7802. {
  7803. info.coneHeadingVector = Vector( 0.0f, 0.0f, 0.0f );
  7804.  
  7805.  
  7806. if ( IsInCombat() )
  7807. {
  7808. info.inFrameCheck = false;
  7809. }
  7810. else
  7811. {
  7812. if ( !bLAxisReleased )
  7813. {
  7814. info.coneCheck = true;
  7815.  
  7816. if ( this.IsSwimming() )
  7817. info.coneHalfAngleCos = -1;
  7818. else
  7819. info.coneHalfAngleCos = 0.86602540378f;
  7820.  
  7821. info.coneHeadingVector = targetingIn.rawPlayerHeadingVector;
  7822. }
  7823. }
  7824. }
  7825.  
  7826. cameraPosition = theCamera.GetCameraPosition();
  7827. cameraDirection = targetingPrecalcs.cameraDirection;
  7828. playerToCamPlaneDist = VecDot2D( cameraDirection, this.GetWorldPosition() - cameraPosition );
  7829.  
  7830.  
  7831. for( i = targets.Size() - 1; i >= 0; i -= 1 )
  7832. {
  7833. info.targetEntity = targets[i];
  7834.  
  7835. if ( !CanBeTargetedIfSwimming( targets[i], true ) )
  7836. {
  7837. targets.EraseFast( i );
  7838. }
  7839. else if ( !IsEntityTargetable( info, true ) )
  7840. {
  7841. targets.EraseFast( i );
  7842. }
  7843. else
  7844. {
  7845. if ( nonCombatCheck && !lastAxisInputIsMovement )
  7846. {
  7847.  
  7848. targetToCamPlaneDist = VecDot2D( cameraDirection, targets[i].GetWorldPosition() - cameraPosition );
  7849. if ( targetToCamPlaneDist < playerToCamPlaneDist )
  7850. {
  7851. targets.EraseFast( i );
  7852. }
  7853. }
  7854. }
  7855. }
  7856. }
  7857.  
  7858. var combatModeColor : Color;
  7859. public function CombatModeDebug()
  7860. {
  7861. var visualDebug : CVisualDebug = GetVisualDebug();
  7862.  
  7863. var naviQueryMsg : string;
  7864. var naviQueryMsg1 : string;
  7865. var naviQueryMsg2 : string;
  7866.  
  7867. var navSnapMsg : string;
  7868. var i : int;
  7869.  
  7870. if ( IsCombatMusicEnabled() )
  7871. visualDebug.AddText( 'CombatMusic', "CombatMusic : On", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.7f ), true, , Color( 255, 255, 255 ) );
  7872. else
  7873. visualDebug.AddText( 'CombatMusic', "CombatMusic : Off", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.7f ), true, , Color( 0, 0, 0 ) );
  7874.  
  7875. if ( GetPlayerMode().GetForceCombatMode() )
  7876. visualDebug.AddText( 'ForcedCombatMode', "ForcedCombatMode : TRUE", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.6f ), true, , Color( 255, 255, 255 ) );
  7877. else
  7878. visualDebug.AddText( 'ForcedCombatMode', "ForcedCombatMode : FALSE", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.6f ), true, , Color( 0, 0, 0 ) );
  7879.  
  7880.  
  7881. if ( IsThreatened() )
  7882. {
  7883. if ( IsInCombat() )
  7884. visualDebug.AddText( 'CombatMode', "CombatMode : AlertNear/Far", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.5f ), true, , Color( 255, 0, 0 ) );
  7885. else
  7886. visualDebug.AddText( 'CombatMode', "CombatMode : CombatExploration", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.5f ), true, , Color( 255, 255, 0 ) );
  7887. }
  7888. else
  7889. visualDebug.AddText( 'CombatMode', "CombatMode : NormalExploration", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.5f ), true, , Color( 0, 255, 0 ) );
  7890.  
  7891. visualDebug.AddText( 'NaviQuery', naviQueryMsg, combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7892. visualDebug.AddText( 'NaviQuery1', naviQueryMsg1, thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7893. visualDebug.AddText( 'NaviQuery2', naviQueryMsg2, thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7894.  
  7895. if ( isInCombatReason == 0 )
  7896. visualDebug.AddText( 'CombatModeReason', "CombatModeReason : ", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.4f ), true, , Color( 125, 125, 125 ) );
  7897. else if ( isInCombatReason == 1 )
  7898. visualDebug.AddText( 'CombatModeReason', "CombatModeReason : Geralt CAN pathfind to NPC", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.4f ), true, , Color( 255, 0, 0 ) );
  7899. else if ( isInCombatReason == 2 )
  7900. visualDebug.AddText( 'CombatModeReason', "CombatModeReason : An NPC is flying or ranged", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.4f ), true, , Color( 255, 0, 0 ) );
  7901. else if ( isInCombatReason == 2 )
  7902. visualDebug.AddText( 'CombatModeReason', "CombatModeReason : Forced Combat Mode", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.4f ), true, , Color( 255, 0, 0 ) );
  7903.  
  7904. if ( reachableEnemyWasTooFar )
  7905. {
  7906. combatModeColor.Red = 255;
  7907. combatModeColor.Green = 255;
  7908. combatModeColor.Blue = 0;
  7909. }
  7910. else
  7911. {
  7912. combatModeColor.Red = 0;
  7913. combatModeColor.Green = 255;
  7914. combatModeColor.Blue = 0;
  7915. }
  7916.  
  7917. if ( IsThreatened() )
  7918. {
  7919. switch ( navQuery.GetLastOutput( 2.0 ) )
  7920. {
  7921. case EAsyncTastResult_Failure:
  7922. {
  7923. if ( this.playerMode.GetForceCombatMode() )
  7924. {
  7925. if ( isSnappedToNavMesh )
  7926. {
  7927. visualDebug.AddText( 'NaviQuery', "", combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7928. visualDebug.AddText( 'NaviQuery1', "Naviquery : Snapped So no need for query", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7929. visualDebug.AddText( 'NaviQuery2', "Naviquery : Snapped So no need for query", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7930. }
  7931. else
  7932. {
  7933. visualDebug.AddText( 'NaviQuery', "", combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7934. visualDebug.AddText( 'NaviQuery1', "Naviquery : Failed", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7935. visualDebug.AddText( 'NaviQuery2', "Naviquery : Failed", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7936. }
  7937. }
  7938. else
  7939. {
  7940. visualDebug.AddText( 'NaviQuery', "", combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7941. visualDebug.AddText( 'NaviQuery1', "Naviquery : Failed", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7942. visualDebug.AddText( 'NaviQuery2', "Naviquery : Failed", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7943. }
  7944. break;
  7945. }
  7946. case EAsyncTastResult_Success:
  7947. {
  7948. visualDebug.AddText( 'NaviQuery', combatModeEnt.GetName(), combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7949. visualDebug.AddText( 'NaviQuery1', "Naviquery : Success (navDist: " + navDist + ")", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7950. visualDebug.AddText( 'NaviQuery2', "Naviquery : Success (directDist: " + directDist + ")", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7951. break;
  7952. }
  7953. case EAsyncTastResult_Pending:
  7954. {
  7955. visualDebug.AddText( 'NaviQuery', combatModeEnt.GetName(), combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7956. visualDebug.AddText( 'NaviQuery1', "Naviquery : Pending (navDist: " + navDist + ")", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7957. visualDebug.AddText( 'NaviQuery2', "Naviquery : Pending (directDist: " + directDist + ")", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7958. break;
  7959. }
  7960. case EAsyncTastResult_Invalidated:
  7961. {
  7962. visualDebug.AddText( 'NaviQuery', "", combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7963. visualDebug.AddText( 'NaviQuery1', "Naviquery : Invalidated", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7964. visualDebug.AddText( 'NaviQuery2', "Naviquery : Invalidated", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7965. break;
  7966. }
  7967. }
  7968. }
  7969. else
  7970. {
  7971. visualDebug.AddText( 'NaviQuery', "", combatModeEnt.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7972. visualDebug.AddText( 'NaviQuery1', "", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.3f ), true, , combatModeColor );
  7973. visualDebug.AddText( 'NaviQuery2', "", thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.2f ), true, , combatModeColor );
  7974. }
  7975.  
  7976. if ( navMeshSnapInfoStack.Size() > 0 )
  7977. {
  7978. for ( i = navMeshSnapInfoStack.Size()-1; i >= 0; i -= 1 )
  7979. {
  7980. navSnapMsg = navSnapMsg + navMeshSnapInfoStack[i] + " ";
  7981. }
  7982.  
  7983. visualDebug.AddText( 'NavMeshSnap', "NavMeshSnap: Enabled, Sources : " + navSnapMsg, thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.1f ), true, , Color( 255, 255, 255 ) );
  7984. }
  7985. else
  7986. visualDebug.AddText( 'NavMeshSnap', "NavMeshSnap: Disabled" , thePlayer.GetWorldPosition() + Vector( 0.f,0.f,1.1f ), true, , Color( 0, 0, 0 ) );
  7987.  
  7988. }
  7989.  
  7990. function IsCombatMusicEnabled() : bool
  7991. {
  7992. if ( theSound.GetCurrentGameState() == ESGS_UnderwaterCombat
  7993. || theSound.GetCurrentGameState() == ESGS_Combat
  7994. || theSound.GetCurrentGameState() == ESGS_CombatMonsterHunt
  7995. || theSound.GetCurrentGameState() == ESGS_FocusUnderwaterCombat )
  7996. return true;
  7997. else
  7998. return false;
  7999. }
  8000.  
  8001. function IsSoundStateCombatMusic( gameState : ESoundGameState ) : bool
  8002. {
  8003. if ( gameState == ESGS_UnderwaterCombat
  8004. || gameState == ESGS_Combat
  8005. || gameState == ESGS_CombatMonsterHunt
  8006. || gameState == ESGS_FocusUnderwaterCombat )
  8007. return true;
  8008. else
  8009. return false;
  8010. }
  8011.  
  8012. private function ConfirmNewTarget( actorToConfirm : CActor )
  8013. {
  8014. var leftJoyRotLimit : float = 1.f;
  8015.  
  8016. var target : CActor;
  8017.  
  8018. target = GetTarget();
  8019.  
  8020.  
  8021. if ( !target
  8022. || !moveTarget
  8023. || ( target && ( !IsThreat( target ) || !target.IsAlive() ) )
  8024. || VecLength( rawLeftJoyVec ) < 0.7f
  8025. || ( 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 ) ) ) )
  8026. || ( !IsInCombatAction() && ( !rangedWeapon || ( rangedWeapon.GetCurrentStateName() != 'State_WeaponHolster' ) ) ))
  8027. {
  8028. SetPrevRawLeftJoyRot();
  8029.  
  8030. if ( actorToConfirm != target )
  8031. {
  8032. SetTarget( actorToConfirm );
  8033. }
  8034. }
  8035. }
  8036.  
  8037. protected function SelectTarget( targets : array< CActor >, useVisibilityCheck : bool, sourcePosition : Vector, headingVector : Vector, selectionWeights : STargetSelectionWeights, optional usePrecalcs : bool ) : CActor
  8038. {
  8039. var i : int;
  8040. var target : CActor;
  8041. var selectedTarget : CActor;
  8042. var currentTarget : CActor;
  8043. var playerPosition : Vector;
  8044. var distanceToPlayer : float;
  8045. var priority : float;
  8046. var maxPriority : float;
  8047. var now : float;
  8048. var remove : bool;
  8049. var visibleActorIndex : int;
  8050.  
  8051. if ( useVisibilityCheck )
  8052. {
  8053. currentTarget = this.GetTarget();
  8054. playerPosition = this.GetWorldPosition();
  8055. now = theGame.GetEngineTimeAsSeconds();
  8056.  
  8057. for ( i = targets.Size() - 1; i >= 0; i-=1 )
  8058. {
  8059. target = targets[ i ];
  8060. if ( target != currentTarget && ( !IsPCModeEnabled() && !WasVisibleInScaledFrame( target, softLockFrameSize, softLockFrameSize ) ) )
  8061. {
  8062. remove = true;
  8063. visibleActorIndex = visibleActors.FindFirst( target );
  8064. if ( visibleActorIndex != -1 )
  8065. {
  8066. if ( usePrecalcs )
  8067. {
  8068. distanceToPlayer = Distance2DBetweenCapsuleAndPoint( target, this ) - targetingPrecalcs.playerRadius;
  8069. }
  8070. else
  8071. {
  8072. distanceToPlayer = Distance2DBetweenCapsules( this, target );
  8073. }
  8074.  
  8075. if ( distanceToPlayer < this.softLockDist && ( now - visibleActorsTime[ i ] ) < 1.0f )
  8076. {
  8077. remove = false;
  8078. }
  8079. }
  8080. if ( remove )
  8081. {
  8082. targets.EraseFast( i );
  8083. }
  8084. }
  8085. else
  8086. {
  8087. visibleActorIndex = visibleActors.FindFirst( target );
  8088. if ( visibleActorIndex == -1 )
  8089. {
  8090. visibleActors.PushBack( target );
  8091. visibleActorsTime.PushBack( now );
  8092. }
  8093. else
  8094. {
  8095. visibleActorsTime[ visibleActorIndex ] = now;
  8096. }
  8097. }
  8098. }
  8099. }
  8100.  
  8101. selectedTarget = NULL;
  8102. maxPriority = -1.0f;
  8103. for( i = targets.Size() - 1; i >= 0; i-=1 )
  8104. {
  8105. priority = CalcSelectionPriority( targets[ i ], selectionWeights, sourcePosition, headingVector );
  8106. if ( priority > maxPriority )
  8107. {
  8108. maxPriority = priority;
  8109. selectedTarget = targets[ i ];
  8110. }
  8111. }
  8112.  
  8113.  
  8114. return selectedTarget;
  8115. }
  8116.  
  8117. function Distance2DBetweenCapsuleAndPoint( actor : CActor, entity : CEntity ) : float
  8118. {
  8119. var distance : float;
  8120. var mpac : CMovingPhysicalAgentComponent;
  8121.  
  8122. distance = VecDistance2D( actor.GetWorldPosition(), entity.GetWorldPosition() );
  8123.  
  8124. mpac = (CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent();
  8125. if ( mpac )
  8126. {
  8127. distance -= mpac.GetCapsuleRadius();
  8128. }
  8129.  
  8130. return distance;
  8131. }
  8132.  
  8133.  
  8134. function Distance2DBetweenCapsules( actor1 : CActor, actor2 : CActor ) : float
  8135. {
  8136. var distance : float;
  8137. var mpac : CMovingPhysicalAgentComponent;
  8138.  
  8139. distance = VecDistance2D( actor1.GetWorldPosition(), actor2.GetWorldPosition() );
  8140.  
  8141. mpac = (CMovingPhysicalAgentComponent)actor1.GetMovingAgentComponent();
  8142. if ( mpac )
  8143. {
  8144. distance -= mpac.GetCapsuleRadius();
  8145. }
  8146.  
  8147. mpac = (CMovingPhysicalAgentComponent)actor2.GetMovingAgentComponent();
  8148. if ( mpac )
  8149. {
  8150. distance -= mpac.GetCapsuleRadius();
  8151. }
  8152.  
  8153. return distance;
  8154. }
  8155.  
  8156. protected function ProcessSelectionWeights() : STargetSelectionWeights
  8157. {
  8158. var selectionWeights : STargetSelectionWeights;
  8159.  
  8160. if ( ShouldUsePCModeTargeting() )
  8161. {
  8162. selectionWeights.angleWeight = 0.75f;
  8163. selectionWeights.distanceWeight = 0.25f;
  8164. selectionWeights.distanceRingWeight = 0.f;
  8165. return selectionWeights;
  8166. }
  8167.  
  8168. if ( IsInCombatAction() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Dodge || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Roll ) )
  8169. {
  8170. selectionWeights.angleWeight = 0.575f;
  8171. selectionWeights.distanceWeight = 0.175f;
  8172. selectionWeights.distanceRingWeight = 0.25f;
  8173. }
  8174. if ( !lAxisReleasedAfterCounter || IsInCombatAction() )
  8175. {
  8176. if ( theInput.GetActionValue( 'ThrowItem' ) == 1.f || ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' ) )
  8177. {
  8178. selectionWeights.angleWeight = 1.f;
  8179. selectionWeights.distanceWeight = 0.f;
  8180. selectionWeights.distanceRingWeight = 0.f;
  8181. }
  8182. else if ( !lAxisReleasedAfterCounter )
  8183. {
  8184. selectionWeights.angleWeight = 0.55f;
  8185. selectionWeights.distanceWeight = 0.45f;
  8186. selectionWeights.distanceRingWeight = 0.f;
  8187. }
  8188. else
  8189. {
  8190. selectionWeights.angleWeight = 0.75f;
  8191. selectionWeights.distanceWeight = 0.25f;
  8192. selectionWeights.distanceRingWeight = 0.f;
  8193. }
  8194. }
  8195. else if( !IsCurrentSignChanneled() )
  8196. {
  8197. selectionWeights.angleWeight = 0.35f;
  8198. selectionWeights.distanceWeight = 0.65f;
  8199. selectionWeights.distanceRingWeight = 0.f;
  8200. }
  8201. else
  8202. {
  8203. selectionWeights.angleWeight = 0.275f;
  8204. selectionWeights.distanceWeight = 0.375f;
  8205. selectionWeights.distanceRingWeight = 0.35f;
  8206. }
  8207.  
  8208. return selectionWeights;
  8209. }
  8210.  
  8211. protected function CalcSelectionPriority( target : CEntity, selectionWeights : STargetSelectionWeights, sourcePosition : Vector, headingVector : Vector ) : float
  8212. {
  8213. var sourceToTarget : Vector;
  8214. var sourceToTargetDist : float;
  8215. var sourceToTargetAngleDiff : float;
  8216. var selectionPriority : float;
  8217.  
  8218. sourceToTarget = target.GetWorldPosition() - sourcePosition;
  8219. sourceToTargetDist = VecLength2D( sourceToTarget );
  8220.  
  8221. if ( sourceToTargetDist < 0.0001f )
  8222. {
  8223. sourceToTarget = Vector( 0.0f, 0.0f, 0.0f );
  8224. }
  8225. else
  8226. {
  8227. sourceToTarget *= ( 1.0f / sourceToTargetDist );
  8228. }
  8229. sourceToTargetAngleDiff = AbsF( Rad2Deg( AcosF( VecDot2D( sourceToTarget, headingVector ) ) ) );
  8230.  
  8231. selectionPriority = ( selectionWeights.angleWeight * ( ( 180 - sourceToTargetAngleDiff ) / 180 ) );
  8232. selectionPriority += selectionWeights.distanceWeight * ( ( softLockDist - sourceToTargetDist ) / softLockDist );
  8233.  
  8234. if ( sourceToTargetDist > 0.f && sourceToTargetDist <= 6.f )
  8235. {
  8236. selectionPriority += selectionWeights.distanceRingWeight * 1.0f;
  8237. }
  8238. else if ( sourceToTargetDist > 6.f && sourceToTargetDist <= softLockDist )
  8239. {
  8240. selectionPriority += selectionWeights.distanceRingWeight * 0.4f;
  8241. }
  8242.  
  8243. return selectionPriority;
  8244. }
  8245.  
  8246. protected function SetTarget( targetActor : CActor, optional forceSetTarget : bool )
  8247. {
  8248. var playerToTargetDistance : float;
  8249. var target : CActor;
  8250. var allow : bool;
  8251.  
  8252. target = GetTarget();
  8253.  
  8254. if ( !IsInNonGameplayCutscene() )
  8255. allow = true;
  8256.  
  8257. if ( allow )
  8258. {
  8259. if ( targetActor )
  8260. {
  8261. if ( ( targetActor.IsAlive() && !targetActor.IsKnockedUnconscious() ) || finishableEnemiesList.Contains( targetActor ) )
  8262. allow = true;
  8263. else
  8264. allow = false;
  8265. }
  8266. else
  8267. allow = true;
  8268. }
  8269.  
  8270. if ( forceSetTarget )
  8271. allow = true;
  8272.  
  8273. if ( allow && target != targetActor )
  8274. allow = true;
  8275. else
  8276. allow = false;
  8277.  
  8278. if ( allow )
  8279. {
  8280. SetPlayerTarget( targetActor );
  8281.  
  8282.  
  8283.  
  8284. }
  8285. }
  8286.  
  8287.  
  8288. public function SetSlideTarget( actor : CGameplayEntity )
  8289. {
  8290.  
  8291.  
  8292.  
  8293. slideTarget = actor;
  8294.  
  8295. if ( slideTarget )
  8296. SetPlayerCombatTarget((CActor)slideTarget);
  8297. else
  8298. Log( "slideTarget = NULL" );
  8299.  
  8300. if ( slideTarget == nonActorTarget )
  8301. UpdateDisplayTarget( true, true );
  8302. else
  8303. UpdateDisplayTarget();
  8304.  
  8305. ConfirmDisplayTargetTimer(0.f);
  8306. }
  8307.  
  8308. event OnForceSelectLockTarget()
  8309. {
  8310. ForceSelectLockTarget();
  8311. }
  8312.  
  8313. private function ForceSelectLockTarget()
  8314. {
  8315. var newMoveTarget : CActor;
  8316. var target : CActor;
  8317.  
  8318. newMoveTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, 90 );
  8319.  
  8320. if ( !newMoveTarget )
  8321. newMoveTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, -90 );
  8322.  
  8323. if ( newMoveTarget )
  8324. {
  8325. thePlayer.ProcessLockTarget( newMoveTarget );
  8326.  
  8327. target = GetTarget();
  8328. if ( target )
  8329. {
  8330. thePlayer.SetSlideTarget( target );
  8331.  
  8332. if ( IsHardLockEnabled() )
  8333. thePlayer.HardLockToTarget( true );
  8334. }
  8335. }
  8336. else
  8337. {
  8338. thePlayer.HardLockToTarget( false );
  8339. }
  8340. }
  8341.  
  8342. public function SetFinisherVictim( actor : CActor )
  8343. {
  8344. finisherVictim = actor;
  8345. }
  8346.  
  8347. public function GetFinisherVictim() : CActor
  8348. {
  8349. return finisherVictim;
  8350. }
  8351.  
  8352. protected function SetNonActorTarget( actor : CGameplayEntity )
  8353. {
  8354. if ( nonActorTarget != actor )
  8355. nonActorTarget = actor;
  8356. }
  8357.  
  8358. timer function DisableTargetHighlightTimer( time : float , id : int)
  8359. {
  8360. var target : CActor;
  8361. target = GetTarget();
  8362.  
  8363. if( target )
  8364. {
  8365. target.StopEffect( 'select_character' );
  8366. }
  8367. }
  8368.  
  8369. public function WasVisibleInScaledFrame( entity : CEntity, frameSizeX : float, frameSizeY : float ) : bool
  8370. {
  8371. var position : Vector;
  8372. var positionFound : bool;
  8373. var inFront : bool;
  8374. var x, y : float;
  8375. var boneIndex : int;
  8376. var actor : CActor;
  8377. var gameplayEntity : CGameplayEntity;
  8378. var gameplayEntityMatrix : Matrix;
  8379. var drawableComp : CDrawableComponent;
  8380. var box : Box;
  8381. var ok : bool;
  8382.  
  8383. if ( !entity )
  8384. {
  8385. return false;
  8386. }
  8387. if ( frameSizeX <= 0.0f && frameSizeY <= 0.0f )
  8388. {
  8389. LogChannel( 'WasVisibleInScaledFrame', "ERROR: WasVisibleInScaledFrame: frameSizeX && frameSizeY are both negative!!!" );
  8390. return false;
  8391. }
  8392.  
  8393. if ( useNativeTargeting )
  8394. {
  8395. return targeting.WasVisibleInScaledFrame( entity, frameSizeX, frameSizeY );
  8396. }
  8397.  
  8398. position = entity.GetWorldPosition();
  8399.  
  8400. actor = (CActor)entity;
  8401. if ( actor )
  8402. {
  8403. boneIndex = entity.GetBoneIndex( 'pelvis' );
  8404. if ( boneIndex == -1 )
  8405. {
  8406. boneIndex = entity.GetBoneIndex( 'k_pelvis_g' );
  8407. }
  8408.  
  8409. if ( boneIndex != -1 )
  8410. {
  8411. position = MatrixGetTranslation( entity.GetBoneWorldMatrixByIndex( boneIndex ) );
  8412. }
  8413. else
  8414. {
  8415. position = entity.GetWorldPosition();
  8416. position.Z += ( (CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent() ).GetCapsuleHeight() * 0.5;
  8417. }
  8418. positionFound = true;
  8419. }
  8420. else
  8421. {
  8422. gameplayEntity = (CGameplayEntity)entity;
  8423. if ( gameplayEntity && !( gameplayEntity.aimVector.X == 0 && gameplayEntity.aimVector.Y == 0 && gameplayEntity.aimVector.Z == 0 ) )
  8424. {
  8425. gameplayEntityMatrix = gameplayEntity.GetLocalToWorld();
  8426. position = VecTransform( gameplayEntityMatrix, gameplayEntity.aimVector );
  8427. positionFound = true;
  8428. }
  8429. }
  8430.  
  8431.  
  8432. if ( !positionFound )
  8433. {
  8434. drawableComp = (CDrawableComponent)entity.GetComponentByClassName( 'CDrawableComponent' );
  8435. if ( drawableComp && drawableComp.GetObjectBoundingVolume( box ) )
  8436. {
  8437. position.Z += ( ( box.Max.Z - box.Min.Z ) * 0.66f );
  8438. }
  8439. }
  8440.  
  8441. inFront = theCamera.WorldVectorToViewRatio( position, x, y );
  8442. if ( !inFront )
  8443. {
  8444. return false;
  8445. }
  8446. x = AbsF( x );
  8447. y = AbsF( y );
  8448.  
  8449. ok = true;
  8450. ok = ok && ( frameSizeX <= 0.0f || x < frameSizeX );
  8451. ok = ok && ( frameSizeY <= 0.0f || y < frameSizeY );
  8452.  
  8453. return ok;
  8454. }
  8455.  
  8456. public function HardLockToTarget( flag : bool )
  8457. {
  8458. if( flag && GetTarget().HasTag( 'NoHardLock' ) )
  8459. return;
  8460.  
  8461. EnableHardLock( flag );
  8462. LockToTarget( flag );
  8463. }
  8464.  
  8465. public function LockToTarget( flag : bool )
  8466. {
  8467. if ( IsHardLockEnabled() && !flag )
  8468. return;
  8469.  
  8470. LockCameraToTarget( flag );
  8471. LockActorToTarget( flag );
  8472. }
  8473.  
  8474. public function LockCameraToTarget( flag : bool )
  8475. {
  8476. if ( flag && !IsCameraLockedToTarget() )
  8477. {
  8478. thePlayer.EnableManualCameraControl( false, 'LockCameraToTarget' );
  8479.  
  8480. SetIsCameraLockedToTarget( flag );
  8481. }
  8482. else if ( !flag && IsCameraLockedToTarget() )
  8483. {
  8484. thePlayer.EnableManualCameraControl( true, 'LockCameraToTarget' );
  8485.  
  8486. SetIsCameraLockedToTarget( flag );
  8487. }
  8488. }
  8489.  
  8490. public function LockActorToTarget( flag : bool, optional withoutIcon : bool )
  8491. {
  8492. var displayTargetActor : CActor;
  8493.  
  8494. if ( flag )
  8495. {
  8496. if ( !IsActorLockedToTarget() )
  8497. {
  8498.  
  8499. SetIsActorLockedToTarget( flag );
  8500. SetMoveTargetChangeAllowed( true );
  8501. SetMoveTarget( GetTarget() );
  8502. SetMoveTargetChangeAllowed( false );
  8503. SetTarget( GetTarget() );
  8504. SetSlideTarget( GetTarget() );
  8505. AddTimer( 'CheckLockTargetIsAlive', 0.5, true );
  8506. }
  8507.  
  8508. if ( IsActorLockedToTarget() )
  8509. {
  8510. displayTargetActor = (CActor)( GetDisplayTarget() );
  8511.  
  8512. if ( displayTargetActor && IsThreat( displayTargetActor ) && !withoutIcon )
  8513. EnableHardLockIcon( flag );
  8514. }
  8515. }
  8516. else if ( !flag && IsActorLockedToTarget() )
  8517. {
  8518. SetIsActorLockedToTarget( flag );
  8519. SetMoveTargetChangeAllowed( true );
  8520. RemoveTimer( 'CheckLockTargetIsAlive' );
  8521. EnableHardLockIcon( flag );
  8522. }
  8523. }
  8524.  
  8525. private function EnableHardLockIcon( flag : bool )
  8526. {
  8527. var hud : CR4ScriptedHud;
  8528. var module : CR4HudModuleEnemyFocus;
  8529.  
  8530. if( GetTarget().HasTag( 'NoHardLockIcon' ) )
  8531. return;
  8532.  
  8533. hud = (CR4ScriptedHud)theGame.GetHud();
  8534. module = (CR4HudModuleEnemyFocus)hud.GetHudModule("EnemyFocusModule");
  8535. module.SetShowHardLock( flag );
  8536. }
  8537.  
  8538. private timer function CheckLockTargetIsAlive( time : float , id : int)
  8539. {
  8540. var vitality : float;
  8541. var essence : float;
  8542. var actor : CActor;
  8543. var target : CActor;
  8544.  
  8545. target = (CActor)GetDisplayTarget();
  8546.  
  8547. if( !target
  8548. || !target.IsAlive()
  8549. || ( !target.GetGameplayVisibility() )
  8550. || !CanBeTargetedIfSwimming( target )
  8551. || (!target.UsesVitality() && !target.UsesEssence()))
  8552. {
  8553. if ( !ProcessLockTarget() )
  8554. HardLockToTarget( false );
  8555. }
  8556. }
  8557.  
  8558.  
  8559.  
  8560.  
  8561.  
  8562.  
  8563. protected function PlayHitAnimation(damageAction : W3DamageAction, animType : EHitReactionType)
  8564. {
  8565. var hitRotation : float;
  8566. var onHitCounter : SAbilityAttributeValue;
  8567. var counter : int;
  8568.  
  8569. if( damageAction.HasAnyCriticalEffect() )
  8570. return;
  8571.  
  8572. if( !substateManager.ReactOnBeingHit() && !IsUsingVehicle() )
  8573. {
  8574. return;
  8575. }
  8576.  
  8577. if ( damageAction.GetHitReactionType() == EHRT_Reflect )
  8578. SetBehaviorVariable( 'isAttackReflected', 1.f );
  8579. else
  8580. SetBehaviorVariable( 'isAttackReflected', 0.f );
  8581.  
  8582. SetBehaviorVariable( 'HitReactionType',(int)animType);
  8583. SetBehaviorVariable( 'HitReactionWeapon', ProcessSwordOrFistHitReaction( this, (CActor)damageAction.attacker ) );
  8584.  
  8585. if (damageAction.attacker)
  8586. {
  8587. super.PlayHitAnimation( damageAction, animType );
  8588. if ( damageAction.attacker.HasAbility( 'IncreaseHitReactionSeverityWithHitCounter' ) )
  8589. {
  8590. counter = GetHitCounter();
  8591. switch ( counter )
  8592. {
  8593. case 2 :
  8594. SetBehaviorVariable( 'HitReactionType', 2 );
  8595. break;
  8596.  
  8597. case 3 :
  8598. AddEffectDefault( EET_Stagger, damageAction.attacker, damageAction.attacker.GetName() );
  8599. break;
  8600.  
  8601. case 4 :
  8602. AddEffectDefault( EET_Knockdown, damageAction.attacker, damageAction.attacker.GetName() );
  8603. break;
  8604.  
  8605. default :
  8606. break;
  8607. }
  8608. }
  8609. SetHitReactionDirection(damageAction.attacker);
  8610. SetDetailedHitReaction(damageAction.GetSwingType(), damageAction.GetSwingDirection());
  8611. }
  8612.  
  8613. RaiseForceEvent( 'Hit' );
  8614. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'ActorInHitReaction', -1, 30.0f, -1.f, -1, true );
  8615.  
  8616. if ( IsUsingBoat() )
  8617. {
  8618. SoundEvent("cmb_play_hit_light");
  8619. return;
  8620. }
  8621.  
  8622. if ( IsUsingVehicle() )
  8623. return;
  8624.  
  8625. if(damageAction.attacker)
  8626. {
  8627. hitRotation = VecHeading( damageAction.attacker.GetWorldPosition() - GetWorldPosition() );
  8628. if ( this.GetBehaviorVariable( 'HitReactionDirection' ) == (float)( (int)EHRD_Back ) )
  8629. hitRotation += 180.f;
  8630.  
  8631.  
  8632. SetCustomRotation( 'Hit', hitRotation, 1080.f, 0.1f, false );
  8633. }
  8634.  
  8635. CriticalEffectAnimationInterrupted("PlayHitAnimation");
  8636. }
  8637.  
  8638. public function ReduceDamage( out damageData : W3DamageAction)
  8639. {
  8640. super.ReduceDamage(damageData);
  8641.  
  8642.  
  8643. if(damageData.attacker == this && (damageData.GetBuffSourceName() == "petard" || (W3Petard)damageData.causer) )
  8644. {
  8645. if ( theGame.CanLog() )
  8646. {
  8647. LogDMHits("CR4Player.ReduceDamage: hitting self with own bomb - damage reduced by 50%", damageData );
  8648. }
  8649. damageData.processedDmg.vitalityDamage = damageData.processedDmg.vitalityDamage / 2;
  8650. damageData.processedDmg.essenceDamage = damageData.processedDmg.essenceDamage / 2;
  8651. }
  8652. }
  8653.  
  8654.  
  8655. public function GetCriticalHitChance( isLightAttack : bool, isHeavyAttack : bool, target : CActor, victimMonsterCategory : EMonsterCategory, isBolt : bool ) : float
  8656. {
  8657. var critChance : float;
  8658. var oilChanceAttribute : name;
  8659. var weapons : array< SItemUniqueId >;
  8660. var i : int;
  8661. var holdsCrossbow : bool;
  8662. var critVal : SAbilityAttributeValue;
  8663.  
  8664. critChance = 0;
  8665.  
  8666.  
  8667. if( FactsQuerySum( 'debug_fact_critical_boy' ) > 0 )
  8668. {
  8669. critChance += 1;
  8670. }
  8671.  
  8672. if( IsInState( 'HorseRiding' ) && ( ( CActor )GetUsedVehicle() ).GetMovingAgentComponent().GetRelativeMoveSpeed() >= 4.0 )
  8673. {
  8674. critChance += 1;
  8675. }
  8676.  
  8677.  
  8678. critChance += CalculateAttributeValue( GetAttributeValue( theGame.params.CRITICAL_HIT_CHANCE ) );
  8679.  
  8680.  
  8681. weapons = inv.GetHeldWeapons();
  8682. for( i=0; i<weapons.Size(); i+=1 )
  8683. {
  8684. holdsCrossbow = ( inv.IsItemCrossbow( weapons[i] ) || inv.IsItemBolt( weapons[i] ) );
  8685. if( holdsCrossbow != isBolt )
  8686. {
  8687. critVal = inv.GetItemAttributeValue( weapons[i], theGame.params.CRITICAL_HIT_CHANCE );
  8688. critChance -= CalculateAttributeValue( critVal );
  8689. }
  8690. }
  8691.  
  8692.  
  8693. if( isHeavyAttack && CanUseSkill( S_Sword_s08 ) )
  8694. {
  8695. critChance += CalculateAttributeValue( GetSkillAttributeValue( S_Sword_s08, theGame.params.CRITICAL_HIT_CHANCE, false, true ) ) * GetSkillLevel( S_Sword_s08 );
  8696. }
  8697. else if( isLightAttack && CanUseSkill( S_Sword_s17 ) )
  8698. {
  8699. critChance += CalculateAttributeValue( GetSkillAttributeValue( S_Sword_s17, theGame.params.CRITICAL_HIT_CHANCE, false, true ) ) * GetSkillLevel( S_Sword_s17 );
  8700. }
  8701.  
  8702. if( target && target.HasBuff( EET_Confusion ) )
  8703. {
  8704. critChance += ( ( W3ConfuseEffect )target.GetBuff( EET_Confusion ) ).GetCriticalHitChanceBonus();
  8705. }
  8706.  
  8707.  
  8708. oilChanceAttribute = MonsterCategoryToCriticalChanceBonus( victimMonsterCategory );
  8709. if( IsNameValid( oilChanceAttribute ) )
  8710. {
  8711. critChance += CalculateAttributeValue( GetAttributeValue( oilChanceAttribute ) );
  8712. }
  8713.  
  8714. return critChance;
  8715. }
  8716.  
  8717.  
  8718. public function GetCriticalHitDamageBonus(weaponId : SItemUniqueId, victimMonsterCategory : EMonsterCategory, isStrikeAtBack : bool) : SAbilityAttributeValue
  8719. {
  8720. var bonus, oilBonus : SAbilityAttributeValue;
  8721. var vsAttributeName : name;
  8722.  
  8723. bonus = super.GetCriticalHitDamageBonus(weaponId, victimMonsterCategory, isStrikeAtBack);
  8724.  
  8725.  
  8726. if( inv.ItemHasActiveOilApplied( weaponId, victimMonsterCategory ) )
  8727. {
  8728. vsAttributeName = MonsterCategoryToCriticalDamageBonus(victimMonsterCategory);
  8729. oilBonus = inv.GetItemAttributeValue(weaponId, vsAttributeName);
  8730. bonus += oilBonus;
  8731. }
  8732.  
  8733. return bonus;
  8734. }
  8735.  
  8736.  
  8737. public function ReactToBeingHit(damageAction : W3DamageAction, optional buffNotApplied : bool) : bool
  8738. {
  8739. var strength : float;
  8740. var animType : EHitReactionType;
  8741. var sup : bool;
  8742. var boat : CBoatComponent;
  8743. var combatActionType : int;
  8744. var attackAction : W3Action_Attack;
  8745. var npc : CNewNPC;
  8746. var shakeCam : bool;
  8747.  
  8748. attackAction = (W3Action_Attack)damageAction;
  8749.  
  8750. if(!damageAction.IsDoTDamage() && (!attackAction || (!attackAction.IsParried() && !attackAction.IsCountered() && !attackAction.WasDodged()) ) )
  8751. {
  8752. npc = (CNewNPC)attackAction.attacker;
  8753. if(npc && npc.IsHeavyAttack(attackAction.GetAttackName()))
  8754. theGame.VibrateControllerVeryHard();
  8755. else
  8756. theGame.VibrateControllerHard();
  8757. }
  8758.  
  8759. if ( (CActor)GetUsedVehicle() && this.playerAiming.GetCurrentStateName() == 'Aiming' )
  8760. {
  8761. OnRangedForceHolster( true, true );
  8762. }
  8763.  
  8764. combatActionType = (int)GetBehaviorVariable( 'combatActionType' );
  8765.  
  8766. if ( thePlayer.IsCurrentlyDodging() && ( combatActionType == (int)CAT_Roll || combatActionType == (int)CAT_CiriDodge ) )
  8767. sup = false;
  8768. else if ( this.GetCurrentStateName() == 'DismountHorse' )
  8769. sup = false;
  8770. else
  8771. sup = super.ReactToBeingHit(damageAction, buffNotApplied);
  8772. sup = false;
  8773.  
  8774. if(damageAction.attacker)
  8775. theTelemetry.LogWithLabelAndValue( TE_FIGHT_HERO_GETS_HIT, damageAction.attacker.ToString(), (int)damageAction.processedDmg.vitalityDamage );
  8776.  
  8777.  
  8778. if(damageAction.DealsAnyDamage())
  8779. {
  8780. if( ((W3PlayerWitcher)this) && GetWitcherPlayer().IsAnyQuenActive() && damageAction.IsDoTDamage())
  8781. {
  8782. shakeCam = false;
  8783. }
  8784. else
  8785. {
  8786. shakeCam = true;
  8787. }
  8788.  
  8789. if(shakeCam)
  8790. {
  8791. animType = ModifyHitSeverityReaction(this, damageAction.GetHitReactionType());
  8792.  
  8793. if(animType == EHRT_Light || animType == EHRT_LightClose)
  8794. strength = 0.1;
  8795. else if(animType == EHRT_Heavy || animType == EHRT_Igni)
  8796. strength = 0.2;
  8797.  
  8798. GCameraShakeLight(strength, false, GetWorldPosition(), 10.0);
  8799. }
  8800.  
  8801. this.HitReactionEffect( 0.25 );
  8802.  
  8803.  
  8804. ResetUninterruptedHitsCount();
  8805. }
  8806.  
  8807.  
  8808. if(!damageAction.IsDoTDamage() && IsThreatened() && ShouldPauseHealthRegenOnHit() && damageAction.DealsAnyDamage() && !damageAction.WasDodged() && attackAction.CanBeParried() && !attackAction.IsParried())
  8809. {
  8810. PauseHPRegenEffects('being_hit', theGame.params.ON_HIT_HP_REGEN_DELAY);
  8811. }
  8812.  
  8813.  
  8814.  
  8815.  
  8816.  
  8817. if(damageAction.processedDmg.vitalityDamage > 0 && !((W3Effect_Toxicity)damageAction.causer))
  8818. ReceivedCombatDamage();
  8819.  
  8820.  
  8821. if(FactsQuerySum("tut_fight_use_slomo") > 0)
  8822. {
  8823. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
  8824. FactsRemove("tut_fight_slomo_ON");
  8825. }
  8826.  
  8827.  
  8828. if( !substateManager.ReactOnBeingHit( damageAction ) )
  8829. {
  8830. GoToCombatIfNeeded();
  8831.  
  8832. }
  8833.  
  8834. return sup;
  8835. }
  8836.  
  8837. protected function ShouldPauseHealthRegenOnHit() : bool
  8838. {
  8839. return true;
  8840. }
  8841.  
  8842. public function PlayHitEffect(damageAction : W3DamageAction)
  8843. {
  8844. super.PlayHitEffect(damageAction);
  8845.  
  8846.  
  8847. if(damageAction.DealsAnyDamage() && !damageAction.IsDoTDamage())
  8848. PlayEffect('hit_screen');
  8849. }
  8850.  
  8851. function HitReactionEffect( interval : float )
  8852. {
  8853. if ( hitReactionEffect )
  8854. {
  8855. PlayEffect( 'radial_blur' );
  8856. hitReactionEffect = false;
  8857. }
  8858. else
  8859. {
  8860. AddTimer( 'HitReactionEffectCooldown', interval, false );
  8861. }
  8862. }
  8863.  
  8864. timer function HitReactionEffectCooldown( td : float , id : int)
  8865. {
  8866. hitReactionEffect = true;
  8867. }
  8868.  
  8869.  
  8870.  
  8871.  
  8872.  
  8873.  
  8874. function PerformParryCheck( parryInfo : SParryInfo) : bool
  8875. {
  8876. var mult : float;
  8877. var parryType : EParryType;
  8878. var parryDir : EPlayerParryDirection;
  8879. var parryHeading : float;
  8880. var fistFightParry : bool;
  8881. var action : W3DamageAction;
  8882. var xmlStaminaDamage : float;
  8883. var xmlStaminaDamageName : name = 'stamina_damage' ;
  8884. var counter : int;
  8885. var onHitCounter : SAbilityAttributeValue;
  8886.  
  8887.  
  8888.  
  8889.  
  8890. if(CanParryAttack() && FistFightCheck( parryInfo.target, parryInfo.attacker, fistFightParry ) )
  8891. {
  8892. parryHeading = GetParryHeading( parryInfo, parryDir ) ;
  8893.  
  8894. SetBehaviorVariable( 'parryDirection', (float)( (int)( parryDir ) ) );
  8895. SetBehaviorVariable( 'parryDirectionOverlay', (float)( (int)( parryDir ) ) );
  8896. SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
  8897.  
  8898. if ( IsInCombatActionFriendly() )
  8899. RaiseEvent('CombatActionFriendlyEnd');
  8900.  
  8901. if ( HasStaminaToParry(parryInfo.attackActionName) )
  8902. {
  8903. this.SetBehaviorVariable( 'combatActionType', (int)CAT_Parry );
  8904.  
  8905. if ( parryInfo.targetToAttackerDist > 3.f && !bLAxisReleased && !thePlayer.IsCiri() )
  8906. {
  8907. if ( !RaiseForceEvent( 'PerformParryOverlay' ) )
  8908. return false;
  8909. else
  8910. {
  8911. ClearCustomOrientationInfoStack();
  8912. IncDefendCounter();
  8913. }
  8914. }
  8915. else
  8916. {
  8917. counter = GetDefendCounter();
  8918. onHitCounter = parryInfo.attacker.GetAttributeValue( 'break_through_parry_on_hit_counter' );
  8919. if ( onHitCounter.valueBase > 0 && counter == onHitCounter.valueBase )
  8920. {
  8921. AddEffectDefault( EET_Stagger, parryInfo.attacker, "Break through parry" );
  8922. }
  8923. else if ( RaiseForceEvent( 'PerformParry' ) )
  8924. {
  8925. OnCombatActionStart();
  8926. ClearCustomOrientationInfoStack();
  8927. SetSlideTarget( parryInfo.attacker );
  8928. SetCustomRotation( 'Parry', parryHeading, 1080.f, 0.1f, false );
  8929. IncDefendCounter();
  8930. }
  8931. else
  8932. return false;
  8933. }
  8934. }
  8935. else
  8936. {
  8937. AddEffectDefault(EET_Stagger, parryInfo.attacker, "Parry");
  8938. return true;
  8939. }
  8940.  
  8941. if ( parryInfo.attacker.IsWeaponHeld( 'fist' ) && !parryInfo.target.IsWeaponHeld( 'fist' ) )
  8942. {
  8943. parryInfo.attacker.ReactToReflectedAttack(parryInfo.target);
  8944. }
  8945. else
  8946. {
  8947. if ( this.IsInFistFightMiniGame() && fistFightParry )
  8948. {
  8949. if ( IsNameValid(xmlStaminaDamageName) )
  8950. {
  8951. xmlStaminaDamage = CalculateAttributeValue(parryInfo.attacker.GetAttributeValue( xmlStaminaDamageName ));
  8952. DrainStamina(ESAT_FixedValue, xmlStaminaDamage);
  8953. }
  8954. }
  8955. else
  8956. {
  8957. DrainStamina(ESAT_Parry, 0, 0, '', 0, mult);
  8958. }
  8959. if(IsLightAttack(parryInfo.attackActionName))
  8960. parryInfo.target.PlayEffectOnHeldWeapon('light_block');
  8961. else
  8962. parryInfo.target.PlayEffectOnHeldWeapon('heavy_block');
  8963. }
  8964. return true;
  8965. }
  8966.  
  8967. return false;
  8968. }
  8969.  
  8970. protected function GetParryHeading( parryInfo : SParryInfo, out parryDir : EPlayerParryDirection ) : float
  8971. {
  8972. var targetToAttackerHeading : float;
  8973. var currToTargetAttackerAngleDiff : float;
  8974.  
  8975. targetToAttackerHeading = VecHeading( parryInfo.attacker.GetWorldPosition() - parryInfo.target.GetWorldPosition() );
  8976. currToTargetAttackerAngleDiff = AngleDistance( VecHeading( parryInfo.target.GetHeadingVector() ), targetToAttackerHeading );
  8977.  
  8978. if ( !parryInfo.target.IsWeaponHeld( 'fist' ) )
  8979. {
  8980. if( currToTargetAttackerAngleDiff > -45 && currToTargetAttackerAngleDiff < 45 )
  8981. {
  8982. parryDir = PPD_Forward;
  8983. return targetToAttackerHeading;
  8984. }
  8985. else if( currToTargetAttackerAngleDiff >= 45 && currToTargetAttackerAngleDiff < 135 )
  8986. {
  8987. parryDir = PPD_Right;
  8988.  
  8989. return targetToAttackerHeading + 90;
  8990. }
  8991. else if( currToTargetAttackerAngleDiff <= -45 && currToTargetAttackerAngleDiff > -135 )
  8992. {
  8993. parryDir = PPD_Left;
  8994.  
  8995. return targetToAttackerHeading - 90;
  8996. }
  8997. else
  8998. {
  8999. parryDir = PPD_Back;
  9000.  
  9001. return targetToAttackerHeading + 180;
  9002. }
  9003. }
  9004. else
  9005. {
  9006. if( currToTargetAttackerAngleDiff > -45 && currToTargetAttackerAngleDiff < 45 )
  9007. {
  9008. parryDir = PPD_Forward;
  9009. return targetToAttackerHeading;
  9010. }
  9011. else if( currToTargetAttackerAngleDiff >= 45 && currToTargetAttackerAngleDiff < 180 )
  9012. {
  9013. parryDir = PPD_Right;
  9014. return targetToAttackerHeading + 90;
  9015. }
  9016. else if( currToTargetAttackerAngleDiff <= -45 && currToTargetAttackerAngleDiff >= -180 )
  9017. {
  9018. parryDir = PPD_Left;
  9019. return targetToAttackerHeading - 90;
  9020. }
  9021. else
  9022. {
  9023. parryDir = PPD_Back;
  9024. return targetToAttackerHeading + 180;
  9025. }
  9026. }
  9027. }
  9028.  
  9029. function ProcessLockTarget( optional newLockTarget : CActor, optional checkLeftStickHeading : bool ) : bool
  9030. {
  9031. var attackerNearestPoint : Vector;
  9032. var playerNearestPoint : Vector;
  9033. var incomingAttacker : CActor;
  9034. var tempLockTarget : CActor;
  9035. var target : CActor;
  9036. var useIncomingAttacker : bool;
  9037.  
  9038. if( newLockTarget.HasTag( 'NoHardLock' ) )
  9039. return false;
  9040.  
  9041. if ( newLockTarget )
  9042. tempLockTarget = newLockTarget;
  9043. else
  9044. {
  9045. incomingAttacker = GetClosestIncomingAttacker();
  9046. if ( incomingAttacker && incomingAttacker.IsAlive() && IsUsingVehicle() )
  9047. {
  9048. tempLockTarget = incomingAttacker;
  9049. useIncomingAttacker = false;
  9050. }
  9051.  
  9052. if ( !useIncomingAttacker )
  9053. {
  9054. target = GetTarget();
  9055. if( target.HasTag('ForceHardLock'))
  9056. {
  9057. return true;
  9058. }
  9059. else if ( target && target.IsAlive() && target.GetGameplayVisibility() && IsEnemyVisible( target ) && IsThreat( target ) && CanBeTargetedIfSwimming( target ) )
  9060. tempLockTarget = FindTarget();
  9061. else
  9062. {
  9063. tempLockTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, 0.f );
  9064. }
  9065. }
  9066. }
  9067.  
  9068. if( tempLockTarget.HasTag( 'NoHardLock' ) )
  9069. return false;
  9070.  
  9071. if ( tempLockTarget )
  9072. {
  9073. if ( IsCombatMusicEnabled() || hostileEnemies.Size() > 0 )
  9074. {
  9075. if ( !IsThreat( tempLockTarget ) )
  9076. tempLockTarget = NULL;
  9077. }
  9078. }
  9079.  
  9080. SetTarget( tempLockTarget, true );
  9081. SetMoveTargetChangeAllowed( true );
  9082. SetMoveTarget( tempLockTarget );
  9083. SetMoveTargetChangeAllowed( false );
  9084. SetSlideTarget( tempLockTarget );
  9085.  
  9086. if ( tempLockTarget )
  9087. {
  9088. if ( this.IsActorLockedToTarget() )
  9089. EnableHardLockIcon( true );
  9090.  
  9091. return true;
  9092. }
  9093. else
  9094. return false;
  9095. }
  9096.  
  9097.  
  9098.  
  9099.  
  9100.  
  9101. event OnTaskSyncAnim( npc : CNewNPC, animNameLeft : name ) {}
  9102.  
  9103.  
  9104. public function IsDoingSpecialAttack(heavy : bool) : bool
  9105. {
  9106. var pat : EPlayerAttackType;
  9107.  
  9108. if(IsInCombatAction() && ( (int)GetBehaviorVariable('combatActionType')) == CAT_SpecialAttack)
  9109. {
  9110. pat = (int)GetBehaviorVariable('playerAttackType');
  9111.  
  9112. if(heavy && pat == PAT_Heavy)
  9113. {
  9114. return true;
  9115. }
  9116. else if(!heavy && pat == PAT_Light)
  9117. {
  9118. return true;
  9119. }
  9120. }
  9121.  
  9122. return false;
  9123. }
  9124.  
  9125. public function SetIsCurrentlyDodging(enable : bool, optional isRolling : bool)
  9126. {
  9127. super.SetIsCurrentlyDodging(enable, isRolling);
  9128.  
  9129. if ( isRolling )
  9130. {
  9131. SetCanPlayHitAnim( false );
  9132. this.AddBuffImmunity( EET_KnockdownTypeApplicator, 'Roll', false );
  9133. this.AddBuffImmunity( EET_Knockdown, 'Roll', false );
  9134. this.AddBuffImmunity( EET_HeavyKnockdown, 'Roll', false );
  9135. this.AddBuffImmunity( EET_Stagger, 'Roll', false );
  9136. }
  9137. else
  9138. {
  9139. SetCanPlayHitAnim( true );
  9140. this.RemoveBuffImmunity( EET_KnockdownTypeApplicator, 'Roll' );
  9141. this.RemoveBuffImmunity( EET_Knockdown, 'Roll' );
  9142. this.RemoveBuffImmunity( EET_HeavyKnockdown, 'Roll' );
  9143. this.RemoveBuffImmunity( EET_Stagger, 'Roll' );
  9144. }
  9145. }
  9146.  
  9147. public function EnableHardLock( flag : bool )
  9148. {
  9149. super.EnableHardLock(flag);
  9150.  
  9151. if(flag && ShouldProcessTutorial('TutorialTargettingWaiting'))
  9152. {
  9153. FactsAdd("tut_hardlocked");
  9154. }
  9155. }
  9156.  
  9157. protected function TestParryAndCounter(data : CPreAttackEventData, weaponId : SItemUniqueId, out parried : bool, out countered : bool) : array<CActor>
  9158. {
  9159. var ret : array<CActor>;
  9160.  
  9161.  
  9162. if(FactsQuerySum('player_is_the_boss') > 0)
  9163. {
  9164.  
  9165.  
  9166. SetDebugAttackRange(data.rangeName);
  9167. RemoveTimer('PostAttackDebugRangeClear');
  9168.  
  9169. return ret;
  9170. }
  9171.  
  9172. ret = super.TestParryAndCounter(data, weaponId, parried, countered);
  9173.  
  9174.  
  9175. if(parried)
  9176. theGame.GetGamerProfile().ResetStat(ES_CounterattackChain);
  9177.  
  9178. return ret;
  9179. }
  9180.  
  9181. public function SetSpecialAttackTimeRatio(f : float)
  9182. {
  9183. LogSpecialHeavy(f);
  9184. specialAttackTimeRatio = f;
  9185. }
  9186.  
  9187. public function GetSpecialAttackTimeRatio() : float
  9188. {
  9189. return specialAttackTimeRatio;
  9190. }
  9191.  
  9192.  
  9193. public function OnSpecialAttackHeavyActionProcess()
  9194. {
  9195.  
  9196. SetSpecialAttackTimeRatio(0.f);
  9197. }
  9198.  
  9199. protected function DoAttack(animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float)
  9200. {
  9201. var shakeStr : float;
  9202. var weapon : EPlayerWeapon;
  9203. var targetActor : CActor;
  9204.  
  9205.  
  9206. if ( animData.attackName == 'attack_heavy_special' )
  9207. {
  9208. if( specialAttackTimeRatio != 1 )
  9209. shakeStr = (specialAttackTimeRatio / 3.333) + 0.2;
  9210. else
  9211. shakeStr = 0.5;
  9212.  
  9213. GCameraShake( shakeStr, false, GetWorldPosition(), 10);
  9214. }
  9215. else if ( IsHeavyAttack(attackActionName) )
  9216. {
  9217. if(parriedBy.Size() > 0)
  9218. shakeStr = 0.2;
  9219. else
  9220. shakeStr = 0.1;
  9221.  
  9222. GCameraShake(shakeStr, false, GetWorldPosition(), 10);
  9223. }
  9224.  
  9225. targetActor = (CActor)slideTarget;
  9226. if ( targetActor && hitTargets.Contains(targetActor) )
  9227. {
  9228. weapon = this.GetMostConvenientMeleeWeapon(targetActor,true);
  9229. if ( this.GetCurrentMeleeWeaponType() != PW_Fists && weapon != this.GetCurrentMeleeWeaponType() )
  9230. {
  9231. if ( weapon == PW_Steel )
  9232. {
  9233. thePlayer.OnEquipMeleeWeapon(PW_Steel,true);
  9234. }
  9235. else if ( weapon == PW_Silver )
  9236. {
  9237. thePlayer.OnEquipMeleeWeapon(PW_Silver,true);
  9238. }
  9239.  
  9240. }
  9241. }
  9242.  
  9243. super.DoAttack(animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime);
  9244. }
  9245.  
  9246.  
  9247.  
  9248. private var confirmCombatStanceTimeStamp : float;
  9249. private var isConfirmingCombatStance : bool;
  9250. final function SetPlayerCombatStance(stance : EPlayerCombatStance, optional force : bool )
  9251. {
  9252. var stanceInt : int;
  9253.  
  9254. if ( !CanChangeCombatStance( stance, force ) )
  9255. return;
  9256.  
  9257. combatStance = stance;
  9258. stanceInt = (int)stance;
  9259.  
  9260. SetBehaviorVariable( 'playerCombatStance' , (float)stanceInt);
  9261. SetBehaviorVariable( 'playerCombatStanceForOverlay' , (float)stanceInt);
  9262. if ( force )
  9263. SetBehaviorVariable( 'forceCombatStance' , 1.f);
  9264. else
  9265. SetBehaviorVariable( 'forceCombatStance' , 0.f);
  9266.  
  9267. if ( stance == PCS_AlertNear )
  9268. this.SetBehaviorVariable('isInCombatForOverlay',1.f);
  9269. else
  9270. this.SetBehaviorVariable('isInCombatForOverlay',0.f);
  9271. }
  9272.  
  9273. private function CanChangeCombatStance( stance : EPlayerCombatStance, optional force : bool ) : bool
  9274. {
  9275. var currTime : float;
  9276.  
  9277. if ( force )
  9278. return true;
  9279.  
  9280. if ( IsInFistFightMiniGame() )
  9281. return true;
  9282.  
  9283. if ( isInHolsterAnim )
  9284. return false;
  9285.  
  9286. if ( ( combatStance == PCS_Normal || combatStance == PCS_AlertFar ) && stance == PCS_AlertNear )
  9287. {
  9288. currTime = theGame.GetEngineTimeAsSeconds();
  9289. if ( !isConfirmingCombatStance )
  9290. {
  9291. isConfirmingCombatStance = true;
  9292. confirmCombatStanceTimeStamp = currTime;
  9293.  
  9294. return false;
  9295. }
  9296. else if ( currTime < confirmCombatStanceTimeStamp + 1.f )
  9297. {
  9298. if ( stance == PCS_AlertNear )
  9299. return false;
  9300. }
  9301. else
  9302. isConfirmingCombatStance = false;
  9303. }
  9304. else
  9305. isConfirmingCombatStance = false;
  9306.  
  9307. return true;
  9308. }
  9309.  
  9310. private var isInHolsterAnim : bool;
  9311. event OnHolsterWeaponStart()
  9312. {
  9313. isInHolsterAnim = true;
  9314. }
  9315.  
  9316. event OnHolsterWeaponEnd()
  9317. {
  9318. isInHolsterAnim = false;
  9319. }
  9320.  
  9321. final function GetPlayerCombatStance() : EPlayerCombatStance
  9322. {
  9323. return combatStance;
  9324. }
  9325.  
  9326. timer function DelayedDisableFindTarget( time : float , id : int)
  9327. {
  9328. if ( GetTarget().IsAlive() )
  9329. {
  9330. EnableFindTarget( false );
  9331. }
  9332. else
  9333. {
  9334. EnableFindTarget( true );
  9335. }
  9336. }
  9337.  
  9338.  
  9339.  
  9340.  
  9341.  
  9342. private var dodgeTimerRunning : bool;
  9343.  
  9344. function StartDodgeTimer()
  9345. {
  9346. dodgeTimerRunning = true;
  9347. thePlayer.AddTimer('DodgeTimer',0.2,false);
  9348. }
  9349.  
  9350. function StopDodgeTimer()
  9351. {
  9352. this.RemoveTimer('DodgeTimer');
  9353. dodgeTimerRunning = false;
  9354. }
  9355.  
  9356. function IsDodgeTimerRunning() : bool
  9357. {
  9358. return dodgeTimerRunning;
  9359. }
  9360.  
  9361. timer function DodgeTimer( dt : float, id : int )
  9362. {
  9363. dodgeTimerRunning = false;
  9364. }
  9365.  
  9366. public function EvadePressed( bufferAction : EBufferActionType )
  9367. {
  9368. }
  9369.  
  9370. public function PerformingCombatAction() : EBufferActionType
  9371. {
  9372. return BufferCombatAction;
  9373. }
  9374.  
  9375. public function PushCombatActionOnBuffer( action : EBufferActionType, stage : EButtonStage, optional allSteps : bool )
  9376. {
  9377. BufferButtonStage = stage;
  9378. BufferCombatAction = action;
  9379. BufferAllSteps = allSteps;
  9380. }
  9381.  
  9382. protected function ProcessCombatActionHeading( action : EBufferActionType ) : float
  9383. {
  9384. var processedActionHeading : float;
  9385.  
  9386. HandleMovement( 0.f );
  9387.  
  9388. if ( ShouldUsePCModeTargeting() )
  9389. return theGame.GetGameCamera().GetHeading();
  9390.  
  9391. if ( lAxisReleasedAfterCounter )
  9392. ResetCachedRawPlayerHeading();
  9393.  
  9394. processedActionHeading = cachedRawPlayerHeading;
  9395.  
  9396. return processedActionHeading;
  9397. }
  9398.  
  9399.  
  9400. function ResetRawPlayerHeading()
  9401. {
  9402. if ( GetDisplayTarget() )
  9403. rawPlayerHeading = VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() );
  9404. else
  9405. rawPlayerHeading = GetHeading();
  9406.  
  9407.  
  9408. }
  9409.  
  9410. function ResetCachedRawPlayerHeading()
  9411. {
  9412. cachedRawPlayerHeading = rawPlayerHeading;
  9413. if ( GetDisplayTarget() && IsDisplayTargetTargetable() && AbsF( AngleDistance( VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() ), this.GetHeading() ) ) < 90.f )
  9414. cachedRawPlayerHeading = VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() );
  9415. else
  9416. cachedRawPlayerHeading = this.GetHeading();
  9417.  
  9418. if ( canResetCachedCombatActionHeading )
  9419. cachedCombatActionHeading = cachedRawPlayerHeading;
  9420. }
  9421.  
  9422. public function GetCombatActionTarget( action : EBufferActionType ) : CGameplayEntity
  9423. {
  9424. var selectedTargetableEntity : CGameplayEntity;
  9425.  
  9426. if ( !this.IsUsingVehicle() )
  9427. selectedTargetableEntity = FindNonActorTarget( true, action );
  9428.  
  9429. if ( selectedTargetableEntity )
  9430. {
  9431. return selectedTargetableEntity;
  9432. }
  9433. else
  9434. {
  9435.  
  9436.  
  9437. if ( !this.IsUsingVehicle() )
  9438. FindTarget( true, action, true );
  9439. else
  9440. ((CR4PlayerStateUseGenericVehicle)this.GetState( 'UseGenericVehicle' )).FindTarget();
  9441.  
  9442. return GetTarget();
  9443. }
  9444. }
  9445.  
  9446.  
  9447. private function FindNonActorTarget( actionCheck : bool, optional action : EBufferActionType ) : CGameplayEntity
  9448. {
  9449. var targetableEntities : array<CGameplayEntity>;
  9450. var selectedTargetableEntity : CGameplayEntity;
  9451. var selectionPriority : array< float >;
  9452. var selectionWeights : STargetSelectionWeights;
  9453. var findEntityDist : float;
  9454. var i, size : int;
  9455. var playerHeading : float;
  9456. var playerInventory : CInventoryComponent;
  9457. var castSignType : ESignType;
  9458. var targetingInfo : STargetingInfo;
  9459. var playerPosition : Vector;
  9460. var cameraPosition : Vector;
  9461. var playerHeadingVector : Vector;
  9462. var rawPlayerHeadingVector : Vector;
  9463.  
  9464. playerPosition = this.GetWorldPosition();
  9465. cameraPosition = theCamera.GetCameraPosition();
  9466. rawPlayerHeadingVector = VecFromHeading( rawPlayerHeading );
  9467.  
  9468. if ( bCanFindTarget && !IsHardLockEnabled() )
  9469. {
  9470. if ( actionCheck && IsInCombat() && action == EBAT_CastSign )
  9471. {
  9472. findEntityDist = 6.f;
  9473. selectionWeights.angleWeight = 0.375f;
  9474. selectionWeights.distanceWeight = 0.275f;
  9475. selectionWeights.distanceRingWeight = 0.35f;
  9476. }
  9477. else if ( !IsInCombat() && lastAxisInputIsMovement )
  9478. {
  9479. findEntityDist = softLockDist;
  9480. selectionWeights.angleWeight = 0.375f;
  9481. selectionWeights.distanceWeight = 0.275f;
  9482. selectionWeights.distanceRingWeight = 0.35f;
  9483. }
  9484. else
  9485. {
  9486. findEntityDist = softLockDist;
  9487. selectionWeights.angleWeight = 0.75f;
  9488. selectionWeights.distanceWeight = 0.125f;
  9489. selectionWeights.distanceRingWeight = 0.125f;
  9490. }
  9491.  
  9492.  
  9493. if ( !IsInCombat() || !bLAxisReleased )
  9494. {
  9495. FindGameplayEntitiesInRange( targetableEntities, this, findEntityDist, 10, theGame.params.TAG_SOFT_LOCK );
  9496. }
  9497.  
  9498. if ( targetableEntities.Size() > 0 )
  9499. {
  9500. playerInventory = this.GetInventory();
  9501. castSignType = this.GetEquippedSign();
  9502.  
  9503. if ( !bLAxisReleased )
  9504. {
  9505. targetingInfo.source = this;
  9506. targetingInfo.canBeTargetedCheck = false;
  9507. targetingInfo.coneCheck = true;
  9508. targetingInfo.coneHalfAngleCos = 0.5f;
  9509. targetingInfo.coneDist = softLockDist;
  9510. targetingInfo.coneHeadingVector = rawPlayerHeadingVector;
  9511. targetingInfo.distCheck = true;
  9512. targetingInfo.invisibleCheck = false;
  9513. targetingInfo.navMeshCheck = false;
  9514. targetingInfo.frameScaleX = 1.0f;
  9515. targetingInfo.frameScaleY = 1.0f;
  9516. targetingInfo.knockDownCheck = false;
  9517. targetingInfo.knockDownCheckDist = 0.0f;
  9518. targetingInfo.rsHeadingCheck = false;
  9519. targetingInfo.rsHeadingLimitCos = 1.0f;
  9520. }
  9521.  
  9522. for( i = targetableEntities.Size()-1; i>=0; i-=1 )
  9523. {
  9524. if ( bLAxisReleased )
  9525. {
  9526. if ( !lastAxisInputIsMovement )
  9527. {
  9528. if ( !WasVisibleInScaledFrame( targetableEntities[i], 0.9f, 0.9f ) )
  9529. {
  9530. targetableEntities.Erase(i);
  9531. continue;
  9532. }
  9533. }
  9534. else if ( !WasVisibleInScaledFrame( targetableEntities[i], 1.f, 1.f ) )
  9535. {
  9536. targetableEntities.Erase(i);
  9537. continue;
  9538. }
  9539. }
  9540. else
  9541. {
  9542. targetingInfo.targetEntity = targetableEntities[i];
  9543. if ( actionCheck && moveTarget )
  9544. {
  9545. targetingInfo.inFrameCheck = false;
  9546. if ( !IsEntityTargetable( targetingInfo ) )
  9547. {
  9548. targetableEntities.Erase(i);
  9549. continue;
  9550. }
  9551. }
  9552. else
  9553. {
  9554. targetingInfo.inFrameCheck = true;
  9555. if ( !IsEntityTargetable( targetingInfo ) )
  9556. {
  9557. targetableEntities.Erase(i);
  9558. continue;
  9559. }
  9560. }
  9561. }
  9562.  
  9563. if ( actionCheck )
  9564. {
  9565. if ( action == EBAT_ItemUse )
  9566. {
  9567. if ( ( playerInventory.IsItemBomb( this.GetSelectedItemId() ) && !targetableEntities[i].HasTag( 'softLock_Bomb' ) )
  9568. || ( playerInventory.IsItemCrossbow( this.GetSelectedItemId() ) && !targetableEntities[i].HasTag( 'softLock_Bolt' ) ) )
  9569. {
  9570. targetableEntities.Erase(i);
  9571. continue;
  9572. }
  9573. }
  9574. else if ( action == EBAT_CastSign )
  9575. {
  9576. if ( ( castSignType == ST_Aard && !targetableEntities[i].HasTag( 'softLock_Aard' ) )
  9577. || ( castSignType == ST_Igni && !targetableEntities[i].HasTag( 'softLock_Igni' ) )
  9578. || ( castSignType == ST_Axii && !targetableEntities[i].HasTag( 'softLock_Axii' ) )
  9579. || castSignType == ST_Yrden
  9580. || castSignType == ST_Quen )
  9581. {
  9582. targetableEntities.Erase(i);
  9583. continue;
  9584. }
  9585. }
  9586. else if ( action == EBAT_LightAttack || action == EBAT_HeavyAttack || action == EBAT_SpecialAttack_Heavy )
  9587. {
  9588. if ( ( IsWeaponHeld( 'fist' ) && !targetableEntities[i].HasTag( 'softLock_Fist' ) ) || ( !IsWeaponHeld( 'fist' ) && !targetableEntities[i].HasTag( 'softLock_Weapon' ) ) )
  9589. {
  9590. targetableEntities.Erase(i);
  9591. continue;
  9592. }
  9593. }
  9594. else
  9595. {
  9596. targetableEntities.Erase(i);
  9597. continue;
  9598. }
  9599. }
  9600. }
  9601. }
  9602.  
  9603. if ( targetableEntities.Size() > 0)
  9604. {
  9605. playerHeading = this.GetHeading();
  9606. playerHeadingVector = this.GetHeadingVector();
  9607. if ( IsInCombat() )
  9608. {
  9609. for( i = 0; i < targetableEntities.Size(); i += 1 )
  9610. {
  9611. if ( bLAxisReleased )
  9612. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, cameraPosition, rawPlayerHeadingVector ) );
  9613. else
  9614. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, rawPlayerHeadingVector ) );
  9615. }
  9616.  
  9617. if ( selectionPriority.Size() > 0 )
  9618. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  9619. }
  9620. else
  9621. {
  9622. if ( bLAxisReleased )
  9623. {
  9624. if ( !lastAxisInputIsMovement )
  9625. {
  9626. for( i = 0; i < targetableEntities.Size(); i += 1 )
  9627. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, cameraPosition, rawPlayerHeadingVector ) );
  9628.  
  9629. if ( selectionPriority.Size() > 0 )
  9630. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  9631. }
  9632. else
  9633. {
  9634. if ( IsInCombatAction() )
  9635. selectedTargetableEntity = nonActorTarget;
  9636. else
  9637. {
  9638. for( i = 0; i < targetableEntities.Size(); i += 1 )
  9639. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, playerHeadingVector ) );
  9640.  
  9641. if ( selectionPriority.Size() > 0 )
  9642. {
  9643. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  9644.  
  9645. targetingInfo.source = this;
  9646. targetingInfo.targetEntity = selectedTargetableEntity;
  9647. targetingInfo.canBeTargetedCheck = false;
  9648. targetingInfo.coneCheck = true;
  9649. targetingInfo.coneHalfAngleCos = 0.0f;
  9650. targetingInfo.coneDist = softLockDist;
  9651. targetingInfo.coneHeadingVector = this.GetHeadingVector();
  9652. targetingInfo.distCheck = true;
  9653. targetingInfo.invisibleCheck = false;
  9654. targetingInfo.navMeshCheck = false;
  9655. targetingInfo.inFrameCheck = false;
  9656. targetingInfo.frameScaleX = 1.0f;
  9657. targetingInfo.frameScaleY = 1.0f;
  9658. targetingInfo.knockDownCheck = false;
  9659. targetingInfo.knockDownCheckDist = 0.0f;
  9660. targetingInfo.rsHeadingCheck = false;
  9661. targetingInfo.rsHeadingLimitCos = 1.0f;
  9662.  
  9663. if ( !IsEntityTargetable( targetingInfo ) )
  9664. selectedTargetableEntity = NULL;
  9665. }
  9666. }
  9667. }
  9668. }
  9669. else
  9670. {
  9671. for( i = 0; i < targetableEntities.Size(); i += 1 )
  9672. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, rawPlayerHeadingVector ) );
  9673.  
  9674. if ( selectionPriority.Size() > 0 )
  9675. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  9676. }
  9677. }
  9678. }
  9679. else
  9680. selectedTargetableEntity = NULL;
  9681. }
  9682.  
  9683. SetNonActorTarget( selectedTargetableEntity );
  9684. return selectedTargetableEntity;
  9685. }
  9686.  
  9687.  
  9688. public function SetupCombatAction( action : EBufferActionType, stage : EButtonStage )
  9689. {
  9690. var weaponType : EPlayerWeapon;
  9691. var canAttackTarget : CGameplayEntity;
  9692. var target : CActor;
  9693.  
  9694.  
  9695. if ( !IsCombatMusicEnabled() )
  9696. {
  9697. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  9698. FindTarget();
  9699. UpdateDisplayTarget( true );
  9700. }
  9701.  
  9702. if ( displayTarget && IsDisplayTargetTargetable() )
  9703. canAttackTarget = displayTarget;
  9704. else if ( GetTarget() )
  9705. canAttackTarget = GetTarget();
  9706. else if( !target && IsCombatMusicEnabled() )
  9707. canAttackTarget = moveTarget;
  9708.  
  9709. target = (CActor)canAttackTarget;
  9710.  
  9711. if ( !AllowAttack( target, action ) )
  9712. return;
  9713.  
  9714. if( ( action != EBAT_ItemUse ) && ( action != EBAT_CastSign ) )
  9715. {
  9716. weaponType = weaponHolster.GetCurrentMeleeWeapon();
  9717. PrepareToAttack( target, action );
  9718.  
  9719.  
  9720. if ( weaponType != weaponHolster.GetCurrentMeleeWeapon() )
  9721. {
  9722.  
  9723. if ( !( weaponType == PW_None && weaponHolster.GetCurrentMeleeWeapon() == PW_Fists ) )
  9724. return;
  9725. }
  9726. }
  9727.  
  9728.  
  9729. if(action == EBAT_SpecialAttack_Heavy && !((W3ReplacerCiri)this) )
  9730. thePlayer.SetAttackActionName(SkillEnumToName(S_Sword_s02));
  9731.  
  9732. CriticalEffectAnimationInterrupted("SetupCombatAction " + action);
  9733. PushCombatActionOnBuffer( action, stage );
  9734.  
  9735. if( GetBIsCombatActionAllowed() )
  9736. {
  9737. ProcessCombatActionBuffer();
  9738. }
  9739. }
  9740.  
  9741. // modHoodToggle
  9742. public var HoodToggleButton : bool; default HoodToggleButton = false; public function ToggleHood() {
  9743. HoodToggleButton = ( !HoodToggleButton );
  9744.  
  9745. if (HoodToggleButton)
  9746. FactsAdd("HoodOn");
  9747. else
  9748. FactsRemove("HoodOn");
  9749. }
  9750. public var CapeToggleButton : bool; default CapeToggleButton = false; public function ToggleCape() {
  9751. CapeToggleButton = ( !CapeToggleButton );
  9752.  
  9753. if (CapeToggleButton)
  9754. FactsAdd("CapeOn");
  9755. else
  9756. FactsRemove("CapeOn");
  9757. }
  9758.  
  9759. public var animHoodCape : string; default animHoodCape = ""; public function SetAnim( val : string ) { animHoodCape = val; }
  9760. timer function TimerHoodOn( dt : float, it : int ) { HoodOn(); }
  9761. timer function TimerHoodOff( dt : float, it : int ) { HoodOff(); }
  9762. timer function TimerCapeOn( dt : float, it : int ) { CapeOn(); }
  9763. timer function TimerCapeOff( dt : float, it : int ) { CapeOff(); }
  9764. timer function TimerInterrupt( dt : float, it : int ) { GotoState('CHInterruption'); }
  9765. // modHoodToggle
  9766.  
  9767. public function AllowAttack( target : CActor, action : EBufferActionType ) : bool
  9768. {
  9769. var newTarget : CActor;
  9770. var canAttackWhenNotInCombat : bool;
  9771. var messageDisplayed : bool;
  9772.  
  9773. var itemId : SItemUniqueId;
  9774. var isShootingCrossbow : bool;
  9775.  
  9776. var isInCorrectState : bool;
  9777.  
  9778. if ( target )
  9779. {
  9780. if ( target.IsTargetableByPlayer())
  9781. {
  9782. if ( !target.IsAttackableByPlayer() )
  9783. {
  9784. DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_cant_attack_this_target"));
  9785. return false;
  9786. }
  9787. }
  9788. }
  9789.  
  9790. if ( this.GetCurrentStateName() == 'Exploration' )
  9791. isInCorrectState = true;
  9792.  
  9793. if ( action == EBAT_ItemUse )
  9794. {
  9795. itemId = thePlayer.GetSelectedItemId();
  9796. if ( inv.IsIdValid(itemId) && inv.IsItemCrossbow(itemId) )
  9797. isShootingCrossbow = true;
  9798.  
  9799. if ( !isInCorrectState )
  9800. {
  9801. if ( this.GetCurrentStateName() == 'AimThrow' && !isShootingCrossbow )
  9802. {
  9803. isInCorrectState = true;
  9804. }
  9805. }
  9806. }
  9807.  
  9808. if ( isInCorrectState )
  9809. canAttackWhenNotInCombat = thePlayer.CanAttackWhenNotInCombat( action, false, newTarget, target );
  9810.  
  9811. if( !target )
  9812. {
  9813. if ( isInCorrectState )
  9814. {
  9815. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  9816. target = newTarget;
  9817. }
  9818. }
  9819.  
  9820. if ( isInCorrectState )
  9821. {
  9822. if ( !canAttackWhenNotInCombat )
  9823. {
  9824. if ( DisplayCannotAttackMessage( target ) )
  9825. messageDisplayed = true;
  9826. else if ( ( action == EBAT_LightAttack || action == EBAT_HeavyAttack )
  9827. && !RaiseAttackFriendlyEvent( target ) )
  9828. messageDisplayed = true;
  9829. else
  9830. {
  9831. if ( !CanRaiseCombatActionFriendlyEvent( isShootingCrossbow ) )
  9832. messageDisplayed = true;
  9833. }
  9834. }
  9835.  
  9836. if ( messageDisplayed )
  9837. {
  9838. theInput.ForceDeactivateAction('ThrowItem');
  9839. theInput.ForceDeactivateAction('ThrowItemHold');
  9840. this.SignalGameplayEvent( 'FriendlyAttackAction' );
  9841. return false;
  9842. }
  9843. }
  9844.  
  9845. return true;
  9846. }
  9847.  
  9848.  
  9849.  
  9850. public function ProcessCombatActionBuffer() : bool
  9851. {
  9852. var actionResult : bool;
  9853. var action : EBufferActionType = this.BufferCombatAction;
  9854. var stage : EButtonStage = this.BufferButtonStage;
  9855. var s : SNotWorkingOutFunctionParametersHackStruct1;
  9856. var allSteps : bool = this.BufferAllSteps;
  9857.  
  9858. if ( IsInCombatActionFriendly() )
  9859. {
  9860. RaiseEvent('CombatActionFriendlyEnd');
  9861. }
  9862.  
  9863.  
  9864. if ( ( action != EBAT_SpecialAttack_Heavy && action != EBAT_ItemUse )
  9865. || ( action == EBAT_SpecialAttack_Heavy && stage == BS_Pressed )
  9866. || ( action == EBAT_ItemUse && stage != BS_Released ) )
  9867. {
  9868. GetMovingAgentComponent().GetMovementAdjustor().CancelAll();
  9869. SetUnpushableTarget( NULL );
  9870. }
  9871.  
  9872.  
  9873. if ( !( action == EBAT_Dodge || action == EBAT_Roll ) )
  9874. {
  9875. SetIsCurrentlyDodging(false);
  9876. }
  9877.  
  9878. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  9879.  
  9880.  
  9881.  
  9882. if ( action == EBAT_ItemUse && GetInventory().IsItemCrossbow( selectedItemId ) )
  9883. {
  9884.  
  9885. if ( rangedWeapon
  9886. && ( ( rangedWeapon.GetCurrentStateName() != 'State_WeaponShoot' && rangedWeapon.GetCurrentStateName() != 'State_WeaponAim' ) || GetIsShootingFriendly() ) )
  9887. {
  9888. SetSlideTarget( GetCombatActionTarget( action ) );
  9889. }
  9890. }
  9891. else if ( !( ( action == EBAT_SpecialAttack_Heavy && stage == BS_Released ) || GetCurrentStateName() == 'AimThrow' ) )
  9892. {
  9893. SetSlideTarget( GetCombatActionTarget( action ) );
  9894. }
  9895.  
  9896. if( !slideTarget )
  9897. LogChannel( 'Targeting', "NO SLIDE TARGET" );
  9898.  
  9899.  
  9900. actionResult = true;
  9901.  
  9902. switch ( action )
  9903. {
  9904. case EBAT_EMPTY :
  9905. {
  9906. this.BufferAllSteps = false;
  9907. return true;
  9908. } break;
  9909.  
  9910. case EBAT_LightAttack :
  9911. {
  9912. if ( IsCiri() )
  9913. return false;
  9914.  
  9915. switch ( stage )
  9916. {
  9917. case BS_Pressed :
  9918. {
  9919.  
  9920.  
  9921.  
  9922.  
  9923.  
  9924.  
  9925. DrainStamina(ESAT_LightAttack);
  9926.  
  9927.  
  9928. thePlayer.BreakPheromoneEffect();
  9929. actionResult = OnPerformAttack(theGame.params.ATTACK_NAME_LIGHT);
  9930.  
  9931. } break;
  9932.  
  9933. default :
  9934. {
  9935. actionResult = false;
  9936. }break;
  9937. }
  9938. }break;
  9939.  
  9940. case EBAT_HeavyAttack :
  9941. {
  9942. if ( IsCiri() )
  9943. return false;
  9944.  
  9945. switch ( stage )
  9946. {
  9947. case BS_Released :
  9948. {
  9949.  
  9950.  
  9951.  
  9952.  
  9953.  
  9954. DrainStamina(ESAT_HeavyAttack);
  9955.  
  9956.  
  9957.  
  9958. thePlayer.BreakPheromoneEffect();
  9959. actionResult = this.OnPerformAttack(theGame.params.ATTACK_NAME_HEAVY);
  9960.  
  9961. } break;
  9962.  
  9963. case BS_Pressed :
  9964. {
  9965. if ( this.GetCurrentStateName() == 'CombatFists' )
  9966. {
  9967.  
  9968.  
  9969.  
  9970.  
  9971.  
  9972. DrainStamina(ESAT_HeavyAttack);
  9973.  
  9974.  
  9975.  
  9976. thePlayer.BreakPheromoneEffect();
  9977. actionResult = this.OnPerformAttack(theGame.params.ATTACK_NAME_HEAVY);
  9978.  
  9979. }
  9980. } break;
  9981.  
  9982. default :
  9983. {
  9984. actionResult = false;
  9985.  
  9986. } break;
  9987. }
  9988. } break;
  9989.  
  9990. case EBAT_ItemUse :
  9991. {
  9992. switch ( stage )
  9993. {
  9994. case BS_Pressed :
  9995. {
  9996. if ( !( (W3PlayerWitcher)this ) ||
  9997. ( !IsInCombatActionFriendly() && !( !GetBIsCombatActionAllowed() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign ) ) ) )
  9998.  
  9999. {
  10000. if ( inv.IsItemCrossbow( selectedItemId ) )
  10001. {
  10002. rangedWeapon = ( Crossbow )( inv.GetItemEntityUnsafe( selectedItemId ) );
  10003. rangedWeapon.OnRangedWeaponPress();
  10004. GetTarget().SignalGameplayEvent( 'Approach' );
  10005. GetTarget().SignalGameplayEvent( 'ShootingCrossbow' );
  10006. }
  10007. else if(inv.IsItemBomb(selectedItemId) && this.inv.SingletonItemGetAmmo(selectedItemId) > 0 )
  10008. {
  10009. if( ((W3PlayerWitcher)this).GetBombDelay( ((W3PlayerWitcher)this).GetItemSlot( selectedItemId ) ) <= 0.0f )
  10010. {
  10011. BombThrowStart();
  10012. GetTarget().SignalGameplayEvent( 'Approach' );
  10013. }
  10014. }
  10015. else
  10016. {
  10017. DrainStamina(ESAT_UsableItem);
  10018. UsableItemStart();
  10019. }
  10020. }
  10021.  
  10022. } if (!allSteps) break;
  10023.  
  10024. case BS_Released:
  10025. {
  10026. if ( !( (W3PlayerWitcher)this ) ||
  10027. ( !IsInCombatActionFriendly() && ( GetBIsCombatActionAllowed() || !( !GetBIsCombatActionAllowed() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign ) ) ) ) )
  10028.  
  10029. {
  10030. if ( inv.IsItemCrossbow( selectedItemId ) )
  10031. {
  10032.  
  10033. rangedWeapon.OnRangedWeaponRelease();
  10034. }
  10035. else if(inv.IsItemBomb(selectedItemId))
  10036. {
  10037. BombThrowRelease();
  10038. }
  10039. else
  10040. {
  10041. UsableItemRelease();
  10042. }
  10043. }
  10044. } break;
  10045.  
  10046. default :
  10047. {
  10048. actionResult = false;
  10049. break;
  10050. }
  10051. }
  10052. } break;
  10053.  
  10054. case EBAT_Dodge :
  10055. {
  10056. switch ( stage )
  10057. {
  10058. case BS_Released :
  10059. {
  10060. theGame.GetBehTreeReactionManager().CreateReactionEvent( this, 'PlayerEvade', 1.0f, 10.0f, -1.0f, -1 );
  10061. thePlayer.BreakPheromoneEffect();
  10062. actionResult = this.OnPerformEvade( PET_Dodge );
  10063. } break;
  10064.  
  10065.  
  10066.  
  10067. default :
  10068. {
  10069. actionResult = false;
  10070. } break;
  10071. }
  10072. } break;
  10073.  
  10074. case EBAT_Roll :
  10075. {
  10076. if ( IsCiri() )
  10077. return false;
  10078.  
  10079. switch ( stage )
  10080. {
  10081. case BS_Released :
  10082. {
  10083. theGame.GetBehTreeReactionManager().CreateReactionEvent( this, 'PlayerEvade', 1.0f, 10.0f, -1.0f, -1 );
  10084. thePlayer.BreakPheromoneEffect();
  10085. actionResult = this.OnPerformEvade( PET_Roll );
  10086. } break;
  10087.  
  10088. case BS_Pressed :
  10089. {
  10090. if ( this.GetBehaviorVariable( 'combatActionType' ) == 2.f )
  10091. {
  10092. if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
  10093. actionResult = this.OnPerformEvade( PET_Pirouette );
  10094. else
  10095. actionResult = this.OnPerformEvade( PET_Roll );
  10096. }
  10097. else
  10098. {
  10099. if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
  10100. {
  10101. actionResult = this.OnPerformEvade( PET_Dodge );
  10102. actionResult = this.OnPerformEvade( PET_Pirouette );
  10103. }
  10104. else
  10105. {
  10106. actionResult = this.OnPerformEvade( PET_Dodge );
  10107. actionResult = this.OnPerformEvade( PET_Roll );
  10108. }
  10109. }
  10110.  
  10111.  
  10112. } break;
  10113.  
  10114. default :
  10115. {
  10116. actionResult = false;
  10117. } break;
  10118. }
  10119. } break;
  10120.  
  10121. case EBAT_Draw_Steel :
  10122. {
  10123. switch ( stage )
  10124. {
  10125. case BS_Pressed :
  10126. {
  10127. if( !IsActionAllowed(EIAB_DrawWeapon) )
  10128. {
  10129. thePlayer.DisplayActionDisallowedHudMessage(EIAB_DrawWeapon);
  10130. actionResult = false;
  10131. break;
  10132. }
  10133. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'steelsword' ) )
  10134. {
  10135. OnEquipMeleeWeapon( PW_Steel, false, true );
  10136. }
  10137.  
  10138. actionResult = false;
  10139.  
  10140. } break;
  10141.  
  10142. default :
  10143. {
  10144. actionResult = false;
  10145. } break;
  10146. }
  10147. } break;
  10148.  
  10149. case EBAT_Draw_Silver :
  10150. {
  10151. switch ( stage )
  10152. {
  10153. case BS_Pressed :
  10154. {
  10155. if( !IsActionAllowed(EIAB_DrawWeapon) )
  10156. {
  10157. thePlayer.DisplayActionDisallowedHudMessage(EIAB_DrawWeapon);
  10158. actionResult = false;
  10159. break;
  10160. }
  10161. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'silversword' ) )
  10162. {
  10163. OnEquipMeleeWeapon( PW_Silver, false, true );
  10164. }
  10165.  
  10166. actionResult = false;
  10167.  
  10168. } break;
  10169.  
  10170. default :
  10171. {
  10172. actionResult = false;
  10173. } break;
  10174. }
  10175. } break;
  10176.  
  10177. case EBAT_Sheathe_Sword :
  10178. {
  10179. switch ( stage )
  10180. {
  10181. case BS_Pressed :
  10182. {
  10183. if( GetCurrentMeleeWeaponType() == PW_Silver )
  10184. {
  10185. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'silversword' ) )
  10186. {
  10187. OnEquipMeleeWeapon( PW_Silver, false, true );
  10188. }
  10189. }
  10190. else if( GetCurrentMeleeWeaponType() == PW_Steel )
  10191. {
  10192. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'steelsword' ) )
  10193. {
  10194. OnEquipMeleeWeapon( PW_Steel, false, true );
  10195. }
  10196. }
  10197.  
  10198. actionResult = false;
  10199.  
  10200. } break;
  10201.  
  10202. default :
  10203. {
  10204. actionResult = false;
  10205. } break;
  10206. }
  10207. } break;
  10208.  
  10209. default:
  10210. return false;
  10211. }
  10212.  
  10213.  
  10214. CleanCombatActionBuffer();
  10215.  
  10216. if (actionResult)
  10217. {
  10218. SetCombatAction( action ) ;
  10219.  
  10220. if(GetWitcherPlayer().IsInFrenzy())
  10221. GetWitcherPlayer().SkillFrenzyFinish(0);
  10222. }
  10223.  
  10224. return true;
  10225. }
  10226.  
  10227. public function CleanCombatActionBuffer()
  10228. {
  10229. BufferCombatAction = EBAT_EMPTY;
  10230. BufferAllSteps = false;
  10231. }
  10232.  
  10233. public function CancelHoldAttacks()
  10234. {
  10235. RemoveTimer( 'IsSpecialLightAttackInputHeld' );
  10236. RemoveTimer( 'IsSpecialHeavyAttackInputHeld' );
  10237. RemoveTimer( 'SpecialAttackLightSustainCost' );
  10238. RemoveTimer( 'SpecialAttackHeavySustainCost' );
  10239. RemoveTimer( 'UpdateSpecialAttackLightHeading' );
  10240. UnblockAction( EIAB_Crossbow, 'SpecialAttack' );
  10241.  
  10242. ResumeStaminaRegen('WhirlSkill');
  10243.  
  10244. if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_SpecialAttack && GetBehaviorVariable( 'isPerformingSpecialAttack' ) == 1.f )
  10245. {
  10246. if( GetBehaviorVariable( 'playerAttackType' ) == (int)PAT_Light )
  10247. {
  10248. SetAttackActionName(SkillEnumToName(S_Sword_s01));
  10249. PushCombatActionOnBuffer( EBAT_SpecialAttack_Light, BS_Released );
  10250. ProcessCombatActionBuffer();
  10251.  
  10252. ((W3PlayerWitcherStateCombatFists) GetState('Combat')).ResetTimeToEndCombat();
  10253.  
  10254. }
  10255. else if( GetBehaviorVariable( 'playerAttackType' ) == (int)PAT_Heavy )
  10256. {
  10257. SetAttackActionName(SkillEnumToName(S_Sword_s02));
  10258. PushCombatActionOnBuffer( EBAT_SpecialAttack_Heavy, BS_Released );
  10259. ProcessCombatActionBuffer();
  10260.  
  10261. }
  10262. }
  10263. }
  10264.  
  10265. public function RaiseAttackFriendlyEvent( actor : CActor ) : bool
  10266. {
  10267. var playerToTargetHeading : float;
  10268.  
  10269. if ( actor && RaiseCombatActionFriendlyEvent() )
  10270. {
  10271. SetBehaviorVariable( 'tauntTypeForOverlay', 0.f );
  10272. SetBehaviorVariable( 'combatActionTypeForOverlay', (int)CAT_Attack );
  10273.  
  10274. if ( actor )
  10275. actor.SignalGameplayEvent('PersonalTauntAction');
  10276. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'TauntAction', -1.0, 4.5f, -1, 9999, true );
  10277.  
  10278. OnCombatActionStart();
  10279.  
  10280. playerToTargetHeading = VecHeading( actor.GetWorldPosition() - GetWorldPosition() );
  10281.  
  10282. SetCustomRotation( 'Attack', playerToTargetHeading, 0.0f, 0.3f, false );
  10283.  
  10284. return true;
  10285. }
  10286.  
  10287. return false;
  10288. }
  10289.  
  10290. public function SendAttackReactionEvent()
  10291. {
  10292. var reactionName : name;
  10293.  
  10294.  
  10295.  
  10296. reactionName = 'AttackAction';
  10297.  
  10298. if ( IsNameValid(reactionName) )
  10299. {
  10300. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, reactionName, -1.0, 8.0f, -1, 5, true );
  10301. }
  10302.  
  10303.  
  10304. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'outOfMyWay', -1.0, 2.0f, -1, 5, true );
  10305. }
  10306.  
  10307. var forceCanAttackWhenNotInCombat : int;
  10308. public function SetForceCanAttackWhenNotInCombat( forceMode : int )
  10309. {
  10310. forceCanAttackWhenNotInCombat = forceMode;
  10311. }
  10312.  
  10313. public function CanAttackWhenNotInCombat( actionType : EBufferActionType, altCast : bool, out newTarget : CActor, optional target : CGameplayEntity ) : bool
  10314. {
  10315. var localTargets : array<CActor>;
  10316. var i, size : int;
  10317. var inputHeading : float;
  10318. var clearanceMin, clearanceMax : float;
  10319. var attackLength : float;
  10320. var attackAngle : float;
  10321. var npc : CNewNPC;
  10322. var canAttackTarget : CGameplayEntity;
  10323. var canAttackTargetActor : CActor;
  10324.  
  10325. if ( target )
  10326. canAttackTarget = target;
  10327. else if ( displayTarget && IsDisplayTargetTargetable() )
  10328. canAttackTarget = displayTarget;
  10329. else
  10330. canAttackTarget = slideTarget;
  10331.  
  10332. canAttackTargetActor = (CActor)canAttackTarget;
  10333.  
  10334. if ( forceCanAttackWhenNotInCombat == 2 )
  10335. return true;
  10336. else if ( forceCanAttackWhenNotInCombat == 1 && ( !canAttackTarget || !canAttackTargetActor.IsHuman() ) )
  10337. return true;
  10338.  
  10339. if ( actionType == EBAT_CastSign )
  10340. {
  10341. if ( thePlayer.GetEquippedSign() != ST_Quen && thePlayer.GetEquippedSign() != ST_Axii )
  10342. {
  10343. if ( CanUseSkill( S_Magic_s20 ) )
  10344. {
  10345. if ( thePlayer.GetEquippedSign() == ST_Aard )
  10346. attackLength = 6.f;
  10347. else if ( thePlayer.GetEquippedSign() == ST_Igni )
  10348. attackLength = 4.f;
  10349. else
  10350. attackLength = 6.f;
  10351. }
  10352. else
  10353. {
  10354. if ( thePlayer.GetEquippedSign() == ST_Aard )
  10355. attackLength = 9.f;
  10356. else if ( thePlayer.GetEquippedSign() == ST_Igni )
  10357. attackLength = 6.f;
  10358. else
  10359. attackLength = 6.f;
  10360. }
  10361.  
  10362. if ( altCast )
  10363. attackAngle = 180.f;
  10364. else
  10365.  
  10366. attackAngle = 90.f;
  10367.  
  10368. if ( !lastAxisInputIsMovement )
  10369. inputHeading = VecHeading( theCamera.GetCameraDirection() );
  10370. else if ( lAxisReleasedAfterCounter )
  10371. inputHeading = GetHeading();
  10372. else
  10373. inputHeading = GetCombatActionHeading();
  10374.  
  10375. clearanceMin = 1.f;
  10376. clearanceMax = attackLength + 1.f;
  10377. }
  10378. else if ( thePlayer.GetEquippedSign() == ST_Axii )
  10379. {
  10380. npc = (CNewNPC)canAttackTarget;
  10381. if ( npc && npc.GetNPCType() == ENGT_Quest && !npc.HasTag(theGame.params.TAG_AXIIABLE_LOWER_CASE) && !npc.HasTag(theGame.params.TAG_AXIIABLE))
  10382. return false;
  10383. else if ( npc && npc.IsUsingHorse() )
  10384. return false;
  10385. else
  10386. return true;
  10387. }
  10388. else
  10389. return true;
  10390. }
  10391. else if ( actionType == EBAT_ItemUse )
  10392. {
  10393. attackLength = theGame.params.MAX_THROW_RANGE;
  10394. attackAngle = 90.f;
  10395.  
  10396. if ( thePlayer.lastAxisInputIsMovement )
  10397. inputHeading = GetCombatActionHeading();
  10398. else
  10399. inputHeading = VecHeading( theCamera.GetCameraDirection() );
  10400.  
  10401. clearanceMin = 0.8f;
  10402. clearanceMax = attackLength + 3.f;
  10403. }
  10404. else
  10405. {
  10406. if ( actionType == EBAT_SpecialAttack_Light || actionType == EBAT_SpecialAttack_Heavy )
  10407. {
  10408. attackLength = 1.9f;
  10409. attackAngle = 90.f;
  10410. }
  10411. else
  10412. {
  10413. if( thePlayer.GetCurrentMeleeWeaponType() == PW_Fists || thePlayer.GetCurrentMeleeWeaponType() == PW_None )
  10414. attackLength = 1.2f;
  10415. else
  10416. attackLength = 1.9f;
  10417.  
  10418. attackAngle = 90.f;
  10419. }
  10420.  
  10421. if ( lastAxisInputIsMovement )
  10422. inputHeading = GetCombatActionHeading();
  10423. else
  10424. inputHeading = VecHeading( theCamera.GetCameraDirection() );
  10425.  
  10426. clearanceMin = attackLength / 2.f;
  10427. clearanceMax = attackLength + 3.f;
  10428. }
  10429.  
  10430.  
  10431. if ( canAttackTarget )
  10432. {
  10433. if ( ( canAttackTargetActor && canAttackTargetActor.IsHuman() ) || canAttackTargetActor.HasTag( 'softLock_Friendly' ) )
  10434. {
  10435. if ( ShouldPerformFriendlyAction( canAttackTargetActor, inputHeading, attackAngle, clearanceMin, clearanceMax ) )
  10436. {
  10437. SetSlideTarget( canAttackTargetActor );
  10438. newTarget = canAttackTargetActor;
  10439. return false;
  10440. }
  10441. }
  10442.  
  10443.  
  10444. }
  10445.  
  10446. return true;
  10447.  
  10448. thePlayer.GetVisibleEnemies( localTargets );
  10449. size = localTargets.Size();
  10450.  
  10451. if ( size > 0 )
  10452. {
  10453. for ( i = size-1; i>=0; i-=1 )
  10454. {
  10455.  
  10456. if ( !localTargets[i].IsHuman() && !localTargets[i].HasTag( 'softLock_Friendly' ) )
  10457. localTargets.Erase(i);
  10458. }
  10459. }
  10460.  
  10461. size = localTargets.Size();
  10462. if ( size > 0 )
  10463. {
  10464. for ( i = 0; i < localTargets.Size(); i += 1 )
  10465. {
  10466. if ( ShouldPerformFriendlyAction( localTargets[i], inputHeading, attackAngle, clearanceMin, clearanceMax ) )
  10467. {
  10468. SetSlideTarget( localTargets[i] );
  10469. newTarget = localTargets[i];
  10470. return false;
  10471. }
  10472. }
  10473. }
  10474.  
  10475. newTarget = NULL;
  10476.  
  10477. return true;
  10478. }
  10479.  
  10480. private function ShouldPerformFriendlyAction( actor : CActor, inputHeading, attackAngle, clearanceMin, clearanceMax : float ) : bool
  10481. {
  10482. var npc : CNewNPC;
  10483. var argh : float;
  10484. var playerToTargetDist : float;
  10485.  
  10486. npc = (CNewNPC)actor;
  10487.  
  10488. if ( npc &&
  10489. ( GetAttitudeBetween(thePlayer, npc) == AIA_Hostile || ( GetAttitudeBetween(thePlayer, npc) == AIA_Neutral && npc.GetNPCType() != ENGT_Guard ) ) )
  10490. {
  10491. }
  10492. else
  10493. {
  10494. playerToTargetDist = VecDistance( this.GetWorldPosition(), actor.PredictWorldPosition( 0.5f ) );
  10495.  
  10496. argh = AbsF( AngleDistance( inputHeading, VecHeading( actor.GetWorldPosition() - thePlayer.GetWorldPosition() ) ) );
  10497.  
  10498. if ( AbsF( AngleDistance( inputHeading, VecHeading( actor.GetWorldPosition() - thePlayer.GetWorldPosition() ) ) ) < attackAngle )
  10499. {
  10500. if ( playerToTargetDist < clearanceMax )
  10501. {
  10502. return true;
  10503. }
  10504. }
  10505. else
  10506. {
  10507. if ( playerToTargetDist < clearanceMin )
  10508. {
  10509. return true;
  10510. }
  10511. }
  10512. }
  10513.  
  10514. return false;
  10515. }
  10516.  
  10517.  
  10518.  
  10519.  
  10520.  
  10521. public function GetHudMessagesSize() : int
  10522. {
  10523. return HudMessages.Size();
  10524. }
  10525.  
  10526. public function GetHudPendingMessage() : string
  10527. {
  10528. return HudMessages[0];
  10529. }
  10530.  
  10531. public function DisplayHudMessage( value : string ) : void
  10532. {
  10533. if (value == "")
  10534. {
  10535. return;
  10536. }
  10537.  
  10538. if( GetHudMessagesSize() > 0 )
  10539. {
  10540. if( HudMessages[HudMessages.Size()-1] == value )
  10541. {
  10542. return;
  10543. }
  10544. }
  10545. HudMessages.PushBack(value);
  10546. }
  10547.  
  10548.  
  10549. private final function DisallowedActionDontShowHack(action : EInputActionBlock, isTimeLock : bool) : bool
  10550. {
  10551. var locks : array< SInputActionLock >;
  10552. var i : int;
  10553.  
  10554.  
  10555. 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)) )
  10556. {
  10557. return true;
  10558. }
  10559.  
  10560.  
  10561. if( action == EIAB_ThrowBomb && ( HasBuff( EET_Hypnotized ) || HasBuff( EET_Confusion ) ) )
  10562. {
  10563. return false;
  10564. }
  10565.  
  10566.  
  10567. if(isTimeLock)
  10568. return false;
  10569.  
  10570.  
  10571. if(action == EIAB_OpenMeditation)
  10572. return false;
  10573.  
  10574.  
  10575. locks = GetActionLocks(action);
  10576. for(i=0; i<locks.Size(); i+=1)
  10577. {
  10578. if(locks[i].isFromQuest || locks[i].isFromPlace)
  10579. return false;
  10580. }
  10581.  
  10582. if ( this.IsCurrentlyUsingItemL() )
  10583. {
  10584. if ( action == EIAB_HeavyAttacks || action == EIAB_Parry )
  10585. return false;
  10586. }
  10587.  
  10588.  
  10589. return true;
  10590. }
  10591.  
  10592. // CA
  10593. public var completeAnims : CompleteAnimations;
  10594. public function CAInit() { completeAnims = new CompleteAnimations in this; }
  10595. timer function CAInterruptMonitor( dt : float , id : int ) { if( theInput.IsActionJustPressed( 'Jump' ) || theInput.IsActionJustPressed( 'Dodge' ) || theInput.IsActionJustPressed( 'Roll' ) ) { GotoState('CAInterruption'); } }
  10596. timer function CADelayedInterrupt( dt : float, id : int ) { GotoState('CAInterruption'); }
  10597. timer function CAAnimState( time : float, id : int ) { GotoState('CAAnimation'); }
  10598. timer function CARemoveHornItem( dt : float, it : int ) { inv.UnmountItem( inv.GetItemId( completeAnims.hornItem ) ); inv.RemoveItem( inv.GetItemId( completeAnims.hornItem ), inv.GetItemQuantity( inv.GetItemId( completeAnims.hornItem ) ) ); }
  10599. timer function CARemoveSecondHornItem( dt : float, it : int ) { inv.UnmountItem( inv.GetItemId( completeAnims.secondHornItem ) ); inv.RemoveItem( inv.GetItemId( completeAnims.secondHornItem ), inv.GetItemQuantity( inv.GetItemId( completeAnims.secondHornItem ) ) ); }
  10600. timer function CATimerPlayHorn( dt : float, it : int ) { thePlayer.completeAnims.PlayHorn(); }
  10601. timer function CAUnblockActions( dt : float, id : int ) { thePlayer.completeAnims.UnblockAllDrinkingActions(); }
  10602. timer function CAReuseUsableItem( dt : float, id : int ) { if (thePlayer.completeAnims.usedLeftItem) { thePlayer.completeAnims.SetUsedLeftItem( false ); OnUseSelectedItem(); } else { GetWitcherPlayer().RaiseEvent('ForcedUsableItemUnequip'); } }
  10603. // CA
  10604.  
  10605. public final function DisplayActionDisallowedHudMessage(action : EInputActionBlock, optional isCombatLock : bool, optional isPlaceLock : bool, optional isTimeLock : bool, optional isDangerous : bool)
  10606. {
  10607. var lockType : name;
  10608.  
  10609. if(action != EIAB_Undefined && DisallowedActionDontShowHack(action, isTimeLock))
  10610. return;
  10611.  
  10612.  
  10613. if(IsInCombat() && !IsActionCombat(action))
  10614. isCombatLock = true;
  10615.  
  10616.  
  10617. if(!isCombatLock && !isPlaceLock && !isTimeLock && action != EIAB_Undefined)
  10618. {
  10619. lockType = inputHandler.GetActionBlockedHudLockType(action);
  10620.  
  10621. if(lockType == 'combat')
  10622. isCombatLock = true;
  10623. else if(lockType == 'place')
  10624. isPlaceLock = true;
  10625. else if(lockType == 'time')
  10626. isTimeLock = true;
  10627. }
  10628.  
  10629. if(isDangerous)
  10630. {
  10631. DisplayHudMessage(GetLocStringByKeyExt( "message_meditation_too_dangerous" ));
  10632. }
  10633. else if(isCombatLock)
  10634. {
  10635. DisplayHudMessage(GetLocStringByKeyExt( "panel_hud_message_actionnotallowed_combat" ));
  10636. }
  10637. else if(isPlaceLock)
  10638. {
  10639. DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_here" ));
  10640. }
  10641. else if(isTimeLock)
  10642. {
  10643. DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_now" ));
  10644. }
  10645. }
  10646.  
  10647.  
  10648. public function RemoveHudMessageByString(msg : string, optional allQueuedInstances : bool)
  10649. {
  10650. var i, j : int;
  10651.  
  10652. for(i=0; i<HudMessages.Size(); i+=1)
  10653. {
  10654. if(HudMessages[i] == msg)
  10655. {
  10656. HudMessages.EraseFast(i);
  10657.  
  10658. if(!allQueuedInstances)
  10659. return;
  10660.  
  10661. break;
  10662. }
  10663. }
  10664.  
  10665.  
  10666. for(j=HudMessages.Size()-1; j >= i; j-=1)
  10667. {
  10668. if(HudMessages[i] == msg)
  10669. {
  10670. HudMessages.EraseFast(i);
  10671. }
  10672. }
  10673. }
  10674.  
  10675. public function RemoveHudMessageByIndex(idx : int)
  10676. {
  10677. if(idx >= 0 && idx < HudMessages.Size())
  10678. HudMessages.Erase(idx);
  10679. }
  10680.  
  10681. function SetSettlementBlockCanter( valueAdd : int )
  10682. {
  10683. m_SettlementBlockCanter += valueAdd;
  10684. }
  10685.  
  10686. var countDownToStart : int;
  10687. default countDownToStart = 0;
  10688.  
  10689. function DisplayRaceStart( countDownSecondsNumber : int )
  10690. {
  10691. var i : int;
  10692. countDownToStart = countDownSecondsNumber;
  10693. for( i = countDownSecondsNumber; i > 0; i -= 1 )
  10694. {
  10695. DisplayHudMessage(IntToString(i));
  10696. }
  10697. DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_race_start"));
  10698. AddTimer('RaceCountdown',1,true);
  10699. }
  10700.  
  10701. timer function RaceCountdown(dt : float, id : int)
  10702. {
  10703. var hud : CR4ScriptedHud;
  10704. var messageModule : CR4HudModuleMessage;
  10705.  
  10706. countDownToStart -= 1;
  10707. hud = (CR4ScriptedHud)theGame.GetHud();
  10708.  
  10709. if( hud )
  10710. {
  10711. messageModule = (CR4HudModuleMessage)hud.GetHudModule("MessageModule");
  10712. if( messageModule )
  10713. {
  10714. messageModule.OnMessageHidden();
  10715. }
  10716. }
  10717.  
  10718. if( countDownToStart <= 0 )
  10719. {
  10720. RemoveTimer('RaceCountdown');
  10721. }
  10722. }
  10723.  
  10724. public function GetCountDownToStart() : int
  10725. {
  10726. return countDownToStart;
  10727. }
  10728.  
  10729. public function HAXE3GetContainer() : W3Container
  10730. {
  10731. return HAXE3Container;
  10732. }
  10733.  
  10734. public function HAXE3SetContainer( container : W3Container) : void
  10735. {
  10736. HAXE3Container = container;
  10737. }
  10738.  
  10739. public function HAXE3GetAutoLoot() : bool
  10740. {
  10741. return HAXE3bAutoLoot;
  10742. }
  10743.  
  10744. public function HAXE3SetAutoLoot( value : bool ) : void
  10745. {
  10746. HAXE3bAutoLoot = value;
  10747. }
  10748.  
  10749. public function GetShowHud() : bool
  10750. {
  10751. return bShowHud;
  10752. }
  10753.  
  10754. public function SetShowHud( value : bool ) : void
  10755. {
  10756. bShowHud = value;
  10757. }
  10758.  
  10759. public function DisplayItemRewardNotification( itemName : name, optional quantity : int ) : void
  10760. {
  10761. var hud : CR4ScriptedHud;
  10762. hud = (CR4ScriptedHud)theGame.GetHud();
  10763. hud.OnItemRecivedDuringScene(itemName, quantity);
  10764. }
  10765.  
  10766. function IsNewQuest( questGuid : CGUID ) : bool
  10767. {
  10768. var i : int;
  10769. for(i = 0; i < displayedQuestsGUID.Size(); i += 1 )
  10770. {
  10771. if( displayedQuestsGUID[i] == questGuid )
  10772. {
  10773. return false;
  10774. }
  10775. }
  10776. displayedQuestsGUID.PushBack(questGuid);
  10777. return true;
  10778. }
  10779.  
  10780. function GetRewardMultiplierData( rewardName : name ) : SRewardMultiplier
  10781. {
  10782. var defaultReward : SRewardMultiplier;
  10783. var i : int;
  10784.  
  10785. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  10786. {
  10787. if( rewardsMultiplier[i].rewardName == rewardName )
  10788. {
  10789. return rewardsMultiplier[i];
  10790. }
  10791. }
  10792.  
  10793. defaultReward.rewardName = rewardName;
  10794. defaultReward.rewardMultiplier = 1.0;
  10795. defaultReward.isItemMultiplier = false;
  10796.  
  10797. return defaultReward;
  10798. }
  10799.  
  10800. function GetRewardMultiplier( rewardName : name ) : float
  10801. {
  10802. var i : int;
  10803. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  10804. {
  10805. if( rewardsMultiplier[i].rewardName == rewardName )
  10806. {
  10807. return rewardsMultiplier[i].rewardMultiplier;
  10808. }
  10809. }
  10810. return 1.0;
  10811. }
  10812.  
  10813. function GetRewardMultiplierExists( rewardName : name ) : bool
  10814. {
  10815. var i : int;
  10816. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  10817. {
  10818. if( rewardsMultiplier[i].rewardName == rewardName )
  10819. {
  10820. return true;
  10821. }
  10822. }
  10823. return false;
  10824. }
  10825.  
  10826. function SetRewardMultiplier( rewardName : name, value : float, optional isItemMultiplier : bool ) : void
  10827. {
  10828. var i : int;
  10829. var rewardMultiplier : SRewardMultiplier;
  10830.  
  10831. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  10832. {
  10833. if( rewardsMultiplier[i].rewardName == rewardName )
  10834. {
  10835. rewardsMultiplier[i].rewardMultiplier = value;
  10836. rewardsMultiplier[i].isItemMultiplier = isItemMultiplier;
  10837. return;
  10838. }
  10839. }
  10840.  
  10841. rewardMultiplier.rewardName = rewardName;
  10842. rewardMultiplier.rewardMultiplier = value;
  10843. rewardMultiplier.isItemMultiplier = isItemMultiplier;
  10844.  
  10845. rewardsMultiplier.PushBack(rewardMultiplier);
  10846. }
  10847.  
  10848. function RemoveRewardMultiplier( rewardName : name ) : void
  10849. {
  10850. var i : int;
  10851. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  10852. {
  10853. if( rewardsMultiplier[i].rewardName == rewardName )
  10854. {
  10855. rewardsMultiplier.Erase(i);
  10856. return;
  10857. }
  10858. }
  10859. }
  10860.  
  10861.  
  10862.  
  10863.  
  10864.  
  10865.  
  10866.  
  10867. public final function TissueExtractorDischarge() : bool
  10868. {
  10869. var ids : array<SItemUniqueId>;
  10870. var chargesLeft, uses, curr, max, red, blue, green : int;
  10871. var i : int;
  10872. var text : string;
  10873.  
  10874. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  10875. if( ids.Size() == 0 )
  10876. {
  10877. return false;
  10878. }
  10879.  
  10880. curr = GetTissueExtractorChargesCurr();
  10881. max = GetTissueExtractorChargesMax();
  10882.  
  10883. if( curr >= max )
  10884. {
  10885.  
  10886. uses = FloorF( ( ( float ) curr ) / ( ( float ) max ) );
  10887. chargesLeft = Max( 0, curr - uses * max );
  10888.  
  10889.  
  10890. inv.SetItemModifierInt( ids[0], 'charges', chargesLeft );
  10891.  
  10892.  
  10893. blue = 0;
  10894. green = 0;
  10895. red = 0;
  10896. for( i=0; i<uses; i+=1 )
  10897. {
  10898. switch( RandRange( 3 ) )
  10899. {
  10900. case 0:
  10901. blue += 1;
  10902. break;
  10903. case 1:
  10904. green += 1;
  10905. break;
  10906. case 2:
  10907. red += 1;
  10908. }
  10909. }
  10910.  
  10911. text = GetLocStringByKeyExt( "message_q705_extractor_extracted" );
  10912.  
  10913. if( blue > 0 )
  10914. {
  10915. inv.AddAnItem( 'Greater mutagen blue', blue, false, true );
  10916. text += "<br/>" + blue + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen blue' ) );
  10917. }
  10918. if( green > 0 )
  10919. {
  10920. inv.AddAnItem( 'Greater mutagen green', green, false, true );
  10921. text += "<br/>" + green + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen green' ) );
  10922. }
  10923. if( red > 0 )
  10924. {
  10925. inv.AddAnItem( 'Greater mutagen red', red, false, true );
  10926. text += "<br/>" + red + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen red' ) );
  10927. }
  10928.  
  10929.  
  10930. theGame.GetGuiManager().ShowNotification( text );
  10931.  
  10932.  
  10933. inv.SetItemModifierInt( ids[0], 'ui_notified', 0 );
  10934.  
  10935. return true;
  10936. }
  10937. else
  10938. {
  10939.  
  10940. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_q705_extractor_too_few_charges" ) );
  10941. }
  10942.  
  10943. return false;
  10944. }
  10945.  
  10946. public final function TissueExtractorIncCharge()
  10947. {
  10948. var ids : array<SItemUniqueId>;
  10949. var uiData : SInventoryItemUIData;
  10950. var curr : int;
  10951.  
  10952. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  10953. if( ids.Size() == 0 )
  10954. {
  10955. return;
  10956. }
  10957.  
  10958. curr = GetTissueExtractorChargesCurr() + 1;
  10959. inv.SetItemModifierInt( ids[0], 'charges', curr );
  10960.  
  10961.  
  10962. if( curr >= GetTissueExtractorChargesMax() )
  10963. {
  10964. uiData = inv.GetInventoryItemUIData( ids[0] );
  10965. uiData.isNew = true;
  10966. inv.SetInventoryItemUIData( ids[0], uiData );
  10967.  
  10968.  
  10969. if( inv.GetItemModifierInt( ids[0], 'ui_notified', 0 ) == 0 )
  10970. {
  10971. inv.SetItemModifierInt( ids[0], 'ui_notified', 1 );
  10972. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_q705_extractor_charged" ), , true );
  10973. }
  10974. }
  10975. }
  10976.  
  10977. public final function GetTissueExtractorChargesCurr() : int
  10978. {
  10979. var ids : array<SItemUniqueId>;
  10980.  
  10981. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  10982. if( ids.Size() == 0 )
  10983. {
  10984. return 0;
  10985. }
  10986.  
  10987. return inv.GetItemModifierInt( ids[0], 'charges', 0 );
  10988. }
  10989.  
  10990. public final function GetTissueExtractorChargesMax() : int
  10991. {
  10992. var ids : array<SItemUniqueId>;
  10993. var val : SAbilityAttributeValue;
  10994.  
  10995. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  10996. if( ids.Size() == 0 )
  10997. {
  10998. return 0;
  10999. }
  11000.  
  11001. val = inv.GetItemAttributeValue( ids[0], 'maxCharges' );
  11002.  
  11003. return FloorF( val.valueBase );
  11004. }
  11005.  
  11006. public function GetEquippedSword(steel : bool) : SItemUniqueId;
  11007.  
  11008. public final function HasRequiredLevelToEquipItem(item : SItemUniqueId) : bool
  11009. {
  11010. //CiriCSfix
  11011. if(thePlayer.IsCiri())
  11012. return true;
  11013. //CiriCSfix
  11014.  
  11015. if(HasBuff(EET_WolfHour))
  11016. {
  11017. if((inv.GetItemLevel(item) - 2) > GetLevel() )
  11018. return false;
  11019. }
  11020. else
  11021. {
  11022. if(inv.GetItemLevel(item) > GetLevel() )
  11023. return false;
  11024. }
  11025.  
  11026. return true;
  11027. }
  11028.  
  11029. public function SkillReduceBombAmmoBonus()
  11030. {
  11031. var i, ammo, maxAmmo : int;
  11032. var items : array<SItemUniqueId>;
  11033.  
  11034. items = inv.GetSingletonItems();
  11035.  
  11036. for(i=0; i<items.Size(); i+=1)
  11037. {
  11038. ammo = inv.GetItemModifierInt(items[i], 'ammo_current');
  11039.  
  11040.  
  11041. if(ammo > 0)
  11042. {
  11043. maxAmmo = inv.SingletonItemGetMaxAmmo(items[i]);
  11044.  
  11045.  
  11046. if(ammo > maxAmmo)
  11047. {
  11048. inv.SetItemModifierInt(items[i], 'ammo_current', maxAmmo);
  11049. }
  11050. }
  11051. }
  11052. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  11053. }
  11054.  
  11055. public function ConsumeItem( itemId : SItemUniqueId ) : bool
  11056. {
  11057. var params : SCustomEffectParams;
  11058. var buffs : array<SEffectInfo>;
  11059. var i : int;
  11060. var category : name;
  11061. var potionToxicity : float;
  11062.  
  11063. if(!inv.IsIdValid(itemId))
  11064. return false;
  11065.  
  11066. category = inv.GetItemCategory(itemId);
  11067. if(category == 'edibles' || inv.ItemHasTag(itemId, 'Drinks') || ( category == 'alchemy_ingredient' && inv.ItemHasTag(itemId, 'Alcohol')) )
  11068. {
  11069.  
  11070. if(IsFistFightMinigameEnabled())
  11071. {
  11072. DisplayActionDisallowedHudMessage(EIAB_Undefined, false, false, true);
  11073. return false;
  11074. }
  11075.  
  11076.  
  11077. inv.GetItemBuffs(itemId, buffs);
  11078.  
  11079. for(i=0; i<buffs.Size(); i+=1)
  11080. {
  11081. params.effectType = buffs[i].effectType;
  11082. params.creator = this;
  11083. params.sourceName = "edible";
  11084. params.customAbilityName = buffs[i].effectAbilityName;
  11085. AddEffectCustom(params);
  11086. }
  11087.  
  11088.  
  11089. if ( inv.ItemHasTag(itemId, 'Alcohol') )
  11090. {
  11091. potionToxicity = CalculateAttributeValue(inv.GetItemAttributeValue(itemId, 'toxicity'));
  11092. abilityManager.GainStat(BCS_Toxicity, potionToxicity );
  11093. AddEffectDefault(EET_Drunkenness, NULL, inv.GetItemName(itemId));
  11094. }
  11095. PlayItemConsumeSound( itemId );
  11096.  
  11097. }
  11098.  
  11099. if(inv.IsItemFood(itemId))
  11100. FactsAdd("consumed_food_cnt");
  11101.  
  11102.  
  11103.  
  11104. if(!inv.ItemHasTag(itemId, theGame.params.TAG_INFINITE_USE) && !inv.RemoveItem(itemId))
  11105. {
  11106. LogAssert(false,"Failed to remove consumable item from player inventory!" + inv.GetItemName( itemId ) );
  11107. return false;
  11108. }
  11109.  
  11110. return true;
  11111. }
  11112.  
  11113. public function MountVehicle( vehicleEntity : CEntity, mountType : EVehicleMountType, optional vehicleSlot : EVehicleSlot )
  11114. {
  11115. var vehicle : CVehicleComponent;
  11116. vehicle = (CVehicleComponent)(vehicleEntity.GetComponentByClassName('CVehicleComponent'));
  11117.  
  11118. if ( vehicle )
  11119. vehicle.Mount( this, mountType, vehicleSlot );
  11120. }
  11121.  
  11122. public function DismountVehicle( vehicleEntity : CEntity, dismountType : EDismountType )
  11123. {
  11124. var vehicle : CVehicleComponent;
  11125. vehicle = (CVehicleComponent)(vehicleEntity.GetComponentByClassName('CVehicleComponent'));
  11126.  
  11127. if ( vehicle )
  11128. vehicle.IssueCommandToDismount( dismountType );
  11129. }
  11130.  
  11131.  
  11132.  
  11133.  
  11134.  
  11135. protected function ShouldDrainStaminaWhileSprinting() : bool
  11136. {
  11137. if( HasBuff( EET_PolishedGenitals ) && !IsInCombat() && !IsThreatened() )
  11138. {
  11139. return false;
  11140. }
  11141.  
  11142. return super.ShouldDrainStaminaWhileSprinting();
  11143. }
  11144.  
  11145.  
  11146.  
  11147. public function HasStaminaToUseAction(action : EStaminaActionType, optional abilityName : name, optional dt :float, optional multiplier : float) : bool
  11148. {
  11149. var cost : float;
  11150. var ret : bool;
  11151.  
  11152. ret = super.HasStaminaToUseAction(action, abilityName, dt, multiplier);
  11153.  
  11154. if(!ret)
  11155. {
  11156. SetCombatActionHeading( GetHeading() );
  11157.  
  11158. if(multiplier == 0)
  11159. multiplier = 1;
  11160.  
  11161. cost = multiplier * GetStaminaActionCost(action, abilityName, dt);
  11162. SetShowToLowStaminaIndication(cost);
  11163. }
  11164.  
  11165. return ret;
  11166. }
  11167.  
  11168.  
  11169. timer function AbilityManager_FloorStaminaSegment(dt : float, id : int)
  11170. {
  11171. ((W3PlayerAbilityManager)abilityManager).FloorStaminaSegment();
  11172. }
  11173.  
  11174. public function DrainToxicity(amount : float )
  11175. {
  11176. if(abilityManager && abilityManager.IsInitialized() && IsAlive())
  11177. abilityManager.DrainToxicity(amount);
  11178. }
  11179.  
  11180. // FCR3 --
  11181. /*
  11182. public function DrainFocus(amount : float )
  11183. {
  11184. if(abilityManager && abilityManager.IsInitialized() && IsAlive())
  11185. abilityManager.DrainFocus(amount);
  11186.  
  11187. }*/
  11188.  
  11189. private var drainFocusAmount : float;
  11190. private var drainFocusTimerActive : bool;
  11191. public function DrainFocus(amount : float )
  11192. {
  11193. if(abilityManager && abilityManager.IsInitialized() && IsAlive())
  11194. {
  11195. //if( GetWitcherPlayer().IsMutationActive( EPMT_Mutation7 ) && !drainFocusTimerActive && thePlayer.GetHealthPercents() >= 1 && thePlayer.IsInCombat() )
  11196. if( GetWitcherPlayer().IsMutationActive( EPMT_Mutation7 ) )
  11197. {
  11198. drainFocusAmount += amount;
  11199. if ( !drainFocusTimerActive )
  11200. {
  11201. AddTimer('Mutation7DelayedDrainFocus', 4.0f, , , , true);
  11202. drainFocusTimerActive = true;
  11203. }
  11204. }
  11205. else
  11206. {
  11207. abilityManager.DrainFocus(amount);
  11208.  
  11209. }*/
  11210.  
  11211. private var drainFocusAmount : float;
  11212. private var drainFocusTimerActive : bool;
  11213. public function DrainFocus(amount : float )
  11214. {
  11215. if(abilityManager && abilityManager.IsInitialized() && IsAlive())
  11216. {
  11217. //if( GetWitcherPlayer().IsMutationActive( EPMT_Mutation7 ) && !drainFocusTimerActive && thePlayer.GetHealthPercents() >= 1 && thePlayer.IsInCombat() )
  11218. if( GetWitcherPlayer().IsMutationActive( EPMT_Mutation7 ) )
  11219. {
  11220. drainFocusAmount += amount;
  11221. if ( !drainFocusTimerActive )
  11222. {
  11223. AddTimer('Mutation7DelayedDrainFocus', 4.0f, , , , true);
  11224. drainFocusTimerActive = true;
  11225. }
  11226. }
  11227. else
  11228. {
  11229. abilityManager.DrainFocus(amount);
  11230.  
  11231. }*/
  11232.  
  11233. private var drainFocusAmount : float;
  11234. private var drainFocusTimerActive : bool;
  11235. public function DrainFocus(amount : float )
  11236. {
  11237. if(abilityManager && abilityManager.IsInitialized() && IsAlive())
  11238. {
  11239. //if( GetWitcherPlayer().IsMutationActive( EPMT_Mutation7 ) && !drainFocusTimerActive && thePlayer.GetHealthPercents() >= 1 && thePlayer.IsInCombat() )
  11240. if( GetWitcherPlayer().IsMutationActive( EPMT_Mutation7 ) )
  11241. {
  11242. drainFocusAmount += amount;
  11243. if ( !drainFocusTimerActive )
  11244. {
  11245. AddTimer('Mutation7DelayedDrainFocus', 4.0f, , , , true);
  11246. drainFocusTimerActive = true;
  11247. }
  11248. }
  11249. else
  11250. {
  11251. abilityManager.DrainFocus(amount);
  11252. }
  11253. }
  11254. }
  11255.  
  11256. timer function Mutation7DelayedDrainFocus( dt : float, id : int )
  11257. {
  11258. abilityManager.DrainFocus(drainFocusAmount);
  11259. drainFocusTimerActive = false;
  11260. drainFocusAmount = 0;
  11261. }
  11262. // -- FCR3
  11263.  
  11264. public function GetOffenseStat():int
  11265. {
  11266. if(abilityManager && abilityManager.IsInitialized())
  11267. return ((W3PlayerAbilityManager)abilityManager).GetOffenseStat();
  11268.  
  11269. return 0;
  11270. }
  11271.  
  11272. public function GetDefenseStat():int
  11273. {
  11274. if(abilityManager && abilityManager.IsInitialized())
  11275. return ((W3PlayerAbilityManager)abilityManager).GetDefenseStat();
  11276.  
  11277. return 0;
  11278. }
  11279.  
  11280. public function GetSignsStat():float
  11281. {
  11282. if(abilityManager && abilityManager.IsInitialized())
  11283. return ((W3PlayerAbilityManager)abilityManager).GetSignsStat();
  11284.  
  11285. return 0;
  11286. }
  11287.  
  11288.  
  11289.  
  11290.  
  11291.  
  11292. private var inWaterTrigger : bool;
  11293.  
  11294. event OnOceanTriggerEnter()
  11295. {
  11296. inWaterTrigger = true;
  11297. }
  11298.  
  11299. event OnOceanTriggerLeave()
  11300. {
  11301. inWaterTrigger = false;
  11302. }
  11303.  
  11304. public function IsInWaterTrigger() : bool
  11305. {
  11306. return inWaterTrigger;
  11307. }
  11308.  
  11309.  
  11310.  
  11311.  
  11312.  
  11313. public function GetSkillColor(skill : ESkill) : ESkillColor
  11314. {
  11315. if(abilityManager && abilityManager.IsInitialized())
  11316. return ((W3PlayerAbilityManager)abilityManager).GetSkillColor(skill);
  11317.  
  11318. return SC_None;
  11319. }
  11320.  
  11321. public function GetSkillSlotIndexFromSkill(skill : ESkill) : int
  11322. {
  11323. if(abilityManager && abilityManager.IsInitialized())
  11324. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIndexFromSkill(skill);
  11325.  
  11326. return -1;
  11327. }
  11328.  
  11329. public final function GetSkillSlotIndex(slotID : int, checkIfUnlocked : bool) : int
  11330. {
  11331. if(abilityManager && abilityManager.IsInitialized())
  11332. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIndex(slotID, checkIfUnlocked);
  11333.  
  11334. return -1;
  11335. }
  11336.  
  11337. public final function GetSkillSlotIDFromIndex(skillSlotIndex : int) : int
  11338. {
  11339. if(abilityManager && abilityManager.IsInitialized())
  11340. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIDFromIndex(skillSlotIndex);
  11341.  
  11342. return -1;
  11343. }
  11344.  
  11345. public function GetSkillSlotID(skill : ESkill) : int
  11346. {
  11347. if(abilityManager && abilityManager.IsInitialized())
  11348. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotID(skill);
  11349.  
  11350. return -1;
  11351. }
  11352.  
  11353. public function GetSkillGroupBonus(groupID : int) : name
  11354. {
  11355. if(abilityManager && abilityManager.IsInitialized())
  11356. return ((W3PlayerAbilityManager)abilityManager).GetGroupBonus(groupID);
  11357.  
  11358. return '';
  11359. }
  11360.  
  11361. public function GetGroupBonusCount(commonColor : ESkillColor,groupID : int) : int
  11362. {
  11363. if(abilityManager && abilityManager.IsInitialized())
  11364. return ((W3PlayerAbilityManager)abilityManager).GetSkillGroupColorCount(commonColor, groupID);
  11365.  
  11366. return 0;
  11367. }
  11368.  
  11369. public function GetMutagenSlotIDFromGroupID(groupID : int) : int
  11370. {
  11371. if(abilityManager && abilityManager.IsInitialized())
  11372. return ((W3PlayerAbilityManager)abilityManager).GetMutagenSlotIDFromGroupID(groupID);
  11373.  
  11374. return -1;
  11375. }
  11376.  
  11377. public function GetSkillLevel(skill : ESkill) : int
  11378. {
  11379. if(abilityManager && abilityManager.IsInitialized())
  11380. return ((W3PlayerAbilityManager)abilityManager).GetSkillLevel(skill);
  11381.  
  11382. return -1;
  11383. }
  11384.  
  11385. public function GetBoughtSkillLevel(skill : ESkill) : int
  11386. {
  11387. if(abilityManager && abilityManager.IsInitialized())
  11388. return ((W3PlayerAbilityManager)abilityManager).GetBoughtSkillLevel(skill);
  11389.  
  11390. return -1;
  11391. }
  11392.  
  11393. public function AddSkill(skill : ESkill, optional isTemporary : bool)
  11394. {
  11395. if(abilityManager && abilityManager.IsInitialized())
  11396. ((W3PlayerAbilityManager)abilityManager).AddSkill(skill, isTemporary);
  11397. }
  11398.  
  11399. public function AddMultipleSkills(skill : ESkill, optional number : int, optional isTemporary : bool)
  11400. {
  11401. var i : int;
  11402.  
  11403. if(number)
  11404. {
  11405. for( i=0; i<number; i+=1)
  11406. {
  11407. AddSkill(skill,isTemporary);
  11408. }
  11409. }
  11410. else
  11411. {
  11412. AddSkill(skill,isTemporary);
  11413. }
  11414. }
  11415.  
  11416. public function GetSkillAbilityName(skill : ESkill) : name
  11417. {
  11418. if(abilityManager && abilityManager.IsInitialized())
  11419. return ((W3PlayerAbilityManager)abilityManager).GetSkillAbilityName(skill);
  11420.  
  11421. return '';
  11422. }
  11423.  
  11424. public function HasStaminaToUseSkill(skill : ESkill, optional perSec : bool, optional signHack : bool) : bool
  11425. {
  11426. var ret : bool;
  11427. var cost : float;
  11428.  
  11429. cost = GetSkillStaminaUseCost(skill, perSec);
  11430.  
  11431. ret = ( CanUseSkill(skill) && (abilityManager.GetStat(BCS_Stamina, signHack) >= cost) );
  11432.  
  11433.  
  11434. if(!ret && IsSkillSign(skill) && CanUseSkill(S_Perk_09) && GetStat(BCS_Focus) >= 1)
  11435. {
  11436. ret = true;
  11437. }
  11438.  
  11439.  
  11440. if( !ret && IsSkillSign( skill ) && GetWitcherPlayer().HasBuff( EET_GryphonSetBonus ) )
  11441. {
  11442. ret = true;
  11443. }
  11444.  
  11445. if(!ret)
  11446. {
  11447. SetCombatActionHeading( GetHeading() );
  11448. SetShowToLowStaminaIndication(cost);
  11449. }
  11450.  
  11451. return ret;
  11452. }
  11453.  
  11454. protected function GetSkillStaminaUseCost(skill : ESkill, optional perSec : bool) : float
  11455. {
  11456. if(abilityManager && abilityManager.IsInitialized())
  11457. return ((W3PlayerAbilityManager)abilityManager).GetSkillStaminaUseCost(skill, perSec);
  11458.  
  11459. return 0;
  11460. }
  11461.  
  11462.  
  11463. public function GetSkillAttributeValue(skill : ESkill, attributeName : name, addBaseCharAttribute : bool, addSkillModsAttribute : bool) : SAbilityAttributeValue
  11464. {
  11465. var null : SAbilityAttributeValue;
  11466.  
  11467. if(abilityManager && abilityManager.IsInitialized())
  11468. return abilityManager.GetSkillAttributeValue(SkillEnumToName(skill), attributeName, addBaseCharAttribute, addSkillModsAttribute);
  11469.  
  11470. return null;
  11471. }
  11472.  
  11473. public function GetSkillLocalisationKeyName(skill : ESkill) : string
  11474. {
  11475. if(abilityManager && abilityManager.IsInitialized())
  11476. return ((W3PlayerAbilityManager)abilityManager).GetSkillLocalisationKeyName(skill);
  11477.  
  11478. return "";
  11479. }
  11480.  
  11481. public function GetSkillLocalisationKeyDescription(skill : ESkill) : string
  11482. {
  11483. if(abilityManager && abilityManager.IsInitialized())
  11484. return ((W3PlayerAbilityManager)abilityManager).GetSkillLocalisationKeyDescription(skill);
  11485.  
  11486. return "";
  11487. }
  11488.  
  11489. public function GetSkillIconPath(skill : ESkill) : string
  11490. {
  11491. if(abilityManager && abilityManager.IsInitialized())
  11492. return ((W3PlayerAbilityManager)abilityManager).GetSkillIconPath(skill);
  11493.  
  11494. return "";
  11495. }
  11496.  
  11497. public function HasLearnedSkill(skill : ESkill) : bool
  11498. {
  11499. if(abilityManager && abilityManager.IsInitialized())
  11500. return ((W3PlayerAbilityManager)abilityManager).HasLearnedSkill(skill);
  11501.  
  11502. return false;
  11503. }
  11504.  
  11505. public function IsSkillEquipped(skill : ESkill) : bool
  11506. {
  11507. if(abilityManager && abilityManager.IsInitialized())
  11508. return ((W3PlayerAbilityManager)abilityManager).IsSkillEquipped(skill);
  11509.  
  11510. return false;
  11511. }
  11512.  
  11513. public function CanUseSkill(skill : ESkill) : bool
  11514. {
  11515. if(abilityManager && abilityManager.IsInitialized())
  11516. return ((W3PlayerAbilityManager)abilityManager).CanUseSkill(skill);
  11517.  
  11518. return false;
  11519. }
  11520.  
  11521. public function CanLearnSkill(skill : ESkill) : bool
  11522. {
  11523. if(abilityManager && abilityManager.IsInitialized())
  11524. return ((W3PlayerAbilityManager)abilityManager).CanLearnSkill(skill);
  11525.  
  11526. return false;
  11527. }
  11528.  
  11529. public function HasSpentEnoughPoints(skill : ESkill) : bool
  11530. {
  11531. if(abilityManager && abilityManager.IsInitialized())
  11532. return ((W3PlayerAbilityManager)abilityManager).HasSpentEnoughPoints(skill);
  11533.  
  11534. return false;
  11535. }
  11536.  
  11537. public function PathPointsForSkillsPath(skill : ESkill) : int
  11538. {
  11539. if(abilityManager && abilityManager.IsInitialized())
  11540. return ((W3PlayerAbilityManager)abilityManager).PathPointsSpentInSkillPathOfSkill(skill);
  11541.  
  11542. return -1;
  11543. }
  11544.  
  11545. public function GetPlayerSkills() : array<SSkill>
  11546. {
  11547. var null : array<SSkill>;
  11548.  
  11549. if(abilityManager && abilityManager.IsInitialized())
  11550. return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkills();
  11551.  
  11552. return null;
  11553. }
  11554.  
  11555. public function GetPlayerSkill(s : ESkill) : SSkill
  11556. {
  11557. var null : SSkill;
  11558.  
  11559. if(abilityManager && abilityManager.IsInitialized())
  11560. return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkill(s);
  11561.  
  11562. return null;
  11563. }
  11564.  
  11565. public function GetSkillSubPathType(s : ESkill) : ESkillSubPath
  11566. {
  11567. if(abilityManager && abilityManager.IsInitialized())
  11568. return ((W3PlayerAbilityManager)abilityManager).GetSkillSubPathType(s);
  11569.  
  11570. return ESSP_NotSet;
  11571. }
  11572.  
  11573. public function GetSkillSlotsCount() : int
  11574. {
  11575. if(abilityManager && abilityManager.IsInitialized())
  11576. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotsCount();
  11577.  
  11578. return 0;
  11579. }
  11580.  
  11581. public function GetSkillSlots() : array<SSkillSlot>
  11582. {
  11583. var null : array<SSkillSlot>;
  11584.  
  11585. if(abilityManager && abilityManager.IsInitialized())
  11586. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlots();
  11587.  
  11588. return null;
  11589. }
  11590.  
  11591. public function GetPlayerSkillMutagens() : array<SMutagenSlot>
  11592. {
  11593. var null : array<SMutagenSlot>;
  11594.  
  11595. if(abilityManager && abilityManager.IsInitialized())
  11596. return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkillMutagens();
  11597.  
  11598. return null;
  11599. }
  11600.  
  11601.  
  11602.  
  11603.  
  11604. public function BlockSkill(skill : ESkill, block : bool, optional cooldown : float) : bool
  11605. {
  11606. if(abilityManager && abilityManager.IsInitialized())
  11607. return ((W3PlayerAbilityManager)abilityManager).BlockSkill(skill, block, cooldown);
  11608.  
  11609. return false;
  11610. }
  11611.  
  11612. public function IsSkillBlocked(skill : ESkill) : bool
  11613. {
  11614. if(abilityManager && abilityManager.IsInitialized())
  11615. return ((W3PlayerAbilityManager)abilityManager).IsSkillBlocked(skill);
  11616.  
  11617. return false;
  11618. }
  11619.  
  11620.  
  11621. public function EquipSkill(skill : ESkill, slotID : int) : bool
  11622. {
  11623. var ret : bool;
  11624. var groupID : int;
  11625. var pam : W3PlayerAbilityManager;
  11626.  
  11627. if(abilityManager && abilityManager.IsInitialized())
  11628. {
  11629. pam = (W3PlayerAbilityManager)abilityManager;
  11630. ret = pam.EquipSkill(skill, slotID);
  11631. if(ret)
  11632. {
  11633. groupID = pam.GetSkillGroupIdFromSkillSlotId(slotID);
  11634. LogSkillColors("Equipped <<" + GetSkillColor(skill) + ">> skill <<" + skill + ">> to group <<" + groupID + ">>");
  11635. LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
  11636. LogSkillColors("");
  11637. }
  11638.  
  11639. return ret;
  11640. }
  11641.  
  11642. return false;
  11643. }
  11644.  
  11645.  
  11646. public function UnequipSkill(slotID : int) : bool
  11647. {
  11648. var ret : bool;
  11649. var groupID : int;
  11650. var skill : ESkill;
  11651. var pam : W3PlayerAbilityManager;
  11652.  
  11653. if(abilityManager && abilityManager.IsInitialized())
  11654. {
  11655. pam = (W3PlayerAbilityManager)abilityManager;
  11656. GetSkillOnSlot(slotID, skill);
  11657. ret = pam.UnequipSkill(slotID);
  11658. if(ret)
  11659. {
  11660. groupID = pam.GetSkillGroupIdFromSkillSlotId(slotID);
  11661. LogSkillColors("Unequipped <<" + GetSkillColor(skill) + ">> skill <<" + skill + ">> from group <<" + groupID + ">>");
  11662. LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
  11663. LogSkillColors("");
  11664. }
  11665. return ret;
  11666. }
  11667.  
  11668. return false;
  11669. }
  11670.  
  11671.  
  11672. public function GetSkillOnSlot(slotID : int, out skill : ESkill) : bool
  11673. {
  11674. if(abilityManager && abilityManager.IsInitialized())
  11675. return ((W3PlayerAbilityManager)abilityManager).GetSkillOnSlot(slotID, skill);
  11676.  
  11677. skill = S_SUndefined;
  11678. return false;
  11679. }
  11680.  
  11681.  
  11682. public function GetFreeSkillSlot() : int
  11683. {
  11684. var i, size : int;
  11685. var skill : ESkill;
  11686.  
  11687. size = ((W3PlayerAbilityManager)abilityManager).GetSkillSlotsCount();
  11688. for(i=1; i<size; i+=1)
  11689. {
  11690. if(!GetSkillOnSlot(i, skill))
  11691. continue;
  11692.  
  11693. if(skill == S_SUndefined)
  11694. return i;
  11695. }
  11696.  
  11697. return -1;
  11698. }
  11699.  
  11700.  
  11701.  
  11702.  
  11703.  
  11704.  
  11705. protected function Attack( hitTarget : CGameplayEntity, animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float, weaponEntity : CItemEntity)
  11706. {
  11707. var attackAction : W3Action_Attack;
  11708.  
  11709. if(!PrepareAttackAction(hitTarget, animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime, weaponEntity, attackAction))
  11710. return;
  11711.  
  11712. if ( attackAction.IsParried() && ( ((CNewNPC)attackAction.victim).IsShielded(attackAction.attacker) || ((CNewNPC)attackAction.victim).SignalGameplayEventReturnInt('IsDefending',0) == 1 ) )
  11713. {
  11714. thePlayer.SetCanPlayHitAnim(true);
  11715. thePlayer.ReactToReflectedAttack(attackAction.victim);
  11716. }
  11717.  
  11718. theTelemetry.LogWithLabel( TE_FIGHT_PLAYER_ATTACKS, attackAction.GetAttackName() );
  11719.  
  11720.  
  11721. theGame.damageMgr.ProcessAction(attackAction);
  11722.  
  11723. delete attackAction;
  11724. }
  11725.  
  11726. public function IsHeavyAttack(attackName : name) : bool
  11727. {
  11728. var skill : ESkill;
  11729. var sup : bool;
  11730.  
  11731. sup = super.IsHeavyAttack(attackName);
  11732. if(sup)
  11733. return true;
  11734.  
  11735. if ( attackName == 'attack_heavy_special' )
  11736. return true;
  11737.  
  11738. skill = SkillNameToEnum(attackName);
  11739.  
  11740. return skill == S_Sword_2 || skill == S_Sword_s02;
  11741. }
  11742.  
  11743. public function IsLightAttack(attackName : name) : bool
  11744. {
  11745. var skill : ESkill;
  11746. var sup : bool;
  11747.  
  11748. sup = super.IsLightAttack(attackName);
  11749. if(sup)
  11750. return true;
  11751.  
  11752. skill = SkillNameToEnum(attackName);
  11753.  
  11754. return skill == S_Sword_1 || skill == S_Sword_s01;
  11755. }
  11756.  
  11757. public final function ProcessWeaponCollision()
  11758. {
  11759. var l_stateName : name;
  11760.  
  11761. var l_weaponPosition : Vector;
  11762. var l_weaponTipPos : Vector;
  11763. var l_collidingPosition : Vector;
  11764. var l_offset : Vector;
  11765. var l_normal : Vector;
  11766.  
  11767. var l_slotMatrix : Matrix;
  11768.  
  11769. var l_distance : float;
  11770.  
  11771. var l_materialName : name;
  11772. var l_hitComponent : CComponent;
  11773. var l_destructibleCmp : CDestructionSystemComponent;
  11774. var barrel : COilBarrelEntity;
  11775.  
  11776.  
  11777.  
  11778. if( isCurrentlyDodging )
  11779. return;
  11780.  
  11781. l_stateName = GetCurrentStateName();
  11782.  
  11783. if( !attackEventInProgress && l_stateName == 'CombatFists' )
  11784. return;
  11785.  
  11786. CalcEntitySlotMatrix('r_weapon', l_slotMatrix);
  11787.  
  11788. l_weaponPosition = MatrixGetTranslation( l_slotMatrix );
  11789.  
  11790.  
  11791. switch( l_stateName )
  11792. {
  11793. case 'CombatFists':
  11794. l_offset = MatrixGetAxisX( l_slotMatrix );
  11795. l_offset = VecNormalize( l_offset ) * 0.25f;
  11796. break;
  11797.  
  11798. default:
  11799. l_offset = MatrixGetAxisZ( l_slotMatrix );
  11800. l_offset = VecNormalize( l_offset ) * 1.f;
  11801. break;
  11802. }
  11803.  
  11804. l_weaponTipPos = l_weaponPosition + l_offset;
  11805.  
  11806.  
  11807.  
  11808. if( !attackEventInProgress )
  11809. {
  11810.  
  11811. if( m_LastWeaponTipPos == Vector ( 0, 0, 0 ) )
  11812. l_distance = 0;
  11813. else
  11814. l_distance = VecDistance( l_weaponTipPos, m_LastWeaponTipPos ) ;
  11815.  
  11816.  
  11817.  
  11818.  
  11819. m_LastWeaponTipPos = l_weaponTipPos;
  11820. if( l_distance < 0.35f )
  11821. return;
  11822.  
  11823. }
  11824.  
  11825.  
  11826.  
  11827. m_LastWeaponTipPos = l_weaponTipPos;
  11828.  
  11829. if ( !theGame.GetWorld().StaticTraceWithAdditionalInfo( l_weaponPosition, l_weaponTipPos, l_collidingPosition, l_normal, l_materialName, l_hitComponent, m_WeaponFXCollisionGroupNames ) )
  11830. {
  11831.  
  11832. if( l_stateName == 'CombatFists' )
  11833. {
  11834. CalcEntitySlotMatrix('l_weapon', l_slotMatrix);
  11835. l_weaponPosition = MatrixGetTranslation( l_slotMatrix );
  11836. l_offset = MatrixGetAxisX( l_slotMatrix );
  11837. l_offset = VecNormalize( l_offset ) * 0.25f;
  11838. l_weaponTipPos = l_weaponPosition + l_offset;
  11839. if( !theGame.GetWorld().StaticTrace( l_weaponPosition, l_weaponTipPos, l_collidingPosition, l_normal, m_WeaponFXCollisionGroupNames ) )
  11840. {
  11841. return;
  11842. }
  11843. }
  11844. else
  11845. {
  11846. return;
  11847. }
  11848. }
  11849.  
  11850. if( !m_CollisionEffect )
  11851. {
  11852. m_CollisionEffect = theGame.CreateEntity( m_CollisionFxTemplate, l_collidingPosition, EulerAngles(0,0,0) );
  11853. }
  11854.  
  11855. m_CollisionEffect.Teleport( l_collidingPosition );
  11856.  
  11857.  
  11858. switch( l_stateName )
  11859. {
  11860. case 'CombatFists':
  11861. m_CollisionEffect.PlayEffect('fist');
  11862. break;
  11863. default:
  11864.  
  11865. if( m_RefreshWeaponFXType )
  11866. {
  11867. m_PlayWoodenFX = IsSwordWooden();
  11868. m_RefreshWeaponFXType = false;
  11869. }
  11870.  
  11871. if( m_PlayWoodenFX )
  11872. {
  11873. m_CollisionEffect.PlayEffect('wood');
  11874. }
  11875. else
  11876. {
  11877. switch( l_materialName )
  11878. {
  11879. case 'wood_hollow':
  11880. case 'wood_debris':
  11881. case 'wood_solid':
  11882. m_CollisionEffect.PlayEffect('wood');
  11883. break;
  11884. case 'dirt_hard':
  11885. case 'dirt_soil':
  11886. case 'hay':
  11887. m_CollisionEffect.PlayEffect('fist');
  11888. break;
  11889. case 'stone_debris':
  11890. case 'stone_solid':
  11891. case 'clay_tile':
  11892. case 'gravel_large':
  11893. case 'gravel_small':
  11894. case 'metal':
  11895. case 'custom_sword':
  11896. m_CollisionEffect.PlayEffect('sparks');
  11897. break;
  11898. case 'flesh':
  11899. m_CollisionEffect.PlayEffect('blood');
  11900. break;
  11901. default:
  11902. m_CollisionEffect.PlayEffect('wood');
  11903. break;
  11904. }
  11905.  
  11906. }
  11907. break;
  11908. }
  11909.  
  11910.  
  11911. if(l_hitComponent)
  11912. {
  11913. barrel = (COilBarrelEntity)l_hitComponent.GetEntity();
  11914. if(barrel)
  11915. {
  11916. barrel.OnFireHit(NULL);
  11917. return;
  11918. }
  11919. }
  11920.  
  11921.  
  11922. l_destructibleCmp = (CDestructionSystemComponent) l_hitComponent;
  11923. if( l_destructibleCmp && l_stateName != 'CombatFists' )
  11924. {
  11925. l_destructibleCmp.ApplyFracture();
  11926. }
  11927.  
  11928.  
  11929.  
  11930. }
  11931.  
  11932. public function ReactToReflectedAttack( target : CGameplayEntity)
  11933. {
  11934.  
  11935. var hp, dmg : float;
  11936. var action : W3DamageAction;
  11937.  
  11938. super.ReactToReflectedAttack(target);
  11939.  
  11940.  
  11941. theGame.VibrateControllerLight();
  11942. }
  11943.  
  11944.  
  11945.  
  11946.  
  11947.  
  11948.  
  11949. function GetFallDist( out fallDist : float ) : bool
  11950. {
  11951. var fallDiff, jumpTotalDiff : float;
  11952.  
  11953.  
  11954. substateManager.m_SharedDataO.CalculateFallingHeights( fallDiff, jumpTotalDiff );
  11955.  
  11956. if ( fallDiff <= 0 )
  11957. return false;
  11958.  
  11959. fallDist = fallDiff;
  11960. return true;
  11961. }
  11962.  
  11963. function ApplyFallingDamage(heightDiff : float, optional reducing : bool) : float
  11964. {
  11965. var hpPerc : float;
  11966. var tut : STutorialMessage;
  11967.  
  11968. if ( IsSwimming() || FactsQuerySum("block_falling_damage") >= 1 )
  11969. return 0.0f;
  11970.  
  11971. hpPerc = super.ApplyFallingDamage( heightDiff, reducing );
  11972.  
  11973. if(hpPerc > 0)
  11974. {
  11975. theGame.VibrateControllerHard();
  11976.  
  11977. if(IsAlive())
  11978. {
  11979. if(ShouldProcessTutorial('TutorialFallingDamage'))
  11980. {
  11981. FactsSet( "tutorial_falling_damage", 1 );
  11982. }
  11983.  
  11984. if(FactsQuerySum("tutorial_falling_damage") > 1 && ShouldProcessTutorial('TutorialFallingRoll'))
  11985. {
  11986.  
  11987. tut.type = ETMT_Hint;
  11988. tut.tutorialScriptTag = 'TutorialFallingRoll';
  11989. tut.hintPositionType = ETHPT_DefaultGlobal;
  11990. tut.hintDurationType = ETHDT_Long;
  11991. tut.canBeShownInMenus = false;
  11992. tut.glossaryLink = false;
  11993. tut.markAsSeenOnShow = true;
  11994.  
  11995.  
  11996. theGame.GetTutorialSystem().DisplayTutorial(tut);
  11997. }
  11998. }
  11999. }
  12000.  
  12001. return hpPerc;
  12002. }
  12003.  
  12004.  
  12005.  
  12006. public function SetShowToLowStaminaIndication( value : float ) : void
  12007. {
  12008. fShowToLowStaminaIndication = value;
  12009. }
  12010.  
  12011. public function GetShowToLowStaminaIndication() : float
  12012. {
  12013. return fShowToLowStaminaIndication;
  12014. }
  12015.  
  12016. public final function IndicateTooLowAdrenaline()
  12017. {
  12018. SoundEvent("gui_no_adrenaline");
  12019. showTooLowAdrenaline = true;
  12020. }
  12021.  
  12022.  
  12023.  
  12024. protected function GotoCombatStateWithAction( initialAction : EInitialAction, optional initialBuff : CBaseGameplayEffect )
  12025. {
  12026. if ( this.GetCurrentActionType() == ActorAction_Exploration )
  12027. ActionCancelAll();
  12028.  
  12029. ((W3PlayerWitcherStateCombatFists)this.GetState('CombatFists')).SetupState( initialAction, initialBuff );
  12030. this.GotoState( 'CombatFists' );
  12031.  
  12032. }
  12033.  
  12034.  
  12035. public function IsThreat( actor : CActor, optional usePrecalcs : bool ) : bool
  12036. {
  12037. var npc : CNewNPC;
  12038. var dist : float;
  12039. var targetCapsuleHeight : float;
  12040. var isDistanceExpanded : bool;
  12041. var distanceToTarget : float;
  12042. var attitude : EAIAttitude;
  12043.  
  12044. if (!actor)
  12045. {
  12046. return false;
  12047. }
  12048.  
  12049. if ( finishableEnemiesList.Contains( actor ) )
  12050. {
  12051. return true;
  12052. }
  12053.  
  12054. if ( !actor.IsAlive() || actor.IsKnockedUnconscious() )
  12055. {
  12056. return false;
  12057. }
  12058.  
  12059. npc = (CNewNPC)actor;
  12060. if (npc && npc.IsHorse() )
  12061. {
  12062. return false;
  12063. }
  12064.  
  12065. if ( hostileEnemies.Contains( actor ) )
  12066. {
  12067. return true;
  12068. }
  12069.  
  12070.  
  12071. if ( GetAttitudeBetween( this, actor ) == AIA_Hostile )
  12072. {
  12073. if ( usePrecalcs )
  12074. {
  12075. distanceToTarget = Distance2DBetweenCapsuleAndPoint( actor, this ) - targetingPrecalcs.playerRadius;
  12076. }
  12077. else
  12078. {
  12079. distanceToTarget = Distance2DBetweenCapsules( this, actor );
  12080. }
  12081.  
  12082.  
  12083. if ( distanceToTarget < findMoveTargetDist + 5.0f )
  12084. {
  12085. return true;
  12086. }
  12087.  
  12088. if ( actor.IsInCombat() || this.IsHardLockEnabled() )
  12089. {
  12090. targetCapsuleHeight = ( (CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent() ).GetCapsuleHeight();
  12091. if ( targetCapsuleHeight >= 2.0f || npc.GetCurrentStance() == NS_Fly )
  12092. {
  12093.  
  12094. if ( distanceToTarget < 40.0f )
  12095. {
  12096. return true;
  12097. }
  12098. }
  12099. }
  12100. }
  12101.  
  12102. if ( actor.GetAttitudeGroup() == 'npc_charmed' )
  12103. {
  12104. if ( theGame.GetGlobalAttitude( GetBaseAttitudeGroup(), actor.GetBaseAttitudeGroup() ) == AIA_Hostile )
  12105. {
  12106. return true;
  12107. }
  12108. }
  12109.  
  12110. return false;
  12111. }
  12112.  
  12113. function SetBIsCombatActionAllowed ( flag : bool )
  12114. {
  12115. bIsCombatActionAllowed = flag;
  12116.  
  12117. if ( !flag )
  12118. {
  12119. SetBIsInCombatAction(true);
  12120. }
  12121. else
  12122. {
  12123. this.ProcessLAxisCaching();
  12124.  
  12125. }
  12126.  
  12127.  
  12128. }
  12129.  
  12130. function GetBIsCombatActionAllowed() : bool
  12131. {
  12132. return bIsCombatActionAllowed;
  12133. }
  12134.  
  12135. function SetCombatAction( action : EBufferActionType )
  12136. {
  12137. currentCombatAction = action;
  12138. }
  12139.  
  12140. function GetCombatAction() : EBufferActionType
  12141. {
  12142. return currentCombatAction;
  12143. }
  12144.  
  12145. protected function WhenCombatActionIsFinished()
  12146. {
  12147. if(IsThrowingItem() || IsThrowingItemWithAim() )
  12148. {
  12149. if(inv.IsItemBomb(selectedItemId))
  12150. {
  12151. BombThrowAbort();
  12152. }
  12153. else
  12154. {
  12155. ThrowingAbort();
  12156. }
  12157. }
  12158.  
  12159. if ( this.GetCurrentStateName() != 'DismountHorse' )
  12160. OnRangedForceHolster( true );
  12161.  
  12162.  
  12163. }
  12164.  
  12165. public function IsInCombatAction_Attack(): bool
  12166. {
  12167. if ( IsInCombatAction_NonSpecialAttack() || IsInCombatAction_SpecialAttack() )
  12168. return true;
  12169. else
  12170. return false;
  12171. }
  12172.  
  12173. public function IsInCombatAction_NonSpecialAttack(): bool
  12174. {
  12175. if ( IsInCombatAction() && ( GetCombatAction() == EBAT_LightAttack || GetCombatAction() == EBAT_HeavyAttack ) )
  12176. return true;
  12177. else
  12178. return false;
  12179. }
  12180.  
  12181. public function IsInSpecificCombatAction ( specificCombatAction : EBufferActionType ) : bool
  12182. {
  12183. if ( IsInCombatAction() && GetCombatAction() == specificCombatAction )
  12184. return true;
  12185. else
  12186. return false;
  12187. }
  12188.  
  12189. public function IsInRunAnimation() : bool
  12190. {
  12191. return isInRunAnimation;
  12192. }
  12193.  
  12194.  
  12195. public function SetCombatIdleStance( stance : float )
  12196. {
  12197. SetBehaviorVariable( 'combatIdleStance', stance );
  12198. SetBehaviorVariable( 'CombatStanceForOverlay', stance );
  12199.  
  12200. if ( stance == 0.f )
  12201. LogChannel( 'ComboInput', "combatIdleStance = Left" );
  12202. else
  12203. LogChannel( 'ComboInput', "combatIdleStance = Right" );
  12204. }
  12205.  
  12206. public function GetCombatIdleStance() : float
  12207. {
  12208.  
  12209. return GetBehaviorVariable( 'combatIdleStance' );
  12210. }
  12211.  
  12212. protected var isRotatingInPlace : bool;
  12213. event OnRotateInPlaceStart()
  12214. {
  12215. isRotatingInPlace = true;
  12216. }
  12217.  
  12218. event OnRotateInPlaceEnd()
  12219. {
  12220. isRotatingInPlace = false;
  12221. }
  12222.  
  12223. event OnFullyBlendedIdle()
  12224. {
  12225. if ( bLAxisReleased )
  12226. {
  12227. ResetRawPlayerHeading();
  12228. ResetCachedRawPlayerHeading();
  12229. defaultLocomotionController.ResetMoveDirection();
  12230. }
  12231. }
  12232.  
  12233. private var isInIdle : bool;
  12234.  
  12235. event OnPlayerIdleStart()
  12236. {
  12237. isInIdle = true;
  12238. }
  12239.  
  12240. event OnPlayerIdleEnd()
  12241. {
  12242. isInIdle = false;
  12243. }
  12244.  
  12245. public function IsInIdle() : bool
  12246. {
  12247. return isInIdle;
  12248. }
  12249.  
  12250. event OnRunLoopStart()
  12251. {
  12252. EnableRunCamera( true );
  12253. }
  12254.  
  12255. event OnRunLoopEnd()
  12256. {
  12257. EnableRunCamera( false );
  12258. }
  12259.  
  12260. event OnCombatActionStartBehgraph()
  12261. {
  12262. var action : EBufferActionType;
  12263. var cost, delay : float;
  12264.  
  12265.  
  12266.  
  12267.  
  12268. OnCombatActionStart();
  12269.  
  12270. action = PerformingCombatAction();
  12271. switch ( action )
  12272. {
  12273. case EBAT_LightAttack :
  12274. {
  12275. abilityManager.GetStaminaActionCost(ESAT_LightAttack, cost, delay);
  12276. } break;
  12277. case EBAT_HeavyAttack :
  12278. {
  12279. abilityManager.GetStaminaActionCost(ESAT_HeavyAttack, cost, delay);
  12280. } break;
  12281. case EBAT_ItemUse :
  12282. {
  12283. abilityManager.GetStaminaActionCost(ESAT_UsableItem, cost, delay);
  12284. } break;
  12285. case EBAT_Parry :
  12286. {
  12287. abilityManager.GetStaminaActionCost(ESAT_Parry, cost, delay);
  12288. } break;
  12289. case EBAT_Dodge :
  12290. {
  12291. abilityManager.GetStaminaActionCost(ESAT_Dodge, cost, delay);
  12292. } break;
  12293. case EBAT_Roll :
  12294. abilityManager.GetStaminaActionCost(ESAT_Roll, cost, delay);
  12295. break;
  12296. case EBAT_SpecialAttack_Light :
  12297. {
  12298. abilityManager.GetStaminaActionCost(ESAT_Ability, cost, delay, 0,0, GetSkillAbilityName(S_Sword_s01));
  12299. } break;
  12300. case EBAT_SpecialAttack_Heavy :
  12301. {
  12302. abilityManager.GetStaminaActionCost(ESAT_Ability, cost, delay, 0,0, GetSkillAbilityName(S_Sword_s02));
  12303. } break;
  12304. case EBAT_Roll :
  12305. {
  12306. abilityManager.GetStaminaActionCost(ESAT_Evade, cost, delay);
  12307. } break;
  12308.  
  12309. default :
  12310. ;
  12311. }
  12312.  
  12313.  
  12314.  
  12315. if( delay > 0 )
  12316. PauseStaminaRegen( 'InsideCombatAction' );
  12317. }
  12318.  
  12319. public function HolsterUsableItem() : bool
  12320. {
  12321. return holsterUsableItem;
  12322. }
  12323.  
  12324. private var isInGuardedState : bool;
  12325. public function IsInGuardedState() : bool
  12326. {
  12327. return isInGuardedState;
  12328. }
  12329.  
  12330. event OnGuardedStart()
  12331. {
  12332. isInParryOrCounter = true;
  12333. isInGuardedState = true;
  12334. }
  12335.  
  12336. event OnGuardedEnd()
  12337. {
  12338. isInParryOrCounter = false;
  12339. isInGuardedState = false;
  12340. }
  12341.  
  12342. private var restoreUsableItem : bool;
  12343. private var holsterUsableItem : bool;
  12344. event OnCombatActionStart()
  12345. {
  12346.  
  12347.  
  12348. BlockAction( EIAB_UsableItem, 'OnCombatActionStart' );
  12349. BlockAction( EIAB_CallHorse, 'OnCombatActionStart' );
  12350.  
  12351.  
  12352.  
  12353. LogChannel('combatActionAllowed',"FALSE OnCombatActionStart");
  12354. SetBIsCombatActionAllowed( false );
  12355. SetBIsInputAllowed( false, 'OnCombatActionStart' );
  12356.  
  12357.  
  12358. ClearFinishableEnemyList( 0.f, 0 );
  12359.  
  12360. bIsInHitAnim = false;
  12361.  
  12362.  
  12363.  
  12364. if ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  12365. {
  12366. CleanCombatActionBuffer();
  12367. SetIsAimingCrossbow( false );
  12368. OnRangedForceHolster( false, true );
  12369. }
  12370.  
  12371.  
  12372. holsterUsableItem = false;
  12373. if ( thePlayer.IsHoldingItemInLHand() )
  12374. {
  12375. if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign )
  12376. holsterUsableItem = true;
  12377. else if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
  12378. {
  12379. if ( this.GetCurrentStateName() == 'CombatFists' )
  12380. holsterUsableItem = true;
  12381. }
  12382. }
  12383.  
  12384. if ( holsterUsableItem )
  12385. {
  12386. thePlayer.SetPlayerActionToRestore ( PATR_None );
  12387. thePlayer.OnUseSelectedItem( true );
  12388.  
  12389. restoreUsableItem = true;
  12390. }
  12391.  
  12392.  
  12393. if ( GetBehaviorVariable( 'combatActionType' ) != (int)CAT_Attack && GetBehaviorVariable( 'combatActionType' ) != (int)CAT_PreAttack )
  12394. {
  12395. RemoveTimer( 'ProcessAttackTimer' );
  12396. RemoveTimer( 'AttackTimerEnd' );
  12397. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  12398. }
  12399. else
  12400. {
  12401.  
  12402. BlockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  12403. }
  12404.  
  12405.  
  12406. }
  12407.  
  12408. var isInParryOrCounter : bool;
  12409. event OnParryOrCounterStart()
  12410. {
  12411. isInParryOrCounter = true;
  12412. OnCombatActionStartBehgraph();
  12413. }
  12414.  
  12415. event OnParryOrCounterEnd()
  12416. {
  12417. isInParryOrCounter = false;
  12418. OnCombatActionEnd();
  12419. SetBIsInCombatAction( false );
  12420. }
  12421.  
  12422.  
  12423. event OnCombatActionEnd()
  12424. {
  12425. var item : SItemUniqueId;
  12426. var combatActionType : float;
  12427.  
  12428. super.OnCombatActionEnd();
  12429.  
  12430.  
  12431.  
  12432. BlockAllActions( 'OnCombatActionStart', false );
  12433.  
  12434. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  12435.  
  12436.  
  12437. UnblockAction( EIAB_Movement, 'CombatActionFriendly' );
  12438.  
  12439.  
  12440.  
  12441.  
  12442. oTCameraOffset = 0.f;
  12443. oTCameraPitchOffset = 0.f;
  12444.  
  12445.  
  12446. SetBIsCombatActionAllowed( true );
  12447.  
  12448.  
  12449. SetBIsInputAllowed( true, 'OnCombatActionEnd' );
  12450. SetCanPlayHitAnim( true );
  12451. EnableFindTarget( true );
  12452.  
  12453.  
  12454.  
  12455.  
  12456. SetFinisherVictim( NULL );
  12457.  
  12458. OnBlockAllCombatTickets( false );
  12459.  
  12460. LogStamina("CombatActionEnd");
  12461.  
  12462.  
  12463.  
  12464. SetAttackActionName('');
  12465. combatActionType = GetBehaviorVariable('combatActionType');
  12466.  
  12467.  
  12468. if(GetBehaviorVariable('combatActionType') == (int)CAT_SpecialAttack)
  12469. {
  12470. theGame.GetGameCamera().StopAnimation( 'camera_shake_loop_lvl1_1' );
  12471. OnSpecialAttackHeavyActionProcess();
  12472. }
  12473.  
  12474. substateManager.ReactToChanceToFallAndSlide();
  12475. }
  12476.  
  12477. event OnCombatActionFriendlyStart()
  12478. {
  12479. SetBIsInCombatActionFriendly(true);
  12480. BlockAction( EIAB_Movement, 'CombatActionFriendly', false, false, false );
  12481. OnCombatActionStart();
  12482. }
  12483.  
  12484. event OnCombatActionFriendlyEnd()
  12485. {
  12486. SetBIsInCombatActionFriendly(false);
  12487. UnblockAction( EIAB_Movement, 'CombatActionFriendly' );
  12488. OnCombatActionEnd();
  12489. SetBIsInCombatAction(false);
  12490.  
  12491. }
  12492.  
  12493. event OnHitStart()
  12494. {
  12495. var timeLeft : float;
  12496. var currentEffects : array<CBaseGameplayEffect>;
  12497. var none : SAbilityAttributeValue;
  12498.  
  12499. CancelHoldAttacks();
  12500. WhenCombatActionIsFinished();
  12501. if ( isInFinisher )
  12502. {
  12503. if ( finisherTarget )
  12504. ( (CNewNPC)finisherTarget ).SignalGameplayEvent( 'FinisherInterrupt' );
  12505. isInFinisher = false;
  12506. finisherTarget = NULL;
  12507. SetBIsCombatActionAllowed( true );
  12508. }
  12509.  
  12510. bIsInHitAnim = true;
  12511.  
  12512. OnCombatActionStart();
  12513.  
  12514.  
  12515. ResumeStaminaRegen( 'InsideCombatAction' );
  12516.  
  12517. if( GetHealthPercents() < 0.3f )
  12518. {
  12519. PlayBattleCry('BattleCryBadSituation', 0.10f, true );
  12520. }
  12521. else
  12522. {
  12523. PlayBattleCry('BattleCryBadSituation', 0.05f, true );
  12524. }
  12525. }
  12526.  
  12527. event OnHitStartSwimming()
  12528. {
  12529. OnRangedForceHolster( true, true, false );
  12530. }
  12531.  
  12532. private var finisherSaveLock : int;
  12533. event OnFinisherStart()
  12534. {
  12535. var currentEffects : array<CBaseGameplayEffect>;
  12536.  
  12537. theGame.CreateNoSaveLock("Finisher",finisherSaveLock,true,false);
  12538.  
  12539. isInFinisher = true;
  12540.  
  12541. finisherTarget = slideTarget;
  12542. OnCombatActionStart();
  12543.  
  12544. CancelHoldAttacks();
  12545.  
  12546. PlayFinisherCameraAnimation( theGame.GetSyncAnimManager().GetFinisherCameraAnimName() );
  12547. this.AddAnimEventCallback('SyncEvent','OnFinisherAnimEvent_SyncEvent');
  12548. SetImmortalityMode( AIM_Invulnerable, AIC_SyncedAnim );
  12549. }
  12550.  
  12551. public function IsPerformingFinisher() : bool
  12552. {
  12553. return isInFinisher;
  12554. }
  12555.  
  12556. private function PlayFinisherCameraAnimation( cameraAnimName : name )
  12557. {
  12558. var camera : CCustomCamera = theGame.GetGameCamera();
  12559. var animation : SCameraAnimationDefinition;
  12560.  
  12561. if( IsLastEnemyKilled() && theGame.GetWorld().NavigationCircleTest( this.GetWorldPosition(), 3.f ) )
  12562. {
  12563. camera.StopAnimation('camera_shake_hit_lvl3_1' );
  12564.  
  12565. animation.animation = cameraAnimName;
  12566. animation.priority = CAP_Highest;
  12567. animation.blendIn = 0.15f;
  12568. animation.blendOut = 1.0f;
  12569. animation.weight = 1.f;
  12570. animation.speed = 1.0f;
  12571. animation.reset = true;
  12572.  
  12573. camera.PlayAnimation( animation );
  12574.  
  12575.  
  12576. thePlayer.EnableManualCameraControl( false, 'Finisher' );
  12577. }
  12578. }
  12579.  
  12580. public function IsLastEnemyKilled() : bool
  12581. {
  12582. var tempMoveTargets : array<CActor>;
  12583.  
  12584. FindMoveTarget();
  12585. tempMoveTargets = GetMoveTargets();
  12586. if ( tempMoveTargets.Size() <= 0 || !thePlayer.IsThreat( tempMoveTargets[0] ) )
  12587. return true;
  12588.  
  12589. return false;
  12590. }
  12591.  
  12592. event OnFinisherAnimEvent_SyncEvent( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  12593. {
  12594. if ( finisherTarget )
  12595. ( (CNewNPC)finisherTarget ).SignalGameplayEvent('FinisherKill');
  12596. finisherTarget = NULL;
  12597. }
  12598.  
  12599. event OnFinisherEnd()
  12600. {
  12601. isInFinisher = false;
  12602. finisherTarget = NULL;
  12603.  
  12604. theGame.ReleaseNoSaveLock(finisherSaveLock);
  12605.  
  12606. this.RemoveAnimEventCallback('SyncEvent');
  12607.  
  12608.  
  12609. SetImmortalityMode( AIM_None, AIC_SyncedAnim );
  12610. theGame.RemoveTimeScale( 'AnimEventSlomoMo' );
  12611. AddTimer( 'FinisherEndEnableCamera', 0.5f );
  12612.  
  12613. OnCombatActionEnd();
  12614. OnCombatActionEndComplete();
  12615. }
  12616.  
  12617. private timer function FinisherEndEnableCamera( dt : float, id : int )
  12618. {
  12619. thePlayer.EnableManualCameraControl( true, 'Finisher' );
  12620. }
  12621.  
  12622. public function SpawnFinisherBlood()
  12623. {
  12624. var weaponEntity : CEntity;
  12625. var weaponSlotMatrix : Matrix;
  12626. var bloodFxPos : Vector;
  12627. var bloodFxRot : EulerAngles;
  12628. var tempEntity : CEntity;
  12629.  
  12630. weaponEntity = this.GetInventory().GetItemEntityUnsafe( GetInventory().GetItemFromSlot('r_weapon') );
  12631. weaponEntity.CalcEntitySlotMatrix( 'blood_fx_point', weaponSlotMatrix );
  12632. bloodFxPos = MatrixGetTranslation( weaponSlotMatrix );
  12633. bloodFxRot = this.GetWorldRotation();
  12634. tempEntity = theGame.CreateEntity( (CEntityTemplate)LoadResource('finisher_blood'), bloodFxPos, bloodFxRot);
  12635. tempEntity.PlayEffect('crawl_blood');
  12636. }
  12637.  
  12638.  
  12639. event OnCombatActionEndComplete()
  12640. {
  12641. var buff : CBaseGameplayEffect;
  12642.  
  12643. buff = ChooseCurrentCriticalBuffForAnim();
  12644. SetCombatAction( EBAT_EMPTY );
  12645.  
  12646.  
  12647. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart' );
  12648. UnblockAction( EIAB_OpenInventory, 'OnCombatActionStart' );
  12649. UnblockAction( EIAB_UsableItem, 'OnCombatActionStart' );
  12650.  
  12651. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  12652.  
  12653. SetUnpushableTarget( NULL );
  12654. SetBIsInCombatAction(false);
  12655. SetIsCurrentlyDodging(false);
  12656. SetMoveTargetChangeAllowed( true );
  12657. SetCanPlayHitAnim( true );
  12658.  
  12659. SetFinisherVictim( NULL );
  12660.  
  12661. this.RemoveBuffImmunity(EET_Burning, 'AnimEvent_RemoveBurning');
  12662.  
  12663. if ( rangedWeapon && rangedWeapon.GetCurrentStateName() == 'State_WeaponWait' && !buff )
  12664. {
  12665. ClearCustomOrientationInfoStack();
  12666. SetSlideTarget( NULL );
  12667. }
  12668.  
  12669. UnblockAction( EIAB_Crossbow, 'OnForceHolster' );
  12670.  
  12671. specialAttackCamera = false;
  12672.  
  12673. bIsRollAllowed = false;
  12674.  
  12675. if ( bLAxisReleased )
  12676. {
  12677. ResetRawPlayerHeading();
  12678. ResetCachedRawPlayerHeading();
  12679. }
  12680.  
  12681.  
  12682. ReapplyCriticalBuff();
  12683. SetBIsInputAllowed( true, 'OnCombatActionEndComplete' );
  12684.  
  12685.  
  12686. ResumeStaminaRegen( 'InsideCombatAction' );
  12687.  
  12688. bIsInHitAnim = false;
  12689.  
  12690. SetBIsCombatActionAllowed( true );
  12691.  
  12692. m_LastWeaponTipPos = Vector(0, 0, 0, 0 );
  12693.  
  12694.  
  12695. this.AddTimer('FreeTickets',3.f,false);
  12696.  
  12697.  
  12698.  
  12699. }
  12700.  
  12701. event OnMovementFullyBlended()
  12702. {
  12703. SetBehaviorVariable( 'isPerformingSpecialAttack', 0.f );
  12704.  
  12705. if ( restoreUsableItem )
  12706. {
  12707. restoreUsableItem = false;
  12708. SetPlayerActionToRestore ( PATR_Default );
  12709. OnUseSelectedItem();
  12710. }
  12711. }
  12712.  
  12713. event OnCombatMovementStart()
  12714. {
  12715. SetCombatIdleStance( 1.f );
  12716. OnCombatActionEndComplete();
  12717. }
  12718.  
  12719. timer function FreeTickets( dt : float, id : int )
  12720. {
  12721. FreeTicketAtCombatTarget();
  12722. }
  12723.  
  12724.  
  12725.  
  12726. event OnGuardedReleased(){}
  12727. event OnPerformAttack( playerAttackType : name ){}
  12728. event OnPerformEvade( playerEvadeType : EPlayerEvadeType ){}
  12729. event OnInterruptAttack(){}
  12730. event OnPerformGuard(){}
  12731. event OnSpawnHorse(){}
  12732. event OnDismountActionScriptCallback(){}
  12733.  
  12734. event OnHorseSummonStart()
  12735. {
  12736. thePlayer.BlockAction(EIAB_CallHorse, 'HorseSummon');
  12737. thePlayer.BlockAction(EIAB_Signs, 'HorseSummon');
  12738. thePlayer.BlockAction(EIAB_Crossbow, 'HorseSummon');
  12739. thePlayer.BlockAction(EIAB_UsableItem, 'HorseSummon');
  12740. thePlayer.BlockAction(EIAB_ThrowBomb, 'HorseSummon');
  12741. thePlayer.BlockAction(EIAB_SwordAttack, 'HorseSummon');
  12742. thePlayer.BlockAction(EIAB_Jump, 'HorseSummon');
  12743. thePlayer.BlockAction(EIAB_Dodge, 'HorseSummon');
  12744. thePlayer.BlockAction(EIAB_LightAttacks, 'HorseSummon');
  12745. thePlayer.BlockAction(EIAB_HeavyAttacks, 'HorseSummon');
  12746. thePlayer.BlockAction(EIAB_SpecialAttackLight, 'HorseSummon');
  12747. thePlayer.BlockAction(EIAB_SpecialAttackHeavy, 'HorseSummon');
  12748.  
  12749. horseSummonTimeStamp = theGame.GetEngineTimeAsSeconds();
  12750. }
  12751.  
  12752. event OnHorseSummonStop()
  12753. {
  12754. thePlayer.BlockAllActions('HorseSummon',false);
  12755. }
  12756.  
  12757.  
  12758. event OnCombatActionStartVehicle( action : EVehicleCombatAction )
  12759. {
  12760. this.SetBIsCombatActionAllowed( false );
  12761.  
  12762. if ( action != EHCA_ShootCrossbow )
  12763. {
  12764. SetIsAimingCrossbow( false );
  12765. OnRangedForceHolster();
  12766. }
  12767. }
  12768.  
  12769. event OnCombatActionEndVehicle()
  12770. {
  12771. this.SetBIsCombatActionAllowed( true );
  12772. }
  12773.  
  12774.  
  12775.  
  12776.  
  12777.  
  12778. protected function CriticalBuffInformBehavior(buff : CBaseGameplayEffect)
  12779. {
  12780.  
  12781. if( !CanAnimationReactToCriticalState( buff ) )
  12782. {
  12783. return;
  12784. }
  12785.  
  12786.  
  12787.  
  12788.  
  12789. SetBehaviorVariable( 'CriticalStateType', (int)GetBuffCriticalType(buff) );
  12790. SetBehaviorVariable( 'bCriticalState', 1);
  12791.  
  12792. if(CriticalBuffUsesFullBodyAnim(buff))
  12793. RaiseEvent('CriticalState');
  12794.  
  12795. SetBehaviorVariable( 'IsInAir', (int)IsInAir());
  12796.  
  12797. LogCritical("Sending player critical state event for <<" + buff.GetEffectType() + ">>");
  12798.  
  12799.  
  12800. }
  12801.  
  12802. private function CanAnimationReactToCriticalState( buff : CBaseGameplayEffect ) : bool
  12803. {
  12804. var buffCritical : W3CriticalEffect;
  12805. var buffCriticalDOT : W3CriticalDOTEffect;
  12806. var isHeavyCritical : bool;
  12807.  
  12808. isHeavyCritical = false;
  12809.  
  12810.  
  12811. buffCritical = ( W3CriticalEffect ) buff;
  12812. if( buffCritical )
  12813. {
  12814. isHeavyCritical = buffCritical.explorationStateHandling == ECH_HandleNow;
  12815. }
  12816. else
  12817. {
  12818. buffCriticalDOT = ( W3CriticalDOTEffect ) buff;
  12819. if( buffCriticalDOT )
  12820. {
  12821. isHeavyCritical = buffCriticalDOT.explorationStateHandling == ECH_HandleNow;
  12822. }
  12823. }
  12824.  
  12825.  
  12826. if( !isHeavyCritical )
  12827. {
  12828. if( !CanReactToCriticalState() )
  12829. {
  12830. return false;
  12831. }
  12832. }
  12833.  
  12834. return true;
  12835. }
  12836.  
  12837. public function CanReactToCriticalState() : bool
  12838. {
  12839. return substateManager.CanReactToHardCriticalState();
  12840. }
  12841.  
  12842. event OnCriticalStateAnimStart()
  12843. {
  12844. var heading : float;
  12845. var newCritical : ECriticalStateType;
  12846. var newReqCS : CBaseGameplayEffect;
  12847.  
  12848. OnCombatActionEndComplete();
  12849.  
  12850.  
  12851. newReqCS = newRequestedCS;
  12852. if(super.OnCriticalStateAnimStart())
  12853. {
  12854.  
  12855. RemoveTimer( 'IsItemUseInputHeld' );
  12856. keepRequestingCriticalAnimStart = false;
  12857. CancelHoldAttacks();
  12858.  
  12859.  
  12860.  
  12861.  
  12862.  
  12863. if(!IsUsingVehicle())
  12864. {
  12865. newCritical = GetBuffCriticalType(newReqCS);
  12866. if(newCritical == ECST_HeavyKnockdown
  12867. || newCritical == ECST_Knockdown
  12868. || newCritical == ECST_Stagger
  12869. || newCritical == ECST_Ragdoll
  12870. || newCritical == ECST_LongStagger )
  12871. {
  12872. if(newReqCS.GetCreator())
  12873. heading = VecHeading(newReqCS.GetCreator().GetWorldPosition() - GetWorldPosition());
  12874. else
  12875. heading = GetHeading();
  12876.  
  12877.  
  12878. SetCustomRotation( 'Knockdown', heading, 2160.f, 0.1f, true );
  12879.  
  12880. if ( newCritical != ECST_Stagger && newCritical != ECST_LongStagger )
  12881. substateManager.ReactOnCriticalState( true );
  12882. }
  12883. }
  12884.  
  12885. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'CriticalEffectStart', -1, 30.0f, -1.f, -1, true );
  12886. return true;
  12887. }
  12888.  
  12889.  
  12890. return false;
  12891. }
  12892.  
  12893.  
  12894. public function StartCSAnim(buff : CBaseGameplayEffect) : bool
  12895. {
  12896. SetBehaviorVariable( 'bCriticalStopped', 0 );
  12897.  
  12898. if(super.StartCSAnim(buff))
  12899. {
  12900. if(!CriticalBuffUsesFullBodyAnim(buff))
  12901. {
  12902. OnCriticalStateAnimStart();
  12903. }
  12904.  
  12905. ResumeStaminaRegen( 'InsideCombatAction' );
  12906.  
  12907. keepRequestingCriticalAnimStart = true;
  12908. AddTimer('RequestCriticalAnimStart', 0, true);
  12909.  
  12910.  
  12911. return true;
  12912. }
  12913.  
  12914. return false;
  12915. }
  12916.  
  12917. public function CriticalEffectAnimationInterrupted(reason : string) : bool
  12918. {
  12919. var ret : bool;
  12920.  
  12921. LogCriticalPlayer("R4Player.CriticalEffectAnimationInterrupted() - because: " + reason);
  12922.  
  12923. ret = super.CriticalEffectAnimationInterrupted(reason);
  12924.  
  12925. if(ret)
  12926. {
  12927. keepRequestingCriticalAnimStart = false;
  12928. }
  12929.  
  12930. substateManager.ReactOnCriticalState( false );
  12931.  
  12932. return ret;
  12933. }
  12934.  
  12935. public function CriticalStateAnimStopped(forceRemoveBuff : bool)
  12936. {
  12937. LogCriticalPlayer("R4Player.CriticalStateAnimStopped() - forced: " + forceRemoveBuff);
  12938.  
  12939. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'RecoveredFromCriticalEffect', -1, 30.0f, -1.f, -1, true );
  12940. super.CriticalStateAnimStopped(forceRemoveBuff);
  12941.  
  12942. substateManager.ReactOnCriticalState( false );
  12943. }
  12944.  
  12945.  
  12946. timer function RequestCriticalAnimStart(dt : float, id : int)
  12947. {
  12948. if(keepRequestingCriticalAnimStart)
  12949. {
  12950. if(newRequestedCS && newRequestedCS.GetDurationLeft() > 0)
  12951. {
  12952. CriticalBuffInformBehavior(newRequestedCS);
  12953. }
  12954. else
  12955. {
  12956. keepRequestingCriticalAnimStart = false;
  12957. RemoveTimer('RequestCriticalAnimStart');
  12958. }
  12959. }
  12960. else
  12961. {
  12962. RemoveTimer('RequestCriticalAnimStart');
  12963. }
  12964. }
  12965.  
  12966. event OnRagdollUpdate(progress : float)
  12967. {
  12968.  
  12969.  
  12970. SetIsInAir(progress == 0);
  12971. }
  12972.  
  12973.  
  12974. event OnRagdollOnGround()
  12975. {
  12976.  
  12977. TryToEndRagdollOnGround( 0.0f );
  12978. }
  12979.  
  12980. event OnRagdollInAir()
  12981. {
  12982. RemoveTimer('TryToEndRagdollOnGround');
  12983. }
  12984.  
  12985. event OnNoLongerInRagdoll()
  12986. {
  12987. RemoveTimer('TryToEndRagdollOnGround');
  12988. }
  12989.  
  12990. timer function TryToEndRagdollOnGround( td : float, optional id : int)
  12991. {
  12992. var critical : CBaseGameplayEffect;
  12993. var type : EEffectType;
  12994.  
  12995. critical = GetCurrentlyAnimatedCS();
  12996. if(critical)
  12997. {
  12998. type = critical.GetEffectType();
  12999. if(type == EET_Knockdown || type == EET_HeavyKnockdown || type == EET_Ragdoll)
  13000. {
  13001.  
  13002. if (critical.GetTimeActive() >= 2.5f)
  13003. {
  13004. SetIsInAir(false);
  13005. RequestCriticalAnimStop();
  13006. RemoveTimer('TryToEndRagdollOnGround');
  13007. }
  13008. else
  13009. {
  13010. AddTimer('TryToEndRagdollOnGround', 0.2f, true);
  13011. }
  13012. return;
  13013. }
  13014. }
  13015.  
  13016.  
  13017. RemoveTimer('TryToEndRagdollOnGround');
  13018. }
  13019.  
  13020. public function RequestCriticalAnimStop(optional dontSetCriticalToStopped : bool)
  13021. {
  13022. var buff : CBaseGameplayEffect;
  13023.  
  13024. buff = GetCurrentlyAnimatedCS();
  13025. if(buff && !CriticalBuffUsesFullBodyAnim(buff))
  13026. {
  13027. CriticalStateAnimStopped(false);
  13028. }
  13029.  
  13030. if(!buff || !CriticalBuffUsesFullBodyAnim(buff))
  13031. {
  13032. SetBehaviorVariable( 'bCriticalState', 0);
  13033. }
  13034.  
  13035. super.RequestCriticalAnimStop(dontSetCriticalToStopped);
  13036. }
  13037.  
  13038.  
  13039.  
  13040.  
  13041. public function SimulateBuffTimePassing(simulatedTime : float)
  13042. {
  13043. effectManager.SimulateBuffTimePassing(simulatedTime);
  13044. }
  13045.  
  13046. public function AddEffectDefault(effectType : EEffectType, creat : CGameplayEntity, srcName : string, optional isSignEffect : bool) : EEffectInteract
  13047. {
  13048. var params : SCustomEffectParams;
  13049.  
  13050.  
  13051. if(effectType == EET_Stagger || effectType == EET_LongStagger || effectType == EET_Knockdown || effectType == EET_HeavyKnockdown)
  13052. {
  13053. params.effectType = effectType;
  13054. params.creator = creat;
  13055. params.sourceName = srcName;
  13056. params.isSignEffect = isSignEffect;
  13057.  
  13058. if ( effectType == EET_Stagger )
  13059. params.duration = 1.83;
  13060. else if ( effectType == EET_LongStagger )
  13061. params.duration = 4;
  13062. else if ( effectType == EET_Knockdown )
  13063. params.duration = 2.5;
  13064. else if ( effectType == EET_HeavyKnockdown )
  13065. params.duration = 4;
  13066.  
  13067. return super.AddEffectCustom(params);
  13068. }
  13069. else
  13070. {
  13071. return super.AddEffectDefault(effectType, creat, srcName, isSignEffect);
  13072. }
  13073. }
  13074.  
  13075.  
  13076.  
  13077.  
  13078.  
  13079. public function CheatResurrect()
  13080. {
  13081. var items : array< SItemUniqueId >;
  13082. var i, size, itemLevel, maxPrice, itemPrice : int;
  13083. var itemToEquip : SItemUniqueId;
  13084.  
  13085. if(IsAlive())
  13086. return;
  13087.  
  13088.  
  13089. if ( !theGame.GetGuiManager().GetRootMenu() )
  13090. {
  13091. Log(" *** Call this function after DeathScreen appears *** ");
  13092. return;
  13093. }
  13094.  
  13095. SetAlive(true);
  13096.  
  13097. SetKinematic(true);
  13098.  
  13099. EnableFindTarget( true );
  13100. SetBehaviorVariable( 'Ragdoll_Weight', 0.f );
  13101. RaiseForceEvent( 'RecoverFromRagdoll' );
  13102. SetCanPlayHitAnim( true );
  13103. SetBehaviorVariable( 'CriticalStateType', (int)ECST_None );
  13104. GoToStateIfNew('Exploration');
  13105.  
  13106. ( (CDismembermentComponent)this.GetComponent( 'Dismemberment' ) ).ClearVisibleWound();
  13107.  
  13108. SetIsInAir(false);
  13109.  
  13110. theInput.SetContext('Exploration');
  13111.  
  13112. ResetDeathType();
  13113.  
  13114. ForceUnlockAllInputActions(false);
  13115.  
  13116. theGame.CloseMenu('DeathScreenMenu');
  13117.  
  13118.  
  13119. theSound.LeaveGameState(ESGS_Death);
  13120.  
  13121.  
  13122. abilityManager.ForceSetStat(BCS_Vitality, GetStatMax(BCS_Vitality));
  13123. effectManager.StopVitalityRegen();
  13124. abilityManager.ForceSetStat( BCS_Air , 100.f );
  13125. effectManager.StopAirRegen();
  13126. abilityManager.ForceSetStat( BCS_Stamina , 100.f );
  13127. effectManager.StopStaminaRegen();
  13128. abilityManager.ForceSetStat( BCS_Toxicity , 0.f );
  13129. abilityManager.ForceSetStat( BCS_Focus , 0.f );
  13130. GetWitcherPlayer().UpdateEncumbrance();
  13131.  
  13132.  
  13133. if ( !inv.IsThereItemOnSlot( EES_SteelSword ) )
  13134. {
  13135. items = inv.GetItemsByCategory( 'steelsword' );
  13136. }
  13137. else if ( !inv.IsThereItemOnSlot( EES_SilverSword ) )
  13138. {
  13139. items = inv.GetItemsByCategory( 'silversword' );
  13140. }
  13141.  
  13142. size = items.Size();
  13143. maxPrice = -1;
  13144. for ( i = 0; i < size; i += 1 )
  13145. {
  13146. itemPrice = inv.GetItemPrice(items[i]);
  13147. itemLevel = inv.GetItemLevel(items[i]);
  13148. if ( itemLevel <= GetLevel() && itemPrice > maxPrice )
  13149. {
  13150. maxPrice = itemPrice;
  13151. itemToEquip = items[i];
  13152. }
  13153. }
  13154. if( inv.IsIdValid( itemToEquip ) )
  13155. {
  13156. EquipItem( itemToEquip , , true );
  13157. }
  13158.  
  13159. theGame.ReleaseNoSaveLock(deathNoSaveLock);
  13160. }
  13161.  
  13162.  
  13163.  
  13164. public function SetIsInsideInteraction(b : bool) {isInsideInteraction = b;}
  13165. public function IsInsideInteraction() : bool {return isInsideInteraction;}
  13166.  
  13167. public function SetIsInsideHorseInteraction( b : bool, horse : CEntity )
  13168. {
  13169. isInsideHorseInteraction = b;
  13170. horseInteractionSource = horse;
  13171. }
  13172. public function IsInsideHorseInteraction() : bool {return isInsideHorseInteraction;}
  13173.  
  13174.  
  13175. event OnInteractionActivationTest( interactionComponentName : string, activator : CEntity )
  13176. {
  13177. if ( interactionComponentName == "ClimbLadder" )
  13178. {
  13179. if( PlayerHasLadderExplorationReady() )
  13180. {
  13181. return true;
  13182. }
  13183. }
  13184.  
  13185. return false;
  13186. }
  13187.  
  13188. private function PlayerHasLadderExplorationReady() : bool
  13189. {
  13190. if( !substateManager.CanInteract() )
  13191. {
  13192. return false;
  13193. }
  13194.  
  13195. if( !substateManager.m_SharedDataO.HasValidLadderExploration() )
  13196. {
  13197. return false;
  13198. }
  13199.  
  13200. return true;
  13201. }
  13202.  
  13203.  
  13204.  
  13205.  
  13206.  
  13207. public function SetGuarded(flag : bool)
  13208. {
  13209. super.SetGuarded(flag);
  13210.  
  13211. if(flag && FactsQuerySum("tut_fight_use_slomo") > 0)
  13212. {
  13213. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
  13214. FactsRemove("tut_fight_slomo_ON");
  13215. }
  13216. }
  13217.  
  13218.  
  13219. public function IsGuarded() : bool
  13220. {
  13221. return super.IsGuarded() && ( !rangedWeapon || rangedWeapon.GetCurrentStateName() == 'State_WeaponWait' );
  13222. }
  13223.  
  13224.  
  13225.  
  13226.  
  13227. public function GetSelectedItemId() : SItemUniqueId {return selectedItemId;}
  13228. public function ClearSelectedItemId() {selectedItemId = GetInvalidUniqueId();}
  13229.  
  13230. public function IsHoldingItemInLHand() : bool
  13231. {
  13232. return currentlyEquipedItemL != GetInvalidUniqueId();
  13233. }
  13234.  
  13235. public function GetCurrentlyUsedItemL () : W3UsableItem
  13236. {
  13237. return currentlyUsedItemL;
  13238. }
  13239.  
  13240. public function SetPlayerActionToRestore ( actionToRestoreType : EPlayerActionToRestore )
  13241. {
  13242. playerActionToRestore = actionToRestoreType;
  13243. }
  13244.  
  13245. public function IsCurrentlyUsingItemL () : bool
  13246. {
  13247. return currentlyUsingItem;
  13248. }
  13249.  
  13250. function BlockSlotsOnLItemUse ()
  13251. {
  13252. var slotsToBlock : array<name>;
  13253.  
  13254. slotsToBlock.PushBack( 'Slot1' );
  13255. slotsToBlock.PushBack( 'Slot2' );
  13256. slotsToBlock.PushBack( 'Slot3' );
  13257. slotsToBlock.PushBack( 'Slot4' );
  13258. slotsToBlock.PushBack( 'Slot5' );
  13259. slotsToBlock.PushBack( 'Yrden' );
  13260. slotsToBlock.PushBack( 'Quen' );
  13261. slotsToBlock.PushBack( 'Igni' );
  13262. slotsToBlock.PushBack( 'Axii' );
  13263. slotsToBlock.PushBack( 'Aard' );
  13264.  
  13265.  
  13266. EnableRadialSlotsWithSource ( false, slotsToBlock, 'usableItemL' );
  13267. }
  13268.  
  13269. function UnblockSlotsOnLItemUse ()
  13270. {
  13271. var slotsToBlock : array<name>;
  13272.  
  13273. slotsToBlock.PushBack( 'Slot1' );
  13274. slotsToBlock.PushBack( 'Slot2' );
  13275. slotsToBlock.PushBack( 'Slot3' );
  13276. slotsToBlock.PushBack( 'Slot4' );
  13277. slotsToBlock.PushBack( 'Slot5' );
  13278. slotsToBlock.PushBack( 'Yrden' );
  13279. slotsToBlock.PushBack( 'Quen' );
  13280. slotsToBlock.PushBack( 'Igni' );
  13281. slotsToBlock.PushBack( 'Axii' );
  13282. slotsToBlock.PushBack( 'Aard' );
  13283.  
  13284.  
  13285. EnableRadialSlotsWithSource ( true, slotsToBlock, 'usableItemL' );
  13286. }
  13287.  
  13288. function IsUsableItemLBlocked () : bool
  13289. {
  13290. return isUsableItemBlocked;
  13291. }
  13292. function HideUsableItem( optional force : bool )
  13293. {
  13294. if( currentlyEquipedItemL != GetInvalidUniqueId() )
  13295. {
  13296. if( force )
  13297. {
  13298. if( !RaiseForceEvent( 'ItemEndL' ) )
  13299. {
  13300.  
  13301. OnUsingItemsReset();
  13302. }
  13303. return;
  13304.  
  13305. }
  13306. RaiseEvent( 'ItemUseL' );
  13307. }
  13308. }
  13309. function ProcessUsableItemsTransition ( actionToRestore : EPlayerActionToRestore )
  13310. {
  13311. var category : name;
  13312. var signSkill : ESkill;
  13313.  
  13314. category = inv.GetItemCategory ( selectedItemId );
  13315. signSkill = SignEnumToSkillEnum( GetEquippedSign());
  13316.  
  13317. switch ( actionToRestore )
  13318. {
  13319. case PATR_None:
  13320. if ( currentlyUsedItemL )
  13321. {
  13322. inv.UnmountItem( currentlyEquipedItemL, true );
  13323. }
  13324. currentlyEquipedItemL = GetInvalidUniqueId();
  13325. return;
  13326.  
  13327. case PATR_Default:
  13328. if ( IsSlotQuickslot( inv.GetSlotForItemId ( selectedItemId )) && category == 'usable' && currentlyEquipedItemL != selectedItemId )
  13329. {
  13330. if ( currentlyUsedItemL )
  13331. {
  13332. inv.UnmountItem( currentlyEquipedItemL, true );
  13333. }
  13334. currentlyEquipedItemL = GetInvalidUniqueId();
  13335. OnUseSelectedItem();
  13336. return;
  13337. }
  13338. break;
  13339. case PATR_Crossbow:
  13340. if ( inv.IsItemCrossbow ( selectedItemId ) )
  13341. {
  13342. if ( currentlyUsedItemL )
  13343. {
  13344. inv.UnmountItem( currentlyEquipedItemL, true );
  13345. }
  13346. currentlyEquipedItemL = GetInvalidUniqueId();
  13347. SetIsAimingCrossbow( true );
  13348.  
  13349. if ( theInput.IsActionPressed( 'ThrowItem' ) )
  13350. SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  13351. else
  13352. {
  13353. SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  13354. SetupCombatAction( EBAT_ItemUse, BS_Released );
  13355. }
  13356. return;
  13357. }
  13358. break;
  13359. case PATR_CastSign:
  13360. if( signSkill != S_SUndefined && playerActionToRestore == PATR_CastSign )
  13361. {
  13362. if ( currentlyUsedItemL )
  13363. {
  13364. inv.UnmountItem( currentlyEquipedItemL, true );
  13365. }
  13366. currentlyEquipedItemL = GetInvalidUniqueId();
  13367.  
  13368. if( HasStaminaToUseSkill( signSkill, false ) )
  13369. {
  13370. if( GetInvalidUniqueId() != inv.GetItemFromSlot( 'l_weapon' ) )
  13371. PushCombatActionOnBuffer( EBAT_CastSign, BS_Pressed );
  13372. else
  13373. SetupCombatAction( EBAT_CastSign, BS_Pressed );
  13374. }
  13375. else
  13376. {
  13377. thePlayer.SoundEvent("gui_no_stamina");
  13378. }
  13379. return;
  13380. }
  13381. break;
  13382. case PATR_ThrowBomb:
  13383. if ( inv.IsItemBomb ( selectedItemId ) )
  13384. {
  13385. if ( currentlyUsedItemL )
  13386. {
  13387. inv.UnmountItem( currentlyEquipedItemL, true );
  13388. }
  13389. currentlyEquipedItemL = GetInvalidUniqueId();
  13390. PrepareToAttack();
  13391. SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  13392. return;
  13393. }
  13394. break;
  13395. case PATR_CallHorse:
  13396. theGame.OnSpawnPlayerHorse();
  13397. break;
  13398. default:
  13399. if ( currentlyUsedItemL )
  13400. {
  13401. inv.UnmountItem( currentlyEquipedItemL, true );
  13402. }
  13403. currentlyEquipedItemL = GetInvalidUniqueId();
  13404. return;
  13405. }
  13406. if ( currentlyUsedItemL )
  13407. {
  13408. inv.UnmountItem( currentlyEquipedItemL, true );
  13409. }
  13410. currentlyEquipedItemL = GetInvalidUniqueId();
  13411. }
  13412.  
  13413. function GetUsableItemLtransitionAllowed () : bool
  13414. {
  13415. return isUsableItemLtransitionAllowed;
  13416. }
  13417.  
  13418. function SetUsableItemLtransitionAllowed ( isAllowed : bool)
  13419. {
  13420. isUsableItemLtransitionAllowed = isAllowed;
  13421. }
  13422.  
  13423. event OnItemUseLUnBlocked ()
  13424. {
  13425. if ( isUsableItemBlocked )
  13426. {
  13427. isUsableItemBlocked = false;
  13428. UnblockSlotsOnLItemUse ();
  13429. }
  13430. }
  13431.  
  13432. event OnItemUseLBlocked ()
  13433. {
  13434. if ( !isUsableItemBlocked )
  13435. {
  13436. isUsableItemBlocked = true;
  13437. BlockSlotsOnLItemUse ();
  13438. }
  13439. }
  13440.  
  13441. event OnUsingItemsReset()
  13442. {
  13443. if ( currentlyUsingItem )
  13444. {
  13445. OnItemUseLUnBlocked ();
  13446. OnUsingItemsComplete();
  13447. }
  13448. }
  13449. event OnUsingItemsComplete ()
  13450. {
  13451. if ( isUsableItemBlocked )
  13452. {
  13453. OnItemUseLUnBlocked ();
  13454. }
  13455. currentlyUsingItem = false;
  13456. if ( GetUsableItemLtransitionAllowed () )
  13457. {
  13458. ProcessUsableItemsTransition( playerActionToRestore );
  13459. }
  13460. else
  13461. {
  13462. if ( currentlyUsedItemL )
  13463. {
  13464. inv.UnmountItem( currentlyEquipedItemL, true );
  13465. }
  13466. currentlyEquipedItemL = GetInvalidUniqueId();
  13467. }
  13468.  
  13469. SetPlayerActionToRestore ( PATR_Default );
  13470. }
  13471.  
  13472. event OnUseSelectedItem( optional force : bool )
  13473. {
  13474. var category : name;
  13475. var itemEntity : W3UsableItem;
  13476.  
  13477. if ( isUsableItemBlocked && !force )
  13478. {
  13479. return false;
  13480. }
  13481. if ( IsCastingSign() )
  13482. return false;
  13483.  
  13484. if ( currentlyEquipedItemL != GetInvalidUniqueId() )
  13485. {
  13486. SetBehaviorVariable( 'SelectedItemL', (int)GetUsableItemTypeById( currentlyEquipedItemL ), true );
  13487. if ( force )
  13488. {
  13489. if ( RaiseEvent( 'ItemEndL' ) )
  13490. {
  13491. SetUsableItemLtransitionAllowed ( true );
  13492. return true;
  13493. }
  13494. }
  13495. else
  13496. {
  13497. if ( RaiseEvent( 'ItemUseL' ) )
  13498. {
  13499. SetUsableItemLtransitionAllowed ( true );
  13500. return true;
  13501. }
  13502. }
  13503. }
  13504. else
  13505. {
  13506. category = inv.GetItemCategory( selectedItemId );
  13507. if( category != 'usable' )
  13508. {
  13509. return false;
  13510. }
  13511. SetBehaviorVariable( 'SelectedItemL', (int)GetUsableItemTypeById( selectedItemId ), true );
  13512. if( RaiseEvent( 'ItemUseL' ) )
  13513. {
  13514. currentlyEquipedItemL = selectedItemId;
  13515. SetUsableItemLtransitionAllowed ( false );
  13516. currentlyUsingItem = true;
  13517.  
  13518. return true;
  13519. }
  13520. inv.UnmountItem( selectedItemId, true );
  13521. }
  13522. }
  13523.  
  13524. protected saved var currentlyUsingItem : bool;
  13525.  
  13526. public function ProcessUseSelectedItem( itemEntity : W3UsableItem, optional shouldCallOnUsed : bool )
  13527. {
  13528. currentlyUsedItemL = itemEntity;
  13529. DrainStamina(ESAT_UsableItem);
  13530.  
  13531. if ( shouldCallOnUsed )
  13532. {
  13533. currentlyUsedItemL.OnUsed( thePlayer );
  13534. }
  13535. }
  13536.  
  13537. function GetUsableItemTypeById ( itemId : SItemUniqueId ) : EUsableItemType
  13538. {
  13539. var itemName : name;
  13540.  
  13541. itemName = inv.GetItemName ( itemId );
  13542.  
  13543. return theGame.GetDefinitionsManager().GetUsableItemType ( itemName );
  13544.  
  13545. }
  13546.  
  13547.  
  13548. public function StartWaitForItemSpawnAndProccesTask()
  13549. {
  13550. AddTimer( 'WaitForItemSpawnAndProccesTask', 0.001f, true,,,,true );
  13551. }
  13552.  
  13553.  
  13554. public function KillWaitForItemSpawnAndProccesTask()
  13555. {
  13556. RemoveTimer ( 'WaitForItemSpawnAndProccesTask' );
  13557. }
  13558.  
  13559.  
  13560.  
  13561. public function AllowUseSelectedItem()
  13562. {
  13563. m_useSelectedItemIfSpawned = true;
  13564. }
  13565.  
  13566.  
  13567.  
  13568. timer function WaitForItemSpawnAndProccesTask( timeDelta : float , id : int )
  13569. {
  13570. var itemEntity : W3UsableItem;
  13571. var canTaskBeKilled : bool;
  13572. canTaskBeKilled = false;
  13573.  
  13574. if ( IsCastingSign() )
  13575. {
  13576. return;
  13577. }
  13578.  
  13579.  
  13580. if ( selectedItemId == GetInvalidUniqueId() )
  13581. {
  13582. canTaskBeKilled = true;
  13583. }
  13584.  
  13585. itemEntity = (W3UsableItem)inv.GetItemEntityUnsafe( selectedItemId );
  13586. if ( itemEntity && m_useSelectedItemIfSpawned )
  13587. {
  13588.  
  13589. canTaskBeKilled = true;
  13590. m_useSelectedItemIfSpawned = false;
  13591. ProcessUseSelectedItem( itemEntity, true );
  13592. }
  13593.  
  13594. if ( canTaskBeKilled )
  13595. {
  13596. KillWaitForItemSpawnAndProccesTask();
  13597. }
  13598. }
  13599.  
  13600. event OnBombProjectileReleased()
  13601. {
  13602. ResetRawPlayerHeading();
  13603. UnblockAction(EIAB_ThrowBomb, 'BombThrow');
  13604. UnblockAction(EIAB_Crossbow, 'BombThrow');
  13605.  
  13606. if(GetCurrentStateName() == 'AimThrow')
  13607. PopState();
  13608.  
  13609. FactsAdd("ach_bomb", 1, 4 );
  13610. theGame.GetGamerProfile().CheckLearningTheRopes();
  13611. }
  13612.  
  13613. public function SetIsThrowingItemWithAim(b : bool)
  13614. {
  13615. isThrowingItemWithAim = b;
  13616. }
  13617.  
  13618. public function SetIsThrowingItem( flag : bool ) {isThrowingItem = flag;}
  13619. public function IsThrowingItem() : bool {return isThrowingItem;}
  13620. public function IsThrowingItemWithAim() : bool {return isThrowingItemWithAim;}
  13621. public function SetThrowHold(b : bool) {isThrowHoldPressed = b;}
  13622. public function IsThrowHold() : bool {return isThrowHoldPressed;}
  13623. public function SetIsAimingCrossbow( flag : bool ) {isAimingCrossbow = flag;}
  13624. public function GetIsAimingCrossbow() : bool {return isAimingCrossbow;}
  13625.  
  13626. event OnThrowAnimLeave()
  13627. {
  13628. var throwStage : EThrowStage;
  13629. var thrownEntity : CThrowable;
  13630.  
  13631. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  13632.  
  13633. if(thrownEntity && !thrownEntity.WasThrown())
  13634. {
  13635. throwStage = (int)GetBehaviorVariable( 'throwStage', (int)TS_Stop);
  13636. if(inv.IsItemBomb(selectedItemId))
  13637. {
  13638. BombThrowCleanUp();
  13639. }
  13640. else
  13641. {
  13642. ThrowingAbort();
  13643. }
  13644. }
  13645.  
  13646. thrownEntity = NULL;
  13647. SetIsThrowingItem( false );
  13648. SetIsThrowingItemWithAim( false );
  13649.  
  13650. this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
  13651. UnblockAction(EIAB_ThrowBomb, 'BombThrow');
  13652. UnblockAction(EIAB_Crossbow, 'BombThrow');
  13653. }
  13654.  
  13655.  
  13656. protected function BombThrowStart()
  13657. {
  13658. var slideTargetActor : CActor;
  13659.  
  13660. BlockAction( EIAB_ThrowBomb, 'BombThrow' );
  13661. BlockAction(EIAB_Crossbow, 'BombThrow');
  13662.  
  13663. SetBehaviorVariable( 'throwStage', (int)TS_Start );
  13664. SetBehaviorVariable( 'combatActionType', (int)CAT_ItemThrow );
  13665.  
  13666. if ( slideTarget )
  13667. {
  13668. AddCustomOrientationTarget( OT_Actor, 'BombThrow' );
  13669.  
  13670. slideTargetActor = (CActor)( slideTarget );
  13671.  
  13672.  
  13673.  
  13674.  
  13675.  
  13676. }
  13677. else
  13678. {
  13679. if ( lastAxisInputIsMovement )
  13680. AddCustomOrientationTarget( OT_Actor, 'BombThrow' );
  13681. else
  13682. AddCustomOrientationTarget( OT_Camera, 'BombThrow' );
  13683. }
  13684.  
  13685. UpdateLookAtTarget();
  13686. SetCustomRotation( 'Throw', VecHeading( this.GetLookAtPosition() - GetWorldPosition() ), 0.0f, 0.3f, false );
  13687.  
  13688. SetBehaviorVariable( 'itemType', (int)IT_Petard );
  13689.  
  13690. ProcessCanAttackWhenNotInCombatBomb();
  13691.  
  13692. if ( RaiseForceEvent('CombatAction') )
  13693. OnCombatActionStart();
  13694.  
  13695.  
  13696. theTelemetry.LogWithLabel(TE_FIGHT_HERO_THROWS_BOMB, inv.GetItemName( selectedItemId ));
  13697. }
  13698.  
  13699.  
  13700. event OnThrowAnimStart()
  13701. {
  13702. var itemId : SItemUniqueId;
  13703. var thrownEntity : CThrowable;
  13704.  
  13705. this.radialSlots.Clear();
  13706. GetWitcherPlayer().GetItemEquippedOnSlot(EES_Petard1, itemId );
  13707.  
  13708. if( GetSelectedItemId() == itemId )
  13709. {
  13710. this.radialSlots.PushBack( 'Slot2' );
  13711. }
  13712. else
  13713. {
  13714. this.radialSlots.PushBack( 'Slot1' );
  13715. }
  13716. this.radialSlots.PushBack( 'Slot3' );
  13717. this.radialSlots.PushBack( 'Slot4' );
  13718. this.radialSlots.PushBack( 'Slot5' );
  13719. this.EnableRadialSlotsWithSource( false, this.radialSlots, 'throwBomb' );
  13720.  
  13721. thrownEntity = (CThrowable)inv.GetDeploymentItemEntity( selectedItemId,,,true );
  13722. thrownEntity.Initialize( this, selectedItemId );
  13723. EntityHandleSet( thrownEntityHandle, thrownEntity );
  13724. SetIsThrowingItem( true );
  13725. }
  13726.  
  13727. public function BombThrowAbort()
  13728. {
  13729. BombThrowCleanUp();
  13730. UnblockAction( EIAB_ThrowBomb, 'BombThrow' );
  13731. UnblockAction(EIAB_Crossbow, 'BombThrow');
  13732. }
  13733.  
  13734. private function BombThrowCleanUp()
  13735. {
  13736. var throwStage : EThrowStage;
  13737. var thrownEntity : CThrowable;
  13738. var vehicle : CVehicleComponent;
  13739.  
  13740. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  13741.  
  13742. this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
  13743. throwStage = (int)GetBehaviorVariable( 'throwStage', (int)TS_Stop);
  13744.  
  13745. SetBehaviorVariable( 'throwStage', (int)TS_Stop );
  13746.  
  13747. if( GetCurrentStateName() == 'AimThrow')
  13748. {
  13749. PopState();
  13750. thrownEntity.StopAiming( true );
  13751. }
  13752. else if ( this.IsUsingHorse() )
  13753. {
  13754. vehicle = (CVehicleComponent)(GetUsedVehicle().GetComponentByClassName('CVehicleComponent'));
  13755. vehicle.GetUserCombatManager().OnForceItemActionAbort();
  13756. }
  13757.  
  13758.  
  13759. if(thrownEntity && !thrownEntity.WasThrown())
  13760. {
  13761. thrownEntity.BreakAttachment();
  13762. thrownEntity.Destroy();
  13763. }
  13764.  
  13765. thrownEntity = NULL;
  13766. SetIsThrowingItem( false );
  13767. SetIsThrowingItemWithAim( false );
  13768. RemoveCustomOrientationTarget( 'BombThrow' );
  13769. }
  13770.  
  13771. public function ProcessCanAttackWhenNotInCombatBomb()
  13772. {
  13773. var targets : array< CGameplayEntity >;
  13774. var temp, throwVector, throwFrom, throwTo, throwVectorU : Vector;
  13775. var temp_n : name;
  13776. var throwVecLen : float;
  13777. var component : CComponent;
  13778.  
  13779.  
  13780.  
  13781. if( FactsQuerySum( "BombThrowSpecificTargets" ) > 0 )
  13782. {
  13783.  
  13784.  
  13785.  
  13786.  
  13787.  
  13788. throwFrom = playerAiming.GetThrowStartPosition();
  13789. throwTo = playerAiming.GetThrowPosition();
  13790. throwVector = throwTo - throwFrom;
  13791. throwVecLen = VecDistance( throwFrom, throwTo );
  13792. throwVectorU = throwVector / throwVecLen;
  13793. if( theGame.GetWorld().StaticTraceWithAdditionalInfo( throwFrom, throwTo + throwVectorU, temp, temp, temp_n, component ) && component && component.GetEntity().HasTag( 'BombThrowSpecificTarget' ) )
  13794. {
  13795. SetIsShootingFriendly( false );
  13796. }
  13797. else
  13798. {
  13799. SetIsShootingFriendly( true );
  13800. }
  13801. }
  13802. else if( FactsQuerySum( "BombThrowDisallowSpecificTargets" ) > 0 )
  13803. {
  13804.  
  13805. throwFrom = playerAiming.GetThrowStartPosition();
  13806. throwTo = playerAiming.GetThrowPosition();
  13807. throwVector = throwTo - throwFrom;
  13808. throwVecLen = VecDistance( throwFrom, throwTo );
  13809. throwVectorU = throwVector / throwVecLen;
  13810. if( theGame.GetWorld().StaticTraceWithAdditionalInfo( throwFrom, throwTo + throwVectorU, temp, temp, temp_n, component ) && component && component.GetEntity().HasTag( 'BombThrowDisallowedTarget' ) )
  13811. {
  13812. SetIsShootingFriendly( true );
  13813. }
  13814. else
  13815. {
  13816. SetIsShootingFriendly( false );
  13817. }
  13818. }
  13819. else
  13820. {
  13821. SetIsShootingFriendly( false );
  13822. }
  13823.  
  13824. SetBehaviorVariable( 'isShootingFriendly', (float)( GetIsShootingFriendly() ) );
  13825. }
  13826.  
  13827. public function SetIsShootingFriendly( flag : bool )
  13828. {
  13829. isShootingFriendly = flag;
  13830. }
  13831.  
  13832. public function GetIsShootingFriendly() : bool
  13833. {
  13834. return isShootingFriendly;
  13835. }
  13836.  
  13837.  
  13838. protected function UsableItemStart()
  13839. {
  13840. var thrownEntity : CThrowable;
  13841.  
  13842.  
  13843. thrownEntity = (CThrowable)inv.GetDeploymentItemEntity( selectedItemId,,,true );
  13844. thrownEntity.Initialize( this, selectedItemId );
  13845. EntityHandleSet( thrownEntityHandle, thrownEntity );
  13846. SetBehaviorVariable( 'throwStage', (int)TS_Start );
  13847. SetIsThrowingItem( true );
  13848. SetBehaviorVariable( 'combatActionType', (int)CAT_ItemThrow );
  13849.  
  13850. if ( slideTarget )
  13851. {
  13852. AddCustomOrientationTarget( OT_Actor, 'UsableItems' );
  13853. }
  13854. else
  13855. {
  13856. if ( lastAxisInputIsMovement )
  13857. AddCustomOrientationTarget( OT_Actor, 'UsableItems' );
  13858. else
  13859. AddCustomOrientationTarget( OT_Camera, 'UsableItems' );
  13860. }
  13861.  
  13862. SetBehaviorVariable( 'itemType', (int)(-1) );
  13863.  
  13864. if ( RaiseForceEvent('CombatAction') )
  13865. OnCombatActionStart();
  13866. }
  13867.  
  13868. protected function BombThrowRelease()
  13869. {
  13870. var stateName : name;
  13871.  
  13872. stateName = playerAiming.GetCurrentStateName();
  13873. OnDelayOrientationChangeOff();
  13874.  
  13875. if( GetIsShootingFriendly() || ( FactsQuerySum( "BombThrowSpecificTargets" ) > 0 && stateName != 'Aiming' ) )
  13876. {
  13877. BombThrowAbort();
  13878. }
  13879. else
  13880. {
  13881. SetBehaviorVariable( 'throwStage', (int)TS_End );
  13882.  
  13883. if ( stateName == 'Aiming' )
  13884. {
  13885. SetCustomRotation( 'Throw', VecHeading( this.GetLookAtPosition() - GetWorldPosition() ), 0.0f, 0.2f, false );
  13886. }
  13887. }
  13888. }
  13889.  
  13890. protected function UsableItemRelease()
  13891. {
  13892. OnDelayOrientationChangeOff();
  13893. SetBehaviorVariable( 'throwStage', (int)TS_End );
  13894. RemoveCustomOrientationTarget( 'UsableItems' );
  13895. }
  13896.  
  13897.  
  13898. public function ThrowingAbort()
  13899. {
  13900. var thrownEntity : CThrowable;
  13901.  
  13902. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  13903.  
  13904. SetBehaviorVariable( 'throwStage', (int)TS_Stop );
  13905. RaiseEvent( 'actionStop' );
  13906.  
  13907. if( GetCurrentStateName() == 'AimThrow')
  13908. {
  13909. PopState();
  13910. thrownEntity.StopAiming( true );
  13911. }
  13912.  
  13913.  
  13914. if(thrownEntity && !thrownEntity.WasThrown())
  13915. {
  13916. thrownEntity.BreakAttachment();
  13917. thrownEntity.Destroy();
  13918. }
  13919. this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
  13920. }
  13921.  
  13922. public function CanSetupCombatAction_Throw() : bool
  13923. {
  13924.  
  13925. if(!inv.IsIdValid( selectedItemId ))
  13926. return false;
  13927.  
  13928.  
  13929. if(!inv.IsItemSingletonItem(selectedItemId))
  13930. return false;
  13931.  
  13932.  
  13933. if(!GetBIsInputAllowed())
  13934. return false;
  13935.  
  13936.  
  13937. if(inv.GetItemQuantity(GetSelectedItemId()) <= 0 && !inv.ItemHasTag(selectedItemId, theGame.params.TAG_INFINITE_AMMO))
  13938. return false;
  13939.  
  13940.  
  13941. if(!inputHandler.IsActionAllowed(EIAB_ThrowBomb) && GetCurrentStateName() != 'Swimming')
  13942. return false;
  13943.  
  13944. return true;
  13945. }
  13946.  
  13947. public function GetThrownEntity() : CThrowable
  13948. {
  13949. return (CThrowable)EntityHandleGet( thrownEntityHandle );
  13950. }
  13951.  
  13952.  
  13953. event OnWeaponWait() { rangedWeapon.OnWeaponWait(); }
  13954. event OnWeaponDrawStart() { rangedWeapon.OnWeaponDrawStart(); }
  13955. event OnWeaponReloadStart() { rangedWeapon.OnWeaponReloadStart(); }
  13956. event OnWeaponReloadEnd() { rangedWeapon.OnWeaponReloadEnd(); }
  13957. event OnWeaponAimStart() { rangedWeapon.OnWeaponAimStart(); }
  13958. event OnWeaponShootStart() { rangedWeapon.OnWeaponShootStart(); }
  13959. event OnWeaponShootEnd() { rangedWeapon.OnWeaponShootEnd(); }
  13960. event OnWeaponAimEnd() { rangedWeapon.OnWeaponAimEnd(); }
  13961. event OnWeaponHolsterStart() { rangedWeapon.OnWeaponHolsterStart(); }
  13962. event OnWeaponHolsterEnd() { rangedWeapon.OnWeaponHolsterEnd(); }
  13963. event OnWeaponToNormalTransStart() { rangedWeapon.OnWeaponToNormalTransStart(); }
  13964. event OnWeaponToNormalTransEnd() { rangedWeapon.OnWeaponToNormalTransEnd(); }
  13965.  
  13966. event OnEnableAimingMode( enable : bool )
  13967. {
  13968. if( !crossbowDontPopStateHack )
  13969. {
  13970. if ( enable )
  13971. PushState( 'AimThrow' );
  13972. else if ( GetCurrentStateName() == 'AimThrow' )
  13973. PopState();
  13974. }
  13975. }
  13976.  
  13977. event OnRangedForceHolster( optional forceUpperBodyAnim, instant, dropItem : bool )
  13978. {
  13979. if(rangedWeapon)
  13980. rangedWeapon.OnForceHolster( forceUpperBodyAnim, instant, dropItem );
  13981. }
  13982.  
  13983.  
  13984. public function IsCrossbowHeld() : bool
  13985. {
  13986. if (rangedWeapon)
  13987. return rangedWeapon.GetCurrentStateName() != 'State_WeaponWait';
  13988. return false;
  13989. }
  13990.  
  13991.  
  13992. event OnBlockAllCombatTickets( release : bool )
  13993. {
  13994. if (!release )
  13995. ((CR4PlayerStateCombat)GetState('Combat')).OnBlockAllCombatTickets(false);
  13996. }
  13997. event OnForceTicketUpdate() {}
  13998.  
  13999.  
  14000.  
  14001.  
  14002.  
  14003. event OnProcessActionPost(action : W3DamageAction)
  14004. {
  14005. var npc : CNewNPC;
  14006. var attackAction : W3Action_Attack;
  14007. var lifeLeech : float;
  14008.  
  14009. super.OnProcessActionPost(action);
  14010.  
  14011. attackAction = (W3Action_Attack)action;
  14012.  
  14013. if(attackAction)
  14014. {
  14015. npc = (CNewNPC)action.victim;
  14016.  
  14017. if(npc && npc.IsHuman() )
  14018. {
  14019. PlayBattleCry('BattleCryHumansHit', 0.05f );
  14020. }
  14021. else
  14022. {
  14023. PlayBattleCry('BattleCryMonstersHit', 0.05f );
  14024. }
  14025.  
  14026. if(attackAction.IsActionMelee())
  14027. {
  14028.  
  14029. IncreaseUninterruptedHitsCount();
  14030.  
  14031.  
  14032. if( IsLightAttack( attackAction.GetAttackName() ) )
  14033. {
  14034. GCameraShake(0.1, false, GetWorldPosition(), 10);
  14035. }
  14036.  
  14037.  
  14038. if(npc && inv.GetItemName(attackAction.GetWeaponId()) == 'PC Caretaker Shovel')
  14039. {
  14040.  
  14041. lifeLeech = CalculateAttributeValue(inv.GetItemAttributeValue(attackAction.GetWeaponId() ,'lifesteal'));
  14042. if (npc.UsesVitality())
  14043. lifeLeech *= action.processedDmg.vitalityDamage;
  14044. else if (UsesEssence())
  14045. lifeLeech *= action.processedDmg.essenceDamage;
  14046. else
  14047. lifeLeech = 0;
  14048.  
  14049. if ( lifeLeech > 0 )
  14050. {
  14051. inv.PlayItemEffect( attackAction.GetWeaponId(), 'stab_attack' );
  14052. PlayEffect('drain_energy_caretaker_shovel');
  14053. GainStat(BCS_Vitality, lifeLeech);
  14054. }
  14055. }
  14056. }
  14057. }
  14058. }
  14059.  
  14060. public function SetHitReactTransScale(f : float) {hitReactTransScale = f;}
  14061. public function GetHitReactTransScale() : float
  14062. {
  14063. if ( ( (CNewNPC)slideTarget ).GetIsTranslationScaled() )
  14064. return hitReactTransScale;
  14065. else
  14066. return 1.f;
  14067. }
  14068.  
  14069.  
  14070.  
  14071.  
  14072.  
  14073. public function GetHorseWithInventory() : CNewNPC
  14074. {
  14075. return (CNewNPC)EntityHandleGet( horseWithInventory );
  14076. }
  14077. public function GetHorseCurrentlyMounted() : CNewNPC
  14078. {
  14079. return currentlyMountedHorse;
  14080. }
  14081.  
  14082. public function _SetHorseCurrentlyMounted( horse : CNewNPC )
  14083. {
  14084. currentlyMountedHorse = horse;
  14085. }
  14086.  
  14087. public function WasHorseRecentlySummoned() : bool
  14088. {
  14089. if ( horseSummonTimeStamp + 5.f > theGame.GetEngineTimeAsSeconds() )
  14090. return true;
  14091.  
  14092. return false;
  14093. }
  14094.  
  14095. private const var MOUNT_DISTANCE_CBT : float;
  14096. default MOUNT_DISTANCE_CBT = 3.0;
  14097.  
  14098. private const var MOUNT_ANGLE_CBT : float;
  14099. default MOUNT_ANGLE_CBT = 35.0;
  14100.  
  14101. private const var MOUNT_ANGLE_EXP : float;
  14102. default MOUNT_ANGLE_EXP = 45.0;
  14103.  
  14104. public function IsMountingHorseAllowed( optional alwaysAllowedInExploration : bool ) : bool
  14105. {
  14106. var angle : float;
  14107. var distance : float;
  14108.  
  14109. if( IsInsideHorseInteraction() )
  14110. {
  14111. angle = AngleDistance( thePlayer.rawPlayerHeading, VecHeading( thePlayer.horseInteractionSource.GetWorldPosition() - thePlayer.GetWorldPosition() ) );
  14112.  
  14113. if( thePlayer.IsInCombat() )
  14114. {
  14115. if( AbsF( angle ) < MOUNT_ANGLE_CBT )
  14116. {
  14117. distance = VecDistance( thePlayer.GetWorldPosition(), thePlayer.horseInteractionSource.GetWorldPosition() );
  14118.  
  14119. if( distance < MOUNT_DISTANCE_CBT )
  14120. {
  14121. return true;
  14122. }
  14123. else
  14124. {
  14125. return false;
  14126. }
  14127. }
  14128. else
  14129. {
  14130. return false;
  14131. }
  14132.  
  14133. }
  14134. else
  14135. {
  14136. if( alwaysAllowedInExploration )
  14137. {
  14138. return true;
  14139. }
  14140. else
  14141. {
  14142. if( AbsF( angle ) < MOUNT_ANGLE_EXP )
  14143. {
  14144. return true;
  14145. }
  14146. else
  14147. {
  14148. return false;
  14149. }
  14150. }
  14151. }
  14152. }
  14153. else
  14154. {
  14155. return false;
  14156. }
  14157. }
  14158.  
  14159. public function FollowActor( actor : CActor )
  14160. {
  14161. var l_aiTreeDecorator : CAIPlayerActionDecorator;
  14162. var l_aiTree_onFoot : CAIFollowSideBySideAction;
  14163. var l_aiTree_onHorse : CAIRiderFollowSideBySideAction;
  14164. var l_success : bool = false;
  14165.  
  14166. actor.AddTag( 'playerFollowing' );
  14167.  
  14168. if( thePlayer.IsUsingHorse() )
  14169. {
  14170. l_aiTree_onHorse = new CAIRiderFollowSideBySideAction in this;
  14171. l_aiTree_onHorse.OnCreated();
  14172.  
  14173. l_aiTree_onHorse.params.targetTag = 'playerFollowing';
  14174. }
  14175. else
  14176. {
  14177. l_aiTree_onFoot = new CAIFollowSideBySideAction in this;
  14178. l_aiTree_onFoot.OnCreated();
  14179.  
  14180. l_aiTree_onFoot.params.targetTag = 'playerFollowing';
  14181. }
  14182.  
  14183. l_aiTreeDecorator = new CAIPlayerActionDecorator in this;
  14184. l_aiTreeDecorator.OnCreated();
  14185. l_aiTreeDecorator.interruptOnInput = false;
  14186.  
  14187. if( thePlayer.IsUsingHorse() )
  14188. l_aiTreeDecorator.scriptedAction = l_aiTree_onHorse;
  14189. else
  14190. l_aiTreeDecorator.scriptedAction = l_aiTree_onFoot;
  14191.  
  14192. if( l_aiTreeDecorator )
  14193. l_success = ForceAIBehavior( l_aiTreeDecorator, BTAP_Emergency );
  14194. else if( thePlayer.IsUsingHorse() )
  14195. l_success = ForceAIBehavior( l_aiTree_onHorse, BTAP_Emergency );
  14196. else
  14197. l_success = ForceAIBehavior( l_aiTree_onFoot, BTAP_Emergency );
  14198.  
  14199. if ( l_success )
  14200. {
  14201. GetMovingAgentComponent().SetGameplayRelativeMoveSpeed( 0.0f );
  14202. }
  14203. }
  14204.  
  14205. public function SetCanFollowNpc( val : bool, actor : CActor ) { canFollowNpc = val; actorToFollow = actor; }
  14206. public function CanFollowNpc() : bool { return canFollowNpc; }
  14207. public function GetActorToFollow() : CActor { return actorToFollow; }
  14208.  
  14209.  
  14210.  
  14211.  
  14212.  
  14213.  
  14214.  
  14215. public function SetIsSwimming ( toggle : bool )
  14216. {
  14217. if( isSwimming != toggle )
  14218. {
  14219. thePlayer.substateManager.SetBehaviorParamBool( 'isSwimmingForOverlay', toggle );
  14220. isSwimming = toggle;
  14221. }
  14222. }
  14223.  
  14224.  
  14225.  
  14226.  
  14227.  
  14228.  
  14229.  
  14230. public function RepairItemUsingConsumable(item, consumable : SItemUniqueId) : bool
  14231. {
  14232. var curr, max, repairValue, itemValue, repairBonus, newDurability : float;
  14233.  
  14234.  
  14235. if(!inv.IsIdValid(item) || !inv.IsIdValid(consumable) || !inv.HasItemDurability(item))
  14236. return false;
  14237.  
  14238. curr = inv.GetItemDurability(item);
  14239. max = inv.GetItemMaxDurability(item);
  14240.  
  14241.  
  14242. if(curr > max)
  14243. return false;
  14244.  
  14245.  
  14246. if( (inv.IsItemAnyArmor(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_ARMOR)) ||
  14247. (inv.IsItemSilverSwordUsableByPlayer(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_SILVER)) ||
  14248. (inv.IsItemSteelSwordUsableByPlayer(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_STEEL)) )
  14249. {
  14250.  
  14251. itemValue = CalculateAttributeValue(inv.GetItemAttributeValue(consumable, 'durabilityRepairValue'));
  14252. if(itemValue <= 0)
  14253. {
  14254. LogAssert(false, "CR4Player.RepairItemUsingConsumable: consumable <<" + inv.GetItemName(consumable) + ">> has <=0 durabilityRepairValue!!!");
  14255. return false;
  14256. }
  14257. repairBonus = CalculateAttributeValue(inv.GetItemAttributeValue(consumable, 'durabilityBonusValue'));
  14258.  
  14259.  
  14260. repairValue = max * itemValue /100;
  14261.  
  14262.  
  14263.  
  14264. newDurability = MinF(max, curr + repairValue);
  14265.  
  14266. inv.SetItemDurabilityScript(item, newDurability);
  14267.  
  14268.  
  14269. inv.RemoveItem(consumable);
  14270.  
  14271. return true;
  14272. }
  14273. return false;
  14274. }
  14275.  
  14276.  
  14277.  
  14278.  
  14279.  
  14280.  
  14281.  
  14282.  
  14283.  
  14284.  
  14285. private function CheckDayNightCycle()
  14286. {
  14287. var time : GameTime;
  14288. var isNight : bool;
  14289.  
  14290.  
  14291. isNight = theGame.envMgr.IsNight();
  14292. if(prevDayNightIsNight != isNight)
  14293. {
  14294. if(isNight)
  14295. OnNightStarted();
  14296. else
  14297. OnDayStarted();
  14298.  
  14299. prevDayNightIsNight = isNight;
  14300. }
  14301.  
  14302.  
  14303. if(isNight)
  14304. time = theGame.envMgr.GetGameTimeTillNextDay();
  14305. else
  14306. time = theGame.envMgr.GetGameTimeTillNextNight();
  14307.  
  14308. AddGameTimeTimer('DayNightCycle', time);
  14309. }
  14310.  
  14311. timer function DayNightCycle(dt : GameTime, id : int)
  14312. {
  14313. CheckDayNightCycle();
  14314. }
  14315.  
  14316. event OnNightStarted()
  14317. {
  14318. var pam : W3PlayerAbilityManager;
  14319.  
  14320. if(CanUseSkill(S_Perk_01))
  14321. {
  14322. pam = (W3PlayerAbilityManager)abilityManager;
  14323. pam.SetPerk01Abilities(false, true);
  14324. }
  14325. }
  14326.  
  14327. event OnDayStarted()
  14328. {
  14329. var pam : W3PlayerAbilityManager;
  14330.  
  14331. if(CanUseSkill(S_Perk_01))
  14332. {
  14333. pam = (W3PlayerAbilityManager)abilityManager;
  14334. pam.SetPerk01Abilities(true, false);
  14335. }
  14336. }
  14337.  
  14338.  
  14339.  
  14340.  
  14341.  
  14342. public function ForceUnlockAllInputActions(alsoQuestLocks : bool)
  14343. {
  14344. if ( inputHandler )
  14345. inputHandler.ForceUnlockAllInputActions(alsoQuestLocks);
  14346. }
  14347.  
  14348. public function SetPrevRawLeftJoyRot()
  14349. {
  14350. prevRawLeftJoyRot = rawLeftJoyRot;
  14351. }
  14352.  
  14353. public function GetPrevRawLeftJoyRot() : float
  14354. {
  14355. return prevRawLeftJoyRot;
  14356. }
  14357.  
  14358. public function GetExplorationInputContext() : name
  14359. {
  14360. return explorationInputContext;
  14361. }
  14362.  
  14363. public function GetCombatInputContext() : name
  14364. {
  14365. return combatInputContext;
  14366. }
  14367.  
  14368.  
  14369.  
  14370.  
  14371.  
  14372. public function SetIsOnBoat(b : bool)
  14373. {
  14374. isOnBoat = b;
  14375. }
  14376.  
  14377. public function IsOnBoat() : bool
  14378. {
  14379. return isOnBoat;
  14380. }
  14381.  
  14382. public function IsInShallowWater() : bool
  14383. {
  14384. return isInShallowWater;
  14385. }
  14386.  
  14387. event OnEnterShallowWater()
  14388. {
  14389. if ( isInShallowWater )
  14390. return false;
  14391.  
  14392. isInShallowWater = true;
  14393. BlockAction( EIAB_Dodge,'ShallowWater', false, false, true );
  14394. BlockAction( EIAB_Sprint,'ShallowWater', false, false, true );
  14395. BlockAction( EIAB_Crossbow,'ShallowWater', false, false, true );
  14396. BlockAction( EIAB_Jump,'ShallowWater', false, false, true );
  14397. SetBehaviorVariable( 'shallowWater',1.0);
  14398. }
  14399. event OnExitShallowWater()
  14400. {
  14401. if ( !isInShallowWater )
  14402. return false;
  14403.  
  14404. isInShallowWater = false;
  14405. BlockAllActions('ShallowWater',false);
  14406. SetBehaviorVariable( 'shallowWater',0.0);
  14407. }
  14408.  
  14409. public function TestIsInSettlement() : bool
  14410. {
  14411. return IsInSettlement();
  14412. }
  14413.  
  14414.  
  14415.  
  14416.  
  14417.  
  14418.  
  14419. public function ProcessGlossaryImageOverride( defaultImage : string, uniqueTag : name ) : string
  14420. {
  14421. var size : int;
  14422. var i : int;
  14423.  
  14424. size = glossaryImageOverride.Size();
  14425.  
  14426. if( size == 0 )
  14427. return defaultImage;
  14428.  
  14429. for( i = 0; i < size; i += 1 )
  14430. {
  14431. if( glossaryImageOverride[i].uniqueTag == uniqueTag )
  14432. return glossaryImageOverride[i].imageFileName;
  14433.  
  14434. }
  14435.  
  14436. return defaultImage;
  14437. }
  14438.  
  14439.  
  14440. public function EnableGlossaryImageOverride( uniqueTag : name, imageFileName : string, enable : bool )
  14441. {
  14442. var imageData : SGlossaryImageOverride;
  14443. var size : int;
  14444. var i : int;
  14445.  
  14446. for( i = 0; i < glossaryImageOverride.Size(); i += 1 )
  14447. {
  14448. if( glossaryImageOverride[i].uniqueTag == uniqueTag )
  14449. {
  14450. glossaryImageOverride.Remove(glossaryImageOverride[i]);
  14451. }
  14452. }
  14453.  
  14454. if( enable )
  14455. {
  14456. if( IsNameValid(uniqueTag) && imageFileName != "" )
  14457. {
  14458. glossaryImageOverride.PushBack( SGlossaryImageOverride( uniqueTag, imageFileName ) );
  14459. }
  14460. }
  14461. }
  14462.  
  14463.  
  14464.  
  14465. public function SetWeatherDisplayDisabled( disable : bool )
  14466. {
  14467. disableWeatherDisplay = disable;
  14468. }
  14469.  
  14470. public function GetWeatherDisplayDisabled() : bool
  14471. {
  14472. return disableWeatherDisplay;
  14473. }
  14474.  
  14475.  
  14476.  
  14477.  
  14478.  
  14479. public function SetCurrentMonsterHuntInvestigationArea ( area : W3MonsterHuntInvestigationArea )
  14480. {
  14481. currentMonsterHuntInvestigationArea = area;
  14482. }
  14483.  
  14484.  
  14485.  
  14486.  
  14487.  
  14488.  
  14489. public function RememberCustomHead( headName : name )
  14490. {
  14491. rememberedCustomHead = headName;
  14492. }
  14493.  
  14494. public function GetRememberedCustomHead() : name
  14495. {
  14496. return rememberedCustomHead;
  14497. }
  14498.  
  14499. public function ClearRememberedCustomHead()
  14500. {
  14501. rememberedCustomHead = '';
  14502. }
  14503.  
  14504.  
  14505.  
  14506.  
  14507.  
  14508. public function CreateTutorialInput()
  14509. {
  14510. var prevInputHandler : CPlayerInput;
  14511.  
  14512. prevInputHandler = inputHandler;
  14513. inputHandler = new W3PlayerTutorialInput in this;
  14514. inputHandler.Initialize(false, prevInputHandler);
  14515.  
  14516. if(prevInputHandler)
  14517. delete prevInputHandler;
  14518. }
  14519.  
  14520. public function CreateInput()
  14521. {
  14522. var oldInputHandler : CPlayerInput;
  14523.  
  14524. oldInputHandler = inputHandler;
  14525. inputHandler = new CPlayerInput in this;
  14526. inputHandler.Initialize(false, oldInputHandler);
  14527. }
  14528.  
  14529. timer function TutorialSilverCombat(dt : float, id : int)
  14530. {
  14531. var i : int;
  14532. var actors : array<CActor>;
  14533.  
  14534. if(IsInCombat())
  14535. {
  14536. actors = GetNPCsAndPlayersInRange(20, 1000000, ,FLAG_ExcludePlayer + FLAG_OnlyAliveActors);
  14537. for(i=0; i<actors.Size(); i+=1)
  14538. {
  14539. if(actors[i] && IsRequiredAttitudeBetween(this, actors[i], true) && actors[i].UsesEssence())
  14540. {
  14541. FactsAdd("TutorialShowSilver");
  14542.  
  14543. RemoveTimer('TutorialSilverCombat');
  14544. break;
  14545. }
  14546. }
  14547. }
  14548. }
  14549.  
  14550. private saved var m_bossTag : name;
  14551.  
  14552. public function GetBossTag() : name
  14553. {
  14554. return m_bossTag;
  14555. }
  14556.  
  14557. public function SetBossTag( bossTag : name )
  14558. {
  14559. m_bossTag = bossTag;
  14560. }
  14561.  
  14562. private saved var m_usingCoatOfArms : bool; default m_usingCoatOfArms = false;
  14563.  
  14564. public function IsUsingCoatOfArms() : bool
  14565. {
  14566. return m_usingCoatOfArms;
  14567. }
  14568.  
  14569. public function SetUsingCoatOfArms( using : bool)
  14570. {
  14571. m_usingCoatOfArms = using;
  14572. }
  14573.  
  14574. private saved var m_initialTimeOut : float;
  14575. private saved var m_currentTimeOut : float;
  14576.  
  14577. public function GetInitialTimeOut() : float
  14578. {
  14579. return m_initialTimeOut;
  14580. }
  14581.  
  14582. public function SetInitialTimeOut( timeOut : float )
  14583. {
  14584. m_initialTimeOut = timeOut;
  14585. }
  14586.  
  14587. public function GetCurrentTimeOut() : float
  14588. {
  14589. return m_currentTimeOut;
  14590. }
  14591.  
  14592. public function SetCurrentTimeOut( timeOut : float )
  14593. {
  14594. m_currentTimeOut = timeOut;
  14595. }
  14596.  
  14597.  
  14598.  
  14599.  
  14600.  
  14601.  
  14602. timer function DelayedFinisherInputTimer(dt : float, id : int)
  14603. {
  14604.  
  14605.  
  14606. }
  14607.  
  14608. timer function RemoveFinisherCameraAnimationCheck(dt : float, id : int)
  14609. {
  14610. if ( !isInFinisher && !bLAxisReleased )
  14611. {
  14612. theGame.GetSyncAnimManager().OnRemoveFinisherCameraAnimation();
  14613. RemoveTimer( 'RemoveFinisherCameraAnimationCheck' );
  14614. }
  14615. }
  14616.  
  14617.  
  14618.  
  14619.  
  14620.  
  14621. timer function GameplayFactRemove(dt : float, timerId : int)
  14622. {
  14623. theGame.GameplayFactRemoveFromTimer(timerId);
  14624. }
  14625.  
  14626.  
  14627. timer function GiveStartingItems(dt : float, timerId : int)
  14628. {
  14629. var template : CEntityTemplate;
  14630. var invEntity : CInventoryComponent;
  14631. var entity : CEntity;
  14632. var items : array<SItemUniqueId>;
  14633. var id : SItemUniqueId;
  14634. var i : int;
  14635.  
  14636.  
  14637. if(inv)
  14638. {
  14639. inv.GetAllItems(items);
  14640. if(items.Size() <= 0)
  14641. {
  14642. return;
  14643. }
  14644. }
  14645. else
  14646. {
  14647. return;
  14648. }
  14649.  
  14650.  
  14651. template = (CEntityTemplate)LoadResource("geralt_inventory_release");
  14652. entity = theGame.CreateEntity(template, Vector(0,0,0));
  14653. invEntity = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  14654.  
  14655. invEntity.GetAllItems(items);
  14656. for(i=0; i<items.Size(); i+=1)
  14657. {
  14658. id = invEntity.GiveItemTo(inv, items[i], 0, false, true);
  14659. if ( inv.ItemHasTag(id,'Scabbard') )
  14660. {
  14661. inv.MountItem(id);
  14662. }
  14663. else if(!inv.IsItemFists(id) && inv.GetItemName(id) != 'Cat 1')
  14664. {
  14665. EquipItem(id);
  14666. }
  14667. else if(inv.IsItemSingletonItem(id))
  14668. {
  14669. inv.SingletonItemSetAmmo(id, inv.SingletonItemGetMaxAmmo(id));
  14670. }
  14671. }
  14672.  
  14673. entity.Destroy();
  14674.  
  14675.  
  14676. RemoveTimer('GiveStartingItems');
  14677. }
  14678.  
  14679.  
  14680.  
  14681. timer function Debug_GiveTestingItems(dt : float, optional id : int)
  14682. {
  14683. var template : CEntityTemplate;
  14684. var invTesting : CInventoryComponent;
  14685. var entity : CEntity;
  14686. var items : array<SItemUniqueId>;
  14687. var i : int;
  14688. var slot : EEquipmentSlots;
  14689.  
  14690.  
  14691. if(inv)
  14692. {
  14693. inv.GetAllItems(items);
  14694. if(items.Size() <= 0)
  14695. {
  14696. return;
  14697. }
  14698. }
  14699. else
  14700. {
  14701. return;
  14702. }
  14703.  
  14704. template = (CEntityTemplate)LoadResource("geralt_inventory_internal");
  14705. entity = theGame.CreateEntity(template, Vector(0,0,0));
  14706. invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  14707. invTesting.GiveAllItemsTo(inv, true);
  14708. entity.Destroy();
  14709.  
  14710.  
  14711. RemoveTimer('Debug_GiveTestingItems');
  14712.  
  14713.  
  14714. inv.GetAllItems(items);
  14715.  
  14716. for(i=0; i<items.Size(); i+=1)
  14717. {
  14718. if( inv.IsItemCrossbow(items[i]) || inv.IsItemBomb(items[i]) )
  14719. {
  14720. slot = inv.GetSlotForItemId(items[i]);
  14721. EquipItem(items[i], slot);
  14722.  
  14723. if( (W3PlayerWitcher)this && inv.IsItemCrossbow(items[i]) )
  14724. GetWitcherPlayer().SelectQuickslotItem(slot);
  14725. }
  14726. else if(inv.IsItemBolt(items[i]))
  14727. {
  14728. slot = inv.GetSlotForItemId(items[i]);
  14729. EquipItem(items[i], slot);
  14730. }
  14731.  
  14732. if(inv.IsItemSingletonItem(items[i]))
  14733. {
  14734. inv.SingletonItemSetAmmo(items[i], inv.SingletonItemGetMaxAmmo(items[i]));
  14735. }
  14736. }
  14737. }
  14738.  
  14739.  
  14740. timer function Debug_RemoveTestingItems(dt : float, id : int)
  14741. {
  14742. var template : CEntityTemplate;
  14743. var entity : CEntity;
  14744. var invTesting : CInventoryComponent;
  14745. var ids : array<SItemUniqueId>;
  14746. var i : int;
  14747.  
  14748. template = (CEntityTemplate)LoadResource("geralt_inventory_internal");
  14749. entity = theGame.CreateEntity(template, Vector(0,0,0));
  14750. invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  14751. invTesting.GetAllItems(ids);
  14752.  
  14753. for(i=0; i<ids.Size(); i+=1)
  14754. inv.RemoveItemByName(invTesting.GetItemName(ids[i]), invTesting.GetItemQuantity(ids[i]));
  14755.  
  14756. entity.Destroy();
  14757. RemoveTimer('Debug_RemoveTestingItems');
  14758. }
  14759.  
  14760. timer function Debug_DelayedConsoleCommand(dt : float, id : int)
  14761. {
  14762.  
  14763. inv.AddAnItem('Boots 2 schematic');
  14764. }
  14765.  
  14766. function DBG_SkillSlots()
  14767. {
  14768. ((W3PlayerAbilityManager)abilityManager).DBG_SkillSlots();
  14769. }
  14770.  
  14771.  
  14772.  
  14773.  
  14774.  
  14775. public final function SetPadBacklightColor(r, g, b : int)
  14776. {
  14777. var padBacklightColor : Vector;
  14778.  
  14779. padBacklightColor.X = r / 255;
  14780. padBacklightColor.Y = g / 255;
  14781. padBacklightColor.Z = b / 255;
  14782.  
  14783. SetBacklightColor(padBacklightColor);
  14784. }
  14785.  
  14786. public final function SetPadBacklightColorFromSign(signType : ESignType)
  14787. {
  14788. LogPS4Light("SetPadBacklightColorFromSign... " + signType);
  14789.  
  14790. switch(signType)
  14791. {
  14792. case ST_Yrden: SetPadBacklightColor( 200 , 81 , 255 ); break;
  14793. case ST_Quen: SetPadBacklightColor( 255 , 205 , 68 ); break;
  14794. case ST_Igni: SetPadBacklightColor( 255 , 79 , 10 ); break;
  14795. case ST_Axii: SetPadBacklightColor( 255 , 255 , 255 ); break;
  14796. case ST_Aard: SetPadBacklightColor( 158 , 214 , 255 ); break;
  14797. }
  14798. }
  14799.  
  14800. timer function ResetPadBacklightColorTimer(dt : float, id : int)
  14801. {
  14802. ResetPadBacklightColor();
  14803. }
  14804.  
  14805. public final function ResetPadBacklightColor(optional skipHeldWeapon : bool)
  14806. {
  14807. var weapons : array<SItemUniqueId>;
  14808. var sword : CWitcherSword;
  14809. var healthPercentage : float;
  14810. var tmpBacklight : Vector;
  14811.  
  14812. if(!skipHeldWeapon)
  14813. {
  14814. weapons = inv.GetHeldWeapons();
  14815.  
  14816.  
  14817. if(weapons.Size() > 0)
  14818. {
  14819. sword = (CWitcherSword)inv.GetItemEntityUnsafe(weapons[0]);
  14820. if(sword)
  14821. {
  14822. tmpBacklight.X = sword.padBacklightColor.X / 255.0f;
  14823. tmpBacklight.Y = sword.padBacklightColor.Y / 255.0f;
  14824. tmpBacklight.Z = sword.padBacklightColor.Z / 255.0f;
  14825. tmpBacklight.W = 1.0f;
  14826. SetBacklightColor( tmpBacklight );
  14827. LogPS4Light("Setting light from sword template: " + NoTrailZeros(sword.padBacklightColor.X) + ", " + NoTrailZeros(sword.padBacklightColor.Y) + ", " + NoTrailZeros(sword.padBacklightColor.Z) );
  14828. return;
  14829. }
  14830. }
  14831. }
  14832.  
  14833. healthPercentage = GetStatPercents( BCS_Vitality );
  14834. SetBacklightFromHealth( healthPercentage );
  14835. LogPS4Light("Setting light from health, " + NoTrailZeros(RoundMath(healthPercentage*100)) + "%");
  14836. }
  14837.  
  14838.  
  14839.  
  14840. event OnOpenningDoor()
  14841. {
  14842. if( !thePlayer.IsUsingHorse() )
  14843. RaiseEvent('OpenDoor');
  14844. }
  14845.  
  14846. public final function SetLoopingCameraShakeAnimName( n : name )
  14847. {
  14848. loopingCameraShakeAnimName = n;
  14849. }
  14850.  
  14851. public var loopingCameraShakeAnimName : name;
  14852. timer function RemoveQuestCameraShakeTimer( dt : float , id : int)
  14853. {
  14854. RemoveQuestCameraShake( loopingCameraShakeAnimName );
  14855. }
  14856.  
  14857. public function RemoveQuestCameraShake( animName : name )
  14858. {
  14859. var camera : CCustomCamera = theGame.GetGameCamera();
  14860. var animation : SCameraAnimationDefinition;
  14861.  
  14862. camera.StopAnimation( animName );
  14863. }
  14864.  
  14865. public function GetCameraPadding() : float
  14866. {
  14867. if( theGame.IsFocusModeActive() )
  14868. {
  14869. return 0.25;
  14870. }
  14871. else
  14872. {
  14873. return 0.02f;
  14874. }
  14875. }
  14876.  
  14877. public function IsPerformingPhaseChangeAnimation() : bool { return isPerformingPhaseChangeAnimation; }
  14878. public function SetIsPerformingPhaseChangeAnimation( val : bool ) { isPerformingPhaseChangeAnimation = val; }
  14879.  
  14880. private function DealCounterDamageToOlgierd()
  14881. {
  14882. var damage : W3DamageAction;
  14883.  
  14884. damage = new W3DamageAction in this;
  14885.  
  14886. damage.Initialize( thePlayer.GetTarget(), thePlayer.GetTarget(), NULL, this, EHRT_None, CPS_Undefined, false, false, false, true );
  14887. damage.AddDamage( theGame.params.DAMAGE_NAME_DIRECT, thePlayer.GetTarget().GetStatMax( BCS_Vitality ) * 3 / 100 );
  14888. theGame.damageMgr.ProcessAction( damage );
  14889.  
  14890. delete damage;
  14891. }
  14892.  
  14893. timer function PlayDelayedCounterDamageEffect( dt : float, id : int )
  14894. {
  14895. thePlayer.GetTarget().PlayEffect( 'olgierd_energy_blast' );
  14896. }
  14897.  
  14898.  
  14899. public function SetTestAdjustRequestedMovementDirection( val : bool )
  14900. {
  14901. testAdjustRequestedMovementDirection = val;
  14902. }
  14903.  
  14904. event OnVisualDebug( frame : CScriptedRenderFrame, flag : EShowFlags )
  14905. {
  14906. var boneFollow : int;
  14907. var bonePosition : Vector;
  14908. var yrdenEntity : W3YrdenEntity;
  14909.  
  14910. substateManager.OnVisualDebug( frame, flag );
  14911.  
  14912. boneFollow = thePlayer.GetBoneIndex( 'Reference' );
  14913. bonePosition = MatrixGetTranslation( thePlayer.GetBoneWorldMatrixByIndex( boneFollow ) );
  14914. frame.DrawText( "R", bonePosition, Color( 50, 200, 70 ) );
  14915.  
  14916.  
  14917. boneFollow = thePlayer.GetBoneIndex( 'Trajectory' );
  14918. bonePosition = MatrixGetTranslation( thePlayer.GetBoneWorldMatrixByIndex( boneFollow ) );
  14919. frame.DrawSphere( bonePosition, 0.1f, Color( 200, 50, 70 ) );
  14920. frame.DrawText( "T", bonePosition, Color( 200, 50, 70 ) );
  14921.  
  14922.  
  14923.  
  14924.  
  14925. yrdenEntity = (W3YrdenEntity)GetWitcherPlayer().GetSignEntity(ST_Yrden);
  14926. yrdenEntity.OnVisualDebug(frame, flag, false);
  14927.  
  14928. return true;
  14929. }
  14930.  
  14931. timer function PotDrinkTimer(dt : float, id : int)
  14932. {
  14933. inputHandler.PotDrinkTimer(false);
  14934. }
  14935.  
  14936. public function SetIsHorseRacing( val : bool )
  14937. {
  14938. isHorseRacing = val;
  14939. }
  14940.  
  14941. public function GetIsHorseRacing() : bool
  14942. {
  14943. return isHorseRacing;
  14944. }
  14945.  
  14946. public function SetHorseCombatSlowMo( val : bool )
  14947. {
  14948. horseCombatSlowMo = val;
  14949. }
  14950.  
  14951. public function GetHorseCombatSlowMo() : bool
  14952. {
  14953. return horseCombatSlowMo;
  14954. }
  14955.  
  14956. public function SetItemsPerLevelGiven( id : int )
  14957. {
  14958. itemsPerLevelGiven[id] = true;
  14959. }
  14960.  
  14961. private function AddItemPerLevelList()
  14962. {
  14963. var i : int;
  14964.  
  14965. itemsPerLevel.Clear();
  14966. itemsPerLevel.PushBack('O');
  14967. itemsPerLevel.PushBack('No Mans Land sword 2');
  14968. itemsPerLevel.PushBack('No Mans Land sword 3');
  14969. itemsPerLevel.PushBack('Silver sword 2');
  14970. itemsPerLevel.PushBack('Boots 01');
  14971. itemsPerLevel.PushBack('Novigraadan sword 2');
  14972. itemsPerLevel.PushBack('Light armor 01');
  14973. itemsPerLevel.PushBack('Heavy boots 01');
  14974. itemsPerLevel.PushBack('Nilfgaardian sword 3');
  14975. itemsPerLevel.PushBack('Silver sword 3');
  14976. itemsPerLevel.PushBack('Heavy gloves 01');
  14977. itemsPerLevel.PushBack('Skellige sword 2');
  14978. itemsPerLevel.PushBack('Heavy pants 01');
  14979. itemsPerLevel.PushBack('Silver sword 4');
  14980. itemsPerLevel.PushBack('No Mans Land sword 4');
  14981. itemsPerLevel.PushBack('Heavy armor 01');
  14982. itemsPerLevel.PushBack('Heavy boots 02');
  14983. itemsPerLevel.PushBack('Skellige sword 3');
  14984. itemsPerLevel.PushBack('Silver sword 5');
  14985. itemsPerLevel.PushBack('Heavy pants 02');
  14986. itemsPerLevel.PushBack('Heavy gloves 02');
  14987. itemsPerLevel.PushBack('Heavy gloves 02');
  14988. itemsPerLevel.PushBack('Heavy armor 02');
  14989. itemsPerLevel.PushBack('Scoiatael sword 1');
  14990.  
  14991. if ( itemsPerLevelGiven.Size() < 49 )
  14992. {
  14993. itemsPerLevelGiven.Clear();
  14994. for (i = 0; i < itemsPerLevel.Size(); i += 1) { itemsPerLevelGiven.PushBack( false ); }
  14995. }
  14996. }
  14997.  
  14998.  
  14999. public function DealDamageToBoat( dmg : float, index : int, optional globalHitPos : Vector )
  15000. {
  15001. var boat : CBoatDestructionComponent;
  15002.  
  15003. if(usedVehicle)
  15004. {
  15005. boat = (CBoatDestructionComponent) usedVehicle.GetComponentByClassName( 'CBoatDestructionComponent' );
  15006. if( boat )
  15007. {
  15008. boat.DealDamage( dmg, index, globalHitPos );
  15009. }
  15010. }
  15011. }
  15012.  
  15013.  
  15014.  
  15015.  
  15016.  
  15017. public function OnStartTeleportingPlayerToPlayableArea()
  15018. {
  15019. var FADEOUT_INTERVAL : float = 0.5;
  15020.  
  15021.  
  15022. if ( thePlayer.IsUsingHorse() )
  15023. {
  15024. if ( thePlayer.GetUsedHorseComponent().OnCheckHorseJump() )
  15025. {
  15026. thePlayer.GetUsedHorseComponent().SetCanTakeDamageFromFalling( false );
  15027. }
  15028. }
  15029.  
  15030. if ( thePlayer.IsActionAllowed( EIAB_FastTravel ) )
  15031. {
  15032. OnOpenMapToLetPlayerGoBackToPlayableArea();
  15033. }
  15034. else
  15035. {
  15036. theGame.FadeOutAsync( FADEOUT_INTERVAL );
  15037. thePlayer.AddTimer( 'BorderTeleportFadeOutTimer', FADEOUT_INTERVAL, false );
  15038. }
  15039. }
  15040.  
  15041. timer function BorderTeleportFadeOutTimer( dt : float, id : int )
  15042. {
  15043. OnTeleportPlayerToPlayableArea( false );
  15044. }
  15045.  
  15046. public function OnOpenMapToLetPlayerGoBackToPlayableArea()
  15047. {
  15048. var initData : W3MapInitData;
  15049.  
  15050. initData = new W3MapInitData in this;
  15051. initData.SetTriggeredExitEntity( true );
  15052. initData.ignoreSaveSystem = true;
  15053. initData.setDefaultState('FastTravel');
  15054. theGame.RequestMenuWithBackground( 'MapMenu', 'CommonMenu', initData );
  15055. }
  15056.  
  15057. public function OnTeleportPlayerToPlayableArea( afterClosingMap : bool )
  15058. {
  15059. var BLACKSCREEN_INTERVAL : float = 0.1;
  15060. var manager : CCommonMapManager = theGame.GetCommonMapManager();
  15061.  
  15062. thePlayer.TeleportWithRotation( manager.GetBorderTeleportPosition(), manager.GetBorderTeleportRotation() );
  15063. thePlayer.AddTimer( 'BorderTeleportFadeInTimer', BLACKSCREEN_INTERVAL, false );
  15064.  
  15065. theGame.FadeOutAsync( 0 );
  15066. theGame.SetFadeLock('PlayerTeleportation');
  15067. }
  15068.  
  15069. timer function BorderTeleportFadeInTimer( dt : float, id : int )
  15070. {
  15071. theGame.ResetFadeLock('PlayerTeleportation');
  15072. theGame.FadeOutAsync( 0 );
  15073. theGame.FadeInAsync( 2.0f );
  15074. }
  15075.  
  15076. public final function SetLastInstantKillTime(g : GameTime)
  15077. {
  15078. lastInstantKillTime = g;
  15079. }
  15080.  
  15081.  
  15082.  
  15083.  
  15084.  
  15085. timer function TestTimer(dt : float, id : int )
  15086. {
  15087. LogChannel('asdf', "asdf");
  15088. theGame.FadeOutAsync( 5 );
  15089. }
  15090.  
  15091. public final function Debug_ReleaseCriticalStateSaveLocks()
  15092. {
  15093. effectManager.Debug_ReleaseCriticalStateSaveLocks();
  15094. }
  15095.  
  15096. timer function Debug_SpamSpeed(dt : float, id : int)
  15097. {
  15098. if(currentlyMountedHorse)
  15099. {
  15100. LogSpeed("curr player's horse speed: " + NoTrailZeros(currentlyMountedHorse.GetMovingAgentComponent().GetSpeed())) ;
  15101. }
  15102. else
  15103. {
  15104. LogSpeed("curr player speed: " + NoTrailZeros(GetMovingAgentComponent().GetSpeed())) ;
  15105. }
  15106. }
  15107.  
  15108. timer function RemoveInstantKillSloMo(dt : float, id : int)
  15109. {
  15110. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_InstantKill) );
  15111. }
  15112.  
  15113. timer function RemoveForceFinisher(dt : float, id : int)
  15114. {
  15115. forceFinisher = false;
  15116. }
  15117.  
  15118. public final function Debug_ClearAllActionLocks(optional action : EInputActionBlock, optional all : bool)
  15119. {
  15120. inputHandler.Debug_ClearAllActionLocks(action, all);
  15121. }
  15122.  
  15123. function OnFocusedCameraBlendBegin() {}
  15124. function OnFocusedCameraBlendUpdate( progress : float ) {}
  15125. function OnFocusedCameraBlendEnd() {}
  15126.  
  15127. public function GetEtherealCount() : int { return etherealCount; }
  15128. public function IncrementEtherealCount()
  15129. {
  15130. etherealCount += 1;
  15131. if( etherealCount == 6 )
  15132. ResetEtherealCount();
  15133. }
  15134. public function ResetEtherealCount() { etherealCount = 0; }
  15135.  
  15136. public function SetInsideDiveAttackArea( val : bool ) { insideDiveAttackArea = val; }
  15137. public function IsInsideDiveAttackArea() : bool { return insideDiveAttackArea; }
  15138. public function SetDiveAreaNumber( val : int ) { diveAreaNumber = val; }
  15139. public function GetDiveAreaNumber() : int { return diveAreaNumber; }
  15140.  
  15141.  
  15142.  
  15143. public function InitPhantomWeaponMgr()
  15144. {
  15145. if( !phantomWeaponMgr )
  15146. {
  15147. phantomWeaponMgr = new CPhantomWeaponManager in this;
  15148. phantomWeaponMgr.Init( this.GetInventory() );
  15149. }
  15150. }
  15151.  
  15152. public function DestroyPhantomWeaponMgr()
  15153. {
  15154. if( phantomWeaponMgr )
  15155. {
  15156. delete phantomWeaponMgr;
  15157. }
  15158. }
  15159.  
  15160. public function GetPhantomWeaponMgr() : CPhantomWeaponManager
  15161. {
  15162. if( phantomWeaponMgr )
  15163. {
  15164. return phantomWeaponMgr;
  15165. }
  15166. else
  15167. {
  15168. return NULL;
  15169. }
  15170. }
  15171.  
  15172. public timer function DischargeWeaponAfter( td : float, id : int )
  15173. {
  15174. GetPhantomWeaponMgr().DischargeWeapon();
  15175. }
  15176.  
  15177.  
  15178.  
  15179.  
  15180. private var forcedFinisherVictim : CActor;
  15181.  
  15182. timer function PerformFinisher( time : float , id : int )
  15183. {
  15184. var combatTarget : CActor;
  15185. var i : int;
  15186.  
  15187. combatTarget = thePlayer.GetTarget();
  15188.  
  15189. if( combatTarget )
  15190. {
  15191. combatTarget.Kill( 'AutoFinisher', false, thePlayer );
  15192. thePlayer.SetFinisherVictim( combatTarget );
  15193. forcedFinisherVictim = combatTarget;
  15194. thePlayer.CleanCombatActionBuffer();
  15195. thePlayer.OnBlockAllCombatTickets( true );
  15196. moveTargets = thePlayer.GetMoveTargets();
  15197.  
  15198. for( i = 0; i < moveTargets.Size(); i += 1 )
  15199. {
  15200. if( combatTarget != moveTargets[i] )
  15201. moveTargets[i].SignalGameplayEvent( 'InterruptChargeAttack' );
  15202. }
  15203.  
  15204. if( theGame.GetInGameConfigWrapper().GetVarValue( 'Gameplay', 'AutomaticFinishersEnabled' ) == "true" )
  15205. combatTarget.AddAbility( 'ForceFinisher', false );
  15206.  
  15207. if( combatTarget.HasTag( 'ForceFinisher' ) )
  15208. combatTarget.AddAbility( 'ForceFinisher', false );
  15209.  
  15210. combatTarget.SignalGameplayEvent( 'ForceFinisher' );
  15211.  
  15212. thePlayer.FindMoveTarget();
  15213.  
  15214. thePlayer.AddTimer( 'SignalFinisher', 0.2, false );
  15215. }
  15216. }
  15217.  
  15218. timer function SignalFinisher( time : float , id : int )
  15219. {
  15220. forcedFinisherVictim.SignalGameplayEvent( 'Finisher' );
  15221. forcedFinisherVictim = NULL;
  15222. }
  15223. }
  15224.  
  15225. exec function ttt()
  15226. {
  15227. thePlayer.AddTimer( 'TestTimer', 5, false );
  15228. }
  15229.  
  15230.  
Add Comment
Please, Sign In to add comment