Guest User

Nacho's Script Merger

a guest
Jul 19th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 49.82 KB | None | 0 0
  1. /***********************************************************************/
  2. /** © 2015 CD PROJEKT S.A. All rights reserved.
  3. /** THE WITCHER® is a trademark of CD PROJEKT S. A.
  4. /** The Witcher game is based on the prose of Andrzej Sapkowski.
  5. /***********************************************************************/
  6. statemachine abstract import class CR4Player extends CPlayer
  7. {
  8.  
  9. protected var pcGamePlayInitialized : bool;
  10.  
  11.  
  12. private var pcMode : bool;
  13. default pcMode = true;
  14.  
  15.  
  16. protected saved var weaponHolster : WeaponHolster;
  17. public var rangedWeapon : Crossbow;
  18. public var crossbowDontPopStateHack : bool; default crossbowDontPopStateHack = false;
  19.  
  20. private var hitReactTransScale : float;
  21.  
  22. private var bIsCombatActionAllowed : bool;
  23. private var currentCombatAction : EBufferActionType;
  24.  
  25. private var uninterruptedHitsCount : int;
  26. private var uninterruptedHitsCameraStarted : bool;
  27. private var uninterruptedHitsCurrentCameraEffect : name;
  28.  
  29. private var counterTimestamps : array<EngineTime>;
  30.  
  31. private var hitReactionEffect : bool;
  32.  
  33. private var lookAtPosition : Vector;
  34. private var orientationTarget : EOrientationTarget;
  35. private var customOrientationTarget : EOrientationTarget;
  36. protected var customOrientationStack : array<SCustomOrientationParams>;
  37.  
  38. public var delayOrientationChange : bool;
  39. protected var delayCameraOrientationChange : bool;
  40. private var actionType : int;
  41. private var customOrientationStackIndex : int;
  42.  
  43. private var emptyMoveTargetTimer : float;
  44.  
  45. private var onlyOneEnemyLeft : bool;
  46.  
  47. public var isInFinisher : bool;
  48. private var finisherTarget : CGameplayEntity;
  49.  
  50. private var combatStance : EPlayerCombatStance;
  51.  
  52. public var approachAttack : int;
  53. default approachAttack = 1;
  54. protected var specialAttackCamera : bool;
  55.  
  56. private var specialAttackTimeRatio : float;
  57.  
  58. public saved var itemsPerLevel : array<name>;
  59. public var itemsPerLevelGiven : array<bool>;
  60.  
  61. private var playerTickTimerPhase : int;
  62. default playerTickTimerPhase = 0;
  63.  
  64. protected var evadeHeading : float;
  65.  
  66. public var vehicleCbtMgrAiming : bool;
  67.  
  68. public var specialHeavyChargeDuration : float;
  69. public var specialHeavyStartEngineTime : EngineTime;
  70. public var playedSpecialAttackMissingResourceSound : bool;
  71. public function SetPlayedSpecialAttackMissingResourceSound(b : bool) {playedSpecialAttackMissingResourceSound = b;}
  72.  
  73. public var counterCollisionGroupNames : array<name>;
  74.  
  75. public saved var lastInstantKillTime : GameTime;
  76.  
  77.  
  78. private var noSaveLockCombatActionName : string; default noSaveLockCombatActionName = 'combat_action';
  79. private var noSaveLockCombatAction : int;
  80. private var deathNoSaveLock : int;
  81. private var noSaveLock : int;
  82.  
  83.  
  84. protected saved var newGamePlusInitialized : bool;
  85. default newGamePlusInitialized = false;
  86.  
  87.  
  88. protected var BufferAllSteps : bool;
  89. protected var BufferCombatAction : EBufferActionType;
  90. protected var BufferButtonStage : EButtonStage;
  91.  
  92. default BufferAllSteps = false;
  93. default customOrientationTarget = OT_None;
  94. default hitReactionEffect = true;
  95. default uninterruptedHitsCount = 0;
  96. default uninterruptedHitsCameraStarted = false;
  97. default customOrientationStackIndex = -1;
  98.  
  99.  
  100. private var keepRequestingCriticalAnimStart : bool;
  101.  
  102. default keepRequestingCriticalAnimStart = false;
  103.  
  104.  
  105. private var currentCustomAction : EPlayerExplorationAction;
  106. public var substateManager : CExplorationStateManager;
  107. protected var isOnBoat : bool;
  108. protected var isInShallowWater : bool;
  109. public var medallion : W3MedallionFX;
  110. protected var lastMedallionEffect : float;
  111. private var isInRunAnimation : bool;
  112. public var interiorTracker :CPlayerInteriorTracker;
  113. public var m_SettlementBlockCanter : int;
  114.  
  115.  
  116.  
  117. private var fistFightMinigameEnabled : bool;
  118. private var isFFMinigameToTheDeath : bool;
  119. private var FFMinigameEndsithBS : bool;
  120. public var fistFightTeleportNode : CNode;
  121. public var isStartingFistFightMinigame : bool;
  122. public var GeraltMaxHealth : float;
  123. public var fistsItems : array< SItemUniqueId >;
  124.  
  125. default FFMinigameEndsithBS = false;
  126. default fistFightMinigameEnabled = false;
  127. default isFFMinigameToTheDeath = false;
  128.  
  129.  
  130. private var gwintAiDifficulty : EGwintDifficultyMode; default gwintAiDifficulty = EGDM_Easy;
  131. private var gwintAiAggression : EGwintAggressionMode; default gwintAiAggression = EGAM_Defensive;
  132. private var gwintMinigameState : EMinigameState; default gwintMinigameState = EMS_None;
  133.  
  134.  
  135. import private var horseWithInventory : EntityHandle;
  136. private var currentlyMountedHorse : CNewNPC;
  137. private var horseSummonTimeStamp : float;
  138. private saved var isHorseRacing : bool;
  139. private var horseCombatSlowMo : bool;
  140. default isHorseRacing = false;
  141. default horseCombatSlowMo = true;
  142.  
  143.  
  144. private var HudMessages : array <string>;
  145. protected var fShowToLowStaminaIndication : float;
  146. public var showTooLowAdrenaline : bool;
  147. private var HAXE3Container : W3Container;
  148. private var HAXE3bAutoLoot: bool;
  149. private var bShowHud : bool;
  150. private var dodgeFeedbackTarget : CActor;
  151.  
  152. default HAXE3bAutoLoot = false;
  153. default fShowToLowStaminaIndication = 0.0f;
  154. default bShowHud = true;
  155.  
  156. saved var displayedQuestsGUID : array< CGUID >;
  157. saved var rewardsMultiplier : array< SRewardMultiplier >;
  158. saved var glossaryImageOverride : array< SGlossaryImageOverride >;
  159.  
  160.  
  161. private var prevRawLeftJoyRot : float;
  162. protected var explorationInputContext : name;
  163. protected var combatInputContext : name;
  164. protected var combatFistsInputContext : name;
  165.  
  166.  
  167. private var isInsideInteraction : bool;
  168. private var isInsideHorseInteraction : bool;
  169. public var horseInteractionSource : CEntity;
  170. public var nearbyLockedContainersNoKey : array<W3LockableEntity>;
  171.  
  172.  
  173. private var bMoveTargetChangeAllowed : bool; default bMoveTargetChangeAllowed = true;
  174. private var moveAdj : CMovementAdjustor;
  175. private var defaultLocomotionController : CR4LocomotionPlayerControllerScript;
  176.  
  177.  
  178. private var canFollowNpc : bool;
  179. private var actorToFollow : CActor;
  180. public var terrainPitch : float;
  181. public var steepSlopeNormalPitch : float; default steepSlopeNormalPitch = 65.f;
  182. public var disableSprintTerrainPitch : float; default disableSprintTerrainPitch = 54.f;
  183. private var submergeDepth : float;
  184.  
  185. private var m_useSelectedItemIfSpawned : bool; default m_useSelectedItemIfSpawned = false;
  186.  
  187.  
  188. var navQuery : CNavigationReachabilityQueryInterface;
  189.  
  190.  
  191. public saved var rememberedCustomHead : name;
  192.  
  193.  
  194. public saved var disableWeatherDisplay : bool;
  195.  
  196.  
  197. public saved var proudWalk : bool;
  198. private var etherealCount : int;
  199. default etherealCount = 0;
  200.  
  201.  
  202. public saved var injuredWalk : bool;
  203. public saved var tiedWalk : bool;
  204. private var insideDiveAttackArea : bool;
  205. default insideDiveAttackArea = false;
  206. private var diveAreaNumber : int;
  207. default diveAreaNumber = -1;
  208.  
  209.  
  210. private var flyingBossCamera : bool;
  211. default flyingBossCamera = false;
  212.  
  213. public function SetFlyingBossCamera( val : bool ) { flyingBossCamera = val; }
  214. public function GetFlyingBossCamera() : bool { return flyingBossCamera; }
  215.  
  216.  
  217. public saved var upscaledTooltipState : bool;
  218. default upscaledTooltipState = false;
  219.  
  220.  
  221. private var phantomWeaponMgr : CPhantomWeaponManager;
  222.  
  223.  
  224.  
  225. function EnablePCMode( flag : bool )
  226. {
  227. pcMode = flag;
  228. }
  229.  
  230. public function IsPCModeEnabled() : bool
  231. {
  232. return pcMode && theInput.LastUsedPCInput();
  233. }
  234.  
  235. public function ShouldUsePCModeTargeting() : bool
  236. {
  237. return IsPCModeEnabled() && !lastAxisInputIsMovement;
  238. }
  239.  
  240. public function SetDodgeFeedbackTarget( target : CActor )
  241. {
  242. dodgeFeedbackTarget = target;
  243. }
  244.  
  245. public function GetDodgeFeedbackTarget() : CActor
  246. {
  247. return dodgeFeedbackTarget;
  248. }
  249.  
  250. public function SetSubmergeDepth( depth : float )
  251. {
  252. submergeDepth = depth;
  253. }
  254.  
  255. public function GetSubmergeDepth() : float
  256. {
  257. return submergeDepth;
  258. }
  259.  
  260.  
  261. editable var delayBetweenIllusionOneliners : float;
  262.  
  263. hint delayBetweenIllusionOneliners = "delay in secs between oneliners about illusionary objects";
  264.  
  265. default delayBetweenIllusionOneliners = 5;
  266.  
  267.  
  268. private var battlecry_timeForNext : float;
  269. private var battlecry_delayMin : float; default battlecry_delayMin = 15;
  270. private var battlecry_delayMax : float; default battlecry_delayMax = 60;
  271. private var battlecry_lastTry : name;
  272.  
  273.  
  274. private var previousWeather : name;
  275. private var previousRainStrength : float;
  276.  
  277.  
  278. protected var receivedDamageInCombat : bool;
  279. protected var prevDayNightIsNight : bool;
  280. public var failedFundamentalsFirstAchievementCondition : bool;
  281.  
  282. private var spawnedTime : float;
  283.  
  284. public var currentMonsterHuntInvestigationArea : W3MonsterHuntInvestigationArea;
  285.  
  286. private var isPerformingPhaseChangeAnimation : bool;
  287. default isPerformingPhaseChangeAnimation = false;
  288.  
  289. default receivedDamageInCombat = false;
  290.  
  291.  
  292. public var playerMode : W3PlayerMode;
  293.  
  294.  
  295. protected saved var selectedItemId : SItemUniqueId;
  296. protected saved var blockedRadialSlots : array < SRadialSlotDef >;
  297.  
  298.  
  299. public var enemyCollectionDist : float;
  300. public var findMoveTargetDistMin : float;
  301. public var findMoveTargetDistMax : float;
  302. private var findMoveTargetScaledFrame : float;
  303. public var interactDist : float;
  304. protected var bCanFindTarget : bool;
  305. private var bIsConfirmingEmptyTarget : bool;
  306. private var displayTarget : CGameplayEntity;
  307. private var isShootingFriendly : bool;
  308.  
  309. default findMoveTargetDistMax = 18.f;
  310. default findMoveTargetScaledFrame = 0.5f;
  311. default interactDist = 3.5f;
  312.  
  313.  
  314. private var currentSelectedTarget : CActor;
  315. private var selectedTargetToConfirm : CActor;
  316. private var bConfirmTargetTimerIsEnabled : bool;
  317.  
  318.  
  319. public saved var thrownEntityHandle : EntityHandle;
  320. private var isThrowingItemWithAim : bool;
  321. private saved var isThrowingItem : bool;
  322. private var isThrowHoldPressed : bool;
  323.  
  324.  
  325. private var isAimingCrossbow : bool;
  326.  
  327. default isThrowingItemWithAim = false;
  328.  
  329.  
  330. public var playerAiming : PlayerAiming;
  331.  
  332.  
  333. public var forceDismember : bool;
  334. public var forceDismemberName : name;
  335. public var forceDismemberChance : int;
  336. public var forceDismemberExplosion : bool;
  337.  
  338.  
  339. private var finisherVictim : CActor;
  340. public var forceFinisher : bool;
  341. public var forceFinisherAnimName : name;
  342. public var forceFinisherChance : int;
  343. public var forcedStance : bool;
  344.  
  345.  
  346. private var m_WeaponFXCollisionGroupNames : array <name>;
  347. private var m_CollisionEffect : CEntity;
  348. private var m_LastWeaponTipPos : Vector;
  349. private var m_CollisionFxTemplate : CEntityTemplate;
  350. private var m_RefreshWeaponFXType : bool;
  351. private var m_PlayWoodenFX : bool;
  352.  
  353.  
  354. private var m_activePoster : W3Poster;
  355.  
  356. public function SetActivePoster ( poster : W3Poster )
  357. {
  358. m_activePoster = poster;
  359. }
  360.  
  361. public function RemoveActivePoster ()
  362. {
  363. m_activePoster = NULL;
  364. }
  365.  
  366. public function GetActivePoster () : W3Poster
  367. {
  368. return m_activePoster;
  369. }
  370.  
  371.  
  372.  
  373.  
  374.  
  375. public var horseOnNavMesh : bool;
  376. default horseOnNavMesh = true;
  377.  
  378. public function SetHorseNav( val : bool ) { horseOnNavMesh = val; }
  379.  
  380.  
  381. public var testAdjustRequestedMovementDirection : bool;
  382. default testAdjustRequestedMovementDirection = false;
  383.  
  384.  
  385. default autoState = 'Exploration';
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392. import final function GetEnemiesInRange( out enemies : array< CActor > );
  393. import final function GetVisibleEnemies( out enemies : array< CActor > );
  394. import final function IsEnemyVisible( enemy : CActor ) : bool;
  395.  
  396.  
  397. import final function SetupEnemiesCollection( range, heightTolerance : float,
  398. maxEnemies : int,
  399. optional tag : name,
  400. optional flags : int );
  401.  
  402. import final function IsInInterior() : bool;
  403. import final function IsInSettlement() : bool;
  404. import final function EnterSettlement( isEntering : bool );
  405. import final function ActionDirectControl( controller : CR4LocomotionDirectController ) : bool;
  406. import final function SetPlayerTarget( target : CActor );
  407. import final function SetPlayerCombatTarget( target : CActor );
  408. import final function ObtainTicketFromCombatTarget( ticketName : CName, ticketsCount : int );
  409. import final function FreeTicketAtCombatTarget();
  410. import final function SetScriptMoveTarget( target : CActor );
  411. import final function GetRiderData() : CAIStorageRiderData;
  412. import final function SetIsInCombat( inCombat : bool );
  413. import final function SaveLastMountedHorse( mountedHorse : CActor );
  414.  
  415. import final function SetBacklightFromHealth( healthPercentage : float );
  416. import private final function SetBacklightColor( color : Vector );
  417.  
  418. import final function GetCombatDataComponent() : CCombatDataComponent;
  419.  
  420. import final function GetTemplatePathAndAppearance( out templatePath : string, out appearance : name );
  421.  
  422. import final function HACK_BoatDismountPositionCorrection( slotPos : Vector );
  423.  
  424. import final function HACK_ForceGetBonePosition( boneIndex : int ) : Vector;
  425.  
  426.  
  427. public function GetLevel() : int
  428. {
  429. return 0;
  430. }
  431.  
  432.  
  433.  
  434.  
  435. var targeting : CR4PlayerTargeting;
  436. var targetingPrecalcs : SR4PlayerTargetingPrecalcs;
  437. var targetingIn : SR4PlayerTargetingIn;
  438. var targetingOut : SR4PlayerTargetingOut;
  439. var useNativeTargeting : bool;
  440. default useNativeTargeting = true;
  441.  
  442. var visibleActors : array< CActor >;
  443. var visibleActorsTime : array< float >;
  444.  
  445.  
  446.  
  447. event OnSpawned( spawnData : SEntitySpawnData )
  448. {
  449. var atts : array<name>;
  450. var skill : ESkill;
  451. var i : int;
  452. var item : SItemUniqueId;
  453.  
  454. AddAnimEventCallback('ThrowHoldTest', 'OnAnimEvent_ThrowHoldTest');
  455. AddAnimEventCallback('OnWeaponDrawReady', 'OnAnimEvent_OnWeaponDrawReady');
  456. AddAnimEventCallback('OnWeaponHolsterReady', 'OnAnimEvent_OnWeaponHolsterReady');
  457. AddAnimEventCallback('AllowTempLookAt', 'OnAnimEvent_AllowTempLookAt');
  458. AddAnimEventCallback('SlideToTarget', 'OnAnimEvent_SlideToTarget');
  459. AddAnimEventCallback('PlayFinisherBlood', 'OnAnimEvent_PlayFinisherBlood');
  460. AddAnimEventCallback('SlowMo', 'OnAnimEvent_SlowMo');
  461. AddAnimEventCallback('BloodTrailForced', 'OnAnimEvent_BloodTrailForced');
  462. AddAnimEventCallback('FadeOut', 'OnAnimEvent_FadeOut');
  463. AddAnimEventCallback('FadeIn', 'OnAnimEvent_FadeIn');
  464. AddAnimEventCallback('DisallowHitAnim', 'OnAnimEvent_DisallowHitAnim');
  465. AddAnimEventCallback('AllowFall', 'OnAnimEvent_AllowFall');
  466. AddAnimEventCallback('AllowFall2', 'OnAnimEvent_AllowFall2');
  467. AddAnimEventCallback('DettachGround', 'OnAnimEvent_DettachGround');
  468. AddAnimEventCallback('KillWithRagdoll', 'OnAnimEvent_KillWithRagdoll');
  469. AddAnimEventCallback('pad_vibration', 'OnAnimEvent_pad_vibration');
  470. AddAnimEventCallback('pad_vibration_light', 'OnAnimEvent_pad_vibration_light');
  471. AddAnimEventCallback('RemoveBurning', 'OnAnimEvent_RemoveBurning');
  472. AddAnimEventCallback('RemoveTangled', 'OnAnimEvent_RemoveTangled');
  473. AddAnimEventCallback('MoveNoise', 'OnAnimEvent_MoveNoise');
  474.  
  475. AddItemPerLevelList();
  476.  
  477. enemyCollectionDist = findMoveTargetDistMax;
  478.  
  479.  
  480. theGame.RemoveTimeScale('horse_melee');
  481.  
  482.  
  483. if(!spawnData.restored && !((W3ReplacerCiri)this) )
  484. {
  485. AddTimer('GiveStartingItems', 0.00001, true, , , true);
  486.  
  487. if(!theGame.IsFinalBuild())
  488. {
  489.  
  490. AddAbility('GeraltSkills_Testing');
  491. AddTimer('Debug_GiveTestingItems',0.0001,true);
  492. }
  493.  
  494.  
  495. FactsAdd("tut_stash_fresh_playthrough");
  496. }
  497.  
  498. InitTargeting();
  499.  
  500.  
  501. if( spawnData.restored )
  502. {
  503.  
  504.  
  505.  
  506. theGame.GameplayFactsRemove( "in_combat" );
  507. }
  508.  
  509.  
  510.  
  511. if ( !weaponHolster )
  512. {
  513. weaponHolster = new WeaponHolster in this;
  514. }
  515.  
  516. weaponHolster.Initialize( this, spawnData.restored );
  517.  
  518. if ( !interiorTracker )
  519. {
  520. interiorTracker = new CPlayerInteriorTracker in this;
  521. }
  522. interiorTracker.Init( spawnData.restored );
  523.  
  524.  
  525. super.OnSpawned( spawnData );
  526.  
  527.  
  528. medallion = new W3MedallionFX in this;
  529.  
  530. playerMode = new W3PlayerMode in this;
  531. playerMode.Initialize( this );
  532.  
  533.  
  534. playerAiming = new PlayerAiming in this;
  535. playerAiming.Initialize( this );
  536.  
  537.  
  538. navQuery = new CNavigationReachabilityQueryInterface in this;
  539.  
  540.  
  541. EnableFindTarget( true );
  542. AddTimer( 'CombatCheck', 0.2f, true );
  543.  
  544.  
  545. substateManager = ( CExplorationStateManager ) GetComponentByClassName( 'CExplorationStateManager' );
  546.  
  547. findMoveTargetDist = findMoveTargetDistMax;
  548.  
  549. SetupEnemiesCollection( enemyCollectionDist, findMoveTargetDist, 10, 'None', FLAG_Attitude_Neutral + FLAG_Attitude_Hostile + FLAG_Attitude_Friendly + FLAG_OnlyAliveActors );
  550.  
  551.  
  552. inputHandler.RemoveLocksOnSpawn();
  553.  
  554.  
  555. ((CActor) this ).SetInteractionPriority( IP_Prio_0 );
  556.  
  557. prevDayNightIsNight = theGame.envMgr.IsNight();
  558. CheckDayNightCycle();
  559.  
  560.  
  561. EnableVisualDebug( SHOW_AI, true );
  562.  
  563.  
  564. FactsRemove("blocked_illusion_oneliner");
  565.  
  566. SetFailedFundamentalsFirstAchievementCondition(false);
  567. m_CollisionFxTemplate = (CEntityTemplate) LoadResource( 'sword_colision_fx' );
  568. if( m_WeaponFXCollisionGroupNames.Size() == 0 )
  569. {
  570. m_WeaponFXCollisionGroupNames.PushBack('Static');
  571. m_WeaponFXCollisionGroupNames.PushBack('Foliage');
  572. m_WeaponFXCollisionGroupNames.PushBack('Fence');
  573. m_WeaponFXCollisionGroupNames.PushBack('BoatSide');
  574. m_WeaponFXCollisionGroupNames.PushBack('Door');
  575. m_WeaponFXCollisionGroupNames.PushBack('RigidBody');
  576. m_WeaponFXCollisionGroupNames.PushBack('Dynamic');
  577. m_WeaponFXCollisionGroupNames.PushBack('Destructible');
  578. }
  579.  
  580. if ( counterCollisionGroupNames.Size() == 0 )
  581. {
  582. counterCollisionGroupNames.PushBack('Static');
  583. counterCollisionGroupNames.PushBack('Foliage');
  584. counterCollisionGroupNames.PushBack('Fence');
  585. counterCollisionGroupNames.PushBack('Terrain');
  586. counterCollisionGroupNames.PushBack('Door');
  587. counterCollisionGroupNames.PushBack('RigidBody');
  588. counterCollisionGroupNames.PushBack('Dynamic');
  589. counterCollisionGroupNames.PushBack('Destructible');
  590. }
  591.  
  592.  
  593. ResetPadBacklightColor();
  594.  
  595. if( spawnData.restored )
  596. {
  597. if (IsCurrentlyUsingItemL())
  598. {
  599. if (inv.HasItemById( currentlyEquipedItemL ))
  600. {
  601. OnUseSelectedItem();
  602. }
  603. else
  604. {
  605. HideUsableItem(true);
  606. }
  607. }
  608. if ( GetCurrentMeleeWeaponType() == PW_Steel || GetCurrentMeleeWeaponType() == PW_Silver )
  609. {
  610. OnEquipMeleeWeapon(GetCurrentMeleeWeaponType(), true, true);
  611. }
  612.  
  613. AddTimer( 'UnmountCrossbowTimer', 0.01, true );
  614.  
  615. ClearBlockedSlots();
  616. }
  617.  
  618. ((CR4PlayerStateSwimming)this.GetState('Swimming')).OnParentSpawned();
  619.  
  620.  
  621. SetImmortalityMode( AIM_None, AIC_SyncedAnim );
  622.  
  623.  
  624. theGame.GetDefinitionsManager().GetContainedAbilities('DwimeritiumBomb_3', atts);
  625. for(i=0; i<atts.Size(); i+=1)
  626. {
  627. skill = SkillNameToEnum(atts[i]);
  628. if(skill != S_SUndefined)
  629. BlockSkill(skill, false);
  630. }
  631.  
  632.  
  633. this.GetInventory().GetItemEquippedOnSlot( EES_SteelSword, item );
  634. if( this.GetInventory().ItemHasTag( item, 'PhantomWeapon' ) )
  635. {
  636. this.InitPhantomWeaponMgr();
  637. }
  638.  
  639.  
  640. if(FactsQuerySum("mq3036_fact_done") > 0)
  641. BlockAllActions('mq3036', false);
  642.  
  643. spawnedTime = theGame.GetEngineTimeAsSeconds();
  644.  
  645. if ( theGame.GetInGameConfigWrapper().GetVarValue('Gameplay', 'EnableUberMovement' ) == "1" )
  646. theGame.EnableUberMovement( true );
  647. else
  648. theGame.EnableUberMovement( false );
  649.  
  650.  
  651. if ( !FactsDoesExist("gwent_difficulty") )
  652. FactsAdd("gwent_difficulty", 2);
  653.  
  654.  
  655. if(!newGamePlusInitialized && FactsQuerySum("NewGamePlus") > 0)
  656. {
  657. NewGamePlusInitialize();
  658. }
  659.  
  660.  
  661. if( lastInstantKillTime > theGame.GetGameTime() )
  662. {
  663. SetLastInstantKillTime( GameTimeCreate(0) );
  664. }
  665. }
  666.  
  667. public function NewGamePlusInitialize()
  668. {
  669.  
  670. SetLastInstantKillTime( GameTimeCreate(0) );
  671. }
  672.  
  673. public function GetTimeSinceSpawned() : float
  674. {
  675. return theGame.GetEngineTimeAsSeconds() - spawnedTime;
  676. }
  677.  
  678. timer function UnmountCrossbowTimer( dt : float, id : int )
  679. {
  680. var itemId : SItemUniqueId;
  681.  
  682. itemId = this.inv.GetItemFromSlot( 'l_weapon' );
  683. if ( inv.IsIdValid( itemId ) && inv.IsItemCrossbow( itemId ) )
  684. {
  685. rangedWeapon = (Crossbow)( inv.GetItemEntityUnsafe( itemId ) );
  686.  
  687. if (rangedWeapon)
  688. {
  689. rangedWeapon.Initialize( (CActor)( rangedWeapon.GetParentEntity() ) );
  690. OnRangedForceHolster( true, true );
  691. RemoveTimer( 'UnmountCrossbowTimer' );
  692. }
  693. }
  694. else
  695. RemoveTimer( 'UnmountCrossbowTimer' );
  696. }
  697.  
  698. event OnDestroyed()
  699. {
  700. playerAiming.RemoveAimingSloMo();
  701.  
  702. if(rangedWeapon)
  703. rangedWeapon.ClearDeployedEntity(true);
  704.  
  705. ResetPadBacklightColor();
  706.  
  707.  
  708. theGame.ReleaseNoSaveLock( noSaveLock );
  709. }
  710.  
  711.  
  712.  
  713.  
  714.  
  715. public function GetBlockedSlots () : array < SRadialSlotDef >
  716. {
  717. return blockedRadialSlots;
  718. }
  719.  
  720. public function ClearBlockedSlots()
  721. {
  722. var i : int;
  723.  
  724.  
  725.  
  726. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  727. {
  728. if( !IsSwimming() )
  729. {
  730. if ( EnableRadialSlot(blockedRadialSlots[i].slotName, 'swimming'))
  731. {
  732. i-=1;
  733. continue;
  734. }
  735. }
  736. if (!IsUsingVehicle())
  737. {
  738. if ( EnableRadialSlot(blockedRadialSlots[i].slotName, 'useVehicle'))
  739. {
  740. i-=1;
  741. continue;
  742. }
  743. }
  744. if ( !IsCurrentlyUsingItemL() || !IsUsableItemLBlocked() )
  745. {
  746. if ( EnableRadialSlot(blockedRadialSlots[i].slotName, 'usableItemL'))
  747. {
  748. i-=1;
  749. continue;
  750. }
  751. }
  752. if ( !IsThrowingItem() )
  753. {
  754. if ( EnableRadialSlot(blockedRadialSlots[i].slotName, 'throwBomb'))
  755. {
  756. i-=1;
  757. continue;
  758. }
  759. }
  760. }
  761.  
  762.  
  763.  
  764. }
  765.  
  766. public function RestoreBlockedSlots ()
  767. {
  768. var i : int;
  769. var slotsToBlock : array<name>;
  770.  
  771. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  772. {
  773. slotsToBlock.PushBack ( blockedRadialSlots[i].slotName );
  774. }
  775. if ( slotsToBlock.Size() > 0 )
  776. {
  777. EnableRadialSlots ( false, slotsToBlock );
  778. }
  779. }
  780. private function DisableRadialSlot ( slotName : name, sourceName : name ) : bool
  781. {
  782. var i : int;
  783. var k : int;
  784. var slotsToBlock : array<name>;
  785.  
  786. var blockedRadialSlotEntry : SRadialSlotDef;
  787.  
  788. slotsToBlock.PushBack ( slotName );
  789.  
  790. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  791. {
  792. if ( blockedRadialSlots[i].slotName == slotName )
  793. {
  794. if ( sourceName != '' )
  795. {
  796. for ( k = 0; k < blockedRadialSlots[i].disabledBySources.Size(); k += 1 )
  797. {
  798. if ( blockedRadialSlots[i].disabledBySources[k] == sourceName )
  799. {
  800. return false;
  801. }
  802. }
  803. blockedRadialSlots[i].disabledBySources.PushBack ( sourceName );
  804. return false;
  805. }
  806.  
  807. return false;
  808. }
  809. }
  810.  
  811. blockedRadialSlotEntry = InitBlockedRadialSlotEntry ( slotName );
  812.  
  813. if ( sourceName != '' )
  814. {
  815. blockedRadialSlotEntry.disabledBySources.PushBack ( sourceName );
  816. }
  817. blockedRadialSlots.PushBack ( blockedRadialSlotEntry );
  818. EnableRadialSlots ( false, slotsToBlock );
  819. return true;
  820. }
  821.  
  822. public function EnableRadialSlot ( slotName : name, sourceName : name ) : bool
  823. {
  824. var i : int;
  825. var k : int;
  826.  
  827. var slotsToBlock : array<name>;
  828.  
  829. slotsToBlock.PushBack ( slotName );
  830.  
  831. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  832. {
  833. if ( blockedRadialSlots[i].slotName == slotName )
  834. {
  835.  
  836. if ( sourceName != '' )
  837. {
  838. for ( k = 0; k < blockedRadialSlots[i].disabledBySources.Size(); k += 1 )
  839. {
  840. if ( blockedRadialSlots[i].disabledBySources[k] == sourceName )
  841. {
  842. blockedRadialSlots[i].disabledBySources.Remove ( blockedRadialSlots[i].disabledBySources[k] );
  843. }
  844. }
  845. }
  846. if ( blockedRadialSlots[i].disabledBySources.Size() <= 0 )
  847. {
  848. blockedRadialSlots.Remove( blockedRadialSlots[i] );
  849. EnableRadialSlots ( true, slotsToBlock );
  850. return true;
  851. }
  852. return false;
  853. }
  854. }
  855. return false;
  856.  
  857. }
  858.  
  859. private function InitBlockedRadialSlotEntry ( slotName : name ) : SRadialSlotDef
  860. {
  861. var blockedRadialSlotEntry : SRadialSlotDef;
  862.  
  863. blockedRadialSlotEntry.slotName = slotName;
  864.  
  865. return blockedRadialSlotEntry;
  866.  
  867. }
  868.  
  869. public function EnableRadialSlotsWithSource ( enable : bool, slotsToBlock : array < name >, sourceName : name )
  870. {
  871. var i : int;
  872.  
  873. for ( i = 0; i < slotsToBlock.Size(); i+=1 )
  874. {
  875. if ( enable )
  876. {
  877. EnableRadialSlot ( slotsToBlock[i], sourceName );
  878. }
  879. else
  880. {
  881. DisableRadialSlot ( slotsToBlock[i], sourceName );
  882. }
  883. }
  884. if ( blockedRadialSlots.Size() <= 0 )
  885. {
  886. blockedRadialSlots.Clear();
  887. }
  888. }
  889.  
  890. public function IsRadialSlotBlocked ( slotName : name ) : bool
  891. {
  892. var i : int;
  893.  
  894. for ( i = 0; i < blockedRadialSlots.Size(); i+=1 )
  895. {
  896. if ( blockedRadialSlots[i].slotName == slotName )
  897. {
  898. return true;
  899. }
  900. }
  901. return false;
  902. }
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909. public function RepairItem ( rapairKitId : SItemUniqueId, usedOnItem : SItemUniqueId );
  910. public function HasRepairAbleGearEquiped () : bool;
  911. public function HasRepairAbleWaponEquiped () : bool;
  912. public function IsItemRepairAble ( item : SItemUniqueId ) : bool;
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919. public final function ReduceAllOilsAmmo( id : SItemUniqueId )
  920. {
  921. var i : int;
  922. var oils : array< W3Effect_Oil >;
  923.  
  924. oils = inv.GetOilsAppliedOnItem( id );
  925.  
  926. for( i=0; i<oils.Size(); i+=1 )
  927. {
  928. oils[ i ].ReduceAmmo();
  929. }
  930. }
  931.  
  932. public final function ResumeOilBuffs( steel : bool )
  933. {
  934. var item : SItemUniqueId;
  935. var oils : array< CBaseGameplayEffect >;
  936. var buff, recentOil : W3Effect_Oil;
  937. var i : int;
  938.  
  939. item = GetEquippedSword( steel );
  940. oils = GetBuffs( EET_Oil );
  941.  
  942. if( oils.Size() > 1 )
  943. {
  944.  
  945.  
  946. recentOil = inv.GetNewestOilAppliedOnItem( item, false );
  947. }
  948.  
  949. for( i=0; i<oils.Size(); i+=1 )
  950. {
  951. buff = ( W3Effect_Oil ) oils[ i ];
  952.  
  953. if( recentOil && recentOil == buff )
  954. {
  955. continue;
  956. }
  957.  
  958. if(buff && buff.GetSwordItemId() == item )
  959. {
  960. buff.Resume( '' );
  961. }
  962. }
  963.  
  964. if( recentOil )
  965. {
  966. recentOil.Resume( '' );
  967. }
  968. }
  969.  
  970. protected final function PauseOilBuffs( isSteel : bool )
  971. {
  972. var item : SItemUniqueId;
  973. var oils : array< CBaseGameplayEffect >;
  974. var buff : W3Effect_Oil;
  975. var i : int;
  976.  
  977. item = GetEquippedSword( isSteel );
  978. oils = GetBuffs( EET_Oil );
  979.  
  980. for( i=0; i<oils.Size(); i+=1 )
  981. {
  982. buff = ( W3Effect_Oil ) oils[ i ];
  983. if(buff && buff.GetSwordItemId() == item )
  984. {
  985. buff.Pause( '', true );
  986. }
  987. }
  988. }
  989.  
  990. public final function ManageAerondightBuff( apply : bool )
  991. {
  992. var aerondight : W3Effect_Aerondight;
  993. var item : SItemUniqueId;
  994.  
  995. item = inv.GetCurrentlyHeldSword();
  996.  
  997. if( inv.ItemHasTag( item, 'Aerondight' ) )
  998. {
  999. aerondight = (W3Effect_Aerondight)GetBuff( EET_Aerondight );
  1000.  
  1001. if( apply )
  1002. {
  1003. if( !aerondight )
  1004. {
  1005. AddEffectDefault( EET_Aerondight, this, "Aerondight" );
  1006. }
  1007. else
  1008. {
  1009. aerondight.Resume( 'ManageAerondightBuff' );
  1010. }
  1011. }
  1012. else
  1013. {
  1014. aerondight.Pause( 'ManageAerondightBuff' );
  1015. }
  1016. }
  1017. }
  1018.  
  1019.  
  1020. public function ApplyOil( oilId : SItemUniqueId, usedOnItem : SItemUniqueId ) : bool
  1021. {
  1022. var oilAbilities : array< name >;
  1023. var ammo, ammoBonus : float;
  1024. var dm : CDefinitionsManagerAccessor;
  1025. var buffParams : SCustomEffectParams;
  1026. var oilParams : W3OilBuffParams;
  1027. var oilName : name;
  1028. var min, max : SAbilityAttributeValue;
  1029. var i : int;
  1030. var oils : array< W3Effect_Oil >;
  1031. var existingOil : W3Effect_Oil;
  1032.  
  1033. if( !CanApplyOilOnItem( oilId, usedOnItem ) )
  1034. {
  1035. return false;
  1036. }
  1037.  
  1038. dm = theGame.GetDefinitionsManager();
  1039. inv.GetItemAbilitiesWithTag( oilId, theGame.params.OIL_ABILITY_TAG, oilAbilities );
  1040. oilName = inv.GetItemName( oilId );
  1041. oils = inv.GetOilsAppliedOnItem( usedOnItem );
  1042.  
  1043.  
  1044. for( i=0; i<oils.Size(); i+=1 )
  1045. {
  1046. if( oils[ i ].GetOilItemName() == oilName )
  1047. {
  1048. existingOil = oils[ i ];
  1049. break;
  1050. }
  1051. }
  1052.  
  1053.  
  1054. if( !existingOil )
  1055. {
  1056. // FCR3 --
  1057. //if( !GetWitcherPlayer() || !GetWitcherPlayer().IsSetBonusActive( EISB_Wolf_1 ) )
  1058. if( !GetWitcherPlayer() || !CanUseSkill(S_Alchemy_s06) )
  1059. // -- FCR3
  1060. {
  1061. inv.RemoveAllOilsFromItem( usedOnItem );
  1062. }
  1063. else
  1064. {
  1065. // FCR3 --
  1066. //dm.GetAbilityAttributeValue( GetSetBonusAbility( EISB_Wolf_1 ), 'max_oils_count', min, max );
  1067. //if( inv.GetActiveOilsAppliedOnItemCount( usedOnItem ) >= CalculateAttributeValue( max ) )
  1068. if( inv.GetActiveOilsAppliedOnItemCount( usedOnItem ) >= GetSkillLevel( S_Alchemy_s06 ) )
  1069. // -- FCR3
  1070. {
  1071. inv.RemoveOldestOilFromItem( usedOnItem );
  1072. }
  1073. }
  1074. }
  1075.  
  1076.  
  1077. ammo = CalculateAttributeValue(inv.GetItemAttributeValue(oilId, 'ammo'));
  1078. if(CanUseSkill(S_Alchemy_s06))
  1079. {
  1080. ammoBonus = CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s06, 'ammo_bonus', false, false));
  1081. ammo *= 1 + ammoBonus * GetSkillLevel(S_Alchemy_s06);
  1082. }
  1083.  
  1084.  
  1085. if( existingOil )
  1086. {
  1087. existingOil.Reapply( RoundMath( ammo ) );
  1088. }
  1089. else
  1090. {
  1091. buffParams.effectType = EET_Oil;
  1092. buffParams.creator = this;
  1093. oilParams = new W3OilBuffParams in this;
  1094. oilParams.iconPath = dm.GetItemIconPath( oilName );
  1095. oilParams.localizedName = dm.GetItemLocalisationKeyName( oilName );
  1096. oilParams.localizedDescription = dm.GetItemLocalisationKeyName( oilName );
  1097. oilParams.sword = usedOnItem;
  1098. oilParams.maxCount = RoundMath( ammo );
  1099. oilParams.currCount = RoundMath( ammo );
  1100. oilParams.oilAbilityName = oilAbilities[ 0 ];
  1101. oilParams.oilItemName = oilName;
  1102. buffParams.buffSpecificParams = oilParams;
  1103.  
  1104. AddEffectCustom( buffParams );
  1105.  
  1106. delete oilParams;
  1107. }
  1108.  
  1109. LogOils("Added oil <<" + oilName + ">> to <<" + inv.GetItemName( usedOnItem ) + ">>");
  1110.  
  1111.  
  1112. SetFailedFundamentalsFirstAchievementCondition( true );
  1113.  
  1114. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnOilApplied );
  1115.  
  1116. if( !inv.IsItemHeld( usedOnItem ) )
  1117. {
  1118. PauseOilBuffs( inv.IsItemSteelSwordUsableByPlayer( usedOnItem ) );
  1119. }
  1120.  
  1121. return true;
  1122. }
  1123.  
  1124.  
  1125. public final function IsEquippedSwordUpgradedWithOil(steel : bool, optional oilName : name) : bool
  1126. {
  1127. var sword : SItemUniqueId;
  1128. var i : int;
  1129. var oils : array< W3Effect_Oil >;
  1130.  
  1131. sword = GetEquippedSword( steel );
  1132. if( !inv.IsIdValid( sword ) )
  1133. {
  1134. return false;
  1135. }
  1136.  
  1137. if( oilName == '' )
  1138. {
  1139. return inv.ItemHasAnyActiveOilApplied( sword );
  1140. }
  1141.  
  1142. oils = inv.GetOilsAppliedOnItem( sword );
  1143. for( i=0; i<oils.Size(); i+=1 )
  1144. {
  1145. if( oils[ i ].GetOilItemName() == oilName )
  1146. {
  1147. return true;
  1148. }
  1149. }
  1150.  
  1151. return false;
  1152. }
  1153.  
  1154. public function CanApplyOilOnItem(oilId : SItemUniqueId, usedOnItem : SItemUniqueId) : bool
  1155. {
  1156. if(inv.ItemHasTag(oilId, theGame.params.TAG_STEEL_OIL) && inv.IsItemSteelSwordUsableByPlayer(usedOnItem))
  1157. return true;
  1158.  
  1159. if(inv.ItemHasTag(oilId, theGame.params.TAG_SILVER_OIL) && inv.IsItemSilverSwordUsableByPlayer(usedOnItem))
  1160. return true;
  1161.  
  1162. return false;
  1163. }
  1164.  
  1165.  
  1166. public final function DidFailFundamentalsFirstAchievementCondition() : bool
  1167. {
  1168. return failedFundamentalsFirstAchievementCondition;
  1169. }
  1170.  
  1171. public final function SetFailedFundamentalsFirstAchievementCondition(b : bool)
  1172. {
  1173. var i : int;
  1174. var npc : CNewNPC;
  1175.  
  1176. failedFundamentalsFirstAchievementCondition = b;
  1177.  
  1178.  
  1179. if(failedFundamentalsFirstAchievementCondition)
  1180. {
  1181. for(i=0; i<hostileEnemies.Size(); i+=1)
  1182. {
  1183. if(hostileEnemies[i].HasTag(theGame.params.MONSTER_HUNT_ACTOR_TAG))
  1184. {
  1185. npc = (CNewNPC)hostileEnemies[i];
  1186. npc.AddTag('failedFundamentalsAchievement');
  1187. npc.AddTimer('FundamentalsAchFailTimer', 30*60, , , , true, true);
  1188. }
  1189. }
  1190. }
  1191. }
  1192.  
  1193. public function IsInCombatFist() : bool
  1194. {
  1195. return this.GetCurrentStateName() == 'CombatFists';
  1196. }
  1197.  
  1198. public function IsInitialized() : bool;
  1199.  
  1200. public function IsCiri() : bool
  1201. {
  1202. return ((W3ReplacerCiri)this);
  1203. }
  1204.  
  1205. protected function WouldLikeToMove() : bool
  1206. {
  1207. var speedVec : Vector;
  1208. var speed, speedMult : float;
  1209.  
  1210.  
  1211. speedVec.X = theInput.GetActionValue( 'GI_AxisLeftX' );
  1212. speedVec.Y = theInput.GetActionValue( 'GI_AxisLeftY' );
  1213. speed = VecLength2D( speedVec );
  1214.  
  1215. return speed > 0.1f;
  1216. }
  1217.  
  1218. function HandleMovement( deltaTime : float )
  1219. {
  1220.  
  1221.  
  1222.  
  1223.  
  1224. if (WouldLikeToMove())
  1225. SetBehaviorVariable( 'playerWouldLikeToMove', 1.0f);
  1226. else
  1227. SetBehaviorVariable( 'playerWouldLikeToMove', 0.0f);
  1228.  
  1229. super.HandleMovement( deltaTime );
  1230. }
  1231.  
  1232. function BattleCryIsReady( ) : bool
  1233. {
  1234. var l_currentTime : float;
  1235.  
  1236. l_currentTime = theGame.GetEngineTimeAsSeconds();
  1237.  
  1238. if( l_currentTime >= battlecry_timeForNext )
  1239. {
  1240. return true;
  1241. }
  1242. return false;
  1243. }
  1244.  
  1245. function PlayBattleCry( _BattleCry : name , _Chance : float, optional _IgnoreDelay, ignoreRepeatCheck : bool )
  1246. {
  1247. var l_randValue : float;
  1248. var fact : int;
  1249.  
  1250. fact = FactsQuerySum("force_stance_normal");
  1251.  
  1252. if( IsSwimming()
  1253. || theGame.IsDialogOrCutscenePlaying()
  1254. || IsInNonGameplayCutscene()
  1255. || IsInGameplayScene()
  1256. || theGame.IsCurrentlyPlayingNonGameplayScene()
  1257. || theGame.IsFading()
  1258. || theGame.IsBlackscreen()
  1259. || FactsQuerySum("force_stance_normal") > 0 )
  1260. {
  1261. return;
  1262. }
  1263.  
  1264.  
  1265. if ( !ignoreRepeatCheck )
  1266. {
  1267. if( battlecry_lastTry == _BattleCry )
  1268. return;
  1269. }
  1270.  
  1271. battlecry_lastTry = _BattleCry;
  1272.  
  1273. l_randValue = RandF();
  1274.  
  1275.  
  1276. if( l_randValue < _Chance && ( _IgnoreDelay || BattleCryIsReady() ) )
  1277. {
  1278. thePlayer.PlayVoiceset( 90, _BattleCry );
  1279.  
  1280. battlecry_timeForNext = theGame.GetEngineTimeAsSeconds() + RandRangeF( battlecry_delayMax, battlecry_delayMin );
  1281. }
  1282.  
  1283. }
  1284.  
  1285. public final function OnWeatherChanged()
  1286. {
  1287. if( IsInInterior()
  1288. || GetCurrentStateName() != 'Exploration'
  1289. || theGame.IsDialogOrCutscenePlaying()
  1290. || IsInNonGameplayCutscene()
  1291. || IsInGameplayScene()
  1292. || theGame.IsCurrentlyPlayingNonGameplayScene()
  1293. || theGame.IsFading()
  1294. || theGame.IsBlackscreen()
  1295. || GetTimeSinceSpawned() < 60 )
  1296. {
  1297. return;
  1298. }
  1299.  
  1300. AddTimer( 'CommentOnWeather', 1 );
  1301. }
  1302.  
  1303. public final timer function CommentOnWeather( _Delta : float, _Id : int )
  1304. {
  1305. var l_weather : name;
  1306. var l_currentArea : EAreaName;
  1307. var l_rand : float;
  1308.  
  1309. l_weather = GetWeatherConditionName();
  1310.  
  1311. l_currentArea = theGame.GetCommonMapManager().GetCurrentArea();
  1312.  
  1313. switch ( l_weather )
  1314. {
  1315. case 'WT_Clear':
  1316.  
  1317. l_rand = RandF();
  1318.  
  1319. if( l_rand > 0.66f && !AreaIsCold() && theGame.envMgr.IsDay() )
  1320. {
  1321. thePlayer.PlayVoiceset( 90, 'WeatherHot' );
  1322. }
  1323. else if ( l_rand > 0.33f )
  1324. {
  1325. thePlayer.PlayVoiceset( 90, 'WeatherClearingUp' );
  1326. }
  1327. break;
  1328.  
  1329. case 'WT_Rain_Storm':
  1330. thePlayer.PlayVoiceset( 90, 'WeatherStormy' );
  1331. break;
  1332.  
  1333. case 'WT_Light_Clouds':
  1334. if( previousRainStrength < GetRainStrength() )
  1335. {
  1336. thePlayer.PlayVoiceset( 90, 'WeatherLooksLikeRain' );
  1337. }
  1338. else if( AreaIsCold() && previousWeather == 'WT_Clear' )
  1339. {
  1340. thePlayer.PlayVoiceset( 90, 'WeatherCold' );
  1341. }
  1342. break;
  1343.  
  1344. case 'WT_Mid_Clouds':
  1345. if( previousRainStrength < GetRainStrength() )
  1346. {
  1347. thePlayer.PlayVoiceset( 90, 'WeatherRaining' );
  1348. }
  1349. else if( AreaIsCold() && previousWeather == 'WT_Clear' )
  1350. {
  1351. thePlayer.PlayVoiceset( 90, 'WeatherCold' );
  1352. }
  1353. break;
  1354.  
  1355. case 'WT_Mid_Clouds_Dark':
  1356. if( previousWeather != 'WT_Heavy_Clouds' && previousWeather != 'WT_Heavy_Clouds_Dark' )
  1357. thePlayer.PlayVoiceset( 90, 'WeatherWindy' );
  1358. break;
  1359.  
  1360. case 'WT_Heavy_Clouds':
  1361. if( previousWeather != 'WT_Mid_Clouds_Dark' && previousWeather != 'WT_Heavy_Clouds_Dark' )
  1362. thePlayer.PlayVoiceset( 90, 'WeatherWindy' );
  1363. break;
  1364.  
  1365. case 'WT_Heavy_Clouds_Dark':
  1366. if( thePlayer.IsOnBoat() )
  1367. {
  1368. thePlayer.PlayVoiceset( 90, 'WeatherSeaWillStorm' );
  1369. }
  1370. else if( previousRainStrength < GetRainStrength() )
  1371. {
  1372. thePlayer.PlayVoiceset( 90, 'WeatherLooksLikeRain' );
  1373. }
  1374. else
  1375. {
  1376. thePlayer.PlayVoiceset( 90, 'WeatherWindy' );
  1377. }
  1378. break;
  1379.  
  1380. case 'WT_Snow':
  1381. if( RandF() > 0.5f )
  1382. thePlayer.PlayVoiceset( 90, 'WeatherSnowy' );
  1383. else
  1384. thePlayer.PlayVoiceset( 90, 'WeatherCold' );
  1385. break;
  1386. }
  1387.  
  1388. previousRainStrength = GetRainStrength();
  1389. previousWeather = l_weather;
  1390. }
  1391.  
  1392. function CanUpdateMovement() : bool
  1393. {
  1394. if ( rangedWeapon
  1395. && GetBehaviorVariable( 'fullBodyAnimWeight' ) >= 1.f
  1396. && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  1397. return false;
  1398.  
  1399. return true;
  1400. }
  1401.  
  1402. public function SetDefaultLocomotionController()
  1403. {
  1404. if( !defaultLocomotionController )
  1405. {
  1406. defaultLocomotionController = new CR4LocomotionPlayerControllerScript in this;
  1407. }
  1408.  
  1409. ActionDirectControl( defaultLocomotionController );
  1410. }
  1411.  
  1412. event OnPlayerTickTimer( deltaTime : float )
  1413. {
  1414. var focusModeController : CFocusModeController;
  1415. var cnt : int;
  1416.  
  1417. super.OnPlayerTickTimer( deltaTime );
  1418.  
  1419. HandleMovement( deltaTime );
  1420.  
  1421. if ( playerAiming.GetCurrentStateName() == 'Aiming' )
  1422. {
  1423. FindTarget();
  1424. FindNonActorTarget( false );
  1425. UpdateDisplayTarget();
  1426. UpdateLookAtTarget();
  1427. }
  1428. else
  1429. {
  1430. if( playerTickTimerPhase == 0 )
  1431. {
  1432. FindTarget();
  1433. }
  1434. else if( playerTickTimerPhase == 1 )
  1435. {
  1436. FindNonActorTarget( false );
  1437. }
  1438. else if ( playerTickTimerPhase == 2 )
  1439. {
  1440. UpdateDisplayTarget();
  1441. UpdateLookAtTarget();
  1442. }
  1443. }
  1444.  
  1445.  
  1446.  
  1447. playerTickTimerPhase = ( playerTickTimerPhase + 1 ) % 3;
  1448.  
  1449. focusModeController = theGame.GetFocusModeController();
  1450. focusModeController.UpdateFocusInteractions( deltaTime );
  1451.  
  1452.  
  1453. cnt = (int)( effectManager.GetCriticalBuffsCount() > 0 );
  1454. SetBehaviorVariable('hasCriticalBuff', cnt);
  1455. }
  1456.  
  1457. event OnDeath( damageAction : W3DamageAction )
  1458. {
  1459. super.OnDeath( damageAction );
  1460.  
  1461. RemoveTimer('RequestCriticalAnimStart');
  1462.  
  1463. EnableFindTarget( false );
  1464. BlockAllActions('Death', true);
  1465.  
  1466. EnableHardLock( false );
  1467.  
  1468. theGame.CreateNoSaveLock( 'player_death', deathNoSaveLock, false, false );
  1469. theGame.SetDeathSaveLockId( deathNoSaveLock );
  1470.  
  1471. ClearHostileEnemiesList();
  1472. RemoveReactions();
  1473. SetPlayerCombatTarget(NULL);
  1474. OnEnableAimingMode( false );
  1475.  
  1476. theGame.EnableFreeCamera( false );
  1477. }
  1478.  
  1479.  
  1480. function OnRevived()
  1481. {
  1482. super.OnRevived();
  1483. BlockAllActions('Death', false);
  1484.  
  1485. theGame.ReleaseNoSaveLock(deathNoSaveLock);
  1486.  
  1487. this.RestartReactionsIfNeeded();
  1488. }
  1489.  
  1490. public function CanStartTalk() : bool
  1491. {
  1492. if ( beingWarnedBy.Size() > 0 )
  1493. return false;
  1494.  
  1495. return super.CanStartTalk();
  1496. }
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503. public function AddCounterTimeStamp(time : EngineTime) {counterTimestamps.PushBack(time);}
  1504.  
  1505.  
  1506. public function CheckCounterSpamming(attacker : CActor) : bool
  1507. {
  1508. var counterWindowStartTime : EngineTime;
  1509. var i, spamCounter : int;
  1510. var reflexAction : bool;
  1511. var testEngineTime : EngineTime;
  1512.  
  1513. if(!attacker)
  1514. return false;
  1515.  
  1516. counterWindowStartTime = ((CNewNPC)attacker).GetCounterWindowStartTime();
  1517. spamCounter = 0;
  1518. reflexAction = false;
  1519.  
  1520.  
  1521. if ( counterWindowStartTime == testEngineTime )
  1522. {
  1523. return false;
  1524. }
  1525.  
  1526. for(i = counterTimestamps.Size() - 1; i>=0; i-=1)
  1527. {
  1528.  
  1529. if(counterTimestamps[i] >= (counterWindowStartTime - EngineTimeFromFloat(0.4)) )
  1530. {
  1531. spamCounter += 1;
  1532. }
  1533.  
  1534. else
  1535. {
  1536. counterTimestamps.Remove(counterTimestamps[i]);
  1537. continue;
  1538. }
  1539.  
  1540.  
  1541. if(!reflexAction && (counterTimestamps[i] >= counterWindowStartTime))
  1542. reflexAction = true;
  1543. }
  1544.  
  1545.  
  1546. if(spamCounter == 1 && reflexAction)
  1547. return true;
  1548.  
  1549. return false;
  1550. }
  1551.  
  1552. protected function PerformCounterCheck(parryInfo: SParryInfo) : bool
  1553. {
  1554. var mult : float;
  1555. var parryType : EParryType;
  1556. var validCounter, useKnockdown : bool;
  1557. var slideDistance, duration : float;
  1558. var playerToTargetRot : EulerAngles;
  1559. var zDifference, mutation8TriggerHP : float;
  1560. var effectType : EEffectType;
  1561. var repelType : EPlayerRepelType = PRT_Random;
  1562. var params : SCustomEffectParams;
  1563. var thisPos, attackerPos : Vector;
  1564. var fistFightCheck, isMutation8 : bool;
  1565. var fistFightCounter : bool;
  1566. var attackerInventory : CInventoryComponent;
  1567. var weaponId : SItemUniqueId;
  1568. var weaponTags : array<name>;
  1569. var playerToAttackerVector : Vector;
  1570. var tracePosStart : Vector;
  1571. var tracePosEnd : Vector;
  1572. var hitPos : Vector;
  1573. var hitNormal : Vector;
  1574. var min, max : SAbilityAttributeValue;
  1575. var npc : CNewNPC;
  1576.  
  1577. if(ShouldProcessTutorial('TutorialDodge') || ShouldProcessTutorial('TutorialCounter'))
  1578. {
  1579. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
  1580. FactsRemove("tut_fight_slomo_ON");
  1581. }
  1582.  
  1583. if ( !parryInfo.canBeParried || parryInfo.attacker.HasAbility( 'CannotBeCountered' ) )
  1584. return false;
  1585.  
  1586. fistFightCheck = FistFightCheck( parryInfo.target, parryInfo.attacker, fistFightCounter );
  1587.  
  1588. if( ParryCounterCheck() && parryInfo.targetToAttackerAngleAbs < theGame.params.PARRY_HALF_ANGLE && fistFightCheck )
  1589. {
  1590.  
  1591. validCounter = CheckCounterSpamming(parryInfo.attacker);
  1592.  
  1593. if(validCounter)
  1594. {
  1595. if ( IsInCombatActionFriendly() )
  1596. RaiseEvent('CombatActionFriendlyEnd');
  1597.  
  1598. SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
  1599. SetBehaviorVariable( 'counter', (float)validCounter);
  1600.  
  1601.  
  1602.  
  1603. SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
  1604. SetBehaviorVariable( 'counter', (float)validCounter);
  1605. this.SetBehaviorVariable( 'combatActionType', (int)CAT_Parry );
  1606.  
  1607.  
  1608. if ( !fistFightCounter )
  1609. {
  1610. attackerInventory = parryInfo.attacker.GetInventory();
  1611. weaponId = attackerInventory.GetItemFromSlot('r_weapon');
  1612. attackerInventory.GetItemTags( weaponId , weaponTags );
  1613.  
  1614. if( GetWitcherPlayer().IsMutationActive( EPMT_Mutation8 ) )
  1615. {
  1616. isMutation8 = true;
  1617. theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Mutation8', 'hp_perc_trigger', min, max );
  1618. mutation8TriggerHP = min.valueMultiplicative;
  1619. }
  1620.  
  1621.  
  1622.  
  1623. npc = (CNewNPC)parryInfo.attacker;
  1624.  
  1625.  
  1626. if ( parryInfo.attacker.HasAbility('mon_gravehag') )
  1627. {
  1628. repelType = PRT_Slash;
  1629. parryInfo.attacker.AddEffectDefault(EET_CounterStrikeHit, this, 'ReflexParryPerformed');
  1630.  
  1631. }
  1632. else if ( npc && !npc.IsHuman() && !npc.HasTag( 'dettlaff_vampire' ) )
  1633. {
  1634. repelType = PRT_SideStepSlash;
  1635. }
  1636. else if ( weaponTags.Contains('spear2h') )
  1637. {
  1638. repelType = PRT_SideStepSlash;
  1639. parryInfo.attacker.AddEffectDefault(EET_CounterStrikeHit, this, "ReflexParryPerformed");
  1640. parryInfo.attacker.SignalGameplayEvent( 'SpearDestruction');
  1641. }
  1642. // FCR3 --
  1643. //else if( isMutation8 && npc && !npc.IsImmuneToMutation8Finisher() )
  1644. else if( isMutation8 && npc && !npc.IsImmuneToMutation8Finisher() && RandRangeF(3,0) < GetWitcherPlayer().GetStat(BCS_Focus) )
  1645. // -- FCR3
  1646. {
  1647. repelType = PRT_RepelToFinisher;
  1648. npc.AddEffectDefault( EET_CounterStrikeHit, this, "ReflexParryPerformed" );
  1649.  
  1650.  
  1651. SetTarget( npc, true );
  1652.  
  1653. PerformFinisher( 0.f, 0 );
  1654. }
  1655. else
  1656. {
  1657.  
  1658. thisPos = this.GetWorldPosition();
  1659. attackerPos = parryInfo.attacker.GetWorldPosition();
  1660. playerToTargetRot = VecToRotation( thisPos - attackerPos );
  1661. zDifference = thisPos.Z - attackerPos.Z;
  1662.  
  1663. if ( playerToTargetRot.Pitch < -5.f && zDifference > 0.35 )
  1664. {
  1665. repelType = PRT_Kick;
  1666.  
  1667. ragdollTarget = parryInfo.attacker;
  1668. AddTimer( 'ApplyCounterRagdollTimer', 0.3 );
  1669. }
  1670. else
  1671. {
  1672. useKnockdown = false;
  1673. if ( CanUseSkill(S_Sword_s11) )
  1674. {
  1675. if( GetSkillLevel(S_Sword_s11) > 1 && RandRangeF(3,0) < GetWitcherPlayer().GetStat(BCS_Focus) )
  1676. {
  1677. duration = CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s11, 'duration', false, true));
  1678. useKnockdown = true;
  1679. }
  1680. }
  1681. else if ( parryInfo.attacker.IsHuman() )
  1682. {
  1683.  
  1684. tracePosStart = parryInfo.attacker.GetWorldPosition();
  1685. tracePosStart.Z += 1.f;
  1686. playerToAttackerVector = VecNormalize( parryInfo.attacker.GetWorldPosition() - parryInfo.target.GetWorldPosition() );
  1687. tracePosEnd = ( playerToAttackerVector * 0.75f ) + ( playerToAttackerVector * parryInfo.attacker.GetRadius() ) + parryInfo.attacker.GetWorldPosition();
  1688. tracePosEnd.Z += 1.f;
  1689.  
  1690. if ( !theGame.GetWorld().StaticTrace( tracePosStart, tracePosEnd, hitPos, hitNormal, counterCollisionGroupNames ) )
  1691. {
  1692. tracePosStart = tracePosEnd;
  1693. tracePosEnd -= 3.f;
  1694.  
  1695. if ( !theGame.GetWorld().StaticTrace( tracePosStart, tracePosEnd, hitPos, hitNormal, counterCollisionGroupNames ) )
  1696. useKnockdown = true;
  1697. }
  1698. }
  1699.  
  1700. if(useKnockdown && (!parryInfo.attacker.IsImmuneToBuff(EET_HeavyKnockdown) || !parryInfo.attacker.IsImmuneToBuff(EET_Knockdown)))
  1701. {
  1702. if(!parryInfo.attacker.IsImmuneToBuff(EET_HeavyKnockdown))
  1703. {
  1704. params.effectType = EET_HeavyKnockdown;
  1705. }
  1706. else
  1707. {
  1708. params.effectType = EET_Knockdown;
  1709. }
  1710.  
  1711. repelType = PRT_Kick;
  1712. params.creator = this;
  1713. params.sourceName = "ReflexParryPerformed";
  1714. params.duration = duration;
  1715.  
  1716. parryInfo.attacker.AddEffectCustom(params);
  1717. }
  1718. else
  1719. {
  1720. parryInfo.attacker.AddEffectDefault(EET_CounterStrikeHit, this, "ReflexParryPerformed");
  1721. }
  1722. }
  1723. }
  1724.  
  1725. parryInfo.attacker.GetInventory().PlayItemEffect(parryInfo.attackerWeaponId, 'counterattack');
  1726.  
  1727.  
  1728. if ( repelType == PRT_Random )
  1729. if ( RandRange(100) > 50 )
  1730. repelType = PRT_Bash;
  1731. else
  1732. repelType = PRT_Kick;
  1733.  
  1734. this.SetBehaviorVariable( 'repelType', (int)repelType );
  1735. parryInfo.attacker.SetBehaviorVariable( 'repelType', (int)repelType );
  1736. }
  1737. else
  1738. {
  1739. parryInfo.attacker.AddEffectDefault(EET_CounterStrikeHit, this, "ReflexParryPerformed");
  1740. }
  1741.  
  1742.  
  1743. SetParryTarget ( parryInfo.attacker );
  1744. SetSlideTarget( parryInfo.attacker );
  1745. if ( !IsActorLockedToTarget() )
  1746. SetMoveTarget( parryInfo.attacker );
  1747.  
  1748. if ( RaiseForceEvent( 'PerformCounter' ) )
  1749. OnCombatActionStart();
  1750.  
  1751. SetCustomRotation( 'Counter', VecHeading( parryInfo.attacker.GetWorldPosition() - this.GetWorldPosition() ), 0.0f, 0.2f, false );
  1752. AddTimer( 'UpdateCounterRotation', 0.4f, true );
  1753. AddTimer( 'SetCounterRotation', 0.2f );
  1754.  
  1755. IncreaseUninterruptedHitsCount();
  1756.  
  1757.  
  1758. if(IsHeavyAttack(parryInfo.attackActionName))
  1759. mult = theGame.params.HEAVY_STRIKE_COST_MULTIPLIER;
  1760.  
  1761. DrainStamina(ESAT_Counterattack, 0, 0, '', 0, mult);
  1762.  
  1763. theGame.GetGamerProfile().IncStat(ES_CounterattackChain);
  1764.  
  1765. }
  1766. else
  1767. {
  1768. ResetUninterruptedHitsCount();
  1769. }
  1770. return validCounter;
  1771. }
  1772.  
  1773. return false;
  1774. }
  1775.  
  1776. timer function UpdateCounterRotation( dt : float, id : int )
  1777. {
  1778. UpdateCustomRotationHeading( 'Counter', VecHeading( parryTarget.GetWorldPosition() - this.GetWorldPosition() ) );
  1779. }
  1780.  
  1781. timer function SetCounterRotation( dt : float, id : int )
  1782. {
  1783. SetCustomRotation( 'Counter', VecHeading( parryTarget.GetWorldPosition() - this.GetWorldPosition() ), 360.f, 0.2f, false );
  1784. }
  1785.  
  1786. private var parryTarget : CActor;
  1787. private function SetParryTarget( t : CActor )
  1788. {
  1789. parryTarget = t;
  1790. }
  1791.  
  1792. private var ragdollTarget : CActor;
  1793. timer function ApplyCounterRagdollTimer( time : float , id : int)
  1794. {
  1795. var actor : CActor;
  1796.  
  1797. actor = (CActor)ragdollTarget;
  1798.  
  1799. if(actor)
  1800. {
  1801. actor.AddEffectDefault(EET_HeavyKnockdown, this, 'ReflexParryPerformed');
  1802. }
  1803. }
  1804.  
  1805.  
  1806.  
  1807.  
  1808. public function EnableMode( mode : EPlayerMode, enable : bool )
  1809. {
  1810. playerMode.EnableMode( mode, enable );
  1811. }
  1812.  
  1813. public function GetPlayerMode() : W3PlayerMode
  1814. {
  1815. return playerMode;
  1816. }
  1817.  
  1818. private function GetClosestIncomingAttacker() : CActor
  1819. {
  1820. var i, size : int;
  1821. var attackerToPlayerDistances : array< float >;
  1822. var closestAttackerIndex : int;
  1823. var incomingAttackers : array<CActor>;
  1824.  
  1825. // FCR3 --
  1826. /*
  1827.  
  1828. }*/
  1829.  
  1830. private var drainFocusAmount : float;
  1831. private var drainFocusTimerActive : bool;
  1832. public function DrainFocus(amount : float )
  1833. {
  1834. if(abilityManager && abilityManager.IsInitialized() && IsAlive())
  1835. {
  1836. //if( GetWitcherPlayer().IsMutationActive( EPMT_Mutation7 ) && !drainFocusTimerActive && thePlayer.GetHealthPercents() >= 1 && thePlayer.IsInCombat() )
  1837. if( GetWitcherPlayer().IsMutationActive( EPMT_Mutation7 ) )
  1838. {
  1839. drainFocusAmount += amount;
  1840. if ( !drainFocusTimerActive )
  1841. inv.SetItemDurabilityScript(item, inv.GetItemMaxDurability(item));
  1842. return true;
  1843. {
  1844. AddTimer('Mutation7DelayedDrainFocus', 4.0f, , , , true);
  1845. drainFocusTimerActive = true;
  1846. }
  1847. }
  1848. else
  1849. {
  1850. abilityManager.DrainFocus(amount);
  1851. }
  1852. }
  1853. }
  1854.  
  1855. timer function Mutation7DelayedDrainFocus( dt : float, id : int )
  1856. {
  1857. abilityManager.DrainFocus(drainFocusAmount);
  1858. drainFocusTimerActive = false;
  1859. drainFocusAmount = 0;
  1860. }
  1861. // -- FCR3
Add Comment
Please, Sign In to add comment