Advertisement
Guest User

Untitled

a guest
Mar 31st, 2019
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 312.79 KB | None | 0 0
  1.  
  2.  
  3.  
  4. // modShieldHood --- Start --------------------------------------------------
  5. public function ManageModShieldHoods( item : SItemUniqueId, isOnEquip : bool )
  6. {
  7. if ( inv.ItemHasTag( item, 'Hood' ) )
  8. {
  9. if (isOnEquip) {
  10. if( theGame.GetInGameConfigWrapper().GetVarValue( 'DLCShieldMenu', 'displayHair' ) )
  11. DisplayHair( true );
  12. }
  13. else {
  14. DisplayHair( false );
  15. }
  16. }
  17. }
  18. private function DisplayHair(display : bool)
  19. {
  20. var l_comp : CComponent;
  21. var hair : CEntityTemplate;
  22.  
  23. l_comp = thePlayer.GetComponentByClassName( 'CAppearanceComponent' );
  24. hair = (CEntityTemplate)LoadResource("dlc\kontusz\data\items\hoods\hood_hair\hair_hood.w2ent", true);
  25. if ( display ){
  26. ((CAppearanceComponent)l_comp).IncludeAppearanceTemplate(hair);
  27. }
  28. else {
  29. ((CAppearanceComponent)l_comp).ExcludeAppearanceTemplate(hair);
  30. }
  31. }
  32. // modShieldHood --- End ------------------------------------------------------
  33. // modShieldSkills --- Start --------------------------------------------------
  34. private var hiddenSkills : array<int>;
  35. private var isHiddenSkillsListInit : bool;
  36.  
  37. public function ManageModShieldSkills( item : SItemUniqueId, isOnEquip : bool )
  38. {
  39. var pam : W3PlayerAbilityManager;
  40. var skills : array<ESkill>;
  41. var i : int;
  42.  
  43. pam = (W3PlayerAbilityManager)GetWitcherPlayer().abilityManager;
  44. skills = GetHiddenSkillsFromItemID( item );
  45.  
  46. for (i = 0;i < skills.Size();i+=1)
  47. {
  48. if (isOnEquip)
  49. SetHiddenSkill( skills[i], pam.AddHiddenSkill( skills[i] ) );
  50. else
  51. pam.RemoveHiddenSkill( skills[i] );
  52. }
  53.  
  54. }
  55. public function SetHiddenSkill( skill : ESkill, level : int )
  56. {
  57. if (!isHiddenSkillsListInit)
  58. {
  59. InitHiddenSkillsList();
  60. isHiddenSkillsListInit = true;
  61. }
  62. hiddenSkills[skill] = level;
  63. }
  64. private function InitHiddenSkillsList()
  65. {
  66. hiddenSkills.Resize( EnumGetMax( 'ESkill' ) + 1 );
  67. }
  68. public function GetHiddenSkill( skill : ESkill ) : int
  69. {
  70. return hiddenSkills[skill];
  71. }
  72.  
  73. public function IsSkillGranted( skill : ESkill ) : bool
  74. {
  75. var itemNames : array<name>;
  76. var ret : bool;
  77. var i : int;
  78.  
  79. itemNames = GetItemNamesFromHiddenSkill( skill );
  80.  
  81. for (i = 0; i < itemNames.Size(); i+=1)
  82. {
  83. if ( GetWitcherPlayer().IsItemEquipped( inv.GetItemId( itemNames[i] ) ) )
  84. ret = true;
  85. }
  86.  
  87. return ret;
  88. }
  89. private function GetHiddenSkillsFromItemID( item : SItemUniqueId ) : array<ESkill>
  90. {
  91. var ret : array<ESkill>;
  92.  
  93. switch( inv.GetItemName(item) )
  94. {
  95. case 'Wanderer Armor' : {ret.PushBack(S_Alchemy_s03); ret.PushBack(S_Alchemy_s04); ret.PushBack(S_Alchemy_s17);break;}
  96. case 'Warden Armor' : {ret.PushBack(S_Magic_s01); ret.PushBack(S_Magic_s02); ret.PushBack(S_Magic_s03); ret.PushBack(S_Magic_s04); ret.PushBack(S_Magic_s05);break;}
  97. case 'Hunter Armor' : {ret.PushBack(S_Sword_s03); ret.PushBack(S_Sword_s10); ret.PushBack(S_Sword_s09); ret.PushBack(S_Sword_s11);break;}
  98. case 'Tracker Armor' : {ret.PushBack(S_Sword_s07); ret.PushBack(S_Sword_s12); ret.PushBack(S_Sword_s13); ret.PushBack(S_Sword_s15); ret.PushBack(S_Perk_02);break;}
  99. case 'Raven Armor' : {ret.PushBack(S_Sword_s01); ret.PushBack(S_Sword_s02);break;}
  100. case 'Shiadhal Armor' : {ret.PushBack(S_Magic_s08); ret.PushBack(S_Magic_s02); ret.PushBack(S_Magic_s07); ret.PushBack(S_Magic_s09);break;}
  101. case 'Astrogarus Armor' : {ret.PushBack(S_Magic_s06); ret.PushBack(S_Magic_s09); ret.PushBack(S_Magic_s11); ret.PushBack(S_Magic_s14); ret.PushBack(S_Magic_s19);break;}
  102. case 'Journeyman Armor' : {ret.PushBack(S_Alchemy_s14); ret.PushBack(S_Alchemy_s13);break;}
  103. case 'Oathbreaker Armor': {ret.PushBack(S_Perk_06);break;}
  104. case 'Kinslayer Armor' : {ret.PushBack(S_Perk_07);break;}
  105. //case '' : {ret.PushBack(S_Magic_s05);break;}
  106. default : {ret.PushBack(S_SUndefined);break;}
  107. }
  108.  
  109. return ret;
  110. }
  111. private function GetItemNamesFromHiddenSkill( skill : ESkill ) : array<name>
  112. {
  113. var ret : array<name>;
  114.  
  115. switch( skill )
  116. {
  117. case S_Magic_s01 : {ret.PushBack('Warden Armor');break;}
  118. case S_Magic_s02 : {ret.PushBack('Warden Armor'); ret.PushBack('Shiadhal Armor');break;}
  119. case S_Magic_s03 : {ret.PushBack('Warden Armor');break;}
  120. case S_Magic_s04 : {ret.PushBack('Warden Armor');break;}
  121. case S_Magic_s05 : {ret.PushBack('Warden Armor');break;}
  122. case S_Magic_s08 : {ret.PushBack('Shiadhal Armor');break;}
  123. case S_Magic_s07 : {ret.PushBack('Shiadhal Armor');break;}
  124. case S_Magic_s09 : {ret.PushBack('Shiadhal Armor'); ret.PushBack('Astrogarus Armor');break;}
  125. case S_Magic_s06 : {ret.PushBack('Astrogarus Armor');break;}
  126. case S_Magic_s11 : {ret.PushBack('Astrogarus Armor');break;}
  127. case S_Magic_s14 : {ret.PushBack('Astrogarus Armor');break;}
  128. case S_Magic_s19 : {ret.PushBack('Astrogarus Armor');break;}
  129. case S_Sword_s03 : {ret.PushBack('Hunter Armor');break;}
  130. case S_Sword_s09 : {ret.PushBack('Hunter Armor');break;}
  131. case S_Sword_s10 : {ret.PushBack('Hunter Armor');break;}
  132. case S_Sword_s11 : {ret.PushBack('Hunter Armor');break;}
  133. case S_Sword_s01 : {ret.PushBack('Raven Armor');break;}
  134. case S_Sword_s02 : {ret.PushBack('Raven Armor');break;}
  135. case S_Alchemy_s03 : {ret.PushBack('Wanderer Armor');break;}
  136. case S_Alchemy_s04 : {ret.PushBack('Wanderer Armor');break;}
  137. case S_Alchemy_s17 : {ret.PushBack('Wanderer Armor'); ret.PushBack('Journeyman Armor');break;}
  138. case S_Alchemy_s13 : {ret.PushBack('Journeyman Armor');break;}
  139. case S_Sword_s07 : {ret.PushBack('Tracker Armor');break;}
  140. case S_Sword_s12 : {ret.PushBack('Tracker Armor');break;}
  141. case S_Sword_s13 : {ret.PushBack('Tracker Armor');break;}
  142. case S_Sword_s15 : {ret.PushBack('Tracker Armor');break;}
  143. case S_Perk_02 : {ret.PushBack('Tracker Armor');break;}
  144. case S_Perk_06 : {ret.PushBack('Oathbreaker Armor');break;}
  145. case S_Perk_07 : {ret.PushBack('Oathbreaker Armor');break;}
  146. default : {ret.PushBack('');break;}
  147. }
  148. return ret;
  149. }
  150. // modShieldSkills --- End --------------------------------------------------
  151.  
  152. // modShieldCombat --- Start --------------------------------------------------
  153. private var hitShieldCount : int;
  154. private var previousAttacker : CActor;
  155.  
  156. public function ProcessShieldParry(optional parryInfo : SParryInfo, optional isArrow : bool, optional shield : W3DLCShield)
  157. {
  158. var anim : CName;
  159. var rand : int;
  160.  
  161. var parryDir : EPlayerParryDirection;
  162. var parryHeading : float;
  163.  
  164. var staminaDrain : int;
  165.  
  166. staminaDrain = StringToInt(theGame.GetInGameConfigWrapper().GetVarValue( 'DLCShieldMenu', 'staminaDrain' ));
  167.  
  168. if(isArrow)
  169. {
  170. rand = RandRange(0,2);
  171. switch(rand){
  172. case 0:
  173. anim = 'man_npc_shield_block_rp_01';
  174. break;
  175. case 1:
  176. anim = 'man_npc_shield_block_rp_02';
  177. break;
  178. }
  179.  
  180. thePlayer.ActionPlaySlotAnimationAsync( 'PLAYER_SLOT', anim, 0.2, 0.2 );
  181.  
  182. parryHeading = GetParryHeading( parryInfo, parryDir ) ;
  183.  
  184. DrainStamina(ESAT_FixedValue, staminaDrain);
  185.  
  186. OnCombatActionStart();
  187. ClearCustomOrientationInfoStack();
  188. SetSlideTarget( parryInfo.attacker );
  189. SetCustomRotation( 'Parry', parryHeading, 1080.f, 0.1f, false );
  190. }
  191. else
  192. {
  193. rand = RandRange(0,2);
  194. switch(rand){
  195. case 0:
  196. anim = 'man_npc_shield_block_rp_01';
  197. break;
  198. case 1:
  199. anim = 'man_npc_shield_block_rp_02';
  200. break;
  201. }
  202.  
  203. thePlayer.ActionPlaySlotAnimationAsync( 'PLAYER_SLOT', anim, 0.2, 0.2 );
  204.  
  205. parryHeading = GetParryHeading( parryInfo, parryDir ) ;
  206.  
  207. SetBehaviorVariable( 'parryDirection', (float)( (int)( parryDir ) ) );
  208. SetBehaviorVariable( 'parryDirectionOverlay', (float)( (int)( parryDir ) ) );
  209. SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
  210.  
  211.  
  212. OnCombatActionStart();
  213. ClearCustomOrientationInfoStack();
  214. SetSlideTarget( parryInfo.attacker );
  215. SetCustomRotation( 'Parry', parryHeading, 1080.f, 0.1f, false );
  216. IncDefendCounter();
  217.  
  218. DrainStamina(ESAT_FixedValue, staminaDrain);
  219.  
  220. if(parryInfo.attacker == previousAttacker){
  221. if(hitShieldCount > RandRange( (int)shield.GetStaggerMin() ,(int)shield.GetStaggerMax() ) ){
  222. parryInfo.attacker.AddEffectDefault( EET_Stagger, thePlayer, "ParryStagger" );
  223. hitShieldCount = 0;
  224. }
  225.  
  226. hitShieldCount += 1;
  227. }
  228. else{
  229. hitShieldCount = 0;
  230. }
  231.  
  232. previousAttacker = parryInfo.attacker;
  233. }
  234. }
  235. public function DestroyArrows(arrows : array<W3ArrowProjectile>)
  236. {
  237. var i : int;
  238.  
  239. for(i = 0; i < arrows.Size(); i += 1)
  240. {
  241. arrows[i].AddTimer( 'TimeDestroy', 0.f, false );
  242. }
  243. }
  244. // modShieldCombat --- End --------------------------------------------------
  245.  
  246.  
  247. function PerformParryCheck( parryInfo : SParryInfo) : bool
  248. function PerformParryCheck( parryInfo : SParryInfo) : bool
  249. {
  250. var mult : float;
  251. var parryType : EParryType;
  252. var parryDir : EPlayerParryDirection;
  253. var parryHeading : float;
  254. var fistFightParry : bool;
  255. var action : W3DamageAction;
  256. var xmlStaminaDamage : float;
  257. var xmlStaminaDamageName : name = 'stamina_damage' ;
  258. var counter : int;
  259. var onHitCounter : SAbilityAttributeValue;
  260.  
  261. {
  262. var mult : float;
  263. var parryType : EParryType;
  264. var parryDir : EPlayerParryDirection;
  265. var parryHeading : float;
  266. var fistFightParry : bool;
  267. var action : W3DamageAction;
  268. var xmlStaminaDamage : float;
  269. var xmlStaminaDamageName : name = 'stamina_damage' ;
  270. var counter : int;
  271. var onHitCounter : SAbilityAttributeValue;
  272.  
  273. // modShieldCombat --- Start --------------------------------------------------
  274. var itemId : SItemUniqueId;
  275. var shield : W3DLCShield;
  276.  
  277. var npc : CNewNPC;
  278. var testedAngle, staminaNeeded : float;
  279. var infront, cantParryFromBehind : bool;
  280.  
  281. cantParryFromBehind = theGame.GetInGameConfigWrapper().GetVarValue( 'DLCShieldMenu', 'cantParryFromBehind' );
  282.  
  283. itemId = thePlayer.GetInventory().GetItemFromSlot('l_weapon');
  284. shield = (W3DLCShield)GetInventory().GetItemEntityUnsafe(itemId);
  285.  
  286. npc = (CNewNPC)parryInfo.attacker;
  287. testedAngle = AngleDistance( VecHeading( npc.GetWorldPosition() - thePlayer.GetWorldPosition() ) , thePlayer.GetHeading() );
  288.  
  289. if ( testedAngle < 100 && testedAngle > -70 )
  290. {
  291. infront = true;
  292. }
  293. else
  294. {
  295. if(!cantParryFromBehind)
  296. {
  297. infront = false;
  298. }
  299. else
  300. {
  301. if(shield)
  302. {
  303. return false;
  304. }
  305. }
  306.  
  307. }
  308.  
  309. if( shield && IsGuarded() && infront)
  310. {
  311. staminaNeeded = StringToFloat(theGame.GetInGameConfigWrapper().GetVarValue( 'DLCShieldMenu', 'staminaNeeded' ));
  312.  
  313. if(GetStaminaPercents() < staminaNeeded/100)
  314. {
  315. return false;
  316. }
  317.  
  318. ProcessShieldParry(parryInfo, , shield);
  319.  
  320. shield.PlayEffect('light_block');
  321.  
  322. return true;
  323. }
  324. // modShieldCombat --- End --------------------------------------------------
  325.  
  326.  
  327.  
  328.  
  329. if(CanParryAttack() && FistFightCheck( parryInfo.target, parryInfo.attacker, fistFightParry ) )
  330. {
  331. parryHeading = GetParryHeading( parryInfo, parryDir ) ;
  332.  
  333. SetBehaviorVariable( 'parryDirection', (float)( (int)( parryDir ) ) );
  334. SetBehaviorVariable( 'parryDirectionOverlay', (float)( (int)( parryDir ) ) );
  335. SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
  336.  
  337. if ( IsInCombatActionFriendly() )
  338. RaiseEvent('CombatActionFriendlyEnd');
  339.  
  340. if ( HasStaminaToParry(parryInfo.attackActionName) )
  341. {
  342. this.SetBehaviorVariable( 'combatActionType', (int)CAT_Parry );
  343.  
  344. if ( parryInfo.targetToAttackerDist > 3.f && !bLAxisReleased && !thePlayer.IsCiri() )
  345. {
  346. if ( !RaiseForceEvent( 'PerformParryOverlay' ) )
  347. return false;
  348. else
  349. {
  350. ClearCustomOrientationInfoStack();
  351. IncDefendCounter();
  352. }
  353. }
  354. else
  355. {
  356. counter = GetDefendCounter();
  357. onHitCounter = parryInfo.attacker.GetAttributeValue( 'break_through_parry_on_hit_counter' );
  358. if ( onHitCounter.valueBase > 0 && counter == onHitCounter.valueBase )
  359. {
  360. AddEffectDefault( EET_Stagger, parryInfo.attacker, "Break through parry" );
  361. }
  362. else if ( RaiseForceEvent( 'PerformParry' ) )
  363. {
  364. OnCombatActionStart();
  365. ClearCustomOrientationInfoStack();
  366. SetSlideTarget( parryInfo.attacker );
  367. SetCustomRotation( 'Parry', parryHeading, 1080.f, 0.1f, false );
  368. IncDefendCounter();
  369. }
  370. else
  371. return false;
  372. }
  373. }
  374. else
  375. {
  376. AddEffectDefault(EET_Stagger, parryInfo.attacker, "Parry");
  377. return true;
  378. }
  379.  
  380. if ( parryInfo.attacker.IsWeaponHeld( 'fist' ) && !parryInfo.target.IsWeaponHeld( 'fist' ) )
  381. {
  382. parryInfo.attacker.ReactToReflectedAttack(parryInfo.target);
  383. }
  384. else
  385. {
  386. if ( this.IsInFistFightMiniGame() && fistFightParry )
  387. {
  388. if ( IsNameValid(xmlStaminaDamageName) )
  389. {
  390. xmlStaminaDamage = CalculateAttributeValue(parryInfo.attacker.GetAttributeValue( xmlStaminaDamageName ));
  391. DrainStamina(ESAT_FixedValue, xmlStaminaDamage);
  392. }
  393. }
  394. else
  395. {
  396. DrainStamina(ESAT_Parry, 0, 0, '', 0, mult);
  397. }
  398. if(IsLightAttack(parryInfo.attackActionName))
  399. parryInfo.target.PlayEffectOnHeldWeapon('light_block');
  400. else
  401. parryInfo.target.PlayEffectOnHeldWeapon('heavy_block');
  402. }
  403. return true;
  404. }
  405.  
  406. return false;
  407. }
  408.  
  409. protected function GetParryHeading( parryInfo : SParryInfo, out parryDir : EPlayerParryDirection ) : float
  410. {
  411. var targetToAttackerHeading : float;
  412. var currToTargetAttackerAngleDiff : float;
  413.  
  414. targetToAttackerHeading = VecHeading( parryInfo.attacker.GetWorldPosition() - parryInfo.target.GetWorldPosition() );
  415. currToTargetAttackerAngleDiff = AngleDistance( VecHeading( parryInfo.target.GetHeadingVector() ), targetToAttackerHeading );
  416.  
  417. if ( !parryInfo.target.IsWeaponHeld( 'fist' ) )
  418. {
  419. if( currToTargetAttackerAngleDiff > -45 && currToTargetAttackerAngleDiff < 45 )
  420. {
  421. parryDir = PPD_Forward;
  422. return targetToAttackerHeading;
  423. }
  424. else if( currToTargetAttackerAngleDiff >= 45 && currToTargetAttackerAngleDiff < 135 )
  425. {
  426. parryDir = PPD_Right;
  427.  
  428. return targetToAttackerHeading + 90;
  429. }
  430. else if( currToTargetAttackerAngleDiff <= -45 && currToTargetAttackerAngleDiff > -135 )
  431. {
  432. parryDir = PPD_Left;
  433.  
  434. return targetToAttackerHeading - 90;
  435. }
  436. else
  437. {
  438. parryDir = PPD_Back;
  439.  
  440. return targetToAttackerHeading + 180;
  441. }
  442. }
  443. else
  444. {
  445. if( currToTargetAttackerAngleDiff > -45 && currToTargetAttackerAngleDiff < 45 )
  446. {
  447. parryDir = PPD_Forward;
  448. return targetToAttackerHeading;
  449. }
  450. else if( currToTargetAttackerAngleDiff >= 45 && currToTargetAttackerAngleDiff < 180 )
  451. {
  452. parryDir = PPD_Right;
  453. return targetToAttackerHeading + 90;
  454. }
  455. else if( currToTargetAttackerAngleDiff <= -45 && currToTargetAttackerAngleDiff >= -180 )
  456. {
  457. parryDir = PPD_Left;
  458. return targetToAttackerHeading - 90;
  459. }
  460. else
  461. {
  462. parryDir = PPD_Back;
  463. return targetToAttackerHeading + 180;
  464. }
  465. }
  466. }
  467.  
  468. function ProcessLockTarget( optional newLockTarget : CActor, optional checkLeftStickHeading : bool ) : bool
  469. {
  470. var attackerNearestPoint : Vector;
  471. var playerNearestPoint : Vector;
  472. var incomingAttacker : CActor;
  473. var tempLockTarget : CActor;
  474. var target : CActor;
  475. var useIncomingAttacker : bool;
  476.  
  477. if( newLockTarget.HasTag( 'NoHardLock' ) )
  478. return false;
  479.  
  480. if ( newLockTarget )
  481. tempLockTarget = newLockTarget;
  482. else
  483. {
  484. incomingAttacker = GetClosestIncomingAttacker();
  485. if ( incomingAttacker && incomingAttacker.IsAlive() && IsUsingVehicle() )
  486. {
  487. tempLockTarget = incomingAttacker;
  488. useIncomingAttacker = false;
  489. }
  490.  
  491. if ( !useIncomingAttacker )
  492. {
  493. target = GetTarget();
  494. if( target.HasTag('ForceHardLock'))
  495. {
  496. return true;
  497. }
  498. else if ( target && target.IsAlive() && target.GetGameplayVisibility() && IsEnemyVisible( target ) && IsThreat( target ) && CanBeTargetedIfSwimming( target ) )
  499. tempLockTarget = FindTarget();
  500. else
  501. {
  502. tempLockTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, 0.f );
  503. }
  504. }
  505. }
  506.  
  507. if( tempLockTarget.HasTag( 'NoHardLock' ) )
  508. return false;
  509.  
  510. if ( tempLockTarget )
  511. {
  512. if ( IsCombatMusicEnabled() || hostileEnemies.Size() > 0 )
  513. {
  514. if ( !IsThreat( tempLockTarget ) )
  515. tempLockTarget = NULL;
  516. }
  517. }
  518.  
  519. SetTarget( tempLockTarget, true );
  520. SetMoveTargetChangeAllowed( true );
  521. SetMoveTarget( tempLockTarget );
  522. SetMoveTargetChangeAllowed( false );
  523. SetSlideTarget( tempLockTarget );
  524.  
  525. if ( tempLockTarget )
  526. {
  527. if ( this.IsActorLockedToTarget() )
  528. EnableHardLockIcon( true );
  529.  
  530. return true;
  531. }
  532. else
  533. return false;
  534. }
  535.  
  536.  
  537.  
  538.  
  539.  
  540. event OnTaskSyncAnim( npc : CNewNPC, animNameLeft : name ) {}
  541.  
  542.  
  543. public function IsDoingSpecialAttack(heavy : bool) : bool
  544. {
  545. var pat : EPlayerAttackType;
  546.  
  547. if(IsInCombatAction() && ( (int)GetBehaviorVariable('combatActionType')) == CAT_SpecialAttack)
  548. {
  549. pat = (int)GetBehaviorVariable('playerAttackType');
  550.  
  551. if(heavy && pat == PAT_Heavy)
  552. {
  553. return true;
  554. }
  555. else if(!heavy && pat == PAT_Light)
  556. {
  557. return true;
  558. }
  559. }
  560.  
  561. return false;
  562. }
  563.  
  564. public function SetIsCurrentlyDodging(enable : bool, optional isRolling : bool)
  565. {
  566. super.SetIsCurrentlyDodging(enable, isRolling);
  567.  
  568. if ( isRolling )
  569. {
  570. SetCanPlayHitAnim( false );
  571. this.AddBuffImmunity( EET_KnockdownTypeApplicator, 'Roll', false );
  572. this.AddBuffImmunity( EET_Knockdown, 'Roll', false );
  573. this.AddBuffImmunity( EET_HeavyKnockdown, 'Roll', false );
  574. this.AddBuffImmunity( EET_Stagger, 'Roll', false );
  575. }
  576. else
  577. {
  578. SetCanPlayHitAnim( true );
  579. this.RemoveBuffImmunity( EET_KnockdownTypeApplicator, 'Roll' );
  580. this.RemoveBuffImmunity( EET_Knockdown, 'Roll' );
  581. this.RemoveBuffImmunity( EET_HeavyKnockdown, 'Roll' );
  582. this.RemoveBuffImmunity( EET_Stagger, 'Roll' );
  583. }
  584. }
  585.  
  586. public function EnableHardLock( flag : bool )
  587. {
  588. super.EnableHardLock(flag);
  589.  
  590. if(flag && ShouldProcessTutorial('TutorialTargettingWaiting'))
  591. {
  592. FactsAdd("tut_hardlocked");
  593. }
  594. }
  595.  
  596. protected function TestParryAndCounter(data : CPreAttackEventData, weaponId : SItemUniqueId, out parried : bool, out countered : bool) : array<CActor>
  597. {
  598. var ret : array<CActor>;
  599.  
  600.  
  601. if(FactsQuerySum('player_is_the_boss') > 0)
  602. {
  603.  
  604.  
  605. SetDebugAttackRange(data.rangeName);
  606. RemoveTimer('PostAttackDebugRangeClear');
  607.  
  608. return ret;
  609. }
  610.  
  611. ret = super.TestParryAndCounter(data, weaponId, parried, countered);
  612.  
  613.  
  614. if(parried)
  615. theGame.GetGamerProfile().ResetStat(ES_CounterattackChain);
  616.  
  617. return ret;
  618. }
  619.  
  620. public function SetSpecialAttackTimeRatio(f : float)
  621. {
  622. LogSpecialHeavy(f);
  623. specialAttackTimeRatio = f;
  624. }
  625.  
  626. public function GetSpecialAttackTimeRatio() : float
  627. {
  628. return specialAttackTimeRatio;
  629. }
  630.  
  631.  
  632. public function OnSpecialAttackHeavyActionProcess()
  633. {
  634.  
  635. SetSpecialAttackTimeRatio(0.f);
  636. }
  637.  
  638. protected function DoAttack(animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float)
  639. {
  640. var shakeStr : float;
  641. var weapon : EPlayerWeapon;
  642. var targetActor : CActor;
  643.  
  644.  
  645. if ( animData.attackName == 'attack_heavy_special' )
  646. {
  647. if( specialAttackTimeRatio != 1 )
  648. shakeStr = (specialAttackTimeRatio / 3.333) + 0.2;
  649. else
  650. shakeStr = 0.5;
  651.  
  652. GCameraShake( shakeStr, false, GetWorldPosition(), 10);
  653. }
  654. else if ( IsHeavyAttack(attackActionName) )
  655. {
  656. if(parriedBy.Size() > 0)
  657. shakeStr = 0.2;
  658. else
  659. shakeStr = 0.1;
  660.  
  661. GCameraShake(shakeStr, false, GetWorldPosition(), 10);
  662. }
  663.  
  664. targetActor = (CActor)slideTarget;
  665. if ( targetActor && hitTargets.Contains(targetActor) )
  666. {
  667. weapon = this.GetMostConvenientMeleeWeapon(targetActor,true);
  668. if ( this.GetCurrentMeleeWeaponType() != PW_Fists && weapon != this.GetCurrentMeleeWeaponType() )
  669. {
  670. if ( weapon == PW_Steel )
  671. {
  672. thePlayer.OnEquipMeleeWeapon(PW_Steel,true);
  673. }
  674. else if ( weapon == PW_Silver )
  675. {
  676. thePlayer.OnEquipMeleeWeapon(PW_Silver,true);
  677. }
  678.  
  679. }
  680. }
  681.  
  682. super.DoAttack(animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime);
  683. }
  684.  
  685.  
  686.  
  687. private var confirmCombatStanceTimeStamp : float;
  688. private var isConfirmingCombatStance : bool;
  689. final function SetPlayerCombatStance(stance : EPlayerCombatStance, optional force : bool )
  690. {
  691. var stanceInt : int;
  692.  
  693. if ( !CanChangeCombatStance( stance, force ) )
  694. return;
  695.  
  696. combatStance = stance;
  697. stanceInt = (int)stance;
  698.  
  699. SetBehaviorVariable( 'playerCombatStance' , (float)stanceInt);
  700. SetBehaviorVariable( 'playerCombatStanceForOverlay' , (float)stanceInt);
  701. if ( force )
  702. SetBehaviorVariable( 'forceCombatStance' , 1.f);
  703. else
  704. SetBehaviorVariable( 'forceCombatStance' , 0.f);
  705.  
  706. if ( stance == PCS_AlertNear )
  707. this.SetBehaviorVariable('isInCombatForOverlay',1.f);
  708. else
  709. this.SetBehaviorVariable('isInCombatForOverlay',0.f);
  710. }
  711.  
  712. private function CanChangeCombatStance( stance : EPlayerCombatStance, optional force : bool ) : bool
  713. {
  714. var currTime : float;
  715.  
  716. if ( force )
  717. return true;
  718.  
  719. if ( IsInFistFightMiniGame() )
  720. return true;
  721.  
  722. if ( isInHolsterAnim )
  723. return false;
  724.  
  725. if ( ( combatStance == PCS_Normal || combatStance == PCS_AlertFar ) && stance == PCS_AlertNear )
  726. {
  727. currTime = theGame.GetEngineTimeAsSeconds();
  728. if ( !isConfirmingCombatStance )
  729. {
  730. isConfirmingCombatStance = true;
  731. confirmCombatStanceTimeStamp = currTime;
  732.  
  733. return false;
  734. }
  735. else if ( currTime < confirmCombatStanceTimeStamp + 1.f )
  736. {
  737. if ( stance == PCS_AlertNear )
  738. return false;
  739. }
  740. else
  741. isConfirmingCombatStance = false;
  742. }
  743. else
  744. isConfirmingCombatStance = false;
  745.  
  746. return true;
  747. }
  748.  
  749. private var isInHolsterAnim : bool;
  750. event OnHolsterWeaponStart()
  751. {
  752. isInHolsterAnim = true;
  753. }
  754.  
  755. event OnHolsterWeaponEnd()
  756. {
  757. isInHolsterAnim = false;
  758. }
  759.  
  760. final function GetPlayerCombatStance() : EPlayerCombatStance
  761. {
  762. return combatStance;
  763. }
  764.  
  765. timer function DelayedDisableFindTarget( time : float , id : int)
  766. {
  767. if ( GetTarget().IsAlive() )
  768. {
  769. EnableFindTarget( false );
  770. }
  771. else
  772. {
  773. EnableFindTarget( true );
  774. }
  775. }
  776.  
  777.  
  778.  
  779.  
  780.  
  781. private var dodgeTimerRunning : bool;
  782.  
  783. function StartDodgeTimer()
  784. {
  785. dodgeTimerRunning = true;
  786. thePlayer.AddTimer('DodgeTimer',0.2,false);
  787. }
  788.  
  789. function StopDodgeTimer()
  790. {
  791. this.RemoveTimer('DodgeTimer');
  792. dodgeTimerRunning = false;
  793. }
  794.  
  795. function IsDodgeTimerRunning() : bool
  796. {
  797. return dodgeTimerRunning;
  798. }
  799.  
  800. timer function DodgeTimer( dt : float, id : int )
  801. {
  802. dodgeTimerRunning = false;
  803. }
  804.  
  805. public function EvadePressed( bufferAction : EBufferActionType )
  806. {
  807. }
  808.  
  809. public function PerformingCombatAction() : EBufferActionType
  810. {
  811. return BufferCombatAction;
  812. }
  813.  
  814. public function PushCombatActionOnBuffer( action : EBufferActionType, stage : EButtonStage, optional allSteps : bool )
  815. {
  816. BufferButtonStage = stage;
  817. BufferCombatAction = action;
  818. BufferAllSteps = allSteps;
  819. }
  820.  
  821. protected function ProcessCombatActionHeading( action : EBufferActionType ) : float
  822. {
  823. var processedActionHeading : float;
  824.  
  825. HandleMovement( 0.f );
  826.  
  827. if ( ShouldUsePCModeTargeting() )
  828. return theGame.GetGameCamera().GetHeading();
  829.  
  830. if ( lAxisReleasedAfterCounter )
  831. ResetCachedRawPlayerHeading();
  832.  
  833. processedActionHeading = cachedRawPlayerHeading;
  834.  
  835. return processedActionHeading;
  836. }
  837.  
  838.  
  839. function ResetRawPlayerHeading()
  840. {
  841. if ( GetDisplayTarget() )
  842. rawPlayerHeading = VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() );
  843. else
  844. rawPlayerHeading = GetHeading();
  845.  
  846.  
  847. }
  848.  
  849. function ResetCachedRawPlayerHeading()
  850. {
  851. cachedRawPlayerHeading = rawPlayerHeading;
  852. if ( GetDisplayTarget() && IsDisplayTargetTargetable() && AbsF( AngleDistance( VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() ), this.GetHeading() ) ) < 90.f )
  853. cachedRawPlayerHeading = VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() );
  854. else
  855. cachedRawPlayerHeading = this.GetHeading();
  856.  
  857. if ( canResetCachedCombatActionHeading )
  858. cachedCombatActionHeading = cachedRawPlayerHeading;
  859. }
  860.  
  861. public function GetCombatActionTarget( action : EBufferActionType ) : CGameplayEntity
  862. {
  863. var selectedTargetableEntity : CGameplayEntity;
  864.  
  865. if ( !this.IsUsingVehicle() )
  866. selectedTargetableEntity = FindNonActorTarget( true, action );
  867.  
  868. if ( selectedTargetableEntity )
  869. {
  870. return selectedTargetableEntity;
  871. }
  872. else
  873. {
  874.  
  875.  
  876. if ( !this.IsUsingVehicle() )
  877. FindTarget( true, action, true );
  878. else
  879. ((CR4PlayerStateUseGenericVehicle)this.GetState( 'UseGenericVehicle' )).FindTarget();
  880.  
  881. return GetTarget();
  882. }
  883. }
  884.  
  885.  
  886. private function FindNonActorTarget( actionCheck : bool, optional action : EBufferActionType ) : CGameplayEntity
  887. {
  888. var targetableEntities : array<CGameplayEntity>;
  889. var selectedTargetableEntity : CGameplayEntity;
  890. var selectionPriority : array< float >;
  891. var selectionWeights : STargetSelectionWeights;
  892. var findEntityDist : float;
  893. var i, size : int;
  894. var playerHeading : float;
  895. var playerInventory : CInventoryComponent;
  896. var castSignType : ESignType;
  897. var targetingInfo : STargetingInfo;
  898. var playerPosition : Vector;
  899. var cameraPosition : Vector;
  900. var playerHeadingVector : Vector;
  901. var rawPlayerHeadingVector : Vector;
  902.  
  903. playerPosition = this.GetWorldPosition();
  904. cameraPosition = theCamera.GetCameraPosition();
  905. rawPlayerHeadingVector = VecFromHeading( rawPlayerHeading );
  906.  
  907. if ( bCanFindTarget && !IsHardLockEnabled() )
  908. {
  909. if ( actionCheck && IsInCombat() && action == EBAT_CastSign )
  910. {
  911. findEntityDist = 6.f;
  912. selectionWeights.angleWeight = 0.375f;
  913. selectionWeights.distanceWeight = 0.275f;
  914. selectionWeights.distanceRingWeight = 0.35f;
  915. }
  916. else if ( !IsInCombat() && lastAxisInputIsMovement )
  917. {
  918. findEntityDist = softLockDist;
  919. selectionWeights.angleWeight = 0.375f;
  920. selectionWeights.distanceWeight = 0.275f;
  921. selectionWeights.distanceRingWeight = 0.35f;
  922. }
  923. else
  924. {
  925. findEntityDist = softLockDist;
  926. selectionWeights.angleWeight = 0.75f;
  927. selectionWeights.distanceWeight = 0.125f;
  928. selectionWeights.distanceRingWeight = 0.125f;
  929. }
  930.  
  931.  
  932. if ( !IsInCombat() || !bLAxisReleased )
  933. {
  934. FindGameplayEntitiesInRange( targetableEntities, this, findEntityDist, 10, theGame.params.TAG_SOFT_LOCK );
  935. }
  936.  
  937. if ( targetableEntities.Size() > 0 )
  938. {
  939. playerInventory = this.GetInventory();
  940. castSignType = this.GetEquippedSign();
  941.  
  942. if ( !bLAxisReleased )
  943. {
  944. targetingInfo.source = this;
  945. targetingInfo.canBeTargetedCheck = false;
  946. targetingInfo.coneCheck = true;
  947. targetingInfo.coneHalfAngleCos = 0.5f;
  948. targetingInfo.coneDist = softLockDist;
  949. targetingInfo.coneHeadingVector = rawPlayerHeadingVector;
  950. targetingInfo.distCheck = true;
  951. targetingInfo.invisibleCheck = false;
  952. targetingInfo.navMeshCheck = false;
  953. targetingInfo.frameScaleX = 1.0f;
  954. targetingInfo.frameScaleY = 1.0f;
  955. targetingInfo.knockDownCheck = false;
  956. targetingInfo.knockDownCheckDist = 0.0f;
  957. targetingInfo.rsHeadingCheck = false;
  958. targetingInfo.rsHeadingLimitCos = 1.0f;
  959. }
  960.  
  961. for( i = targetableEntities.Size()-1; i>=0; i-=1 )
  962. {
  963. if ( bLAxisReleased )
  964. {
  965. if ( !lastAxisInputIsMovement )
  966. {
  967. if ( !WasVisibleInScaledFrame( targetableEntities[i], 0.9f, 0.9f ) )
  968. {
  969. targetableEntities.Erase(i);
  970. continue;
  971. }
  972. }
  973. else if ( !WasVisibleInScaledFrame( targetableEntities[i], 1.f, 1.f ) )
  974. {
  975. targetableEntities.Erase(i);
  976. continue;
  977. }
  978. }
  979. else
  980. {
  981. targetingInfo.targetEntity = targetableEntities[i];
  982. if ( actionCheck && moveTarget )
  983. {
  984. targetingInfo.inFrameCheck = false;
  985. if ( !IsEntityTargetable( targetingInfo ) )
  986. {
  987. targetableEntities.Erase(i);
  988. continue;
  989. }
  990. }
  991. else
  992. {
  993. targetingInfo.inFrameCheck = true;
  994. if ( !IsEntityTargetable( targetingInfo ) )
  995. {
  996. targetableEntities.Erase(i);
  997. continue;
  998. }
  999. }
  1000. }
  1001.  
  1002. if ( actionCheck )
  1003. {
  1004. if ( action == EBAT_ItemUse )
  1005. {
  1006. if ( ( playerInventory.IsItemBomb( this.GetSelectedItemId() ) && !targetableEntities[i].HasTag( 'softLock_Bomb' ) )
  1007. || ( playerInventory.IsItemCrossbow( this.GetSelectedItemId() ) && !targetableEntities[i].HasTag( 'softLock_Bolt' ) ) )
  1008. {
  1009. targetableEntities.Erase(i);
  1010. continue;
  1011. }
  1012. }
  1013. else if ( action == EBAT_CastSign )
  1014. {
  1015. if ( ( castSignType == ST_Aard && !targetableEntities[i].HasTag( 'softLock_Aard' ) )
  1016. || ( castSignType == ST_Igni && !targetableEntities[i].HasTag( 'softLock_Igni' ) )
  1017. || ( castSignType == ST_Axii && !targetableEntities[i].HasTag( 'softLock_Axii' ) )
  1018. || castSignType == ST_Yrden
  1019. || castSignType == ST_Quen )
  1020. {
  1021. targetableEntities.Erase(i);
  1022. continue;
  1023. }
  1024. }
  1025. else if ( action == EBAT_LightAttack || action == EBAT_HeavyAttack || action == EBAT_SpecialAttack_Heavy )
  1026. {
  1027. if ( ( IsWeaponHeld( 'fist' ) && !targetableEntities[i].HasTag( 'softLock_Fist' ) ) || ( !IsWeaponHeld( 'fist' ) && !targetableEntities[i].HasTag( 'softLock_Weapon' ) ) )
  1028. {
  1029. targetableEntities.Erase(i);
  1030. continue;
  1031. }
  1032. }
  1033. else
  1034. {
  1035. targetableEntities.Erase(i);
  1036. continue;
  1037. }
  1038. }
  1039. }
  1040. }
  1041.  
  1042. if ( targetableEntities.Size() > 0)
  1043. {
  1044. playerHeading = this.GetHeading();
  1045. playerHeadingVector = this.GetHeadingVector();
  1046. if ( IsInCombat() )
  1047. {
  1048. for( i = 0; i < targetableEntities.Size(); i += 1 )
  1049. {
  1050. if ( bLAxisReleased )
  1051. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, cameraPosition, rawPlayerHeadingVector ) );
  1052. else
  1053. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, rawPlayerHeadingVector ) );
  1054. }
  1055.  
  1056. if ( selectionPriority.Size() > 0 )
  1057. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  1058. }
  1059. else
  1060. {
  1061. if ( bLAxisReleased )
  1062. {
  1063. if ( !lastAxisInputIsMovement )
  1064. {
  1065. for( i = 0; i < targetableEntities.Size(); i += 1 )
  1066. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, cameraPosition, rawPlayerHeadingVector ) );
  1067.  
  1068. if ( selectionPriority.Size() > 0 )
  1069. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  1070. }
  1071. else
  1072. {
  1073. if ( IsInCombatAction() )
  1074. selectedTargetableEntity = nonActorTarget;
  1075. else
  1076. {
  1077. for( i = 0; i < targetableEntities.Size(); i += 1 )
  1078. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, playerHeadingVector ) );
  1079.  
  1080. if ( selectionPriority.Size() > 0 )
  1081. {
  1082. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  1083.  
  1084. targetingInfo.source = this;
  1085. targetingInfo.targetEntity = selectedTargetableEntity;
  1086. targetingInfo.canBeTargetedCheck = false;
  1087. targetingInfo.coneCheck = true;
  1088. targetingInfo.coneHalfAngleCos = 0.0f;
  1089. targetingInfo.coneDist = softLockDist;
  1090. targetingInfo.coneHeadingVector = this.GetHeadingVector();
  1091. targetingInfo.distCheck = true;
  1092. targetingInfo.invisibleCheck = false;
  1093. targetingInfo.navMeshCheck = false;
  1094. targetingInfo.inFrameCheck = false;
  1095. targetingInfo.frameScaleX = 1.0f;
  1096. targetingInfo.frameScaleY = 1.0f;
  1097. targetingInfo.knockDownCheck = false;
  1098. targetingInfo.knockDownCheckDist = 0.0f;
  1099. targetingInfo.rsHeadingCheck = false;
  1100. targetingInfo.rsHeadingLimitCos = 1.0f;
  1101.  
  1102. if ( !IsEntityTargetable( targetingInfo ) )
  1103. selectedTargetableEntity = NULL;
  1104. }
  1105. }
  1106. }
  1107. }
  1108. else
  1109. {
  1110. for( i = 0; i < targetableEntities.Size(); i += 1 )
  1111. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, rawPlayerHeadingVector ) );
  1112.  
  1113. if ( selectionPriority.Size() > 0 )
  1114. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  1115. }
  1116. }
  1117. }
  1118. else
  1119. selectedTargetableEntity = NULL;
  1120. }
  1121.  
  1122. SetNonActorTarget( selectedTargetableEntity );
  1123. return selectedTargetableEntity;
  1124. }
  1125.  
  1126.  
  1127. public function SetupCombatAction( action : EBufferActionType, stage : EButtonStage )
  1128. {
  1129. var weaponType : EPlayerWeapon;
  1130. var canAttackTarget : CGameplayEntity;
  1131. var target : CActor;
  1132.  
  1133.  
  1134. if ( !IsCombatMusicEnabled() )
  1135. {
  1136. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  1137. FindTarget();
  1138. UpdateDisplayTarget( true );
  1139. }
  1140.  
  1141. if ( displayTarget && IsDisplayTargetTargetable() )
  1142. canAttackTarget = displayTarget;
  1143. else if ( GetTarget() )
  1144. canAttackTarget = GetTarget();
  1145. else if( !target && IsCombatMusicEnabled() )
  1146. canAttackTarget = moveTarget;
  1147.  
  1148. target = (CActor)canAttackTarget;
  1149.  
  1150. if ( !AllowAttack( target, action ) )
  1151. return;
  1152.  
  1153. if( ( action != EBAT_ItemUse ) && ( action != EBAT_CastSign ) )
  1154. {
  1155. weaponType = weaponHolster.GetCurrentMeleeWeapon();
  1156. PrepareToAttack( target, action );
  1157.  
  1158.  
  1159. if ( weaponType != weaponHolster.GetCurrentMeleeWeapon() )
  1160. {
  1161.  
  1162. if ( !( weaponType == PW_None && weaponHolster.GetCurrentMeleeWeapon() == PW_Fists ) )
  1163. return;
  1164. }
  1165. }
  1166.  
  1167.  
  1168. if(action == EBAT_SpecialAttack_Heavy && !((W3ReplacerCiri)this) )
  1169. thePlayer.SetAttackActionName(SkillEnumToName(S_Sword_s02));
  1170.  
  1171. CriticalEffectAnimationInterrupted("SetupCombatAction " + action);
  1172. PushCombatActionOnBuffer( action, stage );
  1173.  
  1174. if( GetBIsCombatActionAllowed() )
  1175. {
  1176. ProcessCombatActionBuffer();
  1177. }
  1178. }
  1179.  
  1180. public function AllowAttack( target : CActor, action : EBufferActionType ) : bool
  1181. {
  1182. var newTarget : CActor;
  1183. var canAttackWhenNotInCombat : bool;
  1184. var messageDisplayed : bool;
  1185.  
  1186. var itemId : SItemUniqueId;
  1187. var isShootingCrossbow : bool;
  1188.  
  1189. var isInCorrectState : bool;
  1190.  
  1191. if ( target )
  1192. {
  1193. if ( target.IsTargetableByPlayer())
  1194. {
  1195. if ( !target.IsAttackableByPlayer() )
  1196. {
  1197. DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_cant_attack_this_target"));
  1198. return false;
  1199. }
  1200. }
  1201. }
  1202.  
  1203. if ( this.GetCurrentStateName() == 'Exploration' )
  1204. isInCorrectState = true;
  1205.  
  1206. if ( action == EBAT_ItemUse )
  1207. {
  1208. itemId = thePlayer.GetSelectedItemId();
  1209. if ( inv.IsIdValid(itemId) && inv.IsItemCrossbow(itemId) )
  1210. isShootingCrossbow = true;
  1211.  
  1212. if ( !isInCorrectState )
  1213. {
  1214. if ( this.GetCurrentStateName() == 'AimThrow' && !isShootingCrossbow )
  1215. {
  1216. isInCorrectState = true;
  1217. }
  1218. }
  1219. }
  1220.  
  1221. if ( isInCorrectState )
  1222. canAttackWhenNotInCombat = thePlayer.CanAttackWhenNotInCombat( action, false, newTarget, target );
  1223.  
  1224. if( !target )
  1225. {
  1226. if ( isInCorrectState )
  1227. {
  1228. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  1229. target = newTarget;
  1230. }
  1231. }
  1232.  
  1233. if ( isInCorrectState )
  1234. {
  1235. if ( !canAttackWhenNotInCombat )
  1236. {
  1237. if ( DisplayCannotAttackMessage( target ) )
  1238. messageDisplayed = true;
  1239. else if ( ( action == EBAT_LightAttack || action == EBAT_HeavyAttack )
  1240. && !RaiseAttackFriendlyEvent( target ) )
  1241. messageDisplayed = true;
  1242. else
  1243. {
  1244. if ( !CanRaiseCombatActionFriendlyEvent( isShootingCrossbow ) )
  1245. messageDisplayed = true;
  1246. }
  1247. }
  1248.  
  1249. if ( messageDisplayed )
  1250. {
  1251. theInput.ForceDeactivateAction('ThrowItem');
  1252. theInput.ForceDeactivateAction('ThrowItemHold');
  1253. this.SignalGameplayEvent( 'FriendlyAttackAction' );
  1254. return false;
  1255. }
  1256. }
  1257.  
  1258. return true;
  1259. }
  1260.  
  1261.  
  1262.  
  1263. public function ProcessCombatActionBuffer() : bool
  1264. {
  1265. var actionResult : bool;
  1266. var action : EBufferActionType = this.BufferCombatAction;
  1267. var stage : EButtonStage = this.BufferButtonStage;
  1268. var s : SNotWorkingOutFunctionParametersHackStruct1;
  1269. var allSteps : bool = this.BufferAllSteps;
  1270.  
  1271. if ( IsInCombatActionFriendly() )
  1272. {
  1273. RaiseEvent('CombatActionFriendlyEnd');
  1274. }
  1275.  
  1276.  
  1277. if ( ( action != EBAT_SpecialAttack_Heavy && action != EBAT_ItemUse )
  1278. || ( action == EBAT_SpecialAttack_Heavy && stage == BS_Pressed )
  1279. || ( action == EBAT_ItemUse && stage != BS_Released ) )
  1280. {
  1281. GetMovingAgentComponent().GetMovementAdjustor().CancelAll();
  1282. SetUnpushableTarget( NULL );
  1283. }
  1284.  
  1285.  
  1286. if ( !( action == EBAT_Dodge || action == EBAT_Roll ) )
  1287. {
  1288. SetIsCurrentlyDodging(false);
  1289. }
  1290.  
  1291. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  1292.  
  1293.  
  1294.  
  1295. if ( action == EBAT_ItemUse && GetInventory().IsItemCrossbow( selectedItemId ) )
  1296. {
  1297.  
  1298. if ( rangedWeapon
  1299. && ( ( rangedWeapon.GetCurrentStateName() != 'State_WeaponShoot' && rangedWeapon.GetCurrentStateName() != 'State_WeaponAim' ) || GetIsShootingFriendly() ) )
  1300. {
  1301. SetSlideTarget( GetCombatActionTarget( action ) );
  1302. }
  1303. }
  1304. else if ( !( ( action == EBAT_SpecialAttack_Heavy && stage == BS_Released ) || GetCurrentStateName() == 'AimThrow' ) )
  1305. {
  1306. SetSlideTarget( GetCombatActionTarget( action ) );
  1307. }
  1308.  
  1309. if( !slideTarget )
  1310. LogChannel( 'Targeting', "NO SLIDE TARGET" );
  1311.  
  1312.  
  1313. actionResult = true;
  1314.  
  1315. switch ( action )
  1316. {
  1317. case EBAT_EMPTY :
  1318. {
  1319. this.BufferAllSteps = false;
  1320. return true;
  1321. } break;
  1322.  
  1323. case EBAT_LightAttack :
  1324. {
  1325. if ( IsCiri() )
  1326. return false;
  1327.  
  1328. switch ( stage )
  1329. {
  1330. case BS_Pressed :
  1331. {
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338. DrainStamina(ESAT_LightAttack);
  1339.  
  1340.  
  1341. thePlayer.BreakPheromoneEffect();
  1342. actionResult = OnPerformAttack(theGame.params.ATTACK_NAME_LIGHT);
  1343.  
  1344. } break;
  1345.  
  1346. default :
  1347. {
  1348. actionResult = false;
  1349. }break;
  1350. }
  1351. }break;
  1352.  
  1353. case EBAT_HeavyAttack :
  1354. {
  1355. if ( IsCiri() )
  1356. return false;
  1357.  
  1358. switch ( stage )
  1359. {
  1360. case BS_Released :
  1361. {
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367. DrainStamina(ESAT_HeavyAttack);
  1368.  
  1369.  
  1370.  
  1371. thePlayer.BreakPheromoneEffect();
  1372. actionResult = this.OnPerformAttack(theGame.params.ATTACK_NAME_HEAVY);
  1373.  
  1374. } break;
  1375.  
  1376. case BS_Pressed :
  1377. {
  1378. if ( this.GetCurrentStateName() == 'CombatFists' )
  1379. {
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385. DrainStamina(ESAT_HeavyAttack);
  1386.  
  1387.  
  1388.  
  1389. thePlayer.BreakPheromoneEffect();
  1390. actionResult = this.OnPerformAttack(theGame.params.ATTACK_NAME_HEAVY);
  1391.  
  1392. }
  1393. } break;
  1394.  
  1395. default :
  1396. {
  1397. actionResult = false;
  1398.  
  1399. } break;
  1400. }
  1401. } break;
  1402.  
  1403. case EBAT_ItemUse :
  1404. {
  1405. switch ( stage )
  1406. {
  1407. case BS_Pressed :
  1408. {
  1409. if ( !( (W3PlayerWitcher)this ) ||
  1410. ( !IsInCombatActionFriendly() && !( !GetBIsCombatActionAllowed() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign ) ) ) )
  1411.  
  1412. {
  1413. if ( inv.IsItemCrossbow( selectedItemId ) )
  1414. {
  1415. rangedWeapon = ( Crossbow )( inv.GetItemEntityUnsafe( selectedItemId ) );
  1416. rangedWeapon.OnRangedWeaponPress();
  1417. GetTarget().SignalGameplayEvent( 'Approach' );
  1418. GetTarget().SignalGameplayEvent( 'ShootingCrossbow' );
  1419. }
  1420. else if(inv.IsItemBomb(selectedItemId) && this.inv.SingletonItemGetAmmo(selectedItemId) > 0 )
  1421. {
  1422. if( ((W3PlayerWitcher)this).GetBombDelay( ((W3PlayerWitcher)this).GetItemSlot( selectedItemId ) ) <= 0.0f )
  1423. {
  1424. BombThrowStart();
  1425. GetTarget().SignalGameplayEvent( 'Approach' );
  1426. }
  1427. }
  1428. else
  1429. {
  1430. DrainStamina(ESAT_UsableItem);
  1431. UsableItemStart();
  1432. }
  1433. }
  1434.  
  1435. } if (!allSteps) break;
  1436.  
  1437. case BS_Released:
  1438. {
  1439. if ( !( (W3PlayerWitcher)this ) ||
  1440. ( !IsInCombatActionFriendly() && ( GetBIsCombatActionAllowed() || !( !GetBIsCombatActionAllowed() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign ) ) ) ) )
  1441.  
  1442. {
  1443. if ( inv.IsItemCrossbow( selectedItemId ) )
  1444. {
  1445.  
  1446. rangedWeapon.OnRangedWeaponRelease();
  1447. }
  1448. else if(inv.IsItemBomb(selectedItemId))
  1449. {
  1450. BombThrowRelease();
  1451. }
  1452. else
  1453. {
  1454. UsableItemRelease();
  1455. }
  1456. }
  1457. } break;
  1458.  
  1459. default :
  1460. {
  1461. actionResult = false;
  1462. break;
  1463. }
  1464. }
  1465. } break;
  1466.  
  1467. case EBAT_Dodge :
  1468. {
  1469. switch ( stage )
  1470. {
  1471. case BS_Released :
  1472. {
  1473. theGame.GetBehTreeReactionManager().CreateReactionEvent( this, 'PlayerEvade', 1.0f, 10.0f, -1.0f, -1 );
  1474. thePlayer.BreakPheromoneEffect();
  1475. actionResult = this.OnPerformEvade( PET_Dodge );
  1476. } break;
  1477.  
  1478.  
  1479.  
  1480. default :
  1481. {
  1482. actionResult = false;
  1483. } break;
  1484. }
  1485. } break;
  1486.  
  1487. case EBAT_Roll :
  1488. {
  1489. if ( IsCiri() )
  1490. return false;
  1491.  
  1492. switch ( stage )
  1493. {
  1494. case BS_Released :
  1495. {
  1496. theGame.GetBehTreeReactionManager().CreateReactionEvent( this, 'PlayerEvade', 1.0f, 10.0f, -1.0f, -1 );
  1497. thePlayer.BreakPheromoneEffect();
  1498. actionResult = this.OnPerformEvade( PET_Roll );
  1499. } break;
  1500.  
  1501. case BS_Pressed :
  1502. {
  1503. if ( this.GetBehaviorVariable( 'combatActionType' ) == 2.f )
  1504. {
  1505. if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
  1506. actionResult = this.OnPerformEvade( PET_Pirouette );
  1507. else
  1508. actionResult = this.OnPerformEvade( PET_Roll );
  1509. }
  1510. else
  1511. {
  1512. if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
  1513. {
  1514. actionResult = this.OnPerformEvade( PET_Dodge );
  1515. actionResult = this.OnPerformEvade( PET_Pirouette );
  1516. }
  1517. else
  1518. {
  1519. actionResult = this.OnPerformEvade( PET_Dodge );
  1520. actionResult = this.OnPerformEvade( PET_Roll );
  1521. }
  1522. }
  1523.  
  1524.  
  1525. } break;
  1526.  
  1527. default :
  1528. {
  1529. actionResult = false;
  1530. } break;
  1531. }
  1532. } break;
  1533.  
  1534. case EBAT_Draw_Steel :
  1535. {
  1536. switch ( stage )
  1537. {
  1538. case BS_Pressed :
  1539. {
  1540. if( !IsActionAllowed(EIAB_DrawWeapon) )
  1541. {
  1542. thePlayer.DisplayActionDisallowedHudMessage(EIAB_DrawWeapon);
  1543. actionResult = false;
  1544. break;
  1545. }
  1546. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'steelsword' ) )
  1547. {
  1548. OnEquipMeleeWeapon( PW_Steel, false, true );
  1549. }
  1550.  
  1551. actionResult = false;
  1552.  
  1553. } break;
  1554.  
  1555. default :
  1556. {
  1557. actionResult = false;
  1558. } break;
  1559. }
  1560. } break;
  1561.  
  1562. case EBAT_Draw_Silver :
  1563. {
  1564. switch ( stage )
  1565. {
  1566. case BS_Pressed :
  1567. {
  1568. if( !IsActionAllowed(EIAB_DrawWeapon) )
  1569. {
  1570. thePlayer.DisplayActionDisallowedHudMessage(EIAB_DrawWeapon);
  1571. actionResult = false;
  1572. break;
  1573. }
  1574. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'silversword' ) )
  1575. {
  1576. OnEquipMeleeWeapon( PW_Silver, false, true );
  1577. }
  1578.  
  1579. actionResult = false;
  1580.  
  1581. } break;
  1582.  
  1583. default :
  1584. {
  1585. actionResult = false;
  1586. } break;
  1587. }
  1588. } break;
  1589.  
  1590. case EBAT_Sheathe_Sword :
  1591. {
  1592. switch ( stage )
  1593. {
  1594. case BS_Pressed :
  1595. {
  1596. if( GetCurrentMeleeWeaponType() == PW_Silver )
  1597. {
  1598. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'silversword' ) )
  1599. {
  1600. OnEquipMeleeWeapon( PW_Silver, false, true );
  1601. }
  1602. }
  1603. else if( GetCurrentMeleeWeaponType() == PW_Steel )
  1604. {
  1605. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'steelsword' ) )
  1606. {
  1607. OnEquipMeleeWeapon( PW_Steel, false, true );
  1608. }
  1609. }
  1610.  
  1611. actionResult = false;
  1612.  
  1613. } break;
  1614.  
  1615. default :
  1616. {
  1617. actionResult = false;
  1618. } break;
  1619. }
  1620. } break;
  1621.  
  1622. default:
  1623. return false;
  1624. }
  1625.  
  1626.  
  1627. CleanCombatActionBuffer();
  1628.  
  1629. if (actionResult)
  1630. {
  1631. SetCombatAction( action ) ;
  1632.  
  1633. if(GetWitcherPlayer().IsInFrenzy())
  1634. GetWitcherPlayer().SkillFrenzyFinish(0);
  1635. }
  1636.  
  1637. return true;
  1638. }
  1639.  
  1640. public function CleanCombatActionBuffer()
  1641. {
  1642. BufferCombatAction = EBAT_EMPTY;
  1643. BufferAllSteps = false;
  1644. }
  1645.  
  1646. public function CancelHoldAttacks()
  1647. {
  1648. RemoveTimer( 'IsSpecialLightAttackInputHeld' );
  1649. RemoveTimer( 'IsSpecialHeavyAttackInputHeld' );
  1650. RemoveTimer( 'SpecialAttackLightSustainCost' );
  1651. RemoveTimer( 'SpecialAttackHeavySustainCost' );
  1652. RemoveTimer( 'UpdateSpecialAttackLightHeading' );
  1653. UnblockAction( EIAB_Crossbow, 'SpecialAttack' );
  1654.  
  1655. ResumeStaminaRegen('WhirlSkill');
  1656.  
  1657. if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_SpecialAttack && GetBehaviorVariable( 'isPerformingSpecialAttack' ) == 1.f )
  1658. {
  1659. if( GetBehaviorVariable( 'playerAttackType' ) == (int)PAT_Light )
  1660. {
  1661. SetAttackActionName(SkillEnumToName(S_Sword_s01));
  1662. PushCombatActionOnBuffer( EBAT_SpecialAttack_Light, BS_Released );
  1663. ProcessCombatActionBuffer();
  1664.  
  1665. ((W3PlayerWitcherStateCombatFists) GetState('Combat')).ResetTimeToEndCombat();
  1666.  
  1667. }
  1668. else if( GetBehaviorVariable( 'playerAttackType' ) == (int)PAT_Heavy )
  1669. {
  1670. SetAttackActionName(SkillEnumToName(S_Sword_s02));
  1671. PushCombatActionOnBuffer( EBAT_SpecialAttack_Heavy, BS_Released );
  1672. ProcessCombatActionBuffer();
  1673.  
  1674. }
  1675. }
  1676. }
  1677.  
  1678. public function RaiseAttackFriendlyEvent( actor : CActor ) : bool
  1679. {
  1680. var playerToTargetHeading : float;
  1681.  
  1682. if ( actor && RaiseCombatActionFriendlyEvent() )
  1683. {
  1684. SetBehaviorVariable( 'tauntTypeForOverlay', 0.f );
  1685. SetBehaviorVariable( 'combatActionTypeForOverlay', (int)CAT_Attack );
  1686.  
  1687. if ( actor )
  1688. actor.SignalGameplayEvent('PersonalTauntAction');
  1689. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'TauntAction', -1.0, 4.5f, -1, 9999, true );
  1690.  
  1691. OnCombatActionStart();
  1692.  
  1693. playerToTargetHeading = VecHeading( actor.GetWorldPosition() - GetWorldPosition() );
  1694.  
  1695. SetCustomRotation( 'Attack', playerToTargetHeading, 0.0f, 0.3f, false );
  1696.  
  1697. return true;
  1698. }
  1699.  
  1700. return false;
  1701. }
  1702.  
  1703. public function SendAttackReactionEvent()
  1704. {
  1705. var reactionName : name;
  1706.  
  1707.  
  1708.  
  1709. reactionName = 'AttackAction';
  1710.  
  1711. if ( IsNameValid(reactionName) )
  1712. {
  1713. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, reactionName, -1.0, 8.0f, -1, 5, true );
  1714. }
  1715.  
  1716.  
  1717. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'outOfMyWay', -1.0, 2.0f, -1, 5, true );
  1718. }
  1719.  
  1720. var forceCanAttackWhenNotInCombat : int;
  1721. public function SetForceCanAttackWhenNotInCombat( forceMode : int )
  1722. {
  1723. forceCanAttackWhenNotInCombat = forceMode;
  1724. }
  1725.  
  1726. public function CanAttackWhenNotInCombat( actionType : EBufferActionType, altCast : bool, out newTarget : CActor, optional target : CGameplayEntity ) : bool
  1727. {
  1728. var localTargets : array<CActor>;
  1729. var i, size : int;
  1730. var inputHeading : float;
  1731. var clearanceMin, clearanceMax : float;
  1732. var attackLength : float;
  1733. var attackAngle : float;
  1734. var npc : CNewNPC;
  1735. var canAttackTarget : CGameplayEntity;
  1736. var canAttackTargetActor : CActor;
  1737.  
  1738. if ( target )
  1739. canAttackTarget = target;
  1740. else if ( displayTarget && IsDisplayTargetTargetable() )
  1741. canAttackTarget = displayTarget;
  1742. else
  1743. canAttackTarget = slideTarget;
  1744.  
  1745. canAttackTargetActor = (CActor)canAttackTarget;
  1746.  
  1747. if ( forceCanAttackWhenNotInCombat == 2 )
  1748. return true;
  1749. else if ( forceCanAttackWhenNotInCombat == 1 && ( !canAttackTarget || !canAttackTargetActor.IsHuman() ) )
  1750. return true;
  1751.  
  1752. if ( actionType == EBAT_CastSign )
  1753. {
  1754. if ( thePlayer.GetEquippedSign() != ST_Quen && thePlayer.GetEquippedSign() != ST_Axii )
  1755. {
  1756. if ( CanUseSkill( S_Magic_s20 ) )
  1757. {
  1758. if ( thePlayer.GetEquippedSign() == ST_Aard )
  1759. attackLength = 6.f;
  1760. else if ( thePlayer.GetEquippedSign() == ST_Igni )
  1761. attackLength = 4.f;
  1762. else
  1763. attackLength = 6.f;
  1764. }
  1765. else
  1766. {
  1767. if ( thePlayer.GetEquippedSign() == ST_Aard )
  1768. attackLength = 9.f;
  1769. else if ( thePlayer.GetEquippedSign() == ST_Igni )
  1770. attackLength = 6.f;
  1771. else
  1772. attackLength = 6.f;
  1773. }
  1774.  
  1775. if ( altCast )
  1776. attackAngle = 180.f;
  1777. else
  1778.  
  1779. attackAngle = 90.f;
  1780.  
  1781. if ( !lastAxisInputIsMovement )
  1782. inputHeading = VecHeading( theCamera.GetCameraDirection() );
  1783. else if ( lAxisReleasedAfterCounter )
  1784. inputHeading = GetHeading();
  1785. else
  1786. inputHeading = GetCombatActionHeading();
  1787.  
  1788. clearanceMin = 1.f;
  1789. clearanceMax = attackLength + 1.f;
  1790. }
  1791. else if ( thePlayer.GetEquippedSign() == ST_Axii )
  1792. {
  1793. npc = (CNewNPC)canAttackTarget;
  1794. if ( npc && npc.GetNPCType() == ENGT_Quest && !npc.HasTag(theGame.params.TAG_AXIIABLE_LOWER_CASE) && !npc.HasTag(theGame.params.TAG_AXIIABLE))
  1795. return false;
  1796. else if ( npc && npc.IsUsingHorse() )
  1797. return false;
  1798. else
  1799. return true;
  1800. }
  1801. else
  1802. return true;
  1803. }
  1804. else if ( actionType == EBAT_ItemUse )
  1805. {
  1806. attackLength = theGame.params.MAX_THROW_RANGE;
  1807. attackAngle = 90.f;
  1808.  
  1809. if ( thePlayer.lastAxisInputIsMovement )
  1810. inputHeading = GetCombatActionHeading();
  1811. else
  1812. inputHeading = VecHeading( theCamera.GetCameraDirection() );
  1813.  
  1814. clearanceMin = 0.8f;
  1815. clearanceMax = attackLength + 3.f;
  1816. }
  1817. else
  1818. {
  1819. if ( actionType == EBAT_SpecialAttack_Light || actionType == EBAT_SpecialAttack_Heavy )
  1820. {
  1821. attackLength = 1.9f;
  1822. attackAngle = 90.f;
  1823. }
  1824. else
  1825. {
  1826. if( thePlayer.GetCurrentMeleeWeaponType() == PW_Fists || thePlayer.GetCurrentMeleeWeaponType() == PW_None )
  1827. attackLength = 1.2f;
  1828. else
  1829. attackLength = 1.9f;
  1830.  
  1831. attackAngle = 90.f;
  1832. }
  1833.  
  1834. if ( lastAxisInputIsMovement )
  1835. inputHeading = GetCombatActionHeading();
  1836. else
  1837. inputHeading = VecHeading( theCamera.GetCameraDirection() );
  1838.  
  1839. clearanceMin = attackLength / 2.f;
  1840. clearanceMax = attackLength + 3.f;
  1841. }
  1842.  
  1843.  
  1844. if ( canAttackTarget )
  1845. {
  1846. if ( ( canAttackTargetActor && canAttackTargetActor.IsHuman() ) || canAttackTargetActor.HasTag( 'softLock_Friendly' ) )
  1847. {
  1848. if ( ShouldPerformFriendlyAction( canAttackTargetActor, inputHeading, attackAngle, clearanceMin, clearanceMax ) )
  1849. {
  1850. SetSlideTarget( canAttackTargetActor );
  1851. newTarget = canAttackTargetActor;
  1852. return false;
  1853. }
  1854. }
  1855.  
  1856.  
  1857. }
  1858.  
  1859. return true;
  1860.  
  1861. thePlayer.GetVisibleEnemies( localTargets );
  1862. size = localTargets.Size();
  1863.  
  1864. if ( size > 0 )
  1865. {
  1866. for ( i = size-1; i>=0; i-=1 )
  1867. {
  1868.  
  1869. if ( !localTargets[i].IsHuman() && !localTargets[i].HasTag( 'softLock_Friendly' ) )
  1870. localTargets.Erase(i);
  1871. }
  1872. }
  1873.  
  1874. size = localTargets.Size();
  1875. if ( size > 0 )
  1876. {
  1877. for ( i = 0; i < localTargets.Size(); i += 1 )
  1878. {
  1879. if ( ShouldPerformFriendlyAction( localTargets[i], inputHeading, attackAngle, clearanceMin, clearanceMax ) )
  1880. {
  1881. SetSlideTarget( localTargets[i] );
  1882. newTarget = localTargets[i];
  1883. return false;
  1884. }
  1885. }
  1886. }
  1887.  
  1888. newTarget = NULL;
  1889.  
  1890. return true;
  1891. }
  1892.  
  1893. private function ShouldPerformFriendlyAction( actor : CActor, inputHeading, attackAngle, clearanceMin, clearanceMax : float ) : bool
  1894. {
  1895. var npc : CNewNPC;
  1896. var argh : float;
  1897. var playerToTargetDist : float;
  1898.  
  1899. npc = (CNewNPC)actor;
  1900.  
  1901. if ( npc &&
  1902. ( GetAttitudeBetween(thePlayer, npc) == AIA_Hostile || ( GetAttitudeBetween(thePlayer, npc) == AIA_Neutral && npc.GetNPCType() != ENGT_Guard ) ) )
  1903. {
  1904. }
  1905. else
  1906. {
  1907. playerToTargetDist = VecDistance( this.GetWorldPosition(), actor.PredictWorldPosition( 0.5f ) );
  1908.  
  1909. argh = AbsF( AngleDistance( inputHeading, VecHeading( actor.GetWorldPosition() - thePlayer.GetWorldPosition() ) ) );
  1910.  
  1911. if ( AbsF( AngleDistance( inputHeading, VecHeading( actor.GetWorldPosition() - thePlayer.GetWorldPosition() ) ) ) < attackAngle )
  1912. {
  1913. if ( playerToTargetDist < clearanceMax )
  1914. {
  1915. return true;
  1916. }
  1917. }
  1918. else
  1919. {
  1920. if ( playerToTargetDist < clearanceMin )
  1921. {
  1922. return true;
  1923. }
  1924. }
  1925. }
  1926.  
  1927. return false;
  1928. }
  1929.  
  1930.  
  1931.  
  1932.  
  1933.  
  1934. public function GetHudMessagesSize() : int
  1935. {
  1936. return HudMessages.Size();
  1937. }
  1938.  
  1939. public function GetHudPendingMessage() : string
  1940. {
  1941. return HudMessages[0];
  1942. }
  1943.  
  1944. public function DisplayHudMessage( value : string ) : void
  1945. {
  1946. if (value == "")
  1947. {
  1948. return;
  1949. }
  1950.  
  1951. if( GetHudMessagesSize() > 0 )
  1952. {
  1953. if( HudMessages[HudMessages.Size()-1] == value )
  1954. {
  1955. return;
  1956. }
  1957. }
  1958. HudMessages.PushBack(value);
  1959. }
  1960.  
  1961.  
  1962. private final function DisallowedActionDontShowHack(action : EInputActionBlock, isTimeLock : bool) : bool
  1963. {
  1964. var locks : array< SInputActionLock >;
  1965. var i : int;
  1966.  
  1967.  
  1968. 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)) )
  1969. {
  1970. return true;
  1971. }
  1972.  
  1973.  
  1974. if( action == EIAB_ThrowBomb && ( HasBuff( EET_Hypnotized ) || HasBuff( EET_Confusion ) ) )
  1975. {
  1976. return false;
  1977. }
  1978.  
  1979.  
  1980. if(isTimeLock)
  1981. return false;
  1982.  
  1983.  
  1984. if(action == EIAB_OpenMeditation)
  1985. return false;
  1986.  
  1987.  
  1988. locks = GetActionLocks(action);
  1989. for(i=0; i<locks.Size(); i+=1)
  1990. {
  1991. if(locks[i].isFromQuest || locks[i].isFromPlace)
  1992. return false;
  1993. }
  1994.  
  1995. if ( this.IsCurrentlyUsingItemL() )
  1996. {
  1997. if ( action == EIAB_HeavyAttacks || action == EIAB_Parry )
  1998. return false;
  1999. }
  2000.  
  2001.  
  2002. return true;
  2003. }
  2004.  
  2005. public final function DisplayActionDisallowedHudMessage(action : EInputActionBlock, optional isCombatLock : bool, optional isPlaceLock : bool, optional isTimeLock : bool, optional isDangerous : bool)
  2006. {
  2007. var lockType : name;
  2008.  
  2009. if(action != EIAB_Undefined && DisallowedActionDontShowHack(action, isTimeLock))
  2010. return;
  2011.  
  2012.  
  2013. if(IsInCombat() && !IsActionCombat(action))
  2014. isCombatLock = true;
  2015.  
  2016.  
  2017. if(!isCombatLock && !isPlaceLock && !isTimeLock && action != EIAB_Undefined)
  2018. {
  2019. lockType = inputHandler.GetActionBlockedHudLockType(action);
  2020.  
  2021. if(lockType == 'combat')
  2022. isCombatLock = true;
  2023. else if(lockType == 'place')
  2024. isPlaceLock = true;
  2025. else if(lockType == 'time')
  2026. isTimeLock = true;
  2027. }
  2028.  
  2029. if(isDangerous)
  2030. {
  2031. DisplayHudMessage(GetLocStringByKeyExt( "message_meditation_too_dangerous" ));
  2032. }
  2033. else if(isCombatLock)
  2034. {
  2035. DisplayHudMessage(GetLocStringByKeyExt( "panel_hud_message_actionnotallowed_combat" ));
  2036. }
  2037. else if(isPlaceLock)
  2038. {
  2039. DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_here" ));
  2040. }
  2041. else if(isTimeLock)
  2042. {
  2043. DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_now" ));
  2044. }
  2045. }
  2046.  
  2047.  
  2048. public function RemoveHudMessageByString(msg : string, optional allQueuedInstances : bool)
  2049. {
  2050. var i, j : int;
  2051.  
  2052. for(i=0; i<HudMessages.Size(); i+=1)
  2053. {
  2054. if(HudMessages[i] == msg)
  2055. {
  2056. HudMessages.EraseFast(i);
  2057.  
  2058. if(!allQueuedInstances)
  2059. return;
  2060.  
  2061. break;
  2062. }
  2063. }
  2064.  
  2065.  
  2066. for(j=HudMessages.Size()-1; j >= i; j-=1)
  2067. {
  2068. if(HudMessages[i] == msg)
  2069. {
  2070. HudMessages.EraseFast(i);
  2071. }
  2072. }
  2073. }
  2074.  
  2075. public function RemoveHudMessageByIndex(idx : int)
  2076. {
  2077. if(idx >= 0 && idx < HudMessages.Size())
  2078. HudMessages.Erase(idx);
  2079. }
  2080.  
  2081. function SetSettlementBlockCanter( valueAdd : int )
  2082. {
  2083. m_SettlementBlockCanter += valueAdd;
  2084. }
  2085.  
  2086. var countDownToStart : int;
  2087. default countDownToStart = 0;
  2088.  
  2089. function DisplayRaceStart( countDownSecondsNumber : int )
  2090. {
  2091. var i : int;
  2092. countDownToStart = countDownSecondsNumber;
  2093. for( i = countDownSecondsNumber; i > 0; i -= 1 )
  2094. {
  2095. DisplayHudMessage(IntToString(i));
  2096. }
  2097. DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_race_start"));
  2098. AddTimer('RaceCountdown',1,true);
  2099. }
  2100.  
  2101. timer function RaceCountdown(dt : float, id : int)
  2102. {
  2103. var hud : CR4ScriptedHud;
  2104. var messageModule : CR4HudModuleMessage;
  2105.  
  2106. countDownToStart -= 1;
  2107. hud = (CR4ScriptedHud)theGame.GetHud();
  2108.  
  2109. if( hud )
  2110. {
  2111. messageModule = (CR4HudModuleMessage)hud.GetHudModule("MessageModule");
  2112. if( messageModule )
  2113. {
  2114. messageModule.OnMessageHidden();
  2115. }
  2116. }
  2117.  
  2118. if( countDownToStart <= 0 )
  2119. {
  2120. RemoveTimer('RaceCountdown');
  2121. }
  2122. }
  2123.  
  2124. public function GetCountDownToStart() : int
  2125. {
  2126. return countDownToStart;
  2127. }
  2128.  
  2129. public function HAXE3GetContainer() : W3Container
  2130. {
  2131. return HAXE3Container;
  2132. }
  2133.  
  2134. public function HAXE3SetContainer( container : W3Container) : void
  2135. {
  2136. HAXE3Container = container;
  2137. }
  2138.  
  2139. public function HAXE3GetAutoLoot() : bool
  2140. {
  2141. return HAXE3bAutoLoot;
  2142. }
  2143.  
  2144. public function HAXE3SetAutoLoot( value : bool ) : void
  2145. {
  2146. HAXE3bAutoLoot = value;
  2147. }
  2148.  
  2149. public function GetShowHud() : bool
  2150. {
  2151. return bShowHud;
  2152. }
  2153.  
  2154. public function SetShowHud( value : bool ) : void
  2155. {
  2156. bShowHud = value;
  2157. }
  2158.  
  2159. public function DisplayItemRewardNotification( itemName : name, optional quantity : int ) : void
  2160. {
  2161. var hud : CR4ScriptedHud;
  2162. hud = (CR4ScriptedHud)theGame.GetHud();
  2163. hud.OnItemRecivedDuringScene(itemName, quantity);
  2164. }
  2165.  
  2166. function IsNewQuest( questGuid : CGUID ) : bool
  2167. {
  2168. var i : int;
  2169. for(i = 0; i < displayedQuestsGUID.Size(); i += 1 )
  2170. {
  2171. if( displayedQuestsGUID[i] == questGuid )
  2172. {
  2173. return false;
  2174. }
  2175. }
  2176. displayedQuestsGUID.PushBack(questGuid);
  2177. return true;
  2178. }
  2179.  
  2180. function GetRewardMultiplierData( rewardName : name ) : SRewardMultiplier
  2181. {
  2182. var defaultReward : SRewardMultiplier;
  2183. var i : int;
  2184.  
  2185. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  2186. {
  2187. if( rewardsMultiplier[i].rewardName == rewardName )
  2188. {
  2189. return rewardsMultiplier[i];
  2190. }
  2191. }
  2192.  
  2193. defaultReward.rewardName = rewardName;
  2194. defaultReward.rewardMultiplier = 1.0;
  2195. defaultReward.isItemMultiplier = false;
  2196.  
  2197. return defaultReward;
  2198. }
  2199.  
  2200. function GetRewardMultiplier( rewardName : name ) : float
  2201. {
  2202. var i : int;
  2203. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  2204. {
  2205. if( rewardsMultiplier[i].rewardName == rewardName )
  2206. {
  2207. return rewardsMultiplier[i].rewardMultiplier;
  2208. }
  2209. }
  2210. return 1.0;
  2211. }
  2212.  
  2213. function GetRewardMultiplierExists( rewardName : name ) : bool
  2214. {
  2215. var i : int;
  2216. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  2217. {
  2218. if( rewardsMultiplier[i].rewardName == rewardName )
  2219. {
  2220. return true;
  2221. }
  2222. }
  2223. return false;
  2224. }
  2225.  
  2226. function SetRewardMultiplier( rewardName : name, value : float, optional isItemMultiplier : bool ) : void
  2227. {
  2228. var i : int;
  2229. var rewardMultiplier : SRewardMultiplier;
  2230.  
  2231. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  2232. {
  2233. if( rewardsMultiplier[i].rewardName == rewardName )
  2234. {
  2235. rewardsMultiplier[i].rewardMultiplier = value;
  2236. rewardsMultiplier[i].isItemMultiplier = isItemMultiplier;
  2237. return;
  2238. }
  2239. }
  2240.  
  2241. rewardMultiplier.rewardName = rewardName;
  2242. rewardMultiplier.rewardMultiplier = value;
  2243. rewardMultiplier.isItemMultiplier = isItemMultiplier;
  2244.  
  2245. rewardsMultiplier.PushBack(rewardMultiplier);
  2246. }
  2247.  
  2248. function RemoveRewardMultiplier( rewardName : name ) : void
  2249. {
  2250. var i : int;
  2251. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  2252. {
  2253. if( rewardsMultiplier[i].rewardName == rewardName )
  2254. {
  2255. rewardsMultiplier.Erase(i);
  2256. return;
  2257. }
  2258. }
  2259. }
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267. public final function TissueExtractorDischarge() : bool
  2268. {
  2269. var ids : array<SItemUniqueId>;
  2270. var chargesLeft, uses, curr, max, red, blue, green : int;
  2271. var i : int;
  2272. var text : string;
  2273.  
  2274. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  2275. if( ids.Size() == 0 )
  2276. {
  2277. return false;
  2278. }
  2279.  
  2280. curr = GetTissueExtractorChargesCurr();
  2281. max = GetTissueExtractorChargesMax();
  2282.  
  2283. if( curr >= max )
  2284. {
  2285.  
  2286. uses = FloorF( ( ( float ) curr ) / ( ( float ) max ) );
  2287. chargesLeft = Max( 0, curr - uses * max );
  2288.  
  2289.  
  2290. inv.SetItemModifierInt( ids[0], 'charges', chargesLeft );
  2291.  
  2292.  
  2293. blue = 0;
  2294. green = 0;
  2295. red = 0;
  2296. for( i=0; i<uses; i+=1 )
  2297. {
  2298. switch( RandRange( 3 ) )
  2299. {
  2300. case 0:
  2301. blue += 1;
  2302. break;
  2303. case 1:
  2304. green += 1;
  2305. break;
  2306. case 2:
  2307. red += 1;
  2308. }
  2309. }
  2310.  
  2311. text = GetLocStringByKeyExt( "message_q705_extractor_extracted" );
  2312.  
  2313. if( blue > 0 )
  2314. {
  2315. inv.AddAnItem( 'Greater mutagen blue', blue, false, true );
  2316. text += "<br/>" + blue + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen blue' ) );
  2317. }
  2318. if( green > 0 )
  2319. {
  2320. inv.AddAnItem( 'Greater mutagen green', green, false, true );
  2321. text += "<br/>" + green + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen green' ) );
  2322. }
  2323. if( red > 0 )
  2324. {
  2325. inv.AddAnItem( 'Greater mutagen red', red, false, true );
  2326. text += "<br/>" + red + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen red' ) );
  2327. }
  2328.  
  2329.  
  2330. theGame.GetGuiManager().ShowNotification( text );
  2331.  
  2332.  
  2333. inv.SetItemModifierInt( ids[0], 'ui_notified', 0 );
  2334.  
  2335. return true;
  2336. }
  2337. else
  2338. {
  2339.  
  2340. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_q705_extractor_too_few_charges" ) );
  2341. }
  2342.  
  2343. return false;
  2344. }
  2345.  
  2346. public final function TissueExtractorIncCharge()
  2347. {
  2348. var ids : array<SItemUniqueId>;
  2349. var uiData : SInventoryItemUIData;
  2350. var curr : int;
  2351.  
  2352. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  2353. if( ids.Size() == 0 )
  2354. {
  2355. return;
  2356. }
  2357.  
  2358. curr = GetTissueExtractorChargesCurr() + 1;
  2359. inv.SetItemModifierInt( ids[0], 'charges', curr );
  2360.  
  2361.  
  2362. if( curr >= GetTissueExtractorChargesMax() )
  2363. {
  2364. uiData = inv.GetInventoryItemUIData( ids[0] );
  2365. uiData.isNew = true;
  2366. inv.SetInventoryItemUIData( ids[0], uiData );
  2367.  
  2368.  
  2369. if( inv.GetItemModifierInt( ids[0], 'ui_notified', 0 ) == 0 )
  2370. {
  2371. inv.SetItemModifierInt( ids[0], 'ui_notified', 1 );
  2372. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_q705_extractor_charged" ), , true );
  2373. }
  2374. }
  2375. }
  2376.  
  2377. public final function GetTissueExtractorChargesCurr() : int
  2378. {
  2379. var ids : array<SItemUniqueId>;
  2380.  
  2381. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  2382. if( ids.Size() == 0 )
  2383. {
  2384. return 0;
  2385. }
  2386.  
  2387. return inv.GetItemModifierInt( ids[0], 'charges', 0 );
  2388. }
  2389.  
  2390. public final function GetTissueExtractorChargesMax() : int
  2391. {
  2392. var ids : array<SItemUniqueId>;
  2393. var val : SAbilityAttributeValue;
  2394.  
  2395. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  2396. if( ids.Size() == 0 )
  2397. {
  2398. return 0;
  2399. }
  2400.  
  2401. val = inv.GetItemAttributeValue( ids[0], 'maxCharges' );
  2402.  
  2403. return FloorF( val.valueBase );
  2404. }
  2405.  
  2406. public function GetEquippedSword(steel : bool) : SItemUniqueId;
  2407.  
  2408. public final function HasRequiredLevelToEquipItem(item : SItemUniqueId) : bool
  2409. {
  2410. if(HasBuff(EET_WolfHour))
  2411. {
  2412. if((inv.GetItemLevel(item) - 2) > GetLevel() )
  2413. return false;
  2414. }
  2415. else
  2416. {
  2417. if(inv.GetItemLevel(item) > GetLevel() )
  2418. return false;
  2419. }
  2420.  
  2421. return true;
  2422. }
  2423.  
  2424. public function SkillReduceBombAmmoBonus()
  2425. {
  2426. var i, ammo, maxAmmo : int;
  2427. var items : array<SItemUniqueId>;
  2428.  
  2429. items = inv.GetSingletonItems();
  2430.  
  2431. for(i=0; i<items.Size(); i+=1)
  2432. {
  2433. ammo = inv.GetItemModifierInt(items[i], 'ammo_current');
  2434.  
  2435.  
  2436. if(ammo > 0)
  2437. {
  2438. maxAmmo = inv.SingletonItemGetMaxAmmo(items[i]);
  2439.  
  2440.  
  2441. if(ammo > maxAmmo)
  2442. {
  2443. inv.SetItemModifierInt(items[i], 'ammo_current', maxAmmo);
  2444. }
  2445. }
  2446. }
  2447. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  2448. }
  2449.  
  2450. public function ConsumeItem( itemId : SItemUniqueId ) : bool
  2451. {
  2452. var params : SCustomEffectParams;
  2453. var buffs : array<SEffectInfo>;
  2454. var i : int;
  2455. var category : name;
  2456. var potionToxicity : float;
  2457.  
  2458. if(!inv.IsIdValid(itemId))
  2459. return false;
  2460.  
  2461.  
  2462. category = inv.GetItemCategory(itemId);
  2463. if(category == 'edibles' || inv.ItemHasTag(itemId, 'Drinks') || ( category == 'alchemy_ingredient' && inv.ItemHasTag(itemId, 'Alcohol')) )
  2464. {
  2465.  
  2466. if(IsFistFightMinigameEnabled())
  2467. {
  2468. DisplayActionDisallowedHudMessage(EIAB_Undefined, false, false, true);
  2469. return false;
  2470. }
  2471.  
  2472.  
  2473. inv.GetItemBuffs(itemId, buffs);
  2474.  
  2475. for(i=0; i<buffs.Size(); i+=1)
  2476. {
  2477. params.effectType = buffs[i].effectType;
  2478. params.creator = this;
  2479. params.sourceName = "edible";
  2480. params.customAbilityName = buffs[i].effectAbilityName;
  2481. AddEffectCustom(params);
  2482. }
  2483.  
  2484.  
  2485. if ( inv.ItemHasTag(itemId, 'Alcohol') )
  2486. {
  2487. potionToxicity = CalculateAttributeValue(inv.GetItemAttributeValue(itemId, 'toxicity'));
  2488. abilityManager.GainStat(BCS_Toxicity, potionToxicity );
  2489. AddEffectDefault(EET_Drunkenness, NULL, inv.GetItemName(itemId));
  2490. }
  2491. PlayItemConsumeSound( itemId );
  2492. }
  2493.  
  2494. if(inv.IsItemFood(itemId))
  2495. FactsAdd("consumed_food_cnt");
  2496.  
  2497.  
  2498. if(!inv.ItemHasTag(itemId, theGame.params.TAG_INFINITE_USE) && !inv.RemoveItem(itemId))
  2499. {
  2500. LogAssert(false,"Failed to remove consumable item from player inventory!" + inv.GetItemName( itemId ) );
  2501. return false;
  2502. }
  2503.  
  2504. return true;
  2505. }
  2506.  
  2507. public function MountVehicle( vehicleEntity : CEntity, mountType : EVehicleMountType, optional vehicleSlot : EVehicleSlot )
  2508. {
  2509. var vehicle : CVehicleComponent;
  2510. vehicle = (CVehicleComponent)(vehicleEntity.GetComponentByClassName('CVehicleComponent'));
  2511.  
  2512. if ( vehicle )
  2513. vehicle.Mount( this, mountType, vehicleSlot );
  2514. }
  2515.  
  2516. public function DismountVehicle( vehicleEntity : CEntity, dismountType : EDismountType )
  2517. {
  2518. var vehicle : CVehicleComponent;
  2519. vehicle = (CVehicleComponent)(vehicleEntity.GetComponentByClassName('CVehicleComponent'));
  2520.  
  2521. if ( vehicle )
  2522. vehicle.IssueCommandToDismount( dismountType );
  2523. }
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529. protected function ShouldDrainStaminaWhileSprinting() : bool
  2530. {
  2531. if( HasBuff( EET_PolishedGenitals ) && !IsInCombat() && !IsThreatened() )
  2532. {
  2533. return false;
  2534. }
  2535.  
  2536. return super.ShouldDrainStaminaWhileSprinting();
  2537. }
  2538.  
  2539.  
  2540.  
  2541. public function HasStaminaToUseAction(action : EStaminaActionType, optional abilityName : name, optional dt :float, optional multiplier : float) : bool
  2542. {
  2543. var cost : float;
  2544. var ret : bool;
  2545.  
  2546. ret = super.HasStaminaToUseAction(action, abilityName, dt, multiplier);
  2547.  
  2548. if(!ret)
  2549. {
  2550. SetCombatActionHeading( GetHeading() );
  2551.  
  2552. if(multiplier == 0)
  2553. multiplier = 1;
  2554.  
  2555. cost = multiplier * GetStaminaActionCost(action, abilityName, dt);
  2556. SetShowToLowStaminaIndication(cost);
  2557. }
  2558.  
  2559. return ret;
  2560. }
  2561.  
  2562.  
  2563. timer function AbilityManager_FloorStaminaSegment(dt : float, id : int)
  2564. {
  2565. ((W3PlayerAbilityManager)abilityManager).FloorStaminaSegment();
  2566. }
  2567.  
  2568. public function DrainToxicity(amount : float )
  2569. {
  2570. if(abilityManager && abilityManager.IsInitialized() && IsAlive())
  2571. abilityManager.DrainToxicity(amount);
  2572. }
  2573.  
  2574. public function DrainFocus(amount : float )
  2575. {
  2576. if(abilityManager && abilityManager.IsInitialized() && IsAlive())
  2577. abilityManager.DrainFocus(amount);
  2578. }
  2579.  
  2580. public function GetOffenseStat():int
  2581. {
  2582. if(abilityManager && abilityManager.IsInitialized())
  2583. return ((W3PlayerAbilityManager)abilityManager).GetOffenseStat();
  2584.  
  2585. return 0;
  2586. }
  2587.  
  2588. public function GetDefenseStat():int
  2589. {
  2590. if(abilityManager && abilityManager.IsInitialized())
  2591. return ((W3PlayerAbilityManager)abilityManager).GetDefenseStat();
  2592.  
  2593. return 0;
  2594. }
  2595.  
  2596. public function GetSignsStat():float
  2597. {
  2598. if(abilityManager && abilityManager.IsInitialized())
  2599. return ((W3PlayerAbilityManager)abilityManager).GetSignsStat();
  2600.  
  2601. return 0;
  2602. }
  2603.  
  2604.  
  2605.  
  2606.  
  2607.  
  2608. private var inWaterTrigger : bool;
  2609.  
  2610. event OnOceanTriggerEnter()
  2611. {
  2612. inWaterTrigger = true;
  2613. }
  2614.  
  2615. event OnOceanTriggerLeave()
  2616. {
  2617. inWaterTrigger = false;
  2618. }
  2619.  
  2620. public function IsInWaterTrigger() : bool
  2621. {
  2622. return inWaterTrigger;
  2623. }
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629. public function GetSkillColor(skill : ESkill) : ESkillColor
  2630. {
  2631. if(abilityManager && abilityManager.IsInitialized())
  2632. return ((W3PlayerAbilityManager)abilityManager).GetSkillColor(skill);
  2633.  
  2634. return SC_None;
  2635. }
  2636.  
  2637. public function GetSkillSlotIndexFromSkill(skill : ESkill) : int
  2638. {
  2639. if(abilityManager && abilityManager.IsInitialized())
  2640. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIndexFromSkill(skill);
  2641.  
  2642. return -1;
  2643. }
  2644.  
  2645. public final function GetSkillSlotIndex(slotID : int, checkIfUnlocked : bool) : int
  2646. {
  2647. if(abilityManager && abilityManager.IsInitialized())
  2648. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIndex(slotID, checkIfUnlocked);
  2649.  
  2650. return -1;
  2651. }
  2652.  
  2653. public final function GetSkillSlotIDFromIndex(skillSlotIndex : int) : int
  2654. {
  2655. if(abilityManager && abilityManager.IsInitialized())
  2656. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIDFromIndex(skillSlotIndex);
  2657.  
  2658. return -1;
  2659. }
  2660.  
  2661. public function GetSkillSlotID(skill : ESkill) : int
  2662. {
  2663. if(abilityManager && abilityManager.IsInitialized())
  2664. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotID(skill);
  2665.  
  2666. return -1;
  2667. }
  2668.  
  2669. public function GetSkillGroupBonus(groupID : int) : name
  2670. {
  2671. if(abilityManager && abilityManager.IsInitialized())
  2672. return ((W3PlayerAbilityManager)abilityManager).GetGroupBonus(groupID);
  2673.  
  2674. return '';
  2675. }
  2676.  
  2677. public function GetGroupBonusCount(commonColor : ESkillColor,groupID : int) : int
  2678. {
  2679. if(abilityManager && abilityManager.IsInitialized())
  2680. return ((W3PlayerAbilityManager)abilityManager).GetSkillGroupColorCount(commonColor, groupID);
  2681.  
  2682. return 0;
  2683. }
  2684.  
  2685. public function GetMutagenSlotIDFromGroupID(groupID : int) : int
  2686. {
  2687. if(abilityManager && abilityManager.IsInitialized())
  2688. return ((W3PlayerAbilityManager)abilityManager).GetMutagenSlotIDFromGroupID(groupID);
  2689.  
  2690. return -1;
  2691. }
  2692.  
  2693. public function GetSkillLevel(skill : ESkill) : int
  2694. {
  2695. if(abilityManager && abilityManager.IsInitialized())
  2696. return ((W3PlayerAbilityManager)abilityManager).GetSkillLevel(skill);
  2697.  
  2698. return -1;
  2699. }
  2700.  
  2701. public function GetBoughtSkillLevel(skill : ESkill) : int
  2702. {
  2703. if(abilityManager && abilityManager.IsInitialized())
  2704. return ((W3PlayerAbilityManager)abilityManager).GetBoughtSkillLevel(skill);
  2705.  
  2706. return -1;
  2707. }
  2708.  
  2709. public function AddSkill(skill : ESkill, optional isTemporary : bool)
  2710. {
  2711. if(abilityManager && abilityManager.IsInitialized())
  2712. ((W3PlayerAbilityManager)abilityManager).AddSkill(skill, isTemporary);
  2713. }
  2714.  
  2715. public function AddMultipleSkills(skill : ESkill, optional number : int, optional isTemporary : bool)
  2716. {
  2717. var i : int;
  2718.  
  2719. if(number)
  2720. {
  2721. for( i=0; i<number; i+=1)
  2722. {
  2723. AddSkill(skill,isTemporary);
  2724. }
  2725. }
  2726. else
  2727. {
  2728. AddSkill(skill,isTemporary);
  2729. }
  2730. }
  2731.  
  2732. public function GetSkillAbilityName(skill : ESkill) : name
  2733. {
  2734. if(abilityManager && abilityManager.IsInitialized())
  2735. return ((W3PlayerAbilityManager)abilityManager).GetSkillAbilityName(skill);
  2736.  
  2737. return '';
  2738. }
  2739.  
  2740. public function HasStaminaToUseSkill(skill : ESkill, optional perSec : bool, optional signHack : bool) : bool
  2741. {
  2742. var ret : bool;
  2743. var cost : float;
  2744.  
  2745. cost = GetSkillStaminaUseCost(skill, perSec);
  2746.  
  2747. ret = ( CanUseSkill(skill) && (abilityManager.GetStat(BCS_Stamina, signHack) >= cost) );
  2748.  
  2749.  
  2750. if(!ret && IsSkillSign(skill) && CanUseSkill(S_Perk_09) && GetStat(BCS_Focus) >= 1)
  2751. {
  2752. ret = true;
  2753. }
  2754.  
  2755.  
  2756. if( !ret && IsSkillSign( skill ) && GetWitcherPlayer().HasBuff( EET_GryphonSetBonus ) )
  2757. {
  2758. ret = true;
  2759. }
  2760.  
  2761. if(!ret)
  2762. {
  2763. SetCombatActionHeading( GetHeading() );
  2764. SetShowToLowStaminaIndication(cost);
  2765. }
  2766.  
  2767. return ret;
  2768. }
  2769.  
  2770. protected function GetSkillStaminaUseCost(skill : ESkill, optional perSec : bool) : float
  2771. {
  2772. if(abilityManager && abilityManager.IsInitialized())
  2773. return ((W3PlayerAbilityManager)abilityManager).GetSkillStaminaUseCost(skill, perSec);
  2774.  
  2775. return 0;
  2776. }
  2777.  
  2778.  
  2779. public function GetSkillAttributeValue(skill : ESkill, attributeName : name, addBaseCharAttribute : bool, addSkillModsAttribute : bool) : SAbilityAttributeValue
  2780. {
  2781. var null : SAbilityAttributeValue;
  2782.  
  2783. if(abilityManager && abilityManager.IsInitialized())
  2784. return abilityManager.GetSkillAttributeValue(SkillEnumToName(skill), attributeName, addBaseCharAttribute, addSkillModsAttribute);
  2785.  
  2786. return null;
  2787. }
  2788.  
  2789. public function GetSkillLocalisationKeyName(skill : ESkill) : string
  2790. {
  2791. if(abilityManager && abilityManager.IsInitialized())
  2792. return ((W3PlayerAbilityManager)abilityManager).GetSkillLocalisationKeyName(skill);
  2793.  
  2794. return "";
  2795. }
  2796.  
  2797. public function GetSkillLocalisationKeyDescription(skill : ESkill) : string
  2798. {
  2799. if(abilityManager && abilityManager.IsInitialized())
  2800. return ((W3PlayerAbilityManager)abilityManager).GetSkillLocalisationKeyDescription(skill);
  2801.  
  2802. return "";
  2803. }
  2804.  
  2805. public function GetSkillIconPath(skill : ESkill) : string
  2806. {
  2807. if(abilityManager && abilityManager.IsInitialized())
  2808. return ((W3PlayerAbilityManager)abilityManager).GetSkillIconPath(skill);
  2809.  
  2810. return "";
  2811. }
  2812.  
  2813. public function HasLearnedSkill(skill : ESkill) : bool
  2814. {
  2815. if(abilityManager && abilityManager.IsInitialized())
  2816. return ((W3PlayerAbilityManager)abilityManager).HasLearnedSkill(skill);
  2817.  
  2818. return false;
  2819. }
  2820.  
  2821. public function IsSkillEquipped(skill : ESkill) : bool
  2822. {
  2823. if(abilityManager && abilityManager.IsInitialized())
  2824. return ((W3PlayerAbilityManager)abilityManager).IsSkillEquipped(skill);
  2825.  
  2826. return false;
  2827. }
  2828.  
  2829. public function CanUseSkill(skill : ESkill) : bool
  2830. {
  2831. if(abilityManager && abilityManager.IsInitialized())
  2832. return ((W3PlayerAbilityManager)abilityManager).CanUseSkill(skill);
  2833.  
  2834. return false;
  2835. }
  2836.  
  2837. public function CanLearnSkill(skill : ESkill) : bool
  2838. {
  2839. if(abilityManager && abilityManager.IsInitialized())
  2840. return ((W3PlayerAbilityManager)abilityManager).CanLearnSkill(skill);
  2841.  
  2842. return false;
  2843. }
  2844.  
  2845. public function HasSpentEnoughPoints(skill : ESkill) : bool
  2846. {
  2847. if(abilityManager && abilityManager.IsInitialized())
  2848. return ((W3PlayerAbilityManager)abilityManager).HasSpentEnoughPoints(skill);
  2849.  
  2850. return false;
  2851. }
  2852.  
  2853. public function PathPointsForSkillsPath(skill : ESkill) : int
  2854. {
  2855. if(abilityManager && abilityManager.IsInitialized())
  2856. return ((W3PlayerAbilityManager)abilityManager).PathPointsSpentInSkillPathOfSkill(skill);
  2857.  
  2858. return -1;
  2859. }
  2860.  
  2861. public function GetPlayerSkills() : array<SSkill>
  2862. {
  2863. var null : array<SSkill>;
  2864.  
  2865. if(abilityManager && abilityManager.IsInitialized())
  2866. return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkills();
  2867.  
  2868. return null;
  2869. }
  2870.  
  2871. public function GetPlayerSkill(s : ESkill) : SSkill
  2872. {
  2873. var null : SSkill;
  2874.  
  2875. if(abilityManager && abilityManager.IsInitialized())
  2876. return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkill(s);
  2877.  
  2878. return null;
  2879. }
  2880.  
  2881. public function GetSkillSubPathType(s : ESkill) : ESkillSubPath
  2882. {
  2883. if(abilityManager && abilityManager.IsInitialized())
  2884. return ((W3PlayerAbilityManager)abilityManager).GetSkillSubPathType(s);
  2885.  
  2886. return ESSP_NotSet;
  2887. }
  2888.  
  2889. public function GetSkillSlotsCount() : int
  2890. {
  2891. if(abilityManager && abilityManager.IsInitialized())
  2892. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotsCount();
  2893.  
  2894. return 0;
  2895. }
  2896.  
  2897. public function GetSkillSlots() : array<SSkillSlot>
  2898. {
  2899. var null : array<SSkillSlot>;
  2900.  
  2901. if(abilityManager && abilityManager.IsInitialized())
  2902. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlots();
  2903.  
  2904. return null;
  2905. }
  2906.  
  2907. public function GetPlayerSkillMutagens() : array<SMutagenSlot>
  2908. {
  2909. var null : array<SMutagenSlot>;
  2910.  
  2911. if(abilityManager && abilityManager.IsInitialized())
  2912. return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkillMutagens();
  2913.  
  2914. return null;
  2915. }
  2916.  
  2917.  
  2918.  
  2919.  
  2920. public function BlockSkill(skill : ESkill, block : bool, optional cooldown : float) : bool
  2921. {
  2922. if(abilityManager && abilityManager.IsInitialized())
  2923. return ((W3PlayerAbilityManager)abilityManager).BlockSkill(skill, block, cooldown);
  2924.  
  2925. return false;
  2926. }
  2927.  
  2928. public function IsSkillBlocked(skill : ESkill) : bool
  2929. {
  2930. if(abilityManager && abilityManager.IsInitialized())
  2931. return ((W3PlayerAbilityManager)abilityManager).IsSkillBlocked(skill);
  2932.  
  2933. return false;
  2934. }
  2935.  
  2936.  
  2937. public function EquipSkill(skill : ESkill, slotID : int) : bool
  2938. {
  2939. var ret : bool;
  2940. var groupID : int;
  2941. var pam : W3PlayerAbilityManager;
  2942.  
  2943. if(abilityManager && abilityManager.IsInitialized())
  2944. {
  2945. pam = (W3PlayerAbilityManager)abilityManager;
  2946. ret = pam.EquipSkill(skill, slotID);
  2947. if(ret)
  2948. {
  2949. groupID = pam.GetSkillGroupIdFromSkillSlotId(slotID);
  2950. LogSkillColors("Equipped <<" + GetSkillColor(skill) + ">> skill <<" + skill + ">> to group <<" + groupID + ">>");
  2951. LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
  2952. LogSkillColors("");
  2953. }
  2954.  
  2955. return ret;
  2956. }
  2957.  
  2958. return false;
  2959. }
  2960.  
  2961.  
  2962. public function UnequipSkill(slotID : int) : bool
  2963. {
  2964. var ret : bool;
  2965. var groupID : int;
  2966. var skill : ESkill;
  2967. var pam : W3PlayerAbilityManager;
  2968.  
  2969. if(abilityManager && abilityManager.IsInitialized())
  2970. {
  2971. pam = (W3PlayerAbilityManager)abilityManager;
  2972. GetSkillOnSlot(slotID, skill);
  2973. ret = pam.UnequipSkill(slotID);
  2974. if(ret)
  2975. {
  2976. groupID = pam.GetSkillGroupIdFromSkillSlotId(slotID);
  2977. LogSkillColors("Unequipped <<" + GetSkillColor(skill) + ">> skill <<" + skill + ">> from group <<" + groupID + ">>");
  2978. LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
  2979. LogSkillColors("");
  2980. }
  2981. return ret;
  2982. }
  2983.  
  2984. return false;
  2985. }
  2986.  
  2987.  
  2988. public function GetSkillOnSlot(slotID : int, out skill : ESkill) : bool
  2989. {
  2990. if(abilityManager && abilityManager.IsInitialized())
  2991. return ((W3PlayerAbilityManager)abilityManager).GetSkillOnSlot(slotID, skill);
  2992.  
  2993. skill = S_SUndefined;
  2994. return false;
  2995. }
  2996.  
  2997.  
  2998. public function GetFreeSkillSlot() : int
  2999. {
  3000. var i, size : int;
  3001. var skill : ESkill;
  3002.  
  3003. size = ((W3PlayerAbilityManager)abilityManager).GetSkillSlotsCount();
  3004. for(i=1; i<size; i+=1)
  3005. {
  3006. if(!GetSkillOnSlot(i, skill))
  3007. continue;
  3008.  
  3009. if(skill == S_SUndefined)
  3010. return i;
  3011. }
  3012.  
  3013. return -1;
  3014. }
  3015.  
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021. protected function Attack( hitTarget : CGameplayEntity, animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float, weaponEntity : CItemEntity)
  3022. {
  3023. var attackAction : W3Action_Attack;
  3024.  
  3025. if(!PrepareAttackAction(hitTarget, animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime, weaponEntity, attackAction))
  3026. return;
  3027.  
  3028. if ( attackAction.IsParried() && ( ((CNewNPC)attackAction.victim).IsShielded(attackAction.attacker) || ((CNewNPC)attackAction.victim).SignalGameplayEventReturnInt('IsDefending',0) == 1 ) )
  3029. {
  3030. thePlayer.SetCanPlayHitAnim(true);
  3031. thePlayer.ReactToReflectedAttack(attackAction.victim);
  3032. }
  3033.  
  3034. theTelemetry.LogWithLabel( TE_FIGHT_PLAYER_ATTACKS, attackAction.GetAttackName() );
  3035.  
  3036.  
  3037. theGame.damageMgr.ProcessAction(attackAction);
  3038.  
  3039. delete attackAction;
  3040. }
  3041.  
  3042. public function IsHeavyAttack(attackName : name) : bool
  3043. {
  3044. var skill : ESkill;
  3045. var sup : bool;
  3046.  
  3047. sup = super.IsHeavyAttack(attackName);
  3048. if(sup)
  3049. return true;
  3050.  
  3051. if ( attackName == 'attack_heavy_special' )
  3052. return true;
  3053.  
  3054. skill = SkillNameToEnum(attackName);
  3055.  
  3056. return skill == S_Sword_2 || skill == S_Sword_s02;
  3057. }
  3058.  
  3059. public function IsLightAttack(attackName : name) : bool
  3060. {
  3061. var skill : ESkill;
  3062. var sup : bool;
  3063.  
  3064. sup = super.IsLightAttack(attackName);
  3065. if(sup)
  3066. return true;
  3067.  
  3068. skill = SkillNameToEnum(attackName);
  3069.  
  3070. return skill == S_Sword_1 || skill == S_Sword_s01;
  3071. }
  3072.  
  3073. public final function ProcessWeaponCollision()
  3074. {
  3075. var l_stateName : name;
  3076.  
  3077. var l_weaponPosition : Vector;
  3078. var l_weaponTipPos : Vector;
  3079. var l_collidingPosition : Vector;
  3080. var l_offset : Vector;
  3081. var l_normal : Vector;
  3082.  
  3083. var l_slotMatrix : Matrix;
  3084.  
  3085. var l_distance : float;
  3086.  
  3087. var l_materialName : name;
  3088. var l_hitComponent : CComponent;
  3089. var l_destructibleCmp : CDestructionSystemComponent;
  3090. var barrel : COilBarrelEntity;
  3091.  
  3092.  
  3093.  
  3094. if( isCurrentlyDodging )
  3095. return;
  3096.  
  3097. l_stateName = GetCurrentStateName();
  3098.  
  3099. if( !attackEventInProgress && l_stateName == 'CombatFists' )
  3100. return;
  3101.  
  3102. CalcEntitySlotMatrix('r_weapon', l_slotMatrix);
  3103.  
  3104. l_weaponPosition = MatrixGetTranslation( l_slotMatrix );
  3105.  
  3106.  
  3107. switch( l_stateName )
  3108. {
  3109. case 'CombatFists':
  3110. l_offset = MatrixGetAxisX( l_slotMatrix );
  3111. l_offset = VecNormalize( l_offset ) * 0.25f;
  3112. break;
  3113.  
  3114. default:
  3115. l_offset = MatrixGetAxisZ( l_slotMatrix );
  3116. l_offset = VecNormalize( l_offset ) * 1.f;
  3117. break;
  3118. }
  3119.  
  3120. l_weaponTipPos = l_weaponPosition + l_offset;
  3121.  
  3122.  
  3123.  
  3124. if( !attackEventInProgress )
  3125. {
  3126.  
  3127. if( m_LastWeaponTipPos == Vector ( 0, 0, 0 ) )
  3128. l_distance = 0;
  3129. else
  3130. l_distance = VecDistance( l_weaponTipPos, m_LastWeaponTipPos ) ;
  3131.  
  3132.  
  3133.  
  3134.  
  3135. m_LastWeaponTipPos = l_weaponTipPos;
  3136. if( l_distance < 0.35f )
  3137. return;
  3138.  
  3139. }
  3140.  
  3141.  
  3142.  
  3143. m_LastWeaponTipPos = l_weaponTipPos;
  3144.  
  3145. if ( !theGame.GetWorld().StaticTraceWithAdditionalInfo( l_weaponPosition, l_weaponTipPos, l_collidingPosition, l_normal, l_materialName, l_hitComponent, m_WeaponFXCollisionGroupNames ) )
  3146. {
  3147.  
  3148. if( l_stateName == 'CombatFists' )
  3149. {
  3150. CalcEntitySlotMatrix('l_weapon', l_slotMatrix);
  3151. l_weaponPosition = MatrixGetTranslation( l_slotMatrix );
  3152. l_offset = MatrixGetAxisX( l_slotMatrix );
  3153. l_offset = VecNormalize( l_offset ) * 0.25f;
  3154. l_weaponTipPos = l_weaponPosition + l_offset;
  3155. if( !theGame.GetWorld().StaticTrace( l_weaponPosition, l_weaponTipPos, l_collidingPosition, l_normal, m_WeaponFXCollisionGroupNames ) )
  3156. {
  3157. return;
  3158. }
  3159. }
  3160. else
  3161. {
  3162. return;
  3163. }
  3164. }
  3165.  
  3166. if( !m_CollisionEffect )
  3167. {
  3168. m_CollisionEffect = theGame.CreateEntity( m_CollisionFxTemplate, l_collidingPosition, EulerAngles(0,0,0) );
  3169. }
  3170.  
  3171. m_CollisionEffect.Teleport( l_collidingPosition );
  3172.  
  3173.  
  3174. switch( l_stateName )
  3175. {
  3176. case 'CombatFists':
  3177. m_CollisionEffect.PlayEffect('fist');
  3178. break;
  3179. default:
  3180.  
  3181. if( m_RefreshWeaponFXType )
  3182. {
  3183. m_PlayWoodenFX = IsSwordWooden();
  3184. m_RefreshWeaponFXType = false;
  3185. }
  3186.  
  3187. if( m_PlayWoodenFX )
  3188. {
  3189. m_CollisionEffect.PlayEffect('wood');
  3190. }
  3191. else
  3192. {
  3193. switch( l_materialName )
  3194. {
  3195. case 'wood_hollow':
  3196. case 'wood_debris':
  3197. case 'wood_solid':
  3198. m_CollisionEffect.PlayEffect('wood');
  3199. break;
  3200. case 'dirt_hard':
  3201. case 'dirt_soil':
  3202. case 'hay':
  3203. m_CollisionEffect.PlayEffect('fist');
  3204. break;
  3205. case 'stone_debris':
  3206. case 'stone_solid':
  3207. case 'clay_tile':
  3208. case 'gravel_large':
  3209. case 'gravel_small':
  3210. case 'metal':
  3211. case 'custom_sword':
  3212. m_CollisionEffect.PlayEffect('sparks');
  3213. break;
  3214. case 'flesh':
  3215. m_CollisionEffect.PlayEffect('blood');
  3216. break;
  3217. default:
  3218. m_CollisionEffect.PlayEffect('wood');
  3219. break;
  3220. }
  3221.  
  3222. }
  3223. break;
  3224. }
  3225.  
  3226.  
  3227. if(l_hitComponent)
  3228. {
  3229. barrel = (COilBarrelEntity)l_hitComponent.GetEntity();
  3230. if(barrel)
  3231. {
  3232. barrel.OnFireHit(NULL);
  3233. return;
  3234. }
  3235. }
  3236.  
  3237.  
  3238. l_destructibleCmp = (CDestructionSystemComponent) l_hitComponent;
  3239. if( l_destructibleCmp && l_stateName != 'CombatFists' )
  3240. {
  3241. l_destructibleCmp.ApplyFracture();
  3242. }
  3243.  
  3244.  
  3245.  
  3246. }
  3247.  
  3248. public function ReactToReflectedAttack( target : CGameplayEntity)
  3249. {
  3250.  
  3251. var hp, dmg : float;
  3252. var action : W3DamageAction;
  3253.  
  3254. super.ReactToReflectedAttack(target);
  3255.  
  3256.  
  3257. theGame.VibrateControllerLight();
  3258. }
  3259.  
  3260.  
  3261.  
  3262.  
  3263.  
  3264.  
  3265. function GetFallDist( out fallDist : float ) : bool
  3266. {
  3267. var fallDiff, jumpTotalDiff : float;
  3268.  
  3269.  
  3270. substateManager.m_SharedDataO.CalculateFallingHeights( fallDiff, jumpTotalDiff );
  3271.  
  3272. if ( fallDiff <= 0 )
  3273. return false;
  3274.  
  3275. fallDist = fallDiff;
  3276. return true;
  3277. }
  3278.  
  3279. function ApplyFallingDamage(heightDiff : float, optional reducing : bool) : float
  3280. {
  3281. var hpPerc : float;
  3282. var tut : STutorialMessage;
  3283.  
  3284. if ( IsSwimming() || FactsQuerySum("block_falling_damage") >= 1 )
  3285. return 0.0f;
  3286.  
  3287. hpPerc = super.ApplyFallingDamage( heightDiff, reducing );
  3288.  
  3289. if(hpPerc > 0)
  3290. {
  3291. theGame.VibrateControllerHard();
  3292.  
  3293. if(IsAlive())
  3294. {
  3295. if(ShouldProcessTutorial('TutorialFallingDamage'))
  3296. {
  3297. FactsSet( "tutorial_falling_damage", 1 );
  3298. }
  3299.  
  3300. if(FactsQuerySum("tutorial_falling_damage") > 1 && ShouldProcessTutorial('TutorialFallingRoll'))
  3301. {
  3302.  
  3303. tut.type = ETMT_Hint;
  3304. tut.tutorialScriptTag = 'TutorialFallingRoll';
  3305. tut.hintPositionType = ETHPT_DefaultGlobal;
  3306. tut.hintDurationType = ETHDT_Long;
  3307. tut.canBeShownInMenus = false;
  3308. tut.glossaryLink = false;
  3309. tut.markAsSeenOnShow = true;
  3310.  
  3311.  
  3312. theGame.GetTutorialSystem().DisplayTutorial(tut);
  3313. }
  3314. }
  3315. }
  3316.  
  3317. return hpPerc;
  3318. }
  3319.  
  3320.  
  3321.  
  3322. public function SetShowToLowStaminaIndication( value : float ) : void
  3323. {
  3324. fShowToLowStaminaIndication = value;
  3325. }
  3326.  
  3327. public function GetShowToLowStaminaIndication() : float
  3328. {
  3329. return fShowToLowStaminaIndication;
  3330. }
  3331.  
  3332. public final function IndicateTooLowAdrenaline()
  3333. {
  3334. SoundEvent("gui_no_adrenaline");
  3335. showTooLowAdrenaline = true;
  3336. }
  3337.  
  3338.  
  3339.  
  3340. protected function GotoCombatStateWithAction( initialAction : EInitialAction, optional initialBuff : CBaseGameplayEffect )
  3341. {
  3342. if ( this.GetCurrentActionType() == ActorAction_Exploration )
  3343. ActionCancelAll();
  3344.  
  3345. ((W3PlayerWitcherStateCombatFists)this.GetState('CombatFists')).SetupState( initialAction, initialBuff );
  3346. this.GotoState( 'CombatFists' );
  3347.  
  3348. }
  3349.  
  3350.  
  3351. public function IsThreat( actor : CActor, optional usePrecalcs : bool ) : bool
  3352. {
  3353. var npc : CNewNPC;
  3354. var dist : float;
  3355. var targetCapsuleHeight : float;
  3356. var isDistanceExpanded : bool;
  3357. var distanceToTarget : float;
  3358. var attitude : EAIAttitude;
  3359.  
  3360. if (!actor)
  3361. {
  3362. return false;
  3363. }
  3364.  
  3365. if ( finishableEnemiesList.Contains( actor ) )
  3366. {
  3367. return true;
  3368. }
  3369.  
  3370. if ( !actor.IsAlive() || actor.IsKnockedUnconscious() )
  3371. {
  3372. return false;
  3373. }
  3374.  
  3375. npc = (CNewNPC)actor;
  3376. if (npc && npc.IsHorse() )
  3377. {
  3378. return false;
  3379. }
  3380.  
  3381. if ( hostileEnemies.Contains( actor ) )
  3382. {
  3383. return true;
  3384. }
  3385.  
  3386.  
  3387. if ( GetAttitudeBetween( this, actor ) == AIA_Hostile )
  3388. {
  3389. if ( usePrecalcs )
  3390. {
  3391. distanceToTarget = Distance2DBetweenCapsuleAndPoint( actor, this ) - targetingPrecalcs.playerRadius;
  3392. }
  3393. else
  3394. {
  3395. distanceToTarget = Distance2DBetweenCapsules( this, actor );
  3396. }
  3397.  
  3398.  
  3399. if ( distanceToTarget < findMoveTargetDist + 5.0f )
  3400. {
  3401. return true;
  3402. }
  3403.  
  3404. if ( actor.IsInCombat() || this.IsHardLockEnabled() )
  3405. {
  3406. targetCapsuleHeight = ( (CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent() ).GetCapsuleHeight();
  3407. if ( targetCapsuleHeight >= 2.0f || npc.GetCurrentStance() == NS_Fly )
  3408. {
  3409.  
  3410. if ( distanceToTarget < 40.0f )
  3411. {
  3412. return true;
  3413. }
  3414. }
  3415. }
  3416. }
  3417.  
  3418. if ( actor.GetAttitudeGroup() == 'npc_charmed' )
  3419. {
  3420. if ( theGame.GetGlobalAttitude( GetBaseAttitudeGroup(), actor.GetBaseAttitudeGroup() ) == AIA_Hostile )
  3421. {
  3422. return true;
  3423. }
  3424. }
  3425.  
  3426. return false;
  3427. }
  3428.  
  3429. function SetBIsCombatActionAllowed ( flag : bool )
  3430. {
  3431. bIsCombatActionAllowed = flag;
  3432.  
  3433. if ( !flag )
  3434. {
  3435. SetBIsInCombatAction(true);
  3436. }
  3437. else
  3438. {
  3439. this.ProcessLAxisCaching();
  3440.  
  3441. }
  3442.  
  3443.  
  3444. }
  3445.  
  3446. function GetBIsCombatActionAllowed() : bool
  3447. {
  3448. return bIsCombatActionAllowed;
  3449. }
  3450.  
  3451. function SetCombatAction( action : EBufferActionType )
  3452. {
  3453. currentCombatAction = action;
  3454. }
  3455.  
  3456. function GetCombatAction() : EBufferActionType
  3457. {
  3458. return currentCombatAction;
  3459. }
  3460.  
  3461. protected function WhenCombatActionIsFinished()
  3462. {
  3463. if(IsThrowingItem() || IsThrowingItemWithAim() )
  3464. {
  3465. if(inv.IsItemBomb(selectedItemId))
  3466. {
  3467. BombThrowAbort();
  3468. }
  3469. else
  3470. {
  3471. ThrowingAbort();
  3472. }
  3473. }
  3474.  
  3475. if ( this.GetCurrentStateName() != 'DismountHorse' )
  3476. OnRangedForceHolster( true );
  3477.  
  3478.  
  3479. }
  3480.  
  3481. public function IsInCombatAction_Attack(): bool
  3482. {
  3483. if ( IsInCombatAction_NonSpecialAttack() || IsInCombatAction_SpecialAttack() )
  3484. return true;
  3485. else
  3486. return false;
  3487. }
  3488.  
  3489. public function IsInCombatAction_NonSpecialAttack(): bool
  3490. {
  3491. if ( IsInCombatAction() && ( GetCombatAction() == EBAT_LightAttack || GetCombatAction() == EBAT_HeavyAttack ) )
  3492. return true;
  3493. else
  3494. return false;
  3495. }
  3496.  
  3497. public function IsInSpecificCombatAction ( specificCombatAction : EBufferActionType ) : bool
  3498. {
  3499. if ( IsInCombatAction() && GetCombatAction() == specificCombatAction )
  3500. return true;
  3501. else
  3502. return false;
  3503. }
  3504.  
  3505. public function IsInRunAnimation() : bool
  3506. {
  3507. return isInRunAnimation;
  3508. }
  3509.  
  3510.  
  3511. public function SetCombatIdleStance( stance : float )
  3512. {
  3513. SetBehaviorVariable( 'combatIdleStance', stance );
  3514. SetBehaviorVariable( 'CombatStanceForOverlay', stance );
  3515.  
  3516. if ( stance == 0.f )
  3517. LogChannel( 'ComboInput', "combatIdleStance = Left" );
  3518. else
  3519. LogChannel( 'ComboInput', "combatIdleStance = Right" );
  3520. }
  3521.  
  3522. public function GetCombatIdleStance() : float
  3523. {
  3524.  
  3525. return GetBehaviorVariable( 'combatIdleStance' );
  3526. }
  3527.  
  3528. protected var isRotatingInPlace : bool;
  3529. event OnRotateInPlaceStart()
  3530. {
  3531. isRotatingInPlace = true;
  3532. }
  3533.  
  3534. event OnRotateInPlaceEnd()
  3535. {
  3536. isRotatingInPlace = false;
  3537. }
  3538.  
  3539. event OnFullyBlendedIdle()
  3540. {
  3541. if ( bLAxisReleased )
  3542. {
  3543. ResetRawPlayerHeading();
  3544. ResetCachedRawPlayerHeading();
  3545. defaultLocomotionController.ResetMoveDirection();
  3546. }
  3547. }
  3548.  
  3549. private var isInIdle : bool;
  3550.  
  3551. event OnPlayerIdleStart()
  3552. {
  3553. isInIdle = true;
  3554. }
  3555.  
  3556. event OnPlayerIdleEnd()
  3557. {
  3558. isInIdle = false;
  3559. }
  3560.  
  3561. public function IsInIdle() : bool
  3562. {
  3563. return isInIdle;
  3564. }
  3565.  
  3566. event OnRunLoopStart()
  3567. {
  3568. EnableRunCamera( true );
  3569. }
  3570.  
  3571. event OnRunLoopEnd()
  3572. {
  3573. EnableRunCamera( false );
  3574. }
  3575.  
  3576. event OnCombatActionStartBehgraph()
  3577. {
  3578. var action : EBufferActionType;
  3579. var cost, delay : float;
  3580.  
  3581.  
  3582.  
  3583.  
  3584. OnCombatActionStart();
  3585.  
  3586. action = PerformingCombatAction();
  3587. switch ( action )
  3588. {
  3589. case EBAT_LightAttack :
  3590. {
  3591. abilityManager.GetStaminaActionCost(ESAT_LightAttack, cost, delay);
  3592. } break;
  3593. case EBAT_HeavyAttack :
  3594. {
  3595. abilityManager.GetStaminaActionCost(ESAT_HeavyAttack, cost, delay);
  3596. } break;
  3597. case EBAT_ItemUse :
  3598. {
  3599. abilityManager.GetStaminaActionCost(ESAT_UsableItem, cost, delay);
  3600. } break;
  3601. case EBAT_Parry :
  3602. {
  3603. abilityManager.GetStaminaActionCost(ESAT_Parry, cost, delay);
  3604. } break;
  3605. case EBAT_Dodge :
  3606. {
  3607. abilityManager.GetStaminaActionCost(ESAT_Dodge, cost, delay);
  3608. } break;
  3609. case EBAT_Roll :
  3610. abilityManager.GetStaminaActionCost(ESAT_Roll, cost, delay);
  3611. break;
  3612. case EBAT_SpecialAttack_Light :
  3613. {
  3614. abilityManager.GetStaminaActionCost(ESAT_Ability, cost, delay, 0,0, GetSkillAbilityName(S_Sword_s01));
  3615. } break;
  3616. case EBAT_SpecialAttack_Heavy :
  3617. {
  3618. abilityManager.GetStaminaActionCost(ESAT_Ability, cost, delay, 0,0, GetSkillAbilityName(S_Sword_s02));
  3619. } break;
  3620. case EBAT_Roll :
  3621. {
  3622. abilityManager.GetStaminaActionCost(ESAT_Evade, cost, delay);
  3623. } break;
  3624.  
  3625. default :
  3626. ;
  3627. }
  3628.  
  3629.  
  3630.  
  3631. if( delay > 0 )
  3632. PauseStaminaRegen( 'InsideCombatAction' );
  3633. }
  3634.  
  3635. public function HolsterUsableItem() : bool
  3636. {
  3637. return holsterUsableItem;
  3638. }
  3639.  
  3640. private var isInGuardedState : bool;
  3641. public function IsInGuardedState() : bool
  3642. {
  3643. return isInGuardedState;
  3644. }
  3645.  
  3646. event OnGuardedStart()
  3647. {
  3648. isInParryOrCounter = true;
  3649. isInGuardedState = true;
  3650. }
  3651.  
  3652. event OnGuardedEnd()
  3653. {
  3654. isInParryOrCounter = false;
  3655. isInGuardedState = false;
  3656. }
  3657.  
  3658. private var restoreUsableItem : bool;
  3659. private var holsterUsableItem : bool;
  3660. event OnCombatActionStart()
  3661. {
  3662.  
  3663.  
  3664. BlockAction( EIAB_UsableItem, 'OnCombatActionStart' );
  3665. BlockAction( EIAB_CallHorse, 'OnCombatActionStart' );
  3666.  
  3667.  
  3668.  
  3669. LogChannel('combatActionAllowed',"FALSE OnCombatActionStart");
  3670. SetBIsCombatActionAllowed( false );
  3671. SetBIsInputAllowed( false, 'OnCombatActionStart' );
  3672.  
  3673.  
  3674. ClearFinishableEnemyList( 0.f, 0 );
  3675.  
  3676. bIsInHitAnim = false;
  3677.  
  3678.  
  3679.  
  3680. if ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  3681. {
  3682. CleanCombatActionBuffer();
  3683. SetIsAimingCrossbow( false );
  3684. OnRangedForceHolster( false, true );
  3685. }
  3686.  
  3687.  
  3688. holsterUsableItem = false;
  3689. if ( thePlayer.IsHoldingItemInLHand() )
  3690. {
  3691. if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign )
  3692. holsterUsableItem = true;
  3693. else if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
  3694. {
  3695. if ( this.GetCurrentStateName() == 'CombatFists' )
  3696. holsterUsableItem = true;
  3697. }
  3698. }
  3699.  
  3700. if ( holsterUsableItem )
  3701. {
  3702. thePlayer.SetPlayerActionToRestore ( PATR_None );
  3703. thePlayer.OnUseSelectedItem( true );
  3704.  
  3705. restoreUsableItem = true;
  3706. }
  3707.  
  3708.  
  3709. if ( GetBehaviorVariable( 'combatActionType' ) != (int)CAT_Attack && GetBehaviorVariable( 'combatActionType' ) != (int)CAT_PreAttack )
  3710. {
  3711. RemoveTimer( 'ProcessAttackTimer' );
  3712. RemoveTimer( 'AttackTimerEnd' );
  3713. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  3714. }
  3715. else
  3716. {
  3717.  
  3718. BlockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  3719. }
  3720.  
  3721.  
  3722. }
  3723.  
  3724. var isInParryOrCounter : bool;
  3725. event OnParryOrCounterStart()
  3726. {
  3727. isInParryOrCounter = true;
  3728. OnCombatActionStartBehgraph();
  3729. }
  3730.  
  3731. event OnParryOrCounterEnd()
  3732. {
  3733. isInParryOrCounter = false;
  3734. OnCombatActionEnd();
  3735. SetBIsInCombatAction( false );
  3736. }
  3737.  
  3738.  
  3739. event OnCombatActionEnd()
  3740. {
  3741. var item : SItemUniqueId;
  3742. var combatActionType : float;
  3743.  
  3744. super.OnCombatActionEnd();
  3745.  
  3746.  
  3747.  
  3748. BlockAllActions( 'OnCombatActionStart', false );
  3749.  
  3750. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  3751.  
  3752.  
  3753. UnblockAction( EIAB_Movement, 'CombatActionFriendly' );
  3754.  
  3755.  
  3756.  
  3757.  
  3758. oTCameraOffset = 0.f;
  3759. oTCameraPitchOffset = 0.f;
  3760.  
  3761.  
  3762. SetBIsCombatActionAllowed( true );
  3763.  
  3764.  
  3765. SetBIsInputAllowed( true, 'OnCombatActionEnd' );
  3766. SetCanPlayHitAnim( true );
  3767. EnableFindTarget( true );
  3768.  
  3769.  
  3770.  
  3771.  
  3772. SetFinisherVictim( NULL );
  3773.  
  3774. OnBlockAllCombatTickets( false );
  3775.  
  3776. LogStamina("CombatActionEnd");
  3777.  
  3778.  
  3779.  
  3780. SetAttackActionName('');
  3781. combatActionType = GetBehaviorVariable('combatActionType');
  3782.  
  3783.  
  3784. if(GetBehaviorVariable('combatActionType') == (int)CAT_SpecialAttack)
  3785. {
  3786. theGame.GetGameCamera().StopAnimation( 'camera_shake_loop_lvl1_1' );
  3787. OnSpecialAttackHeavyActionProcess();
  3788. }
  3789.  
  3790. substateManager.ReactToChanceToFallAndSlide();
  3791. }
  3792.  
  3793. event OnCombatActionFriendlyStart()
  3794. {
  3795. SetBIsInCombatActionFriendly(true);
  3796. BlockAction( EIAB_Movement, 'CombatActionFriendly', false, false, false );
  3797. OnCombatActionStart();
  3798. }
  3799.  
  3800. event OnCombatActionFriendlyEnd()
  3801. {
  3802. SetBIsInCombatActionFriendly(false);
  3803. UnblockAction( EIAB_Movement, 'CombatActionFriendly' );
  3804. OnCombatActionEnd();
  3805. SetBIsInCombatAction(false);
  3806.  
  3807. }
  3808.  
  3809. event OnHitStart()
  3810. {
  3811. var timeLeft : float;
  3812. var currentEffects : array<CBaseGameplayEffect>;
  3813. var none : SAbilityAttributeValue;
  3814.  
  3815. CancelHoldAttacks();
  3816. WhenCombatActionIsFinished();
  3817. if ( isInFinisher )
  3818. {
  3819. if ( finisherTarget )
  3820. ( (CNewNPC)finisherTarget ).SignalGameplayEvent( 'FinisherInterrupt' );
  3821. isInFinisher = false;
  3822. finisherTarget = NULL;
  3823. SetBIsCombatActionAllowed( true );
  3824. }
  3825.  
  3826. bIsInHitAnim = true;
  3827.  
  3828. OnCombatActionStart();
  3829.  
  3830.  
  3831. ResumeStaminaRegen( 'InsideCombatAction' );
  3832.  
  3833. if( GetHealthPercents() < 0.3f )
  3834. {
  3835. PlayBattleCry('BattleCryBadSituation', 0.10f, true );
  3836. }
  3837. else
  3838. {
  3839. PlayBattleCry('BattleCryBadSituation', 0.05f, true );
  3840. }
  3841. }
  3842.  
  3843. event OnHitStartSwimming()
  3844. {
  3845. OnRangedForceHolster( true, true, false );
  3846. }
  3847.  
  3848. private var finisherSaveLock : int;
  3849. event OnFinisherStart()
  3850. {
  3851. var currentEffects : array<CBaseGameplayEffect>;
  3852.  
  3853. theGame.CreateNoSaveLock("Finisher",finisherSaveLock,true,false);
  3854.  
  3855. isInFinisher = true;
  3856.  
  3857. finisherTarget = slideTarget;
  3858. OnCombatActionStart();
  3859.  
  3860. CancelHoldAttacks();
  3861.  
  3862. PlayFinisherCameraAnimation( theGame.GetSyncAnimManager().GetFinisherCameraAnimName() );
  3863. this.AddAnimEventCallback('SyncEvent','OnFinisherAnimEvent_SyncEvent');
  3864. SetImmortalityMode( AIM_Invulnerable, AIC_SyncedAnim );
  3865. }
  3866.  
  3867. public function IsPerformingFinisher() : bool
  3868. {
  3869. return isInFinisher;
  3870. }
  3871.  
  3872. private function PlayFinisherCameraAnimation( cameraAnimName : name )
  3873. {
  3874. var camera : CCustomCamera = theGame.GetGameCamera();
  3875. var animation : SCameraAnimationDefinition;
  3876.  
  3877. if( IsLastEnemyKilled() && theGame.GetWorld().NavigationCircleTest( this.GetWorldPosition(), 3.f ) )
  3878. {
  3879. camera.StopAnimation('camera_shake_hit_lvl3_1' );
  3880.  
  3881. animation.animation = cameraAnimName;
  3882. animation.priority = CAP_Highest;
  3883. animation.blendIn = 0.15f;
  3884. animation.blendOut = 1.0f;
  3885. animation.weight = 1.f;
  3886. animation.speed = 1.0f;
  3887. animation.reset = true;
  3888.  
  3889. camera.PlayAnimation( animation );
  3890.  
  3891.  
  3892. thePlayer.EnableManualCameraControl( false, 'Finisher' );
  3893. }
  3894. }
  3895.  
  3896. public function IsLastEnemyKilled() : bool
  3897. {
  3898. var tempMoveTargets : array<CActor>;
  3899.  
  3900. FindMoveTarget();
  3901. tempMoveTargets = GetMoveTargets();
  3902. if ( tempMoveTargets.Size() <= 0 || !thePlayer.IsThreat( tempMoveTargets[0] ) )
  3903. return true;
  3904.  
  3905. return false;
  3906. }
  3907.  
  3908. event OnFinisherAnimEvent_SyncEvent( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  3909. {
  3910. if ( finisherTarget )
  3911. ( (CNewNPC)finisherTarget ).SignalGameplayEvent('FinisherKill');
  3912. finisherTarget = NULL;
  3913. }
  3914.  
  3915. event OnFinisherEnd()
  3916. {
  3917. isInFinisher = false;
  3918. finisherTarget = NULL;
  3919.  
  3920. theGame.ReleaseNoSaveLock(finisherSaveLock);
  3921.  
  3922. this.RemoveAnimEventCallback('SyncEvent');
  3923.  
  3924.  
  3925. SetImmortalityMode( AIM_None, AIC_SyncedAnim );
  3926. theGame.RemoveTimeScale( 'AnimEventSlomoMo' );
  3927. AddTimer( 'FinisherEndEnableCamera', 0.5f );
  3928.  
  3929. OnCombatActionEnd();
  3930. OnCombatActionEndComplete();
  3931. }
  3932.  
  3933. private timer function FinisherEndEnableCamera( dt : float, id : int )
  3934. {
  3935. thePlayer.EnableManualCameraControl( true, 'Finisher' );
  3936. }
  3937.  
  3938. public function SpawnFinisherBlood()
  3939. {
  3940. var weaponEntity : CEntity;
  3941. var weaponSlotMatrix : Matrix;
  3942. var bloodFxPos : Vector;
  3943. var bloodFxRot : EulerAngles;
  3944. var tempEntity : CEntity;
  3945.  
  3946. weaponEntity = this.GetInventory().GetItemEntityUnsafe( GetInventory().GetItemFromSlot('r_weapon') );
  3947. weaponEntity.CalcEntitySlotMatrix( 'blood_fx_point', weaponSlotMatrix );
  3948. bloodFxPos = MatrixGetTranslation( weaponSlotMatrix );
  3949. bloodFxRot = this.GetWorldRotation();
  3950. tempEntity = theGame.CreateEntity( (CEntityTemplate)LoadResource('finisher_blood'), bloodFxPos, bloodFxRot);
  3951. tempEntity.PlayEffect('crawl_blood');
  3952. }
  3953.  
  3954.  
  3955. event OnCombatActionEndComplete()
  3956. {
  3957. var buff : CBaseGameplayEffect;
  3958.  
  3959. buff = ChooseCurrentCriticalBuffForAnim();
  3960. SetCombatAction( EBAT_EMPTY );
  3961.  
  3962.  
  3963. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart' );
  3964. UnblockAction( EIAB_OpenInventory, 'OnCombatActionStart' );
  3965. UnblockAction( EIAB_UsableItem, 'OnCombatActionStart' );
  3966.  
  3967. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  3968.  
  3969. SetUnpushableTarget( NULL );
  3970. SetBIsInCombatAction(false);
  3971. SetIsCurrentlyDodging(false);
  3972. SetMoveTargetChangeAllowed( true );
  3973. SetCanPlayHitAnim( true );
  3974.  
  3975. SetFinisherVictim( NULL );
  3976.  
  3977. this.RemoveBuffImmunity(EET_Burning, 'AnimEvent_RemoveBurning');
  3978.  
  3979. if ( rangedWeapon && rangedWeapon.GetCurrentStateName() == 'State_WeaponWait' && !buff )
  3980. {
  3981. ClearCustomOrientationInfoStack();
  3982. SetSlideTarget( NULL );
  3983. }
  3984.  
  3985. UnblockAction( EIAB_Crossbow, 'OnForceHolster' );
  3986.  
  3987. specialAttackCamera = false;
  3988.  
  3989. bIsRollAllowed = false;
  3990.  
  3991. if ( bLAxisReleased )
  3992. {
  3993. ResetRawPlayerHeading();
  3994. ResetCachedRawPlayerHeading();
  3995. }
  3996.  
  3997.  
  3998. ReapplyCriticalBuff();
  3999. SetBIsInputAllowed( true, 'OnCombatActionEndComplete' );
  4000.  
  4001.  
  4002. ResumeStaminaRegen( 'InsideCombatAction' );
  4003.  
  4004. bIsInHitAnim = false;
  4005.  
  4006. SetBIsCombatActionAllowed( true );
  4007.  
  4008. m_LastWeaponTipPos = Vector(0, 0, 0, 0 );
  4009.  
  4010.  
  4011. this.AddTimer('FreeTickets',3.f,false);
  4012.  
  4013.  
  4014.  
  4015. }
  4016.  
  4017. event OnMovementFullyBlended()
  4018. {
  4019. SetBehaviorVariable( 'isPerformingSpecialAttack', 0.f );
  4020.  
  4021. if ( restoreUsableItem )
  4022. {
  4023. restoreUsableItem = false;
  4024. SetPlayerActionToRestore ( PATR_Default );
  4025. OnUseSelectedItem();
  4026. }
  4027. }
  4028.  
  4029. event OnCombatMovementStart()
  4030. {
  4031. SetCombatIdleStance( 1.f );
  4032. OnCombatActionEndComplete();
  4033. }
  4034.  
  4035. timer function FreeTickets( dt : float, id : int )
  4036. {
  4037. FreeTicketAtCombatTarget();
  4038. }
  4039.  
  4040.  
  4041.  
  4042. event OnGuardedReleased(){}
  4043. event OnPerformAttack( playerAttackType : name ){}
  4044. event OnPerformEvade( playerEvadeType : EPlayerEvadeType ){}
  4045. event OnInterruptAttack(){}
  4046. event OnPerformGuard(){}
  4047. event OnSpawnHorse(){}
  4048. event OnDismountActionScriptCallback(){}
  4049.  
  4050. event OnHorseSummonStart()
  4051. {
  4052. thePlayer.BlockAction(EIAB_CallHorse, 'HorseSummon');
  4053. thePlayer.BlockAction(EIAB_Signs, 'HorseSummon');
  4054. thePlayer.BlockAction(EIAB_Crossbow, 'HorseSummon');
  4055. thePlayer.BlockAction(EIAB_UsableItem, 'HorseSummon');
  4056. thePlayer.BlockAction(EIAB_ThrowBomb, 'HorseSummon');
  4057. thePlayer.BlockAction(EIAB_SwordAttack, 'HorseSummon');
  4058. thePlayer.BlockAction(EIAB_Jump, 'HorseSummon');
  4059. thePlayer.BlockAction(EIAB_Dodge, 'HorseSummon');
  4060. thePlayer.BlockAction(EIAB_LightAttacks, 'HorseSummon');
  4061. thePlayer.BlockAction(EIAB_HeavyAttacks, 'HorseSummon');
  4062. thePlayer.BlockAction(EIAB_SpecialAttackLight, 'HorseSummon');
  4063. thePlayer.BlockAction(EIAB_SpecialAttackHeavy, 'HorseSummon');
  4064.  
  4065. horseSummonTimeStamp = theGame.GetEngineTimeAsSeconds();
  4066. }
  4067.  
  4068. event OnHorseSummonStop()
  4069. {
  4070. thePlayer.BlockAllActions('HorseSummon',false);
  4071. }
  4072.  
  4073.  
  4074. event OnCombatActionStartVehicle( action : EVehicleCombatAction )
  4075. {
  4076. this.SetBIsCombatActionAllowed( false );
  4077.  
  4078. if ( action != EHCA_ShootCrossbow )
  4079. {
  4080. SetIsAimingCrossbow( false );
  4081. OnRangedForceHolster();
  4082. }
  4083. }
  4084.  
  4085. event OnCombatActionEndVehicle()
  4086. {
  4087. this.SetBIsCombatActionAllowed( true );
  4088. }
  4089.  
  4090.  
  4091.  
  4092.  
  4093.  
  4094. protected function CriticalBuffInformBehavior(buff : CBaseGameplayEffect)
  4095. {
  4096.  
  4097. if( !CanAnimationReactToCriticalState( buff ) )
  4098. {
  4099. return;
  4100. }
  4101.  
  4102.  
  4103.  
  4104.  
  4105. SetBehaviorVariable( 'CriticalStateType', (int)GetBuffCriticalType(buff) );
  4106. SetBehaviorVariable( 'bCriticalState', 1);
  4107.  
  4108. if(CriticalBuffUsesFullBodyAnim(buff))
  4109. RaiseEvent('CriticalState');
  4110.  
  4111. SetBehaviorVariable( 'IsInAir', (int)IsInAir());
  4112.  
  4113. LogCritical("Sending player critical state event for <<" + buff.GetEffectType() + ">>");
  4114.  
  4115.  
  4116. }
  4117.  
  4118. private function CanAnimationReactToCriticalState( buff : CBaseGameplayEffect ) : bool
  4119. {
  4120. var buffCritical : W3CriticalEffect;
  4121. var buffCriticalDOT : W3CriticalDOTEffect;
  4122. var isHeavyCritical : bool;
  4123.  
  4124. isHeavyCritical = false;
  4125.  
  4126.  
  4127. buffCritical = ( W3CriticalEffect ) buff;
  4128. if( buffCritical )
  4129. {
  4130. isHeavyCritical = buffCritical.explorationStateHandling == ECH_HandleNow;
  4131. }
  4132. else
  4133. {
  4134. buffCriticalDOT = ( W3CriticalDOTEffect ) buff;
  4135. if( buffCriticalDOT )
  4136. {
  4137. isHeavyCritical = buffCriticalDOT.explorationStateHandling == ECH_HandleNow;
  4138. }
  4139. }
  4140.  
  4141.  
  4142. if( !isHeavyCritical )
  4143. {
  4144. if( !CanReactToCriticalState() )
  4145. {
  4146. return false;
  4147. }
  4148. }
  4149.  
  4150. return true;
  4151. }
  4152.  
  4153. public function CanReactToCriticalState() : bool
  4154. {
  4155. return substateManager.CanReactToHardCriticalState();
  4156. }
  4157.  
  4158. event OnCriticalStateAnimStart()
  4159. {
  4160. var heading : float;
  4161. var newCritical : ECriticalStateType;
  4162. var newReqCS : CBaseGameplayEffect;
  4163.  
  4164. OnCombatActionEndComplete();
  4165.  
  4166.  
  4167. newReqCS = newRequestedCS;
  4168. if(super.OnCriticalStateAnimStart())
  4169. {
  4170.  
  4171. RemoveTimer( 'IsItemUseInputHeld' );
  4172. keepRequestingCriticalAnimStart = false;
  4173. CancelHoldAttacks();
  4174.  
  4175.  
  4176.  
  4177.  
  4178.  
  4179. if(!IsUsingVehicle())
  4180. {
  4181. newCritical = GetBuffCriticalType(newReqCS);
  4182. if(newCritical == ECST_HeavyKnockdown
  4183. || newCritical == ECST_Knockdown
  4184. || newCritical == ECST_Stagger
  4185. || newCritical == ECST_Ragdoll
  4186. || newCritical == ECST_LongStagger )
  4187. {
  4188. if(newReqCS.GetCreator())
  4189. heading = VecHeading(newReqCS.GetCreator().GetWorldPosition() - GetWorldPosition());
  4190. else
  4191. heading = GetHeading();
  4192.  
  4193.  
  4194. SetCustomRotation( 'Knockdown', heading, 2160.f, 0.1f, true );
  4195.  
  4196. if ( newCritical != ECST_Stagger && newCritical != ECST_LongStagger )
  4197. substateManager.ReactOnCriticalState( true );
  4198. }
  4199. }
  4200.  
  4201. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'CriticalEffectStart', -1, 30.0f, -1.f, -1, true );
  4202. return true;
  4203. }
  4204.  
  4205.  
  4206. return false;
  4207. }
  4208.  
  4209.  
  4210. public function StartCSAnim(buff : CBaseGameplayEffect) : bool
  4211. {
  4212. SetBehaviorVariable( 'bCriticalStopped', 0 );
  4213.  
  4214. if(super.StartCSAnim(buff))
  4215. {
  4216. if(!CriticalBuffUsesFullBodyAnim(buff))
  4217. {
  4218. OnCriticalStateAnimStart();
  4219. }
  4220.  
  4221. ResumeStaminaRegen( 'InsideCombatAction' );
  4222.  
  4223. keepRequestingCriticalAnimStart = true;
  4224. AddTimer('RequestCriticalAnimStart', 0, true);
  4225.  
  4226.  
  4227. return true;
  4228. }
  4229.  
  4230. return false;
  4231. }
  4232.  
  4233. public function CriticalEffectAnimationInterrupted(reason : string) : bool
  4234. {
  4235. var ret : bool;
  4236.  
  4237. LogCriticalPlayer("R4Player.CriticalEffectAnimationInterrupted() - because: " + reason);
  4238.  
  4239. ret = super.CriticalEffectAnimationInterrupted(reason);
  4240.  
  4241. if(ret)
  4242. {
  4243. keepRequestingCriticalAnimStart = false;
  4244. }
  4245.  
  4246. substateManager.ReactOnCriticalState( false );
  4247.  
  4248. return ret;
  4249. }
  4250.  
  4251. public function CriticalStateAnimStopped(forceRemoveBuff : bool)
  4252. {
  4253. LogCriticalPlayer("R4Player.CriticalStateAnimStopped() - forced: " + forceRemoveBuff);
  4254.  
  4255. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'RecoveredFromCriticalEffect', -1, 30.0f, -1.f, -1, true );
  4256. super.CriticalStateAnimStopped(forceRemoveBuff);
  4257.  
  4258. substateManager.ReactOnCriticalState( false );
  4259. }
  4260.  
  4261.  
  4262. timer function RequestCriticalAnimStart(dt : float, id : int)
  4263. {
  4264. if(keepRequestingCriticalAnimStart)
  4265. {
  4266. if(newRequestedCS && newRequestedCS.GetDurationLeft() > 0)
  4267. {
  4268. CriticalBuffInformBehavior(newRequestedCS);
  4269. }
  4270. else
  4271. {
  4272. keepRequestingCriticalAnimStart = false;
  4273. RemoveTimer('RequestCriticalAnimStart');
  4274. }
  4275. }
  4276. else
  4277. {
  4278. RemoveTimer('RequestCriticalAnimStart');
  4279. }
  4280. }
  4281.  
  4282. event OnRagdollUpdate(progress : float)
  4283. {
  4284.  
  4285.  
  4286. SetIsInAir(progress == 0);
  4287. }
  4288.  
  4289.  
  4290. event OnRagdollOnGround()
  4291. {
  4292.  
  4293. TryToEndRagdollOnGround( 0.0f );
  4294. }
  4295.  
  4296. event OnRagdollInAir()
  4297. {
  4298. RemoveTimer('TryToEndRagdollOnGround');
  4299. }
  4300.  
  4301. event OnNoLongerInRagdoll()
  4302. {
  4303. RemoveTimer('TryToEndRagdollOnGround');
  4304. }
  4305.  
  4306. timer function TryToEndRagdollOnGround( td : float, optional id : int)
  4307. {
  4308. var critical : CBaseGameplayEffect;
  4309. var type : EEffectType;
  4310.  
  4311. critical = GetCurrentlyAnimatedCS();
  4312. if(critical)
  4313. {
  4314. type = critical.GetEffectType();
  4315. if(type == EET_Knockdown || type == EET_HeavyKnockdown || type == EET_Ragdoll)
  4316. {
  4317.  
  4318. if (critical.GetTimeActive() >= 2.5f)
  4319. {
  4320. SetIsInAir(false);
  4321. RequestCriticalAnimStop();
  4322. RemoveTimer('TryToEndRagdollOnGround');
  4323. }
  4324. else
  4325. {
  4326. AddTimer('TryToEndRagdollOnGround', 0.2f, true);
  4327. }
  4328. return;
  4329. }
  4330. }
  4331.  
  4332.  
  4333. RemoveTimer('TryToEndRagdollOnGround');
  4334. }
  4335.  
  4336. public function RequestCriticalAnimStop(optional dontSetCriticalToStopped : bool)
  4337. {
  4338. var buff : CBaseGameplayEffect;
  4339.  
  4340. buff = GetCurrentlyAnimatedCS();
  4341. if(buff && !CriticalBuffUsesFullBodyAnim(buff))
  4342. {
  4343. CriticalStateAnimStopped(false);
  4344. }
  4345.  
  4346. if(!buff || !CriticalBuffUsesFullBodyAnim(buff))
  4347. {
  4348. SetBehaviorVariable( 'bCriticalState', 0);
  4349. }
  4350.  
  4351. super.RequestCriticalAnimStop(dontSetCriticalToStopped);
  4352. }
  4353.  
  4354.  
  4355.  
  4356.  
  4357. public function SimulateBuffTimePassing(simulatedTime : float)
  4358. {
  4359. effectManager.SimulateBuffTimePassing(simulatedTime);
  4360. }
  4361.  
  4362. public function AddEffectDefault(effectType : EEffectType, creat : CGameplayEntity, srcName : string, optional isSignEffect : bool) : EEffectInteract
  4363. {
  4364. var params : SCustomEffectParams;
  4365.  
  4366.  
  4367. if(effectType == EET_Stagger || effectType == EET_LongStagger || effectType == EET_Knockdown || effectType == EET_HeavyKnockdown)
  4368. {
  4369. params.effectType = effectType;
  4370. params.creator = creat;
  4371. params.sourceName = srcName;
  4372. params.isSignEffect = isSignEffect;
  4373.  
  4374. if ( effectType == EET_Stagger )
  4375. params.duration = 1.83;
  4376. else if ( effectType == EET_LongStagger )
  4377. params.duration = 4;
  4378. else if ( effectType == EET_Knockdown )
  4379. params.duration = 2.5;
  4380. else if ( effectType == EET_HeavyKnockdown )
  4381. params.duration = 4;
  4382.  
  4383. return super.AddEffectCustom(params);
  4384. }
  4385. else
  4386. {
  4387. return super.AddEffectDefault(effectType, creat, srcName, isSignEffect);
  4388. }
  4389. }
  4390.  
  4391.  
  4392.  
  4393.  
  4394.  
  4395. public function CheatResurrect()
  4396. {
  4397. var items : array< SItemUniqueId >;
  4398. var i, size, itemLevel, maxPrice, itemPrice : int;
  4399. var itemToEquip : SItemUniqueId;
  4400.  
  4401. if(IsAlive())
  4402. return;
  4403.  
  4404.  
  4405. if ( !theGame.GetGuiManager().GetRootMenu() )
  4406. {
  4407. Log(" *** Call this function after DeathScreen appears *** ");
  4408. return;
  4409. }
  4410.  
  4411. SetAlive(true);
  4412.  
  4413. SetKinematic(true);
  4414.  
  4415. EnableFindTarget( true );
  4416. SetBehaviorVariable( 'Ragdoll_Weight', 0.f );
  4417. RaiseForceEvent( 'RecoverFromRagdoll' );
  4418. SetCanPlayHitAnim( true );
  4419. SetBehaviorVariable( 'CriticalStateType', (int)ECST_None );
  4420. GoToStateIfNew('Exploration');
  4421.  
  4422. ( (CDismembermentComponent)this.GetComponent( 'Dismemberment' ) ).ClearVisibleWound();
  4423.  
  4424. SetIsInAir(false);
  4425.  
  4426. theInput.SetContext('Exploration');
  4427.  
  4428. ResetDeathType();
  4429.  
  4430. ForceUnlockAllInputActions(false);
  4431.  
  4432. theGame.CloseMenu('DeathScreenMenu');
  4433.  
  4434.  
  4435. theSound.LeaveGameState(ESGS_Death);
  4436.  
  4437.  
  4438. abilityManager.ForceSetStat(BCS_Vitality, GetStatMax(BCS_Vitality));
  4439. effectManager.StopVitalityRegen();
  4440. abilityManager.ForceSetStat( BCS_Air , 100.f );
  4441. effectManager.StopAirRegen();
  4442. abilityManager.ForceSetStat( BCS_Stamina , 100.f );
  4443. effectManager.StopStaminaRegen();
  4444. abilityManager.ForceSetStat( BCS_Toxicity , 0.f );
  4445. abilityManager.ForceSetStat( BCS_Focus , 0.f );
  4446. GetWitcherPlayer().UpdateEncumbrance();
  4447.  
  4448.  
  4449. if ( !inv.IsThereItemOnSlot( EES_SteelSword ) )
  4450. {
  4451. items = inv.GetItemsByCategory( 'steelsword' );
  4452. }
  4453. else if ( !inv.IsThereItemOnSlot( EES_SilverSword ) )
  4454. {
  4455. items = inv.GetItemsByCategory( 'silversword' );
  4456. }
  4457.  
  4458. size = items.Size();
  4459. maxPrice = -1;
  4460. for ( i = 0; i < size; i += 1 )
  4461. {
  4462. itemPrice = inv.GetItemPrice(items[i]);
  4463. itemLevel = inv.GetItemLevel(items[i]);
  4464. if ( itemLevel <= GetLevel() && itemPrice > maxPrice )
  4465. {
  4466. maxPrice = itemPrice;
  4467. itemToEquip = items[i];
  4468. }
  4469. }
  4470. if( inv.IsIdValid( itemToEquip ) )
  4471. {
  4472. EquipItem( itemToEquip , , true );
  4473. }
  4474.  
  4475. theGame.ReleaseNoSaveLock(deathNoSaveLock);
  4476. }
  4477.  
  4478.  
  4479.  
  4480. public function SetIsInsideInteraction(b : bool) {isInsideInteraction = b;}
  4481. public function IsInsideInteraction() : bool {return isInsideInteraction;}
  4482.  
  4483. public function SetIsInsideHorseInteraction( b : bool, horse : CEntity )
  4484. {
  4485. isInsideHorseInteraction = b;
  4486. horseInteractionSource = horse;
  4487. }
  4488. public function IsInsideHorseInteraction() : bool {return isInsideHorseInteraction;}
  4489.  
  4490.  
  4491. event OnInteractionActivationTest( interactionComponentName : string, activator : CEntity )
  4492. {
  4493. if ( interactionComponentName == "ClimbLadder" )
  4494. {
  4495. if( PlayerHasLadderExplorationReady() )
  4496. {
  4497. return true;
  4498. }
  4499. }
  4500.  
  4501. return false;
  4502. }
  4503.  
  4504. private function PlayerHasLadderExplorationReady() : bool
  4505. {
  4506. if( !substateManager.CanInteract() )
  4507. {
  4508. return false;
  4509. }
  4510.  
  4511. if( !substateManager.m_SharedDataO.HasValidLadderExploration() )
  4512. {
  4513. return false;
  4514. }
  4515.  
  4516. return true;
  4517. }
  4518.  
  4519.  
  4520.  
  4521.  
  4522.  
  4523. public function SetGuarded(flag : bool)
  4524. {
  4525. super.SetGuarded(flag);
  4526.  
  4527. if(flag && FactsQuerySum("tut_fight_use_slomo") > 0)
  4528. {
  4529. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
  4530. FactsRemove("tut_fight_slomo_ON");
  4531. }
  4532. }
  4533.  
  4534.  
  4535. public function IsGuarded() : bool
  4536. {
  4537. return super.IsGuarded() && ( !rangedWeapon || rangedWeapon.GetCurrentStateName() == 'State_WeaponWait' );
  4538. }
  4539.  
  4540.  
  4541.  
  4542.  
  4543. public function GetSelectedItemId() : SItemUniqueId {return selectedItemId;}
  4544. public function ClearSelectedItemId() {selectedItemId = GetInvalidUniqueId();}
  4545.  
  4546. public function IsHoldingItemInLHand() : bool
  4547. {
  4548. return currentlyEquipedItemL != GetInvalidUniqueId();
  4549. }
  4550.  
  4551. public function GetCurrentlyUsedItemL () : W3UsableItem
  4552. {
  4553. return currentlyUsedItemL;
  4554. }
  4555.  
  4556. public function SetPlayerActionToRestore ( actionToRestoreType : EPlayerActionToRestore )
  4557. {
  4558. playerActionToRestore = actionToRestoreType;
  4559. }
  4560.  
  4561. public function IsCurrentlyUsingItemL () : bool
  4562. {
  4563. return currentlyUsingItem;
  4564. }
  4565.  
  4566. function BlockSlotsOnLItemUse ()
  4567. {
  4568. var slotsToBlock : array<name>;
  4569.  
  4570. slotsToBlock.PushBack( 'Slot1' );
  4571. slotsToBlock.PushBack( 'Slot2' );
  4572. slotsToBlock.PushBack( 'Slot3' );
  4573. slotsToBlock.PushBack( 'Slot4' );
  4574. slotsToBlock.PushBack( 'Slot5' );
  4575. slotsToBlock.PushBack( 'Yrden' );
  4576. slotsToBlock.PushBack( 'Quen' );
  4577. slotsToBlock.PushBack( 'Igni' );
  4578. slotsToBlock.PushBack( 'Axii' );
  4579. slotsToBlock.PushBack( 'Aard' );
  4580.  
  4581.  
  4582. EnableRadialSlotsWithSource ( false, slotsToBlock, 'usableItemL' );
  4583. }
  4584.  
  4585. function UnblockSlotsOnLItemUse ()
  4586. {
  4587. var slotsToBlock : array<name>;
  4588.  
  4589. slotsToBlock.PushBack( 'Slot1' );
  4590. slotsToBlock.PushBack( 'Slot2' );
  4591. slotsToBlock.PushBack( 'Slot3' );
  4592. slotsToBlock.PushBack( 'Slot4' );
  4593. slotsToBlock.PushBack( 'Slot5' );
  4594. slotsToBlock.PushBack( 'Yrden' );
  4595. slotsToBlock.PushBack( 'Quen' );
  4596. slotsToBlock.PushBack( 'Igni' );
  4597. slotsToBlock.PushBack( 'Axii' );
  4598. slotsToBlock.PushBack( 'Aard' );
  4599.  
  4600.  
  4601. EnableRadialSlotsWithSource ( true, slotsToBlock, 'usableItemL' );
  4602. }
  4603.  
  4604. function IsUsableItemLBlocked () : bool
  4605. {
  4606. return isUsableItemBlocked;
  4607. }
  4608. function HideUsableItem( optional force : bool )
  4609. {
  4610. if( currentlyEquipedItemL != GetInvalidUniqueId() )
  4611. {
  4612. if( force )
  4613. {
  4614. if( !RaiseForceEvent( 'ItemEndL' ) )
  4615. {
  4616.  
  4617. OnUsingItemsReset();
  4618. }
  4619. return;
  4620.  
  4621. }
  4622. RaiseEvent( 'ItemUseL' );
  4623. }
  4624. }
  4625. function ProcessUsableItemsTransition ( actionToRestore : EPlayerActionToRestore )
  4626. {
  4627. var category : name;
  4628. var signSkill : ESkill;
  4629.  
  4630. category = inv.GetItemCategory ( selectedItemId );
  4631. signSkill = SignEnumToSkillEnum( GetEquippedSign());
  4632.  
  4633. switch ( actionToRestore )
  4634. {
  4635. case PATR_None:
  4636. if ( currentlyUsedItemL )
  4637. {
  4638. inv.UnmountItem( currentlyEquipedItemL, true );
  4639. }
  4640. currentlyEquipedItemL = GetInvalidUniqueId();
  4641. return;
  4642.  
  4643. case PATR_Default:
  4644. if ( IsSlotQuickslot( inv.GetSlotForItemId ( selectedItemId )) && category == 'usable' && currentlyEquipedItemL != selectedItemId )
  4645. {
  4646. if ( currentlyUsedItemL )
  4647. {
  4648. inv.UnmountItem( currentlyEquipedItemL, true );
  4649. }
  4650. currentlyEquipedItemL = GetInvalidUniqueId();
  4651. OnUseSelectedItem();
  4652. return;
  4653. }
  4654. break;
  4655. case PATR_Crossbow:
  4656. if ( inv.IsItemCrossbow ( selectedItemId ) )
  4657. {
  4658. if ( currentlyUsedItemL )
  4659. {
  4660. inv.UnmountItem( currentlyEquipedItemL, true );
  4661. }
  4662. currentlyEquipedItemL = GetInvalidUniqueId();
  4663. SetIsAimingCrossbow( true );
  4664.  
  4665. if ( theInput.IsActionPressed( 'ThrowItem' ) )
  4666. SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  4667. else
  4668. {
  4669. SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  4670. SetupCombatAction( EBAT_ItemUse, BS_Released );
  4671. }
  4672. return;
  4673. }
  4674. break;
  4675. case PATR_CastSign:
  4676. if( signSkill != S_SUndefined && playerActionToRestore == PATR_CastSign )
  4677. {
  4678. if ( currentlyUsedItemL )
  4679. {
  4680. inv.UnmountItem( currentlyEquipedItemL, true );
  4681. }
  4682. currentlyEquipedItemL = GetInvalidUniqueId();
  4683.  
  4684. if( HasStaminaToUseSkill( signSkill, false ) )
  4685. {
  4686. if( GetInvalidUniqueId() != inv.GetItemFromSlot( 'l_weapon' ) )
  4687. PushCombatActionOnBuffer( EBAT_CastSign, BS_Pressed );
  4688. else
  4689. SetupCombatAction( EBAT_CastSign, BS_Pressed );
  4690. }
  4691. else
  4692. {
  4693. thePlayer.SoundEvent("gui_no_stamina");
  4694. }
  4695. return;
  4696. }
  4697. break;
  4698. case PATR_ThrowBomb:
  4699. if ( inv.IsItemBomb ( selectedItemId ) )
  4700. {
  4701. if ( currentlyUsedItemL )
  4702. {
  4703. inv.UnmountItem( currentlyEquipedItemL, true );
  4704. }
  4705. currentlyEquipedItemL = GetInvalidUniqueId();
  4706. PrepareToAttack();
  4707. SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  4708. return;
  4709. }
  4710. break;
  4711. case PATR_CallHorse:
  4712. theGame.OnSpawnPlayerHorse();
  4713. break;
  4714. default:
  4715. if ( currentlyUsedItemL )
  4716. {
  4717. inv.UnmountItem( currentlyEquipedItemL, true );
  4718. }
  4719. currentlyEquipedItemL = GetInvalidUniqueId();
  4720. return;
  4721. }
  4722. if ( currentlyUsedItemL )
  4723. {
  4724. inv.UnmountItem( currentlyEquipedItemL, true );
  4725. }
  4726. currentlyEquipedItemL = GetInvalidUniqueId();
  4727. }
  4728.  
  4729. function GetUsableItemLtransitionAllowed () : bool
  4730. {
  4731. return isUsableItemLtransitionAllowed;
  4732. }
  4733.  
  4734. function SetUsableItemLtransitionAllowed ( isAllowed : bool)
  4735. {
  4736. isUsableItemLtransitionAllowed = isAllowed;
  4737. }
  4738.  
  4739. event OnItemUseLUnBlocked ()
  4740. {
  4741. if ( isUsableItemBlocked )
  4742. {
  4743. isUsableItemBlocked = false;
  4744. UnblockSlotsOnLItemUse ();
  4745. }
  4746. }
  4747.  
  4748. event OnItemUseLBlocked ()
  4749. {
  4750. if ( !isUsableItemBlocked )
  4751. {
  4752. isUsableItemBlocked = true;
  4753. BlockSlotsOnLItemUse ();
  4754. }
  4755. }
  4756.  
  4757. event OnUsingItemsReset()
  4758. {
  4759. if ( currentlyUsingItem )
  4760. {
  4761. OnItemUseLUnBlocked ();
  4762. OnUsingItemsComplete();
  4763. }
  4764. }
  4765. event OnUsingItemsComplete ()
  4766. {
  4767. if ( isUsableItemBlocked )
  4768. {
  4769. OnItemUseLUnBlocked ();
  4770. }
  4771. currentlyUsingItem = false;
  4772. if ( GetUsableItemLtransitionAllowed () )
  4773. {
  4774. ProcessUsableItemsTransition( playerActionToRestore );
  4775. }
  4776. else
  4777. {
  4778. if ( currentlyUsedItemL )
  4779. {
  4780. inv.UnmountItem( currentlyEquipedItemL, true );
  4781. }
  4782. currentlyEquipedItemL = GetInvalidUniqueId();
  4783. }
  4784.  
  4785. SetPlayerActionToRestore ( PATR_Default );
  4786. }
  4787.  
  4788. event OnUseSelectedItem( optional force : bool )
  4789. {
  4790. var category : name;
  4791. var itemEntity : W3UsableItem;
  4792.  
  4793. if ( isUsableItemBlocked && !force )
  4794. {
  4795. return false;
  4796. }
  4797. if ( IsCastingSign() )
  4798. return false;
  4799.  
  4800. if ( currentlyEquipedItemL != GetInvalidUniqueId() )
  4801. {
  4802. SetBehaviorVariable( 'SelectedItemL', (int)GetUsableItemTypeById( currentlyEquipedItemL ), true );
  4803. if ( force )
  4804. {
  4805. if ( RaiseEvent( 'ItemEndL' ) )
  4806. {
  4807. SetUsableItemLtransitionAllowed ( true );
  4808. return true;
  4809. }
  4810. }
  4811. else
  4812. {
  4813. if ( RaiseEvent( 'ItemUseL' ) )
  4814. {
  4815. SetUsableItemLtransitionAllowed ( true );
  4816. return true;
  4817. }
  4818. }
  4819. }
  4820. else
  4821. {
  4822. category = inv.GetItemCategory( selectedItemId );
  4823. if( category != 'usable' )
  4824. {
  4825. return false;
  4826. }
  4827. SetBehaviorVariable( 'SelectedItemL', (int)GetUsableItemTypeById( selectedItemId ), true );
  4828. if( RaiseEvent( 'ItemUseL' ) )
  4829. {
  4830. currentlyEquipedItemL = selectedItemId;
  4831. SetUsableItemLtransitionAllowed ( false );
  4832. currentlyUsingItem = true;
  4833.  
  4834. return true;
  4835. }
  4836. inv.UnmountItem( selectedItemId, true );
  4837. }
  4838. }
  4839.  
  4840. protected saved var currentlyUsingItem : bool;
  4841.  
  4842. public function ProcessUseSelectedItem( itemEntity : W3UsableItem, optional shouldCallOnUsed : bool )
  4843. {
  4844. currentlyUsedItemL = itemEntity;
  4845. DrainStamina(ESAT_UsableItem);
  4846.  
  4847. if ( shouldCallOnUsed )
  4848. {
  4849. currentlyUsedItemL.OnUsed( thePlayer );
  4850. }
  4851. }
  4852.  
  4853. function GetUsableItemTypeById ( itemId : SItemUniqueId ) : EUsableItemType
  4854. {
  4855. var itemName : name;
  4856.  
  4857. itemName = inv.GetItemName ( itemId );
  4858.  
  4859. return theGame.GetDefinitionsManager().GetUsableItemType ( itemName );
  4860.  
  4861. }
  4862.  
  4863.  
  4864. public function StartWaitForItemSpawnAndProccesTask()
  4865. {
  4866. AddTimer( 'WaitForItemSpawnAndProccesTask', 0.001f, true,,,,true );
  4867. }
  4868.  
  4869.  
  4870. public function KillWaitForItemSpawnAndProccesTask()
  4871. {
  4872. RemoveTimer ( 'WaitForItemSpawnAndProccesTask' );
  4873. }
  4874.  
  4875.  
  4876.  
  4877. public function AllowUseSelectedItem()
  4878. {
  4879. m_useSelectedItemIfSpawned = true;
  4880. }
  4881.  
  4882.  
  4883.  
  4884. timer function WaitForItemSpawnAndProccesTask( timeDelta : float , id : int )
  4885. {
  4886. var itemEntity : W3UsableItem;
  4887. var canTaskBeKilled : bool;
  4888. canTaskBeKilled = false;
  4889.  
  4890. if ( IsCastingSign() )
  4891. {
  4892. return;
  4893. }
  4894.  
  4895.  
  4896. if ( selectedItemId == GetInvalidUniqueId() )
  4897. {
  4898. canTaskBeKilled = true;
  4899. }
  4900.  
  4901. itemEntity = (W3UsableItem)inv.GetItemEntityUnsafe( selectedItemId );
  4902. if ( itemEntity && m_useSelectedItemIfSpawned )
  4903. {
  4904.  
  4905. canTaskBeKilled = true;
  4906. m_useSelectedItemIfSpawned = false;
  4907. ProcessUseSelectedItem( itemEntity, true );
  4908. }
  4909.  
  4910. if ( canTaskBeKilled )
  4911. {
  4912. KillWaitForItemSpawnAndProccesTask();
  4913. }
  4914. }
  4915.  
  4916. event OnBombProjectileReleased()
  4917. {
  4918. ResetRawPlayerHeading();
  4919. UnblockAction(EIAB_ThrowBomb, 'BombThrow');
  4920. UnblockAction(EIAB_Crossbow, 'BombThrow');
  4921.  
  4922. if(GetCurrentStateName() == 'AimThrow')
  4923. PopState();
  4924.  
  4925. FactsAdd("ach_bomb", 1, 4 );
  4926. theGame.GetGamerProfile().CheckLearningTheRopes();
  4927. }
  4928.  
  4929. public function SetIsThrowingItemWithAim(b : bool)
  4930. {
  4931. isThrowingItemWithAim = b;
  4932. }
  4933.  
  4934. public function SetIsThrowingItem( flag : bool ) {isThrowingItem = flag;}
  4935. public function IsThrowingItem() : bool {return isThrowingItem;}
  4936. public function IsThrowingItemWithAim() : bool {return isThrowingItemWithAim;}
  4937. public function SetThrowHold(b : bool) {isThrowHoldPressed = b;}
  4938. public function IsThrowHold() : bool {return isThrowHoldPressed;}
  4939. public function SetIsAimingCrossbow( flag : bool ) {isAimingCrossbow = flag;}
  4940. public function GetIsAimingCrossbow() : bool {return isAimingCrossbow;}
  4941.  
  4942. event OnThrowAnimLeave()
  4943. {
  4944. var throwStage : EThrowStage;
  4945. var thrownEntity : CThrowable;
  4946.  
  4947. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  4948.  
  4949. if(thrownEntity && !thrownEntity.WasThrown())
  4950. {
  4951. throwStage = (int)GetBehaviorVariable( 'throwStage', (int)TS_Stop);
  4952. if(inv.IsItemBomb(selectedItemId))
  4953. {
  4954. BombThrowCleanUp();
  4955. }
  4956. else
  4957. {
  4958. ThrowingAbort();
  4959. }
  4960. }
  4961.  
  4962. thrownEntity = NULL;
  4963. SetIsThrowingItem( false );
  4964. SetIsThrowingItemWithAim( false );
  4965.  
  4966. this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
  4967. UnblockAction(EIAB_ThrowBomb, 'BombThrow');
  4968. UnblockAction(EIAB_Crossbow, 'BombThrow');
  4969. }
  4970.  
  4971.  
  4972. protected function BombThrowStart()
  4973. {
  4974. var slideTargetActor : CActor;
  4975.  
  4976. BlockAction( EIAB_ThrowBomb, 'BombThrow' );
  4977. BlockAction(EIAB_Crossbow, 'BombThrow');
  4978.  
  4979. SetBehaviorVariable( 'throwStage', (int)TS_Start );
  4980. SetBehaviorVariable( 'combatActionType', (int)CAT_ItemThrow );
  4981.  
  4982. if ( slideTarget )
  4983. {
  4984. AddCustomOrientationTarget( OT_Actor, 'BombThrow' );
  4985.  
  4986. slideTargetActor = (CActor)( slideTarget );
  4987.  
  4988.  
  4989.  
  4990.  
  4991.  
  4992. }
  4993. else
  4994. {
  4995. if ( lastAxisInputIsMovement )
  4996. AddCustomOrientationTarget( OT_Actor, 'BombThrow' );
  4997. else
  4998. AddCustomOrientationTarget( OT_Camera, 'BombThrow' );
  4999. }
  5000.  
  5001. UpdateLookAtTarget();
  5002. SetCustomRotation( 'Throw', VecHeading( this.GetLookAtPosition() - GetWorldPosition() ), 0.0f, 0.3f, false );
  5003.  
  5004. SetBehaviorVariable( 'itemType', (int)IT_Petard );
  5005.  
  5006. ProcessCanAttackWhenNotInCombatBomb();
  5007.  
  5008. if ( RaiseForceEvent('CombatAction') )
  5009. OnCombatActionStart();
  5010.  
  5011.  
  5012. theTelemetry.LogWithLabel(TE_FIGHT_HERO_THROWS_BOMB, inv.GetItemName( selectedItemId ));
  5013. }
  5014.  
  5015.  
  5016. event OnThrowAnimStart()
  5017. {
  5018. var itemId : SItemUniqueId;
  5019. var thrownEntity : CThrowable;
  5020.  
  5021. this.radialSlots.Clear();
  5022. GetWitcherPlayer().GetItemEquippedOnSlot(EES_Petard1, itemId );
  5023.  
  5024. if( GetSelectedItemId() == itemId )
  5025. {
  5026. this.radialSlots.PushBack( 'Slot2' );
  5027. }
  5028. else
  5029. {
  5030. this.radialSlots.PushBack( 'Slot1' );
  5031. }
  5032. this.radialSlots.PushBack( 'Slot3' );
  5033. this.radialSlots.PushBack( 'Slot4' );
  5034. this.radialSlots.PushBack( 'Slot5' );
  5035. this.EnableRadialSlotsWithSource( false, this.radialSlots, 'throwBomb' );
  5036.  
  5037. thrownEntity = (CThrowable)inv.GetDeploymentItemEntity( selectedItemId,,,true );
  5038. thrownEntity.Initialize( this, selectedItemId );
  5039. EntityHandleSet( thrownEntityHandle, thrownEntity );
  5040. SetIsThrowingItem( true );
  5041. }
  5042.  
  5043. public function BombThrowAbort()
  5044. {
  5045. BombThrowCleanUp();
  5046. UnblockAction( EIAB_ThrowBomb, 'BombThrow' );
  5047. UnblockAction(EIAB_Crossbow, 'BombThrow');
  5048. }
  5049.  
  5050. private function BombThrowCleanUp()
  5051. {
  5052. var throwStage : EThrowStage;
  5053. var thrownEntity : CThrowable;
  5054. var vehicle : CVehicleComponent;
  5055.  
  5056. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  5057.  
  5058. this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
  5059. throwStage = (int)GetBehaviorVariable( 'throwStage', (int)TS_Stop);
  5060.  
  5061. SetBehaviorVariable( 'throwStage', (int)TS_Stop );
  5062.  
  5063. if( GetCurrentStateName() == 'AimThrow')
  5064. {
  5065. PopState();
  5066. thrownEntity.StopAiming( true );
  5067. }
  5068. else if ( this.IsUsingHorse() )
  5069. {
  5070. vehicle = (CVehicleComponent)(GetUsedVehicle().GetComponentByClassName('CVehicleComponent'));
  5071. vehicle.GetUserCombatManager().OnForceItemActionAbort();
  5072. }
  5073.  
  5074.  
  5075. if(thrownEntity && !thrownEntity.WasThrown())
  5076. {
  5077. thrownEntity.BreakAttachment();
  5078. thrownEntity.Destroy();
  5079. }
  5080.  
  5081. thrownEntity = NULL;
  5082. SetIsThrowingItem( false );
  5083. SetIsThrowingItemWithAim( false );
  5084. RemoveCustomOrientationTarget( 'BombThrow' );
  5085. }
  5086.  
  5087. public function ProcessCanAttackWhenNotInCombatBomb()
  5088. {
  5089. var targets : array< CGameplayEntity >;
  5090. var temp, throwVector, throwFrom, throwTo, throwVectorU : Vector;
  5091. var temp_n : name;
  5092. var throwVecLen : float;
  5093. var component : CComponent;
  5094.  
  5095.  
  5096.  
  5097. if( FactsQuerySum( "BombThrowSpecificTargets" ) > 0 )
  5098. {
  5099.  
  5100.  
  5101.  
  5102.  
  5103.  
  5104. throwFrom = playerAiming.GetThrowStartPosition();
  5105. throwTo = playerAiming.GetThrowPosition();
  5106. throwVector = throwTo - throwFrom;
  5107. throwVecLen = VecDistance( throwFrom, throwTo );
  5108. throwVectorU = throwVector / throwVecLen;
  5109. if( theGame.GetWorld().StaticTraceWithAdditionalInfo( throwFrom, throwTo + throwVectorU, temp, temp, temp_n, component ) && component && component.GetEntity().HasTag( 'BombThrowSpecificTarget' ) )
  5110. {
  5111. SetIsShootingFriendly( false );
  5112. }
  5113. else
  5114. {
  5115. SetIsShootingFriendly( true );
  5116. }
  5117. }
  5118. else if( FactsQuerySum( "BombThrowDisallowSpecificTargets" ) > 0 )
  5119. {
  5120.  
  5121. throwFrom = playerAiming.GetThrowStartPosition();
  5122. throwTo = playerAiming.GetThrowPosition();
  5123. throwVector = throwTo - throwFrom;
  5124. throwVecLen = VecDistance( throwFrom, throwTo );
  5125. throwVectorU = throwVector / throwVecLen;
  5126. if( theGame.GetWorld().StaticTraceWithAdditionalInfo( throwFrom, throwTo + throwVectorU, temp, temp, temp_n, component ) && component && component.GetEntity().HasTag( 'BombThrowDisallowedTarget' ) )
  5127. {
  5128. SetIsShootingFriendly( true );
  5129. }
  5130. else
  5131. {
  5132. SetIsShootingFriendly( false );
  5133. }
  5134. }
  5135. else
  5136. {
  5137. SetIsShootingFriendly( false );
  5138. }
  5139.  
  5140. SetBehaviorVariable( 'isShootingFriendly', (float)( GetIsShootingFriendly() ) );
  5141. }
  5142.  
  5143. public function SetIsShootingFriendly( flag : bool )
  5144. {
  5145. isShootingFriendly = flag;
  5146. }
  5147.  
  5148. public function GetIsShootingFriendly() : bool
  5149. {
  5150. return isShootingFriendly;
  5151. }
  5152.  
  5153.  
  5154. protected function UsableItemStart()
  5155. {
  5156. var thrownEntity : CThrowable;
  5157.  
  5158.  
  5159. thrownEntity = (CThrowable)inv.GetDeploymentItemEntity( selectedItemId,,,true );
  5160. thrownEntity.Initialize( this, selectedItemId );
  5161. EntityHandleSet( thrownEntityHandle, thrownEntity );
  5162. SetBehaviorVariable( 'throwStage', (int)TS_Start );
  5163. SetIsThrowingItem( true );
  5164. SetBehaviorVariable( 'combatActionType', (int)CAT_ItemThrow );
  5165.  
  5166. if ( slideTarget )
  5167. {
  5168. AddCustomOrientationTarget( OT_Actor, 'UsableItems' );
  5169. }
  5170. else
  5171. {
  5172. if ( lastAxisInputIsMovement )
  5173. AddCustomOrientationTarget( OT_Actor, 'UsableItems' );
  5174. else
  5175. AddCustomOrientationTarget( OT_Camera, 'UsableItems' );
  5176. }
  5177.  
  5178. SetBehaviorVariable( 'itemType', (int)(-1) );
  5179.  
  5180. if ( RaiseForceEvent('CombatAction') )
  5181. OnCombatActionStart();
  5182. }
  5183.  
  5184. protected function BombThrowRelease()
  5185. {
  5186. var stateName : name;
  5187.  
  5188. stateName = playerAiming.GetCurrentStateName();
  5189. OnDelayOrientationChangeOff();
  5190.  
  5191. if( GetIsShootingFriendly() || ( FactsQuerySum( "BombThrowSpecificTargets" ) > 0 && stateName != 'Aiming' ) )
  5192. {
  5193. BombThrowAbort();
  5194. }
  5195. else
  5196. {
  5197. SetBehaviorVariable( 'throwStage', (int)TS_End );
  5198.  
  5199. if ( stateName == 'Aiming' )
  5200. {
  5201. SetCustomRotation( 'Throw', VecHeading( this.GetLookAtPosition() - GetWorldPosition() ), 0.0f, 0.2f, false );
  5202. }
  5203. }
  5204. }
  5205.  
  5206. protected function UsableItemRelease()
  5207. {
  5208. OnDelayOrientationChangeOff();
  5209. SetBehaviorVariable( 'throwStage', (int)TS_End );
  5210. RemoveCustomOrientationTarget( 'UsableItems' );
  5211. }
  5212.  
  5213.  
  5214. public function ThrowingAbort()
  5215. {
  5216. var thrownEntity : CThrowable;
  5217.  
  5218. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  5219.  
  5220. SetBehaviorVariable( 'throwStage', (int)TS_Stop );
  5221. RaiseEvent( 'actionStop' );
  5222.  
  5223. if( GetCurrentStateName() == 'AimThrow')
  5224. {
  5225. PopState();
  5226. thrownEntity.StopAiming( true );
  5227. }
  5228.  
  5229.  
  5230. if(thrownEntity && !thrownEntity.WasThrown())
  5231. {
  5232. thrownEntity.BreakAttachment();
  5233. thrownEntity.Destroy();
  5234. }
  5235. this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
  5236. }
  5237.  
  5238. public function CanSetupCombatAction_Throw() : bool
  5239. {
  5240.  
  5241. if(!inv.IsIdValid( selectedItemId ))
  5242. return false;
  5243.  
  5244.  
  5245. if(!inv.IsItemSingletonItem(selectedItemId))
  5246. return false;
  5247.  
  5248.  
  5249. if(!GetBIsInputAllowed())
  5250. return false;
  5251.  
  5252.  
  5253. if(inv.GetItemQuantity(GetSelectedItemId()) <= 0 && !inv.ItemHasTag(selectedItemId, theGame.params.TAG_INFINITE_AMMO))
  5254. return false;
  5255.  
  5256.  
  5257. if(!inputHandler.IsActionAllowed(EIAB_ThrowBomb) && GetCurrentStateName() != 'Swimming')
  5258. return false;
  5259.  
  5260. return true;
  5261. }
  5262.  
  5263. public function GetThrownEntity() : CThrowable
  5264. {
  5265. return (CThrowable)EntityHandleGet( thrownEntityHandle );
  5266. }
  5267.  
  5268.  
  5269. event OnWeaponWait() { rangedWeapon.OnWeaponWait(); }
  5270. event OnWeaponDrawStart() { rangedWeapon.OnWeaponDrawStart(); }
  5271. event OnWeaponReloadStart() { rangedWeapon.OnWeaponReloadStart(); }
  5272. event OnWeaponReloadEnd() { rangedWeapon.OnWeaponReloadEnd(); }
  5273. event OnWeaponAimStart() { rangedWeapon.OnWeaponAimStart(); }
  5274. event OnWeaponShootStart() { rangedWeapon.OnWeaponShootStart(); }
  5275. event OnWeaponShootEnd() { rangedWeapon.OnWeaponShootEnd(); }
  5276. event OnWeaponAimEnd() { rangedWeapon.OnWeaponAimEnd(); }
  5277. event OnWeaponHolsterStart() { rangedWeapon.OnWeaponHolsterStart(); }
  5278. event OnWeaponHolsterEnd() { rangedWeapon.OnWeaponHolsterEnd(); }
  5279. event OnWeaponToNormalTransStart() { rangedWeapon.OnWeaponToNormalTransStart(); }
  5280. event OnWeaponToNormalTransEnd() { rangedWeapon.OnWeaponToNormalTransEnd(); }
  5281.  
  5282. event OnEnableAimingMode( enable : bool )
  5283. {
  5284. if( !crossbowDontPopStateHack )
  5285. {
  5286. if ( enable )
  5287. PushState( 'AimThrow' );
  5288. else if ( GetCurrentStateName() == 'AimThrow' )
  5289. PopState();
  5290. }
  5291. }
  5292.  
  5293. event OnRangedForceHolster( optional forceUpperBodyAnim, instant, dropItem : bool )
  5294. {
  5295. if(rangedWeapon)
  5296. rangedWeapon.OnForceHolster( forceUpperBodyAnim, instant, dropItem );
  5297. }
  5298.  
  5299.  
  5300. public function IsCrossbowHeld() : bool
  5301. {
  5302. if (rangedWeapon)
  5303. return rangedWeapon.GetCurrentStateName() != 'State_WeaponWait';
  5304. return false;
  5305. }
  5306.  
  5307.  
  5308. event OnBlockAllCombatTickets( release : bool )
  5309. {
  5310. if (!release )
  5311. ((CR4PlayerStateCombat)GetState('Combat')).OnBlockAllCombatTickets(false);
  5312. }
  5313. event OnForceTicketUpdate() {}
  5314.  
  5315.  
  5316.  
  5317.  
  5318.  
  5319. event OnProcessActionPost(action : W3DamageAction)
  5320. {
  5321. var npc : CNewNPC;
  5322. var attackAction : W3Action_Attack;
  5323. var lifeLeech : float;
  5324.  
  5325. super.OnProcessActionPost(action);
  5326.  
  5327. attackAction = (W3Action_Attack)action;
  5328.  
  5329. if(attackAction)
  5330. {
  5331. npc = (CNewNPC)action.victim;
  5332.  
  5333. if(npc && npc.IsHuman() )
  5334. {
  5335. PlayBattleCry('BattleCryHumansHit', 0.05f );
  5336. }
  5337. else
  5338. {
  5339. PlayBattleCry('BattleCryMonstersHit', 0.05f );
  5340. }
  5341.  
  5342. if(attackAction.IsActionMelee())
  5343. {
  5344.  
  5345. IncreaseUninterruptedHitsCount();
  5346.  
  5347.  
  5348. if( IsLightAttack( attackAction.GetAttackName() ) )
  5349. {
  5350. GCameraShake(0.1, false, GetWorldPosition(), 10);
  5351. }
  5352.  
  5353.  
  5354. if(npc && inv.GetItemName(attackAction.GetWeaponId()) == 'PC Caretaker Shovel')
  5355. {
  5356.  
  5357. lifeLeech = CalculateAttributeValue(inv.GetItemAttributeValue(attackAction.GetWeaponId() ,'lifesteal'));
  5358. if (npc.UsesVitality())
  5359. lifeLeech *= action.processedDmg.vitalityDamage;
  5360. else if (UsesEssence())
  5361. lifeLeech *= action.processedDmg.essenceDamage;
  5362. else
  5363. lifeLeech = 0;
  5364.  
  5365. if ( lifeLeech > 0 )
  5366. {
  5367. inv.PlayItemEffect( attackAction.GetWeaponId(), 'stab_attack' );
  5368. PlayEffect('drain_energy_caretaker_shovel');
  5369. GainStat(BCS_Vitality, lifeLeech);
  5370. }
  5371. }
  5372. }
  5373. }
  5374. }
  5375.  
  5376. public function SetHitReactTransScale(f : float) {hitReactTransScale = f;}
  5377. public function GetHitReactTransScale() : float
  5378. {
  5379. if ( ( (CNewNPC)slideTarget ).GetIsTranslationScaled() )
  5380. return hitReactTransScale;
  5381. else
  5382. return 1.f;
  5383. }
  5384.  
  5385.  
  5386.  
  5387.  
  5388.  
  5389. public function GetHorseWithInventory() : CNewNPC
  5390. {
  5391. return (CNewNPC)EntityHandleGet( horseWithInventory );
  5392. }
  5393. public function GetHorseCurrentlyMounted() : CNewNPC
  5394. {
  5395. return currentlyMountedHorse;
  5396. }
  5397.  
  5398. public function _SetHorseCurrentlyMounted( horse : CNewNPC )
  5399. {
  5400. currentlyMountedHorse = horse;
  5401. }
  5402.  
  5403. public function WasHorseRecentlySummoned() : bool
  5404. {
  5405. if ( horseSummonTimeStamp + 5.f > theGame.GetEngineTimeAsSeconds() )
  5406. return true;
  5407.  
  5408. return false;
  5409. }
  5410.  
  5411. private const var MOUNT_DISTANCE_CBT : float;
  5412. default MOUNT_DISTANCE_CBT = 3.0;
  5413.  
  5414. private const var MOUNT_ANGLE_CBT : float;
  5415. default MOUNT_ANGLE_CBT = 35.0;
  5416.  
  5417. private const var MOUNT_ANGLE_EXP : float;
  5418. default MOUNT_ANGLE_EXP = 45.0;
  5419.  
  5420. public function IsMountingHorseAllowed( optional alwaysAllowedInExploration : bool ) : bool
  5421. {
  5422. var angle : float;
  5423. var distance : float;
  5424.  
  5425. if( IsInsideHorseInteraction() )
  5426. {
  5427. angle = AngleDistance( thePlayer.rawPlayerHeading, VecHeading( thePlayer.horseInteractionSource.GetWorldPosition() - thePlayer.GetWorldPosition() ) );
  5428.  
  5429. if( thePlayer.IsInCombat() )
  5430. {
  5431. if( AbsF( angle ) < MOUNT_ANGLE_CBT )
  5432. {
  5433. distance = VecDistance( thePlayer.GetWorldPosition(), thePlayer.horseInteractionSource.GetWorldPosition() );
  5434.  
  5435. if( distance < MOUNT_DISTANCE_CBT )
  5436. {
  5437. return true;
  5438. }
  5439. else
  5440. {
  5441. return false;
  5442. }
  5443. }
  5444. else
  5445. {
  5446. return false;
  5447. }
  5448.  
  5449. }
  5450. else
  5451. {
  5452. if( alwaysAllowedInExploration )
  5453. {
  5454. return true;
  5455. }
  5456. else
  5457. {
  5458. if( AbsF( angle ) < MOUNT_ANGLE_EXP )
  5459. {
  5460. return true;
  5461. }
  5462. else
  5463. {
  5464. return false;
  5465. }
  5466. }
  5467. }
  5468. }
  5469. else
  5470. {
  5471. return false;
  5472. }
  5473. }
  5474.  
  5475. public function FollowActor( actor : CActor )
  5476. {
  5477. var l_aiTreeDecorator : CAIPlayerActionDecorator;
  5478. var l_aiTree_onFoot : CAIFollowSideBySideAction;
  5479. var l_aiTree_onHorse : CAIRiderFollowSideBySideAction;
  5480. var l_success : bool = false;
  5481.  
  5482. actor.AddTag( 'playerFollowing' );
  5483.  
  5484. if( thePlayer.IsUsingHorse() )
  5485. {
  5486. l_aiTree_onHorse = new CAIRiderFollowSideBySideAction in this;
  5487. l_aiTree_onHorse.OnCreated();
  5488.  
  5489. l_aiTree_onHorse.params.targetTag = 'playerFollowing';
  5490. }
  5491. else
  5492. {
  5493. l_aiTree_onFoot = new CAIFollowSideBySideAction in this;
  5494. l_aiTree_onFoot.OnCreated();
  5495.  
  5496. l_aiTree_onFoot.params.targetTag = 'playerFollowing';
  5497. }
  5498.  
  5499. l_aiTreeDecorator = new CAIPlayerActionDecorator in this;
  5500. l_aiTreeDecorator.OnCreated();
  5501. l_aiTreeDecorator.interruptOnInput = false;
  5502.  
  5503. if( thePlayer.IsUsingHorse() )
  5504. l_aiTreeDecorator.scriptedAction = l_aiTree_onHorse;
  5505. else
  5506. l_aiTreeDecorator.scriptedAction = l_aiTree_onFoot;
  5507.  
  5508. if( l_aiTreeDecorator )
  5509. l_success = ForceAIBehavior( l_aiTreeDecorator, BTAP_Emergency );
  5510. else if( thePlayer.IsUsingHorse() )
  5511. l_success = ForceAIBehavior( l_aiTree_onHorse, BTAP_Emergency );
  5512. else
  5513. l_success = ForceAIBehavior( l_aiTree_onFoot, BTAP_Emergency );
  5514.  
  5515. if ( l_success )
  5516. {
  5517. GetMovingAgentComponent().SetGameplayRelativeMoveSpeed( 0.0f );
  5518. }
  5519. }
  5520.  
  5521. public function SetCanFollowNpc( val : bool, actor : CActor ) { canFollowNpc = val; actorToFollow = actor; }
  5522. public function CanFollowNpc() : bool { return canFollowNpc; }
  5523. public function GetActorToFollow() : CActor { return actorToFollow; }
  5524.  
  5525.  
  5526.  
  5527.  
  5528.  
  5529.  
  5530.  
  5531. public function SetIsSwimming ( toggle : bool )
  5532. {
  5533. if( isSwimming != toggle )
  5534. {
  5535. thePlayer.substateManager.SetBehaviorParamBool( 'isSwimmingForOverlay', toggle );
  5536. isSwimming = toggle;
  5537. }
  5538. }
  5539.  
  5540.  
  5541.  
  5542.  
  5543.  
  5544.  
  5545.  
  5546. public function RepairItemUsingConsumable(item, consumable : SItemUniqueId) : bool
  5547. {
  5548. var curr, max, repairValue, itemValue, repairBonus, newDurability : float;
  5549.  
  5550.  
  5551. if(!inv.IsIdValid(item) || !inv.IsIdValid(consumable) || !inv.HasItemDurability(item))
  5552. return false;
  5553.  
  5554. curr = inv.GetItemDurability(item);
  5555. max = inv.GetItemMaxDurability(item);
  5556.  
  5557.  
  5558. if(curr > max)
  5559. return false;
  5560.  
  5561.  
  5562. if( (inv.IsItemAnyArmor(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_ARMOR)) ||
  5563. (inv.IsItemSilverSwordUsableByPlayer(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_SILVER)) ||
  5564. (inv.IsItemSteelSwordUsableByPlayer(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_STEEL)) )
  5565. {
  5566.  
  5567. itemValue = CalculateAttributeValue(inv.GetItemAttributeValue(consumable, 'durabilityRepairValue'));
  5568. if(itemValue <= 0)
  5569. {
  5570. LogAssert(false, "CR4Player.RepairItemUsingConsumable: consumable <<" + inv.GetItemName(consumable) + ">> has <=0 durabilityRepairValue!!!");
  5571. return false;
  5572. }
  5573. repairBonus = CalculateAttributeValue(inv.GetItemAttributeValue(consumable, 'durabilityBonusValue'));
  5574.  
  5575.  
  5576. repairValue = max * itemValue /100;
  5577.  
  5578.  
  5579.  
  5580. newDurability = MinF(max, curr + repairValue);
  5581.  
  5582. inv.SetItemDurabilityScript(item, newDurability);
  5583.  
  5584.  
  5585. inv.RemoveItem(consumable);
  5586.  
  5587. return true;
  5588. }
  5589. return false;
  5590. }
  5591.  
  5592.  
  5593.  
  5594.  
  5595.  
  5596.  
  5597.  
  5598.  
  5599.  
  5600.  
  5601. private function CheckDayNightCycle()
  5602. {
  5603. var time : GameTime;
  5604. var isNight : bool;
  5605.  
  5606.  
  5607. isNight = theGame.envMgr.IsNight();
  5608. if(prevDayNightIsNight != isNight)
  5609. {
  5610. if(isNight)
  5611. OnNightStarted();
  5612. else
  5613. OnDayStarted();
  5614.  
  5615. prevDayNightIsNight = isNight;
  5616. }
  5617.  
  5618.  
  5619. if(isNight)
  5620. time = theGame.envMgr.GetGameTimeTillNextDay();
  5621. else
  5622. time = theGame.envMgr.GetGameTimeTillNextNight();
  5623.  
  5624. AddGameTimeTimer('DayNightCycle', time);
  5625. }
  5626.  
  5627. timer function DayNightCycle(dt : GameTime, id : int)
  5628. {
  5629. CheckDayNightCycle();
  5630. }
  5631.  
  5632. event OnNightStarted()
  5633. {
  5634. var pam : W3PlayerAbilityManager;
  5635.  
  5636. if(CanUseSkill(S_Perk_01))
  5637. {
  5638. pam = (W3PlayerAbilityManager)abilityManager;
  5639. pam.SetPerk01Abilities(false, true);
  5640. }
  5641. }
  5642.  
  5643. event OnDayStarted()
  5644. {
  5645. var pam : W3PlayerAbilityManager;
  5646.  
  5647. if(CanUseSkill(S_Perk_01))
  5648. {
  5649. pam = (W3PlayerAbilityManager)abilityManager;
  5650. pam.SetPerk01Abilities(true, false);
  5651. }
  5652. }
  5653.  
  5654.  
  5655.  
  5656.  
  5657.  
  5658. public function ForceUnlockAllInputActions(alsoQuestLocks : bool)
  5659. {
  5660. if ( inputHandler )
  5661. inputHandler.ForceUnlockAllInputActions(alsoQuestLocks);
  5662. }
  5663.  
  5664. public function SetPrevRawLeftJoyRot()
  5665. {
  5666. prevRawLeftJoyRot = rawLeftJoyRot;
  5667. }
  5668.  
  5669. public function GetPrevRawLeftJoyRot() : float
  5670. {
  5671. return prevRawLeftJoyRot;
  5672. }
  5673.  
  5674. public function GetExplorationInputContext() : name
  5675. {
  5676. return explorationInputContext;
  5677. }
  5678.  
  5679. public function GetCombatInputContext() : name
  5680. {
  5681. return combatInputContext;
  5682. }
  5683.  
  5684.  
  5685.  
  5686.  
  5687.  
  5688. public function SetIsOnBoat(b : bool)
  5689. {
  5690. isOnBoat = b;
  5691. }
  5692.  
  5693. public function IsOnBoat() : bool
  5694. {
  5695. return isOnBoat;
  5696. }
  5697.  
  5698. public function IsInShallowWater() : bool
  5699. {
  5700. return isInShallowWater;
  5701. }
  5702.  
  5703. event OnEnterShallowWater()
  5704. {
  5705. if ( isInShallowWater )
  5706. return false;
  5707.  
  5708. isInShallowWater = true;
  5709. BlockAction( EIAB_Dodge,'ShallowWater', false, false, true );
  5710. BlockAction( EIAB_Sprint,'ShallowWater', false, false, true );
  5711. BlockAction( EIAB_Crossbow,'ShallowWater', false, false, true );
  5712. BlockAction( EIAB_Jump,'ShallowWater', false, false, true );
  5713. SetBehaviorVariable( 'shallowWater',1.0);
  5714. }
  5715. event OnExitShallowWater()
  5716. {
  5717. if ( !isInShallowWater )
  5718. return false;
  5719.  
  5720. isInShallowWater = false;
  5721. BlockAllActions('ShallowWater',false);
  5722. SetBehaviorVariable( 'shallowWater',0.0);
  5723. }
  5724.  
  5725. public function TestIsInSettlement() : bool
  5726. {
  5727. return IsInSettlement();
  5728. }
  5729.  
  5730.  
  5731.  
  5732.  
  5733.  
  5734.  
  5735. public function ProcessGlossaryImageOverride( defaultImage : string, uniqueTag : name ) : string
  5736. {
  5737. var size : int;
  5738. var i : int;
  5739.  
  5740. size = glossaryImageOverride.Size();
  5741.  
  5742. if( size == 0 )
  5743. return defaultImage;
  5744.  
  5745. for( i = 0; i < size; i += 1 )
  5746. {
  5747. if( glossaryImageOverride[i].uniqueTag == uniqueTag )
  5748. return glossaryImageOverride[i].imageFileName;
  5749.  
  5750. }
  5751.  
  5752. return defaultImage;
  5753. }
  5754.  
  5755.  
  5756. public function EnableGlossaryImageOverride( uniqueTag : name, imageFileName : string, enable : bool )
  5757. {
  5758. var imageData : SGlossaryImageOverride;
  5759. var size : int;
  5760. var i : int;
  5761.  
  5762. for( i = 0; i < glossaryImageOverride.Size(); i += 1 )
  5763. {
  5764. if( glossaryImageOverride[i].uniqueTag == uniqueTag )
  5765. {
  5766. glossaryImageOverride.Remove(glossaryImageOverride[i]);
  5767. }
  5768. }
  5769.  
  5770. if( enable )
  5771. {
  5772. if( IsNameValid(uniqueTag) && imageFileName != "" )
  5773. {
  5774. glossaryImageOverride.PushBack( SGlossaryImageOverride( uniqueTag, imageFileName ) );
  5775. }
  5776. }
  5777. }
  5778.  
  5779.  
  5780.  
  5781. public function SetWeatherDisplayDisabled( disable : bool )
  5782. {
  5783. disableWeatherDisplay = disable;
  5784. }
  5785.  
  5786. public function GetWeatherDisplayDisabled() : bool
  5787. {
  5788. return disableWeatherDisplay;
  5789. }
  5790.  
  5791.  
  5792.  
  5793.  
  5794.  
  5795. public function SetCurrentMonsterHuntInvestigationArea ( area : W3MonsterHuntInvestigationArea )
  5796. {
  5797. currentMonsterHuntInvestigationArea = area;
  5798. }
  5799.  
  5800.  
  5801.  
  5802.  
  5803.  
  5804.  
  5805. public function RememberCustomHead( headName : name )
  5806. {
  5807. rememberedCustomHead = headName;
  5808. }
  5809.  
  5810. public function GetRememberedCustomHead() : name
  5811. {
  5812. return rememberedCustomHead;
  5813. }
  5814.  
  5815. public function ClearRememberedCustomHead()
  5816. {
  5817. rememberedCustomHead = '';
  5818. }
  5819.  
  5820.  
  5821.  
  5822.  
  5823.  
  5824. public function CreateTutorialInput()
  5825. {
  5826. var prevInputHandler : CPlayerInput;
  5827.  
  5828. prevInputHandler = inputHandler;
  5829. inputHandler = new W3PlayerTutorialInput in this;
  5830. inputHandler.Initialize(false, prevInputHandler);
  5831.  
  5832. if(prevInputHandler)
  5833. delete prevInputHandler;
  5834. }
  5835.  
  5836. public function CreateInput()
  5837. {
  5838. var oldInputHandler : CPlayerInput;
  5839.  
  5840. oldInputHandler = inputHandler;
  5841. inputHandler = new CPlayerInput in this;
  5842. inputHandler.Initialize(false, oldInputHandler);
  5843. }
  5844.  
  5845. timer function TutorialSilverCombat(dt : float, id : int)
  5846. {
  5847. var i : int;
  5848. var actors : array<CActor>;
  5849.  
  5850. if(IsInCombat())
  5851. {
  5852. actors = GetNPCsAndPlayersInRange(20, 1000000, ,FLAG_ExcludePlayer + FLAG_OnlyAliveActors);
  5853. for(i=0; i<actors.Size(); i+=1)
  5854. {
  5855. if(actors[i] && IsRequiredAttitudeBetween(this, actors[i], true) && actors[i].UsesEssence())
  5856. {
  5857. FactsAdd("TutorialShowSilver");
  5858.  
  5859. RemoveTimer('TutorialSilverCombat');
  5860. break;
  5861. }
  5862. }
  5863. }
  5864. }
  5865.  
  5866. private saved var m_bossTag : name;
  5867.  
  5868. public function GetBossTag() : name
  5869. {
  5870. return m_bossTag;
  5871. }
  5872.  
  5873. public function SetBossTag( bossTag : name )
  5874. {
  5875. m_bossTag = bossTag;
  5876. }
  5877.  
  5878. private saved var m_usingCoatOfArms : bool; default m_usingCoatOfArms = false;
  5879.  
  5880. public function IsUsingCoatOfArms() : bool
  5881. {
  5882. return m_usingCoatOfArms;
  5883. }
  5884.  
  5885. public function SetUsingCoatOfArms( using : bool)
  5886. {
  5887. m_usingCoatOfArms = using;
  5888. }
  5889.  
  5890. private saved var m_initialTimeOut : float;
  5891. private saved var m_currentTimeOut : float;
  5892.  
  5893. public function GetInitialTimeOut() : float
  5894. {
  5895. return m_initialTimeOut;
  5896. }
  5897.  
  5898. public function SetInitialTimeOut( timeOut : float )
  5899. {
  5900. m_initialTimeOut = timeOut;
  5901. }
  5902.  
  5903. public function GetCurrentTimeOut() : float
  5904. {
  5905. return m_currentTimeOut;
  5906. }
  5907.  
  5908. public function SetCurrentTimeOut( timeOut : float )
  5909. {
  5910. m_currentTimeOut = timeOut;
  5911. }
  5912.  
  5913.  
  5914.  
  5915.  
  5916.  
  5917.  
  5918. timer function DelayedFinisherInputTimer(dt : float, id : int)
  5919. {
  5920.  
  5921.  
  5922. }
  5923.  
  5924. timer function RemoveFinisherCameraAnimationCheck(dt : float, id : int)
  5925. {
  5926. if ( !isInFinisher && !bLAxisReleased )
  5927. {
  5928. theGame.GetSyncAnimManager().OnRemoveFinisherCameraAnimation();
  5929. RemoveTimer( 'RemoveFinisherCameraAnimationCheck' );
  5930. }
  5931. }
  5932.  
  5933.  
  5934.  
  5935.  
  5936.  
  5937. timer function GameplayFactRemove(dt : float, timerId : int)
  5938. {
  5939. theGame.GameplayFactRemoveFromTimer(timerId);
  5940. }
  5941.  
  5942.  
  5943. timer function GiveStartingItems(dt : float, timerId : int)
  5944. {
  5945. var template : CEntityTemplate;
  5946. var invEntity : CInventoryComponent;
  5947. var entity : CEntity;
  5948. var items : array<SItemUniqueId>;
  5949. var id : SItemUniqueId;
  5950. var i : int;
  5951.  
  5952.  
  5953. if(inv)
  5954. {
  5955. inv.GetAllItems(items);
  5956. if(items.Size() <= 0)
  5957. {
  5958. return;
  5959. }
  5960. }
  5961. else
  5962. {
  5963. return;
  5964. }
  5965.  
  5966.  
  5967. template = (CEntityTemplate)LoadResource("geralt_inventory_release");
  5968. entity = theGame.CreateEntity(template, Vector(0,0,0));
  5969. invEntity = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  5970.  
  5971. invEntity.GetAllItems(items);
  5972. for(i=0; i<items.Size(); i+=1)
  5973. {
  5974. id = invEntity.GiveItemTo(inv, items[i], 0, false, true);
  5975. if ( inv.ItemHasTag(id,'Scabbard') )
  5976. {
  5977. inv.MountItem(id);
  5978. }
  5979. else if(!inv.IsItemFists(id) && inv.GetItemName(id) != 'Cat 1')
  5980. {
  5981. EquipItem(id);
  5982. }
  5983. else if(inv.IsItemSingletonItem(id))
  5984. {
  5985. inv.SingletonItemSetAmmo(id, inv.SingletonItemGetMaxAmmo(id));
  5986. }
  5987. }
  5988.  
  5989. entity.Destroy();
  5990.  
  5991.  
  5992. RemoveTimer('GiveStartingItems');
  5993. }
  5994.  
  5995.  
  5996.  
  5997. timer function Debug_GiveTestingItems(dt : float, optional id : int)
  5998. {
  5999. var template : CEntityTemplate;
  6000. var invTesting : CInventoryComponent;
  6001. var entity : CEntity;
  6002. var items : array<SItemUniqueId>;
  6003. var i : int;
  6004. var slot : EEquipmentSlots;
  6005.  
  6006.  
  6007. if(inv)
  6008. {
  6009. inv.GetAllItems(items);
  6010. if(items.Size() <= 0)
  6011. {
  6012. return;
  6013. }
  6014. }
  6015. else
  6016. {
  6017. return;
  6018. }
  6019.  
  6020. template = (CEntityTemplate)LoadResource("geralt_inventory_internal");
  6021. entity = theGame.CreateEntity(template, Vector(0,0,0));
  6022. invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  6023. invTesting.GiveAllItemsTo(inv, true);
  6024. entity.Destroy();
  6025.  
  6026.  
  6027. RemoveTimer('Debug_GiveTestingItems');
  6028.  
  6029.  
  6030. inv.GetAllItems(items);
  6031.  
  6032. for(i=0; i<items.Size(); i+=1)
  6033. {
  6034. if( inv.IsItemCrossbow(items[i]) || inv.IsItemBomb(items[i]) )
  6035. {
  6036. slot = inv.GetSlotForItemId(items[i]);
  6037. EquipItem(items[i], slot);
  6038.  
  6039. if( (W3PlayerWitcher)this && inv.IsItemCrossbow(items[i]) )
  6040. GetWitcherPlayer().SelectQuickslotItem(slot);
  6041. }
  6042. else if(inv.IsItemBolt(items[i]))
  6043. {
  6044. slot = inv.GetSlotForItemId(items[i]);
  6045. EquipItem(items[i], slot);
  6046. }
  6047.  
  6048. if(inv.IsItemSingletonItem(items[i]))
  6049. {
  6050. inv.SingletonItemSetAmmo(items[i], inv.SingletonItemGetMaxAmmo(items[i]));
  6051. }
  6052. }
  6053. }
  6054.  
  6055.  
  6056. timer function Debug_RemoveTestingItems(dt : float, id : int)
  6057. {
  6058. var template : CEntityTemplate;
  6059. var entity : CEntity;
  6060. var invTesting : CInventoryComponent;
  6061. var ids : array<SItemUniqueId>;
  6062. var i : int;
  6063.  
  6064. template = (CEntityTemplate)LoadResource("geralt_inventory_internal");
  6065. entity = theGame.CreateEntity(template, Vector(0,0,0));
  6066. invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  6067. invTesting.GetAllItems(ids);
  6068.  
  6069. for(i=0; i<ids.Size(); i+=1)
  6070. inv.RemoveItemByName(invTesting.GetItemName(ids[i]), invTesting.GetItemQuantity(ids[i]));
  6071.  
  6072. entity.Destroy();
  6073. RemoveTimer('Debug_RemoveTestingItems');
  6074. }
  6075.  
  6076. timer function Debug_DelayedConsoleCommand(dt : float, id : int)
  6077. {
  6078.  
  6079. inv.AddAnItem('Boots 2 schematic');
  6080. }
  6081.  
  6082. function DBG_SkillSlots()
  6083. {
  6084. ((W3PlayerAbilityManager)abilityManager).DBG_SkillSlots();
  6085. }
  6086.  
  6087.  
  6088.  
  6089.  
  6090.  
  6091. public final function SetPadBacklightColor(r, g, b : int)
  6092. {
  6093. var padBacklightColor : Vector;
  6094.  
  6095. padBacklightColor.X = r / 255;
  6096. padBacklightColor.Y = g / 255;
  6097. padBacklightColor.Z = b / 255;
  6098.  
  6099. SetBacklightColor(padBacklightColor);
  6100. }
  6101.  
  6102. public final function SetPadBacklightColorFromSign(signType : ESignType)
  6103. {
  6104. LogPS4Light("SetPadBacklightColorFromSign... " + signType);
  6105.  
  6106. switch(signType)
  6107. {
  6108. case ST_Yrden: SetPadBacklightColor( 200 , 81 , 255 ); break;
  6109. case ST_Quen: SetPadBacklightColor( 255 , 205 , 68 ); break;
  6110. case ST_Igni: SetPadBacklightColor( 255 , 79 , 10 ); break;
  6111. case ST_Axii: SetPadBacklightColor( 255 , 255 , 255 ); break;
  6112. case ST_Aard: SetPadBacklightColor( 158 , 214 , 255 ); break;
  6113. }
  6114. }
  6115.  
  6116. timer function ResetPadBacklightColorTimer(dt : float, id : int)
  6117. {
  6118. ResetPadBacklightColor();
  6119. }
  6120.  
  6121. public final function ResetPadBacklightColor(optional skipHeldWeapon : bool)
  6122. {
  6123. var weapons : array<SItemUniqueId>;
  6124. var sword : CWitcherSword;
  6125. var healthPercentage : float;
  6126. var tmpBacklight : Vector;
  6127.  
  6128. if(!skipHeldWeapon)
  6129. {
  6130. weapons = inv.GetHeldWeapons();
  6131.  
  6132.  
  6133. if(weapons.Size() > 0)
  6134. {
  6135. sword = (CWitcherSword)inv.GetItemEntityUnsafe(weapons[0]);
  6136. if(sword)
  6137. {
  6138. tmpBacklight.X = sword.padBacklightColor.X / 255.0f;
  6139. tmpBacklight.Y = sword.padBacklightColor.Y / 255.0f;
  6140. tmpBacklight.Z = sword.padBacklightColor.Z / 255.0f;
  6141. tmpBacklight.W = 1.0f;
  6142. SetBacklightColor( tmpBacklight );
  6143. LogPS4Light("Setting light from sword template: " + NoTrailZeros(sword.padBacklightColor.X) + ", " + NoTrailZeros(sword.padBacklightColor.Y) + ", " + NoTrailZeros(sword.padBacklightColor.Z) );
  6144. return;
  6145. }
  6146. }
  6147. }
  6148.  
  6149. healthPercentage = GetStatPercents( BCS_Vitality );
  6150. SetBacklightFromHealth( healthPercentage );
  6151. LogPS4Light("Setting light from health, " + NoTrailZeros(RoundMath(healthPercentage*100)) + "%");
  6152. }
  6153.  
  6154.  
  6155.  
  6156. event OnOpenningDoor()
  6157. {
  6158. if( !thePlayer.IsUsingHorse() )
  6159. RaiseEvent('OpenDoor');
  6160. }
  6161.  
  6162. public final function SetLoopingCameraShakeAnimName( n : name )
  6163. {
  6164. loopingCameraShakeAnimName = n;
  6165. }
  6166.  
  6167. public var loopingCameraShakeAnimName : name;
  6168. timer function RemoveQuestCameraShakeTimer( dt : float , id : int)
  6169. {
  6170. RemoveQuestCameraShake( loopingCameraShakeAnimName );
  6171. }
  6172.  
  6173. public function RemoveQuestCameraShake( animName : name )
  6174. {
  6175. var camera : CCustomCamera = theGame.GetGameCamera();
  6176. var animation : SCameraAnimationDefinition;
  6177.  
  6178. camera.StopAnimation( animName );
  6179. }
  6180.  
  6181. public function GetCameraPadding() : float
  6182. {
  6183. if( theGame.IsFocusModeActive() )
  6184. {
  6185. return 0.25;
  6186. }
  6187. else
  6188. {
  6189. return 0.02f;
  6190. }
  6191. }
  6192.  
  6193. public function IsPerformingPhaseChangeAnimation() : bool { return isPerformingPhaseChangeAnimation; }
  6194. public function SetIsPerformingPhaseChangeAnimation( val : bool ) { isPerformingPhaseChangeAnimation = val; }
  6195.  
  6196. private function DealCounterDamageToOlgierd()
  6197. {
  6198. var damage : W3DamageAction;
  6199.  
  6200. damage = new W3DamageAction in this;
  6201.  
  6202. damage.Initialize( thePlayer.GetTarget(), thePlayer.GetTarget(), NULL, this, EHRT_None, CPS_Undefined, false, false, false, true );
  6203. damage.AddDamage( theGame.params.DAMAGE_NAME_DIRECT, thePlayer.GetTarget().GetStatMax( BCS_Vitality ) * 3 / 100 );
  6204. theGame.damageMgr.ProcessAction( damage );
  6205.  
  6206. delete damage;
  6207. }
  6208.  
  6209. timer function PlayDelayedCounterDamageEffect( dt : float, id : int )
  6210. {
  6211. thePlayer.GetTarget().PlayEffect( 'olgierd_energy_blast' );
  6212. }
  6213.  
  6214.  
  6215. public function SetTestAdjustRequestedMovementDirection( val : bool )
  6216. {
  6217. testAdjustRequestedMovementDirection = val;
  6218. }
  6219.  
  6220. event OnVisualDebug( frame : CScriptedRenderFrame, flag : EShowFlags )
  6221. {
  6222. var boneFollow : int;
  6223. var bonePosition : Vector;
  6224. var yrdenEntity : W3YrdenEntity;
  6225.  
  6226. substateManager.OnVisualDebug( frame, flag );
  6227.  
  6228. boneFollow = thePlayer.GetBoneIndex( 'Reference' );
  6229. bonePosition = MatrixGetTranslation( thePlayer.GetBoneWorldMatrixByIndex( boneFollow ) );
  6230. frame.DrawText( "R", bonePosition, Color( 50, 200, 70 ) );
  6231.  
  6232.  
  6233. boneFollow = thePlayer.GetBoneIndex( 'Trajectory' );
  6234. bonePosition = MatrixGetTranslation( thePlayer.GetBoneWorldMatrixByIndex( boneFollow ) );
  6235. frame.DrawSphere( bonePosition, 0.1f, Color( 200, 50, 70 ) );
  6236. frame.DrawText( "T", bonePosition, Color( 200, 50, 70 ) );
  6237.  
  6238.  
  6239.  
  6240.  
  6241. yrdenEntity = (W3YrdenEntity)GetWitcherPlayer().GetSignEntity(ST_Yrden);
  6242. yrdenEntity.OnVisualDebug(frame, flag, false);
  6243.  
  6244. return true;
  6245. }
  6246.  
  6247. timer function PotDrinkTimer(dt : float, id : int)
  6248. {
  6249. inputHandler.PotDrinkTimer(false);
  6250. }
  6251.  
  6252. public function SetIsHorseRacing( val : bool )
  6253. {
  6254. isHorseRacing = val;
  6255. }
  6256.  
  6257. public function GetIsHorseRacing() : bool
  6258. {
  6259. return isHorseRacing;
  6260. }
  6261.  
  6262. public function SetHorseCombatSlowMo( val : bool )
  6263. {
  6264. horseCombatSlowMo = val;
  6265. }
  6266.  
  6267. public function GetHorseCombatSlowMo() : bool
  6268. {
  6269. return horseCombatSlowMo;
  6270. }
  6271.  
  6272. public function SetItemsPerLevelGiven( id : int )
  6273. {
  6274. itemsPerLevelGiven[id] = true;
  6275. }
  6276.  
  6277. private function AddItemPerLevelList()
  6278. {
  6279. var i : int;
  6280.  
  6281. itemsPerLevel.Clear();
  6282. itemsPerLevel.PushBack('O');
  6283. itemsPerLevel.PushBack('No Mans Land sword 2');
  6284. itemsPerLevel.PushBack('No Mans Land sword 3');
  6285. itemsPerLevel.PushBack('Silver sword 2');
  6286. itemsPerLevel.PushBack('Boots 01');
  6287. itemsPerLevel.PushBack('Novigraadan sword 2');
  6288. itemsPerLevel.PushBack('Light armor 01');
  6289. itemsPerLevel.PushBack('Heavy boots 01');
  6290. itemsPerLevel.PushBack('Nilfgaardian sword 3');
  6291. itemsPerLevel.PushBack('Silver sword 3');
  6292. itemsPerLevel.PushBack('Heavy gloves 01');
  6293. itemsPerLevel.PushBack('Skellige sword 2');
  6294. itemsPerLevel.PushBack('Heavy pants 01');
  6295. itemsPerLevel.PushBack('Silver sword 4');
  6296. itemsPerLevel.PushBack('No Mans Land sword 4');
  6297. itemsPerLevel.PushBack('Heavy armor 01');
  6298. itemsPerLevel.PushBack('Heavy boots 02');
  6299. itemsPerLevel.PushBack('Skellige sword 3');
  6300. itemsPerLevel.PushBack('Silver sword 5');
  6301. itemsPerLevel.PushBack('Heavy pants 02');
  6302. itemsPerLevel.PushBack('Heavy gloves 02');
  6303. itemsPerLevel.PushBack('Heavy gloves 02');
  6304. itemsPerLevel.PushBack('Heavy armor 02');
  6305. itemsPerLevel.PushBack('Scoiatael sword 1');
  6306.  
  6307. if ( itemsPerLevelGiven.Size() < 49 )
  6308. {
  6309. itemsPerLevelGiven.Clear();
  6310. for (i = 0; i < itemsPerLevel.Size(); i += 1) { itemsPerLevelGiven.PushBack( false ); }
  6311. }
  6312. }
  6313.  
  6314.  
  6315. public function DealDamageToBoat( dmg : float, index : int, optional globalHitPos : Vector )
  6316. {
  6317. var boat : CBoatDestructionComponent;
  6318.  
  6319. if(usedVehicle)
  6320. {
  6321. boat = (CBoatDestructionComponent) usedVehicle.GetComponentByClassName( 'CBoatDestructionComponent' );
  6322. if( boat )
  6323. {
  6324. boat.DealDamage( dmg, index, globalHitPos );
  6325. }
  6326. }
  6327. }
  6328.  
  6329.  
  6330.  
  6331.  
  6332.  
  6333. public function OnStartTeleportingPlayerToPlayableArea()
  6334. {
  6335. var FADEOUT_INTERVAL : float = 0.5;
  6336.  
  6337.  
  6338. if ( thePlayer.IsUsingHorse() )
  6339. {
  6340. if ( thePlayer.GetUsedHorseComponent().OnCheckHorseJump() )
  6341. {
  6342. thePlayer.GetUsedHorseComponent().SetCanTakeDamageFromFalling( false );
  6343. }
  6344. }
  6345.  
  6346. if ( thePlayer.IsActionAllowed( EIAB_FastTravel ) )
  6347. {
  6348. OnOpenMapToLetPlayerGoBackToPlayableArea();
  6349. }
  6350. else
  6351. {
  6352. theGame.FadeOutAsync( FADEOUT_INTERVAL );
  6353. thePlayer.AddTimer( 'BorderTeleportFadeOutTimer', FADEOUT_INTERVAL, false );
  6354. }
  6355. }
  6356.  
  6357. timer function BorderTeleportFadeOutTimer( dt : float, id : int )
  6358. {
  6359. OnTeleportPlayerToPlayableArea( false );
  6360. }
  6361.  
  6362. public function OnOpenMapToLetPlayerGoBackToPlayableArea()
  6363. {
  6364. var initData : W3MapInitData;
  6365.  
  6366. initData = new W3MapInitData in this;
  6367. initData.SetTriggeredExitEntity( true );
  6368. initData.ignoreSaveSystem = true;
  6369. initData.setDefaultState('FastTravel');
  6370. theGame.RequestMenuWithBackground( 'MapMenu', 'CommonMenu', initData );
  6371. }
  6372.  
  6373. public function OnTeleportPlayerToPlayableArea( afterClosingMap : bool )
  6374. {
  6375. var BLACKSCREEN_INTERVAL : float = 0.1;
  6376. var manager : CCommonMapManager = theGame.GetCommonMapManager();
  6377.  
  6378. thePlayer.TeleportWithRotation( manager.GetBorderTeleportPosition(), manager.GetBorderTeleportRotation() );
  6379. thePlayer.AddTimer( 'BorderTeleportFadeInTimer', BLACKSCREEN_INTERVAL, false );
  6380.  
  6381. theGame.FadeOutAsync( 0 );
  6382. theGame.SetFadeLock('PlayerTeleportation');
  6383. }
  6384.  
  6385. timer function BorderTeleportFadeInTimer( dt : float, id : int )
  6386. {
  6387. theGame.ResetFadeLock('PlayerTeleportation');
  6388. theGame.FadeOutAsync( 0 );
  6389. theGame.FadeInAsync( 2.0f );
  6390. }
  6391.  
  6392. public final function SetLastInstantKillTime(g : GameTime)
  6393. {
  6394. lastInstantKillTime = g;
  6395. }
  6396.  
  6397.  
  6398.  
  6399.  
  6400.  
  6401. timer function TestTimer(dt : float, id : int )
  6402. {
  6403. LogChannel('asdf', "asdf");
  6404. theGame.FadeOutAsync( 5 );
  6405. }
  6406.  
  6407. public final function Debug_ReleaseCriticalStateSaveLocks()
  6408. {
  6409. effectManager.Debug_ReleaseCriticalStateSaveLocks();
  6410. }
  6411.  
  6412. timer function Debug_SpamSpeed(dt : float, id : int)
  6413. {
  6414. if(currentlyMountedHorse)
  6415. {
  6416. LogSpeed("curr player's horse speed: " + NoTrailZeros(currentlyMountedHorse.GetMovingAgentComponent().GetSpeed())) ;
  6417. }
  6418. else
  6419. {
  6420. LogSpeed("curr player speed: " + NoTrailZeros(GetMovingAgentComponent().GetSpeed())) ;
  6421. }
  6422. }
  6423.  
  6424. timer function RemoveInstantKillSloMo(dt : float, id : int)
  6425. {
  6426. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_InstantKill) );
  6427. }
  6428.  
  6429. timer function RemoveForceFinisher(dt : float, id : int)
  6430. {
  6431. forceFinisher = false;
  6432. }
  6433.  
  6434. public final function Debug_ClearAllActionLocks(optional action : EInputActionBlock, optional all : bool)
  6435. {
  6436. inputHandler.Debug_ClearAllActionLocks(action, all);
  6437. }
  6438.  
  6439. function OnFocusedCameraBlendBegin() {}
  6440. function OnFocusedCameraBlendUpdate( progress : float ) {}
  6441. function OnFocusedCameraBlendEnd() {}
  6442.  
  6443. public function GetEtherealCount() : int { return etherealCount; }
  6444. public function IncrementEtherealCount()
  6445. {
  6446. etherealCount += 1;
  6447. if( etherealCount == 6 )
  6448. ResetEtherealCount();
  6449. }
  6450. public function ResetEtherealCount() { etherealCount = 0; }
  6451.  
  6452. public function SetInsideDiveAttackArea( val : bool ) { insideDiveAttackArea = val; }
  6453. public function IsInsideDiveAttackArea() : bool { return insideDiveAttackArea; }
  6454. public function SetDiveAreaNumber( val : int ) { diveAreaNumber = val; }
  6455. public function GetDiveAreaNumber() : int { return diveAreaNumber; }
  6456.  
  6457.  
  6458.  
  6459. public function InitPhantomWeaponMgr()
  6460. {
  6461. if( !phantomWeaponMgr )
  6462. {
  6463. phantomWeaponMgr = new CPhantomWeaponManager in this;
  6464. phantomWeaponMgr.Init( this.GetInventory() );
  6465. }
  6466. }
  6467.  
  6468. public function DestroyPhantomWeaponMgr()
  6469. {
  6470. if( phantomWeaponMgr )
  6471. {
  6472. delete phantomWeaponMgr;
  6473. }
  6474. }
  6475.  
  6476. public function GetPhantomWeaponMgr() : CPhantomWeaponManager
  6477. {
  6478. if( phantomWeaponMgr )
  6479. {
  6480. return phantomWeaponMgr;
  6481. }
  6482. else
  6483. {
  6484. return NULL;
  6485. }
  6486. }
  6487.  
  6488. public timer function DischargeWeaponAfter( td : float, id : int )
  6489. {
  6490. GetPhantomWeaponMgr().DischargeWeapon();
  6491. }
  6492.  
  6493.  
  6494.  
  6495.  
  6496. private var forcedFinisherVictim : CActor;
  6497.  
  6498. timer function PerformFinisher( time : float , id : int )
  6499. {
  6500. var combatTarget : CActor;
  6501. var i : int;
  6502.  
  6503. combatTarget = thePlayer.GetTarget();
  6504.  
  6505. if( combatTarget )
  6506. {
  6507. combatTarget.Kill( 'AutoFinisher', false, thePlayer );
  6508. thePlayer.SetFinisherVictim( combatTarget );
  6509. forcedFinisherVictim = combatTarget;
  6510. thePlayer.CleanCombatActionBuffer();
  6511. thePlayer.OnBlockAllCombatTickets( true );
  6512. moveTargets = thePlayer.GetMoveTargets();
  6513.  
  6514. for( i = 0; i < moveTargets.Size(); i += 1 )
  6515. {
  6516. if( combatTarget != moveTargets[i] )
  6517. moveTargets[i].SignalGameplayEvent( 'InterruptChargeAttack' );
  6518. }
  6519.  
  6520. if( theGame.GetInGameConfigWrapper().GetVarValue( 'Gameplay', 'AutomaticFinishersEnabled' ) == "true" )
  6521. combatTarget.AddAbility( 'ForceFinisher', false );
  6522.  
  6523. if( combatTarget.HasTag( 'ForceFinisher' ) )
  6524. combatTarget.AddAbility( 'ForceFinisher', false );
  6525.  
  6526. combatTarget.SignalGameplayEvent( 'ForceFinisher' );
  6527.  
  6528. thePlayer.FindMoveTarget();
  6529.  
  6530. thePlayer.AddTimer( 'SignalFinisher', 0.2, false );
  6531. }
  6532. }
  6533.  
  6534. timer function SignalFinisher( time : float , id : int )
  6535. {
  6536. forcedFinisherVictim.SignalGameplayEvent( 'Finisher' );
  6537. forcedFinisherVictim = NULL;
  6538. }
  6539. }
  6540.  
  6541. exec function ttt()
  6542. {
  6543. thePlayer.AddTimer( 'TestTimer', 5, false );
  6544. }
  6545. if(CanParryAttack() && FistFightCheck( parryInfo.target, parryInfo.attacker, fistFightParry ) )
  6546. {
  6547. parryHeading = GetParryHeading( parryInfo, parryDir ) ;
  6548.  
  6549. SetBehaviorVariable( 'parryDirection', (float)( (int)( parryDir ) ) );
  6550. SetBehaviorVariable( 'parryDirectionOverlay', (float)( (int)( parryDir ) ) );
  6551. SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
  6552.  
  6553. if ( IsInCombatActionFriendly() )
  6554. RaiseEvent('CombatActionFriendlyEnd');
  6555.  
  6556. if ( HasStaminaToParry(parryInfo.attackActionName) )
  6557. {
  6558. this.SetBehaviorVariable( 'combatActionType', (int)CAT_Parry );
  6559.  
  6560. if ( parryInfo.targetToAttackerDist > 3.f && !bLAxisReleased && !thePlayer.IsCiri() )
  6561. {
  6562. if ( !RaiseForceEvent( 'PerformParryOverlay' ) )
  6563. return false;
  6564. else
  6565. {
  6566. ClearCustomOrientationInfoStack();
  6567. IncDefendCounter();
  6568. }
  6569. }
  6570. else
  6571. {
  6572. counter = GetDefendCounter();
  6573. onHitCounter = parryInfo.attacker.GetAttributeValue( 'break_through_parry_on_hit_counter' );
  6574. if ( onHitCounter.valueBase > 0 && counter == onHitCounter.valueBase )
  6575. {
  6576. AddEffectDefault( EET_Stagger, parryInfo.attacker, "Break through parry" );
  6577. }
  6578. else if ( RaiseForceEvent( 'PerformParry' ) )
  6579. {
  6580. OnCombatActionStart();
  6581. ClearCustomOrientationInfoStack();
  6582. SetSlideTarget( parryInfo.attacker );
  6583. SetCustomRotation( 'Parry', parryHeading, 1080.f, 0.1f, false );
  6584. IncDefendCounter();
  6585. }
  6586. else
  6587. return false;
  6588. }
  6589. }
  6590. else
  6591. {
  6592. AddEffectDefault(EET_Stagger, parryInfo.attacker, "Parry");
  6593. return true;
  6594. }
  6595.  
  6596. if ( parryInfo.attacker.IsWeaponHeld( 'fist' ) && !parryInfo.target.IsWeaponHeld( 'fist' ) )
  6597. {
  6598. parryInfo.attacker.ReactToReflectedAttack(parryInfo.target);
  6599. }
  6600. else
  6601. {
  6602. if ( this.IsInFistFightMiniGame() && fistFightParry )
  6603. {
  6604. if ( IsNameValid(xmlStaminaDamageName) )
  6605. {
  6606. xmlStaminaDamage = CalculateAttributeValue(parryInfo.attacker.GetAttributeValue( xmlStaminaDamageName ));
  6607. DrainStamina(ESAT_FixedValue, xmlStaminaDamage);
  6608. }
  6609. }
  6610. else
  6611. {
  6612. DrainStamina(ESAT_Parry, 0, 0, '', 0, mult);
  6613. }
  6614. if(IsLightAttack(parryInfo.attackActionName))
  6615. parryInfo.target.PlayEffectOnHeldWeapon('light_block');
  6616. else
  6617. parryInfo.target.PlayEffectOnHeldWeapon('heavy_block');
  6618. }
  6619. return true;
  6620. }
  6621.  
  6622. return false;
  6623. }
  6624.  
  6625. protected function GetParryHeading( parryInfo : SParryInfo, out parryDir : EPlayerParryDirection ) : float
  6626. {
  6627. var targetToAttackerHeading : float;
  6628. var currToTargetAttackerAngleDiff : float;
  6629.  
  6630. targetToAttackerHeading = VecHeading( parryInfo.attacker.GetWorldPosition() - parryInfo.target.GetWorldPosition() );
  6631. currToTargetAttackerAngleDiff = AngleDistance( VecHeading( parryInfo.target.GetHeadingVector() ), targetToAttackerHeading );
  6632.  
  6633. if ( !parryInfo.target.IsWeaponHeld( 'fist' ) )
  6634. {
  6635. if( currToTargetAttackerAngleDiff > -45 && currToTargetAttackerAngleDiff < 45 )
  6636. {
  6637. parryDir = PPD_Forward;
  6638. return targetToAttackerHeading;
  6639. }
  6640. else if( currToTargetAttackerAngleDiff >= 45 && currToTargetAttackerAngleDiff < 135 )
  6641. {
  6642. parryDir = PPD_Right;
  6643.  
  6644. return targetToAttackerHeading + 90;
  6645. }
  6646. else if( currToTargetAttackerAngleDiff <= -45 && currToTargetAttackerAngleDiff > -135 )
  6647. {
  6648. parryDir = PPD_Left;
  6649.  
  6650. return targetToAttackerHeading - 90;
  6651. }
  6652. else
  6653. {
  6654. parryDir = PPD_Back;
  6655.  
  6656. return targetToAttackerHeading + 180;
  6657. }
  6658. }
  6659. else
  6660. {
  6661. if( currToTargetAttackerAngleDiff > -45 && currToTargetAttackerAngleDiff < 45 )
  6662. {
  6663. parryDir = PPD_Forward;
  6664. return targetToAttackerHeading;
  6665. }
  6666. else if( currToTargetAttackerAngleDiff >= 45 && currToTargetAttackerAngleDiff < 180 )
  6667. {
  6668. parryDir = PPD_Right;
  6669. return targetToAttackerHeading + 90;
  6670. }
  6671. else if( currToTargetAttackerAngleDiff <= -45 && currToTargetAttackerAngleDiff >= -180 )
  6672. {
  6673. parryDir = PPD_Left;
  6674. return targetToAttackerHeading - 90;
  6675. }
  6676. else
  6677. {
  6678. parryDir = PPD_Back;
  6679. return targetToAttackerHeading + 180;
  6680. }
  6681. }
  6682. }
  6683.  
  6684. function ProcessLockTarget( optional newLockTarget : CActor, optional checkLeftStickHeading : bool ) : bool
  6685. {
  6686. var attackerNearestPoint : Vector;
  6687. var playerNearestPoint : Vector;
  6688. var incomingAttacker : CActor;
  6689. var tempLockTarget : CActor;
  6690. var target : CActor;
  6691. var useIncomingAttacker : bool;
  6692.  
  6693. if( newLockTarget.HasTag( 'NoHardLock' ) )
  6694. return false;
  6695.  
  6696. if ( newLockTarget )
  6697. tempLockTarget = newLockTarget;
  6698. else
  6699. {
  6700. incomingAttacker = GetClosestIncomingAttacker();
  6701. if ( incomingAttacker && incomingAttacker.IsAlive() && IsUsingVehicle() )
  6702. {
  6703. tempLockTarget = incomingAttacker;
  6704. useIncomingAttacker = false;
  6705. }
  6706.  
  6707. if ( !useIncomingAttacker )
  6708. {
  6709. target = GetTarget();
  6710. if( target.HasTag('ForceHardLock'))
  6711. {
  6712. return true;
  6713. }
  6714. else if ( target && target.IsAlive() && target.GetGameplayVisibility() && IsEnemyVisible( target ) && IsThreat( target ) && CanBeTargetedIfSwimming( target ) )
  6715. tempLockTarget = FindTarget();
  6716. else
  6717. {
  6718. tempLockTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, 0.f );
  6719. }
  6720. }
  6721. }
  6722.  
  6723. if( tempLockTarget.HasTag( 'NoHardLock' ) )
  6724. return false;
  6725.  
  6726. if ( tempLockTarget )
  6727. {
  6728. if ( IsCombatMusicEnabled() || hostileEnemies.Size() > 0 )
  6729. {
  6730. if ( !IsThreat( tempLockTarget ) )
  6731. tempLockTarget = NULL;
  6732. }
  6733. }
  6734.  
  6735. SetTarget( tempLockTarget, true );
  6736. SetMoveTargetChangeAllowed( true );
  6737. SetMoveTarget( tempLockTarget );
  6738. SetMoveTargetChangeAllowed( false );
  6739. SetSlideTarget( tempLockTarget );
  6740.  
  6741. if ( tempLockTarget )
  6742. {
  6743. if ( this.IsActorLockedToTarget() )
  6744. EnableHardLockIcon( true );
  6745.  
  6746. return true;
  6747. }
  6748. else
  6749. return false;
  6750. }
  6751.  
  6752.  
  6753.  
  6754.  
  6755.  
  6756. event OnTaskSyncAnim( npc : CNewNPC, animNameLeft : name ) {}
  6757.  
  6758.  
  6759. public function IsDoingSpecialAttack(heavy : bool) : bool
  6760. {
  6761. var pat : EPlayerAttackType;
  6762.  
  6763. if(IsInCombatAction() && ( (int)GetBehaviorVariable('combatActionType')) == CAT_SpecialAttack)
  6764. {
  6765. pat = (int)GetBehaviorVariable('playerAttackType');
  6766.  
  6767. if(heavy && pat == PAT_Heavy)
  6768. {
  6769. return true;
  6770. }
  6771. else if(!heavy && pat == PAT_Light)
  6772. {
  6773. return true;
  6774. }
  6775. }
  6776.  
  6777. return false;
  6778. }
  6779.  
  6780. public function SetIsCurrentlyDodging(enable : bool, optional isRolling : bool)
  6781. {
  6782. super.SetIsCurrentlyDodging(enable, isRolling);
  6783.  
  6784. if ( isRolling )
  6785. {
  6786. SetCanPlayHitAnim( false );
  6787. this.AddBuffImmunity( EET_KnockdownTypeApplicator, 'Roll', false );
  6788. this.AddBuffImmunity( EET_Knockdown, 'Roll', false );
  6789. this.AddBuffImmunity( EET_HeavyKnockdown, 'Roll', false );
  6790. this.AddBuffImmunity( EET_Stagger, 'Roll', false );
  6791. }
  6792. else
  6793. {
  6794. SetCanPlayHitAnim( true );
  6795. this.RemoveBuffImmunity( EET_KnockdownTypeApplicator, 'Roll' );
  6796. this.RemoveBuffImmunity( EET_Knockdown, 'Roll' );
  6797. this.RemoveBuffImmunity( EET_HeavyKnockdown, 'Roll' );
  6798. this.RemoveBuffImmunity( EET_Stagger, 'Roll' );
  6799. }
  6800. }
  6801.  
  6802. public function EnableHardLock( flag : bool )
  6803. {
  6804. super.EnableHardLock(flag);
  6805.  
  6806. if(flag && ShouldProcessTutorial('TutorialTargettingWaiting'))
  6807. {
  6808. FactsAdd("tut_hardlocked");
  6809. }
  6810. }
  6811.  
  6812. protected function TestParryAndCounter(data : CPreAttackEventData, weaponId : SItemUniqueId, out parried : bool, out countered : bool) : array<CActor>
  6813. {
  6814. var ret : array<CActor>;
  6815.  
  6816.  
  6817. if(FactsQuerySum('player_is_the_boss') > 0)
  6818. {
  6819.  
  6820.  
  6821. SetDebugAttackRange(data.rangeName);
  6822. RemoveTimer('PostAttackDebugRangeClear');
  6823.  
  6824. return ret;
  6825. }
  6826.  
  6827. ret = super.TestParryAndCounter(data, weaponId, parried, countered);
  6828.  
  6829.  
  6830. if(parried)
  6831. theGame.GetGamerProfile().ResetStat(ES_CounterattackChain);
  6832.  
  6833. return ret;
  6834. }
  6835.  
  6836. public function SetSpecialAttackTimeRatio(f : float)
  6837. {
  6838. LogSpecialHeavy(f);
  6839. specialAttackTimeRatio = f;
  6840. }
  6841.  
  6842. public function GetSpecialAttackTimeRatio() : float
  6843. {
  6844. return specialAttackTimeRatio;
  6845. }
  6846.  
  6847.  
  6848. public function OnSpecialAttackHeavyActionProcess()
  6849. {
  6850.  
  6851. SetSpecialAttackTimeRatio(0.f);
  6852. }
  6853.  
  6854. protected function DoAttack(animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float)
  6855. {
  6856. var shakeStr : float;
  6857. var weapon : EPlayerWeapon;
  6858. var targetActor : CActor;
  6859.  
  6860.  
  6861. if ( animData.attackName == 'attack_heavy_special' )
  6862. {
  6863. if( specialAttackTimeRatio != 1 )
  6864. shakeStr = (specialAttackTimeRatio / 3.333) + 0.2;
  6865. else
  6866. shakeStr = 0.5;
  6867.  
  6868. GCameraShake( shakeStr, false, GetWorldPosition(), 10);
  6869. }
  6870. else if ( IsHeavyAttack(attackActionName) )
  6871. {
  6872. if(parriedBy.Size() > 0)
  6873. shakeStr = 0.2;
  6874. else
  6875. shakeStr = 0.1;
  6876.  
  6877. GCameraShake(shakeStr, false, GetWorldPosition(), 10);
  6878. }
  6879.  
  6880. targetActor = (CActor)slideTarget;
  6881. if ( targetActor && hitTargets.Contains(targetActor) )
  6882. {
  6883. weapon = this.GetMostConvenientMeleeWeapon(targetActor,true);
  6884. if ( this.GetCurrentMeleeWeaponType() != PW_Fists && weapon != this.GetCurrentMeleeWeaponType() )
  6885. {
  6886. if ( weapon == PW_Steel )
  6887. {
  6888. thePlayer.OnEquipMeleeWeapon(PW_Steel,true);
  6889. }
  6890. else if ( weapon == PW_Silver )
  6891. {
  6892. thePlayer.OnEquipMeleeWeapon(PW_Silver,true);
  6893. }
  6894.  
  6895. }
  6896. }
  6897.  
  6898. super.DoAttack(animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime);
  6899. }
  6900.  
  6901.  
  6902.  
  6903. private var confirmCombatStanceTimeStamp : float;
  6904. private var isConfirmingCombatStance : bool;
  6905. final function SetPlayerCombatStance(stance : EPlayerCombatStance, optional force : bool )
  6906. {
  6907. var stanceInt : int;
  6908.  
  6909. if ( !CanChangeCombatStance( stance, force ) )
  6910. return;
  6911.  
  6912. combatStance = stance;
  6913. stanceInt = (int)stance;
  6914.  
  6915. SetBehaviorVariable( 'playerCombatStance' , (float)stanceInt);
  6916. SetBehaviorVariable( 'playerCombatStanceForOverlay' , (float)stanceInt);
  6917. if ( force )
  6918. SetBehaviorVariable( 'forceCombatStance' , 1.f);
  6919. else
  6920. SetBehaviorVariable( 'forceCombatStance' , 0.f);
  6921.  
  6922. if ( stance == PCS_AlertNear )
  6923. this.SetBehaviorVariable('isInCombatForOverlay',1.f);
  6924. else
  6925. this.SetBehaviorVariable('isInCombatForOverlay',0.f);
  6926. }
  6927.  
  6928. private function CanChangeCombatStance( stance : EPlayerCombatStance, optional force : bool ) : bool
  6929. {
  6930. var currTime : float;
  6931.  
  6932. if ( force )
  6933. return true;
  6934.  
  6935. if ( IsInFistFightMiniGame() )
  6936. return true;
  6937.  
  6938. if ( isInHolsterAnim )
  6939. return false;
  6940.  
  6941. if ( ( combatStance == PCS_Normal || combatStance == PCS_AlertFar ) && stance == PCS_AlertNear )
  6942. {
  6943. currTime = theGame.GetEngineTimeAsSeconds();
  6944. if ( !isConfirmingCombatStance )
  6945. {
  6946. isConfirmingCombatStance = true;
  6947. confirmCombatStanceTimeStamp = currTime;
  6948.  
  6949. return false;
  6950. }
  6951. else if ( currTime < confirmCombatStanceTimeStamp + 1.f )
  6952. {
  6953. if ( stance == PCS_AlertNear )
  6954. return false;
  6955. }
  6956. else
  6957. isConfirmingCombatStance = false;
  6958. }
  6959. else
  6960. isConfirmingCombatStance = false;
  6961.  
  6962. return true;
  6963. }
  6964.  
  6965. private var isInHolsterAnim : bool;
  6966. event OnHolsterWeaponStart()
  6967. {
  6968. isInHolsterAnim = true;
  6969. }
  6970.  
  6971. event OnHolsterWeaponEnd()
  6972. {
  6973. isInHolsterAnim = false;
  6974. }
  6975.  
  6976. final function GetPlayerCombatStance() : EPlayerCombatStance
  6977. {
  6978. return combatStance;
  6979. }
  6980.  
  6981. timer function DelayedDisableFindTarget( time : float , id : int)
  6982. {
  6983. if ( GetTarget().IsAlive() )
  6984. {
  6985. EnableFindTarget( false );
  6986. }
  6987. else
  6988. {
  6989. EnableFindTarget( true );
  6990. }
  6991. }
  6992.  
  6993.  
  6994.  
  6995.  
  6996.  
  6997. private var dodgeTimerRunning : bool;
  6998.  
  6999. function StartDodgeTimer()
  7000. {
  7001. dodgeTimerRunning = true;
  7002. thePlayer.AddTimer('DodgeTimer',0.2,false);
  7003. }
  7004.  
  7005. function StopDodgeTimer()
  7006. {
  7007. this.RemoveTimer('DodgeTimer');
  7008. dodgeTimerRunning = false;
  7009. }
  7010.  
  7011. function IsDodgeTimerRunning() : bool
  7012. {
  7013. return dodgeTimerRunning;
  7014. }
  7015.  
  7016. timer function DodgeTimer( dt : float, id : int )
  7017. {
  7018. dodgeTimerRunning = false;
  7019. }
  7020.  
  7021. public function EvadePressed( bufferAction : EBufferActionType )
  7022. {
  7023. }
  7024.  
  7025. public function PerformingCombatAction() : EBufferActionType
  7026. {
  7027. return BufferCombatAction;
  7028. }
  7029.  
  7030. public function PushCombatActionOnBuffer( action : EBufferActionType, stage : EButtonStage, optional allSteps : bool )
  7031. {
  7032. BufferButtonStage = stage;
  7033. BufferCombatAction = action;
  7034. BufferAllSteps = allSteps;
  7035. }
  7036.  
  7037. protected function ProcessCombatActionHeading( action : EBufferActionType ) : float
  7038. {
  7039. var processedActionHeading : float;
  7040.  
  7041. HandleMovement( 0.f );
  7042.  
  7043. if ( ShouldUsePCModeTargeting() )
  7044. return theGame.GetGameCamera().GetHeading();
  7045.  
  7046. if ( lAxisReleasedAfterCounter )
  7047. ResetCachedRawPlayerHeading();
  7048.  
  7049. processedActionHeading = cachedRawPlayerHeading;
  7050.  
  7051. return processedActionHeading;
  7052. }
  7053.  
  7054.  
  7055. function ResetRawPlayerHeading()
  7056. {
  7057. if ( GetDisplayTarget() )
  7058. rawPlayerHeading = VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() );
  7059. else
  7060. rawPlayerHeading = GetHeading();
  7061.  
  7062.  
  7063. }
  7064.  
  7065. function ResetCachedRawPlayerHeading()
  7066. {
  7067. cachedRawPlayerHeading = rawPlayerHeading;
  7068. if ( GetDisplayTarget() && IsDisplayTargetTargetable() && AbsF( AngleDistance( VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() ), this.GetHeading() ) ) < 90.f )
  7069. cachedRawPlayerHeading = VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() );
  7070. else
  7071. cachedRawPlayerHeading = this.GetHeading();
  7072.  
  7073. if ( canResetCachedCombatActionHeading )
  7074. cachedCombatActionHeading = cachedRawPlayerHeading;
  7075. }
  7076.  
  7077. public function GetCombatActionTarget( action : EBufferActionType ) : CGameplayEntity
  7078. {
  7079. var selectedTargetableEntity : CGameplayEntity;
  7080.  
  7081. if ( !this.IsUsingVehicle() )
  7082. selectedTargetableEntity = FindNonActorTarget( true, action );
  7083.  
  7084. if ( selectedTargetableEntity )
  7085. {
  7086. return selectedTargetableEntity;
  7087. }
  7088. else
  7089. {
  7090.  
  7091.  
  7092. if ( !this.IsUsingVehicle() )
  7093. FindTarget( true, action, true );
  7094. else
  7095. ((CR4PlayerStateUseGenericVehicle)this.GetState( 'UseGenericVehicle' )).FindTarget();
  7096.  
  7097. return GetTarget();
  7098. }
  7099. }
  7100.  
  7101.  
  7102. private function FindNonActorTarget( actionCheck : bool, optional action : EBufferActionType ) : CGameplayEntity
  7103. {
  7104. var targetableEntities : array<CGameplayEntity>;
  7105. var selectedTargetableEntity : CGameplayEntity;
  7106. var selectionPriority : array< float >;
  7107. var selectionWeights : STargetSelectionWeights;
  7108. var findEntityDist : float;
  7109. var i, size : int;
  7110. var playerHeading : float;
  7111. var playerInventory : CInventoryComponent;
  7112. var castSignType : ESignType;
  7113. var targetingInfo : STargetingInfo;
  7114. var playerPosition : Vector;
  7115. var cameraPosition : Vector;
  7116. var playerHeadingVector : Vector;
  7117. var rawPlayerHeadingVector : Vector;
  7118.  
  7119. playerPosition = this.GetWorldPosition();
  7120. cameraPosition = theCamera.GetCameraPosition();
  7121. rawPlayerHeadingVector = VecFromHeading( rawPlayerHeading );
  7122.  
  7123. if ( bCanFindTarget && !IsHardLockEnabled() )
  7124. {
  7125. if ( actionCheck && IsInCombat() && action == EBAT_CastSign )
  7126. {
  7127. findEntityDist = 6.f;
  7128. selectionWeights.angleWeight = 0.375f;
  7129. selectionWeights.distanceWeight = 0.275f;
  7130. selectionWeights.distanceRingWeight = 0.35f;
  7131. }
  7132. else if ( !IsInCombat() && lastAxisInputIsMovement )
  7133. {
  7134. findEntityDist = softLockDist;
  7135. selectionWeights.angleWeight = 0.375f;
  7136. selectionWeights.distanceWeight = 0.275f;
  7137. selectionWeights.distanceRingWeight = 0.35f;
  7138. }
  7139. else
  7140. {
  7141. findEntityDist = softLockDist;
  7142. selectionWeights.angleWeight = 0.75f;
  7143. selectionWeights.distanceWeight = 0.125f;
  7144. selectionWeights.distanceRingWeight = 0.125f;
  7145. }
  7146.  
  7147.  
  7148. if ( !IsInCombat() || !bLAxisReleased )
  7149. {
  7150. FindGameplayEntitiesInRange( targetableEntities, this, findEntityDist, 10, theGame.params.TAG_SOFT_LOCK );
  7151. }
  7152.  
  7153. if ( targetableEntities.Size() > 0 )
  7154. {
  7155. playerInventory = this.GetInventory();
  7156. castSignType = this.GetEquippedSign();
  7157.  
  7158. if ( !bLAxisReleased )
  7159. {
  7160. targetingInfo.source = this;
  7161. targetingInfo.canBeTargetedCheck = false;
  7162. targetingInfo.coneCheck = true;
  7163. targetingInfo.coneHalfAngleCos = 0.5f;
  7164. targetingInfo.coneDist = softLockDist;
  7165. targetingInfo.coneHeadingVector = rawPlayerHeadingVector;
  7166. targetingInfo.distCheck = true;
  7167. targetingInfo.invisibleCheck = false;
  7168. targetingInfo.navMeshCheck = false;
  7169. targetingInfo.frameScaleX = 1.0f;
  7170. targetingInfo.frameScaleY = 1.0f;
  7171. targetingInfo.knockDownCheck = false;
  7172. targetingInfo.knockDownCheckDist = 0.0f;
  7173. targetingInfo.rsHeadingCheck = false;
  7174. targetingInfo.rsHeadingLimitCos = 1.0f;
  7175. }
  7176.  
  7177. for( i = targetableEntities.Size()-1; i>=0; i-=1 )
  7178. {
  7179. if ( bLAxisReleased )
  7180. {
  7181. if ( !lastAxisInputIsMovement )
  7182. {
  7183. if ( !WasVisibleInScaledFrame( targetableEntities[i], 0.9f, 0.9f ) )
  7184. {
  7185. targetableEntities.Erase(i);
  7186. continue;
  7187. }
  7188. }
  7189. else if ( !WasVisibleInScaledFrame( targetableEntities[i], 1.f, 1.f ) )
  7190. {
  7191. targetableEntities.Erase(i);
  7192. continue;
  7193. }
  7194. }
  7195. else
  7196. {
  7197. targetingInfo.targetEntity = targetableEntities[i];
  7198. if ( actionCheck && moveTarget )
  7199. {
  7200. targetingInfo.inFrameCheck = false;
  7201. if ( !IsEntityTargetable( targetingInfo ) )
  7202. {
  7203. targetableEntities.Erase(i);
  7204. continue;
  7205. }
  7206. }
  7207. else
  7208. {
  7209. targetingInfo.inFrameCheck = true;
  7210. if ( !IsEntityTargetable( targetingInfo ) )
  7211. {
  7212. targetableEntities.Erase(i);
  7213. continue;
  7214. }
  7215. }
  7216. }
  7217.  
  7218. if ( actionCheck )
  7219. {
  7220. if ( action == EBAT_ItemUse )
  7221. {
  7222. if ( ( playerInventory.IsItemBomb( this.GetSelectedItemId() ) && !targetableEntities[i].HasTag( 'softLock_Bomb' ) )
  7223. || ( playerInventory.IsItemCrossbow( this.GetSelectedItemId() ) && !targetableEntities[i].HasTag( 'softLock_Bolt' ) ) )
  7224. {
  7225. targetableEntities.Erase(i);
  7226. continue;
  7227. }
  7228. }
  7229. else if ( action == EBAT_CastSign )
  7230. {
  7231. if ( ( castSignType == ST_Aard && !targetableEntities[i].HasTag( 'softLock_Aard' ) )
  7232. || ( castSignType == ST_Igni && !targetableEntities[i].HasTag( 'softLock_Igni' ) )
  7233. || ( castSignType == ST_Axii && !targetableEntities[i].HasTag( 'softLock_Axii' ) )
  7234. || castSignType == ST_Yrden
  7235. || castSignType == ST_Quen )
  7236. {
  7237. targetableEntities.Erase(i);
  7238. continue;
  7239. }
  7240. }
  7241. else if ( action == EBAT_LightAttack || action == EBAT_HeavyAttack || action == EBAT_SpecialAttack_Heavy )
  7242. {
  7243. if ( ( IsWeaponHeld( 'fist' ) && !targetableEntities[i].HasTag( 'softLock_Fist' ) ) || ( !IsWeaponHeld( 'fist' ) && !targetableEntities[i].HasTag( 'softLock_Weapon' ) ) )
  7244. {
  7245. targetableEntities.Erase(i);
  7246. continue;
  7247. }
  7248. }
  7249. else
  7250. {
  7251. targetableEntities.Erase(i);
  7252. continue;
  7253. }
  7254. }
  7255. }
  7256. }
  7257.  
  7258. if ( targetableEntities.Size() > 0)
  7259. {
  7260. playerHeading = this.GetHeading();
  7261. playerHeadingVector = this.GetHeadingVector();
  7262. if ( IsInCombat() )
  7263. {
  7264. for( i = 0; i < targetableEntities.Size(); i += 1 )
  7265. {
  7266. if ( bLAxisReleased )
  7267. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, cameraPosition, rawPlayerHeadingVector ) );
  7268. else
  7269. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, rawPlayerHeadingVector ) );
  7270. }
  7271.  
  7272. if ( selectionPriority.Size() > 0 )
  7273. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  7274. }
  7275. else
  7276. {
  7277. if ( bLAxisReleased )
  7278. {
  7279. if ( !lastAxisInputIsMovement )
  7280. {
  7281. for( i = 0; i < targetableEntities.Size(); i += 1 )
  7282. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, cameraPosition, rawPlayerHeadingVector ) );
  7283.  
  7284. if ( selectionPriority.Size() > 0 )
  7285. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  7286. }
  7287. else
  7288. {
  7289. if ( IsInCombatAction() )
  7290. selectedTargetableEntity = nonActorTarget;
  7291. else
  7292. {
  7293. for( i = 0; i < targetableEntities.Size(); i += 1 )
  7294. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, playerHeadingVector ) );
  7295.  
  7296. if ( selectionPriority.Size() > 0 )
  7297. {
  7298. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  7299.  
  7300. targetingInfo.source = this;
  7301. targetingInfo.targetEntity = selectedTargetableEntity;
  7302. targetingInfo.canBeTargetedCheck = false;
  7303. targetingInfo.coneCheck = true;
  7304. targetingInfo.coneHalfAngleCos = 0.0f;
  7305. targetingInfo.coneDist = softLockDist;
  7306. targetingInfo.coneHeadingVector = this.GetHeadingVector();
  7307. targetingInfo.distCheck = true;
  7308. targetingInfo.invisibleCheck = false;
  7309. targetingInfo.navMeshCheck = false;
  7310. targetingInfo.inFrameCheck = false;
  7311. targetingInfo.frameScaleX = 1.0f;
  7312. targetingInfo.frameScaleY = 1.0f;
  7313. targetingInfo.knockDownCheck = false;
  7314. targetingInfo.knockDownCheckDist = 0.0f;
  7315. targetingInfo.rsHeadingCheck = false;
  7316. targetingInfo.rsHeadingLimitCos = 1.0f;
  7317.  
  7318. if ( !IsEntityTargetable( targetingInfo ) )
  7319. selectedTargetableEntity = NULL;
  7320. }
  7321. }
  7322. }
  7323. }
  7324. else
  7325. {
  7326. for( i = 0; i < targetableEntities.Size(); i += 1 )
  7327. selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, rawPlayerHeadingVector ) );
  7328.  
  7329. if ( selectionPriority.Size() > 0 )
  7330. selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
  7331. }
  7332. }
  7333. }
  7334. else
  7335. selectedTargetableEntity = NULL;
  7336. }
  7337.  
  7338. SetNonActorTarget( selectedTargetableEntity );
  7339. return selectedTargetableEntity;
  7340. }
  7341.  
  7342.  
  7343. public function SetupCombatAction( action : EBufferActionType, stage : EButtonStage )
  7344. {
  7345. var weaponType : EPlayerWeapon;
  7346. var canAttackTarget : CGameplayEntity;
  7347. var target : CActor;
  7348.  
  7349.  
  7350. if ( !IsCombatMusicEnabled() )
  7351. {
  7352. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  7353. FindTarget();
  7354. UpdateDisplayTarget( true );
  7355. }
  7356.  
  7357. if ( displayTarget && IsDisplayTargetTargetable() )
  7358. canAttackTarget = displayTarget;
  7359. else if ( GetTarget() )
  7360. canAttackTarget = GetTarget();
  7361. else if( !target && IsCombatMusicEnabled() )
  7362. canAttackTarget = moveTarget;
  7363.  
  7364. target = (CActor)canAttackTarget;
  7365.  
  7366. if ( !AllowAttack( target, action ) )
  7367. return;
  7368.  
  7369. if( ( action != EBAT_ItemUse ) && ( action != EBAT_CastSign ) )
  7370. {
  7371. weaponType = weaponHolster.GetCurrentMeleeWeapon();
  7372. PrepareToAttack( target, action );
  7373.  
  7374.  
  7375. if ( weaponType != weaponHolster.GetCurrentMeleeWeapon() )
  7376. {
  7377.  
  7378. if ( !( weaponType == PW_None && weaponHolster.GetCurrentMeleeWeapon() == PW_Fists ) )
  7379. return;
  7380. }
  7381. }
  7382.  
  7383.  
  7384. if(action == EBAT_SpecialAttack_Heavy && !((W3ReplacerCiri)this) )
  7385. thePlayer.SetAttackActionName(SkillEnumToName(S_Sword_s02));
  7386.  
  7387. CriticalEffectAnimationInterrupted("SetupCombatAction " + action);
  7388. PushCombatActionOnBuffer( action, stage );
  7389.  
  7390. if( GetBIsCombatActionAllowed() )
  7391. {
  7392. ProcessCombatActionBuffer();
  7393. }
  7394. }
  7395.  
  7396. public function AllowAttack( target : CActor, action : EBufferActionType ) : bool
  7397. {
  7398. var newTarget : CActor;
  7399. var canAttackWhenNotInCombat : bool;
  7400. var messageDisplayed : bool;
  7401.  
  7402. var itemId : SItemUniqueId;
  7403. var isShootingCrossbow : bool;
  7404.  
  7405. var isInCorrectState : bool;
  7406.  
  7407. if ( target )
  7408. {
  7409. if ( target.IsTargetableByPlayer())
  7410. {
  7411. if ( !target.IsAttackableByPlayer() )
  7412. {
  7413. DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_cant_attack_this_target"));
  7414. return false;
  7415. }
  7416. }
  7417. }
  7418.  
  7419. if ( this.GetCurrentStateName() == 'Exploration' )
  7420. isInCorrectState = true;
  7421.  
  7422. if ( action == EBAT_ItemUse )
  7423. {
  7424. itemId = thePlayer.GetSelectedItemId();
  7425. if ( inv.IsIdValid(itemId) && inv.IsItemCrossbow(itemId) )
  7426. isShootingCrossbow = true;
  7427.  
  7428. if ( !isInCorrectState )
  7429. {
  7430. if ( this.GetCurrentStateName() == 'AimThrow' && !isShootingCrossbow )
  7431. {
  7432. isInCorrectState = true;
  7433. }
  7434. }
  7435. }
  7436.  
  7437. if ( isInCorrectState )
  7438. canAttackWhenNotInCombat = thePlayer.CanAttackWhenNotInCombat( action, false, newTarget, target );
  7439.  
  7440. if( !target )
  7441. {
  7442. if ( isInCorrectState )
  7443. {
  7444. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  7445. target = newTarget;
  7446. }
  7447. }
  7448.  
  7449. if ( isInCorrectState )
  7450. {
  7451. if ( !canAttackWhenNotInCombat )
  7452. {
  7453. if ( DisplayCannotAttackMessage( target ) )
  7454. messageDisplayed = true;
  7455. else if ( ( action == EBAT_LightAttack || action == EBAT_HeavyAttack )
  7456. && !RaiseAttackFriendlyEvent( target ) )
  7457. messageDisplayed = true;
  7458. else
  7459. {
  7460. if ( !CanRaiseCombatActionFriendlyEvent( isShootingCrossbow ) )
  7461. messageDisplayed = true;
  7462. }
  7463. }
  7464.  
  7465. if ( messageDisplayed )
  7466. {
  7467. theInput.ForceDeactivateAction('ThrowItem');
  7468. theInput.ForceDeactivateAction('ThrowItemHold');
  7469. this.SignalGameplayEvent( 'FriendlyAttackAction' );
  7470. return false;
  7471. }
  7472. }
  7473.  
  7474. return true;
  7475. }
  7476.  
  7477.  
  7478.  
  7479. public function ProcessCombatActionBuffer() : bool
  7480. {
  7481. var actionResult : bool;
  7482. var action : EBufferActionType = this.BufferCombatAction;
  7483. var stage : EButtonStage = this.BufferButtonStage;
  7484. var s : SNotWorkingOutFunctionParametersHackStruct1;
  7485. var allSteps : bool = this.BufferAllSteps;
  7486.  
  7487. if ( IsInCombatActionFriendly() )
  7488. {
  7489. RaiseEvent('CombatActionFriendlyEnd');
  7490. }
  7491.  
  7492.  
  7493. if ( ( action != EBAT_SpecialAttack_Heavy && action != EBAT_ItemUse )
  7494. || ( action == EBAT_SpecialAttack_Heavy && stage == BS_Pressed )
  7495. || ( action == EBAT_ItemUse && stage != BS_Released ) )
  7496. {
  7497. GetMovingAgentComponent().GetMovementAdjustor().CancelAll();
  7498. SetUnpushableTarget( NULL );
  7499. }
  7500.  
  7501.  
  7502. if ( !( action == EBAT_Dodge || action == EBAT_Roll ) )
  7503. {
  7504. SetIsCurrentlyDodging(false);
  7505. }
  7506.  
  7507. SetCombatActionHeading( ProcessCombatActionHeading( action ) );
  7508.  
  7509.  
  7510.  
  7511. if ( action == EBAT_ItemUse && GetInventory().IsItemCrossbow( selectedItemId ) )
  7512. {
  7513.  
  7514. if ( rangedWeapon
  7515. && ( ( rangedWeapon.GetCurrentStateName() != 'State_WeaponShoot' && rangedWeapon.GetCurrentStateName() != 'State_WeaponAim' ) || GetIsShootingFriendly() ) )
  7516. {
  7517. SetSlideTarget( GetCombatActionTarget( action ) );
  7518. }
  7519. }
  7520. else if ( !( ( action == EBAT_SpecialAttack_Heavy && stage == BS_Released ) || GetCurrentStateName() == 'AimThrow' ) )
  7521. {
  7522. SetSlideTarget( GetCombatActionTarget( action ) );
  7523. }
  7524.  
  7525. if( !slideTarget )
  7526. LogChannel( 'Targeting', "NO SLIDE TARGET" );
  7527.  
  7528.  
  7529. actionResult = true;
  7530.  
  7531. switch ( action )
  7532. {
  7533. case EBAT_EMPTY :
  7534. {
  7535. this.BufferAllSteps = false;
  7536. return true;
  7537. } break;
  7538.  
  7539. case EBAT_LightAttack :
  7540. {
  7541. if ( IsCiri() )
  7542. return false;
  7543.  
  7544. switch ( stage )
  7545. {
  7546. case BS_Pressed :
  7547. {
  7548.  
  7549.  
  7550.  
  7551.  
  7552.  
  7553.  
  7554. DrainStamina(ESAT_LightAttack);
  7555.  
  7556.  
  7557. thePlayer.BreakPheromoneEffect();
  7558. actionResult = OnPerformAttack(theGame.params.ATTACK_NAME_LIGHT);
  7559.  
  7560. } break;
  7561.  
  7562. default :
  7563. {
  7564. actionResult = false;
  7565. }break;
  7566. }
  7567. }break;
  7568.  
  7569. case EBAT_HeavyAttack :
  7570. {
  7571. if ( IsCiri() )
  7572. return false;
  7573.  
  7574. switch ( stage )
  7575. {
  7576. case BS_Released :
  7577. {
  7578.  
  7579.  
  7580.  
  7581.  
  7582.  
  7583. DrainStamina(ESAT_HeavyAttack);
  7584.  
  7585.  
  7586.  
  7587. thePlayer.BreakPheromoneEffect();
  7588. actionResult = this.OnPerformAttack(theGame.params.ATTACK_NAME_HEAVY);
  7589.  
  7590. } break;
  7591.  
  7592. case BS_Pressed :
  7593. {
  7594. if ( this.GetCurrentStateName() == 'CombatFists' )
  7595. {
  7596.  
  7597.  
  7598.  
  7599.  
  7600.  
  7601. DrainStamina(ESAT_HeavyAttack);
  7602.  
  7603.  
  7604.  
  7605. thePlayer.BreakPheromoneEffect();
  7606. actionResult = this.OnPerformAttack(theGame.params.ATTACK_NAME_HEAVY);
  7607.  
  7608. }
  7609. } break;
  7610.  
  7611. default :
  7612. {
  7613. actionResult = false;
  7614.  
  7615. } break;
  7616. }
  7617. } break;
  7618.  
  7619. case EBAT_ItemUse :
  7620. {
  7621. switch ( stage )
  7622. {
  7623. case BS_Pressed :
  7624. {
  7625. if ( !( (W3PlayerWitcher)this ) ||
  7626. ( !IsInCombatActionFriendly() && !( !GetBIsCombatActionAllowed() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign ) ) ) )
  7627.  
  7628. {
  7629. if ( inv.IsItemCrossbow( selectedItemId ) )
  7630. {
  7631. rangedWeapon = ( Crossbow )( inv.GetItemEntityUnsafe( selectedItemId ) );
  7632. rangedWeapon.OnRangedWeaponPress();
  7633. GetTarget().SignalGameplayEvent( 'Approach' );
  7634. GetTarget().SignalGameplayEvent( 'ShootingCrossbow' );
  7635. }
  7636. else if(inv.IsItemBomb(selectedItemId) && this.inv.SingletonItemGetAmmo(selectedItemId) > 0 )
  7637. {
  7638. if( ((W3PlayerWitcher)this).GetBombDelay( ((W3PlayerWitcher)this).GetItemSlot( selectedItemId ) ) <= 0.0f )
  7639. {
  7640. BombThrowStart();
  7641. GetTarget().SignalGameplayEvent( 'Approach' );
  7642. }
  7643. }
  7644. else
  7645. {
  7646. DrainStamina(ESAT_UsableItem);
  7647. UsableItemStart();
  7648. }
  7649. }
  7650.  
  7651. } if (!allSteps) break;
  7652.  
  7653. case BS_Released:
  7654. {
  7655. if ( !( (W3PlayerWitcher)this ) ||
  7656. ( !IsInCombatActionFriendly() && ( GetBIsCombatActionAllowed() || !( !GetBIsCombatActionAllowed() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign ) ) ) ) )
  7657.  
  7658. {
  7659. if ( inv.IsItemCrossbow( selectedItemId ) )
  7660. {
  7661.  
  7662. rangedWeapon.OnRangedWeaponRelease();
  7663. }
  7664. else if(inv.IsItemBomb(selectedItemId))
  7665. {
  7666. BombThrowRelease();
  7667. }
  7668. else
  7669. {
  7670. UsableItemRelease();
  7671. }
  7672. }
  7673. } break;
  7674.  
  7675. default :
  7676. {
  7677. actionResult = false;
  7678. break;
  7679. }
  7680. }
  7681. } break;
  7682.  
  7683. case EBAT_Dodge :
  7684. {
  7685. switch ( stage )
  7686. {
  7687. case BS_Released :
  7688. {
  7689. theGame.GetBehTreeReactionManager().CreateReactionEvent( this, 'PlayerEvade', 1.0f, 10.0f, -1.0f, -1 );
  7690. thePlayer.BreakPheromoneEffect();
  7691. actionResult = this.OnPerformEvade( PET_Dodge );
  7692. } break;
  7693.  
  7694.  
  7695.  
  7696. default :
  7697. {
  7698. actionResult = false;
  7699. } break;
  7700. }
  7701. } break;
  7702.  
  7703. case EBAT_Roll :
  7704. {
  7705. if ( IsCiri() )
  7706. return false;
  7707.  
  7708. switch ( stage )
  7709. {
  7710. case BS_Released :
  7711. {
  7712. theGame.GetBehTreeReactionManager().CreateReactionEvent( this, 'PlayerEvade', 1.0f, 10.0f, -1.0f, -1 );
  7713. thePlayer.BreakPheromoneEffect();
  7714. actionResult = this.OnPerformEvade( PET_Roll );
  7715. } break;
  7716.  
  7717. case BS_Pressed :
  7718. {
  7719. if ( this.GetBehaviorVariable( 'combatActionType' ) == 2.f )
  7720. {
  7721. if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
  7722. actionResult = this.OnPerformEvade( PET_Pirouette );
  7723. else
  7724. actionResult = this.OnPerformEvade( PET_Roll );
  7725. }
  7726. else
  7727. {
  7728. if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
  7729. {
  7730. actionResult = this.OnPerformEvade( PET_Dodge );
  7731. actionResult = this.OnPerformEvade( PET_Pirouette );
  7732. }
  7733. else
  7734. {
  7735. actionResult = this.OnPerformEvade( PET_Dodge );
  7736. actionResult = this.OnPerformEvade( PET_Roll );
  7737. }
  7738. }
  7739.  
  7740.  
  7741. } break;
  7742.  
  7743. default :
  7744. {
  7745. actionResult = false;
  7746. } break;
  7747. }
  7748. } break;
  7749.  
  7750. case EBAT_Draw_Steel :
  7751. {
  7752. switch ( stage )
  7753. {
  7754. case BS_Pressed :
  7755. {
  7756. if( !IsActionAllowed(EIAB_DrawWeapon) )
  7757. {
  7758. thePlayer.DisplayActionDisallowedHudMessage(EIAB_DrawWeapon);
  7759. actionResult = false;
  7760. break;
  7761. }
  7762. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'steelsword' ) )
  7763. {
  7764. OnEquipMeleeWeapon( PW_Steel, false, true );
  7765. }
  7766.  
  7767. actionResult = false;
  7768.  
  7769. } break;
  7770.  
  7771. default :
  7772. {
  7773. actionResult = false;
  7774. } break;
  7775. }
  7776. } break;
  7777.  
  7778. case EBAT_Draw_Silver :
  7779. {
  7780. switch ( stage )
  7781. {
  7782. case BS_Pressed :
  7783. {
  7784. if( !IsActionAllowed(EIAB_DrawWeapon) )
  7785. {
  7786. thePlayer.DisplayActionDisallowedHudMessage(EIAB_DrawWeapon);
  7787. actionResult = false;
  7788. break;
  7789. }
  7790. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'silversword' ) )
  7791. {
  7792. OnEquipMeleeWeapon( PW_Silver, false, true );
  7793. }
  7794.  
  7795. actionResult = false;
  7796.  
  7797. } break;
  7798.  
  7799. default :
  7800. {
  7801. actionResult = false;
  7802. } break;
  7803. }
  7804. } break;
  7805.  
  7806. case EBAT_Sheathe_Sword :
  7807. {
  7808. switch ( stage )
  7809. {
  7810. case BS_Pressed :
  7811. {
  7812. if( GetCurrentMeleeWeaponType() == PW_Silver )
  7813. {
  7814. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'silversword' ) )
  7815. {
  7816. OnEquipMeleeWeapon( PW_Silver, false, true );
  7817. }
  7818. }
  7819. else if( GetCurrentMeleeWeaponType() == PW_Steel )
  7820. {
  7821. if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'steelsword' ) )
  7822. {
  7823. OnEquipMeleeWeapon( PW_Steel, false, true );
  7824. }
  7825. }
  7826.  
  7827. actionResult = false;
  7828.  
  7829. } break;
  7830.  
  7831. default :
  7832. {
  7833. actionResult = false;
  7834. } break;
  7835. }
  7836. } break;
  7837.  
  7838. default:
  7839. return false;
  7840. }
  7841.  
  7842.  
  7843. CleanCombatActionBuffer();
  7844.  
  7845. if (actionResult)
  7846. {
  7847. SetCombatAction( action ) ;
  7848.  
  7849. if(GetWitcherPlayer().IsInFrenzy())
  7850. GetWitcherPlayer().SkillFrenzyFinish(0);
  7851. }
  7852.  
  7853. return true;
  7854. }
  7855.  
  7856. public function CleanCombatActionBuffer()
  7857. {
  7858. BufferCombatAction = EBAT_EMPTY;
  7859. BufferAllSteps = false;
  7860. }
  7861.  
  7862. public function CancelHoldAttacks()
  7863. {
  7864. RemoveTimer( 'IsSpecialLightAttackInputHeld' );
  7865. RemoveTimer( 'IsSpecialHeavyAttackInputHeld' );
  7866. RemoveTimer( 'SpecialAttackLightSustainCost' );
  7867. RemoveTimer( 'SpecialAttackHeavySustainCost' );
  7868. RemoveTimer( 'UpdateSpecialAttackLightHeading' );
  7869. UnblockAction( EIAB_Crossbow, 'SpecialAttack' );
  7870.  
  7871. ResumeStaminaRegen('WhirlSkill');
  7872.  
  7873. if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_SpecialAttack && GetBehaviorVariable( 'isPerformingSpecialAttack' ) == 1.f )
  7874. {
  7875. if( GetBehaviorVariable( 'playerAttackType' ) == (int)PAT_Light )
  7876. {
  7877. SetAttackActionName(SkillEnumToName(S_Sword_s01));
  7878. PushCombatActionOnBuffer( EBAT_SpecialAttack_Light, BS_Released );
  7879. ProcessCombatActionBuffer();
  7880.  
  7881. ((W3PlayerWitcherStateCombatFists) GetState('Combat')).ResetTimeToEndCombat();
  7882.  
  7883. }
  7884. else if( GetBehaviorVariable( 'playerAttackType' ) == (int)PAT_Heavy )
  7885. {
  7886. SetAttackActionName(SkillEnumToName(S_Sword_s02));
  7887. PushCombatActionOnBuffer( EBAT_SpecialAttack_Heavy, BS_Released );
  7888. ProcessCombatActionBuffer();
  7889.  
  7890. }
  7891. }
  7892. }
  7893.  
  7894. public function RaiseAttackFriendlyEvent( actor : CActor ) : bool
  7895. {
  7896. var playerToTargetHeading : float;
  7897.  
  7898. if ( actor && RaiseCombatActionFriendlyEvent() )
  7899. {
  7900. SetBehaviorVariable( 'tauntTypeForOverlay', 0.f );
  7901. SetBehaviorVariable( 'combatActionTypeForOverlay', (int)CAT_Attack );
  7902.  
  7903. if ( actor )
  7904. actor.SignalGameplayEvent('PersonalTauntAction');
  7905. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'TauntAction', -1.0, 4.5f, -1, 9999, true );
  7906.  
  7907. OnCombatActionStart();
  7908.  
  7909. playerToTargetHeading = VecHeading( actor.GetWorldPosition() - GetWorldPosition() );
  7910.  
  7911. SetCustomRotation( 'Attack', playerToTargetHeading, 0.0f, 0.3f, false );
  7912.  
  7913. return true;
  7914. }
  7915.  
  7916. return false;
  7917. }
  7918.  
  7919. public function SendAttackReactionEvent()
  7920. {
  7921. var reactionName : name;
  7922.  
  7923.  
  7924.  
  7925. reactionName = 'AttackAction';
  7926.  
  7927. if ( IsNameValid(reactionName) )
  7928. {
  7929. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, reactionName, -1.0, 8.0f, -1, 5, true );
  7930. }
  7931.  
  7932.  
  7933. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'outOfMyWay', -1.0, 2.0f, -1, 5, true );
  7934. }
  7935.  
  7936. var forceCanAttackWhenNotInCombat : int;
  7937. public function SetForceCanAttackWhenNotInCombat( forceMode : int )
  7938. {
  7939. forceCanAttackWhenNotInCombat = forceMode;
  7940. }
  7941.  
  7942. public function CanAttackWhenNotInCombat( actionType : EBufferActionType, altCast : bool, out newTarget : CActor, optional target : CGameplayEntity ) : bool
  7943. {
  7944. var localTargets : array<CActor>;
  7945. var i, size : int;
  7946. var inputHeading : float;
  7947. var clearanceMin, clearanceMax : float;
  7948. var attackLength : float;
  7949. var attackAngle : float;
  7950. var npc : CNewNPC;
  7951. var canAttackTarget : CGameplayEntity;
  7952. var canAttackTargetActor : CActor;
  7953.  
  7954. if ( target )
  7955. canAttackTarget = target;
  7956. else if ( displayTarget && IsDisplayTargetTargetable() )
  7957. canAttackTarget = displayTarget;
  7958. else
  7959. canAttackTarget = slideTarget;
  7960.  
  7961. canAttackTargetActor = (CActor)canAttackTarget;
  7962.  
  7963. if ( forceCanAttackWhenNotInCombat == 2 )
  7964. return true;
  7965. else if ( forceCanAttackWhenNotInCombat == 1 && ( !canAttackTarget || !canAttackTargetActor.IsHuman() ) )
  7966. return true;
  7967.  
  7968. if ( actionType == EBAT_CastSign )
  7969. {
  7970. if ( thePlayer.GetEquippedSign() != ST_Quen && thePlayer.GetEquippedSign() != ST_Axii )
  7971. {
  7972. if ( CanUseSkill( S_Magic_s20 ) )
  7973. {
  7974. if ( thePlayer.GetEquippedSign() == ST_Aard )
  7975. attackLength = 6.f;
  7976. else if ( thePlayer.GetEquippedSign() == ST_Igni )
  7977. attackLength = 4.f;
  7978. else
  7979. attackLength = 6.f;
  7980. }
  7981. else
  7982. {
  7983. if ( thePlayer.GetEquippedSign() == ST_Aard )
  7984. attackLength = 9.f;
  7985. else if ( thePlayer.GetEquippedSign() == ST_Igni )
  7986. attackLength = 6.f;
  7987. else
  7988. attackLength = 6.f;
  7989. }
  7990.  
  7991. if ( altCast )
  7992. attackAngle = 180.f;
  7993. else
  7994.  
  7995. attackAngle = 90.f;
  7996.  
  7997. if ( !lastAxisInputIsMovement )
  7998. inputHeading = VecHeading( theCamera.GetCameraDirection() );
  7999. else if ( lAxisReleasedAfterCounter )
  8000. inputHeading = GetHeading();
  8001. else
  8002. inputHeading = GetCombatActionHeading();
  8003.  
  8004. clearanceMin = 1.f;
  8005. clearanceMax = attackLength + 1.f;
  8006. }
  8007. else if ( thePlayer.GetEquippedSign() == ST_Axii )
  8008. {
  8009. npc = (CNewNPC)canAttackTarget;
  8010. if ( npc && npc.GetNPCType() == ENGT_Quest && !npc.HasTag(theGame.params.TAG_AXIIABLE_LOWER_CASE) && !npc.HasTag(theGame.params.TAG_AXIIABLE))
  8011. return false;
  8012. else if ( npc && npc.IsUsingHorse() )
  8013. return false;
  8014. else
  8015. return true;
  8016. }
  8017. else
  8018. return true;
  8019. }
  8020. else if ( actionType == EBAT_ItemUse )
  8021. {
  8022. attackLength = theGame.params.MAX_THROW_RANGE;
  8023. attackAngle = 90.f;
  8024.  
  8025. if ( thePlayer.lastAxisInputIsMovement )
  8026. inputHeading = GetCombatActionHeading();
  8027. else
  8028. inputHeading = VecHeading( theCamera.GetCameraDirection() );
  8029.  
  8030. clearanceMin = 0.8f;
  8031. clearanceMax = attackLength + 3.f;
  8032. }
  8033. else
  8034. {
  8035. if ( actionType == EBAT_SpecialAttack_Light || actionType == EBAT_SpecialAttack_Heavy )
  8036. {
  8037. attackLength = 1.9f;
  8038. attackAngle = 90.f;
  8039. }
  8040. else
  8041. {
  8042. if( thePlayer.GetCurrentMeleeWeaponType() == PW_Fists || thePlayer.GetCurrentMeleeWeaponType() == PW_None )
  8043. attackLength = 1.2f;
  8044. else
  8045. attackLength = 1.9f;
  8046.  
  8047. attackAngle = 90.f;
  8048. }
  8049.  
  8050. if ( lastAxisInputIsMovement )
  8051. inputHeading = GetCombatActionHeading();
  8052. else
  8053. inputHeading = VecHeading( theCamera.GetCameraDirection() );
  8054.  
  8055. clearanceMin = attackLength / 2.f;
  8056. clearanceMax = attackLength + 3.f;
  8057. }
  8058.  
  8059.  
  8060. if ( canAttackTarget )
  8061. {
  8062. if ( ( canAttackTargetActor && canAttackTargetActor.IsHuman() ) || canAttackTargetActor.HasTag( 'softLock_Friendly' ) )
  8063. {
  8064. if ( ShouldPerformFriendlyAction( canAttackTargetActor, inputHeading, attackAngle, clearanceMin, clearanceMax ) )
  8065. {
  8066. SetSlideTarget( canAttackTargetActor );
  8067. newTarget = canAttackTargetActor;
  8068. return false;
  8069. }
  8070. }
  8071.  
  8072.  
  8073. }
  8074.  
  8075. return true;
  8076.  
  8077. thePlayer.GetVisibleEnemies( localTargets );
  8078. size = localTargets.Size();
  8079.  
  8080. if ( size > 0 )
  8081. {
  8082. for ( i = size-1; i>=0; i-=1 )
  8083. {
  8084.  
  8085. if ( !localTargets[i].IsHuman() && !localTargets[i].HasTag( 'softLock_Friendly' ) )
  8086. localTargets.Erase(i);
  8087. }
  8088. }
  8089.  
  8090. size = localTargets.Size();
  8091. if ( size > 0 )
  8092. {
  8093. for ( i = 0; i < localTargets.Size(); i += 1 )
  8094. {
  8095. if ( ShouldPerformFriendlyAction( localTargets[i], inputHeading, attackAngle, clearanceMin, clearanceMax ) )
  8096. {
  8097. SetSlideTarget( localTargets[i] );
  8098. newTarget = localTargets[i];
  8099. return false;
  8100. }
  8101. }
  8102. }
  8103.  
  8104. newTarget = NULL;
  8105.  
  8106. return true;
  8107. }
  8108.  
  8109. private function ShouldPerformFriendlyAction( actor : CActor, inputHeading, attackAngle, clearanceMin, clearanceMax : float ) : bool
  8110. {
  8111. var npc : CNewNPC;
  8112. var argh : float;
  8113. var playerToTargetDist : float;
  8114.  
  8115. npc = (CNewNPC)actor;
  8116.  
  8117. if ( npc &&
  8118. ( GetAttitudeBetween(thePlayer, npc) == AIA_Hostile || ( GetAttitudeBetween(thePlayer, npc) == AIA_Neutral && npc.GetNPCType() != ENGT_Guard ) ) )
  8119. {
  8120. }
  8121. else
  8122. {
  8123. playerToTargetDist = VecDistance( this.GetWorldPosition(), actor.PredictWorldPosition( 0.5f ) );
  8124.  
  8125. argh = AbsF( AngleDistance( inputHeading, VecHeading( actor.GetWorldPosition() - thePlayer.GetWorldPosition() ) ) );
  8126.  
  8127. if ( AbsF( AngleDistance( inputHeading, VecHeading( actor.GetWorldPosition() - thePlayer.GetWorldPosition() ) ) ) < attackAngle )
  8128. {
  8129. if ( playerToTargetDist < clearanceMax )
  8130. {
  8131. return true;
  8132. }
  8133. }
  8134. else
  8135. {
  8136. if ( playerToTargetDist < clearanceMin )
  8137. {
  8138. return true;
  8139. }
  8140. }
  8141. }
  8142.  
  8143. return false;
  8144. }
  8145.  
  8146.  
  8147.  
  8148.  
  8149.  
  8150. public function GetHudMessagesSize() : int
  8151. {
  8152. return HudMessages.Size();
  8153. }
  8154.  
  8155. public function GetHudPendingMessage() : string
  8156. {
  8157. return HudMessages[0];
  8158. }
  8159.  
  8160. public function DisplayHudMessage( value : string ) : void
  8161. {
  8162. if (value == "")
  8163. {
  8164. return;
  8165. }
  8166.  
  8167. if( GetHudMessagesSize() > 0 )
  8168. {
  8169. if( HudMessages[HudMessages.Size()-1] == value )
  8170. {
  8171. return;
  8172. }
  8173. }
  8174. HudMessages.PushBack(value);
  8175. }
  8176.  
  8177.  
  8178. private final function DisallowedActionDontShowHack(action : EInputActionBlock, isTimeLock : bool) : bool
  8179. {
  8180. var locks : array< SInputActionLock >;
  8181. var i : int;
  8182.  
  8183.  
  8184. 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)) )
  8185. {
  8186. return true;
  8187. }
  8188.  
  8189.  
  8190. if( action == EIAB_ThrowBomb && ( HasBuff( EET_Hypnotized ) || HasBuff( EET_Confusion ) ) )
  8191. {
  8192. return false;
  8193. }
  8194.  
  8195.  
  8196. if(isTimeLock)
  8197. return false;
  8198.  
  8199.  
  8200. if(action == EIAB_OpenMeditation)
  8201. return false;
  8202.  
  8203.  
  8204. locks = GetActionLocks(action);
  8205. for(i=0; i<locks.Size(); i+=1)
  8206. {
  8207. if(locks[i].isFromQuest || locks[i].isFromPlace)
  8208. return false;
  8209. }
  8210.  
  8211. if ( this.IsCurrentlyUsingItemL() )
  8212. {
  8213. if ( action == EIAB_HeavyAttacks || action == EIAB_Parry )
  8214. return false;
  8215. }
  8216.  
  8217.  
  8218. return true;
  8219. }
  8220.  
  8221. public final function DisplayActionDisallowedHudMessage(action : EInputActionBlock, optional isCombatLock : bool, optional isPlaceLock : bool, optional isTimeLock : bool, optional isDangerous : bool)
  8222. {
  8223. var lockType : name;
  8224.  
  8225. if(action != EIAB_Undefined && DisallowedActionDontShowHack(action, isTimeLock))
  8226. return;
  8227.  
  8228.  
  8229. if(IsInCombat() && !IsActionCombat(action))
  8230. isCombatLock = true;
  8231.  
  8232.  
  8233. if(!isCombatLock && !isPlaceLock && !isTimeLock && action != EIAB_Undefined)
  8234. {
  8235. lockType = inputHandler.GetActionBlockedHudLockType(action);
  8236.  
  8237. if(lockType == 'combat')
  8238. isCombatLock = true;
  8239. else if(lockType == 'place')
  8240. isPlaceLock = true;
  8241. else if(lockType == 'time')
  8242. isTimeLock = true;
  8243. }
  8244.  
  8245. if(isDangerous)
  8246. {
  8247. DisplayHudMessage(GetLocStringByKeyExt( "message_meditation_too_dangerous" ));
  8248. }
  8249. else if(isCombatLock)
  8250. {
  8251. DisplayHudMessage(GetLocStringByKeyExt( "panel_hud_message_actionnotallowed_combat" ));
  8252. }
  8253. else if(isPlaceLock)
  8254. {
  8255. DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_here" ));
  8256. }
  8257. else if(isTimeLock)
  8258. {
  8259. DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_now" ));
  8260. }
  8261. }
  8262.  
  8263.  
  8264. public function RemoveHudMessageByString(msg : string, optional allQueuedInstances : bool)
  8265. {
  8266. var i, j : int;
  8267.  
  8268. for(i=0; i<HudMessages.Size(); i+=1)
  8269. {
  8270. if(HudMessages[i] == msg)
  8271. {
  8272. HudMessages.EraseFast(i);
  8273.  
  8274. if(!allQueuedInstances)
  8275. return;
  8276.  
  8277. break;
  8278. }
  8279. }
  8280.  
  8281.  
  8282. for(j=HudMessages.Size()-1; j >= i; j-=1)
  8283. {
  8284. if(HudMessages[i] == msg)
  8285. {
  8286. HudMessages.EraseFast(i);
  8287. }
  8288. }
  8289. }
  8290.  
  8291. public function RemoveHudMessageByIndex(idx : int)
  8292. {
  8293. if(idx >= 0 && idx < HudMessages.Size())
  8294. HudMessages.Erase(idx);
  8295. }
  8296.  
  8297. function SetSettlementBlockCanter( valueAdd : int )
  8298. {
  8299. m_SettlementBlockCanter += valueAdd;
  8300. }
  8301.  
  8302. var countDownToStart : int;
  8303. default countDownToStart = 0;
  8304.  
  8305. function DisplayRaceStart( countDownSecondsNumber : int )
  8306. {
  8307. var i : int;
  8308. countDownToStart = countDownSecondsNumber;
  8309. for( i = countDownSecondsNumber; i > 0; i -= 1 )
  8310. {
  8311. DisplayHudMessage(IntToString(i));
  8312. }
  8313. DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_race_start"));
  8314. AddTimer('RaceCountdown',1,true);
  8315. }
  8316.  
  8317. timer function RaceCountdown(dt : float, id : int)
  8318. {
  8319. var hud : CR4ScriptedHud;
  8320. var messageModule : CR4HudModuleMessage;
  8321.  
  8322. countDownToStart -= 1;
  8323. hud = (CR4ScriptedHud)theGame.GetHud();
  8324.  
  8325. if( hud )
  8326. {
  8327. messageModule = (CR4HudModuleMessage)hud.GetHudModule("MessageModule");
  8328. if( messageModule )
  8329. {
  8330. messageModule.OnMessageHidden();
  8331. }
  8332. }
  8333.  
  8334. if( countDownToStart <= 0 )
  8335. {
  8336. RemoveTimer('RaceCountdown');
  8337. }
  8338. }
  8339.  
  8340. public function GetCountDownToStart() : int
  8341. {
  8342. return countDownToStart;
  8343. }
  8344.  
  8345. public function HAXE3GetContainer() : W3Container
  8346. {
  8347. return HAXE3Container;
  8348. }
  8349.  
  8350. public function HAXE3SetContainer( container : W3Container) : void
  8351. {
  8352. HAXE3Container = container;
  8353. }
  8354.  
  8355. public function HAXE3GetAutoLoot() : bool
  8356. {
  8357. return HAXE3bAutoLoot;
  8358. }
  8359.  
  8360. public function HAXE3SetAutoLoot( value : bool ) : void
  8361. {
  8362. HAXE3bAutoLoot = value;
  8363. }
  8364.  
  8365. public function GetShowHud() : bool
  8366. {
  8367. return bShowHud;
  8368. }
  8369.  
  8370. public function SetShowHud( value : bool ) : void
  8371. {
  8372. bShowHud = value;
  8373. }
  8374.  
  8375. public function DisplayItemRewardNotification( itemName : name, optional quantity : int ) : void
  8376. {
  8377. var hud : CR4ScriptedHud;
  8378. hud = (CR4ScriptedHud)theGame.GetHud();
  8379. hud.OnItemRecivedDuringScene(itemName, quantity);
  8380. }
  8381.  
  8382. function IsNewQuest( questGuid : CGUID ) : bool
  8383. {
  8384. var i : int;
  8385. for(i = 0; i < displayedQuestsGUID.Size(); i += 1 )
  8386. {
  8387. if( displayedQuestsGUID[i] == questGuid )
  8388. {
  8389. return false;
  8390. }
  8391. }
  8392. displayedQuestsGUID.PushBack(questGuid);
  8393. return true;
  8394. }
  8395.  
  8396. function GetRewardMultiplierData( rewardName : name ) : SRewardMultiplier
  8397. {
  8398. var defaultReward : SRewardMultiplier;
  8399. var i : int;
  8400.  
  8401. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  8402. {
  8403. if( rewardsMultiplier[i].rewardName == rewardName )
  8404. {
  8405. return rewardsMultiplier[i];
  8406. }
  8407. }
  8408.  
  8409. defaultReward.rewardName = rewardName;
  8410. defaultReward.rewardMultiplier = 1.0;
  8411. defaultReward.isItemMultiplier = false;
  8412.  
  8413. return defaultReward;
  8414. }
  8415.  
  8416. function GetRewardMultiplier( rewardName : name ) : float
  8417. {
  8418. var i : int;
  8419. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  8420. {
  8421. if( rewardsMultiplier[i].rewardName == rewardName )
  8422. {
  8423. return rewardsMultiplier[i].rewardMultiplier;
  8424. }
  8425. }
  8426. return 1.0;
  8427. }
  8428.  
  8429. function GetRewardMultiplierExists( rewardName : name ) : bool
  8430. {
  8431. var i : int;
  8432. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  8433. {
  8434. if( rewardsMultiplier[i].rewardName == rewardName )
  8435. {
  8436. return true;
  8437. }
  8438. }
  8439. return false;
  8440. }
  8441.  
  8442. function SetRewardMultiplier( rewardName : name, value : float, optional isItemMultiplier : bool ) : void
  8443. {
  8444. var i : int;
  8445. var rewardMultiplier : SRewardMultiplier;
  8446.  
  8447. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  8448. {
  8449. if( rewardsMultiplier[i].rewardName == rewardName )
  8450. {
  8451. rewardsMultiplier[i].rewardMultiplier = value;
  8452. rewardsMultiplier[i].isItemMultiplier = isItemMultiplier;
  8453. return;
  8454. }
  8455. }
  8456.  
  8457. rewardMultiplier.rewardName = rewardName;
  8458. rewardMultiplier.rewardMultiplier = value;
  8459. rewardMultiplier.isItemMultiplier = isItemMultiplier;
  8460.  
  8461. rewardsMultiplier.PushBack(rewardMultiplier);
  8462. }
  8463.  
  8464. function RemoveRewardMultiplier( rewardName : name ) : void
  8465. {
  8466. var i : int;
  8467. for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
  8468. {
  8469. if( rewardsMultiplier[i].rewardName == rewardName )
  8470. {
  8471. rewardsMultiplier.Erase(i);
  8472. return;
  8473. }
  8474. }
  8475. }
  8476.  
  8477.  
  8478.  
  8479.  
  8480.  
  8481.  
  8482.  
  8483. public final function TissueExtractorDischarge() : bool
  8484. {
  8485. var ids : array<SItemUniqueId>;
  8486. var chargesLeft, uses, curr, max, red, blue, green : int;
  8487. var i : int;
  8488. var text : string;
  8489.  
  8490. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  8491. if( ids.Size() == 0 )
  8492. {
  8493. return false;
  8494. }
  8495.  
  8496. curr = GetTissueExtractorChargesCurr();
  8497. max = GetTissueExtractorChargesMax();
  8498.  
  8499. if( curr >= max )
  8500. {
  8501.  
  8502. uses = FloorF( ( ( float ) curr ) / ( ( float ) max ) );
  8503. chargesLeft = Max( 0, curr - uses * max );
  8504.  
  8505.  
  8506. inv.SetItemModifierInt( ids[0], 'charges', chargesLeft );
  8507.  
  8508.  
  8509. blue = 0;
  8510. green = 0;
  8511. red = 0;
  8512. for( i=0; i<uses; i+=1 )
  8513. {
  8514. switch( RandRange( 3 ) )
  8515. {
  8516. case 0:
  8517. blue += 1;
  8518. break;
  8519. case 1:
  8520. green += 1;
  8521. break;
  8522. case 2:
  8523. red += 1;
  8524. }
  8525. }
  8526.  
  8527. text = GetLocStringByKeyExt( "message_q705_extractor_extracted" );
  8528.  
  8529. if( blue > 0 )
  8530. {
  8531. inv.AddAnItem( 'Greater mutagen blue', blue, false, true );
  8532. text += "<br/>" + blue + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen blue' ) );
  8533. }
  8534. if( green > 0 )
  8535. {
  8536. inv.AddAnItem( 'Greater mutagen green', green, false, true );
  8537. text += "<br/>" + green + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen green' ) );
  8538. }
  8539. if( red > 0 )
  8540. {
  8541. inv.AddAnItem( 'Greater mutagen red', red, false, true );
  8542. text += "<br/>" + red + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen red' ) );
  8543. }
  8544.  
  8545.  
  8546. theGame.GetGuiManager().ShowNotification( text );
  8547.  
  8548.  
  8549. inv.SetItemModifierInt( ids[0], 'ui_notified', 0 );
  8550.  
  8551. return true;
  8552. }
  8553. else
  8554. {
  8555.  
  8556. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_q705_extractor_too_few_charges" ) );
  8557. }
  8558.  
  8559. return false;
  8560. }
  8561.  
  8562. public final function TissueExtractorIncCharge()
  8563. {
  8564. var ids : array<SItemUniqueId>;
  8565. var uiData : SInventoryItemUIData;
  8566. var curr : int;
  8567.  
  8568. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  8569. if( ids.Size() == 0 )
  8570. {
  8571. return;
  8572. }
  8573.  
  8574. curr = GetTissueExtractorChargesCurr() + 1;
  8575. inv.SetItemModifierInt( ids[0], 'charges', curr );
  8576.  
  8577.  
  8578. if( curr >= GetTissueExtractorChargesMax() )
  8579. {
  8580. uiData = inv.GetInventoryItemUIData( ids[0] );
  8581. uiData.isNew = true;
  8582. inv.SetInventoryItemUIData( ids[0], uiData );
  8583.  
  8584.  
  8585. if( inv.GetItemModifierInt( ids[0], 'ui_notified', 0 ) == 0 )
  8586. {
  8587. inv.SetItemModifierInt( ids[0], 'ui_notified', 1 );
  8588. theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_q705_extractor_charged" ), , true );
  8589. }
  8590. }
  8591. }
  8592.  
  8593. public final function GetTissueExtractorChargesCurr() : int
  8594. {
  8595. var ids : array<SItemUniqueId>;
  8596.  
  8597. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  8598. if( ids.Size() == 0 )
  8599. {
  8600. return 0;
  8601. }
  8602.  
  8603. return inv.GetItemModifierInt( ids[0], 'charges', 0 );
  8604. }
  8605.  
  8606. public final function GetTissueExtractorChargesMax() : int
  8607. {
  8608. var ids : array<SItemUniqueId>;
  8609. var val : SAbilityAttributeValue;
  8610.  
  8611. ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
  8612. if( ids.Size() == 0 )
  8613. {
  8614. return 0;
  8615. }
  8616.  
  8617. val = inv.GetItemAttributeValue( ids[0], 'maxCharges' );
  8618.  
  8619. return FloorF( val.valueBase );
  8620. }
  8621.  
  8622. public function GetEquippedSword(steel : bool) : SItemUniqueId;
  8623.  
  8624. public final function HasRequiredLevelToEquipItem(item : SItemUniqueId) : bool
  8625. {
  8626. if(HasBuff(EET_WolfHour))
  8627. {
  8628. if((inv.GetItemLevel(item) - 2) > GetLevel() )
  8629. return false;
  8630. }
  8631. else
  8632. {
  8633. if(inv.GetItemLevel(item) > GetLevel() )
  8634. return false;
  8635. }
  8636.  
  8637. return true;
  8638. }
  8639.  
  8640. public function SkillReduceBombAmmoBonus()
  8641. {
  8642. var i, ammo, maxAmmo : int;
  8643. var items : array<SItemUniqueId>;
  8644.  
  8645. items = inv.GetSingletonItems();
  8646.  
  8647. for(i=0; i<items.Size(); i+=1)
  8648. {
  8649. ammo = inv.GetItemModifierInt(items[i], 'ammo_current');
  8650.  
  8651.  
  8652. if(ammo > 0)
  8653. {
  8654. maxAmmo = inv.SingletonItemGetMaxAmmo(items[i]);
  8655.  
  8656.  
  8657. if(ammo > maxAmmo)
  8658. {
  8659. inv.SetItemModifierInt(items[i], 'ammo_current', maxAmmo);
  8660. }
  8661. }
  8662. }
  8663. theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
  8664. }
  8665.  
  8666. public function ConsumeItem( itemId : SItemUniqueId ) : bool
  8667. {
  8668. var params : SCustomEffectParams;
  8669. var buffs : array<SEffectInfo>;
  8670. var i : int;
  8671. var category : name;
  8672. var potionToxicity : float;
  8673.  
  8674. if(!inv.IsIdValid(itemId))
  8675. return false;
  8676.  
  8677.  
  8678. category = inv.GetItemCategory(itemId);
  8679. if(category == 'edibles' || inv.ItemHasTag(itemId, 'Drinks') || ( category == 'alchemy_ingredient' && inv.ItemHasTag(itemId, 'Alcohol')) )
  8680. {
  8681.  
  8682. if(IsFistFightMinigameEnabled())
  8683. {
  8684. DisplayActionDisallowedHudMessage(EIAB_Undefined, false, false, true);
  8685. return false;
  8686. }
  8687.  
  8688.  
  8689. inv.GetItemBuffs(itemId, buffs);
  8690.  
  8691. for(i=0; i<buffs.Size(); i+=1)
  8692. {
  8693. params.effectType = buffs[i].effectType;
  8694. params.creator = this;
  8695. params.sourceName = "edible";
  8696. params.customAbilityName = buffs[i].effectAbilityName;
  8697. AddEffectCustom(params);
  8698. }
  8699.  
  8700.  
  8701. if ( inv.ItemHasTag(itemId, 'Alcohol') )
  8702. {
  8703. potionToxicity = CalculateAttributeValue(inv.GetItemAttributeValue(itemId, 'toxicity'));
  8704. abilityManager.GainStat(BCS_Toxicity, potionToxicity );
  8705. AddEffectDefault(EET_Drunkenness, NULL, inv.GetItemName(itemId));
  8706. }
  8707. PlayItemConsumeSound( itemId );
  8708. }
  8709.  
  8710. if(inv.IsItemFood(itemId))
  8711. FactsAdd("consumed_food_cnt");
  8712.  
  8713.  
  8714. if(!inv.ItemHasTag(itemId, theGame.params.TAG_INFINITE_USE) && !inv.RemoveItem(itemId))
  8715. {
  8716. LogAssert(false,"Failed to remove consumable item from player inventory!" + inv.GetItemName( itemId ) );
  8717. return false;
  8718. }
  8719.  
  8720. return true;
  8721. }
  8722.  
  8723. public function MountVehicle( vehicleEntity : CEntity, mountType : EVehicleMountType, optional vehicleSlot : EVehicleSlot )
  8724. {
  8725. var vehicle : CVehicleComponent;
  8726. vehicle = (CVehicleComponent)(vehicleEntity.GetComponentByClassName('CVehicleComponent'));
  8727.  
  8728. if ( vehicle )
  8729. vehicle.Mount( this, mountType, vehicleSlot );
  8730. }
  8731.  
  8732. public function DismountVehicle( vehicleEntity : CEntity, dismountType : EDismountType )
  8733. {
  8734. var vehicle : CVehicleComponent;
  8735. vehicle = (CVehicleComponent)(vehicleEntity.GetComponentByClassName('CVehicleComponent'));
  8736.  
  8737. if ( vehicle )
  8738. vehicle.IssueCommandToDismount( dismountType );
  8739. }
  8740.  
  8741.  
  8742.  
  8743.  
  8744.  
  8745. protected function ShouldDrainStaminaWhileSprinting() : bool
  8746. {
  8747. if( HasBuff( EET_PolishedGenitals ) && !IsInCombat() && !IsThreatened() )
  8748. {
  8749. return false;
  8750. }
  8751.  
  8752. return super.ShouldDrainStaminaWhileSprinting();
  8753. }
  8754.  
  8755.  
  8756.  
  8757. public function HasStaminaToUseAction(action : EStaminaActionType, optional abilityName : name, optional dt :float, optional multiplier : float) : bool
  8758. {
  8759. var cost : float;
  8760. var ret : bool;
  8761.  
  8762. ret = super.HasStaminaToUseAction(action, abilityName, dt, multiplier);
  8763.  
  8764. if(!ret)
  8765. {
  8766. SetCombatActionHeading( GetHeading() );
  8767.  
  8768. if(multiplier == 0)
  8769. multiplier = 1;
  8770.  
  8771. cost = multiplier * GetStaminaActionCost(action, abilityName, dt);
  8772. SetShowToLowStaminaIndication(cost);
  8773. }
  8774.  
  8775. return ret;
  8776. }
  8777.  
  8778.  
  8779. timer function AbilityManager_FloorStaminaSegment(dt : float, id : int)
  8780. {
  8781. ((W3PlayerAbilityManager)abilityManager).FloorStaminaSegment();
  8782. }
  8783.  
  8784. public function DrainToxicity(amount : float )
  8785. {
  8786. if(abilityManager && abilityManager.IsInitialized() && IsAlive())
  8787. abilityManager.DrainToxicity(amount);
  8788. }
  8789.  
  8790. public function DrainFocus(amount : float )
  8791. {
  8792. if(abilityManager && abilityManager.IsInitialized() && IsAlive())
  8793. abilityManager.DrainFocus(amount);
  8794. }
  8795.  
  8796. public function GetOffenseStat():int
  8797. {
  8798. if(abilityManager && abilityManager.IsInitialized())
  8799. return ((W3PlayerAbilityManager)abilityManager).GetOffenseStat();
  8800.  
  8801. return 0;
  8802. }
  8803.  
  8804. public function GetDefenseStat():int
  8805. {
  8806. if(abilityManager && abilityManager.IsInitialized())
  8807. return ((W3PlayerAbilityManager)abilityManager).GetDefenseStat();
  8808.  
  8809. return 0;
  8810. }
  8811.  
  8812. public function GetSignsStat():float
  8813. {
  8814. if(abilityManager && abilityManager.IsInitialized())
  8815. return ((W3PlayerAbilityManager)abilityManager).GetSignsStat();
  8816.  
  8817. return 0;
  8818. }
  8819.  
  8820.  
  8821.  
  8822.  
  8823.  
  8824. private var inWaterTrigger : bool;
  8825.  
  8826. event OnOceanTriggerEnter()
  8827. {
  8828. inWaterTrigger = true;
  8829. }
  8830.  
  8831. event OnOceanTriggerLeave()
  8832. {
  8833. inWaterTrigger = false;
  8834. }
  8835.  
  8836. public function IsInWaterTrigger() : bool
  8837. {
  8838. return inWaterTrigger;
  8839. }
  8840.  
  8841.  
  8842.  
  8843.  
  8844.  
  8845. public function GetSkillColor(skill : ESkill) : ESkillColor
  8846. {
  8847. if(abilityManager && abilityManager.IsInitialized())
  8848. return ((W3PlayerAbilityManager)abilityManager).GetSkillColor(skill);
  8849.  
  8850. return SC_None;
  8851. }
  8852.  
  8853. public function GetSkillSlotIndexFromSkill(skill : ESkill) : int
  8854. {
  8855. if(abilityManager && abilityManager.IsInitialized())
  8856. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIndexFromSkill(skill);
  8857.  
  8858. return -1;
  8859. }
  8860.  
  8861. public final function GetSkillSlotIndex(slotID : int, checkIfUnlocked : bool) : int
  8862. {
  8863. if(abilityManager && abilityManager.IsInitialized())
  8864. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIndex(slotID, checkIfUnlocked);
  8865.  
  8866. return -1;
  8867. }
  8868.  
  8869. public final function GetSkillSlotIDFromIndex(skillSlotIndex : int) : int
  8870. {
  8871. if(abilityManager && abilityManager.IsInitialized())
  8872. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIDFromIndex(skillSlotIndex);
  8873.  
  8874. return -1;
  8875. }
  8876.  
  8877. public function GetSkillSlotID(skill : ESkill) : int
  8878. {
  8879. if(abilityManager && abilityManager.IsInitialized())
  8880. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotID(skill);
  8881.  
  8882. return -1;
  8883. }
  8884.  
  8885. public function GetSkillGroupBonus(groupID : int) : name
  8886. {
  8887. if(abilityManager && abilityManager.IsInitialized())
  8888. return ((W3PlayerAbilityManager)abilityManager).GetGroupBonus(groupID);
  8889.  
  8890. return '';
  8891. }
  8892.  
  8893. public function GetGroupBonusCount(commonColor : ESkillColor,groupID : int) : int
  8894. {
  8895. if(abilityManager && abilityManager.IsInitialized())
  8896. return ((W3PlayerAbilityManager)abilityManager).GetSkillGroupColorCount(commonColor, groupID);
  8897.  
  8898. return 0;
  8899. }
  8900.  
  8901. public function GetMutagenSlotIDFromGroupID(groupID : int) : int
  8902. {
  8903. if(abilityManager && abilityManager.IsInitialized())
  8904. return ((W3PlayerAbilityManager)abilityManager).GetMutagenSlotIDFromGroupID(groupID);
  8905.  
  8906. return -1;
  8907. }
  8908.  
  8909. public function GetSkillLevel(skill : ESkill) : int
  8910. {
  8911. if(abilityManager && abilityManager.IsInitialized())
  8912. return ((W3PlayerAbilityManager)abilityManager).GetSkillLevel(skill);
  8913.  
  8914. return -1;
  8915. }
  8916.  
  8917. public function GetBoughtSkillLevel(skill : ESkill) : int
  8918. {
  8919. if(abilityManager && abilityManager.IsInitialized())
  8920. return ((W3PlayerAbilityManager)abilityManager).GetBoughtSkillLevel(skill);
  8921.  
  8922. return -1;
  8923. }
  8924.  
  8925. public function AddSkill(skill : ESkill, optional isTemporary : bool)
  8926. {
  8927. if(abilityManager && abilityManager.IsInitialized())
  8928. ((W3PlayerAbilityManager)abilityManager).AddSkill(skill, isTemporary);
  8929. }
  8930.  
  8931. public function AddMultipleSkills(skill : ESkill, optional number : int, optional isTemporary : bool)
  8932. {
  8933. var i : int;
  8934.  
  8935. if(number)
  8936. {
  8937. for( i=0; i<number; i+=1)
  8938. {
  8939. AddSkill(skill,isTemporary);
  8940. }
  8941. }
  8942. else
  8943. {
  8944. AddSkill(skill,isTemporary);
  8945. }
  8946. }
  8947.  
  8948. public function GetSkillAbilityName(skill : ESkill) : name
  8949. {
  8950. if(abilityManager && abilityManager.IsInitialized())
  8951. return ((W3PlayerAbilityManager)abilityManager).GetSkillAbilityName(skill);
  8952.  
  8953. return '';
  8954. }
  8955.  
  8956. public function HasStaminaToUseSkill(skill : ESkill, optional perSec : bool, optional signHack : bool) : bool
  8957. {
  8958. var ret : bool;
  8959. var cost : float;
  8960.  
  8961. cost = GetSkillStaminaUseCost(skill, perSec);
  8962.  
  8963. ret = ( CanUseSkill(skill) && (abilityManager.GetStat(BCS_Stamina, signHack) >= cost) );
  8964.  
  8965.  
  8966. if(!ret && IsSkillSign(skill) && CanUseSkill(S_Perk_09) && GetStat(BCS_Focus) >= 1)
  8967. {
  8968. ret = true;
  8969. }
  8970.  
  8971.  
  8972. if( !ret && IsSkillSign( skill ) && GetWitcherPlayer().HasBuff( EET_GryphonSetBonus ) )
  8973. {
  8974. ret = true;
  8975. }
  8976.  
  8977. if(!ret)
  8978. {
  8979. SetCombatActionHeading( GetHeading() );
  8980. SetShowToLowStaminaIndication(cost);
  8981. }
  8982.  
  8983. return ret;
  8984. }
  8985.  
  8986. protected function GetSkillStaminaUseCost(skill : ESkill, optional perSec : bool) : float
  8987. {
  8988. if(abilityManager && abilityManager.IsInitialized())
  8989. return ((W3PlayerAbilityManager)abilityManager).GetSkillStaminaUseCost(skill, perSec);
  8990.  
  8991. return 0;
  8992. }
  8993.  
  8994.  
  8995. public function GetSkillAttributeValue(skill : ESkill, attributeName : name, addBaseCharAttribute : bool, addSkillModsAttribute : bool) : SAbilityAttributeValue
  8996. {
  8997. var null : SAbilityAttributeValue;
  8998.  
  8999. if(abilityManager && abilityManager.IsInitialized())
  9000. return abilityManager.GetSkillAttributeValue(SkillEnumToName(skill), attributeName, addBaseCharAttribute, addSkillModsAttribute);
  9001.  
  9002. return null;
  9003. }
  9004.  
  9005. public function GetSkillLocalisationKeyName(skill : ESkill) : string
  9006. {
  9007. if(abilityManager && abilityManager.IsInitialized())
  9008. return ((W3PlayerAbilityManager)abilityManager).GetSkillLocalisationKeyName(skill);
  9009.  
  9010. return "";
  9011. }
  9012.  
  9013. public function GetSkillLocalisationKeyDescription(skill : ESkill) : string
  9014. {
  9015. if(abilityManager && abilityManager.IsInitialized())
  9016. return ((W3PlayerAbilityManager)abilityManager).GetSkillLocalisationKeyDescription(skill);
  9017.  
  9018. return "";
  9019. }
  9020.  
  9021. public function GetSkillIconPath(skill : ESkill) : string
  9022. {
  9023. if(abilityManager && abilityManager.IsInitialized())
  9024. return ((W3PlayerAbilityManager)abilityManager).GetSkillIconPath(skill);
  9025.  
  9026. return "";
  9027. }
  9028.  
  9029. public function HasLearnedSkill(skill : ESkill) : bool
  9030. {
  9031. if(abilityManager && abilityManager.IsInitialized())
  9032. return ((W3PlayerAbilityManager)abilityManager).HasLearnedSkill(skill);
  9033.  
  9034. return false;
  9035. }
  9036.  
  9037. public function IsSkillEquipped(skill : ESkill) : bool
  9038. {
  9039. if(abilityManager && abilityManager.IsInitialized())
  9040. return ((W3PlayerAbilityManager)abilityManager).IsSkillEquipped(skill);
  9041.  
  9042. return false;
  9043. }
  9044.  
  9045. public function CanUseSkill(skill : ESkill) : bool
  9046. {
  9047. if(abilityManager && abilityManager.IsInitialized())
  9048. return ((W3PlayerAbilityManager)abilityManager).CanUseSkill(skill);
  9049.  
  9050. return false;
  9051. }
  9052.  
  9053. public function CanLearnSkill(skill : ESkill) : bool
  9054. {
  9055. if(abilityManager && abilityManager.IsInitialized())
  9056. return ((W3PlayerAbilityManager)abilityManager).CanLearnSkill(skill);
  9057.  
  9058. return false;
  9059. }
  9060.  
  9061. public function HasSpentEnoughPoints(skill : ESkill) : bool
  9062. {
  9063. if(abilityManager && abilityManager.IsInitialized())
  9064. return ((W3PlayerAbilityManager)abilityManager).HasSpentEnoughPoints(skill);
  9065.  
  9066. return false;
  9067. }
  9068.  
  9069. public function PathPointsForSkillsPath(skill : ESkill) : int
  9070. {
  9071. if(abilityManager && abilityManager.IsInitialized())
  9072. return ((W3PlayerAbilityManager)abilityManager).PathPointsSpentInSkillPathOfSkill(skill);
  9073.  
  9074. return -1;
  9075. }
  9076.  
  9077. public function GetPlayerSkills() : array<SSkill>
  9078. {
  9079. var null : array<SSkill>;
  9080.  
  9081. if(abilityManager && abilityManager.IsInitialized())
  9082. return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkills();
  9083.  
  9084. return null;
  9085. }
  9086.  
  9087. public function GetPlayerSkill(s : ESkill) : SSkill
  9088. {
  9089. var null : SSkill;
  9090.  
  9091. if(abilityManager && abilityManager.IsInitialized())
  9092. return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkill(s);
  9093.  
  9094. return null;
  9095. }
  9096.  
  9097. public function GetSkillSubPathType(s : ESkill) : ESkillSubPath
  9098. {
  9099. if(abilityManager && abilityManager.IsInitialized())
  9100. return ((W3PlayerAbilityManager)abilityManager).GetSkillSubPathType(s);
  9101.  
  9102. return ESSP_NotSet;
  9103. }
  9104.  
  9105. public function GetSkillSlotsCount() : int
  9106. {
  9107. if(abilityManager && abilityManager.IsInitialized())
  9108. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotsCount();
  9109.  
  9110. return 0;
  9111. }
  9112.  
  9113. public function GetSkillSlots() : array<SSkillSlot>
  9114. {
  9115. var null : array<SSkillSlot>;
  9116.  
  9117. if(abilityManager && abilityManager.IsInitialized())
  9118. return ((W3PlayerAbilityManager)abilityManager).GetSkillSlots();
  9119.  
  9120. return null;
  9121. }
  9122.  
  9123. public function GetPlayerSkillMutagens() : array<SMutagenSlot>
  9124. {
  9125. var null : array<SMutagenSlot>;
  9126.  
  9127. if(abilityManager && abilityManager.IsInitialized())
  9128. return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkillMutagens();
  9129.  
  9130. return null;
  9131. }
  9132.  
  9133.  
  9134.  
  9135.  
  9136. public function BlockSkill(skill : ESkill, block : bool, optional cooldown : float) : bool
  9137. {
  9138. if(abilityManager && abilityManager.IsInitialized())
  9139. return ((W3PlayerAbilityManager)abilityManager).BlockSkill(skill, block, cooldown);
  9140.  
  9141. return false;
  9142. }
  9143.  
  9144. public function IsSkillBlocked(skill : ESkill) : bool
  9145. {
  9146. if(abilityManager && abilityManager.IsInitialized())
  9147. return ((W3PlayerAbilityManager)abilityManager).IsSkillBlocked(skill);
  9148.  
  9149. return false;
  9150. }
  9151.  
  9152.  
  9153. public function EquipSkill(skill : ESkill, slotID : int) : bool
  9154. {
  9155. var ret : bool;
  9156. var groupID : int;
  9157. var pam : W3PlayerAbilityManager;
  9158.  
  9159. if(abilityManager && abilityManager.IsInitialized())
  9160. {
  9161. pam = (W3PlayerAbilityManager)abilityManager;
  9162. ret = pam.EquipSkill(skill, slotID);
  9163. if(ret)
  9164. {
  9165. groupID = pam.GetSkillGroupIdFromSkillSlotId(slotID);
  9166. LogSkillColors("Equipped <<" + GetSkillColor(skill) + ">> skill <<" + skill + ">> to group <<" + groupID + ">>");
  9167. LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
  9168. LogSkillColors("");
  9169. }
  9170.  
  9171. return ret;
  9172. }
  9173.  
  9174. return false;
  9175. }
  9176.  
  9177.  
  9178. public function UnequipSkill(slotID : int) : bool
  9179. {
  9180. var ret : bool;
  9181. var groupID : int;
  9182. var skill : ESkill;
  9183. var pam : W3PlayerAbilityManager;
  9184.  
  9185. if(abilityManager && abilityManager.IsInitialized())
  9186. {
  9187. pam = (W3PlayerAbilityManager)abilityManager;
  9188. GetSkillOnSlot(slotID, skill);
  9189. ret = pam.UnequipSkill(slotID);
  9190. if(ret)
  9191. {
  9192. groupID = pam.GetSkillGroupIdFromSkillSlotId(slotID);
  9193. LogSkillColors("Unequipped <<" + GetSkillColor(skill) + ">> skill <<" + skill + ">> from group <<" + groupID + ">>");
  9194. LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
  9195. LogSkillColors("");
  9196. }
  9197. return ret;
  9198. }
  9199.  
  9200. return false;
  9201. }
  9202.  
  9203.  
  9204. public function GetSkillOnSlot(slotID : int, out skill : ESkill) : bool
  9205. {
  9206. if(abilityManager && abilityManager.IsInitialized())
  9207. return ((W3PlayerAbilityManager)abilityManager).GetSkillOnSlot(slotID, skill);
  9208.  
  9209. skill = S_SUndefined;
  9210. return false;
  9211. }
  9212.  
  9213.  
  9214. public function GetFreeSkillSlot() : int
  9215. {
  9216. var i, size : int;
  9217. var skill : ESkill;
  9218.  
  9219. size = ((W3PlayerAbilityManager)abilityManager).GetSkillSlotsCount();
  9220. for(i=1; i<size; i+=1)
  9221. {
  9222. if(!GetSkillOnSlot(i, skill))
  9223. continue;
  9224.  
  9225. if(skill == S_SUndefined)
  9226. return i;
  9227. }
  9228.  
  9229. return -1;
  9230. }
  9231.  
  9232.  
  9233.  
  9234.  
  9235.  
  9236.  
  9237. protected function Attack( hitTarget : CGameplayEntity, animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float, weaponEntity : CItemEntity)
  9238. {
  9239. var attackAction : W3Action_Attack;
  9240.  
  9241. if(!PrepareAttackAction(hitTarget, animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime, weaponEntity, attackAction))
  9242. return;
  9243.  
  9244. if ( attackAction.IsParried() && ( ((CNewNPC)attackAction.victim).IsShielded(attackAction.attacker) || ((CNewNPC)attackAction.victim).SignalGameplayEventReturnInt('IsDefending',0) == 1 ) )
  9245. {
  9246. thePlayer.SetCanPlayHitAnim(true);
  9247. thePlayer.ReactToReflectedAttack(attackAction.victim);
  9248. }
  9249.  
  9250. theTelemetry.LogWithLabel( TE_FIGHT_PLAYER_ATTACKS, attackAction.GetAttackName() );
  9251.  
  9252.  
  9253. theGame.damageMgr.ProcessAction(attackAction);
  9254.  
  9255. delete attackAction;
  9256. }
  9257.  
  9258. public function IsHeavyAttack(attackName : name) : bool
  9259. {
  9260. var skill : ESkill;
  9261. var sup : bool;
  9262.  
  9263. sup = super.IsHeavyAttack(attackName);
  9264. if(sup)
  9265. return true;
  9266.  
  9267. if ( attackName == 'attack_heavy_special' )
  9268. return true;
  9269.  
  9270. skill = SkillNameToEnum(attackName);
  9271.  
  9272. return skill == S_Sword_2 || skill == S_Sword_s02;
  9273. }
  9274.  
  9275. public function IsLightAttack(attackName : name) : bool
  9276. {
  9277. var skill : ESkill;
  9278. var sup : bool;
  9279.  
  9280. sup = super.IsLightAttack(attackName);
  9281. if(sup)
  9282. return true;
  9283.  
  9284. skill = SkillNameToEnum(attackName);
  9285.  
  9286. return skill == S_Sword_1 || skill == S_Sword_s01;
  9287. }
  9288.  
  9289. public final function ProcessWeaponCollision()
  9290. {
  9291. var l_stateName : name;
  9292.  
  9293. var l_weaponPosition : Vector;
  9294. var l_weaponTipPos : Vector;
  9295. var l_collidingPosition : Vector;
  9296. var l_offset : Vector;
  9297. var l_normal : Vector;
  9298.  
  9299. var l_slotMatrix : Matrix;
  9300.  
  9301. var l_distance : float;
  9302.  
  9303. var l_materialName : name;
  9304. var l_hitComponent : CComponent;
  9305. var l_destructibleCmp : CDestructionSystemComponent;
  9306. var barrel : COilBarrelEntity;
  9307.  
  9308.  
  9309.  
  9310. if( isCurrentlyDodging )
  9311. return;
  9312.  
  9313. l_stateName = GetCurrentStateName();
  9314.  
  9315. if( !attackEventInProgress && l_stateName == 'CombatFists' )
  9316. return;
  9317.  
  9318. CalcEntitySlotMatrix('r_weapon', l_slotMatrix);
  9319.  
  9320. l_weaponPosition = MatrixGetTranslation( l_slotMatrix );
  9321.  
  9322.  
  9323. switch( l_stateName )
  9324. {
  9325. case 'CombatFists':
  9326. l_offset = MatrixGetAxisX( l_slotMatrix );
  9327. l_offset = VecNormalize( l_offset ) * 0.25f;
  9328. break;
  9329.  
  9330. default:
  9331. l_offset = MatrixGetAxisZ( l_slotMatrix );
  9332. l_offset = VecNormalize( l_offset ) * 1.f;
  9333. break;
  9334. }
  9335.  
  9336. l_weaponTipPos = l_weaponPosition + l_offset;
  9337.  
  9338.  
  9339.  
  9340. if( !attackEventInProgress )
  9341. {
  9342.  
  9343. if( m_LastWeaponTipPos == Vector ( 0, 0, 0 ) )
  9344. l_distance = 0;
  9345. else
  9346. l_distance = VecDistance( l_weaponTipPos, m_LastWeaponTipPos ) ;
  9347.  
  9348.  
  9349.  
  9350.  
  9351. m_LastWeaponTipPos = l_weaponTipPos;
  9352. if( l_distance < 0.35f )
  9353. return;
  9354.  
  9355. }
  9356.  
  9357.  
  9358.  
  9359. m_LastWeaponTipPos = l_weaponTipPos;
  9360.  
  9361. if ( !theGame.GetWorld().StaticTraceWithAdditionalInfo( l_weaponPosition, l_weaponTipPos, l_collidingPosition, l_normal, l_materialName, l_hitComponent, m_WeaponFXCollisionGroupNames ) )
  9362. {
  9363.  
  9364. if( l_stateName == 'CombatFists' )
  9365. {
  9366. CalcEntitySlotMatrix('l_weapon', l_slotMatrix);
  9367. l_weaponPosition = MatrixGetTranslation( l_slotMatrix );
  9368. l_offset = MatrixGetAxisX( l_slotMatrix );
  9369. l_offset = VecNormalize( l_offset ) * 0.25f;
  9370. l_weaponTipPos = l_weaponPosition + l_offset;
  9371. if( !theGame.GetWorld().StaticTrace( l_weaponPosition, l_weaponTipPos, l_collidingPosition, l_normal, m_WeaponFXCollisionGroupNames ) )
  9372. {
  9373. return;
  9374. }
  9375. }
  9376. else
  9377. {
  9378. return;
  9379. }
  9380. }
  9381.  
  9382. if( !m_CollisionEffect )
  9383. {
  9384. m_CollisionEffect = theGame.CreateEntity( m_CollisionFxTemplate, l_collidingPosition, EulerAngles(0,0,0) );
  9385. }
  9386.  
  9387. m_CollisionEffect.Teleport( l_collidingPosition );
  9388.  
  9389.  
  9390. switch( l_stateName )
  9391. {
  9392. case 'CombatFists':
  9393. m_CollisionEffect.PlayEffect('fist');
  9394. break;
  9395. default:
  9396.  
  9397. if( m_RefreshWeaponFXType )
  9398. {
  9399. m_PlayWoodenFX = IsSwordWooden();
  9400. m_RefreshWeaponFXType = false;
  9401. }
  9402.  
  9403. if( m_PlayWoodenFX )
  9404. {
  9405. m_CollisionEffect.PlayEffect('wood');
  9406. }
  9407. else
  9408. {
  9409. switch( l_materialName )
  9410. {
  9411. case 'wood_hollow':
  9412. case 'wood_debris':
  9413. case 'wood_solid':
  9414. m_CollisionEffect.PlayEffect('wood');
  9415. break;
  9416. case 'dirt_hard':
  9417. case 'dirt_soil':
  9418. case 'hay':
  9419. m_CollisionEffect.PlayEffect('fist');
  9420. break;
  9421. case 'stone_debris':
  9422. case 'stone_solid':
  9423. case 'clay_tile':
  9424. case 'gravel_large':
  9425. case 'gravel_small':
  9426. case 'metal':
  9427. case 'custom_sword':
  9428. m_CollisionEffect.PlayEffect('sparks');
  9429. break;
  9430. case 'flesh':
  9431. m_CollisionEffect.PlayEffect('blood');
  9432. break;
  9433. default:
  9434. m_CollisionEffect.PlayEffect('wood');
  9435. break;
  9436. }
  9437.  
  9438. }
  9439. break;
  9440. }
  9441.  
  9442.  
  9443. if(l_hitComponent)
  9444. {
  9445. barrel = (COilBarrelEntity)l_hitComponent.GetEntity();
  9446. if(barrel)
  9447. {
  9448. barrel.OnFireHit(NULL);
  9449. return;
  9450. }
  9451. }
  9452.  
  9453.  
  9454. l_destructibleCmp = (CDestructionSystemComponent) l_hitComponent;
  9455. if( l_destructibleCmp && l_stateName != 'CombatFists' )
  9456. {
  9457. l_destructibleCmp.ApplyFracture();
  9458. }
  9459.  
  9460.  
  9461.  
  9462. }
  9463.  
  9464. public function ReactToReflectedAttack( target : CGameplayEntity)
  9465. {
  9466.  
  9467. var hp, dmg : float;
  9468. var action : W3DamageAction;
  9469.  
  9470. super.ReactToReflectedAttack(target);
  9471.  
  9472.  
  9473. theGame.VibrateControllerLight();
  9474. }
  9475.  
  9476.  
  9477.  
  9478.  
  9479.  
  9480.  
  9481. function GetFallDist( out fallDist : float ) : bool
  9482. {
  9483. var fallDiff, jumpTotalDiff : float;
  9484.  
  9485.  
  9486. substateManager.m_SharedDataO.CalculateFallingHeights( fallDiff, jumpTotalDiff );
  9487.  
  9488. if ( fallDiff <= 0 )
  9489. return false;
  9490.  
  9491. fallDist = fallDiff;
  9492. return true;
  9493. }
  9494.  
  9495. function ApplyFallingDamage(heightDiff : float, optional reducing : bool) : float
  9496. {
  9497. var hpPerc : float;
  9498. var tut : STutorialMessage;
  9499.  
  9500. if ( IsSwimming() || FactsQuerySum("block_falling_damage") >= 1 )
  9501. return 0.0f;
  9502.  
  9503. hpPerc = super.ApplyFallingDamage( heightDiff, reducing );
  9504.  
  9505. if(hpPerc > 0)
  9506. {
  9507. theGame.VibrateControllerHard();
  9508.  
  9509. if(IsAlive())
  9510. {
  9511. if(ShouldProcessTutorial('TutorialFallingDamage'))
  9512. {
  9513. FactsSet( "tutorial_falling_damage", 1 );
  9514. }
  9515.  
  9516. if(FactsQuerySum("tutorial_falling_damage") > 1 && ShouldProcessTutorial('TutorialFallingRoll'))
  9517. {
  9518.  
  9519. tut.type = ETMT_Hint;
  9520. tut.tutorialScriptTag = 'TutorialFallingRoll';
  9521. tut.hintPositionType = ETHPT_DefaultGlobal;
  9522. tut.hintDurationType = ETHDT_Long;
  9523. tut.canBeShownInMenus = false;
  9524. tut.glossaryLink = false;
  9525. tut.markAsSeenOnShow = true;
  9526.  
  9527.  
  9528. theGame.GetTutorialSystem().DisplayTutorial(tut);
  9529. }
  9530. }
  9531. }
  9532.  
  9533. return hpPerc;
  9534. }
  9535.  
  9536.  
  9537.  
  9538. public function SetShowToLowStaminaIndication( value : float ) : void
  9539. {
  9540. fShowToLowStaminaIndication = value;
  9541. }
  9542.  
  9543. public function GetShowToLowStaminaIndication() : float
  9544. {
  9545. return fShowToLowStaminaIndication;
  9546. }
  9547.  
  9548. public final function IndicateTooLowAdrenaline()
  9549. {
  9550. SoundEvent("gui_no_adrenaline");
  9551. showTooLowAdrenaline = true;
  9552. }
  9553.  
  9554.  
  9555.  
  9556. protected function GotoCombatStateWithAction( initialAction : EInitialAction, optional initialBuff : CBaseGameplayEffect )
  9557. {
  9558. if ( this.GetCurrentActionType() == ActorAction_Exploration )
  9559. ActionCancelAll();
  9560.  
  9561. ((W3PlayerWitcherStateCombatFists)this.GetState('CombatFists')).SetupState( initialAction, initialBuff );
  9562. this.GotoState( 'CombatFists' );
  9563.  
  9564. }
  9565.  
  9566.  
  9567. public function IsThreat( actor : CActor, optional usePrecalcs : bool ) : bool
  9568. {
  9569. var npc : CNewNPC;
  9570. var dist : float;
  9571. var targetCapsuleHeight : float;
  9572. var isDistanceExpanded : bool;
  9573. var distanceToTarget : float;
  9574. var attitude : EAIAttitude;
  9575.  
  9576. if (!actor)
  9577. {
  9578. return false;
  9579. }
  9580.  
  9581. if ( finishableEnemiesList.Contains( actor ) )
  9582. {
  9583. return true;
  9584. }
  9585.  
  9586. if ( !actor.IsAlive() || actor.IsKnockedUnconscious() )
  9587. {
  9588. return false;
  9589. }
  9590.  
  9591. npc = (CNewNPC)actor;
  9592. if (npc && npc.IsHorse() )
  9593. {
  9594. return false;
  9595. }
  9596.  
  9597. if ( hostileEnemies.Contains( actor ) )
  9598. {
  9599. return true;
  9600. }
  9601.  
  9602.  
  9603. if ( GetAttitudeBetween( this, actor ) == AIA_Hostile )
  9604. {
  9605. if ( usePrecalcs )
  9606. {
  9607. distanceToTarget = Distance2DBetweenCapsuleAndPoint( actor, this ) - targetingPrecalcs.playerRadius;
  9608. }
  9609. else
  9610. {
  9611. distanceToTarget = Distance2DBetweenCapsules( this, actor );
  9612. }
  9613.  
  9614.  
  9615. if ( distanceToTarget < findMoveTargetDist + 5.0f )
  9616. {
  9617. return true;
  9618. }
  9619.  
  9620. if ( actor.IsInCombat() || this.IsHardLockEnabled() )
  9621. {
  9622. targetCapsuleHeight = ( (CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent() ).GetCapsuleHeight();
  9623. if ( targetCapsuleHeight >= 2.0f || npc.GetCurrentStance() == NS_Fly )
  9624. {
  9625.  
  9626. if ( distanceToTarget < 40.0f )
  9627. {
  9628. return true;
  9629. }
  9630. }
  9631. }
  9632. }
  9633.  
  9634. if ( actor.GetAttitudeGroup() == 'npc_charmed' )
  9635. {
  9636. if ( theGame.GetGlobalAttitude( GetBaseAttitudeGroup(), actor.GetBaseAttitudeGroup() ) == AIA_Hostile )
  9637. {
  9638. return true;
  9639. }
  9640. }
  9641.  
  9642. return false;
  9643. }
  9644.  
  9645. function SetBIsCombatActionAllowed ( flag : bool )
  9646. {
  9647. bIsCombatActionAllowed = flag;
  9648.  
  9649. if ( !flag )
  9650. {
  9651. SetBIsInCombatAction(true);
  9652. }
  9653. else
  9654. {
  9655. this.ProcessLAxisCaching();
  9656.  
  9657. }
  9658.  
  9659.  
  9660. }
  9661.  
  9662. function GetBIsCombatActionAllowed() : bool
  9663. {
  9664. return bIsCombatActionAllowed;
  9665. }
  9666.  
  9667. function SetCombatAction( action : EBufferActionType )
  9668. {
  9669. currentCombatAction = action;
  9670. }
  9671.  
  9672. function GetCombatAction() : EBufferActionType
  9673. {
  9674. return currentCombatAction;
  9675. }
  9676.  
  9677. protected function WhenCombatActionIsFinished()
  9678. {
  9679. if(IsThrowingItem() || IsThrowingItemWithAim() )
  9680. {
  9681. if(inv.IsItemBomb(selectedItemId))
  9682. {
  9683. BombThrowAbort();
  9684. }
  9685. else
  9686. {
  9687. ThrowingAbort();
  9688. }
  9689. }
  9690.  
  9691. if ( this.GetCurrentStateName() != 'DismountHorse' )
  9692. OnRangedForceHolster( true );
  9693.  
  9694.  
  9695. }
  9696.  
  9697. public function IsInCombatAction_Attack(): bool
  9698. {
  9699. if ( IsInCombatAction_NonSpecialAttack() || IsInCombatAction_SpecialAttack() )
  9700. return true;
  9701. else
  9702. return false;
  9703. }
  9704.  
  9705. public function IsInCombatAction_NonSpecialAttack(): bool
  9706. {
  9707. if ( IsInCombatAction() && ( GetCombatAction() == EBAT_LightAttack || GetCombatAction() == EBAT_HeavyAttack ) )
  9708. return true;
  9709. else
  9710. return false;
  9711. }
  9712.  
  9713. public function IsInSpecificCombatAction ( specificCombatAction : EBufferActionType ) : bool
  9714. {
  9715. if ( IsInCombatAction() && GetCombatAction() == specificCombatAction )
  9716. return true;
  9717. else
  9718. return false;
  9719. }
  9720.  
  9721. public function IsInRunAnimation() : bool
  9722. {
  9723. return isInRunAnimation;
  9724. }
  9725.  
  9726.  
  9727. public function SetCombatIdleStance( stance : float )
  9728. {
  9729. SetBehaviorVariable( 'combatIdleStance', stance );
  9730. SetBehaviorVariable( 'CombatStanceForOverlay', stance );
  9731.  
  9732. if ( stance == 0.f )
  9733. LogChannel( 'ComboInput', "combatIdleStance = Left" );
  9734. else
  9735. LogChannel( 'ComboInput', "combatIdleStance = Right" );
  9736. }
  9737.  
  9738. public function GetCombatIdleStance() : float
  9739. {
  9740.  
  9741. return GetBehaviorVariable( 'combatIdleStance' );
  9742. }
  9743.  
  9744. protected var isRotatingInPlace : bool;
  9745. event OnRotateInPlaceStart()
  9746. {
  9747. isRotatingInPlace = true;
  9748. }
  9749.  
  9750. event OnRotateInPlaceEnd()
  9751. {
  9752. isRotatingInPlace = false;
  9753. }
  9754.  
  9755. event OnFullyBlendedIdle()
  9756. {
  9757. if ( bLAxisReleased )
  9758. {
  9759. ResetRawPlayerHeading();
  9760. ResetCachedRawPlayerHeading();
  9761. defaultLocomotionController.ResetMoveDirection();
  9762. }
  9763. }
  9764.  
  9765. private var isInIdle : bool;
  9766.  
  9767. event OnPlayerIdleStart()
  9768. {
  9769. isInIdle = true;
  9770. }
  9771.  
  9772. event OnPlayerIdleEnd()
  9773. {
  9774. isInIdle = false;
  9775. }
  9776.  
  9777. public function IsInIdle() : bool
  9778. {
  9779. return isInIdle;
  9780. }
  9781.  
  9782. event OnRunLoopStart()
  9783. {
  9784. EnableRunCamera( true );
  9785. }
  9786.  
  9787. event OnRunLoopEnd()
  9788. {
  9789. EnableRunCamera( false );
  9790. }
  9791.  
  9792. event OnCombatActionStartBehgraph()
  9793. {
  9794. var action : EBufferActionType;
  9795. var cost, delay : float;
  9796.  
  9797.  
  9798.  
  9799.  
  9800. OnCombatActionStart();
  9801.  
  9802. action = PerformingCombatAction();
  9803. switch ( action )
  9804. {
  9805. case EBAT_LightAttack :
  9806. {
  9807. abilityManager.GetStaminaActionCost(ESAT_LightAttack, cost, delay);
  9808. } break;
  9809. case EBAT_HeavyAttack :
  9810. {
  9811. abilityManager.GetStaminaActionCost(ESAT_HeavyAttack, cost, delay);
  9812. } break;
  9813. case EBAT_ItemUse :
  9814. {
  9815. abilityManager.GetStaminaActionCost(ESAT_UsableItem, cost, delay);
  9816. } break;
  9817. case EBAT_Parry :
  9818. {
  9819. abilityManager.GetStaminaActionCost(ESAT_Parry, cost, delay);
  9820. } break;
  9821. case EBAT_Dodge :
  9822. {
  9823. abilityManager.GetStaminaActionCost(ESAT_Dodge, cost, delay);
  9824. } break;
  9825. case EBAT_Roll :
  9826. abilityManager.GetStaminaActionCost(ESAT_Roll, cost, delay);
  9827. break;
  9828. case EBAT_SpecialAttack_Light :
  9829. {
  9830. abilityManager.GetStaminaActionCost(ESAT_Ability, cost, delay, 0,0, GetSkillAbilityName(S_Sword_s01));
  9831. } break;
  9832. case EBAT_SpecialAttack_Heavy :
  9833. {
  9834. abilityManager.GetStaminaActionCost(ESAT_Ability, cost, delay, 0,0, GetSkillAbilityName(S_Sword_s02));
  9835. } break;
  9836. case EBAT_Roll :
  9837. {
  9838. abilityManager.GetStaminaActionCost(ESAT_Evade, cost, delay);
  9839. } break;
  9840.  
  9841. default :
  9842. ;
  9843. }
  9844.  
  9845.  
  9846.  
  9847. if( delay > 0 )
  9848. PauseStaminaRegen( 'InsideCombatAction' );
  9849. }
  9850.  
  9851. public function HolsterUsableItem() : bool
  9852. {
  9853. return holsterUsableItem;
  9854. }
  9855.  
  9856. private var isInGuardedState : bool;
  9857. public function IsInGuardedState() : bool
  9858. {
  9859. return isInGuardedState;
  9860. }
  9861.  
  9862. event OnGuardedStart()
  9863. {
  9864. isInParryOrCounter = true;
  9865. isInGuardedState = true;
  9866. }
  9867.  
  9868. event OnGuardedEnd()
  9869. {
  9870. isInParryOrCounter = false;
  9871. isInGuardedState = false;
  9872. }
  9873.  
  9874. private var restoreUsableItem : bool;
  9875. private var holsterUsableItem : bool;
  9876. event OnCombatActionStart()
  9877. {
  9878.  
  9879.  
  9880. BlockAction( EIAB_UsableItem, 'OnCombatActionStart' );
  9881. BlockAction( EIAB_CallHorse, 'OnCombatActionStart' );
  9882.  
  9883.  
  9884.  
  9885. LogChannel('combatActionAllowed',"FALSE OnCombatActionStart");
  9886. SetBIsCombatActionAllowed( false );
  9887. SetBIsInputAllowed( false, 'OnCombatActionStart' );
  9888.  
  9889.  
  9890. ClearFinishableEnemyList( 0.f, 0 );
  9891.  
  9892. bIsInHitAnim = false;
  9893.  
  9894.  
  9895.  
  9896. if ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  9897. {
  9898. CleanCombatActionBuffer();
  9899. SetIsAimingCrossbow( false );
  9900. OnRangedForceHolster( false, true );
  9901. }
  9902.  
  9903.  
  9904. holsterUsableItem = false;
  9905. if ( thePlayer.IsHoldingItemInLHand() )
  9906. {
  9907. if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign )
  9908. holsterUsableItem = true;
  9909. else if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
  9910. {
  9911. if ( this.GetCurrentStateName() == 'CombatFists' )
  9912. holsterUsableItem = true;
  9913. }
  9914. }
  9915.  
  9916. if ( holsterUsableItem )
  9917. {
  9918. thePlayer.SetPlayerActionToRestore ( PATR_None );
  9919. thePlayer.OnUseSelectedItem( true );
  9920.  
  9921. restoreUsableItem = true;
  9922. }
  9923.  
  9924.  
  9925. if ( GetBehaviorVariable( 'combatActionType' ) != (int)CAT_Attack && GetBehaviorVariable( 'combatActionType' ) != (int)CAT_PreAttack )
  9926. {
  9927. RemoveTimer( 'ProcessAttackTimer' );
  9928. RemoveTimer( 'AttackTimerEnd' );
  9929. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  9930. }
  9931. else
  9932. {
  9933.  
  9934. BlockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  9935. }
  9936.  
  9937.  
  9938. }
  9939.  
  9940. var isInParryOrCounter : bool;
  9941. event OnParryOrCounterStart()
  9942. {
  9943. isInParryOrCounter = true;
  9944. OnCombatActionStartBehgraph();
  9945. }
  9946.  
  9947. event OnParryOrCounterEnd()
  9948. {
  9949. isInParryOrCounter = false;
  9950. OnCombatActionEnd();
  9951. SetBIsInCombatAction( false );
  9952. }
  9953.  
  9954.  
  9955. event OnCombatActionEnd()
  9956. {
  9957. var item : SItemUniqueId;
  9958. var combatActionType : float;
  9959.  
  9960. super.OnCombatActionEnd();
  9961.  
  9962.  
  9963.  
  9964. BlockAllActions( 'OnCombatActionStart', false );
  9965.  
  9966. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  9967.  
  9968.  
  9969. UnblockAction( EIAB_Movement, 'CombatActionFriendly' );
  9970.  
  9971.  
  9972.  
  9973.  
  9974. oTCameraOffset = 0.f;
  9975. oTCameraPitchOffset = 0.f;
  9976.  
  9977.  
  9978. SetBIsCombatActionAllowed( true );
  9979.  
  9980.  
  9981. SetBIsInputAllowed( true, 'OnCombatActionEnd' );
  9982. SetCanPlayHitAnim( true );
  9983. EnableFindTarget( true );
  9984.  
  9985.  
  9986.  
  9987.  
  9988. SetFinisherVictim( NULL );
  9989.  
  9990. OnBlockAllCombatTickets( false );
  9991.  
  9992. LogStamina("CombatActionEnd");
  9993.  
  9994.  
  9995.  
  9996. SetAttackActionName('');
  9997. combatActionType = GetBehaviorVariable('combatActionType');
  9998.  
  9999.  
  10000. if(GetBehaviorVariable('combatActionType') == (int)CAT_SpecialAttack)
  10001. {
  10002. theGame.GetGameCamera().StopAnimation( 'camera_shake_loop_lvl1_1' );
  10003. OnSpecialAttackHeavyActionProcess();
  10004. }
  10005.  
  10006. substateManager.ReactToChanceToFallAndSlide();
  10007. }
  10008.  
  10009. event OnCombatActionFriendlyStart()
  10010. {
  10011. SetBIsInCombatActionFriendly(true);
  10012. BlockAction( EIAB_Movement, 'CombatActionFriendly', false, false, false );
  10013. OnCombatActionStart();
  10014. }
  10015.  
  10016. event OnCombatActionFriendlyEnd()
  10017. {
  10018. SetBIsInCombatActionFriendly(false);
  10019. UnblockAction( EIAB_Movement, 'CombatActionFriendly' );
  10020. OnCombatActionEnd();
  10021. SetBIsInCombatAction(false);
  10022.  
  10023. }
  10024.  
  10025. event OnHitStart()
  10026. {
  10027. var timeLeft : float;
  10028. var currentEffects : array<CBaseGameplayEffect>;
  10029. var none : SAbilityAttributeValue;
  10030.  
  10031. CancelHoldAttacks();
  10032. WhenCombatActionIsFinished();
  10033. if ( isInFinisher )
  10034. {
  10035. if ( finisherTarget )
  10036. ( (CNewNPC)finisherTarget ).SignalGameplayEvent( 'FinisherInterrupt' );
  10037. isInFinisher = false;
  10038. finisherTarget = NULL;
  10039. SetBIsCombatActionAllowed( true );
  10040. }
  10041.  
  10042. bIsInHitAnim = true;
  10043.  
  10044. OnCombatActionStart();
  10045.  
  10046.  
  10047. ResumeStaminaRegen( 'InsideCombatAction' );
  10048.  
  10049. if( GetHealthPercents() < 0.3f )
  10050. {
  10051. PlayBattleCry('BattleCryBadSituation', 0.10f, true );
  10052. }
  10053. else
  10054. {
  10055. PlayBattleCry('BattleCryBadSituation', 0.05f, true );
  10056. }
  10057. }
  10058.  
  10059. event OnHitStartSwimming()
  10060. {
  10061. OnRangedForceHolster( true, true, false );
  10062. }
  10063.  
  10064. private var finisherSaveLock : int;
  10065. event OnFinisherStart()
  10066. {
  10067. var currentEffects : array<CBaseGameplayEffect>;
  10068.  
  10069. theGame.CreateNoSaveLock("Finisher",finisherSaveLock,true,false);
  10070.  
  10071. isInFinisher = true;
  10072.  
  10073. finisherTarget = slideTarget;
  10074. OnCombatActionStart();
  10075.  
  10076. CancelHoldAttacks();
  10077.  
  10078. PlayFinisherCameraAnimation( theGame.GetSyncAnimManager().GetFinisherCameraAnimName() );
  10079. this.AddAnimEventCallback('SyncEvent','OnFinisherAnimEvent_SyncEvent');
  10080. SetImmortalityMode( AIM_Invulnerable, AIC_SyncedAnim );
  10081. }
  10082.  
  10083. public function IsPerformingFinisher() : bool
  10084. {
  10085. return isInFinisher;
  10086. }
  10087.  
  10088. private function PlayFinisherCameraAnimation( cameraAnimName : name )
  10089. {
  10090. var camera : CCustomCamera = theGame.GetGameCamera();
  10091. var animation : SCameraAnimationDefinition;
  10092.  
  10093. if( IsLastEnemyKilled() && theGame.GetWorld().NavigationCircleTest( this.GetWorldPosition(), 3.f ) )
  10094. {
  10095. camera.StopAnimation('camera_shake_hit_lvl3_1' );
  10096.  
  10097. animation.animation = cameraAnimName;
  10098. animation.priority = CAP_Highest;
  10099. animation.blendIn = 0.15f;
  10100. animation.blendOut = 1.0f;
  10101. animation.weight = 1.f;
  10102. animation.speed = 1.0f;
  10103. animation.reset = true;
  10104.  
  10105. camera.PlayAnimation( animation );
  10106.  
  10107.  
  10108. thePlayer.EnableManualCameraControl( false, 'Finisher' );
  10109. }
  10110. }
  10111.  
  10112. public function IsLastEnemyKilled() : bool
  10113. {
  10114. var tempMoveTargets : array<CActor>;
  10115.  
  10116. FindMoveTarget();
  10117. tempMoveTargets = GetMoveTargets();
  10118. if ( tempMoveTargets.Size() <= 0 || !thePlayer.IsThreat( tempMoveTargets[0] ) )
  10119. return true;
  10120.  
  10121. return false;
  10122. }
  10123.  
  10124. event OnFinisherAnimEvent_SyncEvent( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  10125. {
  10126. if ( finisherTarget )
  10127. ( (CNewNPC)finisherTarget ).SignalGameplayEvent('FinisherKill');
  10128. finisherTarget = NULL;
  10129. }
  10130.  
  10131. event OnFinisherEnd()
  10132. {
  10133. isInFinisher = false;
  10134. finisherTarget = NULL;
  10135.  
  10136. theGame.ReleaseNoSaveLock(finisherSaveLock);
  10137.  
  10138. this.RemoveAnimEventCallback('SyncEvent');
  10139.  
  10140.  
  10141. SetImmortalityMode( AIM_None, AIC_SyncedAnim );
  10142. theGame.RemoveTimeScale( 'AnimEventSlomoMo' );
  10143. AddTimer( 'FinisherEndEnableCamera', 0.5f );
  10144.  
  10145. OnCombatActionEnd();
  10146. OnCombatActionEndComplete();
  10147. }
  10148.  
  10149. private timer function FinisherEndEnableCamera( dt : float, id : int )
  10150. {
  10151. thePlayer.EnableManualCameraControl( true, 'Finisher' );
  10152. }
  10153.  
  10154. public function SpawnFinisherBlood()
  10155. {
  10156. var weaponEntity : CEntity;
  10157. var weaponSlotMatrix : Matrix;
  10158. var bloodFxPos : Vector;
  10159. var bloodFxRot : EulerAngles;
  10160. var tempEntity : CEntity;
  10161.  
  10162. weaponEntity = this.GetInventory().GetItemEntityUnsafe( GetInventory().GetItemFromSlot('r_weapon') );
  10163. weaponEntity.CalcEntitySlotMatrix( 'blood_fx_point', weaponSlotMatrix );
  10164. bloodFxPos = MatrixGetTranslation( weaponSlotMatrix );
  10165. bloodFxRot = this.GetWorldRotation();
  10166. tempEntity = theGame.CreateEntity( (CEntityTemplate)LoadResource('finisher_blood'), bloodFxPos, bloodFxRot);
  10167. tempEntity.PlayEffect('crawl_blood');
  10168. }
  10169.  
  10170.  
  10171. event OnCombatActionEndComplete()
  10172. {
  10173. var buff : CBaseGameplayEffect;
  10174.  
  10175. buff = ChooseCurrentCriticalBuffForAnim();
  10176. SetCombatAction( EBAT_EMPTY );
  10177.  
  10178.  
  10179. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart' );
  10180. UnblockAction( EIAB_OpenInventory, 'OnCombatActionStart' );
  10181. UnblockAction( EIAB_UsableItem, 'OnCombatActionStart' );
  10182.  
  10183. UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
  10184.  
  10185. SetUnpushableTarget( NULL );
  10186. SetBIsInCombatAction(false);
  10187. SetIsCurrentlyDodging(false);
  10188. SetMoveTargetChangeAllowed( true );
  10189. SetCanPlayHitAnim( true );
  10190.  
  10191. SetFinisherVictim( NULL );
  10192.  
  10193. this.RemoveBuffImmunity(EET_Burning, 'AnimEvent_RemoveBurning');
  10194.  
  10195. if ( rangedWeapon && rangedWeapon.GetCurrentStateName() == 'State_WeaponWait' && !buff )
  10196. {
  10197. ClearCustomOrientationInfoStack();
  10198. SetSlideTarget( NULL );
  10199. }
  10200.  
  10201. UnblockAction( EIAB_Crossbow, 'OnForceHolster' );
  10202.  
  10203. specialAttackCamera = false;
  10204.  
  10205. bIsRollAllowed = false;
  10206.  
  10207. if ( bLAxisReleased )
  10208. {
  10209. ResetRawPlayerHeading();
  10210. ResetCachedRawPlayerHeading();
  10211. }
  10212.  
  10213.  
  10214. ReapplyCriticalBuff();
  10215. SetBIsInputAllowed( true, 'OnCombatActionEndComplete' );
  10216.  
  10217.  
  10218. ResumeStaminaRegen( 'InsideCombatAction' );
  10219.  
  10220. bIsInHitAnim = false;
  10221.  
  10222. SetBIsCombatActionAllowed( true );
  10223.  
  10224. m_LastWeaponTipPos = Vector(0, 0, 0, 0 );
  10225.  
  10226.  
  10227. this.AddTimer('FreeTickets',3.f,false);
  10228.  
  10229.  
  10230.  
  10231. }
  10232.  
  10233. event OnMovementFullyBlended()
  10234. {
  10235. SetBehaviorVariable( 'isPerformingSpecialAttack', 0.f );
  10236.  
  10237. if ( restoreUsableItem )
  10238. {
  10239. restoreUsableItem = false;
  10240. SetPlayerActionToRestore ( PATR_Default );
  10241. OnUseSelectedItem();
  10242. }
  10243. }
  10244.  
  10245. event OnCombatMovementStart()
  10246. {
  10247. SetCombatIdleStance( 1.f );
  10248. OnCombatActionEndComplete();
  10249. }
  10250.  
  10251. timer function FreeTickets( dt : float, id : int )
  10252. {
  10253. FreeTicketAtCombatTarget();
  10254. }
  10255.  
  10256.  
  10257.  
  10258. event OnGuardedReleased(){}
  10259. event OnPerformAttack( playerAttackType : name ){}
  10260. event OnPerformEvade( playerEvadeType : EPlayerEvadeType ){}
  10261. event OnInterruptAttack(){}
  10262. event OnPerformGuard(){}
  10263. event OnSpawnHorse(){}
  10264. event OnDismountActionScriptCallback(){}
  10265.  
  10266. event OnHorseSummonStart()
  10267. {
  10268. thePlayer.BlockAction(EIAB_CallHorse, 'HorseSummon');
  10269. thePlayer.BlockAction(EIAB_Signs, 'HorseSummon');
  10270. thePlayer.BlockAction(EIAB_Crossbow, 'HorseSummon');
  10271. thePlayer.BlockAction(EIAB_UsableItem, 'HorseSummon');
  10272. thePlayer.BlockAction(EIAB_ThrowBomb, 'HorseSummon');
  10273. thePlayer.BlockAction(EIAB_SwordAttack, 'HorseSummon');
  10274. thePlayer.BlockAction(EIAB_Jump, 'HorseSummon');
  10275. thePlayer.BlockAction(EIAB_Dodge, 'HorseSummon');
  10276. thePlayer.BlockAction(EIAB_LightAttacks, 'HorseSummon');
  10277. thePlayer.BlockAction(EIAB_HeavyAttacks, 'HorseSummon');
  10278. thePlayer.BlockAction(EIAB_SpecialAttackLight, 'HorseSummon');
  10279. thePlayer.BlockAction(EIAB_SpecialAttackHeavy, 'HorseSummon');
  10280.  
  10281. horseSummonTimeStamp = theGame.GetEngineTimeAsSeconds();
  10282. }
  10283.  
  10284. event OnHorseSummonStop()
  10285. {
  10286. thePlayer.BlockAllActions('HorseSummon',false);
  10287. }
  10288.  
  10289.  
  10290. event OnCombatActionStartVehicle( action : EVehicleCombatAction )
  10291. {
  10292. this.SetBIsCombatActionAllowed( false );
  10293.  
  10294. if ( action != EHCA_ShootCrossbow )
  10295. {
  10296. SetIsAimingCrossbow( false );
  10297. OnRangedForceHolster();
  10298. }
  10299. }
  10300.  
  10301. event OnCombatActionEndVehicle()
  10302. {
  10303. this.SetBIsCombatActionAllowed( true );
  10304. }
  10305.  
  10306.  
  10307.  
  10308.  
  10309.  
  10310. protected function CriticalBuffInformBehavior(buff : CBaseGameplayEffect)
  10311. {
  10312.  
  10313. if( !CanAnimationReactToCriticalState( buff ) )
  10314. {
  10315. return;
  10316. }
  10317.  
  10318.  
  10319.  
  10320.  
  10321. SetBehaviorVariable( 'CriticalStateType', (int)GetBuffCriticalType(buff) );
  10322. SetBehaviorVariable( 'bCriticalState', 1);
  10323.  
  10324. if(CriticalBuffUsesFullBodyAnim(buff))
  10325. RaiseEvent('CriticalState');
  10326.  
  10327. SetBehaviorVariable( 'IsInAir', (int)IsInAir());
  10328.  
  10329. LogCritical("Sending player critical state event for <<" + buff.GetEffectType() + ">>");
  10330.  
  10331.  
  10332. }
  10333.  
  10334. private function CanAnimationReactToCriticalState( buff : CBaseGameplayEffect ) : bool
  10335. {
  10336. var buffCritical : W3CriticalEffect;
  10337. var buffCriticalDOT : W3CriticalDOTEffect;
  10338. var isHeavyCritical : bool;
  10339.  
  10340. isHeavyCritical = false;
  10341.  
  10342.  
  10343. buffCritical = ( W3CriticalEffect ) buff;
  10344. if( buffCritical )
  10345. {
  10346. isHeavyCritical = buffCritical.explorationStateHandling == ECH_HandleNow;
  10347. }
  10348. else
  10349. {
  10350. buffCriticalDOT = ( W3CriticalDOTEffect ) buff;
  10351. if( buffCriticalDOT )
  10352. {
  10353. isHeavyCritical = buffCriticalDOT.explorationStateHandling == ECH_HandleNow;
  10354. }
  10355. }
  10356.  
  10357.  
  10358. if( !isHeavyCritical )
  10359. {
  10360. if( !CanReactToCriticalState() )
  10361. {
  10362. return false;
  10363. }
  10364. }
  10365.  
  10366. return true;
  10367. }
  10368.  
  10369. public function CanReactToCriticalState() : bool
  10370. {
  10371. return substateManager.CanReactToHardCriticalState();
  10372. }
  10373.  
  10374. event OnCriticalStateAnimStart()
  10375. {
  10376. var heading : float;
  10377. var newCritical : ECriticalStateType;
  10378. var newReqCS : CBaseGameplayEffect;
  10379.  
  10380. OnCombatActionEndComplete();
  10381.  
  10382.  
  10383. newReqCS = newRequestedCS;
  10384. if(super.OnCriticalStateAnimStart())
  10385. {
  10386.  
  10387. RemoveTimer( 'IsItemUseInputHeld' );
  10388. keepRequestingCriticalAnimStart = false;
  10389. CancelHoldAttacks();
  10390.  
  10391.  
  10392.  
  10393.  
  10394.  
  10395. if(!IsUsingVehicle())
  10396. {
  10397. newCritical = GetBuffCriticalType(newReqCS);
  10398. if(newCritical == ECST_HeavyKnockdown
  10399. || newCritical == ECST_Knockdown
  10400. || newCritical == ECST_Stagger
  10401. || newCritical == ECST_Ragdoll
  10402. || newCritical == ECST_LongStagger )
  10403. {
  10404. if(newReqCS.GetCreator())
  10405. heading = VecHeading(newReqCS.GetCreator().GetWorldPosition() - GetWorldPosition());
  10406. else
  10407. heading = GetHeading();
  10408.  
  10409.  
  10410. SetCustomRotation( 'Knockdown', heading, 2160.f, 0.1f, true );
  10411.  
  10412. if ( newCritical != ECST_Stagger && newCritical != ECST_LongStagger )
  10413. substateManager.ReactOnCriticalState( true );
  10414. }
  10415. }
  10416.  
  10417. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'CriticalEffectStart', -1, 30.0f, -1.f, -1, true );
  10418. return true;
  10419. }
  10420.  
  10421.  
  10422. return false;
  10423. }
  10424.  
  10425.  
  10426. public function StartCSAnim(buff : CBaseGameplayEffect) : bool
  10427. {
  10428. SetBehaviorVariable( 'bCriticalStopped', 0 );
  10429.  
  10430. if(super.StartCSAnim(buff))
  10431. {
  10432. if(!CriticalBuffUsesFullBodyAnim(buff))
  10433. {
  10434. OnCriticalStateAnimStart();
  10435. }
  10436.  
  10437. ResumeStaminaRegen( 'InsideCombatAction' );
  10438.  
  10439. keepRequestingCriticalAnimStart = true;
  10440. AddTimer('RequestCriticalAnimStart', 0, true);
  10441.  
  10442.  
  10443. return true;
  10444. }
  10445.  
  10446. return false;
  10447. }
  10448.  
  10449. public function CriticalEffectAnimationInterrupted(reason : string) : bool
  10450. {
  10451. var ret : bool;
  10452.  
  10453. LogCriticalPlayer("R4Player.CriticalEffectAnimationInterrupted() - because: " + reason);
  10454.  
  10455. ret = super.CriticalEffectAnimationInterrupted(reason);
  10456.  
  10457. if(ret)
  10458. {
  10459. keepRequestingCriticalAnimStart = false;
  10460. }
  10461.  
  10462. substateManager.ReactOnCriticalState( false );
  10463.  
  10464. return ret;
  10465. }
  10466.  
  10467. public function CriticalStateAnimStopped(forceRemoveBuff : bool)
  10468. {
  10469. LogCriticalPlayer("R4Player.CriticalStateAnimStopped() - forced: " + forceRemoveBuff);
  10470.  
  10471. theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'RecoveredFromCriticalEffect', -1, 30.0f, -1.f, -1, true );
  10472. super.CriticalStateAnimStopped(forceRemoveBuff);
  10473.  
  10474. substateManager.ReactOnCriticalState( false );
  10475. }
  10476.  
  10477.  
  10478. timer function RequestCriticalAnimStart(dt : float, id : int)
  10479. {
  10480. if(keepRequestingCriticalAnimStart)
  10481. {
  10482. if(newRequestedCS && newRequestedCS.GetDurationLeft() > 0)
  10483. {
  10484. CriticalBuffInformBehavior(newRequestedCS);
  10485. }
  10486. else
  10487. {
  10488. keepRequestingCriticalAnimStart = false;
  10489. RemoveTimer('RequestCriticalAnimStart');
  10490. }
  10491. }
  10492. else
  10493. {
  10494. RemoveTimer('RequestCriticalAnimStart');
  10495. }
  10496. }
  10497.  
  10498. event OnRagdollUpdate(progress : float)
  10499. {
  10500.  
  10501.  
  10502. SetIsInAir(progress == 0);
  10503. }
  10504.  
  10505.  
  10506. event OnRagdollOnGround()
  10507. {
  10508.  
  10509. TryToEndRagdollOnGround( 0.0f );
  10510. }
  10511.  
  10512. event OnRagdollInAir()
  10513. {
  10514. RemoveTimer('TryToEndRagdollOnGround');
  10515. }
  10516.  
  10517. event OnNoLongerInRagdoll()
  10518. {
  10519. RemoveTimer('TryToEndRagdollOnGround');
  10520. }
  10521.  
  10522. timer function TryToEndRagdollOnGround( td : float, optional id : int)
  10523. {
  10524. var critical : CBaseGameplayEffect;
  10525. var type : EEffectType;
  10526.  
  10527. critical = GetCurrentlyAnimatedCS();
  10528. if(critical)
  10529. {
  10530. type = critical.GetEffectType();
  10531. if(type == EET_Knockdown || type == EET_HeavyKnockdown || type == EET_Ragdoll)
  10532. {
  10533.  
  10534. if (critical.GetTimeActive() >= 2.5f)
  10535. {
  10536. SetIsInAir(false);
  10537. RequestCriticalAnimStop();
  10538. RemoveTimer('TryToEndRagdollOnGround');
  10539. }
  10540. else
  10541. {
  10542. AddTimer('TryToEndRagdollOnGround', 0.2f, true);
  10543. }
  10544. return;
  10545. }
  10546. }
  10547.  
  10548.  
  10549. RemoveTimer('TryToEndRagdollOnGround');
  10550. }
  10551.  
  10552. public function RequestCriticalAnimStop(optional dontSetCriticalToStopped : bool)
  10553. {
  10554. var buff : CBaseGameplayEffect;
  10555.  
  10556. buff = GetCurrentlyAnimatedCS();
  10557. if(buff && !CriticalBuffUsesFullBodyAnim(buff))
  10558. {
  10559. CriticalStateAnimStopped(false);
  10560. }
  10561.  
  10562. if(!buff || !CriticalBuffUsesFullBodyAnim(buff))
  10563. {
  10564. SetBehaviorVariable( 'bCriticalState', 0);
  10565. }
  10566.  
  10567. super.RequestCriticalAnimStop(dontSetCriticalToStopped);
  10568. }
  10569.  
  10570.  
  10571.  
  10572.  
  10573. public function SimulateBuffTimePassing(simulatedTime : float)
  10574. {
  10575. effectManager.SimulateBuffTimePassing(simulatedTime);
  10576. }
  10577.  
  10578. public function AddEffectDefault(effectType : EEffectType, creat : CGameplayEntity, srcName : string, optional isSignEffect : bool) : EEffectInteract
  10579. {
  10580. var params : SCustomEffectParams;
  10581.  
  10582.  
  10583. if(effectType == EET_Stagger || effectType == EET_LongStagger || effectType == EET_Knockdown || effectType == EET_HeavyKnockdown)
  10584. {
  10585. params.effectType = effectType;
  10586. params.creator = creat;
  10587. params.sourceName = srcName;
  10588. params.isSignEffect = isSignEffect;
  10589.  
  10590. if ( effectType == EET_Stagger )
  10591. params.duration = 1.83;
  10592. else if ( effectType == EET_LongStagger )
  10593. params.duration = 4;
  10594. else if ( effectType == EET_Knockdown )
  10595. params.duration = 2.5;
  10596. else if ( effectType == EET_HeavyKnockdown )
  10597. params.duration = 4;
  10598.  
  10599. return super.AddEffectCustom(params);
  10600. }
  10601. else
  10602. {
  10603. return super.AddEffectDefault(effectType, creat, srcName, isSignEffect);
  10604. }
  10605. }
  10606.  
  10607.  
  10608.  
  10609.  
  10610.  
  10611. public function CheatResurrect()
  10612. {
  10613. var items : array< SItemUniqueId >;
  10614. var i, size, itemLevel, maxPrice, itemPrice : int;
  10615. var itemToEquip : SItemUniqueId;
  10616.  
  10617. if(IsAlive())
  10618. return;
  10619.  
  10620.  
  10621. if ( !theGame.GetGuiManager().GetRootMenu() )
  10622. {
  10623. Log(" *** Call this function after DeathScreen appears *** ");
  10624. return;
  10625. }
  10626.  
  10627. SetAlive(true);
  10628.  
  10629. SetKinematic(true);
  10630.  
  10631. EnableFindTarget( true );
  10632. SetBehaviorVariable( 'Ragdoll_Weight', 0.f );
  10633. RaiseForceEvent( 'RecoverFromRagdoll' );
  10634. SetCanPlayHitAnim( true );
  10635. SetBehaviorVariable( 'CriticalStateType', (int)ECST_None );
  10636. GoToStateIfNew('Exploration');
  10637.  
  10638. ( (CDismembermentComponent)this.GetComponent( 'Dismemberment' ) ).ClearVisibleWound();
  10639.  
  10640. SetIsInAir(false);
  10641.  
  10642. theInput.SetContext('Exploration');
  10643.  
  10644. ResetDeathType();
  10645.  
  10646. ForceUnlockAllInputActions(false);
  10647.  
  10648. theGame.CloseMenu('DeathScreenMenu');
  10649.  
  10650.  
  10651. theSound.LeaveGameState(ESGS_Death);
  10652.  
  10653.  
  10654. abilityManager.ForceSetStat(BCS_Vitality, GetStatMax(BCS_Vitality));
  10655. effectManager.StopVitalityRegen();
  10656. abilityManager.ForceSetStat( BCS_Air , 100.f );
  10657. effectManager.StopAirRegen();
  10658. abilityManager.ForceSetStat( BCS_Stamina , 100.f );
  10659. effectManager.StopStaminaRegen();
  10660. abilityManager.ForceSetStat( BCS_Toxicity , 0.f );
  10661. abilityManager.ForceSetStat( BCS_Focus , 0.f );
  10662. GetWitcherPlayer().UpdateEncumbrance();
  10663.  
  10664.  
  10665. if ( !inv.IsThereItemOnSlot( EES_SteelSword ) )
  10666. {
  10667. items = inv.GetItemsByCategory( 'steelsword' );
  10668. }
  10669. else if ( !inv.IsThereItemOnSlot( EES_SilverSword ) )
  10670. {
  10671. items = inv.GetItemsByCategory( 'silversword' );
  10672. }
  10673.  
  10674. size = items.Size();
  10675. maxPrice = -1;
  10676. for ( i = 0; i < size; i += 1 )
  10677. {
  10678. itemPrice = inv.GetItemPrice(items[i]);
  10679. itemLevel = inv.GetItemLevel(items[i]);
  10680. if ( itemLevel <= GetLevel() && itemPrice > maxPrice )
  10681. {
  10682. maxPrice = itemPrice;
  10683. itemToEquip = items[i];
  10684. }
  10685. }
  10686. if( inv.IsIdValid( itemToEquip ) )
  10687. {
  10688. EquipItem( itemToEquip , , true );
  10689. }
  10690.  
  10691. theGame.ReleaseNoSaveLock(deathNoSaveLock);
  10692. }
  10693.  
  10694.  
  10695.  
  10696. public function SetIsInsideInteraction(b : bool) {isInsideInteraction = b;}
  10697. public function IsInsideInteraction() : bool {return isInsideInteraction;}
  10698.  
  10699. public function SetIsInsideHorseInteraction( b : bool, horse : CEntity )
  10700. {
  10701. isInsideHorseInteraction = b;
  10702. horseInteractionSource = horse;
  10703. }
  10704. public function IsInsideHorseInteraction() : bool {return isInsideHorseInteraction;}
  10705.  
  10706.  
  10707. event OnInteractionActivationTest( interactionComponentName : string, activator : CEntity )
  10708. {
  10709. if ( interactionComponentName == "ClimbLadder" )
  10710. {
  10711. if( PlayerHasLadderExplorationReady() )
  10712. {
  10713. return true;
  10714. }
  10715. }
  10716.  
  10717. return false;
  10718. }
  10719.  
  10720. private function PlayerHasLadderExplorationReady() : bool
  10721. {
  10722. if( !substateManager.CanInteract() )
  10723. {
  10724. return false;
  10725. }
  10726.  
  10727. if( !substateManager.m_SharedDataO.HasValidLadderExploration() )
  10728. {
  10729. return false;
  10730. }
  10731.  
  10732. return true;
  10733. }
  10734.  
  10735.  
  10736.  
  10737.  
  10738.  
  10739. public function SetGuarded(flag : bool)
  10740. {
  10741. super.SetGuarded(flag);
  10742.  
  10743. if(flag && FactsQuerySum("tut_fight_use_slomo") > 0)
  10744. {
  10745. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
  10746. FactsRemove("tut_fight_slomo_ON");
  10747. }
  10748. }
  10749.  
  10750.  
  10751. public function IsGuarded() : bool
  10752. {
  10753. return super.IsGuarded() && ( !rangedWeapon || rangedWeapon.GetCurrentStateName() == 'State_WeaponWait' );
  10754. }
  10755.  
  10756.  
  10757.  
  10758.  
  10759. public function GetSelectedItemId() : SItemUniqueId {return selectedItemId;}
  10760. public function ClearSelectedItemId() {selectedItemId = GetInvalidUniqueId();}
  10761.  
  10762. public function IsHoldingItemInLHand() : bool
  10763. {
  10764. return currentlyEquipedItemL != GetInvalidUniqueId();
  10765. }
  10766.  
  10767. public function GetCurrentlyUsedItemL () : W3UsableItem
  10768. {
  10769. return currentlyUsedItemL;
  10770. }
  10771.  
  10772. public function SetPlayerActionToRestore ( actionToRestoreType : EPlayerActionToRestore )
  10773. {
  10774. playerActionToRestore = actionToRestoreType;
  10775. }
  10776.  
  10777. public function IsCurrentlyUsingItemL () : bool
  10778. {
  10779. return currentlyUsingItem;
  10780. }
  10781.  
  10782. function BlockSlotsOnLItemUse ()
  10783. {
  10784. var slotsToBlock : array<name>;
  10785.  
  10786. slotsToBlock.PushBack( 'Slot1' );
  10787. slotsToBlock.PushBack( 'Slot2' );
  10788. slotsToBlock.PushBack( 'Slot3' );
  10789. slotsToBlock.PushBack( 'Slot4' );
  10790. slotsToBlock.PushBack( 'Slot5' );
  10791. slotsToBlock.PushBack( 'Yrden' );
  10792. slotsToBlock.PushBack( 'Quen' );
  10793. slotsToBlock.PushBack( 'Igni' );
  10794. slotsToBlock.PushBack( 'Axii' );
  10795. slotsToBlock.PushBack( 'Aard' );
  10796.  
  10797.  
  10798. EnableRadialSlotsWithSource ( false, slotsToBlock, 'usableItemL' );
  10799. }
  10800.  
  10801. function UnblockSlotsOnLItemUse ()
  10802. {
  10803. var slotsToBlock : array<name>;
  10804.  
  10805. slotsToBlock.PushBack( 'Slot1' );
  10806. slotsToBlock.PushBack( 'Slot2' );
  10807. slotsToBlock.PushBack( 'Slot3' );
  10808. slotsToBlock.PushBack( 'Slot4' );
  10809. slotsToBlock.PushBack( 'Slot5' );
  10810. slotsToBlock.PushBack( 'Yrden' );
  10811. slotsToBlock.PushBack( 'Quen' );
  10812. slotsToBlock.PushBack( 'Igni' );
  10813. slotsToBlock.PushBack( 'Axii' );
  10814. slotsToBlock.PushBack( 'Aard' );
  10815.  
  10816.  
  10817. EnableRadialSlotsWithSource ( true, slotsToBlock, 'usableItemL' );
  10818. }
  10819.  
  10820. function IsUsableItemLBlocked () : bool
  10821. {
  10822. return isUsableItemBlocked;
  10823. }
  10824. function HideUsableItem( optional force : bool )
  10825. {
  10826. if( currentlyEquipedItemL != GetInvalidUniqueId() )
  10827. {
  10828. if( force )
  10829. {
  10830. if( !RaiseForceEvent( 'ItemEndL' ) )
  10831. {
  10832.  
  10833. OnUsingItemsReset();
  10834. }
  10835. return;
  10836.  
  10837. }
  10838. RaiseEvent( 'ItemUseL' );
  10839. }
  10840. }
  10841. function ProcessUsableItemsTransition ( actionToRestore : EPlayerActionToRestore )
  10842. {
  10843. var category : name;
  10844. var signSkill : ESkill;
  10845.  
  10846. category = inv.GetItemCategory ( selectedItemId );
  10847. signSkill = SignEnumToSkillEnum( GetEquippedSign());
  10848.  
  10849. switch ( actionToRestore )
  10850. {
  10851. case PATR_None:
  10852. if ( currentlyUsedItemL )
  10853. {
  10854. inv.UnmountItem( currentlyEquipedItemL, true );
  10855. }
  10856. currentlyEquipedItemL = GetInvalidUniqueId();
  10857. return;
  10858.  
  10859. case PATR_Default:
  10860. if ( IsSlotQuickslot( inv.GetSlotForItemId ( selectedItemId )) && category == 'usable' && currentlyEquipedItemL != selectedItemId )
  10861. {
  10862. if ( currentlyUsedItemL )
  10863. {
  10864. inv.UnmountItem( currentlyEquipedItemL, true );
  10865. }
  10866. currentlyEquipedItemL = GetInvalidUniqueId();
  10867. OnUseSelectedItem();
  10868. return;
  10869. }
  10870. break;
  10871. case PATR_Crossbow:
  10872. if ( inv.IsItemCrossbow ( selectedItemId ) )
  10873. {
  10874. if ( currentlyUsedItemL )
  10875. {
  10876. inv.UnmountItem( currentlyEquipedItemL, true );
  10877. }
  10878. currentlyEquipedItemL = GetInvalidUniqueId();
  10879. SetIsAimingCrossbow( true );
  10880.  
  10881. if ( theInput.IsActionPressed( 'ThrowItem' ) )
  10882. SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  10883. else
  10884. {
  10885. SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  10886. SetupCombatAction( EBAT_ItemUse, BS_Released );
  10887. }
  10888. return;
  10889. }
  10890. break;
  10891. case PATR_CastSign:
  10892. if( signSkill != S_SUndefined && playerActionToRestore == PATR_CastSign )
  10893. {
  10894. if ( currentlyUsedItemL )
  10895. {
  10896. inv.UnmountItem( currentlyEquipedItemL, true );
  10897. }
  10898. currentlyEquipedItemL = GetInvalidUniqueId();
  10899.  
  10900. if( HasStaminaToUseSkill( signSkill, false ) )
  10901. {
  10902. if( GetInvalidUniqueId() != inv.GetItemFromSlot( 'l_weapon' ) )
  10903. PushCombatActionOnBuffer( EBAT_CastSign, BS_Pressed );
  10904. else
  10905. SetupCombatAction( EBAT_CastSign, BS_Pressed );
  10906. }
  10907. else
  10908. {
  10909. thePlayer.SoundEvent("gui_no_stamina");
  10910. }
  10911. return;
  10912. }
  10913. break;
  10914. case PATR_ThrowBomb:
  10915. if ( inv.IsItemBomb ( selectedItemId ) )
  10916. {
  10917. if ( currentlyUsedItemL )
  10918. {
  10919. inv.UnmountItem( currentlyEquipedItemL, true );
  10920. }
  10921. currentlyEquipedItemL = GetInvalidUniqueId();
  10922. PrepareToAttack();
  10923. SetupCombatAction( EBAT_ItemUse, BS_Pressed );
  10924. return;
  10925. }
  10926. break;
  10927. case PATR_CallHorse:
  10928. theGame.OnSpawnPlayerHorse();
  10929. break;
  10930. default:
  10931. if ( currentlyUsedItemL )
  10932. {
  10933. inv.UnmountItem( currentlyEquipedItemL, true );
  10934. }
  10935. currentlyEquipedItemL = GetInvalidUniqueId();
  10936. return;
  10937. }
  10938. if ( currentlyUsedItemL )
  10939. {
  10940. inv.UnmountItem( currentlyEquipedItemL, true );
  10941. }
  10942. currentlyEquipedItemL = GetInvalidUniqueId();
  10943. }
  10944.  
  10945. function GetUsableItemLtransitionAllowed () : bool
  10946. {
  10947. return isUsableItemLtransitionAllowed;
  10948. }
  10949.  
  10950. function SetUsableItemLtransitionAllowed ( isAllowed : bool)
  10951. {
  10952. isUsableItemLtransitionAllowed = isAllowed;
  10953. }
  10954.  
  10955. event OnItemUseLUnBlocked ()
  10956. {
  10957. if ( isUsableItemBlocked )
  10958. {
  10959. isUsableItemBlocked = false;
  10960. UnblockSlotsOnLItemUse ();
  10961. }
  10962. }
  10963.  
  10964. event OnItemUseLBlocked ()
  10965. {
  10966. if ( !isUsableItemBlocked )
  10967. {
  10968. isUsableItemBlocked = true;
  10969. BlockSlotsOnLItemUse ();
  10970. }
  10971. }
  10972.  
  10973. event OnUsingItemsReset()
  10974. {
  10975. if ( currentlyUsingItem )
  10976. {
  10977. OnItemUseLUnBlocked ();
  10978. OnUsingItemsComplete();
  10979. }
  10980. }
  10981. event OnUsingItemsComplete ()
  10982. {
  10983. if ( isUsableItemBlocked )
  10984. {
  10985. OnItemUseLUnBlocked ();
  10986. }
  10987. currentlyUsingItem = false;
  10988. if ( GetUsableItemLtransitionAllowed () )
  10989. {
  10990. ProcessUsableItemsTransition( playerActionToRestore );
  10991. }
  10992. else
  10993. {
  10994. if ( currentlyUsedItemL )
  10995. {
  10996. inv.UnmountItem( currentlyEquipedItemL, true );
  10997. }
  10998. currentlyEquipedItemL = GetInvalidUniqueId();
  10999. }
  11000.  
  11001. SetPlayerActionToRestore ( PATR_Default );
  11002. }
  11003.  
  11004. event OnUseSelectedItem( optional force : bool )
  11005. {
  11006. var category : name;
  11007. var itemEntity : W3UsableItem;
  11008.  
  11009. if ( isUsableItemBlocked && !force )
  11010. {
  11011. return false;
  11012. }
  11013. if ( IsCastingSign() )
  11014. return false;
  11015.  
  11016. if ( currentlyEquipedItemL != GetInvalidUniqueId() )
  11017. {
  11018. SetBehaviorVariable( 'SelectedItemL', (int)GetUsableItemTypeById( currentlyEquipedItemL ), true );
  11019. if ( force )
  11020. {
  11021. if ( RaiseEvent( 'ItemEndL' ) )
  11022. {
  11023. SetUsableItemLtransitionAllowed ( true );
  11024. return true;
  11025. }
  11026. }
  11027. else
  11028. {
  11029. if ( RaiseEvent( 'ItemUseL' ) )
  11030. {
  11031. SetUsableItemLtransitionAllowed ( true );
  11032. return true;
  11033. }
  11034. }
  11035. }
  11036. else
  11037. {
  11038. category = inv.GetItemCategory( selectedItemId );
  11039. if( category != 'usable' )
  11040. {
  11041. return false;
  11042. }
  11043. SetBehaviorVariable( 'SelectedItemL', (int)GetUsableItemTypeById( selectedItemId ), true );
  11044. if( RaiseEvent( 'ItemUseL' ) )
  11045. {
  11046. currentlyEquipedItemL = selectedItemId;
  11047. SetUsableItemLtransitionAllowed ( false );
  11048. currentlyUsingItem = true;
  11049.  
  11050. return true;
  11051. }
  11052. inv.UnmountItem( selectedItemId, true );
  11053. }
  11054. }
  11055.  
  11056. protected saved var currentlyUsingItem : bool;
  11057.  
  11058. public function ProcessUseSelectedItem( itemEntity : W3UsableItem, optional shouldCallOnUsed : bool )
  11059. {
  11060. currentlyUsedItemL = itemEntity;
  11061. DrainStamina(ESAT_UsableItem);
  11062.  
  11063. if ( shouldCallOnUsed )
  11064. {
  11065. currentlyUsedItemL.OnUsed( thePlayer );
  11066. }
  11067. }
  11068.  
  11069. function GetUsableItemTypeById ( itemId : SItemUniqueId ) : EUsableItemType
  11070. {
  11071. var itemName : name;
  11072.  
  11073. itemName = inv.GetItemName ( itemId );
  11074.  
  11075. return theGame.GetDefinitionsManager().GetUsableItemType ( itemName );
  11076.  
  11077. }
  11078.  
  11079.  
  11080. public function StartWaitForItemSpawnAndProccesTask()
  11081. {
  11082. AddTimer( 'WaitForItemSpawnAndProccesTask', 0.001f, true,,,,true );
  11083. }
  11084.  
  11085.  
  11086. public function KillWaitForItemSpawnAndProccesTask()
  11087. {
  11088. RemoveTimer ( 'WaitForItemSpawnAndProccesTask' );
  11089. }
  11090.  
  11091.  
  11092.  
  11093. public function AllowUseSelectedItem()
  11094. {
  11095. m_useSelectedItemIfSpawned = true;
  11096. }
  11097.  
  11098.  
  11099.  
  11100. timer function WaitForItemSpawnAndProccesTask( timeDelta : float , id : int )
  11101. {
  11102. var itemEntity : W3UsableItem;
  11103. var canTaskBeKilled : bool;
  11104. canTaskBeKilled = false;
  11105.  
  11106. if ( IsCastingSign() )
  11107. {
  11108. return;
  11109. }
  11110.  
  11111.  
  11112. if ( selectedItemId == GetInvalidUniqueId() )
  11113. {
  11114. canTaskBeKilled = true;
  11115. }
  11116.  
  11117. itemEntity = (W3UsableItem)inv.GetItemEntityUnsafe( selectedItemId );
  11118. if ( itemEntity && m_useSelectedItemIfSpawned )
  11119. {
  11120.  
  11121. canTaskBeKilled = true;
  11122. m_useSelectedItemIfSpawned = false;
  11123. ProcessUseSelectedItem( itemEntity, true );
  11124. }
  11125.  
  11126. if ( canTaskBeKilled )
  11127. {
  11128. KillWaitForItemSpawnAndProccesTask();
  11129. }
  11130. }
  11131.  
  11132. event OnBombProjectileReleased()
  11133. {
  11134. ResetRawPlayerHeading();
  11135. UnblockAction(EIAB_ThrowBomb, 'BombThrow');
  11136. UnblockAction(EIAB_Crossbow, 'BombThrow');
  11137.  
  11138. if(GetCurrentStateName() == 'AimThrow')
  11139. PopState();
  11140.  
  11141. FactsAdd("ach_bomb", 1, 4 );
  11142. theGame.GetGamerProfile().CheckLearningTheRopes();
  11143. }
  11144.  
  11145. public function SetIsThrowingItemWithAim(b : bool)
  11146. {
  11147. isThrowingItemWithAim = b;
  11148. }
  11149.  
  11150. public function SetIsThrowingItem( flag : bool ) {isThrowingItem = flag;}
  11151. public function IsThrowingItem() : bool {return isThrowingItem;}
  11152. public function IsThrowingItemWithAim() : bool {return isThrowingItemWithAim;}
  11153. public function SetThrowHold(b : bool) {isThrowHoldPressed = b;}
  11154. public function IsThrowHold() : bool {return isThrowHoldPressed;}
  11155. public function SetIsAimingCrossbow( flag : bool ) {isAimingCrossbow = flag;}
  11156. public function GetIsAimingCrossbow() : bool {return isAimingCrossbow;}
  11157.  
  11158. event OnThrowAnimLeave()
  11159. {
  11160. var throwStage : EThrowStage;
  11161. var thrownEntity : CThrowable;
  11162.  
  11163. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  11164.  
  11165. if(thrownEntity && !thrownEntity.WasThrown())
  11166. {
  11167. throwStage = (int)GetBehaviorVariable( 'throwStage', (int)TS_Stop);
  11168. if(inv.IsItemBomb(selectedItemId))
  11169. {
  11170. BombThrowCleanUp();
  11171. }
  11172. else
  11173. {
  11174. ThrowingAbort();
  11175. }
  11176. }
  11177.  
  11178. thrownEntity = NULL;
  11179. SetIsThrowingItem( false );
  11180. SetIsThrowingItemWithAim( false );
  11181.  
  11182. this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
  11183. UnblockAction(EIAB_ThrowBomb, 'BombThrow');
  11184. UnblockAction(EIAB_Crossbow, 'BombThrow');
  11185. }
  11186.  
  11187.  
  11188. protected function BombThrowStart()
  11189. {
  11190. var slideTargetActor : CActor;
  11191.  
  11192. BlockAction( EIAB_ThrowBomb, 'BombThrow' );
  11193. BlockAction(EIAB_Crossbow, 'BombThrow');
  11194.  
  11195. SetBehaviorVariable( 'throwStage', (int)TS_Start );
  11196. SetBehaviorVariable( 'combatActionType', (int)CAT_ItemThrow );
  11197.  
  11198. if ( slideTarget )
  11199. {
  11200. AddCustomOrientationTarget( OT_Actor, 'BombThrow' );
  11201.  
  11202. slideTargetActor = (CActor)( slideTarget );
  11203.  
  11204.  
  11205.  
  11206.  
  11207.  
  11208. }
  11209. else
  11210. {
  11211. if ( lastAxisInputIsMovement )
  11212. AddCustomOrientationTarget( OT_Actor, 'BombThrow' );
  11213. else
  11214. AddCustomOrientationTarget( OT_Camera, 'BombThrow' );
  11215. }
  11216.  
  11217. UpdateLookAtTarget();
  11218. SetCustomRotation( 'Throw', VecHeading( this.GetLookAtPosition() - GetWorldPosition() ), 0.0f, 0.3f, false );
  11219.  
  11220. SetBehaviorVariable( 'itemType', (int)IT_Petard );
  11221.  
  11222. ProcessCanAttackWhenNotInCombatBomb();
  11223.  
  11224. if ( RaiseForceEvent('CombatAction') )
  11225. OnCombatActionStart();
  11226.  
  11227.  
  11228. theTelemetry.LogWithLabel(TE_FIGHT_HERO_THROWS_BOMB, inv.GetItemName( selectedItemId ));
  11229. }
  11230.  
  11231.  
  11232. event OnThrowAnimStart()
  11233. {
  11234. var itemId : SItemUniqueId;
  11235. var thrownEntity : CThrowable;
  11236.  
  11237. this.radialSlots.Clear();
  11238. GetWitcherPlayer().GetItemEquippedOnSlot(EES_Petard1, itemId );
  11239.  
  11240. if( GetSelectedItemId() == itemId )
  11241. {
  11242. this.radialSlots.PushBack( 'Slot2' );
  11243. }
  11244. else
  11245. {
  11246. this.radialSlots.PushBack( 'Slot1' );
  11247. }
  11248. this.radialSlots.PushBack( 'Slot3' );
  11249. this.radialSlots.PushBack( 'Slot4' );
  11250. this.radialSlots.PushBack( 'Slot5' );
  11251. this.EnableRadialSlotsWithSource( false, this.radialSlots, 'throwBomb' );
  11252.  
  11253. thrownEntity = (CThrowable)inv.GetDeploymentItemEntity( selectedItemId,,,true );
  11254. thrownEntity.Initialize( this, selectedItemId );
  11255. EntityHandleSet( thrownEntityHandle, thrownEntity );
  11256. SetIsThrowingItem( true );
  11257. }
  11258.  
  11259. public function BombThrowAbort()
  11260. {
  11261. BombThrowCleanUp();
  11262. UnblockAction( EIAB_ThrowBomb, 'BombThrow' );
  11263. UnblockAction(EIAB_Crossbow, 'BombThrow');
  11264. }
  11265.  
  11266. private function BombThrowCleanUp()
  11267. {
  11268. var throwStage : EThrowStage;
  11269. var thrownEntity : CThrowable;
  11270. var vehicle : CVehicleComponent;
  11271.  
  11272. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  11273.  
  11274. this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
  11275. throwStage = (int)GetBehaviorVariable( 'throwStage', (int)TS_Stop);
  11276.  
  11277. SetBehaviorVariable( 'throwStage', (int)TS_Stop );
  11278.  
  11279. if( GetCurrentStateName() == 'AimThrow')
  11280. {
  11281. PopState();
  11282. thrownEntity.StopAiming( true );
  11283. }
  11284. else if ( this.IsUsingHorse() )
  11285. {
  11286. vehicle = (CVehicleComponent)(GetUsedVehicle().GetComponentByClassName('CVehicleComponent'));
  11287. vehicle.GetUserCombatManager().OnForceItemActionAbort();
  11288. }
  11289.  
  11290.  
  11291. if(thrownEntity && !thrownEntity.WasThrown())
  11292. {
  11293. thrownEntity.BreakAttachment();
  11294. thrownEntity.Destroy();
  11295. }
  11296.  
  11297. thrownEntity = NULL;
  11298. SetIsThrowingItem( false );
  11299. SetIsThrowingItemWithAim( false );
  11300. RemoveCustomOrientationTarget( 'BombThrow' );
  11301. }
  11302.  
  11303. public function ProcessCanAttackWhenNotInCombatBomb()
  11304. {
  11305. var targets : array< CGameplayEntity >;
  11306. var temp, throwVector, throwFrom, throwTo, throwVectorU : Vector;
  11307. var temp_n : name;
  11308. var throwVecLen : float;
  11309. var component : CComponent;
  11310.  
  11311.  
  11312.  
  11313. if( FactsQuerySum( "BombThrowSpecificTargets" ) > 0 )
  11314. {
  11315.  
  11316.  
  11317.  
  11318.  
  11319.  
  11320. throwFrom = playerAiming.GetThrowStartPosition();
  11321. throwTo = playerAiming.GetThrowPosition();
  11322. throwVector = throwTo - throwFrom;
  11323. throwVecLen = VecDistance( throwFrom, throwTo );
  11324. throwVectorU = throwVector / throwVecLen;
  11325. if( theGame.GetWorld().StaticTraceWithAdditionalInfo( throwFrom, throwTo + throwVectorU, temp, temp, temp_n, component ) && component && component.GetEntity().HasTag( 'BombThrowSpecificTarget' ) )
  11326. {
  11327. SetIsShootingFriendly( false );
  11328. }
  11329. else
  11330. {
  11331. SetIsShootingFriendly( true );
  11332. }
  11333. }
  11334. else if( FactsQuerySum( "BombThrowDisallowSpecificTargets" ) > 0 )
  11335. {
  11336.  
  11337. throwFrom = playerAiming.GetThrowStartPosition();
  11338. throwTo = playerAiming.GetThrowPosition();
  11339. throwVector = throwTo - throwFrom;
  11340. throwVecLen = VecDistance( throwFrom, throwTo );
  11341. throwVectorU = throwVector / throwVecLen;
  11342. if( theGame.GetWorld().StaticTraceWithAdditionalInfo( throwFrom, throwTo + throwVectorU, temp, temp, temp_n, component ) && component && component.GetEntity().HasTag( 'BombThrowDisallowedTarget' ) )
  11343. {
  11344. SetIsShootingFriendly( true );
  11345. }
  11346. else
  11347. {
  11348. SetIsShootingFriendly( false );
  11349. }
  11350. }
  11351. else
  11352. {
  11353. SetIsShootingFriendly( false );
  11354. }
  11355.  
  11356. SetBehaviorVariable( 'isShootingFriendly', (float)( GetIsShootingFriendly() ) );
  11357. }
  11358.  
  11359. public function SetIsShootingFriendly( flag : bool )
  11360. {
  11361. isShootingFriendly = flag;
  11362. }
  11363.  
  11364. public function GetIsShootingFriendly() : bool
  11365. {
  11366. return isShootingFriendly;
  11367. }
  11368.  
  11369.  
  11370. protected function UsableItemStart()
  11371. {
  11372. var thrownEntity : CThrowable;
  11373.  
  11374.  
  11375. thrownEntity = (CThrowable)inv.GetDeploymentItemEntity( selectedItemId,,,true );
  11376. thrownEntity.Initialize( this, selectedItemId );
  11377. EntityHandleSet( thrownEntityHandle, thrownEntity );
  11378. SetBehaviorVariable( 'throwStage', (int)TS_Start );
  11379. SetIsThrowingItem( true );
  11380. SetBehaviorVariable( 'combatActionType', (int)CAT_ItemThrow );
  11381.  
  11382. if ( slideTarget )
  11383. {
  11384. AddCustomOrientationTarget( OT_Actor, 'UsableItems' );
  11385. }
  11386. else
  11387. {
  11388. if ( lastAxisInputIsMovement )
  11389. AddCustomOrientationTarget( OT_Actor, 'UsableItems' );
  11390. else
  11391. AddCustomOrientationTarget( OT_Camera, 'UsableItems' );
  11392. }
  11393.  
  11394. SetBehaviorVariable( 'itemType', (int)(-1) );
  11395.  
  11396. if ( RaiseForceEvent('CombatAction') )
  11397. OnCombatActionStart();
  11398. }
  11399.  
  11400. protected function BombThrowRelease()
  11401. {
  11402. var stateName : name;
  11403.  
  11404. stateName = playerAiming.GetCurrentStateName();
  11405. OnDelayOrientationChangeOff();
  11406.  
  11407. if( GetIsShootingFriendly() || ( FactsQuerySum( "BombThrowSpecificTargets" ) > 0 && stateName != 'Aiming' ) )
  11408. {
  11409. BombThrowAbort();
  11410. }
  11411. else
  11412. {
  11413. SetBehaviorVariable( 'throwStage', (int)TS_End );
  11414.  
  11415. if ( stateName == 'Aiming' )
  11416. {
  11417. SetCustomRotation( 'Throw', VecHeading( this.GetLookAtPosition() - GetWorldPosition() ), 0.0f, 0.2f, false );
  11418. }
  11419. }
  11420. }
  11421.  
  11422. protected function UsableItemRelease()
  11423. {
  11424. OnDelayOrientationChangeOff();
  11425. SetBehaviorVariable( 'throwStage', (int)TS_End );
  11426. RemoveCustomOrientationTarget( 'UsableItems' );
  11427. }
  11428.  
  11429.  
  11430. public function ThrowingAbort()
  11431. {
  11432. var thrownEntity : CThrowable;
  11433.  
  11434. thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  11435.  
  11436. SetBehaviorVariable( 'throwStage', (int)TS_Stop );
  11437. RaiseEvent( 'actionStop' );
  11438.  
  11439. if( GetCurrentStateName() == 'AimThrow')
  11440. {
  11441. PopState();
  11442. thrownEntity.StopAiming( true );
  11443. }
  11444.  
  11445.  
  11446. if(thrownEntity && !thrownEntity.WasThrown())
  11447. {
  11448. thrownEntity.BreakAttachment();
  11449. thrownEntity.Destroy();
  11450. }
  11451. this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
  11452. }
  11453.  
  11454. public function CanSetupCombatAction_Throw() : bool
  11455. {
  11456.  
  11457. if(!inv.IsIdValid( selectedItemId ))
  11458. return false;
  11459.  
  11460.  
  11461. if(!inv.IsItemSingletonItem(selectedItemId))
  11462. return false;
  11463.  
  11464.  
  11465. if(!GetBIsInputAllowed())
  11466. return false;
  11467.  
  11468.  
  11469. if(inv.GetItemQuantity(GetSelectedItemId()) <= 0 && !inv.ItemHasTag(selectedItemId, theGame.params.TAG_INFINITE_AMMO))
  11470. return false;
  11471.  
  11472.  
  11473. if(!inputHandler.IsActionAllowed(EIAB_ThrowBomb) && GetCurrentStateName() != 'Swimming')
  11474. return false;
  11475.  
  11476. return true;
  11477. }
  11478.  
  11479. public function GetThrownEntity() : CThrowable
  11480. {
  11481. return (CThrowable)EntityHandleGet( thrownEntityHandle );
  11482. }
  11483.  
  11484.  
  11485. event OnWeaponWait() { rangedWeapon.OnWeaponWait(); }
  11486. event OnWeaponDrawStart() { rangedWeapon.OnWeaponDrawStart(); }
  11487. event OnWeaponReloadStart() { rangedWeapon.OnWeaponReloadStart(); }
  11488. event OnWeaponReloadEnd() { rangedWeapon.OnWeaponReloadEnd(); }
  11489. event OnWeaponAimStart() { rangedWeapon.OnWeaponAimStart(); }
  11490. event OnWeaponShootStart() { rangedWeapon.OnWeaponShootStart(); }
  11491. event OnWeaponShootEnd() { rangedWeapon.OnWeaponShootEnd(); }
  11492. event OnWeaponAimEnd() { rangedWeapon.OnWeaponAimEnd(); }
  11493. event OnWeaponHolsterStart() { rangedWeapon.OnWeaponHolsterStart(); }
  11494. event OnWeaponHolsterEnd() { rangedWeapon.OnWeaponHolsterEnd(); }
  11495. event OnWeaponToNormalTransStart() { rangedWeapon.OnWeaponToNormalTransStart(); }
  11496. event OnWeaponToNormalTransEnd() { rangedWeapon.OnWeaponToNormalTransEnd(); }
  11497.  
  11498. event OnEnableAimingMode( enable : bool )
  11499. {
  11500. if( !crossbowDontPopStateHack )
  11501. {
  11502. if ( enable )
  11503. PushState( 'AimThrow' );
  11504. else if ( GetCurrentStateName() == 'AimThrow' )
  11505. PopState();
  11506. }
  11507. }
  11508.  
  11509. event OnRangedForceHolster( optional forceUpperBodyAnim, instant, dropItem : bool )
  11510. {
  11511. if(rangedWeapon)
  11512. rangedWeapon.OnForceHolster( forceUpperBodyAnim, instant, dropItem );
  11513. }
  11514.  
  11515.  
  11516. public function IsCrossbowHeld() : bool
  11517. {
  11518. if (rangedWeapon)
  11519. return rangedWeapon.GetCurrentStateName() != 'State_WeaponWait';
  11520. return false;
  11521. }
  11522.  
  11523.  
  11524. event OnBlockAllCombatTickets( release : bool )
  11525. {
  11526. if (!release )
  11527. ((CR4PlayerStateCombat)GetState('Combat')).OnBlockAllCombatTickets(false);
  11528. }
  11529. event OnForceTicketUpdate() {}
  11530.  
  11531.  
  11532.  
  11533.  
  11534.  
  11535. event OnProcessActionPost(action : W3DamageAction)
  11536. {
  11537. var npc : CNewNPC;
  11538. var attackAction : W3Action_Attack;
  11539. var lifeLeech : float;
  11540.  
  11541. super.OnProcessActionPost(action);
  11542.  
  11543. attackAction = (W3Action_Attack)action;
  11544.  
  11545. if(attackAction)
  11546. {
  11547. npc = (CNewNPC)action.victim;
  11548.  
  11549. if(npc && npc.IsHuman() )
  11550. {
  11551. PlayBattleCry('BattleCryHumansHit', 0.05f );
  11552. }
  11553. else
  11554. {
  11555. PlayBattleCry('BattleCryMonstersHit', 0.05f );
  11556. }
  11557.  
  11558. if(attackAction.IsActionMelee())
  11559. {
  11560.  
  11561. IncreaseUninterruptedHitsCount();
  11562.  
  11563.  
  11564. if( IsLightAttack( attackAction.GetAttackName() ) )
  11565. {
  11566. GCameraShake(0.1, false, GetWorldPosition(), 10);
  11567. }
  11568.  
  11569.  
  11570. if(npc && inv.GetItemName(attackAction.GetWeaponId()) == 'PC Caretaker Shovel')
  11571. {
  11572.  
  11573. lifeLeech = CalculateAttributeValue(inv.GetItemAttributeValue(attackAction.GetWeaponId() ,'lifesteal'));
  11574. if (npc.UsesVitality())
  11575. lifeLeech *= action.processedDmg.vitalityDamage;
  11576. else if (UsesEssence())
  11577. lifeLeech *= action.processedDmg.essenceDamage;
  11578. else
  11579. lifeLeech = 0;
  11580.  
  11581. if ( lifeLeech > 0 )
  11582. {
  11583. inv.PlayItemEffect( attackAction.GetWeaponId(), 'stab_attack' );
  11584. PlayEffect('drain_energy_caretaker_shovel');
  11585. GainStat(BCS_Vitality, lifeLeech);
  11586. }
  11587. }
  11588. }
  11589. }
  11590. }
  11591.  
  11592. public function SetHitReactTransScale(f : float) {hitReactTransScale = f;}
  11593. public function GetHitReactTransScale() : float
  11594. {
  11595. if ( ( (CNewNPC)slideTarget ).GetIsTranslationScaled() )
  11596. return hitReactTransScale;
  11597. else
  11598. return 1.f;
  11599. }
  11600.  
  11601.  
  11602.  
  11603.  
  11604.  
  11605. public function GetHorseWithInventory() : CNewNPC
  11606. {
  11607. return (CNewNPC)EntityHandleGet( horseWithInventory );
  11608. }
  11609. public function GetHorseCurrentlyMounted() : CNewNPC
  11610. {
  11611. return currentlyMountedHorse;
  11612. }
  11613.  
  11614. public function _SetHorseCurrentlyMounted( horse : CNewNPC )
  11615. {
  11616. currentlyMountedHorse = horse;
  11617. }
  11618.  
  11619. public function WasHorseRecentlySummoned() : bool
  11620. {
  11621. if ( horseSummonTimeStamp + 5.f > theGame.GetEngineTimeAsSeconds() )
  11622. return true;
  11623.  
  11624. return false;
  11625. }
  11626.  
  11627. private const var MOUNT_DISTANCE_CBT : float;
  11628. default MOUNT_DISTANCE_CBT = 3.0;
  11629.  
  11630. private const var MOUNT_ANGLE_CBT : float;
  11631. default MOUNT_ANGLE_CBT = 35.0;
  11632.  
  11633. private const var MOUNT_ANGLE_EXP : float;
  11634. default MOUNT_ANGLE_EXP = 45.0;
  11635.  
  11636. public function IsMountingHorseAllowed( optional alwaysAllowedInExploration : bool ) : bool
  11637. {
  11638. var angle : float;
  11639. var distance : float;
  11640.  
  11641. if( IsInsideHorseInteraction() )
  11642. {
  11643. angle = AngleDistance( thePlayer.rawPlayerHeading, VecHeading( thePlayer.horseInteractionSource.GetWorldPosition() - thePlayer.GetWorldPosition() ) );
  11644.  
  11645. if( thePlayer.IsInCombat() )
  11646. {
  11647. if( AbsF( angle ) < MOUNT_ANGLE_CBT )
  11648. {
  11649. distance = VecDistance( thePlayer.GetWorldPosition(), thePlayer.horseInteractionSource.GetWorldPosition() );
  11650.  
  11651. if( distance < MOUNT_DISTANCE_CBT )
  11652. {
  11653. return true;
  11654. }
  11655. else
  11656. {
  11657. return false;
  11658. }
  11659. }
  11660. else
  11661. {
  11662. return false;
  11663. }
  11664.  
  11665. }
  11666. else
  11667. {
  11668. if( alwaysAllowedInExploration )
  11669. {
  11670. return true;
  11671. }
  11672. else
  11673. {
  11674. if( AbsF( angle ) < MOUNT_ANGLE_EXP )
  11675. {
  11676. return true;
  11677. }
  11678. else
  11679. {
  11680. return false;
  11681. }
  11682. }
  11683. }
  11684. }
  11685. else
  11686. {
  11687. return false;
  11688. }
  11689. }
  11690.  
  11691. public function FollowActor( actor : CActor )
  11692. {
  11693. var l_aiTreeDecorator : CAIPlayerActionDecorator;
  11694. var l_aiTree_onFoot : CAIFollowSideBySideAction;
  11695. var l_aiTree_onHorse : CAIRiderFollowSideBySideAction;
  11696. var l_success : bool = false;
  11697.  
  11698. actor.AddTag( 'playerFollowing' );
  11699.  
  11700. if( thePlayer.IsUsingHorse() )
  11701. {
  11702. l_aiTree_onHorse = new CAIRiderFollowSideBySideAction in this;
  11703. l_aiTree_onHorse.OnCreated();
  11704.  
  11705. l_aiTree_onHorse.params.targetTag = 'playerFollowing';
  11706. }
  11707. else
  11708. {
  11709. l_aiTree_onFoot = new CAIFollowSideBySideAction in this;
  11710. l_aiTree_onFoot.OnCreated();
  11711.  
  11712. l_aiTree_onFoot.params.targetTag = 'playerFollowing';
  11713. }
  11714.  
  11715. l_aiTreeDecorator = new CAIPlayerActionDecorator in this;
  11716. l_aiTreeDecorator.OnCreated();
  11717. l_aiTreeDecorator.interruptOnInput = false;
  11718.  
  11719. if( thePlayer.IsUsingHorse() )
  11720. l_aiTreeDecorator.scriptedAction = l_aiTree_onHorse;
  11721. else
  11722. l_aiTreeDecorator.scriptedAction = l_aiTree_onFoot;
  11723.  
  11724. if( l_aiTreeDecorator )
  11725. l_success = ForceAIBehavior( l_aiTreeDecorator, BTAP_Emergency );
  11726. else if( thePlayer.IsUsingHorse() )
  11727. l_success = ForceAIBehavior( l_aiTree_onHorse, BTAP_Emergency );
  11728. else
  11729. l_success = ForceAIBehavior( l_aiTree_onFoot, BTAP_Emergency );
  11730.  
  11731. if ( l_success )
  11732. {
  11733. GetMovingAgentComponent().SetGameplayRelativeMoveSpeed( 0.0f );
  11734. }
  11735. }
  11736.  
  11737. public function SetCanFollowNpc( val : bool, actor : CActor ) { canFollowNpc = val; actorToFollow = actor; }
  11738. public function CanFollowNpc() : bool { return canFollowNpc; }
  11739. public function GetActorToFollow() : CActor { return actorToFollow; }
  11740.  
  11741.  
  11742.  
  11743.  
  11744.  
  11745.  
  11746.  
  11747. public function SetIsSwimming ( toggle : bool )
  11748. {
  11749. if( isSwimming != toggle )
  11750. {
  11751. thePlayer.substateManager.SetBehaviorParamBool( 'isSwimmingForOverlay', toggle );
  11752. isSwimming = toggle;
  11753. }
  11754. }
  11755.  
  11756.  
  11757.  
  11758.  
  11759.  
  11760.  
  11761.  
  11762. public function RepairItemUsingConsumable(item, consumable : SItemUniqueId) : bool
  11763. {
  11764. var curr, max, repairValue, itemValue, repairBonus, newDurability : float;
  11765.  
  11766.  
  11767. if(!inv.IsIdValid(item) || !inv.IsIdValid(consumable) || !inv.HasItemDurability(item))
  11768. return false;
  11769.  
  11770. curr = inv.GetItemDurability(item);
  11771. max = inv.GetItemMaxDurability(item);
  11772.  
  11773.  
  11774. if(curr > max)
  11775. return false;
  11776.  
  11777.  
  11778. if( (inv.IsItemAnyArmor(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_ARMOR)) ||
  11779. (inv.IsItemSilverSwordUsableByPlayer(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_SILVER)) ||
  11780. (inv.IsItemSteelSwordUsableByPlayer(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_STEEL)) )
  11781. {
  11782.  
  11783. itemValue = CalculateAttributeValue(inv.GetItemAttributeValue(consumable, 'durabilityRepairValue'));
  11784. if(itemValue <= 0)
  11785. {
  11786. LogAssert(false, "CR4Player.RepairItemUsingConsumable: consumable <<" + inv.GetItemName(consumable) + ">> has <=0 durabilityRepairValue!!!");
  11787. return false;
  11788. }
  11789. repairBonus = CalculateAttributeValue(inv.GetItemAttributeValue(consumable, 'durabilityBonusValue'));
  11790.  
  11791.  
  11792. repairValue = max * itemValue /100;
  11793.  
  11794.  
  11795.  
  11796. newDurability = MinF(max, curr + repairValue);
  11797.  
  11798. inv.SetItemDurabilityScript(item, newDurability);
  11799.  
  11800.  
  11801. inv.RemoveItem(consumable);
  11802.  
  11803. return true;
  11804. }
  11805. return false;
  11806. }
  11807.  
  11808.  
  11809.  
  11810.  
  11811.  
  11812.  
  11813.  
  11814.  
  11815.  
  11816.  
  11817. private function CheckDayNightCycle()
  11818. {
  11819. var time : GameTime;
  11820. var isNight : bool;
  11821.  
  11822.  
  11823. isNight = theGame.envMgr.IsNight();
  11824. if(prevDayNightIsNight != isNight)
  11825. {
  11826. if(isNight)
  11827. OnNightStarted();
  11828. else
  11829. OnDayStarted();
  11830.  
  11831. prevDayNightIsNight = isNight;
  11832. }
  11833.  
  11834.  
  11835. if(isNight)
  11836. time = theGame.envMgr.GetGameTimeTillNextDay();
  11837. else
  11838. time = theGame.envMgr.GetGameTimeTillNextNight();
  11839.  
  11840. AddGameTimeTimer('DayNightCycle', time);
  11841. }
  11842.  
  11843. timer function DayNightCycle(dt : GameTime, id : int)
  11844. {
  11845. CheckDayNightCycle();
  11846. }
  11847.  
  11848. event OnNightStarted()
  11849. {
  11850. var pam : W3PlayerAbilityManager;
  11851.  
  11852. if(CanUseSkill(S_Perk_01))
  11853. {
  11854. pam = (W3PlayerAbilityManager)abilityManager;
  11855. pam.SetPerk01Abilities(false, true);
  11856. }
  11857. }
  11858.  
  11859. event OnDayStarted()
  11860. {
  11861. var pam : W3PlayerAbilityManager;
  11862.  
  11863. if(CanUseSkill(S_Perk_01))
  11864. {
  11865. pam = (W3PlayerAbilityManager)abilityManager;
  11866. pam.SetPerk01Abilities(true, false);
  11867. }
  11868. }
  11869.  
  11870.  
  11871.  
  11872.  
  11873.  
  11874. public function ForceUnlockAllInputActions(alsoQuestLocks : bool)
  11875. {
  11876. if ( inputHandler )
  11877. inputHandler.ForceUnlockAllInputActions(alsoQuestLocks);
  11878. }
  11879.  
  11880. public function SetPrevRawLeftJoyRot()
  11881. {
  11882. prevRawLeftJoyRot = rawLeftJoyRot;
  11883. }
  11884.  
  11885. public function GetPrevRawLeftJoyRot() : float
  11886. {
  11887. return prevRawLeftJoyRot;
  11888. }
  11889.  
  11890. public function GetExplorationInputContext() : name
  11891. {
  11892. return explorationInputContext;
  11893. }
  11894.  
  11895. public function GetCombatInputContext() : name
  11896. {
  11897. return combatInputContext;
  11898. }
  11899.  
  11900.  
  11901.  
  11902.  
  11903.  
  11904. public function SetIsOnBoat(b : bool)
  11905. {
  11906. isOnBoat = b;
  11907. }
  11908.  
  11909. public function IsOnBoat() : bool
  11910. {
  11911. return isOnBoat;
  11912. }
  11913.  
  11914. public function IsInShallowWater() : bool
  11915. {
  11916. return isInShallowWater;
  11917. }
  11918.  
  11919. event OnEnterShallowWater()
  11920. {
  11921. if ( isInShallowWater )
  11922. return false;
  11923.  
  11924. isInShallowWater = true;
  11925. BlockAction( EIAB_Dodge,'ShallowWater', false, false, true );
  11926. BlockAction( EIAB_Sprint,'ShallowWater', false, false, true );
  11927. BlockAction( EIAB_Crossbow,'ShallowWater', false, false, true );
  11928. BlockAction( EIAB_Jump,'ShallowWater', false, false, true );
  11929. SetBehaviorVariable( 'shallowWater',1.0);
  11930. }
  11931. event OnExitShallowWater()
  11932. {
  11933. if ( !isInShallowWater )
  11934. return false;
  11935.  
  11936. isInShallowWater = false;
  11937. BlockAllActions('ShallowWater',false);
  11938. SetBehaviorVariable( 'shallowWater',0.0);
  11939. }
  11940.  
  11941. public function TestIsInSettlement() : bool
  11942. {
  11943. return IsInSettlement();
  11944. }
  11945.  
  11946.  
  11947.  
  11948.  
  11949.  
  11950.  
  11951. public function ProcessGlossaryImageOverride( defaultImage : string, uniqueTag : name ) : string
  11952. {
  11953. var size : int;
  11954. var i : int;
  11955.  
  11956. size = glossaryImageOverride.Size();
  11957.  
  11958. if( size == 0 )
  11959. return defaultImage;
  11960.  
  11961. for( i = 0; i < size; i += 1 )
  11962. {
  11963. if( glossaryImageOverride[i].uniqueTag == uniqueTag )
  11964. return glossaryImageOverride[i].imageFileName;
  11965.  
  11966. }
  11967.  
  11968. return defaultImage;
  11969. }
  11970.  
  11971.  
  11972. public function EnableGlossaryImageOverride( uniqueTag : name, imageFileName : string, enable : bool )
  11973. {
  11974. var imageData : SGlossaryImageOverride;
  11975. var size : int;
  11976. var i : int;
  11977.  
  11978. for( i = 0; i < glossaryImageOverride.Size(); i += 1 )
  11979. {
  11980. if( glossaryImageOverride[i].uniqueTag == uniqueTag )
  11981. {
  11982. glossaryImageOverride.Remove(glossaryImageOverride[i]);
  11983. }
  11984. }
  11985.  
  11986. if( enable )
  11987. {
  11988. if( IsNameValid(uniqueTag) && imageFileName != "" )
  11989. {
  11990. glossaryImageOverride.PushBack( SGlossaryImageOverride( uniqueTag, imageFileName ) );
  11991. }
  11992. }
  11993. }
  11994.  
  11995.  
  11996.  
  11997. public function SetWeatherDisplayDisabled( disable : bool )
  11998. {
  11999. disableWeatherDisplay = disable;
  12000. }
  12001.  
  12002. public function GetWeatherDisplayDisabled() : bool
  12003. {
  12004. return disableWeatherDisplay;
  12005. }
  12006.  
  12007.  
  12008.  
  12009.  
  12010.  
  12011. public function SetCurrentMonsterHuntInvestigationArea ( area : W3MonsterHuntInvestigationArea )
  12012. {
  12013. currentMonsterHuntInvestigationArea = area;
  12014. }
  12015.  
  12016.  
  12017.  
  12018.  
  12019.  
  12020.  
  12021. public function RememberCustomHead( headName : name )
  12022. {
  12023. rememberedCustomHead = headName;
  12024. }
  12025.  
  12026. public function GetRememberedCustomHead() : name
  12027. {
  12028. return rememberedCustomHead;
  12029. }
  12030.  
  12031. public function ClearRememberedCustomHead()
  12032. {
  12033. rememberedCustomHead = '';
  12034. }
  12035.  
  12036.  
  12037.  
  12038.  
  12039.  
  12040. public function CreateTutorialInput()
  12041. {
  12042. var prevInputHandler : CPlayerInput;
  12043.  
  12044. prevInputHandler = inputHandler;
  12045. inputHandler = new W3PlayerTutorialInput in this;
  12046. inputHandler.Initialize(false, prevInputHandler);
  12047.  
  12048. if(prevInputHandler)
  12049. delete prevInputHandler;
  12050. }
  12051.  
  12052. public function CreateInput()
  12053. {
  12054. var oldInputHandler : CPlayerInput;
  12055.  
  12056. oldInputHandler = inputHandler;
  12057. inputHandler = new CPlayerInput in this;
  12058. inputHandler.Initialize(false, oldInputHandler);
  12059. }
  12060.  
  12061. timer function TutorialSilverCombat(dt : float, id : int)
  12062. {
  12063. var i : int;
  12064. var actors : array<CActor>;
  12065.  
  12066. if(IsInCombat())
  12067. {
  12068. actors = GetNPCsAndPlayersInRange(20, 1000000, ,FLAG_ExcludePlayer + FLAG_OnlyAliveActors);
  12069. for(i=0; i<actors.Size(); i+=1)
  12070. {
  12071. if(actors[i] && IsRequiredAttitudeBetween(this, actors[i], true) && actors[i].UsesEssence())
  12072. {
  12073. FactsAdd("TutorialShowSilver");
  12074.  
  12075. RemoveTimer('TutorialSilverCombat');
  12076. break;
  12077. }
  12078. }
  12079. }
  12080. }
  12081.  
  12082. private saved var m_bossTag : name;
  12083.  
  12084. public function GetBossTag() : name
  12085. {
  12086. return m_bossTag;
  12087. }
  12088.  
  12089. public function SetBossTag( bossTag : name )
  12090. {
  12091. m_bossTag = bossTag;
  12092. }
  12093.  
  12094. private saved var m_usingCoatOfArms : bool; default m_usingCoatOfArms = false;
  12095.  
  12096. public function IsUsingCoatOfArms() : bool
  12097. {
  12098. return m_usingCoatOfArms;
  12099. }
  12100.  
  12101. public function SetUsingCoatOfArms( using : bool)
  12102. {
  12103. m_usingCoatOfArms = using;
  12104. }
  12105.  
  12106. private saved var m_initialTimeOut : float;
  12107. private saved var m_currentTimeOut : float;
  12108.  
  12109. public function GetInitialTimeOut() : float
  12110. {
  12111. return m_initialTimeOut;
  12112. }
  12113.  
  12114. public function SetInitialTimeOut( timeOut : float )
  12115. {
  12116. m_initialTimeOut = timeOut;
  12117. }
  12118.  
  12119. public function GetCurrentTimeOut() : float
  12120. {
  12121. return m_currentTimeOut;
  12122. }
  12123.  
  12124. public function SetCurrentTimeOut( timeOut : float )
  12125. {
  12126. m_currentTimeOut = timeOut;
  12127. }
  12128.  
  12129.  
  12130.  
  12131.  
  12132.  
  12133.  
  12134. timer function DelayedFinisherInputTimer(dt : float, id : int)
  12135. {
  12136.  
  12137.  
  12138. }
  12139.  
  12140. timer function RemoveFinisherCameraAnimationCheck(dt : float, id : int)
  12141. {
  12142. if ( !isInFinisher && !bLAxisReleased )
  12143. {
  12144. theGame.GetSyncAnimManager().OnRemoveFinisherCameraAnimation();
  12145. RemoveTimer( 'RemoveFinisherCameraAnimationCheck' );
  12146. }
  12147. }
  12148.  
  12149.  
  12150.  
  12151.  
  12152.  
  12153. timer function GameplayFactRemove(dt : float, timerId : int)
  12154. {
  12155. theGame.GameplayFactRemoveFromTimer(timerId);
  12156. }
  12157.  
  12158.  
  12159. timer function GiveStartingItems(dt : float, timerId : int)
  12160. {
  12161. var template : CEntityTemplate;
  12162. var invEntity : CInventoryComponent;
  12163. var entity : CEntity;
  12164. var items : array<SItemUniqueId>;
  12165. var id : SItemUniqueId;
  12166. var i : int;
  12167.  
  12168.  
  12169. if(inv)
  12170. {
  12171. inv.GetAllItems(items);
  12172. if(items.Size() <= 0)
  12173. {
  12174. return;
  12175. }
  12176. }
  12177. else
  12178. {
  12179. return;
  12180. }
  12181.  
  12182.  
  12183. template = (CEntityTemplate)LoadResource("geralt_inventory_release");
  12184. entity = theGame.CreateEntity(template, Vector(0,0,0));
  12185. invEntity = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  12186.  
  12187. invEntity.GetAllItems(items);
  12188. for(i=0; i<items.Size(); i+=1)
  12189. {
  12190. id = invEntity.GiveItemTo(inv, items[i], 0, false, true);
  12191. if ( inv.ItemHasTag(id,'Scabbard') )
  12192. {
  12193. inv.MountItem(id);
  12194. }
  12195. else if(!inv.IsItemFists(id) && inv.GetItemName(id) != 'Cat 1')
  12196. {
  12197. EquipItem(id);
  12198. }
  12199. else if(inv.IsItemSingletonItem(id))
  12200. {
  12201. inv.SingletonItemSetAmmo(id, inv.SingletonItemGetMaxAmmo(id));
  12202. }
  12203. }
  12204.  
  12205. entity.Destroy();
  12206.  
  12207.  
  12208. RemoveTimer('GiveStartingItems');
  12209. }
  12210.  
  12211.  
  12212.  
  12213. timer function Debug_GiveTestingItems(dt : float, optional id : int)
  12214. {
  12215. var template : CEntityTemplate;
  12216. var invTesting : CInventoryComponent;
  12217. var entity : CEntity;
  12218. var items : array<SItemUniqueId>;
  12219. var i : int;
  12220. var slot : EEquipmentSlots;
  12221.  
  12222.  
  12223. if(inv)
  12224. {
  12225. inv.GetAllItems(items);
  12226. if(items.Size() <= 0)
  12227. {
  12228. return;
  12229. }
  12230. }
  12231. else
  12232. {
  12233. return;
  12234. }
  12235.  
  12236. template = (CEntityTemplate)LoadResource("geralt_inventory_internal");
  12237. entity = theGame.CreateEntity(template, Vector(0,0,0));
  12238. invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  12239. invTesting.GiveAllItemsTo(inv, true);
  12240. entity.Destroy();
  12241.  
  12242.  
  12243. RemoveTimer('Debug_GiveTestingItems');
  12244.  
  12245.  
  12246. inv.GetAllItems(items);
  12247.  
  12248. for(i=0; i<items.Size(); i+=1)
  12249. {
  12250. if( inv.IsItemCrossbow(items[i]) || inv.IsItemBomb(items[i]) )
  12251. {
  12252. slot = inv.GetSlotForItemId(items[i]);
  12253. EquipItem(items[i], slot);
  12254.  
  12255. if( (W3PlayerWitcher)this && inv.IsItemCrossbow(items[i]) )
  12256. GetWitcherPlayer().SelectQuickslotItem(slot);
  12257. }
  12258. else if(inv.IsItemBolt(items[i]))
  12259. {
  12260. slot = inv.GetSlotForItemId(items[i]);
  12261. EquipItem(items[i], slot);
  12262. }
  12263.  
  12264. if(inv.IsItemSingletonItem(items[i]))
  12265. {
  12266. inv.SingletonItemSetAmmo(items[i], inv.SingletonItemGetMaxAmmo(items[i]));
  12267. }
  12268. }
  12269. }
  12270.  
  12271.  
  12272. timer function Debug_RemoveTestingItems(dt : float, id : int)
  12273. {
  12274. var template : CEntityTemplate;
  12275. var entity : CEntity;
  12276. var invTesting : CInventoryComponent;
  12277. var ids : array<SItemUniqueId>;
  12278. var i : int;
  12279.  
  12280. template = (CEntityTemplate)LoadResource("geralt_inventory_internal");
  12281. entity = theGame.CreateEntity(template, Vector(0,0,0));
  12282. invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  12283. invTesting.GetAllItems(ids);
  12284.  
  12285. for(i=0; i<ids.Size(); i+=1)
  12286. inv.RemoveItemByName(invTesting.GetItemName(ids[i]), invTesting.GetItemQuantity(ids[i]));
  12287.  
  12288. entity.Destroy();
  12289. RemoveTimer('Debug_RemoveTestingItems');
  12290. }
  12291.  
  12292. timer function Debug_DelayedConsoleCommand(dt : float, id : int)
  12293. {
  12294.  
  12295. inv.AddAnItem('Boots 2 schematic');
  12296. }
  12297.  
  12298. function DBG_SkillSlots()
  12299. {
  12300. ((W3PlayerAbilityManager)abilityManager).DBG_SkillSlots();
  12301. }
  12302.  
  12303.  
  12304.  
  12305.  
  12306.  
  12307. public final function SetPadBacklightColor(r, g, b : int)
  12308. {
  12309. var padBacklightColor : Vector;
  12310.  
  12311. padBacklightColor.X = r / 255;
  12312. padBacklightColor.Y = g / 255;
  12313. padBacklightColor.Z = b / 255;
  12314.  
  12315. SetBacklightColor(padBacklightColor);
  12316. }
  12317.  
  12318. public final function SetPadBacklightColorFromSign(signType : ESignType)
  12319. {
  12320. LogPS4Light("SetPadBacklightColorFromSign... " + signType);
  12321.  
  12322. switch(signType)
  12323. {
  12324. case ST_Yrden: SetPadBacklightColor( 200 , 81 , 255 ); break;
  12325. case ST_Quen: SetPadBacklightColor( 255 , 205 , 68 ); break;
  12326. case ST_Igni: SetPadBacklightColor( 255 , 79 , 10 ); break;
  12327. case ST_Axii: SetPadBacklightColor( 255 , 255 , 255 ); break;
  12328. case ST_Aard: SetPadBacklightColor( 158 , 214 , 255 ); break;
  12329. }
  12330. }
  12331.  
  12332. timer function ResetPadBacklightColorTimer(dt : float, id : int)
  12333. {
  12334. ResetPadBacklightColor();
  12335. }
  12336.  
  12337. public final function ResetPadBacklightColor(optional skipHeldWeapon : bool)
  12338. {
  12339. var weapons : array<SItemUniqueId>;
  12340. var sword : CWitcherSword;
  12341. var healthPercentage : float;
  12342. var tmpBacklight : Vector;
  12343.  
  12344. if(!skipHeldWeapon)
  12345. {
  12346. weapons = inv.GetHeldWeapons();
  12347.  
  12348.  
  12349. if(weapons.Size() > 0)
  12350. {
  12351. sword = (CWitcherSword)inv.GetItemEntityUnsafe(weapons[0]);
  12352. if(sword)
  12353. {
  12354. tmpBacklight.X = sword.padBacklightColor.X / 255.0f;
  12355. tmpBacklight.Y = sword.padBacklightColor.Y / 255.0f;
  12356. tmpBacklight.Z = sword.padBacklightColor.Z / 255.0f;
  12357. tmpBacklight.W = 1.0f;
  12358. SetBacklightColor( tmpBacklight );
  12359. LogPS4Light("Setting light from sword template: " + NoTrailZeros(sword.padBacklightColor.X) + ", " + NoTrailZeros(sword.padBacklightColor.Y) + ", " + NoTrailZeros(sword.padBacklightColor.Z) );
  12360. return;
  12361. }
  12362. }
  12363. }
  12364.  
  12365. healthPercentage = GetStatPercents( BCS_Vitality );
  12366. SetBacklightFromHealth( healthPercentage );
  12367. LogPS4Light("Setting light from health, " + NoTrailZeros(RoundMath(healthPercentage*100)) + "%");
  12368. }
  12369.  
  12370.  
  12371.  
  12372. event OnOpenningDoor()
  12373. {
  12374. if( !thePlayer.IsUsingHorse() )
  12375. RaiseEvent('OpenDoor');
  12376. }
  12377.  
  12378. public final function SetLoopingCameraShakeAnimName( n : name )
  12379. {
  12380. loopingCameraShakeAnimName = n;
  12381. }
  12382.  
  12383. public var loopingCameraShakeAnimName : name;
  12384. timer function RemoveQuestCameraShakeTimer( dt : float , id : int)
  12385. {
  12386. RemoveQuestCameraShake( loopingCameraShakeAnimName );
  12387. }
  12388.  
  12389. public function RemoveQuestCameraShake( animName : name )
  12390. {
  12391. var camera : CCustomCamera = theGame.GetGameCamera();
  12392. var animation : SCameraAnimationDefinition;
  12393.  
  12394. camera.StopAnimation( animName );
  12395. }
  12396.  
  12397. public function GetCameraPadding() : float
  12398. {
  12399. if( theGame.IsFocusModeActive() )
  12400. {
  12401. return 0.25;
  12402. }
  12403. else
  12404. {
  12405. return 0.02f;
  12406. }
  12407. }
  12408.  
  12409. public function IsPerformingPhaseChangeAnimation() : bool { return isPerformingPhaseChangeAnimation; }
  12410. public function SetIsPerformingPhaseChangeAnimation( val : bool ) { isPerformingPhaseChangeAnimation = val; }
  12411.  
  12412. private function DealCounterDamageToOlgierd()
  12413. {
  12414. var damage : W3DamageAction;
  12415.  
  12416. damage = new W3DamageAction in this;
  12417.  
  12418. damage.Initialize( thePlayer.GetTarget(), thePlayer.GetTarget(), NULL, this, EHRT_None, CPS_Undefined, false, false, false, true );
  12419. damage.AddDamage( theGame.params.DAMAGE_NAME_DIRECT, thePlayer.GetTarget().GetStatMax( BCS_Vitality ) * 3 / 100 );
  12420. theGame.damageMgr.ProcessAction( damage );
  12421.  
  12422. delete damage;
  12423. }
  12424.  
  12425. timer function PlayDelayedCounterDamageEffect( dt : float, id : int )
  12426. {
  12427. thePlayer.GetTarget().PlayEffect( 'olgierd_energy_blast' );
  12428. }
  12429.  
  12430.  
  12431. public function SetTestAdjustRequestedMovementDirection( val : bool )
  12432. {
  12433. testAdjustRequestedMovementDirection = val;
  12434. }
  12435.  
  12436. event OnVisualDebug( frame : CScriptedRenderFrame, flag : EShowFlags )
  12437. {
  12438. var boneFollow : int;
  12439. var bonePosition : Vector;
  12440. var yrdenEntity : W3YrdenEntity;
  12441.  
  12442. substateManager.OnVisualDebug( frame, flag );
  12443.  
  12444. boneFollow = thePlayer.GetBoneIndex( 'Reference' );
  12445. bonePosition = MatrixGetTranslation( thePlayer.GetBoneWorldMatrixByIndex( boneFollow ) );
  12446. frame.DrawText( "R", bonePosition, Color( 50, 200, 70 ) );
  12447.  
  12448.  
  12449. boneFollow = thePlayer.GetBoneIndex( 'Trajectory' );
  12450. bonePosition = MatrixGetTranslation( thePlayer.GetBoneWorldMatrixByIndex( boneFollow ) );
  12451. frame.DrawSphere( bonePosition, 0.1f, Color( 200, 50, 70 ) );
  12452. frame.DrawText( "T", bonePosition, Color( 200, 50, 70 ) );
  12453.  
  12454.  
  12455.  
  12456.  
  12457. yrdenEntity = (W3YrdenEntity)GetWitcherPlayer().GetSignEntity(ST_Yrden);
  12458. yrdenEntity.OnVisualDebug(frame, flag, false);
  12459.  
  12460. return true;
  12461. }
  12462.  
  12463. timer function PotDrinkTimer(dt : float, id : int)
  12464. {
  12465. inputHandler.PotDrinkTimer(false);
  12466. }
  12467.  
  12468. public function SetIsHorseRacing( val : bool )
  12469. {
  12470. isHorseRacing = val;
  12471. }
  12472.  
  12473. public function GetIsHorseRacing() : bool
  12474. {
  12475. return isHorseRacing;
  12476. }
  12477.  
  12478. public function SetHorseCombatSlowMo( val : bool )
  12479. {
  12480. horseCombatSlowMo = val;
  12481. }
  12482.  
  12483. public function GetHorseCombatSlowMo() : bool
  12484. {
  12485. return horseCombatSlowMo;
  12486. }
  12487.  
  12488. public function SetItemsPerLevelGiven( id : int )
  12489. {
  12490. itemsPerLevelGiven[id] = true;
  12491. }
  12492.  
  12493. private function AddItemPerLevelList()
  12494. {
  12495. var i : int;
  12496.  
  12497. itemsPerLevel.Clear();
  12498. itemsPerLevel.PushBack('O');
  12499. itemsPerLevel.PushBack('No Mans Land sword 2');
  12500. itemsPerLevel.PushBack('No Mans Land sword 3');
  12501. itemsPerLevel.PushBack('Silver sword 2');
  12502. itemsPerLevel.PushBack('Boots 01');
  12503. itemsPerLevel.PushBack('Novigraadan sword 2');
  12504. itemsPerLevel.PushBack('Light armor 01');
  12505. itemsPerLevel.PushBack('Heavy boots 01');
  12506. itemsPerLevel.PushBack('Nilfgaardian sword 3');
  12507. itemsPerLevel.PushBack('Silver sword 3');
  12508. itemsPerLevel.PushBack('Heavy gloves 01');
  12509. itemsPerLevel.PushBack('Skellige sword 2');
  12510. itemsPerLevel.PushBack('Heavy pants 01');
  12511. itemsPerLevel.PushBack('Silver sword 4');
  12512. itemsPerLevel.PushBack('No Mans Land sword 4');
  12513. itemsPerLevel.PushBack('Heavy armor 01');
  12514. itemsPerLevel.PushBack('Heavy boots 02');
  12515. itemsPerLevel.PushBack('Skellige sword 3');
  12516. itemsPerLevel.PushBack('Silver sword 5');
  12517. itemsPerLevel.PushBack('Heavy pants 02');
  12518. itemsPerLevel.PushBack('Heavy gloves 02');
  12519. itemsPerLevel.PushBack('Heavy gloves 02');
  12520. itemsPerLevel.PushBack('Heavy armor 02');
  12521. itemsPerLevel.PushBack('Scoiatael sword 1');
  12522.  
  12523. if ( itemsPerLevelGiven.Size() < 49 )
  12524. {
  12525. itemsPerLevelGiven.Clear();
  12526. for (i = 0; i < itemsPerLevel.Size(); i += 1) { itemsPerLevelGiven.PushBack( false ); }
  12527. }
  12528. }
  12529.  
  12530.  
  12531. public function DealDamageToBoat( dmg : float, index : int, optional globalHitPos : Vector )
  12532. {
  12533. var boat : CBoatDestructionComponent;
  12534.  
  12535. if(usedVehicle)
  12536. {
  12537. boat = (CBoatDestructionComponent) usedVehicle.GetComponentByClassName( 'CBoatDestructionComponent' );
  12538. if( boat )
  12539. {
  12540. boat.DealDamage( dmg, index, globalHitPos );
  12541. }
  12542. }
  12543. }
  12544.  
  12545.  
  12546.  
  12547.  
  12548.  
  12549. public function OnStartTeleportingPlayerToPlayableArea()
  12550. {
  12551. var FADEOUT_INTERVAL : float = 0.5;
  12552.  
  12553.  
  12554. if ( thePlayer.IsUsingHorse() )
  12555. {
  12556. if ( thePlayer.GetUsedHorseComponent().OnCheckHorseJump() )
  12557. {
  12558. thePlayer.GetUsedHorseComponent().SetCanTakeDamageFromFalling( false );
  12559. }
  12560. }
  12561.  
  12562. if ( thePlayer.IsActionAllowed( EIAB_FastTravel ) )
  12563. {
  12564. OnOpenMapToLetPlayerGoBackToPlayableArea();
  12565. }
  12566. else
  12567. {
  12568. theGame.FadeOutAsync( FADEOUT_INTERVAL );
  12569. thePlayer.AddTimer( 'BorderTeleportFadeOutTimer', FADEOUT_INTERVAL, false );
  12570. }
  12571. }
  12572.  
  12573. timer function BorderTeleportFadeOutTimer( dt : float, id : int )
  12574. {
  12575. OnTeleportPlayerToPlayableArea( false );
  12576. }
  12577.  
  12578. public function OnOpenMapToLetPlayerGoBackToPlayableArea()
  12579. {
  12580. var initData : W3MapInitData;
  12581.  
  12582. initData = new W3MapInitData in this;
  12583. initData.SetTriggeredExitEntity( true );
  12584. initData.ignoreSaveSystem = true;
  12585. initData.setDefaultState('FastTravel');
  12586. theGame.RequestMenuWithBackground( 'MapMenu', 'CommonMenu', initData );
  12587. }
  12588.  
  12589. public function OnTeleportPlayerToPlayableArea( afterClosingMap : bool )
  12590. {
  12591. var BLACKSCREEN_INTERVAL : float = 0.1;
  12592. var manager : CCommonMapManager = theGame.GetCommonMapManager();
  12593.  
  12594. thePlayer.TeleportWithRotation( manager.GetBorderTeleportPosition(), manager.GetBorderTeleportRotation() );
  12595. thePlayer.AddTimer( 'BorderTeleportFadeInTimer', BLACKSCREEN_INTERVAL, false );
  12596.  
  12597. theGame.FadeOutAsync( 0 );
  12598. theGame.SetFadeLock('PlayerTeleportation');
  12599. }
  12600.  
  12601. timer function BorderTeleportFadeInTimer( dt : float, id : int )
  12602. {
  12603. theGame.ResetFadeLock('PlayerTeleportation');
  12604. theGame.FadeOutAsync( 0 );
  12605. theGame.FadeInAsync( 2.0f );
  12606. }
  12607.  
  12608. public final function SetLastInstantKillTime(g : GameTime)
  12609. {
  12610. lastInstantKillTime = g;
  12611. }
  12612.  
  12613.  
  12614.  
  12615.  
  12616.  
  12617. timer function TestTimer(dt : float, id : int )
  12618. {
  12619. LogChannel('asdf', "asdf");
  12620. theGame.FadeOutAsync( 5 );
  12621. }
  12622.  
  12623. public final function Debug_ReleaseCriticalStateSaveLocks()
  12624. {
  12625. effectManager.Debug_ReleaseCriticalStateSaveLocks();
  12626. }
  12627.  
  12628. timer function Debug_SpamSpeed(dt : float, id : int)
  12629. {
  12630. if(currentlyMountedHorse)
  12631. {
  12632. LogSpeed("curr player's horse speed: " + NoTrailZeros(currentlyMountedHorse.GetMovingAgentComponent().GetSpeed())) ;
  12633. }
  12634. else
  12635. {
  12636. LogSpeed("curr player speed: " + NoTrailZeros(GetMovingAgentComponent().GetSpeed())) ;
  12637. }
  12638. }
  12639.  
  12640. timer function RemoveInstantKillSloMo(dt : float, id : int)
  12641. {
  12642. theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_InstantKill) );
  12643. }
  12644.  
  12645. timer function RemoveForceFinisher(dt : float, id : int)
  12646. {
  12647. forceFinisher = false;
  12648. }
  12649.  
  12650. public final function Debug_ClearAllActionLocks(optional action : EInputActionBlock, optional all : bool)
  12651. {
  12652. inputHandler.Debug_ClearAllActionLocks(action, all);
  12653. }
  12654.  
  12655. function OnFocusedCameraBlendBegin() {}
  12656. function OnFocusedCameraBlendUpdate( progress : float ) {}
  12657. function OnFocusedCameraBlendEnd() {}
  12658.  
  12659. public function GetEtherealCount() : int { return etherealCount; }
  12660. public function IncrementEtherealCount()
  12661. {
  12662. etherealCount += 1;
  12663. if( etherealCount == 6 )
  12664. ResetEtherealCount();
  12665. }
  12666. public function ResetEtherealCount() { etherealCount = 0; }
  12667.  
  12668. public function SetInsideDiveAttackArea( val : bool ) { insideDiveAttackArea = val; }
  12669. public function IsInsideDiveAttackArea() : bool { return insideDiveAttackArea; }
  12670. public function SetDiveAreaNumber( val : int ) { diveAreaNumber = val; }
  12671. public function GetDiveAreaNumber() : int { return diveAreaNumber; }
  12672.  
  12673.  
  12674.  
  12675. public function InitPhantomWeaponMgr()
  12676. {
  12677. if( !phantomWeaponMgr )
  12678. {
  12679. phantomWeaponMgr = new CPhantomWeaponManager in this;
  12680. phantomWeaponMgr.Init( this.GetInventory() );
  12681. }
  12682. }
  12683.  
  12684. public function DestroyPhantomWeaponMgr()
  12685. {
  12686. if( phantomWeaponMgr )
  12687. {
  12688. delete phantomWeaponMgr;
  12689. }
  12690. }
  12691.  
  12692. public function GetPhantomWeaponMgr() : CPhantomWeaponManager
  12693. {
  12694. if( phantomWeaponMgr )
  12695. {
  12696. return phantomWeaponMgr;
  12697. }
  12698. else
  12699. {
  12700. return NULL;
  12701. }
  12702. }
  12703.  
  12704. public timer function DischargeWeaponAfter( td : float, id : int )
  12705. {
  12706. GetPhantomWeaponMgr().DischargeWeapon();
  12707. }
  12708.  
  12709.  
  12710.  
  12711.  
  12712. private var forcedFinisherVictim : CActor;
  12713.  
  12714. timer function PerformFinisher( time : float , id : int )
  12715. {
  12716. var combatTarget : CActor;
  12717. var i : int;
  12718.  
  12719. combatTarget = thePlayer.GetTarget();
  12720.  
  12721. if( combatTarget )
  12722. {
  12723. combatTarget.Kill( 'AutoFinisher', false, thePlayer );
  12724. thePlayer.SetFinisherVictim( combatTarget );
  12725. forcedFinisherVictim = combatTarget;
  12726. thePlayer.CleanCombatActionBuffer();
  12727. thePlayer.OnBlockAllCombatTickets( true );
  12728. moveTargets = thePlayer.GetMoveTargets();
  12729.  
  12730. for( i = 0; i < moveTargets.Size(); i += 1 )
  12731. {
  12732. if( combatTarget != moveTargets[i] )
  12733. moveTargets[i].SignalGameplayEvent( 'InterruptChargeAttack' );
  12734. }
  12735.  
  12736. if( theGame.GetInGameConfigWrapper().GetVarValue( 'Gameplay', 'AutomaticFinishersEnabled' ) == "true" )
  12737. combatTarget.AddAbility( 'ForceFinisher', false );
  12738.  
  12739. if( combatTarget.HasTag( 'ForceFinisher' ) )
  12740. combatTarget.AddAbility( 'ForceFinisher', false );
  12741.  
  12742. combatTarget.SignalGameplayEvent( 'ForceFinisher' );
  12743.  
  12744. thePlayer.FindMoveTarget();
  12745.  
  12746. thePlayer.AddTimer( 'SignalFinisher', 0.2, false );
  12747. }
  12748. }
  12749.  
  12750. timer function SignalFinisher( time : float , id : int )
  12751. {
  12752. forcedFinisherVictim.SignalGameplayEvent( 'Finisher' );
  12753. forcedFinisherVictim = NULL;
  12754. }
  12755. }
  12756.  
  12757. exec function ttt()
  12758. {
  12759. thePlayer.AddTimer( 'TestTimer', 5, false );
  12760. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement