Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // modShieldHood --- Start --------------------------------------------------
- public function ManageModShieldHoods( item : SItemUniqueId, isOnEquip : bool )
- {
- if ( inv.ItemHasTag( item, 'Hood' ) )
- {
- if (isOnEquip) {
- if( theGame.GetInGameConfigWrapper().GetVarValue( 'DLCShieldMenu', 'displayHair' ) )
- DisplayHair( true );
- }
- else {
- DisplayHair( false );
- }
- }
- }
- private function DisplayHair(display : bool)
- {
- var l_comp : CComponent;
- var hair : CEntityTemplate;
- l_comp = thePlayer.GetComponentByClassName( 'CAppearanceComponent' );
- hair = (CEntityTemplate)LoadResource("dlc\kontusz\data\items\hoods\hood_hair\hair_hood.w2ent", true);
- if ( display ){
- ((CAppearanceComponent)l_comp).IncludeAppearanceTemplate(hair);
- }
- else {
- ((CAppearanceComponent)l_comp).ExcludeAppearanceTemplate(hair);
- }
- }
- // modShieldHood --- End ------------------------------------------------------
- // modShieldSkills --- Start --------------------------------------------------
- private var hiddenSkills : array<int>;
- private var isHiddenSkillsListInit : bool;
- public function ManageModShieldSkills( item : SItemUniqueId, isOnEquip : bool )
- {
- var pam : W3PlayerAbilityManager;
- var skills : array<ESkill>;
- var i : int;
- pam = (W3PlayerAbilityManager)GetWitcherPlayer().abilityManager;
- skills = GetHiddenSkillsFromItemID( item );
- for (i = 0;i < skills.Size();i+=1)
- {
- if (isOnEquip)
- SetHiddenSkill( skills[i], pam.AddHiddenSkill( skills[i] ) );
- else
- pam.RemoveHiddenSkill( skills[i] );
- }
- }
- public function SetHiddenSkill( skill : ESkill, level : int )
- {
- if (!isHiddenSkillsListInit)
- {
- InitHiddenSkillsList();
- isHiddenSkillsListInit = true;
- }
- hiddenSkills[skill] = level;
- }
- private function InitHiddenSkillsList()
- {
- hiddenSkills.Resize( EnumGetMax( 'ESkill' ) + 1 );
- }
- public function GetHiddenSkill( skill : ESkill ) : int
- {
- return hiddenSkills[skill];
- }
- public function IsSkillGranted( skill : ESkill ) : bool
- {
- var itemNames : array<name>;
- var ret : bool;
- var i : int;
- itemNames = GetItemNamesFromHiddenSkill( skill );
- for (i = 0; i < itemNames.Size(); i+=1)
- {
- if ( GetWitcherPlayer().IsItemEquipped( inv.GetItemId( itemNames[i] ) ) )
- ret = true;
- }
- return ret;
- }
- private function GetHiddenSkillsFromItemID( item : SItemUniqueId ) : array<ESkill>
- {
- var ret : array<ESkill>;
- switch( inv.GetItemName(item) )
- {
- case 'Wanderer Armor' : {ret.PushBack(S_Alchemy_s03); ret.PushBack(S_Alchemy_s04); ret.PushBack(S_Alchemy_s17);break;}
- 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;}
- case 'Hunter Armor' : {ret.PushBack(S_Sword_s03); ret.PushBack(S_Sword_s10); ret.PushBack(S_Sword_s09); ret.PushBack(S_Sword_s11);break;}
- 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;}
- case 'Raven Armor' : {ret.PushBack(S_Sword_s01); ret.PushBack(S_Sword_s02);break;}
- case 'Shiadhal Armor' : {ret.PushBack(S_Magic_s08); ret.PushBack(S_Magic_s02); ret.PushBack(S_Magic_s07); ret.PushBack(S_Magic_s09);break;}
- 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;}
- case 'Journeyman Armor' : {ret.PushBack(S_Alchemy_s14); ret.PushBack(S_Alchemy_s13);break;}
- case 'Oathbreaker Armor': {ret.PushBack(S_Perk_06);break;}
- case 'Kinslayer Armor' : {ret.PushBack(S_Perk_07);break;}
- //case '' : {ret.PushBack(S_Magic_s05);break;}
- default : {ret.PushBack(S_SUndefined);break;}
- }
- return ret;
- }
- private function GetItemNamesFromHiddenSkill( skill : ESkill ) : array<name>
- {
- var ret : array<name>;
- switch( skill )
- {
- case S_Magic_s01 : {ret.PushBack('Warden Armor');break;}
- case S_Magic_s02 : {ret.PushBack('Warden Armor'); ret.PushBack('Shiadhal Armor');break;}
- case S_Magic_s03 : {ret.PushBack('Warden Armor');break;}
- case S_Magic_s04 : {ret.PushBack('Warden Armor');break;}
- case S_Magic_s05 : {ret.PushBack('Warden Armor');break;}
- case S_Magic_s08 : {ret.PushBack('Shiadhal Armor');break;}
- case S_Magic_s07 : {ret.PushBack('Shiadhal Armor');break;}
- case S_Magic_s09 : {ret.PushBack('Shiadhal Armor'); ret.PushBack('Astrogarus Armor');break;}
- case S_Magic_s06 : {ret.PushBack('Astrogarus Armor');break;}
- case S_Magic_s11 : {ret.PushBack('Astrogarus Armor');break;}
- case S_Magic_s14 : {ret.PushBack('Astrogarus Armor');break;}
- case S_Magic_s19 : {ret.PushBack('Astrogarus Armor');break;}
- case S_Sword_s03 : {ret.PushBack('Hunter Armor');break;}
- case S_Sword_s09 : {ret.PushBack('Hunter Armor');break;}
- case S_Sword_s10 : {ret.PushBack('Hunter Armor');break;}
- case S_Sword_s11 : {ret.PushBack('Hunter Armor');break;}
- case S_Sword_s01 : {ret.PushBack('Raven Armor');break;}
- case S_Sword_s02 : {ret.PushBack('Raven Armor');break;}
- case S_Alchemy_s03 : {ret.PushBack('Wanderer Armor');break;}
- case S_Alchemy_s04 : {ret.PushBack('Wanderer Armor');break;}
- case S_Alchemy_s17 : {ret.PushBack('Wanderer Armor'); ret.PushBack('Journeyman Armor');break;}
- case S_Alchemy_s13 : {ret.PushBack('Journeyman Armor');break;}
- case S_Sword_s07 : {ret.PushBack('Tracker Armor');break;}
- case S_Sword_s12 : {ret.PushBack('Tracker Armor');break;}
- case S_Sword_s13 : {ret.PushBack('Tracker Armor');break;}
- case S_Sword_s15 : {ret.PushBack('Tracker Armor');break;}
- case S_Perk_02 : {ret.PushBack('Tracker Armor');break;}
- case S_Perk_06 : {ret.PushBack('Oathbreaker Armor');break;}
- case S_Perk_07 : {ret.PushBack('Oathbreaker Armor');break;}
- default : {ret.PushBack('');break;}
- }
- return ret;
- }
- // modShieldSkills --- End --------------------------------------------------
- // modShieldCombat --- Start --------------------------------------------------
- private var hitShieldCount : int;
- private var previousAttacker : CActor;
- public function ProcessShieldParry(optional parryInfo : SParryInfo, optional isArrow : bool, optional shield : W3DLCShield)
- {
- var anim : CName;
- var rand : int;
- var parryDir : EPlayerParryDirection;
- var parryHeading : float;
- var staminaDrain : int;
- staminaDrain = StringToInt(theGame.GetInGameConfigWrapper().GetVarValue( 'DLCShieldMenu', 'staminaDrain' ));
- if(isArrow)
- {
- rand = RandRange(0,2);
- switch(rand){
- case 0:
- anim = 'man_npc_shield_block_rp_01';
- break;
- case 1:
- anim = 'man_npc_shield_block_rp_02';
- break;
- }
- thePlayer.ActionPlaySlotAnimationAsync( 'PLAYER_SLOT', anim, 0.2, 0.2 );
- parryHeading = GetParryHeading( parryInfo, parryDir ) ;
- DrainStamina(ESAT_FixedValue, staminaDrain);
- OnCombatActionStart();
- ClearCustomOrientationInfoStack();
- SetSlideTarget( parryInfo.attacker );
- SetCustomRotation( 'Parry', parryHeading, 1080.f, 0.1f, false );
- }
- else
- {
- rand = RandRange(0,2);
- switch(rand){
- case 0:
- anim = 'man_npc_shield_block_rp_01';
- break;
- case 1:
- anim = 'man_npc_shield_block_rp_02';
- break;
- }
- thePlayer.ActionPlaySlotAnimationAsync( 'PLAYER_SLOT', anim, 0.2, 0.2 );
- parryHeading = GetParryHeading( parryInfo, parryDir ) ;
- SetBehaviorVariable( 'parryDirection', (float)( (int)( parryDir ) ) );
- SetBehaviorVariable( 'parryDirectionOverlay', (float)( (int)( parryDir ) ) );
- SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
- OnCombatActionStart();
- ClearCustomOrientationInfoStack();
- SetSlideTarget( parryInfo.attacker );
- SetCustomRotation( 'Parry', parryHeading, 1080.f, 0.1f, false );
- IncDefendCounter();
- DrainStamina(ESAT_FixedValue, staminaDrain);
- if(parryInfo.attacker == previousAttacker){
- if(hitShieldCount > RandRange( (int)shield.GetStaggerMin() ,(int)shield.GetStaggerMax() ) ){
- parryInfo.attacker.AddEffectDefault( EET_Stagger, thePlayer, "ParryStagger" );
- hitShieldCount = 0;
- }
- hitShieldCount += 1;
- }
- else{
- hitShieldCount = 0;
- }
- previousAttacker = parryInfo.attacker;
- }
- }
- public function DestroyArrows(arrows : array<W3ArrowProjectile>)
- {
- var i : int;
- for(i = 0; i < arrows.Size(); i += 1)
- {
- arrows[i].AddTimer( 'TimeDestroy', 0.f, false );
- }
- }
- // modShieldCombat --- End --------------------------------------------------
- function PerformParryCheck( parryInfo : SParryInfo) : bool
- function PerformParryCheck( parryInfo : SParryInfo) : bool
- {
- var mult : float;
- var parryType : EParryType;
- var parryDir : EPlayerParryDirection;
- var parryHeading : float;
- var fistFightParry : bool;
- var action : W3DamageAction;
- var xmlStaminaDamage : float;
- var xmlStaminaDamageName : name = 'stamina_damage' ;
- var counter : int;
- var onHitCounter : SAbilityAttributeValue;
- {
- var mult : float;
- var parryType : EParryType;
- var parryDir : EPlayerParryDirection;
- var parryHeading : float;
- var fistFightParry : bool;
- var action : W3DamageAction;
- var xmlStaminaDamage : float;
- var xmlStaminaDamageName : name = 'stamina_damage' ;
- var counter : int;
- var onHitCounter : SAbilityAttributeValue;
- // modShieldCombat --- Start --------------------------------------------------
- var itemId : SItemUniqueId;
- var shield : W3DLCShield;
- var npc : CNewNPC;
- var testedAngle, staminaNeeded : float;
- var infront, cantParryFromBehind : bool;
- cantParryFromBehind = theGame.GetInGameConfigWrapper().GetVarValue( 'DLCShieldMenu', 'cantParryFromBehind' );
- itemId = thePlayer.GetInventory().GetItemFromSlot('l_weapon');
- shield = (W3DLCShield)GetInventory().GetItemEntityUnsafe(itemId);
- npc = (CNewNPC)parryInfo.attacker;
- testedAngle = AngleDistance( VecHeading( npc.GetWorldPosition() - thePlayer.GetWorldPosition() ) , thePlayer.GetHeading() );
- if ( testedAngle < 100 && testedAngle > -70 )
- {
- infront = true;
- }
- else
- {
- if(!cantParryFromBehind)
- {
- infront = false;
- }
- else
- {
- if(shield)
- {
- return false;
- }
- }
- }
- if( shield && IsGuarded() && infront)
- {
- staminaNeeded = StringToFloat(theGame.GetInGameConfigWrapper().GetVarValue( 'DLCShieldMenu', 'staminaNeeded' ));
- if(GetStaminaPercents() < staminaNeeded/100)
- {
- return false;
- }
- ProcessShieldParry(parryInfo, , shield);
- shield.PlayEffect('light_block');
- return true;
- }
- // modShieldCombat --- End --------------------------------------------------
- if(CanParryAttack() && FistFightCheck( parryInfo.target, parryInfo.attacker, fistFightParry ) )
- {
- parryHeading = GetParryHeading( parryInfo, parryDir ) ;
- SetBehaviorVariable( 'parryDirection', (float)( (int)( parryDir ) ) );
- SetBehaviorVariable( 'parryDirectionOverlay', (float)( (int)( parryDir ) ) );
- SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
- if ( IsInCombatActionFriendly() )
- RaiseEvent('CombatActionFriendlyEnd');
- if ( HasStaminaToParry(parryInfo.attackActionName) )
- {
- this.SetBehaviorVariable( 'combatActionType', (int)CAT_Parry );
- if ( parryInfo.targetToAttackerDist > 3.f && !bLAxisReleased && !thePlayer.IsCiri() )
- {
- if ( !RaiseForceEvent( 'PerformParryOverlay' ) )
- return false;
- else
- {
- ClearCustomOrientationInfoStack();
- IncDefendCounter();
- }
- }
- else
- {
- counter = GetDefendCounter();
- onHitCounter = parryInfo.attacker.GetAttributeValue( 'break_through_parry_on_hit_counter' );
- if ( onHitCounter.valueBase > 0 && counter == onHitCounter.valueBase )
- {
- AddEffectDefault( EET_Stagger, parryInfo.attacker, "Break through parry" );
- }
- else if ( RaiseForceEvent( 'PerformParry' ) )
- {
- OnCombatActionStart();
- ClearCustomOrientationInfoStack();
- SetSlideTarget( parryInfo.attacker );
- SetCustomRotation( 'Parry', parryHeading, 1080.f, 0.1f, false );
- IncDefendCounter();
- }
- else
- return false;
- }
- }
- else
- {
- AddEffectDefault(EET_Stagger, parryInfo.attacker, "Parry");
- return true;
- }
- if ( parryInfo.attacker.IsWeaponHeld( 'fist' ) && !parryInfo.target.IsWeaponHeld( 'fist' ) )
- {
- parryInfo.attacker.ReactToReflectedAttack(parryInfo.target);
- }
- else
- {
- if ( this.IsInFistFightMiniGame() && fistFightParry )
- {
- if ( IsNameValid(xmlStaminaDamageName) )
- {
- xmlStaminaDamage = CalculateAttributeValue(parryInfo.attacker.GetAttributeValue( xmlStaminaDamageName ));
- DrainStamina(ESAT_FixedValue, xmlStaminaDamage);
- }
- }
- else
- {
- DrainStamina(ESAT_Parry, 0, 0, '', 0, mult);
- }
- if(IsLightAttack(parryInfo.attackActionName))
- parryInfo.target.PlayEffectOnHeldWeapon('light_block');
- else
- parryInfo.target.PlayEffectOnHeldWeapon('heavy_block');
- }
- return true;
- }
- return false;
- }
- protected function GetParryHeading( parryInfo : SParryInfo, out parryDir : EPlayerParryDirection ) : float
- {
- var targetToAttackerHeading : float;
- var currToTargetAttackerAngleDiff : float;
- targetToAttackerHeading = VecHeading( parryInfo.attacker.GetWorldPosition() - parryInfo.target.GetWorldPosition() );
- currToTargetAttackerAngleDiff = AngleDistance( VecHeading( parryInfo.target.GetHeadingVector() ), targetToAttackerHeading );
- if ( !parryInfo.target.IsWeaponHeld( 'fist' ) )
- {
- if( currToTargetAttackerAngleDiff > -45 && currToTargetAttackerAngleDiff < 45 )
- {
- parryDir = PPD_Forward;
- return targetToAttackerHeading;
- }
- else if( currToTargetAttackerAngleDiff >= 45 && currToTargetAttackerAngleDiff < 135 )
- {
- parryDir = PPD_Right;
- return targetToAttackerHeading + 90;
- }
- else if( currToTargetAttackerAngleDiff <= -45 && currToTargetAttackerAngleDiff > -135 )
- {
- parryDir = PPD_Left;
- return targetToAttackerHeading - 90;
- }
- else
- {
- parryDir = PPD_Back;
- return targetToAttackerHeading + 180;
- }
- }
- else
- {
- if( currToTargetAttackerAngleDiff > -45 && currToTargetAttackerAngleDiff < 45 )
- {
- parryDir = PPD_Forward;
- return targetToAttackerHeading;
- }
- else if( currToTargetAttackerAngleDiff >= 45 && currToTargetAttackerAngleDiff < 180 )
- {
- parryDir = PPD_Right;
- return targetToAttackerHeading + 90;
- }
- else if( currToTargetAttackerAngleDiff <= -45 && currToTargetAttackerAngleDiff >= -180 )
- {
- parryDir = PPD_Left;
- return targetToAttackerHeading - 90;
- }
- else
- {
- parryDir = PPD_Back;
- return targetToAttackerHeading + 180;
- }
- }
- }
- function ProcessLockTarget( optional newLockTarget : CActor, optional checkLeftStickHeading : bool ) : bool
- {
- var attackerNearestPoint : Vector;
- var playerNearestPoint : Vector;
- var incomingAttacker : CActor;
- var tempLockTarget : CActor;
- var target : CActor;
- var useIncomingAttacker : bool;
- if( newLockTarget.HasTag( 'NoHardLock' ) )
- return false;
- if ( newLockTarget )
- tempLockTarget = newLockTarget;
- else
- {
- incomingAttacker = GetClosestIncomingAttacker();
- if ( incomingAttacker && incomingAttacker.IsAlive() && IsUsingVehicle() )
- {
- tempLockTarget = incomingAttacker;
- useIncomingAttacker = false;
- }
- if ( !useIncomingAttacker )
- {
- target = GetTarget();
- if( target.HasTag('ForceHardLock'))
- {
- return true;
- }
- else if ( target && target.IsAlive() && target.GetGameplayVisibility() && IsEnemyVisible( target ) && IsThreat( target ) && CanBeTargetedIfSwimming( target ) )
- tempLockTarget = FindTarget();
- else
- {
- tempLockTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, 0.f );
- }
- }
- }
- if( tempLockTarget.HasTag( 'NoHardLock' ) )
- return false;
- if ( tempLockTarget )
- {
- if ( IsCombatMusicEnabled() || hostileEnemies.Size() > 0 )
- {
- if ( !IsThreat( tempLockTarget ) )
- tempLockTarget = NULL;
- }
- }
- SetTarget( tempLockTarget, true );
- SetMoveTargetChangeAllowed( true );
- SetMoveTarget( tempLockTarget );
- SetMoveTargetChangeAllowed( false );
- SetSlideTarget( tempLockTarget );
- if ( tempLockTarget )
- {
- if ( this.IsActorLockedToTarget() )
- EnableHardLockIcon( true );
- return true;
- }
- else
- return false;
- }
- event OnTaskSyncAnim( npc : CNewNPC, animNameLeft : name ) {}
- public function IsDoingSpecialAttack(heavy : bool) : bool
- {
- var pat : EPlayerAttackType;
- if(IsInCombatAction() && ( (int)GetBehaviorVariable('combatActionType')) == CAT_SpecialAttack)
- {
- pat = (int)GetBehaviorVariable('playerAttackType');
- if(heavy && pat == PAT_Heavy)
- {
- return true;
- }
- else if(!heavy && pat == PAT_Light)
- {
- return true;
- }
- }
- return false;
- }
- public function SetIsCurrentlyDodging(enable : bool, optional isRolling : bool)
- {
- super.SetIsCurrentlyDodging(enable, isRolling);
- if ( isRolling )
- {
- SetCanPlayHitAnim( false );
- this.AddBuffImmunity( EET_KnockdownTypeApplicator, 'Roll', false );
- this.AddBuffImmunity( EET_Knockdown, 'Roll', false );
- this.AddBuffImmunity( EET_HeavyKnockdown, 'Roll', false );
- this.AddBuffImmunity( EET_Stagger, 'Roll', false );
- }
- else
- {
- SetCanPlayHitAnim( true );
- this.RemoveBuffImmunity( EET_KnockdownTypeApplicator, 'Roll' );
- this.RemoveBuffImmunity( EET_Knockdown, 'Roll' );
- this.RemoveBuffImmunity( EET_HeavyKnockdown, 'Roll' );
- this.RemoveBuffImmunity( EET_Stagger, 'Roll' );
- }
- }
- public function EnableHardLock( flag : bool )
- {
- super.EnableHardLock(flag);
- if(flag && ShouldProcessTutorial('TutorialTargettingWaiting'))
- {
- FactsAdd("tut_hardlocked");
- }
- }
- protected function TestParryAndCounter(data : CPreAttackEventData, weaponId : SItemUniqueId, out parried : bool, out countered : bool) : array<CActor>
- {
- var ret : array<CActor>;
- if(FactsQuerySum('player_is_the_boss') > 0)
- {
- SetDebugAttackRange(data.rangeName);
- RemoveTimer('PostAttackDebugRangeClear');
- return ret;
- }
- ret = super.TestParryAndCounter(data, weaponId, parried, countered);
- if(parried)
- theGame.GetGamerProfile().ResetStat(ES_CounterattackChain);
- return ret;
- }
- public function SetSpecialAttackTimeRatio(f : float)
- {
- LogSpecialHeavy(f);
- specialAttackTimeRatio = f;
- }
- public function GetSpecialAttackTimeRatio() : float
- {
- return specialAttackTimeRatio;
- }
- public function OnSpecialAttackHeavyActionProcess()
- {
- SetSpecialAttackTimeRatio(0.f);
- }
- protected function DoAttack(animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float)
- {
- var shakeStr : float;
- var weapon : EPlayerWeapon;
- var targetActor : CActor;
- if ( animData.attackName == 'attack_heavy_special' )
- {
- if( specialAttackTimeRatio != 1 )
- shakeStr = (specialAttackTimeRatio / 3.333) + 0.2;
- else
- shakeStr = 0.5;
- GCameraShake( shakeStr, false, GetWorldPosition(), 10);
- }
- else if ( IsHeavyAttack(attackActionName) )
- {
- if(parriedBy.Size() > 0)
- shakeStr = 0.2;
- else
- shakeStr = 0.1;
- GCameraShake(shakeStr, false, GetWorldPosition(), 10);
- }
- targetActor = (CActor)slideTarget;
- if ( targetActor && hitTargets.Contains(targetActor) )
- {
- weapon = this.GetMostConvenientMeleeWeapon(targetActor,true);
- if ( this.GetCurrentMeleeWeaponType() != PW_Fists && weapon != this.GetCurrentMeleeWeaponType() )
- {
- if ( weapon == PW_Steel )
- {
- thePlayer.OnEquipMeleeWeapon(PW_Steel,true);
- }
- else if ( weapon == PW_Silver )
- {
- thePlayer.OnEquipMeleeWeapon(PW_Silver,true);
- }
- }
- }
- super.DoAttack(animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime);
- }
- private var confirmCombatStanceTimeStamp : float;
- private var isConfirmingCombatStance : bool;
- final function SetPlayerCombatStance(stance : EPlayerCombatStance, optional force : bool )
- {
- var stanceInt : int;
- if ( !CanChangeCombatStance( stance, force ) )
- return;
- combatStance = stance;
- stanceInt = (int)stance;
- SetBehaviorVariable( 'playerCombatStance' , (float)stanceInt);
- SetBehaviorVariable( 'playerCombatStanceForOverlay' , (float)stanceInt);
- if ( force )
- SetBehaviorVariable( 'forceCombatStance' , 1.f);
- else
- SetBehaviorVariable( 'forceCombatStance' , 0.f);
- if ( stance == PCS_AlertNear )
- this.SetBehaviorVariable('isInCombatForOverlay',1.f);
- else
- this.SetBehaviorVariable('isInCombatForOverlay',0.f);
- }
- private function CanChangeCombatStance( stance : EPlayerCombatStance, optional force : bool ) : bool
- {
- var currTime : float;
- if ( force )
- return true;
- if ( IsInFistFightMiniGame() )
- return true;
- if ( isInHolsterAnim )
- return false;
- if ( ( combatStance == PCS_Normal || combatStance == PCS_AlertFar ) && stance == PCS_AlertNear )
- {
- currTime = theGame.GetEngineTimeAsSeconds();
- if ( !isConfirmingCombatStance )
- {
- isConfirmingCombatStance = true;
- confirmCombatStanceTimeStamp = currTime;
- return false;
- }
- else if ( currTime < confirmCombatStanceTimeStamp + 1.f )
- {
- if ( stance == PCS_AlertNear )
- return false;
- }
- else
- isConfirmingCombatStance = false;
- }
- else
- isConfirmingCombatStance = false;
- return true;
- }
- private var isInHolsterAnim : bool;
- event OnHolsterWeaponStart()
- {
- isInHolsterAnim = true;
- }
- event OnHolsterWeaponEnd()
- {
- isInHolsterAnim = false;
- }
- final function GetPlayerCombatStance() : EPlayerCombatStance
- {
- return combatStance;
- }
- timer function DelayedDisableFindTarget( time : float , id : int)
- {
- if ( GetTarget().IsAlive() )
- {
- EnableFindTarget( false );
- }
- else
- {
- EnableFindTarget( true );
- }
- }
- private var dodgeTimerRunning : bool;
- function StartDodgeTimer()
- {
- dodgeTimerRunning = true;
- thePlayer.AddTimer('DodgeTimer',0.2,false);
- }
- function StopDodgeTimer()
- {
- this.RemoveTimer('DodgeTimer');
- dodgeTimerRunning = false;
- }
- function IsDodgeTimerRunning() : bool
- {
- return dodgeTimerRunning;
- }
- timer function DodgeTimer( dt : float, id : int )
- {
- dodgeTimerRunning = false;
- }
- public function EvadePressed( bufferAction : EBufferActionType )
- {
- }
- public function PerformingCombatAction() : EBufferActionType
- {
- return BufferCombatAction;
- }
- public function PushCombatActionOnBuffer( action : EBufferActionType, stage : EButtonStage, optional allSteps : bool )
- {
- BufferButtonStage = stage;
- BufferCombatAction = action;
- BufferAllSteps = allSteps;
- }
- protected function ProcessCombatActionHeading( action : EBufferActionType ) : float
- {
- var processedActionHeading : float;
- HandleMovement( 0.f );
- if ( ShouldUsePCModeTargeting() )
- return theGame.GetGameCamera().GetHeading();
- if ( lAxisReleasedAfterCounter )
- ResetCachedRawPlayerHeading();
- processedActionHeading = cachedRawPlayerHeading;
- return processedActionHeading;
- }
- function ResetRawPlayerHeading()
- {
- if ( GetDisplayTarget() )
- rawPlayerHeading = VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() );
- else
- rawPlayerHeading = GetHeading();
- }
- function ResetCachedRawPlayerHeading()
- {
- cachedRawPlayerHeading = rawPlayerHeading;
- if ( GetDisplayTarget() && IsDisplayTargetTargetable() && AbsF( AngleDistance( VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() ), this.GetHeading() ) ) < 90.f )
- cachedRawPlayerHeading = VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() );
- else
- cachedRawPlayerHeading = this.GetHeading();
- if ( canResetCachedCombatActionHeading )
- cachedCombatActionHeading = cachedRawPlayerHeading;
- }
- public function GetCombatActionTarget( action : EBufferActionType ) : CGameplayEntity
- {
- var selectedTargetableEntity : CGameplayEntity;
- if ( !this.IsUsingVehicle() )
- selectedTargetableEntity = FindNonActorTarget( true, action );
- if ( selectedTargetableEntity )
- {
- return selectedTargetableEntity;
- }
- else
- {
- if ( !this.IsUsingVehicle() )
- FindTarget( true, action, true );
- else
- ((CR4PlayerStateUseGenericVehicle)this.GetState( 'UseGenericVehicle' )).FindTarget();
- return GetTarget();
- }
- }
- private function FindNonActorTarget( actionCheck : bool, optional action : EBufferActionType ) : CGameplayEntity
- {
- var targetableEntities : array<CGameplayEntity>;
- var selectedTargetableEntity : CGameplayEntity;
- var selectionPriority : array< float >;
- var selectionWeights : STargetSelectionWeights;
- var findEntityDist : float;
- var i, size : int;
- var playerHeading : float;
- var playerInventory : CInventoryComponent;
- var castSignType : ESignType;
- var targetingInfo : STargetingInfo;
- var playerPosition : Vector;
- var cameraPosition : Vector;
- var playerHeadingVector : Vector;
- var rawPlayerHeadingVector : Vector;
- playerPosition = this.GetWorldPosition();
- cameraPosition = theCamera.GetCameraPosition();
- rawPlayerHeadingVector = VecFromHeading( rawPlayerHeading );
- if ( bCanFindTarget && !IsHardLockEnabled() )
- {
- if ( actionCheck && IsInCombat() && action == EBAT_CastSign )
- {
- findEntityDist = 6.f;
- selectionWeights.angleWeight = 0.375f;
- selectionWeights.distanceWeight = 0.275f;
- selectionWeights.distanceRingWeight = 0.35f;
- }
- else if ( !IsInCombat() && lastAxisInputIsMovement )
- {
- findEntityDist = softLockDist;
- selectionWeights.angleWeight = 0.375f;
- selectionWeights.distanceWeight = 0.275f;
- selectionWeights.distanceRingWeight = 0.35f;
- }
- else
- {
- findEntityDist = softLockDist;
- selectionWeights.angleWeight = 0.75f;
- selectionWeights.distanceWeight = 0.125f;
- selectionWeights.distanceRingWeight = 0.125f;
- }
- if ( !IsInCombat() || !bLAxisReleased )
- {
- FindGameplayEntitiesInRange( targetableEntities, this, findEntityDist, 10, theGame.params.TAG_SOFT_LOCK );
- }
- if ( targetableEntities.Size() > 0 )
- {
- playerInventory = this.GetInventory();
- castSignType = this.GetEquippedSign();
- if ( !bLAxisReleased )
- {
- targetingInfo.source = this;
- targetingInfo.canBeTargetedCheck = false;
- targetingInfo.coneCheck = true;
- targetingInfo.coneHalfAngleCos = 0.5f;
- targetingInfo.coneDist = softLockDist;
- targetingInfo.coneHeadingVector = rawPlayerHeadingVector;
- targetingInfo.distCheck = true;
- targetingInfo.invisibleCheck = false;
- targetingInfo.navMeshCheck = false;
- targetingInfo.frameScaleX = 1.0f;
- targetingInfo.frameScaleY = 1.0f;
- targetingInfo.knockDownCheck = false;
- targetingInfo.knockDownCheckDist = 0.0f;
- targetingInfo.rsHeadingCheck = false;
- targetingInfo.rsHeadingLimitCos = 1.0f;
- }
- for( i = targetableEntities.Size()-1; i>=0; i-=1 )
- {
- if ( bLAxisReleased )
- {
- if ( !lastAxisInputIsMovement )
- {
- if ( !WasVisibleInScaledFrame( targetableEntities[i], 0.9f, 0.9f ) )
- {
- targetableEntities.Erase(i);
- continue;
- }
- }
- else if ( !WasVisibleInScaledFrame( targetableEntities[i], 1.f, 1.f ) )
- {
- targetableEntities.Erase(i);
- continue;
- }
- }
- else
- {
- targetingInfo.targetEntity = targetableEntities[i];
- if ( actionCheck && moveTarget )
- {
- targetingInfo.inFrameCheck = false;
- if ( !IsEntityTargetable( targetingInfo ) )
- {
- targetableEntities.Erase(i);
- continue;
- }
- }
- else
- {
- targetingInfo.inFrameCheck = true;
- if ( !IsEntityTargetable( targetingInfo ) )
- {
- targetableEntities.Erase(i);
- continue;
- }
- }
- }
- if ( actionCheck )
- {
- if ( action == EBAT_ItemUse )
- {
- if ( ( playerInventory.IsItemBomb( this.GetSelectedItemId() ) && !targetableEntities[i].HasTag( 'softLock_Bomb' ) )
- || ( playerInventory.IsItemCrossbow( this.GetSelectedItemId() ) && !targetableEntities[i].HasTag( 'softLock_Bolt' ) ) )
- {
- targetableEntities.Erase(i);
- continue;
- }
- }
- else if ( action == EBAT_CastSign )
- {
- if ( ( castSignType == ST_Aard && !targetableEntities[i].HasTag( 'softLock_Aard' ) )
- || ( castSignType == ST_Igni && !targetableEntities[i].HasTag( 'softLock_Igni' ) )
- || ( castSignType == ST_Axii && !targetableEntities[i].HasTag( 'softLock_Axii' ) )
- || castSignType == ST_Yrden
- || castSignType == ST_Quen )
- {
- targetableEntities.Erase(i);
- continue;
- }
- }
- else if ( action == EBAT_LightAttack || action == EBAT_HeavyAttack || action == EBAT_SpecialAttack_Heavy )
- {
- if ( ( IsWeaponHeld( 'fist' ) && !targetableEntities[i].HasTag( 'softLock_Fist' ) ) || ( !IsWeaponHeld( 'fist' ) && !targetableEntities[i].HasTag( 'softLock_Weapon' ) ) )
- {
- targetableEntities.Erase(i);
- continue;
- }
- }
- else
- {
- targetableEntities.Erase(i);
- continue;
- }
- }
- }
- }
- if ( targetableEntities.Size() > 0)
- {
- playerHeading = this.GetHeading();
- playerHeadingVector = this.GetHeadingVector();
- if ( IsInCombat() )
- {
- for( i = 0; i < targetableEntities.Size(); i += 1 )
- {
- if ( bLAxisReleased )
- selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, cameraPosition, rawPlayerHeadingVector ) );
- else
- selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, rawPlayerHeadingVector ) );
- }
- if ( selectionPriority.Size() > 0 )
- selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
- }
- else
- {
- if ( bLAxisReleased )
- {
- if ( !lastAxisInputIsMovement )
- {
- for( i = 0; i < targetableEntities.Size(); i += 1 )
- selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, cameraPosition, rawPlayerHeadingVector ) );
- if ( selectionPriority.Size() > 0 )
- selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
- }
- else
- {
- if ( IsInCombatAction() )
- selectedTargetableEntity = nonActorTarget;
- else
- {
- for( i = 0; i < targetableEntities.Size(); i += 1 )
- selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, playerHeadingVector ) );
- if ( selectionPriority.Size() > 0 )
- {
- selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
- targetingInfo.source = this;
- targetingInfo.targetEntity = selectedTargetableEntity;
- targetingInfo.canBeTargetedCheck = false;
- targetingInfo.coneCheck = true;
- targetingInfo.coneHalfAngleCos = 0.0f;
- targetingInfo.coneDist = softLockDist;
- targetingInfo.coneHeadingVector = this.GetHeadingVector();
- targetingInfo.distCheck = true;
- targetingInfo.invisibleCheck = false;
- targetingInfo.navMeshCheck = false;
- targetingInfo.inFrameCheck = false;
- targetingInfo.frameScaleX = 1.0f;
- targetingInfo.frameScaleY = 1.0f;
- targetingInfo.knockDownCheck = false;
- targetingInfo.knockDownCheckDist = 0.0f;
- targetingInfo.rsHeadingCheck = false;
- targetingInfo.rsHeadingLimitCos = 1.0f;
- if ( !IsEntityTargetable( targetingInfo ) )
- selectedTargetableEntity = NULL;
- }
- }
- }
- }
- else
- {
- for( i = 0; i < targetableEntities.Size(); i += 1 )
- selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, rawPlayerHeadingVector ) );
- if ( selectionPriority.Size() > 0 )
- selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
- }
- }
- }
- else
- selectedTargetableEntity = NULL;
- }
- SetNonActorTarget( selectedTargetableEntity );
- return selectedTargetableEntity;
- }
- public function SetupCombatAction( action : EBufferActionType, stage : EButtonStage )
- {
- var weaponType : EPlayerWeapon;
- var canAttackTarget : CGameplayEntity;
- var target : CActor;
- if ( !IsCombatMusicEnabled() )
- {
- SetCombatActionHeading( ProcessCombatActionHeading( action ) );
- FindTarget();
- UpdateDisplayTarget( true );
- }
- if ( displayTarget && IsDisplayTargetTargetable() )
- canAttackTarget = displayTarget;
- else if ( GetTarget() )
- canAttackTarget = GetTarget();
- else if( !target && IsCombatMusicEnabled() )
- canAttackTarget = moveTarget;
- target = (CActor)canAttackTarget;
- if ( !AllowAttack( target, action ) )
- return;
- if( ( action != EBAT_ItemUse ) && ( action != EBAT_CastSign ) )
- {
- weaponType = weaponHolster.GetCurrentMeleeWeapon();
- PrepareToAttack( target, action );
- if ( weaponType != weaponHolster.GetCurrentMeleeWeapon() )
- {
- if ( !( weaponType == PW_None && weaponHolster.GetCurrentMeleeWeapon() == PW_Fists ) )
- return;
- }
- }
- if(action == EBAT_SpecialAttack_Heavy && !((W3ReplacerCiri)this) )
- thePlayer.SetAttackActionName(SkillEnumToName(S_Sword_s02));
- CriticalEffectAnimationInterrupted("SetupCombatAction " + action);
- PushCombatActionOnBuffer( action, stage );
- if( GetBIsCombatActionAllowed() )
- {
- ProcessCombatActionBuffer();
- }
- }
- public function AllowAttack( target : CActor, action : EBufferActionType ) : bool
- {
- var newTarget : CActor;
- var canAttackWhenNotInCombat : bool;
- var messageDisplayed : bool;
- var itemId : SItemUniqueId;
- var isShootingCrossbow : bool;
- var isInCorrectState : bool;
- if ( target )
- {
- if ( target.IsTargetableByPlayer())
- {
- if ( !target.IsAttackableByPlayer() )
- {
- DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_cant_attack_this_target"));
- return false;
- }
- }
- }
- if ( this.GetCurrentStateName() == 'Exploration' )
- isInCorrectState = true;
- if ( action == EBAT_ItemUse )
- {
- itemId = thePlayer.GetSelectedItemId();
- if ( inv.IsIdValid(itemId) && inv.IsItemCrossbow(itemId) )
- isShootingCrossbow = true;
- if ( !isInCorrectState )
- {
- if ( this.GetCurrentStateName() == 'AimThrow' && !isShootingCrossbow )
- {
- isInCorrectState = true;
- }
- }
- }
- if ( isInCorrectState )
- canAttackWhenNotInCombat = thePlayer.CanAttackWhenNotInCombat( action, false, newTarget, target );
- if( !target )
- {
- if ( isInCorrectState )
- {
- SetCombatActionHeading( ProcessCombatActionHeading( action ) );
- target = newTarget;
- }
- }
- if ( isInCorrectState )
- {
- if ( !canAttackWhenNotInCombat )
- {
- if ( DisplayCannotAttackMessage( target ) )
- messageDisplayed = true;
- else if ( ( action == EBAT_LightAttack || action == EBAT_HeavyAttack )
- && !RaiseAttackFriendlyEvent( target ) )
- messageDisplayed = true;
- else
- {
- if ( !CanRaiseCombatActionFriendlyEvent( isShootingCrossbow ) )
- messageDisplayed = true;
- }
- }
- if ( messageDisplayed )
- {
- theInput.ForceDeactivateAction('ThrowItem');
- theInput.ForceDeactivateAction('ThrowItemHold');
- this.SignalGameplayEvent( 'FriendlyAttackAction' );
- return false;
- }
- }
- return true;
- }
- public function ProcessCombatActionBuffer() : bool
- {
- var actionResult : bool;
- var action : EBufferActionType = this.BufferCombatAction;
- var stage : EButtonStage = this.BufferButtonStage;
- var s : SNotWorkingOutFunctionParametersHackStruct1;
- var allSteps : bool = this.BufferAllSteps;
- if ( IsInCombatActionFriendly() )
- {
- RaiseEvent('CombatActionFriendlyEnd');
- }
- if ( ( action != EBAT_SpecialAttack_Heavy && action != EBAT_ItemUse )
- || ( action == EBAT_SpecialAttack_Heavy && stage == BS_Pressed )
- || ( action == EBAT_ItemUse && stage != BS_Released ) )
- {
- GetMovingAgentComponent().GetMovementAdjustor().CancelAll();
- SetUnpushableTarget( NULL );
- }
- if ( !( action == EBAT_Dodge || action == EBAT_Roll ) )
- {
- SetIsCurrentlyDodging(false);
- }
- SetCombatActionHeading( ProcessCombatActionHeading( action ) );
- if ( action == EBAT_ItemUse && GetInventory().IsItemCrossbow( selectedItemId ) )
- {
- if ( rangedWeapon
- && ( ( rangedWeapon.GetCurrentStateName() != 'State_WeaponShoot' && rangedWeapon.GetCurrentStateName() != 'State_WeaponAim' ) || GetIsShootingFriendly() ) )
- {
- SetSlideTarget( GetCombatActionTarget( action ) );
- }
- }
- else if ( !( ( action == EBAT_SpecialAttack_Heavy && stage == BS_Released ) || GetCurrentStateName() == 'AimThrow' ) )
- {
- SetSlideTarget( GetCombatActionTarget( action ) );
- }
- if( !slideTarget )
- LogChannel( 'Targeting', "NO SLIDE TARGET" );
- actionResult = true;
- switch ( action )
- {
- case EBAT_EMPTY :
- {
- this.BufferAllSteps = false;
- return true;
- } break;
- case EBAT_LightAttack :
- {
- if ( IsCiri() )
- return false;
- switch ( stage )
- {
- case BS_Pressed :
- {
- DrainStamina(ESAT_LightAttack);
- thePlayer.BreakPheromoneEffect();
- actionResult = OnPerformAttack(theGame.params.ATTACK_NAME_LIGHT);
- } break;
- default :
- {
- actionResult = false;
- }break;
- }
- }break;
- case EBAT_HeavyAttack :
- {
- if ( IsCiri() )
- return false;
- switch ( stage )
- {
- case BS_Released :
- {
- DrainStamina(ESAT_HeavyAttack);
- thePlayer.BreakPheromoneEffect();
- actionResult = this.OnPerformAttack(theGame.params.ATTACK_NAME_HEAVY);
- } break;
- case BS_Pressed :
- {
- if ( this.GetCurrentStateName() == 'CombatFists' )
- {
- DrainStamina(ESAT_HeavyAttack);
- thePlayer.BreakPheromoneEffect();
- actionResult = this.OnPerformAttack(theGame.params.ATTACK_NAME_HEAVY);
- }
- } break;
- default :
- {
- actionResult = false;
- } break;
- }
- } break;
- case EBAT_ItemUse :
- {
- switch ( stage )
- {
- case BS_Pressed :
- {
- if ( !( (W3PlayerWitcher)this ) ||
- ( !IsInCombatActionFriendly() && !( !GetBIsCombatActionAllowed() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign ) ) ) )
- {
- if ( inv.IsItemCrossbow( selectedItemId ) )
- {
- rangedWeapon = ( Crossbow )( inv.GetItemEntityUnsafe( selectedItemId ) );
- rangedWeapon.OnRangedWeaponPress();
- GetTarget().SignalGameplayEvent( 'Approach' );
- GetTarget().SignalGameplayEvent( 'ShootingCrossbow' );
- }
- else if(inv.IsItemBomb(selectedItemId) && this.inv.SingletonItemGetAmmo(selectedItemId) > 0 )
- {
- if( ((W3PlayerWitcher)this).GetBombDelay( ((W3PlayerWitcher)this).GetItemSlot( selectedItemId ) ) <= 0.0f )
- {
- BombThrowStart();
- GetTarget().SignalGameplayEvent( 'Approach' );
- }
- }
- else
- {
- DrainStamina(ESAT_UsableItem);
- UsableItemStart();
- }
- }
- } if (!allSteps) break;
- case BS_Released:
- {
- if ( !( (W3PlayerWitcher)this ) ||
- ( !IsInCombatActionFriendly() && ( GetBIsCombatActionAllowed() || !( !GetBIsCombatActionAllowed() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign ) ) ) ) )
- {
- if ( inv.IsItemCrossbow( selectedItemId ) )
- {
- rangedWeapon.OnRangedWeaponRelease();
- }
- else if(inv.IsItemBomb(selectedItemId))
- {
- BombThrowRelease();
- }
- else
- {
- UsableItemRelease();
- }
- }
- } break;
- default :
- {
- actionResult = false;
- break;
- }
- }
- } break;
- case EBAT_Dodge :
- {
- switch ( stage )
- {
- case BS_Released :
- {
- theGame.GetBehTreeReactionManager().CreateReactionEvent( this, 'PlayerEvade', 1.0f, 10.0f, -1.0f, -1 );
- thePlayer.BreakPheromoneEffect();
- actionResult = this.OnPerformEvade( PET_Dodge );
- } break;
- default :
- {
- actionResult = false;
- } break;
- }
- } break;
- case EBAT_Roll :
- {
- if ( IsCiri() )
- return false;
- switch ( stage )
- {
- case BS_Released :
- {
- theGame.GetBehTreeReactionManager().CreateReactionEvent( this, 'PlayerEvade', 1.0f, 10.0f, -1.0f, -1 );
- thePlayer.BreakPheromoneEffect();
- actionResult = this.OnPerformEvade( PET_Roll );
- } break;
- case BS_Pressed :
- {
- if ( this.GetBehaviorVariable( 'combatActionType' ) == 2.f )
- {
- if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
- actionResult = this.OnPerformEvade( PET_Pirouette );
- else
- actionResult = this.OnPerformEvade( PET_Roll );
- }
- else
- {
- if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
- {
- actionResult = this.OnPerformEvade( PET_Dodge );
- actionResult = this.OnPerformEvade( PET_Pirouette );
- }
- else
- {
- actionResult = this.OnPerformEvade( PET_Dodge );
- actionResult = this.OnPerformEvade( PET_Roll );
- }
- }
- } break;
- default :
- {
- actionResult = false;
- } break;
- }
- } break;
- case EBAT_Draw_Steel :
- {
- switch ( stage )
- {
- case BS_Pressed :
- {
- if( !IsActionAllowed(EIAB_DrawWeapon) )
- {
- thePlayer.DisplayActionDisallowedHudMessage(EIAB_DrawWeapon);
- actionResult = false;
- break;
- }
- if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'steelsword' ) )
- {
- OnEquipMeleeWeapon( PW_Steel, false, true );
- }
- actionResult = false;
- } break;
- default :
- {
- actionResult = false;
- } break;
- }
- } break;
- case EBAT_Draw_Silver :
- {
- switch ( stage )
- {
- case BS_Pressed :
- {
- if( !IsActionAllowed(EIAB_DrawWeapon) )
- {
- thePlayer.DisplayActionDisallowedHudMessage(EIAB_DrawWeapon);
- actionResult = false;
- break;
- }
- if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'silversword' ) )
- {
- OnEquipMeleeWeapon( PW_Silver, false, true );
- }
- actionResult = false;
- } break;
- default :
- {
- actionResult = false;
- } break;
- }
- } break;
- case EBAT_Sheathe_Sword :
- {
- switch ( stage )
- {
- case BS_Pressed :
- {
- if( GetCurrentMeleeWeaponType() == PW_Silver )
- {
- if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'silversword' ) )
- {
- OnEquipMeleeWeapon( PW_Silver, false, true );
- }
- }
- else if( GetCurrentMeleeWeaponType() == PW_Steel )
- {
- if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'steelsword' ) )
- {
- OnEquipMeleeWeapon( PW_Steel, false, true );
- }
- }
- actionResult = false;
- } break;
- default :
- {
- actionResult = false;
- } break;
- }
- } break;
- default:
- return false;
- }
- CleanCombatActionBuffer();
- if (actionResult)
- {
- SetCombatAction( action ) ;
- if(GetWitcherPlayer().IsInFrenzy())
- GetWitcherPlayer().SkillFrenzyFinish(0);
- }
- return true;
- }
- public function CleanCombatActionBuffer()
- {
- BufferCombatAction = EBAT_EMPTY;
- BufferAllSteps = false;
- }
- public function CancelHoldAttacks()
- {
- RemoveTimer( 'IsSpecialLightAttackInputHeld' );
- RemoveTimer( 'IsSpecialHeavyAttackInputHeld' );
- RemoveTimer( 'SpecialAttackLightSustainCost' );
- RemoveTimer( 'SpecialAttackHeavySustainCost' );
- RemoveTimer( 'UpdateSpecialAttackLightHeading' );
- UnblockAction( EIAB_Crossbow, 'SpecialAttack' );
- ResumeStaminaRegen('WhirlSkill');
- if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_SpecialAttack && GetBehaviorVariable( 'isPerformingSpecialAttack' ) == 1.f )
- {
- if( GetBehaviorVariable( 'playerAttackType' ) == (int)PAT_Light )
- {
- SetAttackActionName(SkillEnumToName(S_Sword_s01));
- PushCombatActionOnBuffer( EBAT_SpecialAttack_Light, BS_Released );
- ProcessCombatActionBuffer();
- ((W3PlayerWitcherStateCombatFists) GetState('Combat')).ResetTimeToEndCombat();
- }
- else if( GetBehaviorVariable( 'playerAttackType' ) == (int)PAT_Heavy )
- {
- SetAttackActionName(SkillEnumToName(S_Sword_s02));
- PushCombatActionOnBuffer( EBAT_SpecialAttack_Heavy, BS_Released );
- ProcessCombatActionBuffer();
- }
- }
- }
- public function RaiseAttackFriendlyEvent( actor : CActor ) : bool
- {
- var playerToTargetHeading : float;
- if ( actor && RaiseCombatActionFriendlyEvent() )
- {
- SetBehaviorVariable( 'tauntTypeForOverlay', 0.f );
- SetBehaviorVariable( 'combatActionTypeForOverlay', (int)CAT_Attack );
- if ( actor )
- actor.SignalGameplayEvent('PersonalTauntAction');
- theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'TauntAction', -1.0, 4.5f, -1, 9999, true );
- OnCombatActionStart();
- playerToTargetHeading = VecHeading( actor.GetWorldPosition() - GetWorldPosition() );
- SetCustomRotation( 'Attack', playerToTargetHeading, 0.0f, 0.3f, false );
- return true;
- }
- return false;
- }
- public function SendAttackReactionEvent()
- {
- var reactionName : name;
- reactionName = 'AttackAction';
- if ( IsNameValid(reactionName) )
- {
- theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, reactionName, -1.0, 8.0f, -1, 5, true );
- }
- theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'outOfMyWay', -1.0, 2.0f, -1, 5, true );
- }
- var forceCanAttackWhenNotInCombat : int;
- public function SetForceCanAttackWhenNotInCombat( forceMode : int )
- {
- forceCanAttackWhenNotInCombat = forceMode;
- }
- public function CanAttackWhenNotInCombat( actionType : EBufferActionType, altCast : bool, out newTarget : CActor, optional target : CGameplayEntity ) : bool
- {
- var localTargets : array<CActor>;
- var i, size : int;
- var inputHeading : float;
- var clearanceMin, clearanceMax : float;
- var attackLength : float;
- var attackAngle : float;
- var npc : CNewNPC;
- var canAttackTarget : CGameplayEntity;
- var canAttackTargetActor : CActor;
- if ( target )
- canAttackTarget = target;
- else if ( displayTarget && IsDisplayTargetTargetable() )
- canAttackTarget = displayTarget;
- else
- canAttackTarget = slideTarget;
- canAttackTargetActor = (CActor)canAttackTarget;
- if ( forceCanAttackWhenNotInCombat == 2 )
- return true;
- else if ( forceCanAttackWhenNotInCombat == 1 && ( !canAttackTarget || !canAttackTargetActor.IsHuman() ) )
- return true;
- if ( actionType == EBAT_CastSign )
- {
- if ( thePlayer.GetEquippedSign() != ST_Quen && thePlayer.GetEquippedSign() != ST_Axii )
- {
- if ( CanUseSkill( S_Magic_s20 ) )
- {
- if ( thePlayer.GetEquippedSign() == ST_Aard )
- attackLength = 6.f;
- else if ( thePlayer.GetEquippedSign() == ST_Igni )
- attackLength = 4.f;
- else
- attackLength = 6.f;
- }
- else
- {
- if ( thePlayer.GetEquippedSign() == ST_Aard )
- attackLength = 9.f;
- else if ( thePlayer.GetEquippedSign() == ST_Igni )
- attackLength = 6.f;
- else
- attackLength = 6.f;
- }
- if ( altCast )
- attackAngle = 180.f;
- else
- attackAngle = 90.f;
- if ( !lastAxisInputIsMovement )
- inputHeading = VecHeading( theCamera.GetCameraDirection() );
- else if ( lAxisReleasedAfterCounter )
- inputHeading = GetHeading();
- else
- inputHeading = GetCombatActionHeading();
- clearanceMin = 1.f;
- clearanceMax = attackLength + 1.f;
- }
- else if ( thePlayer.GetEquippedSign() == ST_Axii )
- {
- npc = (CNewNPC)canAttackTarget;
- if ( npc && npc.GetNPCType() == ENGT_Quest && !npc.HasTag(theGame.params.TAG_AXIIABLE_LOWER_CASE) && !npc.HasTag(theGame.params.TAG_AXIIABLE))
- return false;
- else if ( npc && npc.IsUsingHorse() )
- return false;
- else
- return true;
- }
- else
- return true;
- }
- else if ( actionType == EBAT_ItemUse )
- {
- attackLength = theGame.params.MAX_THROW_RANGE;
- attackAngle = 90.f;
- if ( thePlayer.lastAxisInputIsMovement )
- inputHeading = GetCombatActionHeading();
- else
- inputHeading = VecHeading( theCamera.GetCameraDirection() );
- clearanceMin = 0.8f;
- clearanceMax = attackLength + 3.f;
- }
- else
- {
- if ( actionType == EBAT_SpecialAttack_Light || actionType == EBAT_SpecialAttack_Heavy )
- {
- attackLength = 1.9f;
- attackAngle = 90.f;
- }
- else
- {
- if( thePlayer.GetCurrentMeleeWeaponType() == PW_Fists || thePlayer.GetCurrentMeleeWeaponType() == PW_None )
- attackLength = 1.2f;
- else
- attackLength = 1.9f;
- attackAngle = 90.f;
- }
- if ( lastAxisInputIsMovement )
- inputHeading = GetCombatActionHeading();
- else
- inputHeading = VecHeading( theCamera.GetCameraDirection() );
- clearanceMin = attackLength / 2.f;
- clearanceMax = attackLength + 3.f;
- }
- if ( canAttackTarget )
- {
- if ( ( canAttackTargetActor && canAttackTargetActor.IsHuman() ) || canAttackTargetActor.HasTag( 'softLock_Friendly' ) )
- {
- if ( ShouldPerformFriendlyAction( canAttackTargetActor, inputHeading, attackAngle, clearanceMin, clearanceMax ) )
- {
- SetSlideTarget( canAttackTargetActor );
- newTarget = canAttackTargetActor;
- return false;
- }
- }
- }
- return true;
- thePlayer.GetVisibleEnemies( localTargets );
- size = localTargets.Size();
- if ( size > 0 )
- {
- for ( i = size-1; i>=0; i-=1 )
- {
- if ( !localTargets[i].IsHuman() && !localTargets[i].HasTag( 'softLock_Friendly' ) )
- localTargets.Erase(i);
- }
- }
- size = localTargets.Size();
- if ( size > 0 )
- {
- for ( i = 0; i < localTargets.Size(); i += 1 )
- {
- if ( ShouldPerformFriendlyAction( localTargets[i], inputHeading, attackAngle, clearanceMin, clearanceMax ) )
- {
- SetSlideTarget( localTargets[i] );
- newTarget = localTargets[i];
- return false;
- }
- }
- }
- newTarget = NULL;
- return true;
- }
- private function ShouldPerformFriendlyAction( actor : CActor, inputHeading, attackAngle, clearanceMin, clearanceMax : float ) : bool
- {
- var npc : CNewNPC;
- var argh : float;
- var playerToTargetDist : float;
- npc = (CNewNPC)actor;
- if ( npc &&
- ( GetAttitudeBetween(thePlayer, npc) == AIA_Hostile || ( GetAttitudeBetween(thePlayer, npc) == AIA_Neutral && npc.GetNPCType() != ENGT_Guard ) ) )
- {
- }
- else
- {
- playerToTargetDist = VecDistance( this.GetWorldPosition(), actor.PredictWorldPosition( 0.5f ) );
- argh = AbsF( AngleDistance( inputHeading, VecHeading( actor.GetWorldPosition() - thePlayer.GetWorldPosition() ) ) );
- if ( AbsF( AngleDistance( inputHeading, VecHeading( actor.GetWorldPosition() - thePlayer.GetWorldPosition() ) ) ) < attackAngle )
- {
- if ( playerToTargetDist < clearanceMax )
- {
- return true;
- }
- }
- else
- {
- if ( playerToTargetDist < clearanceMin )
- {
- return true;
- }
- }
- }
- return false;
- }
- public function GetHudMessagesSize() : int
- {
- return HudMessages.Size();
- }
- public function GetHudPendingMessage() : string
- {
- return HudMessages[0];
- }
- public function DisplayHudMessage( value : string ) : void
- {
- if (value == "")
- {
- return;
- }
- if( GetHudMessagesSize() > 0 )
- {
- if( HudMessages[HudMessages.Size()-1] == value )
- {
- return;
- }
- }
- HudMessages.PushBack(value);
- }
- private final function DisallowedActionDontShowHack(action : EInputActionBlock, isTimeLock : bool) : bool
- {
- var locks : array< SInputActionLock >;
- var i : int;
- 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)) )
- {
- return true;
- }
- if( action == EIAB_ThrowBomb && ( HasBuff( EET_Hypnotized ) || HasBuff( EET_Confusion ) ) )
- {
- return false;
- }
- if(isTimeLock)
- return false;
- if(action == EIAB_OpenMeditation)
- return false;
- locks = GetActionLocks(action);
- for(i=0; i<locks.Size(); i+=1)
- {
- if(locks[i].isFromQuest || locks[i].isFromPlace)
- return false;
- }
- if ( this.IsCurrentlyUsingItemL() )
- {
- if ( action == EIAB_HeavyAttacks || action == EIAB_Parry )
- return false;
- }
- return true;
- }
- public final function DisplayActionDisallowedHudMessage(action : EInputActionBlock, optional isCombatLock : bool, optional isPlaceLock : bool, optional isTimeLock : bool, optional isDangerous : bool)
- {
- var lockType : name;
- if(action != EIAB_Undefined && DisallowedActionDontShowHack(action, isTimeLock))
- return;
- if(IsInCombat() && !IsActionCombat(action))
- isCombatLock = true;
- if(!isCombatLock && !isPlaceLock && !isTimeLock && action != EIAB_Undefined)
- {
- lockType = inputHandler.GetActionBlockedHudLockType(action);
- if(lockType == 'combat')
- isCombatLock = true;
- else if(lockType == 'place')
- isPlaceLock = true;
- else if(lockType == 'time')
- isTimeLock = true;
- }
- if(isDangerous)
- {
- DisplayHudMessage(GetLocStringByKeyExt( "message_meditation_too_dangerous" ));
- }
- else if(isCombatLock)
- {
- DisplayHudMessage(GetLocStringByKeyExt( "panel_hud_message_actionnotallowed_combat" ));
- }
- else if(isPlaceLock)
- {
- DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_here" ));
- }
- else if(isTimeLock)
- {
- DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_now" ));
- }
- }
- public function RemoveHudMessageByString(msg : string, optional allQueuedInstances : bool)
- {
- var i, j : int;
- for(i=0; i<HudMessages.Size(); i+=1)
- {
- if(HudMessages[i] == msg)
- {
- HudMessages.EraseFast(i);
- if(!allQueuedInstances)
- return;
- break;
- }
- }
- for(j=HudMessages.Size()-1; j >= i; j-=1)
- {
- if(HudMessages[i] == msg)
- {
- HudMessages.EraseFast(i);
- }
- }
- }
- public function RemoveHudMessageByIndex(idx : int)
- {
- if(idx >= 0 && idx < HudMessages.Size())
- HudMessages.Erase(idx);
- }
- function SetSettlementBlockCanter( valueAdd : int )
- {
- m_SettlementBlockCanter += valueAdd;
- }
- var countDownToStart : int;
- default countDownToStart = 0;
- function DisplayRaceStart( countDownSecondsNumber : int )
- {
- var i : int;
- countDownToStart = countDownSecondsNumber;
- for( i = countDownSecondsNumber; i > 0; i -= 1 )
- {
- DisplayHudMessage(IntToString(i));
- }
- DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_race_start"));
- AddTimer('RaceCountdown',1,true);
- }
- timer function RaceCountdown(dt : float, id : int)
- {
- var hud : CR4ScriptedHud;
- var messageModule : CR4HudModuleMessage;
- countDownToStart -= 1;
- hud = (CR4ScriptedHud)theGame.GetHud();
- if( hud )
- {
- messageModule = (CR4HudModuleMessage)hud.GetHudModule("MessageModule");
- if( messageModule )
- {
- messageModule.OnMessageHidden();
- }
- }
- if( countDownToStart <= 0 )
- {
- RemoveTimer('RaceCountdown');
- }
- }
- public function GetCountDownToStart() : int
- {
- return countDownToStart;
- }
- public function HAXE3GetContainer() : W3Container
- {
- return HAXE3Container;
- }
- public function HAXE3SetContainer( container : W3Container) : void
- {
- HAXE3Container = container;
- }
- public function HAXE3GetAutoLoot() : bool
- {
- return HAXE3bAutoLoot;
- }
- public function HAXE3SetAutoLoot( value : bool ) : void
- {
- HAXE3bAutoLoot = value;
- }
- public function GetShowHud() : bool
- {
- return bShowHud;
- }
- public function SetShowHud( value : bool ) : void
- {
- bShowHud = value;
- }
- public function DisplayItemRewardNotification( itemName : name, optional quantity : int ) : void
- {
- var hud : CR4ScriptedHud;
- hud = (CR4ScriptedHud)theGame.GetHud();
- hud.OnItemRecivedDuringScene(itemName, quantity);
- }
- function IsNewQuest( questGuid : CGUID ) : bool
- {
- var i : int;
- for(i = 0; i < displayedQuestsGUID.Size(); i += 1 )
- {
- if( displayedQuestsGUID[i] == questGuid )
- {
- return false;
- }
- }
- displayedQuestsGUID.PushBack(questGuid);
- return true;
- }
- function GetRewardMultiplierData( rewardName : name ) : SRewardMultiplier
- {
- var defaultReward : SRewardMultiplier;
- var i : int;
- for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
- {
- if( rewardsMultiplier[i].rewardName == rewardName )
- {
- return rewardsMultiplier[i];
- }
- }
- defaultReward.rewardName = rewardName;
- defaultReward.rewardMultiplier = 1.0;
- defaultReward.isItemMultiplier = false;
- return defaultReward;
- }
- function GetRewardMultiplier( rewardName : name ) : float
- {
- var i : int;
- for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
- {
- if( rewardsMultiplier[i].rewardName == rewardName )
- {
- return rewardsMultiplier[i].rewardMultiplier;
- }
- }
- return 1.0;
- }
- function GetRewardMultiplierExists( rewardName : name ) : bool
- {
- var i : int;
- for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
- {
- if( rewardsMultiplier[i].rewardName == rewardName )
- {
- return true;
- }
- }
- return false;
- }
- function SetRewardMultiplier( rewardName : name, value : float, optional isItemMultiplier : bool ) : void
- {
- var i : int;
- var rewardMultiplier : SRewardMultiplier;
- for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
- {
- if( rewardsMultiplier[i].rewardName == rewardName )
- {
- rewardsMultiplier[i].rewardMultiplier = value;
- rewardsMultiplier[i].isItemMultiplier = isItemMultiplier;
- return;
- }
- }
- rewardMultiplier.rewardName = rewardName;
- rewardMultiplier.rewardMultiplier = value;
- rewardMultiplier.isItemMultiplier = isItemMultiplier;
- rewardsMultiplier.PushBack(rewardMultiplier);
- }
- function RemoveRewardMultiplier( rewardName : name ) : void
- {
- var i : int;
- for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
- {
- if( rewardsMultiplier[i].rewardName == rewardName )
- {
- rewardsMultiplier.Erase(i);
- return;
- }
- }
- }
- public final function TissueExtractorDischarge() : bool
- {
- var ids : array<SItemUniqueId>;
- var chargesLeft, uses, curr, max, red, blue, green : int;
- var i : int;
- var text : string;
- ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
- if( ids.Size() == 0 )
- {
- return false;
- }
- curr = GetTissueExtractorChargesCurr();
- max = GetTissueExtractorChargesMax();
- if( curr >= max )
- {
- uses = FloorF( ( ( float ) curr ) / ( ( float ) max ) );
- chargesLeft = Max( 0, curr - uses * max );
- inv.SetItemModifierInt( ids[0], 'charges', chargesLeft );
- blue = 0;
- green = 0;
- red = 0;
- for( i=0; i<uses; i+=1 )
- {
- switch( RandRange( 3 ) )
- {
- case 0:
- blue += 1;
- break;
- case 1:
- green += 1;
- break;
- case 2:
- red += 1;
- }
- }
- text = GetLocStringByKeyExt( "message_q705_extractor_extracted" );
- if( blue > 0 )
- {
- inv.AddAnItem( 'Greater mutagen blue', blue, false, true );
- text += "<br/>" + blue + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen blue' ) );
- }
- if( green > 0 )
- {
- inv.AddAnItem( 'Greater mutagen green', green, false, true );
- text += "<br/>" + green + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen green' ) );
- }
- if( red > 0 )
- {
- inv.AddAnItem( 'Greater mutagen red', red, false, true );
- text += "<br/>" + red + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen red' ) );
- }
- theGame.GetGuiManager().ShowNotification( text );
- inv.SetItemModifierInt( ids[0], 'ui_notified', 0 );
- return true;
- }
- else
- {
- theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_q705_extractor_too_few_charges" ) );
- }
- return false;
- }
- public final function TissueExtractorIncCharge()
- {
- var ids : array<SItemUniqueId>;
- var uiData : SInventoryItemUIData;
- var curr : int;
- ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
- if( ids.Size() == 0 )
- {
- return;
- }
- curr = GetTissueExtractorChargesCurr() + 1;
- inv.SetItemModifierInt( ids[0], 'charges', curr );
- if( curr >= GetTissueExtractorChargesMax() )
- {
- uiData = inv.GetInventoryItemUIData( ids[0] );
- uiData.isNew = true;
- inv.SetInventoryItemUIData( ids[0], uiData );
- if( inv.GetItemModifierInt( ids[0], 'ui_notified', 0 ) == 0 )
- {
- inv.SetItemModifierInt( ids[0], 'ui_notified', 1 );
- theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_q705_extractor_charged" ), , true );
- }
- }
- }
- public final function GetTissueExtractorChargesCurr() : int
- {
- var ids : array<SItemUniqueId>;
- ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
- if( ids.Size() == 0 )
- {
- return 0;
- }
- return inv.GetItemModifierInt( ids[0], 'charges', 0 );
- }
- public final function GetTissueExtractorChargesMax() : int
- {
- var ids : array<SItemUniqueId>;
- var val : SAbilityAttributeValue;
- ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
- if( ids.Size() == 0 )
- {
- return 0;
- }
- val = inv.GetItemAttributeValue( ids[0], 'maxCharges' );
- return FloorF( val.valueBase );
- }
- public function GetEquippedSword(steel : bool) : SItemUniqueId;
- public final function HasRequiredLevelToEquipItem(item : SItemUniqueId) : bool
- {
- if(HasBuff(EET_WolfHour))
- {
- if((inv.GetItemLevel(item) - 2) > GetLevel() )
- return false;
- }
- else
- {
- if(inv.GetItemLevel(item) > GetLevel() )
- return false;
- }
- return true;
- }
- public function SkillReduceBombAmmoBonus()
- {
- var i, ammo, maxAmmo : int;
- var items : array<SItemUniqueId>;
- items = inv.GetSingletonItems();
- for(i=0; i<items.Size(); i+=1)
- {
- ammo = inv.GetItemModifierInt(items[i], 'ammo_current');
- if(ammo > 0)
- {
- maxAmmo = inv.SingletonItemGetMaxAmmo(items[i]);
- if(ammo > maxAmmo)
- {
- inv.SetItemModifierInt(items[i], 'ammo_current', maxAmmo);
- }
- }
- }
- theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
- }
- public function ConsumeItem( itemId : SItemUniqueId ) : bool
- {
- var params : SCustomEffectParams;
- var buffs : array<SEffectInfo>;
- var i : int;
- var category : name;
- var potionToxicity : float;
- if(!inv.IsIdValid(itemId))
- return false;
- category = inv.GetItemCategory(itemId);
- if(category == 'edibles' || inv.ItemHasTag(itemId, 'Drinks') || ( category == 'alchemy_ingredient' && inv.ItemHasTag(itemId, 'Alcohol')) )
- {
- if(IsFistFightMinigameEnabled())
- {
- DisplayActionDisallowedHudMessage(EIAB_Undefined, false, false, true);
- return false;
- }
- inv.GetItemBuffs(itemId, buffs);
- for(i=0; i<buffs.Size(); i+=1)
- {
- params.effectType = buffs[i].effectType;
- params.creator = this;
- params.sourceName = "edible";
- params.customAbilityName = buffs[i].effectAbilityName;
- AddEffectCustom(params);
- }
- if ( inv.ItemHasTag(itemId, 'Alcohol') )
- {
- potionToxicity = CalculateAttributeValue(inv.GetItemAttributeValue(itemId, 'toxicity'));
- abilityManager.GainStat(BCS_Toxicity, potionToxicity );
- AddEffectDefault(EET_Drunkenness, NULL, inv.GetItemName(itemId));
- }
- PlayItemConsumeSound( itemId );
- }
- if(inv.IsItemFood(itemId))
- FactsAdd("consumed_food_cnt");
- if(!inv.ItemHasTag(itemId, theGame.params.TAG_INFINITE_USE) && !inv.RemoveItem(itemId))
- {
- LogAssert(false,"Failed to remove consumable item from player inventory!" + inv.GetItemName( itemId ) );
- return false;
- }
- return true;
- }
- public function MountVehicle( vehicleEntity : CEntity, mountType : EVehicleMountType, optional vehicleSlot : EVehicleSlot )
- {
- var vehicle : CVehicleComponent;
- vehicle = (CVehicleComponent)(vehicleEntity.GetComponentByClassName('CVehicleComponent'));
- if ( vehicle )
- vehicle.Mount( this, mountType, vehicleSlot );
- }
- public function DismountVehicle( vehicleEntity : CEntity, dismountType : EDismountType )
- {
- var vehicle : CVehicleComponent;
- vehicle = (CVehicleComponent)(vehicleEntity.GetComponentByClassName('CVehicleComponent'));
- if ( vehicle )
- vehicle.IssueCommandToDismount( dismountType );
- }
- protected function ShouldDrainStaminaWhileSprinting() : bool
- {
- if( HasBuff( EET_PolishedGenitals ) && !IsInCombat() && !IsThreatened() )
- {
- return false;
- }
- return super.ShouldDrainStaminaWhileSprinting();
- }
- public function HasStaminaToUseAction(action : EStaminaActionType, optional abilityName : name, optional dt :float, optional multiplier : float) : bool
- {
- var cost : float;
- var ret : bool;
- ret = super.HasStaminaToUseAction(action, abilityName, dt, multiplier);
- if(!ret)
- {
- SetCombatActionHeading( GetHeading() );
- if(multiplier == 0)
- multiplier = 1;
- cost = multiplier * GetStaminaActionCost(action, abilityName, dt);
- SetShowToLowStaminaIndication(cost);
- }
- return ret;
- }
- timer function AbilityManager_FloorStaminaSegment(dt : float, id : int)
- {
- ((W3PlayerAbilityManager)abilityManager).FloorStaminaSegment();
- }
- public function DrainToxicity(amount : float )
- {
- if(abilityManager && abilityManager.IsInitialized() && IsAlive())
- abilityManager.DrainToxicity(amount);
- }
- public function DrainFocus(amount : float )
- {
- if(abilityManager && abilityManager.IsInitialized() && IsAlive())
- abilityManager.DrainFocus(amount);
- }
- public function GetOffenseStat():int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetOffenseStat();
- return 0;
- }
- public function GetDefenseStat():int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetDefenseStat();
- return 0;
- }
- public function GetSignsStat():float
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSignsStat();
- return 0;
- }
- private var inWaterTrigger : bool;
- event OnOceanTriggerEnter()
- {
- inWaterTrigger = true;
- }
- event OnOceanTriggerLeave()
- {
- inWaterTrigger = false;
- }
- public function IsInWaterTrigger() : bool
- {
- return inWaterTrigger;
- }
- public function GetSkillColor(skill : ESkill) : ESkillColor
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillColor(skill);
- return SC_None;
- }
- public function GetSkillSlotIndexFromSkill(skill : ESkill) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIndexFromSkill(skill);
- return -1;
- }
- public final function GetSkillSlotIndex(slotID : int, checkIfUnlocked : bool) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIndex(slotID, checkIfUnlocked);
- return -1;
- }
- public final function GetSkillSlotIDFromIndex(skillSlotIndex : int) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIDFromIndex(skillSlotIndex);
- return -1;
- }
- public function GetSkillSlotID(skill : ESkill) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotID(skill);
- return -1;
- }
- public function GetSkillGroupBonus(groupID : int) : name
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetGroupBonus(groupID);
- return '';
- }
- public function GetGroupBonusCount(commonColor : ESkillColor,groupID : int) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillGroupColorCount(commonColor, groupID);
- return 0;
- }
- public function GetMutagenSlotIDFromGroupID(groupID : int) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetMutagenSlotIDFromGroupID(groupID);
- return -1;
- }
- public function GetSkillLevel(skill : ESkill) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillLevel(skill);
- return -1;
- }
- public function GetBoughtSkillLevel(skill : ESkill) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetBoughtSkillLevel(skill);
- return -1;
- }
- public function AddSkill(skill : ESkill, optional isTemporary : bool)
- {
- if(abilityManager && abilityManager.IsInitialized())
- ((W3PlayerAbilityManager)abilityManager).AddSkill(skill, isTemporary);
- }
- public function AddMultipleSkills(skill : ESkill, optional number : int, optional isTemporary : bool)
- {
- var i : int;
- if(number)
- {
- for( i=0; i<number; i+=1)
- {
- AddSkill(skill,isTemporary);
- }
- }
- else
- {
- AddSkill(skill,isTemporary);
- }
- }
- public function GetSkillAbilityName(skill : ESkill) : name
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillAbilityName(skill);
- return '';
- }
- public function HasStaminaToUseSkill(skill : ESkill, optional perSec : bool, optional signHack : bool) : bool
- {
- var ret : bool;
- var cost : float;
- cost = GetSkillStaminaUseCost(skill, perSec);
- ret = ( CanUseSkill(skill) && (abilityManager.GetStat(BCS_Stamina, signHack) >= cost) );
- if(!ret && IsSkillSign(skill) && CanUseSkill(S_Perk_09) && GetStat(BCS_Focus) >= 1)
- {
- ret = true;
- }
- if( !ret && IsSkillSign( skill ) && GetWitcherPlayer().HasBuff( EET_GryphonSetBonus ) )
- {
- ret = true;
- }
- if(!ret)
- {
- SetCombatActionHeading( GetHeading() );
- SetShowToLowStaminaIndication(cost);
- }
- return ret;
- }
- protected function GetSkillStaminaUseCost(skill : ESkill, optional perSec : bool) : float
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillStaminaUseCost(skill, perSec);
- return 0;
- }
- public function GetSkillAttributeValue(skill : ESkill, attributeName : name, addBaseCharAttribute : bool, addSkillModsAttribute : bool) : SAbilityAttributeValue
- {
- var null : SAbilityAttributeValue;
- if(abilityManager && abilityManager.IsInitialized())
- return abilityManager.GetSkillAttributeValue(SkillEnumToName(skill), attributeName, addBaseCharAttribute, addSkillModsAttribute);
- return null;
- }
- public function GetSkillLocalisationKeyName(skill : ESkill) : string
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillLocalisationKeyName(skill);
- return "";
- }
- public function GetSkillLocalisationKeyDescription(skill : ESkill) : string
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillLocalisationKeyDescription(skill);
- return "";
- }
- public function GetSkillIconPath(skill : ESkill) : string
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillIconPath(skill);
- return "";
- }
- public function HasLearnedSkill(skill : ESkill) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).HasLearnedSkill(skill);
- return false;
- }
- public function IsSkillEquipped(skill : ESkill) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).IsSkillEquipped(skill);
- return false;
- }
- public function CanUseSkill(skill : ESkill) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).CanUseSkill(skill);
- return false;
- }
- public function CanLearnSkill(skill : ESkill) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).CanLearnSkill(skill);
- return false;
- }
- public function HasSpentEnoughPoints(skill : ESkill) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).HasSpentEnoughPoints(skill);
- return false;
- }
- public function PathPointsForSkillsPath(skill : ESkill) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).PathPointsSpentInSkillPathOfSkill(skill);
- return -1;
- }
- public function GetPlayerSkills() : array<SSkill>
- {
- var null : array<SSkill>;
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkills();
- return null;
- }
- public function GetPlayerSkill(s : ESkill) : SSkill
- {
- var null : SSkill;
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkill(s);
- return null;
- }
- public function GetSkillSubPathType(s : ESkill) : ESkillSubPath
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillSubPathType(s);
- return ESSP_NotSet;
- }
- public function GetSkillSlotsCount() : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotsCount();
- return 0;
- }
- public function GetSkillSlots() : array<SSkillSlot>
- {
- var null : array<SSkillSlot>;
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillSlots();
- return null;
- }
- public function GetPlayerSkillMutagens() : array<SMutagenSlot>
- {
- var null : array<SMutagenSlot>;
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkillMutagens();
- return null;
- }
- public function BlockSkill(skill : ESkill, block : bool, optional cooldown : float) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).BlockSkill(skill, block, cooldown);
- return false;
- }
- public function IsSkillBlocked(skill : ESkill) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).IsSkillBlocked(skill);
- return false;
- }
- public function EquipSkill(skill : ESkill, slotID : int) : bool
- {
- var ret : bool;
- var groupID : int;
- var pam : W3PlayerAbilityManager;
- if(abilityManager && abilityManager.IsInitialized())
- {
- pam = (W3PlayerAbilityManager)abilityManager;
- ret = pam.EquipSkill(skill, slotID);
- if(ret)
- {
- groupID = pam.GetSkillGroupIdFromSkillSlotId(slotID);
- LogSkillColors("Equipped <<" + GetSkillColor(skill) + ">> skill <<" + skill + ">> to group <<" + groupID + ">>");
- LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
- LogSkillColors("");
- }
- return ret;
- }
- return false;
- }
- public function UnequipSkill(slotID : int) : bool
- {
- var ret : bool;
- var groupID : int;
- var skill : ESkill;
- var pam : W3PlayerAbilityManager;
- if(abilityManager && abilityManager.IsInitialized())
- {
- pam = (W3PlayerAbilityManager)abilityManager;
- GetSkillOnSlot(slotID, skill);
- ret = pam.UnequipSkill(slotID);
- if(ret)
- {
- groupID = pam.GetSkillGroupIdFromSkillSlotId(slotID);
- LogSkillColors("Unequipped <<" + GetSkillColor(skill) + ">> skill <<" + skill + ">> from group <<" + groupID + ">>");
- LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
- LogSkillColors("");
- }
- return ret;
- }
- return false;
- }
- public function GetSkillOnSlot(slotID : int, out skill : ESkill) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillOnSlot(slotID, skill);
- skill = S_SUndefined;
- return false;
- }
- public function GetFreeSkillSlot() : int
- {
- var i, size : int;
- var skill : ESkill;
- size = ((W3PlayerAbilityManager)abilityManager).GetSkillSlotsCount();
- for(i=1; i<size; i+=1)
- {
- if(!GetSkillOnSlot(i, skill))
- continue;
- if(skill == S_SUndefined)
- return i;
- }
- return -1;
- }
- protected function Attack( hitTarget : CGameplayEntity, animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float, weaponEntity : CItemEntity)
- {
- var attackAction : W3Action_Attack;
- if(!PrepareAttackAction(hitTarget, animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime, weaponEntity, attackAction))
- return;
- if ( attackAction.IsParried() && ( ((CNewNPC)attackAction.victim).IsShielded(attackAction.attacker) || ((CNewNPC)attackAction.victim).SignalGameplayEventReturnInt('IsDefending',0) == 1 ) )
- {
- thePlayer.SetCanPlayHitAnim(true);
- thePlayer.ReactToReflectedAttack(attackAction.victim);
- }
- theTelemetry.LogWithLabel( TE_FIGHT_PLAYER_ATTACKS, attackAction.GetAttackName() );
- theGame.damageMgr.ProcessAction(attackAction);
- delete attackAction;
- }
- public function IsHeavyAttack(attackName : name) : bool
- {
- var skill : ESkill;
- var sup : bool;
- sup = super.IsHeavyAttack(attackName);
- if(sup)
- return true;
- if ( attackName == 'attack_heavy_special' )
- return true;
- skill = SkillNameToEnum(attackName);
- return skill == S_Sword_2 || skill == S_Sword_s02;
- }
- public function IsLightAttack(attackName : name) : bool
- {
- var skill : ESkill;
- var sup : bool;
- sup = super.IsLightAttack(attackName);
- if(sup)
- return true;
- skill = SkillNameToEnum(attackName);
- return skill == S_Sword_1 || skill == S_Sword_s01;
- }
- public final function ProcessWeaponCollision()
- {
- var l_stateName : name;
- var l_weaponPosition : Vector;
- var l_weaponTipPos : Vector;
- var l_collidingPosition : Vector;
- var l_offset : Vector;
- var l_normal : Vector;
- var l_slotMatrix : Matrix;
- var l_distance : float;
- var l_materialName : name;
- var l_hitComponent : CComponent;
- var l_destructibleCmp : CDestructionSystemComponent;
- var barrel : COilBarrelEntity;
- if( isCurrentlyDodging )
- return;
- l_stateName = GetCurrentStateName();
- if( !attackEventInProgress && l_stateName == 'CombatFists' )
- return;
- CalcEntitySlotMatrix('r_weapon', l_slotMatrix);
- l_weaponPosition = MatrixGetTranslation( l_slotMatrix );
- switch( l_stateName )
- {
- case 'CombatFists':
- l_offset = MatrixGetAxisX( l_slotMatrix );
- l_offset = VecNormalize( l_offset ) * 0.25f;
- break;
- default:
- l_offset = MatrixGetAxisZ( l_slotMatrix );
- l_offset = VecNormalize( l_offset ) * 1.f;
- break;
- }
- l_weaponTipPos = l_weaponPosition + l_offset;
- if( !attackEventInProgress )
- {
- if( m_LastWeaponTipPos == Vector ( 0, 0, 0 ) )
- l_distance = 0;
- else
- l_distance = VecDistance( l_weaponTipPos, m_LastWeaponTipPos ) ;
- m_LastWeaponTipPos = l_weaponTipPos;
- if( l_distance < 0.35f )
- return;
- }
- m_LastWeaponTipPos = l_weaponTipPos;
- if ( !theGame.GetWorld().StaticTraceWithAdditionalInfo( l_weaponPosition, l_weaponTipPos, l_collidingPosition, l_normal, l_materialName, l_hitComponent, m_WeaponFXCollisionGroupNames ) )
- {
- if( l_stateName == 'CombatFists' )
- {
- CalcEntitySlotMatrix('l_weapon', l_slotMatrix);
- l_weaponPosition = MatrixGetTranslation( l_slotMatrix );
- l_offset = MatrixGetAxisX( l_slotMatrix );
- l_offset = VecNormalize( l_offset ) * 0.25f;
- l_weaponTipPos = l_weaponPosition + l_offset;
- if( !theGame.GetWorld().StaticTrace( l_weaponPosition, l_weaponTipPos, l_collidingPosition, l_normal, m_WeaponFXCollisionGroupNames ) )
- {
- return;
- }
- }
- else
- {
- return;
- }
- }
- if( !m_CollisionEffect )
- {
- m_CollisionEffect = theGame.CreateEntity( m_CollisionFxTemplate, l_collidingPosition, EulerAngles(0,0,0) );
- }
- m_CollisionEffect.Teleport( l_collidingPosition );
- switch( l_stateName )
- {
- case 'CombatFists':
- m_CollisionEffect.PlayEffect('fist');
- break;
- default:
- if( m_RefreshWeaponFXType )
- {
- m_PlayWoodenFX = IsSwordWooden();
- m_RefreshWeaponFXType = false;
- }
- if( m_PlayWoodenFX )
- {
- m_CollisionEffect.PlayEffect('wood');
- }
- else
- {
- switch( l_materialName )
- {
- case 'wood_hollow':
- case 'wood_debris':
- case 'wood_solid':
- m_CollisionEffect.PlayEffect('wood');
- break;
- case 'dirt_hard':
- case 'dirt_soil':
- case 'hay':
- m_CollisionEffect.PlayEffect('fist');
- break;
- case 'stone_debris':
- case 'stone_solid':
- case 'clay_tile':
- case 'gravel_large':
- case 'gravel_small':
- case 'metal':
- case 'custom_sword':
- m_CollisionEffect.PlayEffect('sparks');
- break;
- case 'flesh':
- m_CollisionEffect.PlayEffect('blood');
- break;
- default:
- m_CollisionEffect.PlayEffect('wood');
- break;
- }
- }
- break;
- }
- if(l_hitComponent)
- {
- barrel = (COilBarrelEntity)l_hitComponent.GetEntity();
- if(barrel)
- {
- barrel.OnFireHit(NULL);
- return;
- }
- }
- l_destructibleCmp = (CDestructionSystemComponent) l_hitComponent;
- if( l_destructibleCmp && l_stateName != 'CombatFists' )
- {
- l_destructibleCmp.ApplyFracture();
- }
- }
- public function ReactToReflectedAttack( target : CGameplayEntity)
- {
- var hp, dmg : float;
- var action : W3DamageAction;
- super.ReactToReflectedAttack(target);
- theGame.VibrateControllerLight();
- }
- function GetFallDist( out fallDist : float ) : bool
- {
- var fallDiff, jumpTotalDiff : float;
- substateManager.m_SharedDataO.CalculateFallingHeights( fallDiff, jumpTotalDiff );
- if ( fallDiff <= 0 )
- return false;
- fallDist = fallDiff;
- return true;
- }
- function ApplyFallingDamage(heightDiff : float, optional reducing : bool) : float
- {
- var hpPerc : float;
- var tut : STutorialMessage;
- if ( IsSwimming() || FactsQuerySum("block_falling_damage") >= 1 )
- return 0.0f;
- hpPerc = super.ApplyFallingDamage( heightDiff, reducing );
- if(hpPerc > 0)
- {
- theGame.VibrateControllerHard();
- if(IsAlive())
- {
- if(ShouldProcessTutorial('TutorialFallingDamage'))
- {
- FactsSet( "tutorial_falling_damage", 1 );
- }
- if(FactsQuerySum("tutorial_falling_damage") > 1 && ShouldProcessTutorial('TutorialFallingRoll'))
- {
- tut.type = ETMT_Hint;
- tut.tutorialScriptTag = 'TutorialFallingRoll';
- tut.hintPositionType = ETHPT_DefaultGlobal;
- tut.hintDurationType = ETHDT_Long;
- tut.canBeShownInMenus = false;
- tut.glossaryLink = false;
- tut.markAsSeenOnShow = true;
- theGame.GetTutorialSystem().DisplayTutorial(tut);
- }
- }
- }
- return hpPerc;
- }
- public function SetShowToLowStaminaIndication( value : float ) : void
- {
- fShowToLowStaminaIndication = value;
- }
- public function GetShowToLowStaminaIndication() : float
- {
- return fShowToLowStaminaIndication;
- }
- public final function IndicateTooLowAdrenaline()
- {
- SoundEvent("gui_no_adrenaline");
- showTooLowAdrenaline = true;
- }
- protected function GotoCombatStateWithAction( initialAction : EInitialAction, optional initialBuff : CBaseGameplayEffect )
- {
- if ( this.GetCurrentActionType() == ActorAction_Exploration )
- ActionCancelAll();
- ((W3PlayerWitcherStateCombatFists)this.GetState('CombatFists')).SetupState( initialAction, initialBuff );
- this.GotoState( 'CombatFists' );
- }
- public function IsThreat( actor : CActor, optional usePrecalcs : bool ) : bool
- {
- var npc : CNewNPC;
- var dist : float;
- var targetCapsuleHeight : float;
- var isDistanceExpanded : bool;
- var distanceToTarget : float;
- var attitude : EAIAttitude;
- if (!actor)
- {
- return false;
- }
- if ( finishableEnemiesList.Contains( actor ) )
- {
- return true;
- }
- if ( !actor.IsAlive() || actor.IsKnockedUnconscious() )
- {
- return false;
- }
- npc = (CNewNPC)actor;
- if (npc && npc.IsHorse() )
- {
- return false;
- }
- if ( hostileEnemies.Contains( actor ) )
- {
- return true;
- }
- if ( GetAttitudeBetween( this, actor ) == AIA_Hostile )
- {
- if ( usePrecalcs )
- {
- distanceToTarget = Distance2DBetweenCapsuleAndPoint( actor, this ) - targetingPrecalcs.playerRadius;
- }
- else
- {
- distanceToTarget = Distance2DBetweenCapsules( this, actor );
- }
- if ( distanceToTarget < findMoveTargetDist + 5.0f )
- {
- return true;
- }
- if ( actor.IsInCombat() || this.IsHardLockEnabled() )
- {
- targetCapsuleHeight = ( (CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent() ).GetCapsuleHeight();
- if ( targetCapsuleHeight >= 2.0f || npc.GetCurrentStance() == NS_Fly )
- {
- if ( distanceToTarget < 40.0f )
- {
- return true;
- }
- }
- }
- }
- if ( actor.GetAttitudeGroup() == 'npc_charmed' )
- {
- if ( theGame.GetGlobalAttitude( GetBaseAttitudeGroup(), actor.GetBaseAttitudeGroup() ) == AIA_Hostile )
- {
- return true;
- }
- }
- return false;
- }
- function SetBIsCombatActionAllowed ( flag : bool )
- {
- bIsCombatActionAllowed = flag;
- if ( !flag )
- {
- SetBIsInCombatAction(true);
- }
- else
- {
- this.ProcessLAxisCaching();
- }
- }
- function GetBIsCombatActionAllowed() : bool
- {
- return bIsCombatActionAllowed;
- }
- function SetCombatAction( action : EBufferActionType )
- {
- currentCombatAction = action;
- }
- function GetCombatAction() : EBufferActionType
- {
- return currentCombatAction;
- }
- protected function WhenCombatActionIsFinished()
- {
- if(IsThrowingItem() || IsThrowingItemWithAim() )
- {
- if(inv.IsItemBomb(selectedItemId))
- {
- BombThrowAbort();
- }
- else
- {
- ThrowingAbort();
- }
- }
- if ( this.GetCurrentStateName() != 'DismountHorse' )
- OnRangedForceHolster( true );
- }
- public function IsInCombatAction_Attack(): bool
- {
- if ( IsInCombatAction_NonSpecialAttack() || IsInCombatAction_SpecialAttack() )
- return true;
- else
- return false;
- }
- public function IsInCombatAction_NonSpecialAttack(): bool
- {
- if ( IsInCombatAction() && ( GetCombatAction() == EBAT_LightAttack || GetCombatAction() == EBAT_HeavyAttack ) )
- return true;
- else
- return false;
- }
- public function IsInSpecificCombatAction ( specificCombatAction : EBufferActionType ) : bool
- {
- if ( IsInCombatAction() && GetCombatAction() == specificCombatAction )
- return true;
- else
- return false;
- }
- public function IsInRunAnimation() : bool
- {
- return isInRunAnimation;
- }
- public function SetCombatIdleStance( stance : float )
- {
- SetBehaviorVariable( 'combatIdleStance', stance );
- SetBehaviorVariable( 'CombatStanceForOverlay', stance );
- if ( stance == 0.f )
- LogChannel( 'ComboInput', "combatIdleStance = Left" );
- else
- LogChannel( 'ComboInput', "combatIdleStance = Right" );
- }
- public function GetCombatIdleStance() : float
- {
- return GetBehaviorVariable( 'combatIdleStance' );
- }
- protected var isRotatingInPlace : bool;
- event OnRotateInPlaceStart()
- {
- isRotatingInPlace = true;
- }
- event OnRotateInPlaceEnd()
- {
- isRotatingInPlace = false;
- }
- event OnFullyBlendedIdle()
- {
- if ( bLAxisReleased )
- {
- ResetRawPlayerHeading();
- ResetCachedRawPlayerHeading();
- defaultLocomotionController.ResetMoveDirection();
- }
- }
- private var isInIdle : bool;
- event OnPlayerIdleStart()
- {
- isInIdle = true;
- }
- event OnPlayerIdleEnd()
- {
- isInIdle = false;
- }
- public function IsInIdle() : bool
- {
- return isInIdle;
- }
- event OnRunLoopStart()
- {
- EnableRunCamera( true );
- }
- event OnRunLoopEnd()
- {
- EnableRunCamera( false );
- }
- event OnCombatActionStartBehgraph()
- {
- var action : EBufferActionType;
- var cost, delay : float;
- OnCombatActionStart();
- action = PerformingCombatAction();
- switch ( action )
- {
- case EBAT_LightAttack :
- {
- abilityManager.GetStaminaActionCost(ESAT_LightAttack, cost, delay);
- } break;
- case EBAT_HeavyAttack :
- {
- abilityManager.GetStaminaActionCost(ESAT_HeavyAttack, cost, delay);
- } break;
- case EBAT_ItemUse :
- {
- abilityManager.GetStaminaActionCost(ESAT_UsableItem, cost, delay);
- } break;
- case EBAT_Parry :
- {
- abilityManager.GetStaminaActionCost(ESAT_Parry, cost, delay);
- } break;
- case EBAT_Dodge :
- {
- abilityManager.GetStaminaActionCost(ESAT_Dodge, cost, delay);
- } break;
- case EBAT_Roll :
- abilityManager.GetStaminaActionCost(ESAT_Roll, cost, delay);
- break;
- case EBAT_SpecialAttack_Light :
- {
- abilityManager.GetStaminaActionCost(ESAT_Ability, cost, delay, 0,0, GetSkillAbilityName(S_Sword_s01));
- } break;
- case EBAT_SpecialAttack_Heavy :
- {
- abilityManager.GetStaminaActionCost(ESAT_Ability, cost, delay, 0,0, GetSkillAbilityName(S_Sword_s02));
- } break;
- case EBAT_Roll :
- {
- abilityManager.GetStaminaActionCost(ESAT_Evade, cost, delay);
- } break;
- default :
- ;
- }
- if( delay > 0 )
- PauseStaminaRegen( 'InsideCombatAction' );
- }
- public function HolsterUsableItem() : bool
- {
- return holsterUsableItem;
- }
- private var isInGuardedState : bool;
- public function IsInGuardedState() : bool
- {
- return isInGuardedState;
- }
- event OnGuardedStart()
- {
- isInParryOrCounter = true;
- isInGuardedState = true;
- }
- event OnGuardedEnd()
- {
- isInParryOrCounter = false;
- isInGuardedState = false;
- }
- private var restoreUsableItem : bool;
- private var holsterUsableItem : bool;
- event OnCombatActionStart()
- {
- BlockAction( EIAB_UsableItem, 'OnCombatActionStart' );
- BlockAction( EIAB_CallHorse, 'OnCombatActionStart' );
- LogChannel('combatActionAllowed',"FALSE OnCombatActionStart");
- SetBIsCombatActionAllowed( false );
- SetBIsInputAllowed( false, 'OnCombatActionStart' );
- ClearFinishableEnemyList( 0.f, 0 );
- bIsInHitAnim = false;
- if ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
- {
- CleanCombatActionBuffer();
- SetIsAimingCrossbow( false );
- OnRangedForceHolster( false, true );
- }
- holsterUsableItem = false;
- if ( thePlayer.IsHoldingItemInLHand() )
- {
- if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign )
- holsterUsableItem = true;
- else if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
- {
- if ( this.GetCurrentStateName() == 'CombatFists' )
- holsterUsableItem = true;
- }
- }
- if ( holsterUsableItem )
- {
- thePlayer.SetPlayerActionToRestore ( PATR_None );
- thePlayer.OnUseSelectedItem( true );
- restoreUsableItem = true;
- }
- if ( GetBehaviorVariable( 'combatActionType' ) != (int)CAT_Attack && GetBehaviorVariable( 'combatActionType' ) != (int)CAT_PreAttack )
- {
- RemoveTimer( 'ProcessAttackTimer' );
- RemoveTimer( 'AttackTimerEnd' );
- UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
- }
- else
- {
- BlockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
- }
- }
- var isInParryOrCounter : bool;
- event OnParryOrCounterStart()
- {
- isInParryOrCounter = true;
- OnCombatActionStartBehgraph();
- }
- event OnParryOrCounterEnd()
- {
- isInParryOrCounter = false;
- OnCombatActionEnd();
- SetBIsInCombatAction( false );
- }
- event OnCombatActionEnd()
- {
- var item : SItemUniqueId;
- var combatActionType : float;
- super.OnCombatActionEnd();
- BlockAllActions( 'OnCombatActionStart', false );
- UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
- UnblockAction( EIAB_Movement, 'CombatActionFriendly' );
- oTCameraOffset = 0.f;
- oTCameraPitchOffset = 0.f;
- SetBIsCombatActionAllowed( true );
- SetBIsInputAllowed( true, 'OnCombatActionEnd' );
- SetCanPlayHitAnim( true );
- EnableFindTarget( true );
- SetFinisherVictim( NULL );
- OnBlockAllCombatTickets( false );
- LogStamina("CombatActionEnd");
- SetAttackActionName('');
- combatActionType = GetBehaviorVariable('combatActionType');
- if(GetBehaviorVariable('combatActionType') == (int)CAT_SpecialAttack)
- {
- theGame.GetGameCamera().StopAnimation( 'camera_shake_loop_lvl1_1' );
- OnSpecialAttackHeavyActionProcess();
- }
- substateManager.ReactToChanceToFallAndSlide();
- }
- event OnCombatActionFriendlyStart()
- {
- SetBIsInCombatActionFriendly(true);
- BlockAction( EIAB_Movement, 'CombatActionFriendly', false, false, false );
- OnCombatActionStart();
- }
- event OnCombatActionFriendlyEnd()
- {
- SetBIsInCombatActionFriendly(false);
- UnblockAction( EIAB_Movement, 'CombatActionFriendly' );
- OnCombatActionEnd();
- SetBIsInCombatAction(false);
- }
- event OnHitStart()
- {
- var timeLeft : float;
- var currentEffects : array<CBaseGameplayEffect>;
- var none : SAbilityAttributeValue;
- CancelHoldAttacks();
- WhenCombatActionIsFinished();
- if ( isInFinisher )
- {
- if ( finisherTarget )
- ( (CNewNPC)finisherTarget ).SignalGameplayEvent( 'FinisherInterrupt' );
- isInFinisher = false;
- finisherTarget = NULL;
- SetBIsCombatActionAllowed( true );
- }
- bIsInHitAnim = true;
- OnCombatActionStart();
- ResumeStaminaRegen( 'InsideCombatAction' );
- if( GetHealthPercents() < 0.3f )
- {
- PlayBattleCry('BattleCryBadSituation', 0.10f, true );
- }
- else
- {
- PlayBattleCry('BattleCryBadSituation', 0.05f, true );
- }
- }
- event OnHitStartSwimming()
- {
- OnRangedForceHolster( true, true, false );
- }
- private var finisherSaveLock : int;
- event OnFinisherStart()
- {
- var currentEffects : array<CBaseGameplayEffect>;
- theGame.CreateNoSaveLock("Finisher",finisherSaveLock,true,false);
- isInFinisher = true;
- finisherTarget = slideTarget;
- OnCombatActionStart();
- CancelHoldAttacks();
- PlayFinisherCameraAnimation( theGame.GetSyncAnimManager().GetFinisherCameraAnimName() );
- this.AddAnimEventCallback('SyncEvent','OnFinisherAnimEvent_SyncEvent');
- SetImmortalityMode( AIM_Invulnerable, AIC_SyncedAnim );
- }
- public function IsPerformingFinisher() : bool
- {
- return isInFinisher;
- }
- private function PlayFinisherCameraAnimation( cameraAnimName : name )
- {
- var camera : CCustomCamera = theGame.GetGameCamera();
- var animation : SCameraAnimationDefinition;
- if( IsLastEnemyKilled() && theGame.GetWorld().NavigationCircleTest( this.GetWorldPosition(), 3.f ) )
- {
- camera.StopAnimation('camera_shake_hit_lvl3_1' );
- animation.animation = cameraAnimName;
- animation.priority = CAP_Highest;
- animation.blendIn = 0.15f;
- animation.blendOut = 1.0f;
- animation.weight = 1.f;
- animation.speed = 1.0f;
- animation.reset = true;
- camera.PlayAnimation( animation );
- thePlayer.EnableManualCameraControl( false, 'Finisher' );
- }
- }
- public function IsLastEnemyKilled() : bool
- {
- var tempMoveTargets : array<CActor>;
- FindMoveTarget();
- tempMoveTargets = GetMoveTargets();
- if ( tempMoveTargets.Size() <= 0 || !thePlayer.IsThreat( tempMoveTargets[0] ) )
- return true;
- return false;
- }
- event OnFinisherAnimEvent_SyncEvent( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
- {
- if ( finisherTarget )
- ( (CNewNPC)finisherTarget ).SignalGameplayEvent('FinisherKill');
- finisherTarget = NULL;
- }
- event OnFinisherEnd()
- {
- isInFinisher = false;
- finisherTarget = NULL;
- theGame.ReleaseNoSaveLock(finisherSaveLock);
- this.RemoveAnimEventCallback('SyncEvent');
- SetImmortalityMode( AIM_None, AIC_SyncedAnim );
- theGame.RemoveTimeScale( 'AnimEventSlomoMo' );
- AddTimer( 'FinisherEndEnableCamera', 0.5f );
- OnCombatActionEnd();
- OnCombatActionEndComplete();
- }
- private timer function FinisherEndEnableCamera( dt : float, id : int )
- {
- thePlayer.EnableManualCameraControl( true, 'Finisher' );
- }
- public function SpawnFinisherBlood()
- {
- var weaponEntity : CEntity;
- var weaponSlotMatrix : Matrix;
- var bloodFxPos : Vector;
- var bloodFxRot : EulerAngles;
- var tempEntity : CEntity;
- weaponEntity = this.GetInventory().GetItemEntityUnsafe( GetInventory().GetItemFromSlot('r_weapon') );
- weaponEntity.CalcEntitySlotMatrix( 'blood_fx_point', weaponSlotMatrix );
- bloodFxPos = MatrixGetTranslation( weaponSlotMatrix );
- bloodFxRot = this.GetWorldRotation();
- tempEntity = theGame.CreateEntity( (CEntityTemplate)LoadResource('finisher_blood'), bloodFxPos, bloodFxRot);
- tempEntity.PlayEffect('crawl_blood');
- }
- event OnCombatActionEndComplete()
- {
- var buff : CBaseGameplayEffect;
- buff = ChooseCurrentCriticalBuffForAnim();
- SetCombatAction( EBAT_EMPTY );
- UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart' );
- UnblockAction( EIAB_OpenInventory, 'OnCombatActionStart' );
- UnblockAction( EIAB_UsableItem, 'OnCombatActionStart' );
- UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
- SetUnpushableTarget( NULL );
- SetBIsInCombatAction(false);
- SetIsCurrentlyDodging(false);
- SetMoveTargetChangeAllowed( true );
- SetCanPlayHitAnim( true );
- SetFinisherVictim( NULL );
- this.RemoveBuffImmunity(EET_Burning, 'AnimEvent_RemoveBurning');
- if ( rangedWeapon && rangedWeapon.GetCurrentStateName() == 'State_WeaponWait' && !buff )
- {
- ClearCustomOrientationInfoStack();
- SetSlideTarget( NULL );
- }
- UnblockAction( EIAB_Crossbow, 'OnForceHolster' );
- specialAttackCamera = false;
- bIsRollAllowed = false;
- if ( bLAxisReleased )
- {
- ResetRawPlayerHeading();
- ResetCachedRawPlayerHeading();
- }
- ReapplyCriticalBuff();
- SetBIsInputAllowed( true, 'OnCombatActionEndComplete' );
- ResumeStaminaRegen( 'InsideCombatAction' );
- bIsInHitAnim = false;
- SetBIsCombatActionAllowed( true );
- m_LastWeaponTipPos = Vector(0, 0, 0, 0 );
- this.AddTimer('FreeTickets',3.f,false);
- }
- event OnMovementFullyBlended()
- {
- SetBehaviorVariable( 'isPerformingSpecialAttack', 0.f );
- if ( restoreUsableItem )
- {
- restoreUsableItem = false;
- SetPlayerActionToRestore ( PATR_Default );
- OnUseSelectedItem();
- }
- }
- event OnCombatMovementStart()
- {
- SetCombatIdleStance( 1.f );
- OnCombatActionEndComplete();
- }
- timer function FreeTickets( dt : float, id : int )
- {
- FreeTicketAtCombatTarget();
- }
- event OnGuardedReleased(){}
- event OnPerformAttack( playerAttackType : name ){}
- event OnPerformEvade( playerEvadeType : EPlayerEvadeType ){}
- event OnInterruptAttack(){}
- event OnPerformGuard(){}
- event OnSpawnHorse(){}
- event OnDismountActionScriptCallback(){}
- event OnHorseSummonStart()
- {
- thePlayer.BlockAction(EIAB_CallHorse, 'HorseSummon');
- thePlayer.BlockAction(EIAB_Signs, 'HorseSummon');
- thePlayer.BlockAction(EIAB_Crossbow, 'HorseSummon');
- thePlayer.BlockAction(EIAB_UsableItem, 'HorseSummon');
- thePlayer.BlockAction(EIAB_ThrowBomb, 'HorseSummon');
- thePlayer.BlockAction(EIAB_SwordAttack, 'HorseSummon');
- thePlayer.BlockAction(EIAB_Jump, 'HorseSummon');
- thePlayer.BlockAction(EIAB_Dodge, 'HorseSummon');
- thePlayer.BlockAction(EIAB_LightAttacks, 'HorseSummon');
- thePlayer.BlockAction(EIAB_HeavyAttacks, 'HorseSummon');
- thePlayer.BlockAction(EIAB_SpecialAttackLight, 'HorseSummon');
- thePlayer.BlockAction(EIAB_SpecialAttackHeavy, 'HorseSummon');
- horseSummonTimeStamp = theGame.GetEngineTimeAsSeconds();
- }
- event OnHorseSummonStop()
- {
- thePlayer.BlockAllActions('HorseSummon',false);
- }
- event OnCombatActionStartVehicle( action : EVehicleCombatAction )
- {
- this.SetBIsCombatActionAllowed( false );
- if ( action != EHCA_ShootCrossbow )
- {
- SetIsAimingCrossbow( false );
- OnRangedForceHolster();
- }
- }
- event OnCombatActionEndVehicle()
- {
- this.SetBIsCombatActionAllowed( true );
- }
- protected function CriticalBuffInformBehavior(buff : CBaseGameplayEffect)
- {
- if( !CanAnimationReactToCriticalState( buff ) )
- {
- return;
- }
- SetBehaviorVariable( 'CriticalStateType', (int)GetBuffCriticalType(buff) );
- SetBehaviorVariable( 'bCriticalState', 1);
- if(CriticalBuffUsesFullBodyAnim(buff))
- RaiseEvent('CriticalState');
- SetBehaviorVariable( 'IsInAir', (int)IsInAir());
- LogCritical("Sending player critical state event for <<" + buff.GetEffectType() + ">>");
- }
- private function CanAnimationReactToCriticalState( buff : CBaseGameplayEffect ) : bool
- {
- var buffCritical : W3CriticalEffect;
- var buffCriticalDOT : W3CriticalDOTEffect;
- var isHeavyCritical : bool;
- isHeavyCritical = false;
- buffCritical = ( W3CriticalEffect ) buff;
- if( buffCritical )
- {
- isHeavyCritical = buffCritical.explorationStateHandling == ECH_HandleNow;
- }
- else
- {
- buffCriticalDOT = ( W3CriticalDOTEffect ) buff;
- if( buffCriticalDOT )
- {
- isHeavyCritical = buffCriticalDOT.explorationStateHandling == ECH_HandleNow;
- }
- }
- if( !isHeavyCritical )
- {
- if( !CanReactToCriticalState() )
- {
- return false;
- }
- }
- return true;
- }
- public function CanReactToCriticalState() : bool
- {
- return substateManager.CanReactToHardCriticalState();
- }
- event OnCriticalStateAnimStart()
- {
- var heading : float;
- var newCritical : ECriticalStateType;
- var newReqCS : CBaseGameplayEffect;
- OnCombatActionEndComplete();
- newReqCS = newRequestedCS;
- if(super.OnCriticalStateAnimStart())
- {
- RemoveTimer( 'IsItemUseInputHeld' );
- keepRequestingCriticalAnimStart = false;
- CancelHoldAttacks();
- if(!IsUsingVehicle())
- {
- newCritical = GetBuffCriticalType(newReqCS);
- if(newCritical == ECST_HeavyKnockdown
- || newCritical == ECST_Knockdown
- || newCritical == ECST_Stagger
- || newCritical == ECST_Ragdoll
- || newCritical == ECST_LongStagger )
- {
- if(newReqCS.GetCreator())
- heading = VecHeading(newReqCS.GetCreator().GetWorldPosition() - GetWorldPosition());
- else
- heading = GetHeading();
- SetCustomRotation( 'Knockdown', heading, 2160.f, 0.1f, true );
- if ( newCritical != ECST_Stagger && newCritical != ECST_LongStagger )
- substateManager.ReactOnCriticalState( true );
- }
- }
- theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'CriticalEffectStart', -1, 30.0f, -1.f, -1, true );
- return true;
- }
- return false;
- }
- public function StartCSAnim(buff : CBaseGameplayEffect) : bool
- {
- SetBehaviorVariable( 'bCriticalStopped', 0 );
- if(super.StartCSAnim(buff))
- {
- if(!CriticalBuffUsesFullBodyAnim(buff))
- {
- OnCriticalStateAnimStart();
- }
- ResumeStaminaRegen( 'InsideCombatAction' );
- keepRequestingCriticalAnimStart = true;
- AddTimer('RequestCriticalAnimStart', 0, true);
- return true;
- }
- return false;
- }
- public function CriticalEffectAnimationInterrupted(reason : string) : bool
- {
- var ret : bool;
- LogCriticalPlayer("R4Player.CriticalEffectAnimationInterrupted() - because: " + reason);
- ret = super.CriticalEffectAnimationInterrupted(reason);
- if(ret)
- {
- keepRequestingCriticalAnimStart = false;
- }
- substateManager.ReactOnCriticalState( false );
- return ret;
- }
- public function CriticalStateAnimStopped(forceRemoveBuff : bool)
- {
- LogCriticalPlayer("R4Player.CriticalStateAnimStopped() - forced: " + forceRemoveBuff);
- theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'RecoveredFromCriticalEffect', -1, 30.0f, -1.f, -1, true );
- super.CriticalStateAnimStopped(forceRemoveBuff);
- substateManager.ReactOnCriticalState( false );
- }
- timer function RequestCriticalAnimStart(dt : float, id : int)
- {
- if(keepRequestingCriticalAnimStart)
- {
- if(newRequestedCS && newRequestedCS.GetDurationLeft() > 0)
- {
- CriticalBuffInformBehavior(newRequestedCS);
- }
- else
- {
- keepRequestingCriticalAnimStart = false;
- RemoveTimer('RequestCriticalAnimStart');
- }
- }
- else
- {
- RemoveTimer('RequestCriticalAnimStart');
- }
- }
- event OnRagdollUpdate(progress : float)
- {
- SetIsInAir(progress == 0);
- }
- event OnRagdollOnGround()
- {
- TryToEndRagdollOnGround( 0.0f );
- }
- event OnRagdollInAir()
- {
- RemoveTimer('TryToEndRagdollOnGround');
- }
- event OnNoLongerInRagdoll()
- {
- RemoveTimer('TryToEndRagdollOnGround');
- }
- timer function TryToEndRagdollOnGround( td : float, optional id : int)
- {
- var critical : CBaseGameplayEffect;
- var type : EEffectType;
- critical = GetCurrentlyAnimatedCS();
- if(critical)
- {
- type = critical.GetEffectType();
- if(type == EET_Knockdown || type == EET_HeavyKnockdown || type == EET_Ragdoll)
- {
- if (critical.GetTimeActive() >= 2.5f)
- {
- SetIsInAir(false);
- RequestCriticalAnimStop();
- RemoveTimer('TryToEndRagdollOnGround');
- }
- else
- {
- AddTimer('TryToEndRagdollOnGround', 0.2f, true);
- }
- return;
- }
- }
- RemoveTimer('TryToEndRagdollOnGround');
- }
- public function RequestCriticalAnimStop(optional dontSetCriticalToStopped : bool)
- {
- var buff : CBaseGameplayEffect;
- buff = GetCurrentlyAnimatedCS();
- if(buff && !CriticalBuffUsesFullBodyAnim(buff))
- {
- CriticalStateAnimStopped(false);
- }
- if(!buff || !CriticalBuffUsesFullBodyAnim(buff))
- {
- SetBehaviorVariable( 'bCriticalState', 0);
- }
- super.RequestCriticalAnimStop(dontSetCriticalToStopped);
- }
- public function SimulateBuffTimePassing(simulatedTime : float)
- {
- effectManager.SimulateBuffTimePassing(simulatedTime);
- }
- public function AddEffectDefault(effectType : EEffectType, creat : CGameplayEntity, srcName : string, optional isSignEffect : bool) : EEffectInteract
- {
- var params : SCustomEffectParams;
- if(effectType == EET_Stagger || effectType == EET_LongStagger || effectType == EET_Knockdown || effectType == EET_HeavyKnockdown)
- {
- params.effectType = effectType;
- params.creator = creat;
- params.sourceName = srcName;
- params.isSignEffect = isSignEffect;
- if ( effectType == EET_Stagger )
- params.duration = 1.83;
- else if ( effectType == EET_LongStagger )
- params.duration = 4;
- else if ( effectType == EET_Knockdown )
- params.duration = 2.5;
- else if ( effectType == EET_HeavyKnockdown )
- params.duration = 4;
- return super.AddEffectCustom(params);
- }
- else
- {
- return super.AddEffectDefault(effectType, creat, srcName, isSignEffect);
- }
- }
- public function CheatResurrect()
- {
- var items : array< SItemUniqueId >;
- var i, size, itemLevel, maxPrice, itemPrice : int;
- var itemToEquip : SItemUniqueId;
- if(IsAlive())
- return;
- if ( !theGame.GetGuiManager().GetRootMenu() )
- {
- Log(" *** Call this function after DeathScreen appears *** ");
- return;
- }
- SetAlive(true);
- SetKinematic(true);
- EnableFindTarget( true );
- SetBehaviorVariable( 'Ragdoll_Weight', 0.f );
- RaiseForceEvent( 'RecoverFromRagdoll' );
- SetCanPlayHitAnim( true );
- SetBehaviorVariable( 'CriticalStateType', (int)ECST_None );
- GoToStateIfNew('Exploration');
- ( (CDismembermentComponent)this.GetComponent( 'Dismemberment' ) ).ClearVisibleWound();
- SetIsInAir(false);
- theInput.SetContext('Exploration');
- ResetDeathType();
- ForceUnlockAllInputActions(false);
- theGame.CloseMenu('DeathScreenMenu');
- theSound.LeaveGameState(ESGS_Death);
- abilityManager.ForceSetStat(BCS_Vitality, GetStatMax(BCS_Vitality));
- effectManager.StopVitalityRegen();
- abilityManager.ForceSetStat( BCS_Air , 100.f );
- effectManager.StopAirRegen();
- abilityManager.ForceSetStat( BCS_Stamina , 100.f );
- effectManager.StopStaminaRegen();
- abilityManager.ForceSetStat( BCS_Toxicity , 0.f );
- abilityManager.ForceSetStat( BCS_Focus , 0.f );
- GetWitcherPlayer().UpdateEncumbrance();
- if ( !inv.IsThereItemOnSlot( EES_SteelSword ) )
- {
- items = inv.GetItemsByCategory( 'steelsword' );
- }
- else if ( !inv.IsThereItemOnSlot( EES_SilverSword ) )
- {
- items = inv.GetItemsByCategory( 'silversword' );
- }
- size = items.Size();
- maxPrice = -1;
- for ( i = 0; i < size; i += 1 )
- {
- itemPrice = inv.GetItemPrice(items[i]);
- itemLevel = inv.GetItemLevel(items[i]);
- if ( itemLevel <= GetLevel() && itemPrice > maxPrice )
- {
- maxPrice = itemPrice;
- itemToEquip = items[i];
- }
- }
- if( inv.IsIdValid( itemToEquip ) )
- {
- EquipItem( itemToEquip , , true );
- }
- theGame.ReleaseNoSaveLock(deathNoSaveLock);
- }
- public function SetIsInsideInteraction(b : bool) {isInsideInteraction = b;}
- public function IsInsideInteraction() : bool {return isInsideInteraction;}
- public function SetIsInsideHorseInteraction( b : bool, horse : CEntity )
- {
- isInsideHorseInteraction = b;
- horseInteractionSource = horse;
- }
- public function IsInsideHorseInteraction() : bool {return isInsideHorseInteraction;}
- event OnInteractionActivationTest( interactionComponentName : string, activator : CEntity )
- {
- if ( interactionComponentName == "ClimbLadder" )
- {
- if( PlayerHasLadderExplorationReady() )
- {
- return true;
- }
- }
- return false;
- }
- private function PlayerHasLadderExplorationReady() : bool
- {
- if( !substateManager.CanInteract() )
- {
- return false;
- }
- if( !substateManager.m_SharedDataO.HasValidLadderExploration() )
- {
- return false;
- }
- return true;
- }
- public function SetGuarded(flag : bool)
- {
- super.SetGuarded(flag);
- if(flag && FactsQuerySum("tut_fight_use_slomo") > 0)
- {
- theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
- FactsRemove("tut_fight_slomo_ON");
- }
- }
- public function IsGuarded() : bool
- {
- return super.IsGuarded() && ( !rangedWeapon || rangedWeapon.GetCurrentStateName() == 'State_WeaponWait' );
- }
- public function GetSelectedItemId() : SItemUniqueId {return selectedItemId;}
- public function ClearSelectedItemId() {selectedItemId = GetInvalidUniqueId();}
- public function IsHoldingItemInLHand() : bool
- {
- return currentlyEquipedItemL != GetInvalidUniqueId();
- }
- public function GetCurrentlyUsedItemL () : W3UsableItem
- {
- return currentlyUsedItemL;
- }
- public function SetPlayerActionToRestore ( actionToRestoreType : EPlayerActionToRestore )
- {
- playerActionToRestore = actionToRestoreType;
- }
- public function IsCurrentlyUsingItemL () : bool
- {
- return currentlyUsingItem;
- }
- function BlockSlotsOnLItemUse ()
- {
- var slotsToBlock : array<name>;
- slotsToBlock.PushBack( 'Slot1' );
- slotsToBlock.PushBack( 'Slot2' );
- slotsToBlock.PushBack( 'Slot3' );
- slotsToBlock.PushBack( 'Slot4' );
- slotsToBlock.PushBack( 'Slot5' );
- slotsToBlock.PushBack( 'Yrden' );
- slotsToBlock.PushBack( 'Quen' );
- slotsToBlock.PushBack( 'Igni' );
- slotsToBlock.PushBack( 'Axii' );
- slotsToBlock.PushBack( 'Aard' );
- EnableRadialSlotsWithSource ( false, slotsToBlock, 'usableItemL' );
- }
- function UnblockSlotsOnLItemUse ()
- {
- var slotsToBlock : array<name>;
- slotsToBlock.PushBack( 'Slot1' );
- slotsToBlock.PushBack( 'Slot2' );
- slotsToBlock.PushBack( 'Slot3' );
- slotsToBlock.PushBack( 'Slot4' );
- slotsToBlock.PushBack( 'Slot5' );
- slotsToBlock.PushBack( 'Yrden' );
- slotsToBlock.PushBack( 'Quen' );
- slotsToBlock.PushBack( 'Igni' );
- slotsToBlock.PushBack( 'Axii' );
- slotsToBlock.PushBack( 'Aard' );
- EnableRadialSlotsWithSource ( true, slotsToBlock, 'usableItemL' );
- }
- function IsUsableItemLBlocked () : bool
- {
- return isUsableItemBlocked;
- }
- function HideUsableItem( optional force : bool )
- {
- if( currentlyEquipedItemL != GetInvalidUniqueId() )
- {
- if( force )
- {
- if( !RaiseForceEvent( 'ItemEndL' ) )
- {
- OnUsingItemsReset();
- }
- return;
- }
- RaiseEvent( 'ItemUseL' );
- }
- }
- function ProcessUsableItemsTransition ( actionToRestore : EPlayerActionToRestore )
- {
- var category : name;
- var signSkill : ESkill;
- category = inv.GetItemCategory ( selectedItemId );
- signSkill = SignEnumToSkillEnum( GetEquippedSign());
- switch ( actionToRestore )
- {
- case PATR_None:
- if ( currentlyUsedItemL )
- {
- inv.UnmountItem( currentlyEquipedItemL, true );
- }
- currentlyEquipedItemL = GetInvalidUniqueId();
- return;
- case PATR_Default:
- if ( IsSlotQuickslot( inv.GetSlotForItemId ( selectedItemId )) && category == 'usable' && currentlyEquipedItemL != selectedItemId )
- {
- if ( currentlyUsedItemL )
- {
- inv.UnmountItem( currentlyEquipedItemL, true );
- }
- currentlyEquipedItemL = GetInvalidUniqueId();
- OnUseSelectedItem();
- return;
- }
- break;
- case PATR_Crossbow:
- if ( inv.IsItemCrossbow ( selectedItemId ) )
- {
- if ( currentlyUsedItemL )
- {
- inv.UnmountItem( currentlyEquipedItemL, true );
- }
- currentlyEquipedItemL = GetInvalidUniqueId();
- SetIsAimingCrossbow( true );
- if ( theInput.IsActionPressed( 'ThrowItem' ) )
- SetupCombatAction( EBAT_ItemUse, BS_Pressed );
- else
- {
- SetupCombatAction( EBAT_ItemUse, BS_Pressed );
- SetupCombatAction( EBAT_ItemUse, BS_Released );
- }
- return;
- }
- break;
- case PATR_CastSign:
- if( signSkill != S_SUndefined && playerActionToRestore == PATR_CastSign )
- {
- if ( currentlyUsedItemL )
- {
- inv.UnmountItem( currentlyEquipedItemL, true );
- }
- currentlyEquipedItemL = GetInvalidUniqueId();
- if( HasStaminaToUseSkill( signSkill, false ) )
- {
- if( GetInvalidUniqueId() != inv.GetItemFromSlot( 'l_weapon' ) )
- PushCombatActionOnBuffer( EBAT_CastSign, BS_Pressed );
- else
- SetupCombatAction( EBAT_CastSign, BS_Pressed );
- }
- else
- {
- thePlayer.SoundEvent("gui_no_stamina");
- }
- return;
- }
- break;
- case PATR_ThrowBomb:
- if ( inv.IsItemBomb ( selectedItemId ) )
- {
- if ( currentlyUsedItemL )
- {
- inv.UnmountItem( currentlyEquipedItemL, true );
- }
- currentlyEquipedItemL = GetInvalidUniqueId();
- PrepareToAttack();
- SetupCombatAction( EBAT_ItemUse, BS_Pressed );
- return;
- }
- break;
- case PATR_CallHorse:
- theGame.OnSpawnPlayerHorse();
- break;
- default:
- if ( currentlyUsedItemL )
- {
- inv.UnmountItem( currentlyEquipedItemL, true );
- }
- currentlyEquipedItemL = GetInvalidUniqueId();
- return;
- }
- if ( currentlyUsedItemL )
- {
- inv.UnmountItem( currentlyEquipedItemL, true );
- }
- currentlyEquipedItemL = GetInvalidUniqueId();
- }
- function GetUsableItemLtransitionAllowed () : bool
- {
- return isUsableItemLtransitionAllowed;
- }
- function SetUsableItemLtransitionAllowed ( isAllowed : bool)
- {
- isUsableItemLtransitionAllowed = isAllowed;
- }
- event OnItemUseLUnBlocked ()
- {
- if ( isUsableItemBlocked )
- {
- isUsableItemBlocked = false;
- UnblockSlotsOnLItemUse ();
- }
- }
- event OnItemUseLBlocked ()
- {
- if ( !isUsableItemBlocked )
- {
- isUsableItemBlocked = true;
- BlockSlotsOnLItemUse ();
- }
- }
- event OnUsingItemsReset()
- {
- if ( currentlyUsingItem )
- {
- OnItemUseLUnBlocked ();
- OnUsingItemsComplete();
- }
- }
- event OnUsingItemsComplete ()
- {
- if ( isUsableItemBlocked )
- {
- OnItemUseLUnBlocked ();
- }
- currentlyUsingItem = false;
- if ( GetUsableItemLtransitionAllowed () )
- {
- ProcessUsableItemsTransition( playerActionToRestore );
- }
- else
- {
- if ( currentlyUsedItemL )
- {
- inv.UnmountItem( currentlyEquipedItemL, true );
- }
- currentlyEquipedItemL = GetInvalidUniqueId();
- }
- SetPlayerActionToRestore ( PATR_Default );
- }
- event OnUseSelectedItem( optional force : bool )
- {
- var category : name;
- var itemEntity : W3UsableItem;
- if ( isUsableItemBlocked && !force )
- {
- return false;
- }
- if ( IsCastingSign() )
- return false;
- if ( currentlyEquipedItemL != GetInvalidUniqueId() )
- {
- SetBehaviorVariable( 'SelectedItemL', (int)GetUsableItemTypeById( currentlyEquipedItemL ), true );
- if ( force )
- {
- if ( RaiseEvent( 'ItemEndL' ) )
- {
- SetUsableItemLtransitionAllowed ( true );
- return true;
- }
- }
- else
- {
- if ( RaiseEvent( 'ItemUseL' ) )
- {
- SetUsableItemLtransitionAllowed ( true );
- return true;
- }
- }
- }
- else
- {
- category = inv.GetItemCategory( selectedItemId );
- if( category != 'usable' )
- {
- return false;
- }
- SetBehaviorVariable( 'SelectedItemL', (int)GetUsableItemTypeById( selectedItemId ), true );
- if( RaiseEvent( 'ItemUseL' ) )
- {
- currentlyEquipedItemL = selectedItemId;
- SetUsableItemLtransitionAllowed ( false );
- currentlyUsingItem = true;
- return true;
- }
- inv.UnmountItem( selectedItemId, true );
- }
- }
- protected saved var currentlyUsingItem : bool;
- public function ProcessUseSelectedItem( itemEntity : W3UsableItem, optional shouldCallOnUsed : bool )
- {
- currentlyUsedItemL = itemEntity;
- DrainStamina(ESAT_UsableItem);
- if ( shouldCallOnUsed )
- {
- currentlyUsedItemL.OnUsed( thePlayer );
- }
- }
- function GetUsableItemTypeById ( itemId : SItemUniqueId ) : EUsableItemType
- {
- var itemName : name;
- itemName = inv.GetItemName ( itemId );
- return theGame.GetDefinitionsManager().GetUsableItemType ( itemName );
- }
- public function StartWaitForItemSpawnAndProccesTask()
- {
- AddTimer( 'WaitForItemSpawnAndProccesTask', 0.001f, true,,,,true );
- }
- public function KillWaitForItemSpawnAndProccesTask()
- {
- RemoveTimer ( 'WaitForItemSpawnAndProccesTask' );
- }
- public function AllowUseSelectedItem()
- {
- m_useSelectedItemIfSpawned = true;
- }
- timer function WaitForItemSpawnAndProccesTask( timeDelta : float , id : int )
- {
- var itemEntity : W3UsableItem;
- var canTaskBeKilled : bool;
- canTaskBeKilled = false;
- if ( IsCastingSign() )
- {
- return;
- }
- if ( selectedItemId == GetInvalidUniqueId() )
- {
- canTaskBeKilled = true;
- }
- itemEntity = (W3UsableItem)inv.GetItemEntityUnsafe( selectedItemId );
- if ( itemEntity && m_useSelectedItemIfSpawned )
- {
- canTaskBeKilled = true;
- m_useSelectedItemIfSpawned = false;
- ProcessUseSelectedItem( itemEntity, true );
- }
- if ( canTaskBeKilled )
- {
- KillWaitForItemSpawnAndProccesTask();
- }
- }
- event OnBombProjectileReleased()
- {
- ResetRawPlayerHeading();
- UnblockAction(EIAB_ThrowBomb, 'BombThrow');
- UnblockAction(EIAB_Crossbow, 'BombThrow');
- if(GetCurrentStateName() == 'AimThrow')
- PopState();
- FactsAdd("ach_bomb", 1, 4 );
- theGame.GetGamerProfile().CheckLearningTheRopes();
- }
- public function SetIsThrowingItemWithAim(b : bool)
- {
- isThrowingItemWithAim = b;
- }
- public function SetIsThrowingItem( flag : bool ) {isThrowingItem = flag;}
- public function IsThrowingItem() : bool {return isThrowingItem;}
- public function IsThrowingItemWithAim() : bool {return isThrowingItemWithAim;}
- public function SetThrowHold(b : bool) {isThrowHoldPressed = b;}
- public function IsThrowHold() : bool {return isThrowHoldPressed;}
- public function SetIsAimingCrossbow( flag : bool ) {isAimingCrossbow = flag;}
- public function GetIsAimingCrossbow() : bool {return isAimingCrossbow;}
- event OnThrowAnimLeave()
- {
- var throwStage : EThrowStage;
- var thrownEntity : CThrowable;
- thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
- if(thrownEntity && !thrownEntity.WasThrown())
- {
- throwStage = (int)GetBehaviorVariable( 'throwStage', (int)TS_Stop);
- if(inv.IsItemBomb(selectedItemId))
- {
- BombThrowCleanUp();
- }
- else
- {
- ThrowingAbort();
- }
- }
- thrownEntity = NULL;
- SetIsThrowingItem( false );
- SetIsThrowingItemWithAim( false );
- this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
- UnblockAction(EIAB_ThrowBomb, 'BombThrow');
- UnblockAction(EIAB_Crossbow, 'BombThrow');
- }
- protected function BombThrowStart()
- {
- var slideTargetActor : CActor;
- BlockAction( EIAB_ThrowBomb, 'BombThrow' );
- BlockAction(EIAB_Crossbow, 'BombThrow');
- SetBehaviorVariable( 'throwStage', (int)TS_Start );
- SetBehaviorVariable( 'combatActionType', (int)CAT_ItemThrow );
- if ( slideTarget )
- {
- AddCustomOrientationTarget( OT_Actor, 'BombThrow' );
- slideTargetActor = (CActor)( slideTarget );
- }
- else
- {
- if ( lastAxisInputIsMovement )
- AddCustomOrientationTarget( OT_Actor, 'BombThrow' );
- else
- AddCustomOrientationTarget( OT_Camera, 'BombThrow' );
- }
- UpdateLookAtTarget();
- SetCustomRotation( 'Throw', VecHeading( this.GetLookAtPosition() - GetWorldPosition() ), 0.0f, 0.3f, false );
- SetBehaviorVariable( 'itemType', (int)IT_Petard );
- ProcessCanAttackWhenNotInCombatBomb();
- if ( RaiseForceEvent('CombatAction') )
- OnCombatActionStart();
- theTelemetry.LogWithLabel(TE_FIGHT_HERO_THROWS_BOMB, inv.GetItemName( selectedItemId ));
- }
- event OnThrowAnimStart()
- {
- var itemId : SItemUniqueId;
- var thrownEntity : CThrowable;
- this.radialSlots.Clear();
- GetWitcherPlayer().GetItemEquippedOnSlot(EES_Petard1, itemId );
- if( GetSelectedItemId() == itemId )
- {
- this.radialSlots.PushBack( 'Slot2' );
- }
- else
- {
- this.radialSlots.PushBack( 'Slot1' );
- }
- this.radialSlots.PushBack( 'Slot3' );
- this.radialSlots.PushBack( 'Slot4' );
- this.radialSlots.PushBack( 'Slot5' );
- this.EnableRadialSlotsWithSource( false, this.radialSlots, 'throwBomb' );
- thrownEntity = (CThrowable)inv.GetDeploymentItemEntity( selectedItemId,,,true );
- thrownEntity.Initialize( this, selectedItemId );
- EntityHandleSet( thrownEntityHandle, thrownEntity );
- SetIsThrowingItem( true );
- }
- public function BombThrowAbort()
- {
- BombThrowCleanUp();
- UnblockAction( EIAB_ThrowBomb, 'BombThrow' );
- UnblockAction(EIAB_Crossbow, 'BombThrow');
- }
- private function BombThrowCleanUp()
- {
- var throwStage : EThrowStage;
- var thrownEntity : CThrowable;
- var vehicle : CVehicleComponent;
- thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
- this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
- throwStage = (int)GetBehaviorVariable( 'throwStage', (int)TS_Stop);
- SetBehaviorVariable( 'throwStage', (int)TS_Stop );
- if( GetCurrentStateName() == 'AimThrow')
- {
- PopState();
- thrownEntity.StopAiming( true );
- }
- else if ( this.IsUsingHorse() )
- {
- vehicle = (CVehicleComponent)(GetUsedVehicle().GetComponentByClassName('CVehicleComponent'));
- vehicle.GetUserCombatManager().OnForceItemActionAbort();
- }
- if(thrownEntity && !thrownEntity.WasThrown())
- {
- thrownEntity.BreakAttachment();
- thrownEntity.Destroy();
- }
- thrownEntity = NULL;
- SetIsThrowingItem( false );
- SetIsThrowingItemWithAim( false );
- RemoveCustomOrientationTarget( 'BombThrow' );
- }
- public function ProcessCanAttackWhenNotInCombatBomb()
- {
- var targets : array< CGameplayEntity >;
- var temp, throwVector, throwFrom, throwTo, throwVectorU : Vector;
- var temp_n : name;
- var throwVecLen : float;
- var component : CComponent;
- if( FactsQuerySum( "BombThrowSpecificTargets" ) > 0 )
- {
- throwFrom = playerAiming.GetThrowStartPosition();
- throwTo = playerAiming.GetThrowPosition();
- throwVector = throwTo - throwFrom;
- throwVecLen = VecDistance( throwFrom, throwTo );
- throwVectorU = throwVector / throwVecLen;
- if( theGame.GetWorld().StaticTraceWithAdditionalInfo( throwFrom, throwTo + throwVectorU, temp, temp, temp_n, component ) && component && component.GetEntity().HasTag( 'BombThrowSpecificTarget' ) )
- {
- SetIsShootingFriendly( false );
- }
- else
- {
- SetIsShootingFriendly( true );
- }
- }
- else if( FactsQuerySum( "BombThrowDisallowSpecificTargets" ) > 0 )
- {
- throwFrom = playerAiming.GetThrowStartPosition();
- throwTo = playerAiming.GetThrowPosition();
- throwVector = throwTo - throwFrom;
- throwVecLen = VecDistance( throwFrom, throwTo );
- throwVectorU = throwVector / throwVecLen;
- if( theGame.GetWorld().StaticTraceWithAdditionalInfo( throwFrom, throwTo + throwVectorU, temp, temp, temp_n, component ) && component && component.GetEntity().HasTag( 'BombThrowDisallowedTarget' ) )
- {
- SetIsShootingFriendly( true );
- }
- else
- {
- SetIsShootingFriendly( false );
- }
- }
- else
- {
- SetIsShootingFriendly( false );
- }
- SetBehaviorVariable( 'isShootingFriendly', (float)( GetIsShootingFriendly() ) );
- }
- public function SetIsShootingFriendly( flag : bool )
- {
- isShootingFriendly = flag;
- }
- public function GetIsShootingFriendly() : bool
- {
- return isShootingFriendly;
- }
- protected function UsableItemStart()
- {
- var thrownEntity : CThrowable;
- thrownEntity = (CThrowable)inv.GetDeploymentItemEntity( selectedItemId,,,true );
- thrownEntity.Initialize( this, selectedItemId );
- EntityHandleSet( thrownEntityHandle, thrownEntity );
- SetBehaviorVariable( 'throwStage', (int)TS_Start );
- SetIsThrowingItem( true );
- SetBehaviorVariable( 'combatActionType', (int)CAT_ItemThrow );
- if ( slideTarget )
- {
- AddCustomOrientationTarget( OT_Actor, 'UsableItems' );
- }
- else
- {
- if ( lastAxisInputIsMovement )
- AddCustomOrientationTarget( OT_Actor, 'UsableItems' );
- else
- AddCustomOrientationTarget( OT_Camera, 'UsableItems' );
- }
- SetBehaviorVariable( 'itemType', (int)(-1) );
- if ( RaiseForceEvent('CombatAction') )
- OnCombatActionStart();
- }
- protected function BombThrowRelease()
- {
- var stateName : name;
- stateName = playerAiming.GetCurrentStateName();
- OnDelayOrientationChangeOff();
- if( GetIsShootingFriendly() || ( FactsQuerySum( "BombThrowSpecificTargets" ) > 0 && stateName != 'Aiming' ) )
- {
- BombThrowAbort();
- }
- else
- {
- SetBehaviorVariable( 'throwStage', (int)TS_End );
- if ( stateName == 'Aiming' )
- {
- SetCustomRotation( 'Throw', VecHeading( this.GetLookAtPosition() - GetWorldPosition() ), 0.0f, 0.2f, false );
- }
- }
- }
- protected function UsableItemRelease()
- {
- OnDelayOrientationChangeOff();
- SetBehaviorVariable( 'throwStage', (int)TS_End );
- RemoveCustomOrientationTarget( 'UsableItems' );
- }
- public function ThrowingAbort()
- {
- var thrownEntity : CThrowable;
- thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
- SetBehaviorVariable( 'throwStage', (int)TS_Stop );
- RaiseEvent( 'actionStop' );
- if( GetCurrentStateName() == 'AimThrow')
- {
- PopState();
- thrownEntity.StopAiming( true );
- }
- if(thrownEntity && !thrownEntity.WasThrown())
- {
- thrownEntity.BreakAttachment();
- thrownEntity.Destroy();
- }
- this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
- }
- public function CanSetupCombatAction_Throw() : bool
- {
- if(!inv.IsIdValid( selectedItemId ))
- return false;
- if(!inv.IsItemSingletonItem(selectedItemId))
- return false;
- if(!GetBIsInputAllowed())
- return false;
- if(inv.GetItemQuantity(GetSelectedItemId()) <= 0 && !inv.ItemHasTag(selectedItemId, theGame.params.TAG_INFINITE_AMMO))
- return false;
- if(!inputHandler.IsActionAllowed(EIAB_ThrowBomb) && GetCurrentStateName() != 'Swimming')
- return false;
- return true;
- }
- public function GetThrownEntity() : CThrowable
- {
- return (CThrowable)EntityHandleGet( thrownEntityHandle );
- }
- event OnWeaponWait() { rangedWeapon.OnWeaponWait(); }
- event OnWeaponDrawStart() { rangedWeapon.OnWeaponDrawStart(); }
- event OnWeaponReloadStart() { rangedWeapon.OnWeaponReloadStart(); }
- event OnWeaponReloadEnd() { rangedWeapon.OnWeaponReloadEnd(); }
- event OnWeaponAimStart() { rangedWeapon.OnWeaponAimStart(); }
- event OnWeaponShootStart() { rangedWeapon.OnWeaponShootStart(); }
- event OnWeaponShootEnd() { rangedWeapon.OnWeaponShootEnd(); }
- event OnWeaponAimEnd() { rangedWeapon.OnWeaponAimEnd(); }
- event OnWeaponHolsterStart() { rangedWeapon.OnWeaponHolsterStart(); }
- event OnWeaponHolsterEnd() { rangedWeapon.OnWeaponHolsterEnd(); }
- event OnWeaponToNormalTransStart() { rangedWeapon.OnWeaponToNormalTransStart(); }
- event OnWeaponToNormalTransEnd() { rangedWeapon.OnWeaponToNormalTransEnd(); }
- event OnEnableAimingMode( enable : bool )
- {
- if( !crossbowDontPopStateHack )
- {
- if ( enable )
- PushState( 'AimThrow' );
- else if ( GetCurrentStateName() == 'AimThrow' )
- PopState();
- }
- }
- event OnRangedForceHolster( optional forceUpperBodyAnim, instant, dropItem : bool )
- {
- if(rangedWeapon)
- rangedWeapon.OnForceHolster( forceUpperBodyAnim, instant, dropItem );
- }
- public function IsCrossbowHeld() : bool
- {
- if (rangedWeapon)
- return rangedWeapon.GetCurrentStateName() != 'State_WeaponWait';
- return false;
- }
- event OnBlockAllCombatTickets( release : bool )
- {
- if (!release )
- ((CR4PlayerStateCombat)GetState('Combat')).OnBlockAllCombatTickets(false);
- }
- event OnForceTicketUpdate() {}
- event OnProcessActionPost(action : W3DamageAction)
- {
- var npc : CNewNPC;
- var attackAction : W3Action_Attack;
- var lifeLeech : float;
- super.OnProcessActionPost(action);
- attackAction = (W3Action_Attack)action;
- if(attackAction)
- {
- npc = (CNewNPC)action.victim;
- if(npc && npc.IsHuman() )
- {
- PlayBattleCry('BattleCryHumansHit', 0.05f );
- }
- else
- {
- PlayBattleCry('BattleCryMonstersHit', 0.05f );
- }
- if(attackAction.IsActionMelee())
- {
- IncreaseUninterruptedHitsCount();
- if( IsLightAttack( attackAction.GetAttackName() ) )
- {
- GCameraShake(0.1, false, GetWorldPosition(), 10);
- }
- if(npc && inv.GetItemName(attackAction.GetWeaponId()) == 'PC Caretaker Shovel')
- {
- lifeLeech = CalculateAttributeValue(inv.GetItemAttributeValue(attackAction.GetWeaponId() ,'lifesteal'));
- if (npc.UsesVitality())
- lifeLeech *= action.processedDmg.vitalityDamage;
- else if (UsesEssence())
- lifeLeech *= action.processedDmg.essenceDamage;
- else
- lifeLeech = 0;
- if ( lifeLeech > 0 )
- {
- inv.PlayItemEffect( attackAction.GetWeaponId(), 'stab_attack' );
- PlayEffect('drain_energy_caretaker_shovel');
- GainStat(BCS_Vitality, lifeLeech);
- }
- }
- }
- }
- }
- public function SetHitReactTransScale(f : float) {hitReactTransScale = f;}
- public function GetHitReactTransScale() : float
- {
- if ( ( (CNewNPC)slideTarget ).GetIsTranslationScaled() )
- return hitReactTransScale;
- else
- return 1.f;
- }
- public function GetHorseWithInventory() : CNewNPC
- {
- return (CNewNPC)EntityHandleGet( horseWithInventory );
- }
- public function GetHorseCurrentlyMounted() : CNewNPC
- {
- return currentlyMountedHorse;
- }
- public function _SetHorseCurrentlyMounted( horse : CNewNPC )
- {
- currentlyMountedHorse = horse;
- }
- public function WasHorseRecentlySummoned() : bool
- {
- if ( horseSummonTimeStamp + 5.f > theGame.GetEngineTimeAsSeconds() )
- return true;
- return false;
- }
- private const var MOUNT_DISTANCE_CBT : float;
- default MOUNT_DISTANCE_CBT = 3.0;
- private const var MOUNT_ANGLE_CBT : float;
- default MOUNT_ANGLE_CBT = 35.0;
- private const var MOUNT_ANGLE_EXP : float;
- default MOUNT_ANGLE_EXP = 45.0;
- public function IsMountingHorseAllowed( optional alwaysAllowedInExploration : bool ) : bool
- {
- var angle : float;
- var distance : float;
- if( IsInsideHorseInteraction() )
- {
- angle = AngleDistance( thePlayer.rawPlayerHeading, VecHeading( thePlayer.horseInteractionSource.GetWorldPosition() - thePlayer.GetWorldPosition() ) );
- if( thePlayer.IsInCombat() )
- {
- if( AbsF( angle ) < MOUNT_ANGLE_CBT )
- {
- distance = VecDistance( thePlayer.GetWorldPosition(), thePlayer.horseInteractionSource.GetWorldPosition() );
- if( distance < MOUNT_DISTANCE_CBT )
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- }
- else
- {
- if( alwaysAllowedInExploration )
- {
- return true;
- }
- else
- {
- if( AbsF( angle ) < MOUNT_ANGLE_EXP )
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
- else
- {
- return false;
- }
- }
- public function FollowActor( actor : CActor )
- {
- var l_aiTreeDecorator : CAIPlayerActionDecorator;
- var l_aiTree_onFoot : CAIFollowSideBySideAction;
- var l_aiTree_onHorse : CAIRiderFollowSideBySideAction;
- var l_success : bool = false;
- actor.AddTag( 'playerFollowing' );
- if( thePlayer.IsUsingHorse() )
- {
- l_aiTree_onHorse = new CAIRiderFollowSideBySideAction in this;
- l_aiTree_onHorse.OnCreated();
- l_aiTree_onHorse.params.targetTag = 'playerFollowing';
- }
- else
- {
- l_aiTree_onFoot = new CAIFollowSideBySideAction in this;
- l_aiTree_onFoot.OnCreated();
- l_aiTree_onFoot.params.targetTag = 'playerFollowing';
- }
- l_aiTreeDecorator = new CAIPlayerActionDecorator in this;
- l_aiTreeDecorator.OnCreated();
- l_aiTreeDecorator.interruptOnInput = false;
- if( thePlayer.IsUsingHorse() )
- l_aiTreeDecorator.scriptedAction = l_aiTree_onHorse;
- else
- l_aiTreeDecorator.scriptedAction = l_aiTree_onFoot;
- if( l_aiTreeDecorator )
- l_success = ForceAIBehavior( l_aiTreeDecorator, BTAP_Emergency );
- else if( thePlayer.IsUsingHorse() )
- l_success = ForceAIBehavior( l_aiTree_onHorse, BTAP_Emergency );
- else
- l_success = ForceAIBehavior( l_aiTree_onFoot, BTAP_Emergency );
- if ( l_success )
- {
- GetMovingAgentComponent().SetGameplayRelativeMoveSpeed( 0.0f );
- }
- }
- public function SetCanFollowNpc( val : bool, actor : CActor ) { canFollowNpc = val; actorToFollow = actor; }
- public function CanFollowNpc() : bool { return canFollowNpc; }
- public function GetActorToFollow() : CActor { return actorToFollow; }
- public function SetIsSwimming ( toggle : bool )
- {
- if( isSwimming != toggle )
- {
- thePlayer.substateManager.SetBehaviorParamBool( 'isSwimmingForOverlay', toggle );
- isSwimming = toggle;
- }
- }
- public function RepairItemUsingConsumable(item, consumable : SItemUniqueId) : bool
- {
- var curr, max, repairValue, itemValue, repairBonus, newDurability : float;
- if(!inv.IsIdValid(item) || !inv.IsIdValid(consumable) || !inv.HasItemDurability(item))
- return false;
- curr = inv.GetItemDurability(item);
- max = inv.GetItemMaxDurability(item);
- if(curr > max)
- return false;
- if( (inv.IsItemAnyArmor(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_ARMOR)) ||
- (inv.IsItemSilverSwordUsableByPlayer(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_SILVER)) ||
- (inv.IsItemSteelSwordUsableByPlayer(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_STEEL)) )
- {
- itemValue = CalculateAttributeValue(inv.GetItemAttributeValue(consumable, 'durabilityRepairValue'));
- if(itemValue <= 0)
- {
- LogAssert(false, "CR4Player.RepairItemUsingConsumable: consumable <<" + inv.GetItemName(consumable) + ">> has <=0 durabilityRepairValue!!!");
- return false;
- }
- repairBonus = CalculateAttributeValue(inv.GetItemAttributeValue(consumable, 'durabilityBonusValue'));
- repairValue = max * itemValue /100;
- newDurability = MinF(max, curr + repairValue);
- inv.SetItemDurabilityScript(item, newDurability);
- inv.RemoveItem(consumable);
- return true;
- }
- return false;
- }
- private function CheckDayNightCycle()
- {
- var time : GameTime;
- var isNight : bool;
- isNight = theGame.envMgr.IsNight();
- if(prevDayNightIsNight != isNight)
- {
- if(isNight)
- OnNightStarted();
- else
- OnDayStarted();
- prevDayNightIsNight = isNight;
- }
- if(isNight)
- time = theGame.envMgr.GetGameTimeTillNextDay();
- else
- time = theGame.envMgr.GetGameTimeTillNextNight();
- AddGameTimeTimer('DayNightCycle', time);
- }
- timer function DayNightCycle(dt : GameTime, id : int)
- {
- CheckDayNightCycle();
- }
- event OnNightStarted()
- {
- var pam : W3PlayerAbilityManager;
- if(CanUseSkill(S_Perk_01))
- {
- pam = (W3PlayerAbilityManager)abilityManager;
- pam.SetPerk01Abilities(false, true);
- }
- }
- event OnDayStarted()
- {
- var pam : W3PlayerAbilityManager;
- if(CanUseSkill(S_Perk_01))
- {
- pam = (W3PlayerAbilityManager)abilityManager;
- pam.SetPerk01Abilities(true, false);
- }
- }
- public function ForceUnlockAllInputActions(alsoQuestLocks : bool)
- {
- if ( inputHandler )
- inputHandler.ForceUnlockAllInputActions(alsoQuestLocks);
- }
- public function SetPrevRawLeftJoyRot()
- {
- prevRawLeftJoyRot = rawLeftJoyRot;
- }
- public function GetPrevRawLeftJoyRot() : float
- {
- return prevRawLeftJoyRot;
- }
- public function GetExplorationInputContext() : name
- {
- return explorationInputContext;
- }
- public function GetCombatInputContext() : name
- {
- return combatInputContext;
- }
- public function SetIsOnBoat(b : bool)
- {
- isOnBoat = b;
- }
- public function IsOnBoat() : bool
- {
- return isOnBoat;
- }
- public function IsInShallowWater() : bool
- {
- return isInShallowWater;
- }
- event OnEnterShallowWater()
- {
- if ( isInShallowWater )
- return false;
- isInShallowWater = true;
- BlockAction( EIAB_Dodge,'ShallowWater', false, false, true );
- BlockAction( EIAB_Sprint,'ShallowWater', false, false, true );
- BlockAction( EIAB_Crossbow,'ShallowWater', false, false, true );
- BlockAction( EIAB_Jump,'ShallowWater', false, false, true );
- SetBehaviorVariable( 'shallowWater',1.0);
- }
- event OnExitShallowWater()
- {
- if ( !isInShallowWater )
- return false;
- isInShallowWater = false;
- BlockAllActions('ShallowWater',false);
- SetBehaviorVariable( 'shallowWater',0.0);
- }
- public function TestIsInSettlement() : bool
- {
- return IsInSettlement();
- }
- public function ProcessGlossaryImageOverride( defaultImage : string, uniqueTag : name ) : string
- {
- var size : int;
- var i : int;
- size = glossaryImageOverride.Size();
- if( size == 0 )
- return defaultImage;
- for( i = 0; i < size; i += 1 )
- {
- if( glossaryImageOverride[i].uniqueTag == uniqueTag )
- return glossaryImageOverride[i].imageFileName;
- }
- return defaultImage;
- }
- public function EnableGlossaryImageOverride( uniqueTag : name, imageFileName : string, enable : bool )
- {
- var imageData : SGlossaryImageOverride;
- var size : int;
- var i : int;
- for( i = 0; i < glossaryImageOverride.Size(); i += 1 )
- {
- if( glossaryImageOverride[i].uniqueTag == uniqueTag )
- {
- glossaryImageOverride.Remove(glossaryImageOverride[i]);
- }
- }
- if( enable )
- {
- if( IsNameValid(uniqueTag) && imageFileName != "" )
- {
- glossaryImageOverride.PushBack( SGlossaryImageOverride( uniqueTag, imageFileName ) );
- }
- }
- }
- public function SetWeatherDisplayDisabled( disable : bool )
- {
- disableWeatherDisplay = disable;
- }
- public function GetWeatherDisplayDisabled() : bool
- {
- return disableWeatherDisplay;
- }
- public function SetCurrentMonsterHuntInvestigationArea ( area : W3MonsterHuntInvestigationArea )
- {
- currentMonsterHuntInvestigationArea = area;
- }
- public function RememberCustomHead( headName : name )
- {
- rememberedCustomHead = headName;
- }
- public function GetRememberedCustomHead() : name
- {
- return rememberedCustomHead;
- }
- public function ClearRememberedCustomHead()
- {
- rememberedCustomHead = '';
- }
- public function CreateTutorialInput()
- {
- var prevInputHandler : CPlayerInput;
- prevInputHandler = inputHandler;
- inputHandler = new W3PlayerTutorialInput in this;
- inputHandler.Initialize(false, prevInputHandler);
- if(prevInputHandler)
- delete prevInputHandler;
- }
- public function CreateInput()
- {
- var oldInputHandler : CPlayerInput;
- oldInputHandler = inputHandler;
- inputHandler = new CPlayerInput in this;
- inputHandler.Initialize(false, oldInputHandler);
- }
- timer function TutorialSilverCombat(dt : float, id : int)
- {
- var i : int;
- var actors : array<CActor>;
- if(IsInCombat())
- {
- actors = GetNPCsAndPlayersInRange(20, 1000000, ,FLAG_ExcludePlayer + FLAG_OnlyAliveActors);
- for(i=0; i<actors.Size(); i+=1)
- {
- if(actors[i] && IsRequiredAttitudeBetween(this, actors[i], true) && actors[i].UsesEssence())
- {
- FactsAdd("TutorialShowSilver");
- RemoveTimer('TutorialSilverCombat');
- break;
- }
- }
- }
- }
- private saved var m_bossTag : name;
- public function GetBossTag() : name
- {
- return m_bossTag;
- }
- public function SetBossTag( bossTag : name )
- {
- m_bossTag = bossTag;
- }
- private saved var m_usingCoatOfArms : bool; default m_usingCoatOfArms = false;
- public function IsUsingCoatOfArms() : bool
- {
- return m_usingCoatOfArms;
- }
- public function SetUsingCoatOfArms( using : bool)
- {
- m_usingCoatOfArms = using;
- }
- private saved var m_initialTimeOut : float;
- private saved var m_currentTimeOut : float;
- public function GetInitialTimeOut() : float
- {
- return m_initialTimeOut;
- }
- public function SetInitialTimeOut( timeOut : float )
- {
- m_initialTimeOut = timeOut;
- }
- public function GetCurrentTimeOut() : float
- {
- return m_currentTimeOut;
- }
- public function SetCurrentTimeOut( timeOut : float )
- {
- m_currentTimeOut = timeOut;
- }
- timer function DelayedFinisherInputTimer(dt : float, id : int)
- {
- }
- timer function RemoveFinisherCameraAnimationCheck(dt : float, id : int)
- {
- if ( !isInFinisher && !bLAxisReleased )
- {
- theGame.GetSyncAnimManager().OnRemoveFinisherCameraAnimation();
- RemoveTimer( 'RemoveFinisherCameraAnimationCheck' );
- }
- }
- timer function GameplayFactRemove(dt : float, timerId : int)
- {
- theGame.GameplayFactRemoveFromTimer(timerId);
- }
- timer function GiveStartingItems(dt : float, timerId : int)
- {
- var template : CEntityTemplate;
- var invEntity : CInventoryComponent;
- var entity : CEntity;
- var items : array<SItemUniqueId>;
- var id : SItemUniqueId;
- var i : int;
- if(inv)
- {
- inv.GetAllItems(items);
- if(items.Size() <= 0)
- {
- return;
- }
- }
- else
- {
- return;
- }
- template = (CEntityTemplate)LoadResource("geralt_inventory_release");
- entity = theGame.CreateEntity(template, Vector(0,0,0));
- invEntity = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
- invEntity.GetAllItems(items);
- for(i=0; i<items.Size(); i+=1)
- {
- id = invEntity.GiveItemTo(inv, items[i], 0, false, true);
- if ( inv.ItemHasTag(id,'Scabbard') )
- {
- inv.MountItem(id);
- }
- else if(!inv.IsItemFists(id) && inv.GetItemName(id) != 'Cat 1')
- {
- EquipItem(id);
- }
- else if(inv.IsItemSingletonItem(id))
- {
- inv.SingletonItemSetAmmo(id, inv.SingletonItemGetMaxAmmo(id));
- }
- }
- entity.Destroy();
- RemoveTimer('GiveStartingItems');
- }
- timer function Debug_GiveTestingItems(dt : float, optional id : int)
- {
- var template : CEntityTemplate;
- var invTesting : CInventoryComponent;
- var entity : CEntity;
- var items : array<SItemUniqueId>;
- var i : int;
- var slot : EEquipmentSlots;
- if(inv)
- {
- inv.GetAllItems(items);
- if(items.Size() <= 0)
- {
- return;
- }
- }
- else
- {
- return;
- }
- template = (CEntityTemplate)LoadResource("geralt_inventory_internal");
- entity = theGame.CreateEntity(template, Vector(0,0,0));
- invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
- invTesting.GiveAllItemsTo(inv, true);
- entity.Destroy();
- RemoveTimer('Debug_GiveTestingItems');
- inv.GetAllItems(items);
- for(i=0; i<items.Size(); i+=1)
- {
- if( inv.IsItemCrossbow(items[i]) || inv.IsItemBomb(items[i]) )
- {
- slot = inv.GetSlotForItemId(items[i]);
- EquipItem(items[i], slot);
- if( (W3PlayerWitcher)this && inv.IsItemCrossbow(items[i]) )
- GetWitcherPlayer().SelectQuickslotItem(slot);
- }
- else if(inv.IsItemBolt(items[i]))
- {
- slot = inv.GetSlotForItemId(items[i]);
- EquipItem(items[i], slot);
- }
- if(inv.IsItemSingletonItem(items[i]))
- {
- inv.SingletonItemSetAmmo(items[i], inv.SingletonItemGetMaxAmmo(items[i]));
- }
- }
- }
- timer function Debug_RemoveTestingItems(dt : float, id : int)
- {
- var template : CEntityTemplate;
- var entity : CEntity;
- var invTesting : CInventoryComponent;
- var ids : array<SItemUniqueId>;
- var i : int;
- template = (CEntityTemplate)LoadResource("geralt_inventory_internal");
- entity = theGame.CreateEntity(template, Vector(0,0,0));
- invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
- invTesting.GetAllItems(ids);
- for(i=0; i<ids.Size(); i+=1)
- inv.RemoveItemByName(invTesting.GetItemName(ids[i]), invTesting.GetItemQuantity(ids[i]));
- entity.Destroy();
- RemoveTimer('Debug_RemoveTestingItems');
- }
- timer function Debug_DelayedConsoleCommand(dt : float, id : int)
- {
- inv.AddAnItem('Boots 2 schematic');
- }
- function DBG_SkillSlots()
- {
- ((W3PlayerAbilityManager)abilityManager).DBG_SkillSlots();
- }
- public final function SetPadBacklightColor(r, g, b : int)
- {
- var padBacklightColor : Vector;
- padBacklightColor.X = r / 255;
- padBacklightColor.Y = g / 255;
- padBacklightColor.Z = b / 255;
- SetBacklightColor(padBacklightColor);
- }
- public final function SetPadBacklightColorFromSign(signType : ESignType)
- {
- LogPS4Light("SetPadBacklightColorFromSign... " + signType);
- switch(signType)
- {
- case ST_Yrden: SetPadBacklightColor( 200 , 81 , 255 ); break;
- case ST_Quen: SetPadBacklightColor( 255 , 205 , 68 ); break;
- case ST_Igni: SetPadBacklightColor( 255 , 79 , 10 ); break;
- case ST_Axii: SetPadBacklightColor( 255 , 255 , 255 ); break;
- case ST_Aard: SetPadBacklightColor( 158 , 214 , 255 ); break;
- }
- }
- timer function ResetPadBacklightColorTimer(dt : float, id : int)
- {
- ResetPadBacklightColor();
- }
- public final function ResetPadBacklightColor(optional skipHeldWeapon : bool)
- {
- var weapons : array<SItemUniqueId>;
- var sword : CWitcherSword;
- var healthPercentage : float;
- var tmpBacklight : Vector;
- if(!skipHeldWeapon)
- {
- weapons = inv.GetHeldWeapons();
- if(weapons.Size() > 0)
- {
- sword = (CWitcherSword)inv.GetItemEntityUnsafe(weapons[0]);
- if(sword)
- {
- tmpBacklight.X = sword.padBacklightColor.X / 255.0f;
- tmpBacklight.Y = sword.padBacklightColor.Y / 255.0f;
- tmpBacklight.Z = sword.padBacklightColor.Z / 255.0f;
- tmpBacklight.W = 1.0f;
- SetBacklightColor( tmpBacklight );
- LogPS4Light("Setting light from sword template: " + NoTrailZeros(sword.padBacklightColor.X) + ", " + NoTrailZeros(sword.padBacklightColor.Y) + ", " + NoTrailZeros(sword.padBacklightColor.Z) );
- return;
- }
- }
- }
- healthPercentage = GetStatPercents( BCS_Vitality );
- SetBacklightFromHealth( healthPercentage );
- LogPS4Light("Setting light from health, " + NoTrailZeros(RoundMath(healthPercentage*100)) + "%");
- }
- event OnOpenningDoor()
- {
- if( !thePlayer.IsUsingHorse() )
- RaiseEvent('OpenDoor');
- }
- public final function SetLoopingCameraShakeAnimName( n : name )
- {
- loopingCameraShakeAnimName = n;
- }
- public var loopingCameraShakeAnimName : name;
- timer function RemoveQuestCameraShakeTimer( dt : float , id : int)
- {
- RemoveQuestCameraShake( loopingCameraShakeAnimName );
- }
- public function RemoveQuestCameraShake( animName : name )
- {
- var camera : CCustomCamera = theGame.GetGameCamera();
- var animation : SCameraAnimationDefinition;
- camera.StopAnimation( animName );
- }
- public function GetCameraPadding() : float
- {
- if( theGame.IsFocusModeActive() )
- {
- return 0.25;
- }
- else
- {
- return 0.02f;
- }
- }
- public function IsPerformingPhaseChangeAnimation() : bool { return isPerformingPhaseChangeAnimation; }
- public function SetIsPerformingPhaseChangeAnimation( val : bool ) { isPerformingPhaseChangeAnimation = val; }
- private function DealCounterDamageToOlgierd()
- {
- var damage : W3DamageAction;
- damage = new W3DamageAction in this;
- damage.Initialize( thePlayer.GetTarget(), thePlayer.GetTarget(), NULL, this, EHRT_None, CPS_Undefined, false, false, false, true );
- damage.AddDamage( theGame.params.DAMAGE_NAME_DIRECT, thePlayer.GetTarget().GetStatMax( BCS_Vitality ) * 3 / 100 );
- theGame.damageMgr.ProcessAction( damage );
- delete damage;
- }
- timer function PlayDelayedCounterDamageEffect( dt : float, id : int )
- {
- thePlayer.GetTarget().PlayEffect( 'olgierd_energy_blast' );
- }
- public function SetTestAdjustRequestedMovementDirection( val : bool )
- {
- testAdjustRequestedMovementDirection = val;
- }
- event OnVisualDebug( frame : CScriptedRenderFrame, flag : EShowFlags )
- {
- var boneFollow : int;
- var bonePosition : Vector;
- var yrdenEntity : W3YrdenEntity;
- substateManager.OnVisualDebug( frame, flag );
- boneFollow = thePlayer.GetBoneIndex( 'Reference' );
- bonePosition = MatrixGetTranslation( thePlayer.GetBoneWorldMatrixByIndex( boneFollow ) );
- frame.DrawText( "R", bonePosition, Color( 50, 200, 70 ) );
- boneFollow = thePlayer.GetBoneIndex( 'Trajectory' );
- bonePosition = MatrixGetTranslation( thePlayer.GetBoneWorldMatrixByIndex( boneFollow ) );
- frame.DrawSphere( bonePosition, 0.1f, Color( 200, 50, 70 ) );
- frame.DrawText( "T", bonePosition, Color( 200, 50, 70 ) );
- yrdenEntity = (W3YrdenEntity)GetWitcherPlayer().GetSignEntity(ST_Yrden);
- yrdenEntity.OnVisualDebug(frame, flag, false);
- return true;
- }
- timer function PotDrinkTimer(dt : float, id : int)
- {
- inputHandler.PotDrinkTimer(false);
- }
- public function SetIsHorseRacing( val : bool )
- {
- isHorseRacing = val;
- }
- public function GetIsHorseRacing() : bool
- {
- return isHorseRacing;
- }
- public function SetHorseCombatSlowMo( val : bool )
- {
- horseCombatSlowMo = val;
- }
- public function GetHorseCombatSlowMo() : bool
- {
- return horseCombatSlowMo;
- }
- public function SetItemsPerLevelGiven( id : int )
- {
- itemsPerLevelGiven[id] = true;
- }
- private function AddItemPerLevelList()
- {
- var i : int;
- itemsPerLevel.Clear();
- itemsPerLevel.PushBack('O');
- itemsPerLevel.PushBack('No Mans Land sword 2');
- itemsPerLevel.PushBack('No Mans Land sword 3');
- itemsPerLevel.PushBack('Silver sword 2');
- itemsPerLevel.PushBack('Boots 01');
- itemsPerLevel.PushBack('Novigraadan sword 2');
- itemsPerLevel.PushBack('Light armor 01');
- itemsPerLevel.PushBack('Heavy boots 01');
- itemsPerLevel.PushBack('Nilfgaardian sword 3');
- itemsPerLevel.PushBack('Silver sword 3');
- itemsPerLevel.PushBack('Heavy gloves 01');
- itemsPerLevel.PushBack('Skellige sword 2');
- itemsPerLevel.PushBack('Heavy pants 01');
- itemsPerLevel.PushBack('Silver sword 4');
- itemsPerLevel.PushBack('No Mans Land sword 4');
- itemsPerLevel.PushBack('Heavy armor 01');
- itemsPerLevel.PushBack('Heavy boots 02');
- itemsPerLevel.PushBack('Skellige sword 3');
- itemsPerLevel.PushBack('Silver sword 5');
- itemsPerLevel.PushBack('Heavy pants 02');
- itemsPerLevel.PushBack('Heavy gloves 02');
- itemsPerLevel.PushBack('Heavy gloves 02');
- itemsPerLevel.PushBack('Heavy armor 02');
- itemsPerLevel.PushBack('Scoiatael sword 1');
- if ( itemsPerLevelGiven.Size() < 49 )
- {
- itemsPerLevelGiven.Clear();
- for (i = 0; i < itemsPerLevel.Size(); i += 1) { itemsPerLevelGiven.PushBack( false ); }
- }
- }
- public function DealDamageToBoat( dmg : float, index : int, optional globalHitPos : Vector )
- {
- var boat : CBoatDestructionComponent;
- if(usedVehicle)
- {
- boat = (CBoatDestructionComponent) usedVehicle.GetComponentByClassName( 'CBoatDestructionComponent' );
- if( boat )
- {
- boat.DealDamage( dmg, index, globalHitPos );
- }
- }
- }
- public function OnStartTeleportingPlayerToPlayableArea()
- {
- var FADEOUT_INTERVAL : float = 0.5;
- if ( thePlayer.IsUsingHorse() )
- {
- if ( thePlayer.GetUsedHorseComponent().OnCheckHorseJump() )
- {
- thePlayer.GetUsedHorseComponent().SetCanTakeDamageFromFalling( false );
- }
- }
- if ( thePlayer.IsActionAllowed( EIAB_FastTravel ) )
- {
- OnOpenMapToLetPlayerGoBackToPlayableArea();
- }
- else
- {
- theGame.FadeOutAsync( FADEOUT_INTERVAL );
- thePlayer.AddTimer( 'BorderTeleportFadeOutTimer', FADEOUT_INTERVAL, false );
- }
- }
- timer function BorderTeleportFadeOutTimer( dt : float, id : int )
- {
- OnTeleportPlayerToPlayableArea( false );
- }
- public function OnOpenMapToLetPlayerGoBackToPlayableArea()
- {
- var initData : W3MapInitData;
- initData = new W3MapInitData in this;
- initData.SetTriggeredExitEntity( true );
- initData.ignoreSaveSystem = true;
- initData.setDefaultState('FastTravel');
- theGame.RequestMenuWithBackground( 'MapMenu', 'CommonMenu', initData );
- }
- public function OnTeleportPlayerToPlayableArea( afterClosingMap : bool )
- {
- var BLACKSCREEN_INTERVAL : float = 0.1;
- var manager : CCommonMapManager = theGame.GetCommonMapManager();
- thePlayer.TeleportWithRotation( manager.GetBorderTeleportPosition(), manager.GetBorderTeleportRotation() );
- thePlayer.AddTimer( 'BorderTeleportFadeInTimer', BLACKSCREEN_INTERVAL, false );
- theGame.FadeOutAsync( 0 );
- theGame.SetFadeLock('PlayerTeleportation');
- }
- timer function BorderTeleportFadeInTimer( dt : float, id : int )
- {
- theGame.ResetFadeLock('PlayerTeleportation');
- theGame.FadeOutAsync( 0 );
- theGame.FadeInAsync( 2.0f );
- }
- public final function SetLastInstantKillTime(g : GameTime)
- {
- lastInstantKillTime = g;
- }
- timer function TestTimer(dt : float, id : int )
- {
- LogChannel('asdf', "asdf");
- theGame.FadeOutAsync( 5 );
- }
- public final function Debug_ReleaseCriticalStateSaveLocks()
- {
- effectManager.Debug_ReleaseCriticalStateSaveLocks();
- }
- timer function Debug_SpamSpeed(dt : float, id : int)
- {
- if(currentlyMountedHorse)
- {
- LogSpeed("curr player's horse speed: " + NoTrailZeros(currentlyMountedHorse.GetMovingAgentComponent().GetSpeed())) ;
- }
- else
- {
- LogSpeed("curr player speed: " + NoTrailZeros(GetMovingAgentComponent().GetSpeed())) ;
- }
- }
- timer function RemoveInstantKillSloMo(dt : float, id : int)
- {
- theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_InstantKill) );
- }
- timer function RemoveForceFinisher(dt : float, id : int)
- {
- forceFinisher = false;
- }
- public final function Debug_ClearAllActionLocks(optional action : EInputActionBlock, optional all : bool)
- {
- inputHandler.Debug_ClearAllActionLocks(action, all);
- }
- function OnFocusedCameraBlendBegin() {}
- function OnFocusedCameraBlendUpdate( progress : float ) {}
- function OnFocusedCameraBlendEnd() {}
- public function GetEtherealCount() : int { return etherealCount; }
- public function IncrementEtherealCount()
- {
- etherealCount += 1;
- if( etherealCount == 6 )
- ResetEtherealCount();
- }
- public function ResetEtherealCount() { etherealCount = 0; }
- public function SetInsideDiveAttackArea( val : bool ) { insideDiveAttackArea = val; }
- public function IsInsideDiveAttackArea() : bool { return insideDiveAttackArea; }
- public function SetDiveAreaNumber( val : int ) { diveAreaNumber = val; }
- public function GetDiveAreaNumber() : int { return diveAreaNumber; }
- public function InitPhantomWeaponMgr()
- {
- if( !phantomWeaponMgr )
- {
- phantomWeaponMgr = new CPhantomWeaponManager in this;
- phantomWeaponMgr.Init( this.GetInventory() );
- }
- }
- public function DestroyPhantomWeaponMgr()
- {
- if( phantomWeaponMgr )
- {
- delete phantomWeaponMgr;
- }
- }
- public function GetPhantomWeaponMgr() : CPhantomWeaponManager
- {
- if( phantomWeaponMgr )
- {
- return phantomWeaponMgr;
- }
- else
- {
- return NULL;
- }
- }
- public timer function DischargeWeaponAfter( td : float, id : int )
- {
- GetPhantomWeaponMgr().DischargeWeapon();
- }
- private var forcedFinisherVictim : CActor;
- timer function PerformFinisher( time : float , id : int )
- {
- var combatTarget : CActor;
- var i : int;
- combatTarget = thePlayer.GetTarget();
- if( combatTarget )
- {
- combatTarget.Kill( 'AutoFinisher', false, thePlayer );
- thePlayer.SetFinisherVictim( combatTarget );
- forcedFinisherVictim = combatTarget;
- thePlayer.CleanCombatActionBuffer();
- thePlayer.OnBlockAllCombatTickets( true );
- moveTargets = thePlayer.GetMoveTargets();
- for( i = 0; i < moveTargets.Size(); i += 1 )
- {
- if( combatTarget != moveTargets[i] )
- moveTargets[i].SignalGameplayEvent( 'InterruptChargeAttack' );
- }
- if( theGame.GetInGameConfigWrapper().GetVarValue( 'Gameplay', 'AutomaticFinishersEnabled' ) == "true" )
- combatTarget.AddAbility( 'ForceFinisher', false );
- if( combatTarget.HasTag( 'ForceFinisher' ) )
- combatTarget.AddAbility( 'ForceFinisher', false );
- combatTarget.SignalGameplayEvent( 'ForceFinisher' );
- thePlayer.FindMoveTarget();
- thePlayer.AddTimer( 'SignalFinisher', 0.2, false );
- }
- }
- timer function SignalFinisher( time : float , id : int )
- {
- forcedFinisherVictim.SignalGameplayEvent( 'Finisher' );
- forcedFinisherVictim = NULL;
- }
- }
- exec function ttt()
- {
- thePlayer.AddTimer( 'TestTimer', 5, false );
- }
- if(CanParryAttack() && FistFightCheck( parryInfo.target, parryInfo.attacker, fistFightParry ) )
- {
- parryHeading = GetParryHeading( parryInfo, parryDir ) ;
- SetBehaviorVariable( 'parryDirection', (float)( (int)( parryDir ) ) );
- SetBehaviorVariable( 'parryDirectionOverlay', (float)( (int)( parryDir ) ) );
- SetBehaviorVariable( 'parryType', ChooseParryTypeIndex( parryInfo ) );
- if ( IsInCombatActionFriendly() )
- RaiseEvent('CombatActionFriendlyEnd');
- if ( HasStaminaToParry(parryInfo.attackActionName) )
- {
- this.SetBehaviorVariable( 'combatActionType', (int)CAT_Parry );
- if ( parryInfo.targetToAttackerDist > 3.f && !bLAxisReleased && !thePlayer.IsCiri() )
- {
- if ( !RaiseForceEvent( 'PerformParryOverlay' ) )
- return false;
- else
- {
- ClearCustomOrientationInfoStack();
- IncDefendCounter();
- }
- }
- else
- {
- counter = GetDefendCounter();
- onHitCounter = parryInfo.attacker.GetAttributeValue( 'break_through_parry_on_hit_counter' );
- if ( onHitCounter.valueBase > 0 && counter == onHitCounter.valueBase )
- {
- AddEffectDefault( EET_Stagger, parryInfo.attacker, "Break through parry" );
- }
- else if ( RaiseForceEvent( 'PerformParry' ) )
- {
- OnCombatActionStart();
- ClearCustomOrientationInfoStack();
- SetSlideTarget( parryInfo.attacker );
- SetCustomRotation( 'Parry', parryHeading, 1080.f, 0.1f, false );
- IncDefendCounter();
- }
- else
- return false;
- }
- }
- else
- {
- AddEffectDefault(EET_Stagger, parryInfo.attacker, "Parry");
- return true;
- }
- if ( parryInfo.attacker.IsWeaponHeld( 'fist' ) && !parryInfo.target.IsWeaponHeld( 'fist' ) )
- {
- parryInfo.attacker.ReactToReflectedAttack(parryInfo.target);
- }
- else
- {
- if ( this.IsInFistFightMiniGame() && fistFightParry )
- {
- if ( IsNameValid(xmlStaminaDamageName) )
- {
- xmlStaminaDamage = CalculateAttributeValue(parryInfo.attacker.GetAttributeValue( xmlStaminaDamageName ));
- DrainStamina(ESAT_FixedValue, xmlStaminaDamage);
- }
- }
- else
- {
- DrainStamina(ESAT_Parry, 0, 0, '', 0, mult);
- }
- if(IsLightAttack(parryInfo.attackActionName))
- parryInfo.target.PlayEffectOnHeldWeapon('light_block');
- else
- parryInfo.target.PlayEffectOnHeldWeapon('heavy_block');
- }
- return true;
- }
- return false;
- }
- protected function GetParryHeading( parryInfo : SParryInfo, out parryDir : EPlayerParryDirection ) : float
- {
- var targetToAttackerHeading : float;
- var currToTargetAttackerAngleDiff : float;
- targetToAttackerHeading = VecHeading( parryInfo.attacker.GetWorldPosition() - parryInfo.target.GetWorldPosition() );
- currToTargetAttackerAngleDiff = AngleDistance( VecHeading( parryInfo.target.GetHeadingVector() ), targetToAttackerHeading );
- if ( !parryInfo.target.IsWeaponHeld( 'fist' ) )
- {
- if( currToTargetAttackerAngleDiff > -45 && currToTargetAttackerAngleDiff < 45 )
- {
- parryDir = PPD_Forward;
- return targetToAttackerHeading;
- }
- else if( currToTargetAttackerAngleDiff >= 45 && currToTargetAttackerAngleDiff < 135 )
- {
- parryDir = PPD_Right;
- return targetToAttackerHeading + 90;
- }
- else if( currToTargetAttackerAngleDiff <= -45 && currToTargetAttackerAngleDiff > -135 )
- {
- parryDir = PPD_Left;
- return targetToAttackerHeading - 90;
- }
- else
- {
- parryDir = PPD_Back;
- return targetToAttackerHeading + 180;
- }
- }
- else
- {
- if( currToTargetAttackerAngleDiff > -45 && currToTargetAttackerAngleDiff < 45 )
- {
- parryDir = PPD_Forward;
- return targetToAttackerHeading;
- }
- else if( currToTargetAttackerAngleDiff >= 45 && currToTargetAttackerAngleDiff < 180 )
- {
- parryDir = PPD_Right;
- return targetToAttackerHeading + 90;
- }
- else if( currToTargetAttackerAngleDiff <= -45 && currToTargetAttackerAngleDiff >= -180 )
- {
- parryDir = PPD_Left;
- return targetToAttackerHeading - 90;
- }
- else
- {
- parryDir = PPD_Back;
- return targetToAttackerHeading + 180;
- }
- }
- }
- function ProcessLockTarget( optional newLockTarget : CActor, optional checkLeftStickHeading : bool ) : bool
- {
- var attackerNearestPoint : Vector;
- var playerNearestPoint : Vector;
- var incomingAttacker : CActor;
- var tempLockTarget : CActor;
- var target : CActor;
- var useIncomingAttacker : bool;
- if( newLockTarget.HasTag( 'NoHardLock' ) )
- return false;
- if ( newLockTarget )
- tempLockTarget = newLockTarget;
- else
- {
- incomingAttacker = GetClosestIncomingAttacker();
- if ( incomingAttacker && incomingAttacker.IsAlive() && IsUsingVehicle() )
- {
- tempLockTarget = incomingAttacker;
- useIncomingAttacker = false;
- }
- if ( !useIncomingAttacker )
- {
- target = GetTarget();
- if( target.HasTag('ForceHardLock'))
- {
- return true;
- }
- else if ( target && target.IsAlive() && target.GetGameplayVisibility() && IsEnemyVisible( target ) && IsThreat( target ) && CanBeTargetedIfSwimming( target ) )
- tempLockTarget = FindTarget();
- else
- {
- tempLockTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, 0.f );
- }
- }
- }
- if( tempLockTarget.HasTag( 'NoHardLock' ) )
- return false;
- if ( tempLockTarget )
- {
- if ( IsCombatMusicEnabled() || hostileEnemies.Size() > 0 )
- {
- if ( !IsThreat( tempLockTarget ) )
- tempLockTarget = NULL;
- }
- }
- SetTarget( tempLockTarget, true );
- SetMoveTargetChangeAllowed( true );
- SetMoveTarget( tempLockTarget );
- SetMoveTargetChangeAllowed( false );
- SetSlideTarget( tempLockTarget );
- if ( tempLockTarget )
- {
- if ( this.IsActorLockedToTarget() )
- EnableHardLockIcon( true );
- return true;
- }
- else
- return false;
- }
- event OnTaskSyncAnim( npc : CNewNPC, animNameLeft : name ) {}
- public function IsDoingSpecialAttack(heavy : bool) : bool
- {
- var pat : EPlayerAttackType;
- if(IsInCombatAction() && ( (int)GetBehaviorVariable('combatActionType')) == CAT_SpecialAttack)
- {
- pat = (int)GetBehaviorVariable('playerAttackType');
- if(heavy && pat == PAT_Heavy)
- {
- return true;
- }
- else if(!heavy && pat == PAT_Light)
- {
- return true;
- }
- }
- return false;
- }
- public function SetIsCurrentlyDodging(enable : bool, optional isRolling : bool)
- {
- super.SetIsCurrentlyDodging(enable, isRolling);
- if ( isRolling )
- {
- SetCanPlayHitAnim( false );
- this.AddBuffImmunity( EET_KnockdownTypeApplicator, 'Roll', false );
- this.AddBuffImmunity( EET_Knockdown, 'Roll', false );
- this.AddBuffImmunity( EET_HeavyKnockdown, 'Roll', false );
- this.AddBuffImmunity( EET_Stagger, 'Roll', false );
- }
- else
- {
- SetCanPlayHitAnim( true );
- this.RemoveBuffImmunity( EET_KnockdownTypeApplicator, 'Roll' );
- this.RemoveBuffImmunity( EET_Knockdown, 'Roll' );
- this.RemoveBuffImmunity( EET_HeavyKnockdown, 'Roll' );
- this.RemoveBuffImmunity( EET_Stagger, 'Roll' );
- }
- }
- public function EnableHardLock( flag : bool )
- {
- super.EnableHardLock(flag);
- if(flag && ShouldProcessTutorial('TutorialTargettingWaiting'))
- {
- FactsAdd("tut_hardlocked");
- }
- }
- protected function TestParryAndCounter(data : CPreAttackEventData, weaponId : SItemUniqueId, out parried : bool, out countered : bool) : array<CActor>
- {
- var ret : array<CActor>;
- if(FactsQuerySum('player_is_the_boss') > 0)
- {
- SetDebugAttackRange(data.rangeName);
- RemoveTimer('PostAttackDebugRangeClear');
- return ret;
- }
- ret = super.TestParryAndCounter(data, weaponId, parried, countered);
- if(parried)
- theGame.GetGamerProfile().ResetStat(ES_CounterattackChain);
- return ret;
- }
- public function SetSpecialAttackTimeRatio(f : float)
- {
- LogSpecialHeavy(f);
- specialAttackTimeRatio = f;
- }
- public function GetSpecialAttackTimeRatio() : float
- {
- return specialAttackTimeRatio;
- }
- public function OnSpecialAttackHeavyActionProcess()
- {
- SetSpecialAttackTimeRatio(0.f);
- }
- protected function DoAttack(animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float)
- {
- var shakeStr : float;
- var weapon : EPlayerWeapon;
- var targetActor : CActor;
- if ( animData.attackName == 'attack_heavy_special' )
- {
- if( specialAttackTimeRatio != 1 )
- shakeStr = (specialAttackTimeRatio / 3.333) + 0.2;
- else
- shakeStr = 0.5;
- GCameraShake( shakeStr, false, GetWorldPosition(), 10);
- }
- else if ( IsHeavyAttack(attackActionName) )
- {
- if(parriedBy.Size() > 0)
- shakeStr = 0.2;
- else
- shakeStr = 0.1;
- GCameraShake(shakeStr, false, GetWorldPosition(), 10);
- }
- targetActor = (CActor)slideTarget;
- if ( targetActor && hitTargets.Contains(targetActor) )
- {
- weapon = this.GetMostConvenientMeleeWeapon(targetActor,true);
- if ( this.GetCurrentMeleeWeaponType() != PW_Fists && weapon != this.GetCurrentMeleeWeaponType() )
- {
- if ( weapon == PW_Steel )
- {
- thePlayer.OnEquipMeleeWeapon(PW_Steel,true);
- }
- else if ( weapon == PW_Silver )
- {
- thePlayer.OnEquipMeleeWeapon(PW_Silver,true);
- }
- }
- }
- super.DoAttack(animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime);
- }
- private var confirmCombatStanceTimeStamp : float;
- private var isConfirmingCombatStance : bool;
- final function SetPlayerCombatStance(stance : EPlayerCombatStance, optional force : bool )
- {
- var stanceInt : int;
- if ( !CanChangeCombatStance( stance, force ) )
- return;
- combatStance = stance;
- stanceInt = (int)stance;
- SetBehaviorVariable( 'playerCombatStance' , (float)stanceInt);
- SetBehaviorVariable( 'playerCombatStanceForOverlay' , (float)stanceInt);
- if ( force )
- SetBehaviorVariable( 'forceCombatStance' , 1.f);
- else
- SetBehaviorVariable( 'forceCombatStance' , 0.f);
- if ( stance == PCS_AlertNear )
- this.SetBehaviorVariable('isInCombatForOverlay',1.f);
- else
- this.SetBehaviorVariable('isInCombatForOverlay',0.f);
- }
- private function CanChangeCombatStance( stance : EPlayerCombatStance, optional force : bool ) : bool
- {
- var currTime : float;
- if ( force )
- return true;
- if ( IsInFistFightMiniGame() )
- return true;
- if ( isInHolsterAnim )
- return false;
- if ( ( combatStance == PCS_Normal || combatStance == PCS_AlertFar ) && stance == PCS_AlertNear )
- {
- currTime = theGame.GetEngineTimeAsSeconds();
- if ( !isConfirmingCombatStance )
- {
- isConfirmingCombatStance = true;
- confirmCombatStanceTimeStamp = currTime;
- return false;
- }
- else if ( currTime < confirmCombatStanceTimeStamp + 1.f )
- {
- if ( stance == PCS_AlertNear )
- return false;
- }
- else
- isConfirmingCombatStance = false;
- }
- else
- isConfirmingCombatStance = false;
- return true;
- }
- private var isInHolsterAnim : bool;
- event OnHolsterWeaponStart()
- {
- isInHolsterAnim = true;
- }
- event OnHolsterWeaponEnd()
- {
- isInHolsterAnim = false;
- }
- final function GetPlayerCombatStance() : EPlayerCombatStance
- {
- return combatStance;
- }
- timer function DelayedDisableFindTarget( time : float , id : int)
- {
- if ( GetTarget().IsAlive() )
- {
- EnableFindTarget( false );
- }
- else
- {
- EnableFindTarget( true );
- }
- }
- private var dodgeTimerRunning : bool;
- function StartDodgeTimer()
- {
- dodgeTimerRunning = true;
- thePlayer.AddTimer('DodgeTimer',0.2,false);
- }
- function StopDodgeTimer()
- {
- this.RemoveTimer('DodgeTimer');
- dodgeTimerRunning = false;
- }
- function IsDodgeTimerRunning() : bool
- {
- return dodgeTimerRunning;
- }
- timer function DodgeTimer( dt : float, id : int )
- {
- dodgeTimerRunning = false;
- }
- public function EvadePressed( bufferAction : EBufferActionType )
- {
- }
- public function PerformingCombatAction() : EBufferActionType
- {
- return BufferCombatAction;
- }
- public function PushCombatActionOnBuffer( action : EBufferActionType, stage : EButtonStage, optional allSteps : bool )
- {
- BufferButtonStage = stage;
- BufferCombatAction = action;
- BufferAllSteps = allSteps;
- }
- protected function ProcessCombatActionHeading( action : EBufferActionType ) : float
- {
- var processedActionHeading : float;
- HandleMovement( 0.f );
- if ( ShouldUsePCModeTargeting() )
- return theGame.GetGameCamera().GetHeading();
- if ( lAxisReleasedAfterCounter )
- ResetCachedRawPlayerHeading();
- processedActionHeading = cachedRawPlayerHeading;
- return processedActionHeading;
- }
- function ResetRawPlayerHeading()
- {
- if ( GetDisplayTarget() )
- rawPlayerHeading = VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() );
- else
- rawPlayerHeading = GetHeading();
- }
- function ResetCachedRawPlayerHeading()
- {
- cachedRawPlayerHeading = rawPlayerHeading;
- if ( GetDisplayTarget() && IsDisplayTargetTargetable() && AbsF( AngleDistance( VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() ), this.GetHeading() ) ) < 90.f )
- cachedRawPlayerHeading = VecHeading( GetDisplayTarget().GetWorldPosition() - this.GetWorldPosition() );
- else
- cachedRawPlayerHeading = this.GetHeading();
- if ( canResetCachedCombatActionHeading )
- cachedCombatActionHeading = cachedRawPlayerHeading;
- }
- public function GetCombatActionTarget( action : EBufferActionType ) : CGameplayEntity
- {
- var selectedTargetableEntity : CGameplayEntity;
- if ( !this.IsUsingVehicle() )
- selectedTargetableEntity = FindNonActorTarget( true, action );
- if ( selectedTargetableEntity )
- {
- return selectedTargetableEntity;
- }
- else
- {
- if ( !this.IsUsingVehicle() )
- FindTarget( true, action, true );
- else
- ((CR4PlayerStateUseGenericVehicle)this.GetState( 'UseGenericVehicle' )).FindTarget();
- return GetTarget();
- }
- }
- private function FindNonActorTarget( actionCheck : bool, optional action : EBufferActionType ) : CGameplayEntity
- {
- var targetableEntities : array<CGameplayEntity>;
- var selectedTargetableEntity : CGameplayEntity;
- var selectionPriority : array< float >;
- var selectionWeights : STargetSelectionWeights;
- var findEntityDist : float;
- var i, size : int;
- var playerHeading : float;
- var playerInventory : CInventoryComponent;
- var castSignType : ESignType;
- var targetingInfo : STargetingInfo;
- var playerPosition : Vector;
- var cameraPosition : Vector;
- var playerHeadingVector : Vector;
- var rawPlayerHeadingVector : Vector;
- playerPosition = this.GetWorldPosition();
- cameraPosition = theCamera.GetCameraPosition();
- rawPlayerHeadingVector = VecFromHeading( rawPlayerHeading );
- if ( bCanFindTarget && !IsHardLockEnabled() )
- {
- if ( actionCheck && IsInCombat() && action == EBAT_CastSign )
- {
- findEntityDist = 6.f;
- selectionWeights.angleWeight = 0.375f;
- selectionWeights.distanceWeight = 0.275f;
- selectionWeights.distanceRingWeight = 0.35f;
- }
- else if ( !IsInCombat() && lastAxisInputIsMovement )
- {
- findEntityDist = softLockDist;
- selectionWeights.angleWeight = 0.375f;
- selectionWeights.distanceWeight = 0.275f;
- selectionWeights.distanceRingWeight = 0.35f;
- }
- else
- {
- findEntityDist = softLockDist;
- selectionWeights.angleWeight = 0.75f;
- selectionWeights.distanceWeight = 0.125f;
- selectionWeights.distanceRingWeight = 0.125f;
- }
- if ( !IsInCombat() || !bLAxisReleased )
- {
- FindGameplayEntitiesInRange( targetableEntities, this, findEntityDist, 10, theGame.params.TAG_SOFT_LOCK );
- }
- if ( targetableEntities.Size() > 0 )
- {
- playerInventory = this.GetInventory();
- castSignType = this.GetEquippedSign();
- if ( !bLAxisReleased )
- {
- targetingInfo.source = this;
- targetingInfo.canBeTargetedCheck = false;
- targetingInfo.coneCheck = true;
- targetingInfo.coneHalfAngleCos = 0.5f;
- targetingInfo.coneDist = softLockDist;
- targetingInfo.coneHeadingVector = rawPlayerHeadingVector;
- targetingInfo.distCheck = true;
- targetingInfo.invisibleCheck = false;
- targetingInfo.navMeshCheck = false;
- targetingInfo.frameScaleX = 1.0f;
- targetingInfo.frameScaleY = 1.0f;
- targetingInfo.knockDownCheck = false;
- targetingInfo.knockDownCheckDist = 0.0f;
- targetingInfo.rsHeadingCheck = false;
- targetingInfo.rsHeadingLimitCos = 1.0f;
- }
- for( i = targetableEntities.Size()-1; i>=0; i-=1 )
- {
- if ( bLAxisReleased )
- {
- if ( !lastAxisInputIsMovement )
- {
- if ( !WasVisibleInScaledFrame( targetableEntities[i], 0.9f, 0.9f ) )
- {
- targetableEntities.Erase(i);
- continue;
- }
- }
- else if ( !WasVisibleInScaledFrame( targetableEntities[i], 1.f, 1.f ) )
- {
- targetableEntities.Erase(i);
- continue;
- }
- }
- else
- {
- targetingInfo.targetEntity = targetableEntities[i];
- if ( actionCheck && moveTarget )
- {
- targetingInfo.inFrameCheck = false;
- if ( !IsEntityTargetable( targetingInfo ) )
- {
- targetableEntities.Erase(i);
- continue;
- }
- }
- else
- {
- targetingInfo.inFrameCheck = true;
- if ( !IsEntityTargetable( targetingInfo ) )
- {
- targetableEntities.Erase(i);
- continue;
- }
- }
- }
- if ( actionCheck )
- {
- if ( action == EBAT_ItemUse )
- {
- if ( ( playerInventory.IsItemBomb( this.GetSelectedItemId() ) && !targetableEntities[i].HasTag( 'softLock_Bomb' ) )
- || ( playerInventory.IsItemCrossbow( this.GetSelectedItemId() ) && !targetableEntities[i].HasTag( 'softLock_Bolt' ) ) )
- {
- targetableEntities.Erase(i);
- continue;
- }
- }
- else if ( action == EBAT_CastSign )
- {
- if ( ( castSignType == ST_Aard && !targetableEntities[i].HasTag( 'softLock_Aard' ) )
- || ( castSignType == ST_Igni && !targetableEntities[i].HasTag( 'softLock_Igni' ) )
- || ( castSignType == ST_Axii && !targetableEntities[i].HasTag( 'softLock_Axii' ) )
- || castSignType == ST_Yrden
- || castSignType == ST_Quen )
- {
- targetableEntities.Erase(i);
- continue;
- }
- }
- else if ( action == EBAT_LightAttack || action == EBAT_HeavyAttack || action == EBAT_SpecialAttack_Heavy )
- {
- if ( ( IsWeaponHeld( 'fist' ) && !targetableEntities[i].HasTag( 'softLock_Fist' ) ) || ( !IsWeaponHeld( 'fist' ) && !targetableEntities[i].HasTag( 'softLock_Weapon' ) ) )
- {
- targetableEntities.Erase(i);
- continue;
- }
- }
- else
- {
- targetableEntities.Erase(i);
- continue;
- }
- }
- }
- }
- if ( targetableEntities.Size() > 0)
- {
- playerHeading = this.GetHeading();
- playerHeadingVector = this.GetHeadingVector();
- if ( IsInCombat() )
- {
- for( i = 0; i < targetableEntities.Size(); i += 1 )
- {
- if ( bLAxisReleased )
- selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, cameraPosition, rawPlayerHeadingVector ) );
- else
- selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, rawPlayerHeadingVector ) );
- }
- if ( selectionPriority.Size() > 0 )
- selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
- }
- else
- {
- if ( bLAxisReleased )
- {
- if ( !lastAxisInputIsMovement )
- {
- for( i = 0; i < targetableEntities.Size(); i += 1 )
- selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, cameraPosition, rawPlayerHeadingVector ) );
- if ( selectionPriority.Size() > 0 )
- selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
- }
- else
- {
- if ( IsInCombatAction() )
- selectedTargetableEntity = nonActorTarget;
- else
- {
- for( i = 0; i < targetableEntities.Size(); i += 1 )
- selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, playerHeadingVector ) );
- if ( selectionPriority.Size() > 0 )
- {
- selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
- targetingInfo.source = this;
- targetingInfo.targetEntity = selectedTargetableEntity;
- targetingInfo.canBeTargetedCheck = false;
- targetingInfo.coneCheck = true;
- targetingInfo.coneHalfAngleCos = 0.0f;
- targetingInfo.coneDist = softLockDist;
- targetingInfo.coneHeadingVector = this.GetHeadingVector();
- targetingInfo.distCheck = true;
- targetingInfo.invisibleCheck = false;
- targetingInfo.navMeshCheck = false;
- targetingInfo.inFrameCheck = false;
- targetingInfo.frameScaleX = 1.0f;
- targetingInfo.frameScaleY = 1.0f;
- targetingInfo.knockDownCheck = false;
- targetingInfo.knockDownCheckDist = 0.0f;
- targetingInfo.rsHeadingCheck = false;
- targetingInfo.rsHeadingLimitCos = 1.0f;
- if ( !IsEntityTargetable( targetingInfo ) )
- selectedTargetableEntity = NULL;
- }
- }
- }
- }
- else
- {
- for( i = 0; i < targetableEntities.Size(); i += 1 )
- selectionPriority.PushBack( CalcSelectionPriority( targetableEntities[i], selectionWeights, playerPosition, rawPlayerHeadingVector ) );
- if ( selectionPriority.Size() > 0 )
- selectedTargetableEntity = targetableEntities[ ArrayFindMaxF( selectionPriority ) ];
- }
- }
- }
- else
- selectedTargetableEntity = NULL;
- }
- SetNonActorTarget( selectedTargetableEntity );
- return selectedTargetableEntity;
- }
- public function SetupCombatAction( action : EBufferActionType, stage : EButtonStage )
- {
- var weaponType : EPlayerWeapon;
- var canAttackTarget : CGameplayEntity;
- var target : CActor;
- if ( !IsCombatMusicEnabled() )
- {
- SetCombatActionHeading( ProcessCombatActionHeading( action ) );
- FindTarget();
- UpdateDisplayTarget( true );
- }
- if ( displayTarget && IsDisplayTargetTargetable() )
- canAttackTarget = displayTarget;
- else if ( GetTarget() )
- canAttackTarget = GetTarget();
- else if( !target && IsCombatMusicEnabled() )
- canAttackTarget = moveTarget;
- target = (CActor)canAttackTarget;
- if ( !AllowAttack( target, action ) )
- return;
- if( ( action != EBAT_ItemUse ) && ( action != EBAT_CastSign ) )
- {
- weaponType = weaponHolster.GetCurrentMeleeWeapon();
- PrepareToAttack( target, action );
- if ( weaponType != weaponHolster.GetCurrentMeleeWeapon() )
- {
- if ( !( weaponType == PW_None && weaponHolster.GetCurrentMeleeWeapon() == PW_Fists ) )
- return;
- }
- }
- if(action == EBAT_SpecialAttack_Heavy && !((W3ReplacerCiri)this) )
- thePlayer.SetAttackActionName(SkillEnumToName(S_Sword_s02));
- CriticalEffectAnimationInterrupted("SetupCombatAction " + action);
- PushCombatActionOnBuffer( action, stage );
- if( GetBIsCombatActionAllowed() )
- {
- ProcessCombatActionBuffer();
- }
- }
- public function AllowAttack( target : CActor, action : EBufferActionType ) : bool
- {
- var newTarget : CActor;
- var canAttackWhenNotInCombat : bool;
- var messageDisplayed : bool;
- var itemId : SItemUniqueId;
- var isShootingCrossbow : bool;
- var isInCorrectState : bool;
- if ( target )
- {
- if ( target.IsTargetableByPlayer())
- {
- if ( !target.IsAttackableByPlayer() )
- {
- DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_cant_attack_this_target"));
- return false;
- }
- }
- }
- if ( this.GetCurrentStateName() == 'Exploration' )
- isInCorrectState = true;
- if ( action == EBAT_ItemUse )
- {
- itemId = thePlayer.GetSelectedItemId();
- if ( inv.IsIdValid(itemId) && inv.IsItemCrossbow(itemId) )
- isShootingCrossbow = true;
- if ( !isInCorrectState )
- {
- if ( this.GetCurrentStateName() == 'AimThrow' && !isShootingCrossbow )
- {
- isInCorrectState = true;
- }
- }
- }
- if ( isInCorrectState )
- canAttackWhenNotInCombat = thePlayer.CanAttackWhenNotInCombat( action, false, newTarget, target );
- if( !target )
- {
- if ( isInCorrectState )
- {
- SetCombatActionHeading( ProcessCombatActionHeading( action ) );
- target = newTarget;
- }
- }
- if ( isInCorrectState )
- {
- if ( !canAttackWhenNotInCombat )
- {
- if ( DisplayCannotAttackMessage( target ) )
- messageDisplayed = true;
- else if ( ( action == EBAT_LightAttack || action == EBAT_HeavyAttack )
- && !RaiseAttackFriendlyEvent( target ) )
- messageDisplayed = true;
- else
- {
- if ( !CanRaiseCombatActionFriendlyEvent( isShootingCrossbow ) )
- messageDisplayed = true;
- }
- }
- if ( messageDisplayed )
- {
- theInput.ForceDeactivateAction('ThrowItem');
- theInput.ForceDeactivateAction('ThrowItemHold');
- this.SignalGameplayEvent( 'FriendlyAttackAction' );
- return false;
- }
- }
- return true;
- }
- public function ProcessCombatActionBuffer() : bool
- {
- var actionResult : bool;
- var action : EBufferActionType = this.BufferCombatAction;
- var stage : EButtonStage = this.BufferButtonStage;
- var s : SNotWorkingOutFunctionParametersHackStruct1;
- var allSteps : bool = this.BufferAllSteps;
- if ( IsInCombatActionFriendly() )
- {
- RaiseEvent('CombatActionFriendlyEnd');
- }
- if ( ( action != EBAT_SpecialAttack_Heavy && action != EBAT_ItemUse )
- || ( action == EBAT_SpecialAttack_Heavy && stage == BS_Pressed )
- || ( action == EBAT_ItemUse && stage != BS_Released ) )
- {
- GetMovingAgentComponent().GetMovementAdjustor().CancelAll();
- SetUnpushableTarget( NULL );
- }
- if ( !( action == EBAT_Dodge || action == EBAT_Roll ) )
- {
- SetIsCurrentlyDodging(false);
- }
- SetCombatActionHeading( ProcessCombatActionHeading( action ) );
- if ( action == EBAT_ItemUse && GetInventory().IsItemCrossbow( selectedItemId ) )
- {
- if ( rangedWeapon
- && ( ( rangedWeapon.GetCurrentStateName() != 'State_WeaponShoot' && rangedWeapon.GetCurrentStateName() != 'State_WeaponAim' ) || GetIsShootingFriendly() ) )
- {
- SetSlideTarget( GetCombatActionTarget( action ) );
- }
- }
- else if ( !( ( action == EBAT_SpecialAttack_Heavy && stage == BS_Released ) || GetCurrentStateName() == 'AimThrow' ) )
- {
- SetSlideTarget( GetCombatActionTarget( action ) );
- }
- if( !slideTarget )
- LogChannel( 'Targeting', "NO SLIDE TARGET" );
- actionResult = true;
- switch ( action )
- {
- case EBAT_EMPTY :
- {
- this.BufferAllSteps = false;
- return true;
- } break;
- case EBAT_LightAttack :
- {
- if ( IsCiri() )
- return false;
- switch ( stage )
- {
- case BS_Pressed :
- {
- DrainStamina(ESAT_LightAttack);
- thePlayer.BreakPheromoneEffect();
- actionResult = OnPerformAttack(theGame.params.ATTACK_NAME_LIGHT);
- } break;
- default :
- {
- actionResult = false;
- }break;
- }
- }break;
- case EBAT_HeavyAttack :
- {
- if ( IsCiri() )
- return false;
- switch ( stage )
- {
- case BS_Released :
- {
- DrainStamina(ESAT_HeavyAttack);
- thePlayer.BreakPheromoneEffect();
- actionResult = this.OnPerformAttack(theGame.params.ATTACK_NAME_HEAVY);
- } break;
- case BS_Pressed :
- {
- if ( this.GetCurrentStateName() == 'CombatFists' )
- {
- DrainStamina(ESAT_HeavyAttack);
- thePlayer.BreakPheromoneEffect();
- actionResult = this.OnPerformAttack(theGame.params.ATTACK_NAME_HEAVY);
- }
- } break;
- default :
- {
- actionResult = false;
- } break;
- }
- } break;
- case EBAT_ItemUse :
- {
- switch ( stage )
- {
- case BS_Pressed :
- {
- if ( !( (W3PlayerWitcher)this ) ||
- ( !IsInCombatActionFriendly() && !( !GetBIsCombatActionAllowed() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign ) ) ) )
- {
- if ( inv.IsItemCrossbow( selectedItemId ) )
- {
- rangedWeapon = ( Crossbow )( inv.GetItemEntityUnsafe( selectedItemId ) );
- rangedWeapon.OnRangedWeaponPress();
- GetTarget().SignalGameplayEvent( 'Approach' );
- GetTarget().SignalGameplayEvent( 'ShootingCrossbow' );
- }
- else if(inv.IsItemBomb(selectedItemId) && this.inv.SingletonItemGetAmmo(selectedItemId) > 0 )
- {
- if( ((W3PlayerWitcher)this).GetBombDelay( ((W3PlayerWitcher)this).GetItemSlot( selectedItemId ) ) <= 0.0f )
- {
- BombThrowStart();
- GetTarget().SignalGameplayEvent( 'Approach' );
- }
- }
- else
- {
- DrainStamina(ESAT_UsableItem);
- UsableItemStart();
- }
- }
- } if (!allSteps) break;
- case BS_Released:
- {
- if ( !( (W3PlayerWitcher)this ) ||
- ( !IsInCombatActionFriendly() && ( GetBIsCombatActionAllowed() || !( !GetBIsCombatActionAllowed() && ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack || GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign ) ) ) ) )
- {
- if ( inv.IsItemCrossbow( selectedItemId ) )
- {
- rangedWeapon.OnRangedWeaponRelease();
- }
- else if(inv.IsItemBomb(selectedItemId))
- {
- BombThrowRelease();
- }
- else
- {
- UsableItemRelease();
- }
- }
- } break;
- default :
- {
- actionResult = false;
- break;
- }
- }
- } break;
- case EBAT_Dodge :
- {
- switch ( stage )
- {
- case BS_Released :
- {
- theGame.GetBehTreeReactionManager().CreateReactionEvent( this, 'PlayerEvade', 1.0f, 10.0f, -1.0f, -1 );
- thePlayer.BreakPheromoneEffect();
- actionResult = this.OnPerformEvade( PET_Dodge );
- } break;
- default :
- {
- actionResult = false;
- } break;
- }
- } break;
- case EBAT_Roll :
- {
- if ( IsCiri() )
- return false;
- switch ( stage )
- {
- case BS_Released :
- {
- theGame.GetBehTreeReactionManager().CreateReactionEvent( this, 'PlayerEvade', 1.0f, 10.0f, -1.0f, -1 );
- thePlayer.BreakPheromoneEffect();
- actionResult = this.OnPerformEvade( PET_Roll );
- } break;
- case BS_Pressed :
- {
- if ( this.GetBehaviorVariable( 'combatActionType' ) == 2.f )
- {
- if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
- actionResult = this.OnPerformEvade( PET_Pirouette );
- else
- actionResult = this.OnPerformEvade( PET_Roll );
- }
- else
- {
- if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
- {
- actionResult = this.OnPerformEvade( PET_Dodge );
- actionResult = this.OnPerformEvade( PET_Pirouette );
- }
- else
- {
- actionResult = this.OnPerformEvade( PET_Dodge );
- actionResult = this.OnPerformEvade( PET_Roll );
- }
- }
- } break;
- default :
- {
- actionResult = false;
- } break;
- }
- } break;
- case EBAT_Draw_Steel :
- {
- switch ( stage )
- {
- case BS_Pressed :
- {
- if( !IsActionAllowed(EIAB_DrawWeapon) )
- {
- thePlayer.DisplayActionDisallowedHudMessage(EIAB_DrawWeapon);
- actionResult = false;
- break;
- }
- if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'steelsword' ) )
- {
- OnEquipMeleeWeapon( PW_Steel, false, true );
- }
- actionResult = false;
- } break;
- default :
- {
- actionResult = false;
- } break;
- }
- } break;
- case EBAT_Draw_Silver :
- {
- switch ( stage )
- {
- case BS_Pressed :
- {
- if( !IsActionAllowed(EIAB_DrawWeapon) )
- {
- thePlayer.DisplayActionDisallowedHudMessage(EIAB_DrawWeapon);
- actionResult = false;
- break;
- }
- if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'silversword' ) )
- {
- OnEquipMeleeWeapon( PW_Silver, false, true );
- }
- actionResult = false;
- } break;
- default :
- {
- actionResult = false;
- } break;
- }
- } break;
- case EBAT_Sheathe_Sword :
- {
- switch ( stage )
- {
- case BS_Pressed :
- {
- if( GetCurrentMeleeWeaponType() == PW_Silver )
- {
- if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'silversword' ) )
- {
- OnEquipMeleeWeapon( PW_Silver, false, true );
- }
- }
- else if( GetCurrentMeleeWeaponType() == PW_Steel )
- {
- if( GetWitcherPlayer().IsItemEquippedByCategoryName( 'steelsword' ) )
- {
- OnEquipMeleeWeapon( PW_Steel, false, true );
- }
- }
- actionResult = false;
- } break;
- default :
- {
- actionResult = false;
- } break;
- }
- } break;
- default:
- return false;
- }
- CleanCombatActionBuffer();
- if (actionResult)
- {
- SetCombatAction( action ) ;
- if(GetWitcherPlayer().IsInFrenzy())
- GetWitcherPlayer().SkillFrenzyFinish(0);
- }
- return true;
- }
- public function CleanCombatActionBuffer()
- {
- BufferCombatAction = EBAT_EMPTY;
- BufferAllSteps = false;
- }
- public function CancelHoldAttacks()
- {
- RemoveTimer( 'IsSpecialLightAttackInputHeld' );
- RemoveTimer( 'IsSpecialHeavyAttackInputHeld' );
- RemoveTimer( 'SpecialAttackLightSustainCost' );
- RemoveTimer( 'SpecialAttackHeavySustainCost' );
- RemoveTimer( 'UpdateSpecialAttackLightHeading' );
- UnblockAction( EIAB_Crossbow, 'SpecialAttack' );
- ResumeStaminaRegen('WhirlSkill');
- if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_SpecialAttack && GetBehaviorVariable( 'isPerformingSpecialAttack' ) == 1.f )
- {
- if( GetBehaviorVariable( 'playerAttackType' ) == (int)PAT_Light )
- {
- SetAttackActionName(SkillEnumToName(S_Sword_s01));
- PushCombatActionOnBuffer( EBAT_SpecialAttack_Light, BS_Released );
- ProcessCombatActionBuffer();
- ((W3PlayerWitcherStateCombatFists) GetState('Combat')).ResetTimeToEndCombat();
- }
- else if( GetBehaviorVariable( 'playerAttackType' ) == (int)PAT_Heavy )
- {
- SetAttackActionName(SkillEnumToName(S_Sword_s02));
- PushCombatActionOnBuffer( EBAT_SpecialAttack_Heavy, BS_Released );
- ProcessCombatActionBuffer();
- }
- }
- }
- public function RaiseAttackFriendlyEvent( actor : CActor ) : bool
- {
- var playerToTargetHeading : float;
- if ( actor && RaiseCombatActionFriendlyEvent() )
- {
- SetBehaviorVariable( 'tauntTypeForOverlay', 0.f );
- SetBehaviorVariable( 'combatActionTypeForOverlay', (int)CAT_Attack );
- if ( actor )
- actor.SignalGameplayEvent('PersonalTauntAction');
- theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'TauntAction', -1.0, 4.5f, -1, 9999, true );
- OnCombatActionStart();
- playerToTargetHeading = VecHeading( actor.GetWorldPosition() - GetWorldPosition() );
- SetCustomRotation( 'Attack', playerToTargetHeading, 0.0f, 0.3f, false );
- return true;
- }
- return false;
- }
- public function SendAttackReactionEvent()
- {
- var reactionName : name;
- reactionName = 'AttackAction';
- if ( IsNameValid(reactionName) )
- {
- theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, reactionName, -1.0, 8.0f, -1, 5, true );
- }
- theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'outOfMyWay', -1.0, 2.0f, -1, 5, true );
- }
- var forceCanAttackWhenNotInCombat : int;
- public function SetForceCanAttackWhenNotInCombat( forceMode : int )
- {
- forceCanAttackWhenNotInCombat = forceMode;
- }
- public function CanAttackWhenNotInCombat( actionType : EBufferActionType, altCast : bool, out newTarget : CActor, optional target : CGameplayEntity ) : bool
- {
- var localTargets : array<CActor>;
- var i, size : int;
- var inputHeading : float;
- var clearanceMin, clearanceMax : float;
- var attackLength : float;
- var attackAngle : float;
- var npc : CNewNPC;
- var canAttackTarget : CGameplayEntity;
- var canAttackTargetActor : CActor;
- if ( target )
- canAttackTarget = target;
- else if ( displayTarget && IsDisplayTargetTargetable() )
- canAttackTarget = displayTarget;
- else
- canAttackTarget = slideTarget;
- canAttackTargetActor = (CActor)canAttackTarget;
- if ( forceCanAttackWhenNotInCombat == 2 )
- return true;
- else if ( forceCanAttackWhenNotInCombat == 1 && ( !canAttackTarget || !canAttackTargetActor.IsHuman() ) )
- return true;
- if ( actionType == EBAT_CastSign )
- {
- if ( thePlayer.GetEquippedSign() != ST_Quen && thePlayer.GetEquippedSign() != ST_Axii )
- {
- if ( CanUseSkill( S_Magic_s20 ) )
- {
- if ( thePlayer.GetEquippedSign() == ST_Aard )
- attackLength = 6.f;
- else if ( thePlayer.GetEquippedSign() == ST_Igni )
- attackLength = 4.f;
- else
- attackLength = 6.f;
- }
- else
- {
- if ( thePlayer.GetEquippedSign() == ST_Aard )
- attackLength = 9.f;
- else if ( thePlayer.GetEquippedSign() == ST_Igni )
- attackLength = 6.f;
- else
- attackLength = 6.f;
- }
- if ( altCast )
- attackAngle = 180.f;
- else
- attackAngle = 90.f;
- if ( !lastAxisInputIsMovement )
- inputHeading = VecHeading( theCamera.GetCameraDirection() );
- else if ( lAxisReleasedAfterCounter )
- inputHeading = GetHeading();
- else
- inputHeading = GetCombatActionHeading();
- clearanceMin = 1.f;
- clearanceMax = attackLength + 1.f;
- }
- else if ( thePlayer.GetEquippedSign() == ST_Axii )
- {
- npc = (CNewNPC)canAttackTarget;
- if ( npc && npc.GetNPCType() == ENGT_Quest && !npc.HasTag(theGame.params.TAG_AXIIABLE_LOWER_CASE) && !npc.HasTag(theGame.params.TAG_AXIIABLE))
- return false;
- else if ( npc && npc.IsUsingHorse() )
- return false;
- else
- return true;
- }
- else
- return true;
- }
- else if ( actionType == EBAT_ItemUse )
- {
- attackLength = theGame.params.MAX_THROW_RANGE;
- attackAngle = 90.f;
- if ( thePlayer.lastAxisInputIsMovement )
- inputHeading = GetCombatActionHeading();
- else
- inputHeading = VecHeading( theCamera.GetCameraDirection() );
- clearanceMin = 0.8f;
- clearanceMax = attackLength + 3.f;
- }
- else
- {
- if ( actionType == EBAT_SpecialAttack_Light || actionType == EBAT_SpecialAttack_Heavy )
- {
- attackLength = 1.9f;
- attackAngle = 90.f;
- }
- else
- {
- if( thePlayer.GetCurrentMeleeWeaponType() == PW_Fists || thePlayer.GetCurrentMeleeWeaponType() == PW_None )
- attackLength = 1.2f;
- else
- attackLength = 1.9f;
- attackAngle = 90.f;
- }
- if ( lastAxisInputIsMovement )
- inputHeading = GetCombatActionHeading();
- else
- inputHeading = VecHeading( theCamera.GetCameraDirection() );
- clearanceMin = attackLength / 2.f;
- clearanceMax = attackLength + 3.f;
- }
- if ( canAttackTarget )
- {
- if ( ( canAttackTargetActor && canAttackTargetActor.IsHuman() ) || canAttackTargetActor.HasTag( 'softLock_Friendly' ) )
- {
- if ( ShouldPerformFriendlyAction( canAttackTargetActor, inputHeading, attackAngle, clearanceMin, clearanceMax ) )
- {
- SetSlideTarget( canAttackTargetActor );
- newTarget = canAttackTargetActor;
- return false;
- }
- }
- }
- return true;
- thePlayer.GetVisibleEnemies( localTargets );
- size = localTargets.Size();
- if ( size > 0 )
- {
- for ( i = size-1; i>=0; i-=1 )
- {
- if ( !localTargets[i].IsHuman() && !localTargets[i].HasTag( 'softLock_Friendly' ) )
- localTargets.Erase(i);
- }
- }
- size = localTargets.Size();
- if ( size > 0 )
- {
- for ( i = 0; i < localTargets.Size(); i += 1 )
- {
- if ( ShouldPerformFriendlyAction( localTargets[i], inputHeading, attackAngle, clearanceMin, clearanceMax ) )
- {
- SetSlideTarget( localTargets[i] );
- newTarget = localTargets[i];
- return false;
- }
- }
- }
- newTarget = NULL;
- return true;
- }
- private function ShouldPerformFriendlyAction( actor : CActor, inputHeading, attackAngle, clearanceMin, clearanceMax : float ) : bool
- {
- var npc : CNewNPC;
- var argh : float;
- var playerToTargetDist : float;
- npc = (CNewNPC)actor;
- if ( npc &&
- ( GetAttitudeBetween(thePlayer, npc) == AIA_Hostile || ( GetAttitudeBetween(thePlayer, npc) == AIA_Neutral && npc.GetNPCType() != ENGT_Guard ) ) )
- {
- }
- else
- {
- playerToTargetDist = VecDistance( this.GetWorldPosition(), actor.PredictWorldPosition( 0.5f ) );
- argh = AbsF( AngleDistance( inputHeading, VecHeading( actor.GetWorldPosition() - thePlayer.GetWorldPosition() ) ) );
- if ( AbsF( AngleDistance( inputHeading, VecHeading( actor.GetWorldPosition() - thePlayer.GetWorldPosition() ) ) ) < attackAngle )
- {
- if ( playerToTargetDist < clearanceMax )
- {
- return true;
- }
- }
- else
- {
- if ( playerToTargetDist < clearanceMin )
- {
- return true;
- }
- }
- }
- return false;
- }
- public function GetHudMessagesSize() : int
- {
- return HudMessages.Size();
- }
- public function GetHudPendingMessage() : string
- {
- return HudMessages[0];
- }
- public function DisplayHudMessage( value : string ) : void
- {
- if (value == "")
- {
- return;
- }
- if( GetHudMessagesSize() > 0 )
- {
- if( HudMessages[HudMessages.Size()-1] == value )
- {
- return;
- }
- }
- HudMessages.PushBack(value);
- }
- private final function DisallowedActionDontShowHack(action : EInputActionBlock, isTimeLock : bool) : bool
- {
- var locks : array< SInputActionLock >;
- var i : int;
- 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)) )
- {
- return true;
- }
- if( action == EIAB_ThrowBomb && ( HasBuff( EET_Hypnotized ) || HasBuff( EET_Confusion ) ) )
- {
- return false;
- }
- if(isTimeLock)
- return false;
- if(action == EIAB_OpenMeditation)
- return false;
- locks = GetActionLocks(action);
- for(i=0; i<locks.Size(); i+=1)
- {
- if(locks[i].isFromQuest || locks[i].isFromPlace)
- return false;
- }
- if ( this.IsCurrentlyUsingItemL() )
- {
- if ( action == EIAB_HeavyAttacks || action == EIAB_Parry )
- return false;
- }
- return true;
- }
- public final function DisplayActionDisallowedHudMessage(action : EInputActionBlock, optional isCombatLock : bool, optional isPlaceLock : bool, optional isTimeLock : bool, optional isDangerous : bool)
- {
- var lockType : name;
- if(action != EIAB_Undefined && DisallowedActionDontShowHack(action, isTimeLock))
- return;
- if(IsInCombat() && !IsActionCombat(action))
- isCombatLock = true;
- if(!isCombatLock && !isPlaceLock && !isTimeLock && action != EIAB_Undefined)
- {
- lockType = inputHandler.GetActionBlockedHudLockType(action);
- if(lockType == 'combat')
- isCombatLock = true;
- else if(lockType == 'place')
- isPlaceLock = true;
- else if(lockType == 'time')
- isTimeLock = true;
- }
- if(isDangerous)
- {
- DisplayHudMessage(GetLocStringByKeyExt( "message_meditation_too_dangerous" ));
- }
- else if(isCombatLock)
- {
- DisplayHudMessage(GetLocStringByKeyExt( "panel_hud_message_actionnotallowed_combat" ));
- }
- else if(isPlaceLock)
- {
- DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_here" ));
- }
- else if(isTimeLock)
- {
- DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_now" ));
- }
- }
- public function RemoveHudMessageByString(msg : string, optional allQueuedInstances : bool)
- {
- var i, j : int;
- for(i=0; i<HudMessages.Size(); i+=1)
- {
- if(HudMessages[i] == msg)
- {
- HudMessages.EraseFast(i);
- if(!allQueuedInstances)
- return;
- break;
- }
- }
- for(j=HudMessages.Size()-1; j >= i; j-=1)
- {
- if(HudMessages[i] == msg)
- {
- HudMessages.EraseFast(i);
- }
- }
- }
- public function RemoveHudMessageByIndex(idx : int)
- {
- if(idx >= 0 && idx < HudMessages.Size())
- HudMessages.Erase(idx);
- }
- function SetSettlementBlockCanter( valueAdd : int )
- {
- m_SettlementBlockCanter += valueAdd;
- }
- var countDownToStart : int;
- default countDownToStart = 0;
- function DisplayRaceStart( countDownSecondsNumber : int )
- {
- var i : int;
- countDownToStart = countDownSecondsNumber;
- for( i = countDownSecondsNumber; i > 0; i -= 1 )
- {
- DisplayHudMessage(IntToString(i));
- }
- DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_race_start"));
- AddTimer('RaceCountdown',1,true);
- }
- timer function RaceCountdown(dt : float, id : int)
- {
- var hud : CR4ScriptedHud;
- var messageModule : CR4HudModuleMessage;
- countDownToStart -= 1;
- hud = (CR4ScriptedHud)theGame.GetHud();
- if( hud )
- {
- messageModule = (CR4HudModuleMessage)hud.GetHudModule("MessageModule");
- if( messageModule )
- {
- messageModule.OnMessageHidden();
- }
- }
- if( countDownToStart <= 0 )
- {
- RemoveTimer('RaceCountdown');
- }
- }
- public function GetCountDownToStart() : int
- {
- return countDownToStart;
- }
- public function HAXE3GetContainer() : W3Container
- {
- return HAXE3Container;
- }
- public function HAXE3SetContainer( container : W3Container) : void
- {
- HAXE3Container = container;
- }
- public function HAXE3GetAutoLoot() : bool
- {
- return HAXE3bAutoLoot;
- }
- public function HAXE3SetAutoLoot( value : bool ) : void
- {
- HAXE3bAutoLoot = value;
- }
- public function GetShowHud() : bool
- {
- return bShowHud;
- }
- public function SetShowHud( value : bool ) : void
- {
- bShowHud = value;
- }
- public function DisplayItemRewardNotification( itemName : name, optional quantity : int ) : void
- {
- var hud : CR4ScriptedHud;
- hud = (CR4ScriptedHud)theGame.GetHud();
- hud.OnItemRecivedDuringScene(itemName, quantity);
- }
- function IsNewQuest( questGuid : CGUID ) : bool
- {
- var i : int;
- for(i = 0; i < displayedQuestsGUID.Size(); i += 1 )
- {
- if( displayedQuestsGUID[i] == questGuid )
- {
- return false;
- }
- }
- displayedQuestsGUID.PushBack(questGuid);
- return true;
- }
- function GetRewardMultiplierData( rewardName : name ) : SRewardMultiplier
- {
- var defaultReward : SRewardMultiplier;
- var i : int;
- for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
- {
- if( rewardsMultiplier[i].rewardName == rewardName )
- {
- return rewardsMultiplier[i];
- }
- }
- defaultReward.rewardName = rewardName;
- defaultReward.rewardMultiplier = 1.0;
- defaultReward.isItemMultiplier = false;
- return defaultReward;
- }
- function GetRewardMultiplier( rewardName : name ) : float
- {
- var i : int;
- for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
- {
- if( rewardsMultiplier[i].rewardName == rewardName )
- {
- return rewardsMultiplier[i].rewardMultiplier;
- }
- }
- return 1.0;
- }
- function GetRewardMultiplierExists( rewardName : name ) : bool
- {
- var i : int;
- for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
- {
- if( rewardsMultiplier[i].rewardName == rewardName )
- {
- return true;
- }
- }
- return false;
- }
- function SetRewardMultiplier( rewardName : name, value : float, optional isItemMultiplier : bool ) : void
- {
- var i : int;
- var rewardMultiplier : SRewardMultiplier;
- for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
- {
- if( rewardsMultiplier[i].rewardName == rewardName )
- {
- rewardsMultiplier[i].rewardMultiplier = value;
- rewardsMultiplier[i].isItemMultiplier = isItemMultiplier;
- return;
- }
- }
- rewardMultiplier.rewardName = rewardName;
- rewardMultiplier.rewardMultiplier = value;
- rewardMultiplier.isItemMultiplier = isItemMultiplier;
- rewardsMultiplier.PushBack(rewardMultiplier);
- }
- function RemoveRewardMultiplier( rewardName : name ) : void
- {
- var i : int;
- for(i = 0; i < rewardsMultiplier.Size(); i += 1 )
- {
- if( rewardsMultiplier[i].rewardName == rewardName )
- {
- rewardsMultiplier.Erase(i);
- return;
- }
- }
- }
- public final function TissueExtractorDischarge() : bool
- {
- var ids : array<SItemUniqueId>;
- var chargesLeft, uses, curr, max, red, blue, green : int;
- var i : int;
- var text : string;
- ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
- if( ids.Size() == 0 )
- {
- return false;
- }
- curr = GetTissueExtractorChargesCurr();
- max = GetTissueExtractorChargesMax();
- if( curr >= max )
- {
- uses = FloorF( ( ( float ) curr ) / ( ( float ) max ) );
- chargesLeft = Max( 0, curr - uses * max );
- inv.SetItemModifierInt( ids[0], 'charges', chargesLeft );
- blue = 0;
- green = 0;
- red = 0;
- for( i=0; i<uses; i+=1 )
- {
- switch( RandRange( 3 ) )
- {
- case 0:
- blue += 1;
- break;
- case 1:
- green += 1;
- break;
- case 2:
- red += 1;
- }
- }
- text = GetLocStringByKeyExt( "message_q705_extractor_extracted" );
- if( blue > 0 )
- {
- inv.AddAnItem( 'Greater mutagen blue', blue, false, true );
- text += "<br/>" + blue + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen blue' ) );
- }
- if( green > 0 )
- {
- inv.AddAnItem( 'Greater mutagen green', green, false, true );
- text += "<br/>" + green + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen green' ) );
- }
- if( red > 0 )
- {
- inv.AddAnItem( 'Greater mutagen red', red, false, true );
- text += "<br/>" + red + "x " + GetLocStringByKey( inv.GetItemLocalizedNameByName( 'Greater mutagen red' ) );
- }
- theGame.GetGuiManager().ShowNotification( text );
- inv.SetItemModifierInt( ids[0], 'ui_notified', 0 );
- return true;
- }
- else
- {
- theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_q705_extractor_too_few_charges" ) );
- }
- return false;
- }
- public final function TissueExtractorIncCharge()
- {
- var ids : array<SItemUniqueId>;
- var uiData : SInventoryItemUIData;
- var curr : int;
- ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
- if( ids.Size() == 0 )
- {
- return;
- }
- curr = GetTissueExtractorChargesCurr() + 1;
- inv.SetItemModifierInt( ids[0], 'charges', curr );
- if( curr >= GetTissueExtractorChargesMax() )
- {
- uiData = inv.GetInventoryItemUIData( ids[0] );
- uiData.isNew = true;
- inv.SetInventoryItemUIData( ids[0], uiData );
- if( inv.GetItemModifierInt( ids[0], 'ui_notified', 0 ) == 0 )
- {
- inv.SetItemModifierInt( ids[0], 'ui_notified', 1 );
- theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_q705_extractor_charged" ), , true );
- }
- }
- }
- public final function GetTissueExtractorChargesCurr() : int
- {
- var ids : array<SItemUniqueId>;
- ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
- if( ids.Size() == 0 )
- {
- return 0;
- }
- return inv.GetItemModifierInt( ids[0], 'charges', 0 );
- }
- public final function GetTissueExtractorChargesMax() : int
- {
- var ids : array<SItemUniqueId>;
- var val : SAbilityAttributeValue;
- ids = thePlayer.inv.GetItemsByName( 'q705_tissue_extractor' );
- if( ids.Size() == 0 )
- {
- return 0;
- }
- val = inv.GetItemAttributeValue( ids[0], 'maxCharges' );
- return FloorF( val.valueBase );
- }
- public function GetEquippedSword(steel : bool) : SItemUniqueId;
- public final function HasRequiredLevelToEquipItem(item : SItemUniqueId) : bool
- {
- if(HasBuff(EET_WolfHour))
- {
- if((inv.GetItemLevel(item) - 2) > GetLevel() )
- return false;
- }
- else
- {
- if(inv.GetItemLevel(item) > GetLevel() )
- return false;
- }
- return true;
- }
- public function SkillReduceBombAmmoBonus()
- {
- var i, ammo, maxAmmo : int;
- var items : array<SItemUniqueId>;
- items = inv.GetSingletonItems();
- for(i=0; i<items.Size(); i+=1)
- {
- ammo = inv.GetItemModifierInt(items[i], 'ammo_current');
- if(ammo > 0)
- {
- maxAmmo = inv.SingletonItemGetMaxAmmo(items[i]);
- if(ammo > maxAmmo)
- {
- inv.SetItemModifierInt(items[i], 'ammo_current', maxAmmo);
- }
- }
- }
- theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnAmmoChanged );
- }
- public function ConsumeItem( itemId : SItemUniqueId ) : bool
- {
- var params : SCustomEffectParams;
- var buffs : array<SEffectInfo>;
- var i : int;
- var category : name;
- var potionToxicity : float;
- if(!inv.IsIdValid(itemId))
- return false;
- category = inv.GetItemCategory(itemId);
- if(category == 'edibles' || inv.ItemHasTag(itemId, 'Drinks') || ( category == 'alchemy_ingredient' && inv.ItemHasTag(itemId, 'Alcohol')) )
- {
- if(IsFistFightMinigameEnabled())
- {
- DisplayActionDisallowedHudMessage(EIAB_Undefined, false, false, true);
- return false;
- }
- inv.GetItemBuffs(itemId, buffs);
- for(i=0; i<buffs.Size(); i+=1)
- {
- params.effectType = buffs[i].effectType;
- params.creator = this;
- params.sourceName = "edible";
- params.customAbilityName = buffs[i].effectAbilityName;
- AddEffectCustom(params);
- }
- if ( inv.ItemHasTag(itemId, 'Alcohol') )
- {
- potionToxicity = CalculateAttributeValue(inv.GetItemAttributeValue(itemId, 'toxicity'));
- abilityManager.GainStat(BCS_Toxicity, potionToxicity );
- AddEffectDefault(EET_Drunkenness, NULL, inv.GetItemName(itemId));
- }
- PlayItemConsumeSound( itemId );
- }
- if(inv.IsItemFood(itemId))
- FactsAdd("consumed_food_cnt");
- if(!inv.ItemHasTag(itemId, theGame.params.TAG_INFINITE_USE) && !inv.RemoveItem(itemId))
- {
- LogAssert(false,"Failed to remove consumable item from player inventory!" + inv.GetItemName( itemId ) );
- return false;
- }
- return true;
- }
- public function MountVehicle( vehicleEntity : CEntity, mountType : EVehicleMountType, optional vehicleSlot : EVehicleSlot )
- {
- var vehicle : CVehicleComponent;
- vehicle = (CVehicleComponent)(vehicleEntity.GetComponentByClassName('CVehicleComponent'));
- if ( vehicle )
- vehicle.Mount( this, mountType, vehicleSlot );
- }
- public function DismountVehicle( vehicleEntity : CEntity, dismountType : EDismountType )
- {
- var vehicle : CVehicleComponent;
- vehicle = (CVehicleComponent)(vehicleEntity.GetComponentByClassName('CVehicleComponent'));
- if ( vehicle )
- vehicle.IssueCommandToDismount( dismountType );
- }
- protected function ShouldDrainStaminaWhileSprinting() : bool
- {
- if( HasBuff( EET_PolishedGenitals ) && !IsInCombat() && !IsThreatened() )
- {
- return false;
- }
- return super.ShouldDrainStaminaWhileSprinting();
- }
- public function HasStaminaToUseAction(action : EStaminaActionType, optional abilityName : name, optional dt :float, optional multiplier : float) : bool
- {
- var cost : float;
- var ret : bool;
- ret = super.HasStaminaToUseAction(action, abilityName, dt, multiplier);
- if(!ret)
- {
- SetCombatActionHeading( GetHeading() );
- if(multiplier == 0)
- multiplier = 1;
- cost = multiplier * GetStaminaActionCost(action, abilityName, dt);
- SetShowToLowStaminaIndication(cost);
- }
- return ret;
- }
- timer function AbilityManager_FloorStaminaSegment(dt : float, id : int)
- {
- ((W3PlayerAbilityManager)abilityManager).FloorStaminaSegment();
- }
- public function DrainToxicity(amount : float )
- {
- if(abilityManager && abilityManager.IsInitialized() && IsAlive())
- abilityManager.DrainToxicity(amount);
- }
- public function DrainFocus(amount : float )
- {
- if(abilityManager && abilityManager.IsInitialized() && IsAlive())
- abilityManager.DrainFocus(amount);
- }
- public function GetOffenseStat():int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetOffenseStat();
- return 0;
- }
- public function GetDefenseStat():int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetDefenseStat();
- return 0;
- }
- public function GetSignsStat():float
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSignsStat();
- return 0;
- }
- private var inWaterTrigger : bool;
- event OnOceanTriggerEnter()
- {
- inWaterTrigger = true;
- }
- event OnOceanTriggerLeave()
- {
- inWaterTrigger = false;
- }
- public function IsInWaterTrigger() : bool
- {
- return inWaterTrigger;
- }
- public function GetSkillColor(skill : ESkill) : ESkillColor
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillColor(skill);
- return SC_None;
- }
- public function GetSkillSlotIndexFromSkill(skill : ESkill) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIndexFromSkill(skill);
- return -1;
- }
- public final function GetSkillSlotIndex(slotID : int, checkIfUnlocked : bool) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIndex(slotID, checkIfUnlocked);
- return -1;
- }
- public final function GetSkillSlotIDFromIndex(skillSlotIndex : int) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotIDFromIndex(skillSlotIndex);
- return -1;
- }
- public function GetSkillSlotID(skill : ESkill) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotID(skill);
- return -1;
- }
- public function GetSkillGroupBonus(groupID : int) : name
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetGroupBonus(groupID);
- return '';
- }
- public function GetGroupBonusCount(commonColor : ESkillColor,groupID : int) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillGroupColorCount(commonColor, groupID);
- return 0;
- }
- public function GetMutagenSlotIDFromGroupID(groupID : int) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetMutagenSlotIDFromGroupID(groupID);
- return -1;
- }
- public function GetSkillLevel(skill : ESkill) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillLevel(skill);
- return -1;
- }
- public function GetBoughtSkillLevel(skill : ESkill) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetBoughtSkillLevel(skill);
- return -1;
- }
- public function AddSkill(skill : ESkill, optional isTemporary : bool)
- {
- if(abilityManager && abilityManager.IsInitialized())
- ((W3PlayerAbilityManager)abilityManager).AddSkill(skill, isTemporary);
- }
- public function AddMultipleSkills(skill : ESkill, optional number : int, optional isTemporary : bool)
- {
- var i : int;
- if(number)
- {
- for( i=0; i<number; i+=1)
- {
- AddSkill(skill,isTemporary);
- }
- }
- else
- {
- AddSkill(skill,isTemporary);
- }
- }
- public function GetSkillAbilityName(skill : ESkill) : name
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillAbilityName(skill);
- return '';
- }
- public function HasStaminaToUseSkill(skill : ESkill, optional perSec : bool, optional signHack : bool) : bool
- {
- var ret : bool;
- var cost : float;
- cost = GetSkillStaminaUseCost(skill, perSec);
- ret = ( CanUseSkill(skill) && (abilityManager.GetStat(BCS_Stamina, signHack) >= cost) );
- if(!ret && IsSkillSign(skill) && CanUseSkill(S_Perk_09) && GetStat(BCS_Focus) >= 1)
- {
- ret = true;
- }
- if( !ret && IsSkillSign( skill ) && GetWitcherPlayer().HasBuff( EET_GryphonSetBonus ) )
- {
- ret = true;
- }
- if(!ret)
- {
- SetCombatActionHeading( GetHeading() );
- SetShowToLowStaminaIndication(cost);
- }
- return ret;
- }
- protected function GetSkillStaminaUseCost(skill : ESkill, optional perSec : bool) : float
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillStaminaUseCost(skill, perSec);
- return 0;
- }
- public function GetSkillAttributeValue(skill : ESkill, attributeName : name, addBaseCharAttribute : bool, addSkillModsAttribute : bool) : SAbilityAttributeValue
- {
- var null : SAbilityAttributeValue;
- if(abilityManager && abilityManager.IsInitialized())
- return abilityManager.GetSkillAttributeValue(SkillEnumToName(skill), attributeName, addBaseCharAttribute, addSkillModsAttribute);
- return null;
- }
- public function GetSkillLocalisationKeyName(skill : ESkill) : string
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillLocalisationKeyName(skill);
- return "";
- }
- public function GetSkillLocalisationKeyDescription(skill : ESkill) : string
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillLocalisationKeyDescription(skill);
- return "";
- }
- public function GetSkillIconPath(skill : ESkill) : string
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillIconPath(skill);
- return "";
- }
- public function HasLearnedSkill(skill : ESkill) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).HasLearnedSkill(skill);
- return false;
- }
- public function IsSkillEquipped(skill : ESkill) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).IsSkillEquipped(skill);
- return false;
- }
- public function CanUseSkill(skill : ESkill) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).CanUseSkill(skill);
- return false;
- }
- public function CanLearnSkill(skill : ESkill) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).CanLearnSkill(skill);
- return false;
- }
- public function HasSpentEnoughPoints(skill : ESkill) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).HasSpentEnoughPoints(skill);
- return false;
- }
- public function PathPointsForSkillsPath(skill : ESkill) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).PathPointsSpentInSkillPathOfSkill(skill);
- return -1;
- }
- public function GetPlayerSkills() : array<SSkill>
- {
- var null : array<SSkill>;
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkills();
- return null;
- }
- public function GetPlayerSkill(s : ESkill) : SSkill
- {
- var null : SSkill;
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkill(s);
- return null;
- }
- public function GetSkillSubPathType(s : ESkill) : ESkillSubPath
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillSubPathType(s);
- return ESSP_NotSet;
- }
- public function GetSkillSlotsCount() : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillSlotsCount();
- return 0;
- }
- public function GetSkillSlots() : array<SSkillSlot>
- {
- var null : array<SSkillSlot>;
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillSlots();
- return null;
- }
- public function GetPlayerSkillMutagens() : array<SMutagenSlot>
- {
- var null : array<SMutagenSlot>;
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetPlayerSkillMutagens();
- return null;
- }
- public function BlockSkill(skill : ESkill, block : bool, optional cooldown : float) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).BlockSkill(skill, block, cooldown);
- return false;
- }
- public function IsSkillBlocked(skill : ESkill) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).IsSkillBlocked(skill);
- return false;
- }
- public function EquipSkill(skill : ESkill, slotID : int) : bool
- {
- var ret : bool;
- var groupID : int;
- var pam : W3PlayerAbilityManager;
- if(abilityManager && abilityManager.IsInitialized())
- {
- pam = (W3PlayerAbilityManager)abilityManager;
- ret = pam.EquipSkill(skill, slotID);
- if(ret)
- {
- groupID = pam.GetSkillGroupIdFromSkillSlotId(slotID);
- LogSkillColors("Equipped <<" + GetSkillColor(skill) + ">> skill <<" + skill + ">> to group <<" + groupID + ">>");
- LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
- LogSkillColors("");
- }
- return ret;
- }
- return false;
- }
- public function UnequipSkill(slotID : int) : bool
- {
- var ret : bool;
- var groupID : int;
- var skill : ESkill;
- var pam : W3PlayerAbilityManager;
- if(abilityManager && abilityManager.IsInitialized())
- {
- pam = (W3PlayerAbilityManager)abilityManager;
- GetSkillOnSlot(slotID, skill);
- ret = pam.UnequipSkill(slotID);
- if(ret)
- {
- groupID = pam.GetSkillGroupIdFromSkillSlotId(slotID);
- LogSkillColors("Unequipped <<" + GetSkillColor(skill) + ">> skill <<" + skill + ">> from group <<" + groupID + ">>");
- LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
- LogSkillColors("");
- }
- return ret;
- }
- return false;
- }
- public function GetSkillOnSlot(slotID : int, out skill : ESkill) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillOnSlot(slotID, skill);
- skill = S_SUndefined;
- return false;
- }
- public function GetFreeSkillSlot() : int
- {
- var i, size : int;
- var skill : ESkill;
- size = ((W3PlayerAbilityManager)abilityManager).GetSkillSlotsCount();
- for(i=1; i<size; i+=1)
- {
- if(!GetSkillOnSlot(i, skill))
- continue;
- if(skill == S_SUndefined)
- return i;
- }
- return -1;
- }
- protected function Attack( hitTarget : CGameplayEntity, animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float, weaponEntity : CItemEntity)
- {
- var attackAction : W3Action_Attack;
- if(!PrepareAttackAction(hitTarget, animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime, weaponEntity, attackAction))
- return;
- if ( attackAction.IsParried() && ( ((CNewNPC)attackAction.victim).IsShielded(attackAction.attacker) || ((CNewNPC)attackAction.victim).SignalGameplayEventReturnInt('IsDefending',0) == 1 ) )
- {
- thePlayer.SetCanPlayHitAnim(true);
- thePlayer.ReactToReflectedAttack(attackAction.victim);
- }
- theTelemetry.LogWithLabel( TE_FIGHT_PLAYER_ATTACKS, attackAction.GetAttackName() );
- theGame.damageMgr.ProcessAction(attackAction);
- delete attackAction;
- }
- public function IsHeavyAttack(attackName : name) : bool
- {
- var skill : ESkill;
- var sup : bool;
- sup = super.IsHeavyAttack(attackName);
- if(sup)
- return true;
- if ( attackName == 'attack_heavy_special' )
- return true;
- skill = SkillNameToEnum(attackName);
- return skill == S_Sword_2 || skill == S_Sword_s02;
- }
- public function IsLightAttack(attackName : name) : bool
- {
- var skill : ESkill;
- var sup : bool;
- sup = super.IsLightAttack(attackName);
- if(sup)
- return true;
- skill = SkillNameToEnum(attackName);
- return skill == S_Sword_1 || skill == S_Sword_s01;
- }
- public final function ProcessWeaponCollision()
- {
- var l_stateName : name;
- var l_weaponPosition : Vector;
- var l_weaponTipPos : Vector;
- var l_collidingPosition : Vector;
- var l_offset : Vector;
- var l_normal : Vector;
- var l_slotMatrix : Matrix;
- var l_distance : float;
- var l_materialName : name;
- var l_hitComponent : CComponent;
- var l_destructibleCmp : CDestructionSystemComponent;
- var barrel : COilBarrelEntity;
- if( isCurrentlyDodging )
- return;
- l_stateName = GetCurrentStateName();
- if( !attackEventInProgress && l_stateName == 'CombatFists' )
- return;
- CalcEntitySlotMatrix('r_weapon', l_slotMatrix);
- l_weaponPosition = MatrixGetTranslation( l_slotMatrix );
- switch( l_stateName )
- {
- case 'CombatFists':
- l_offset = MatrixGetAxisX( l_slotMatrix );
- l_offset = VecNormalize( l_offset ) * 0.25f;
- break;
- default:
- l_offset = MatrixGetAxisZ( l_slotMatrix );
- l_offset = VecNormalize( l_offset ) * 1.f;
- break;
- }
- l_weaponTipPos = l_weaponPosition + l_offset;
- if( !attackEventInProgress )
- {
- if( m_LastWeaponTipPos == Vector ( 0, 0, 0 ) )
- l_distance = 0;
- else
- l_distance = VecDistance( l_weaponTipPos, m_LastWeaponTipPos ) ;
- m_LastWeaponTipPos = l_weaponTipPos;
- if( l_distance < 0.35f )
- return;
- }
- m_LastWeaponTipPos = l_weaponTipPos;
- if ( !theGame.GetWorld().StaticTraceWithAdditionalInfo( l_weaponPosition, l_weaponTipPos, l_collidingPosition, l_normal, l_materialName, l_hitComponent, m_WeaponFXCollisionGroupNames ) )
- {
- if( l_stateName == 'CombatFists' )
- {
- CalcEntitySlotMatrix('l_weapon', l_slotMatrix);
- l_weaponPosition = MatrixGetTranslation( l_slotMatrix );
- l_offset = MatrixGetAxisX( l_slotMatrix );
- l_offset = VecNormalize( l_offset ) * 0.25f;
- l_weaponTipPos = l_weaponPosition + l_offset;
- if( !theGame.GetWorld().StaticTrace( l_weaponPosition, l_weaponTipPos, l_collidingPosition, l_normal, m_WeaponFXCollisionGroupNames ) )
- {
- return;
- }
- }
- else
- {
- return;
- }
- }
- if( !m_CollisionEffect )
- {
- m_CollisionEffect = theGame.CreateEntity( m_CollisionFxTemplate, l_collidingPosition, EulerAngles(0,0,0) );
- }
- m_CollisionEffect.Teleport( l_collidingPosition );
- switch( l_stateName )
- {
- case 'CombatFists':
- m_CollisionEffect.PlayEffect('fist');
- break;
- default:
- if( m_RefreshWeaponFXType )
- {
- m_PlayWoodenFX = IsSwordWooden();
- m_RefreshWeaponFXType = false;
- }
- if( m_PlayWoodenFX )
- {
- m_CollisionEffect.PlayEffect('wood');
- }
- else
- {
- switch( l_materialName )
- {
- case 'wood_hollow':
- case 'wood_debris':
- case 'wood_solid':
- m_CollisionEffect.PlayEffect('wood');
- break;
- case 'dirt_hard':
- case 'dirt_soil':
- case 'hay':
- m_CollisionEffect.PlayEffect('fist');
- break;
- case 'stone_debris':
- case 'stone_solid':
- case 'clay_tile':
- case 'gravel_large':
- case 'gravel_small':
- case 'metal':
- case 'custom_sword':
- m_CollisionEffect.PlayEffect('sparks');
- break;
- case 'flesh':
- m_CollisionEffect.PlayEffect('blood');
- break;
- default:
- m_CollisionEffect.PlayEffect('wood');
- break;
- }
- }
- break;
- }
- if(l_hitComponent)
- {
- barrel = (COilBarrelEntity)l_hitComponent.GetEntity();
- if(barrel)
- {
- barrel.OnFireHit(NULL);
- return;
- }
- }
- l_destructibleCmp = (CDestructionSystemComponent) l_hitComponent;
- if( l_destructibleCmp && l_stateName != 'CombatFists' )
- {
- l_destructibleCmp.ApplyFracture();
- }
- }
- public function ReactToReflectedAttack( target : CGameplayEntity)
- {
- var hp, dmg : float;
- var action : W3DamageAction;
- super.ReactToReflectedAttack(target);
- theGame.VibrateControllerLight();
- }
- function GetFallDist( out fallDist : float ) : bool
- {
- var fallDiff, jumpTotalDiff : float;
- substateManager.m_SharedDataO.CalculateFallingHeights( fallDiff, jumpTotalDiff );
- if ( fallDiff <= 0 )
- return false;
- fallDist = fallDiff;
- return true;
- }
- function ApplyFallingDamage(heightDiff : float, optional reducing : bool) : float
- {
- var hpPerc : float;
- var tut : STutorialMessage;
- if ( IsSwimming() || FactsQuerySum("block_falling_damage") >= 1 )
- return 0.0f;
- hpPerc = super.ApplyFallingDamage( heightDiff, reducing );
- if(hpPerc > 0)
- {
- theGame.VibrateControllerHard();
- if(IsAlive())
- {
- if(ShouldProcessTutorial('TutorialFallingDamage'))
- {
- FactsSet( "tutorial_falling_damage", 1 );
- }
- if(FactsQuerySum("tutorial_falling_damage") > 1 && ShouldProcessTutorial('TutorialFallingRoll'))
- {
- tut.type = ETMT_Hint;
- tut.tutorialScriptTag = 'TutorialFallingRoll';
- tut.hintPositionType = ETHPT_DefaultGlobal;
- tut.hintDurationType = ETHDT_Long;
- tut.canBeShownInMenus = false;
- tut.glossaryLink = false;
- tut.markAsSeenOnShow = true;
- theGame.GetTutorialSystem().DisplayTutorial(tut);
- }
- }
- }
- return hpPerc;
- }
- public function SetShowToLowStaminaIndication( value : float ) : void
- {
- fShowToLowStaminaIndication = value;
- }
- public function GetShowToLowStaminaIndication() : float
- {
- return fShowToLowStaminaIndication;
- }
- public final function IndicateTooLowAdrenaline()
- {
- SoundEvent("gui_no_adrenaline");
- showTooLowAdrenaline = true;
- }
- protected function GotoCombatStateWithAction( initialAction : EInitialAction, optional initialBuff : CBaseGameplayEffect )
- {
- if ( this.GetCurrentActionType() == ActorAction_Exploration )
- ActionCancelAll();
- ((W3PlayerWitcherStateCombatFists)this.GetState('CombatFists')).SetupState( initialAction, initialBuff );
- this.GotoState( 'CombatFists' );
- }
- public function IsThreat( actor : CActor, optional usePrecalcs : bool ) : bool
- {
- var npc : CNewNPC;
- var dist : float;
- var targetCapsuleHeight : float;
- var isDistanceExpanded : bool;
- var distanceToTarget : float;
- var attitude : EAIAttitude;
- if (!actor)
- {
- return false;
- }
- if ( finishableEnemiesList.Contains( actor ) )
- {
- return true;
- }
- if ( !actor.IsAlive() || actor.IsKnockedUnconscious() )
- {
- return false;
- }
- npc = (CNewNPC)actor;
- if (npc && npc.IsHorse() )
- {
- return false;
- }
- if ( hostileEnemies.Contains( actor ) )
- {
- return true;
- }
- if ( GetAttitudeBetween( this, actor ) == AIA_Hostile )
- {
- if ( usePrecalcs )
- {
- distanceToTarget = Distance2DBetweenCapsuleAndPoint( actor, this ) - targetingPrecalcs.playerRadius;
- }
- else
- {
- distanceToTarget = Distance2DBetweenCapsules( this, actor );
- }
- if ( distanceToTarget < findMoveTargetDist + 5.0f )
- {
- return true;
- }
- if ( actor.IsInCombat() || this.IsHardLockEnabled() )
- {
- targetCapsuleHeight = ( (CMovingPhysicalAgentComponent)actor.GetMovingAgentComponent() ).GetCapsuleHeight();
- if ( targetCapsuleHeight >= 2.0f || npc.GetCurrentStance() == NS_Fly )
- {
- if ( distanceToTarget < 40.0f )
- {
- return true;
- }
- }
- }
- }
- if ( actor.GetAttitudeGroup() == 'npc_charmed' )
- {
- if ( theGame.GetGlobalAttitude( GetBaseAttitudeGroup(), actor.GetBaseAttitudeGroup() ) == AIA_Hostile )
- {
- return true;
- }
- }
- return false;
- }
- function SetBIsCombatActionAllowed ( flag : bool )
- {
- bIsCombatActionAllowed = flag;
- if ( !flag )
- {
- SetBIsInCombatAction(true);
- }
- else
- {
- this.ProcessLAxisCaching();
- }
- }
- function GetBIsCombatActionAllowed() : bool
- {
- return bIsCombatActionAllowed;
- }
- function SetCombatAction( action : EBufferActionType )
- {
- currentCombatAction = action;
- }
- function GetCombatAction() : EBufferActionType
- {
- return currentCombatAction;
- }
- protected function WhenCombatActionIsFinished()
- {
- if(IsThrowingItem() || IsThrowingItemWithAim() )
- {
- if(inv.IsItemBomb(selectedItemId))
- {
- BombThrowAbort();
- }
- else
- {
- ThrowingAbort();
- }
- }
- if ( this.GetCurrentStateName() != 'DismountHorse' )
- OnRangedForceHolster( true );
- }
- public function IsInCombatAction_Attack(): bool
- {
- if ( IsInCombatAction_NonSpecialAttack() || IsInCombatAction_SpecialAttack() )
- return true;
- else
- return false;
- }
- public function IsInCombatAction_NonSpecialAttack(): bool
- {
- if ( IsInCombatAction() && ( GetCombatAction() == EBAT_LightAttack || GetCombatAction() == EBAT_HeavyAttack ) )
- return true;
- else
- return false;
- }
- public function IsInSpecificCombatAction ( specificCombatAction : EBufferActionType ) : bool
- {
- if ( IsInCombatAction() && GetCombatAction() == specificCombatAction )
- return true;
- else
- return false;
- }
- public function IsInRunAnimation() : bool
- {
- return isInRunAnimation;
- }
- public function SetCombatIdleStance( stance : float )
- {
- SetBehaviorVariable( 'combatIdleStance', stance );
- SetBehaviorVariable( 'CombatStanceForOverlay', stance );
- if ( stance == 0.f )
- LogChannel( 'ComboInput', "combatIdleStance = Left" );
- else
- LogChannel( 'ComboInput', "combatIdleStance = Right" );
- }
- public function GetCombatIdleStance() : float
- {
- return GetBehaviorVariable( 'combatIdleStance' );
- }
- protected var isRotatingInPlace : bool;
- event OnRotateInPlaceStart()
- {
- isRotatingInPlace = true;
- }
- event OnRotateInPlaceEnd()
- {
- isRotatingInPlace = false;
- }
- event OnFullyBlendedIdle()
- {
- if ( bLAxisReleased )
- {
- ResetRawPlayerHeading();
- ResetCachedRawPlayerHeading();
- defaultLocomotionController.ResetMoveDirection();
- }
- }
- private var isInIdle : bool;
- event OnPlayerIdleStart()
- {
- isInIdle = true;
- }
- event OnPlayerIdleEnd()
- {
- isInIdle = false;
- }
- public function IsInIdle() : bool
- {
- return isInIdle;
- }
- event OnRunLoopStart()
- {
- EnableRunCamera( true );
- }
- event OnRunLoopEnd()
- {
- EnableRunCamera( false );
- }
- event OnCombatActionStartBehgraph()
- {
- var action : EBufferActionType;
- var cost, delay : float;
- OnCombatActionStart();
- action = PerformingCombatAction();
- switch ( action )
- {
- case EBAT_LightAttack :
- {
- abilityManager.GetStaminaActionCost(ESAT_LightAttack, cost, delay);
- } break;
- case EBAT_HeavyAttack :
- {
- abilityManager.GetStaminaActionCost(ESAT_HeavyAttack, cost, delay);
- } break;
- case EBAT_ItemUse :
- {
- abilityManager.GetStaminaActionCost(ESAT_UsableItem, cost, delay);
- } break;
- case EBAT_Parry :
- {
- abilityManager.GetStaminaActionCost(ESAT_Parry, cost, delay);
- } break;
- case EBAT_Dodge :
- {
- abilityManager.GetStaminaActionCost(ESAT_Dodge, cost, delay);
- } break;
- case EBAT_Roll :
- abilityManager.GetStaminaActionCost(ESAT_Roll, cost, delay);
- break;
- case EBAT_SpecialAttack_Light :
- {
- abilityManager.GetStaminaActionCost(ESAT_Ability, cost, delay, 0,0, GetSkillAbilityName(S_Sword_s01));
- } break;
- case EBAT_SpecialAttack_Heavy :
- {
- abilityManager.GetStaminaActionCost(ESAT_Ability, cost, delay, 0,0, GetSkillAbilityName(S_Sword_s02));
- } break;
- case EBAT_Roll :
- {
- abilityManager.GetStaminaActionCost(ESAT_Evade, cost, delay);
- } break;
- default :
- ;
- }
- if( delay > 0 )
- PauseStaminaRegen( 'InsideCombatAction' );
- }
- public function HolsterUsableItem() : bool
- {
- return holsterUsableItem;
- }
- private var isInGuardedState : bool;
- public function IsInGuardedState() : bool
- {
- return isInGuardedState;
- }
- event OnGuardedStart()
- {
- isInParryOrCounter = true;
- isInGuardedState = true;
- }
- event OnGuardedEnd()
- {
- isInParryOrCounter = false;
- isInGuardedState = false;
- }
- private var restoreUsableItem : bool;
- private var holsterUsableItem : bool;
- event OnCombatActionStart()
- {
- BlockAction( EIAB_UsableItem, 'OnCombatActionStart' );
- BlockAction( EIAB_CallHorse, 'OnCombatActionStart' );
- LogChannel('combatActionAllowed',"FALSE OnCombatActionStart");
- SetBIsCombatActionAllowed( false );
- SetBIsInputAllowed( false, 'OnCombatActionStart' );
- ClearFinishableEnemyList( 0.f, 0 );
- bIsInHitAnim = false;
- if ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
- {
- CleanCombatActionBuffer();
- SetIsAimingCrossbow( false );
- OnRangedForceHolster( false, true );
- }
- holsterUsableItem = false;
- if ( thePlayer.IsHoldingItemInLHand() )
- {
- if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_CastSign )
- holsterUsableItem = true;
- else if ( GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
- {
- if ( this.GetCurrentStateName() == 'CombatFists' )
- holsterUsableItem = true;
- }
- }
- if ( holsterUsableItem )
- {
- thePlayer.SetPlayerActionToRestore ( PATR_None );
- thePlayer.OnUseSelectedItem( true );
- restoreUsableItem = true;
- }
- if ( GetBehaviorVariable( 'combatActionType' ) != (int)CAT_Attack && GetBehaviorVariable( 'combatActionType' ) != (int)CAT_PreAttack )
- {
- RemoveTimer( 'ProcessAttackTimer' );
- RemoveTimer( 'AttackTimerEnd' );
- UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
- }
- else
- {
- BlockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
- }
- }
- var isInParryOrCounter : bool;
- event OnParryOrCounterStart()
- {
- isInParryOrCounter = true;
- OnCombatActionStartBehgraph();
- }
- event OnParryOrCounterEnd()
- {
- isInParryOrCounter = false;
- OnCombatActionEnd();
- SetBIsInCombatAction( false );
- }
- event OnCombatActionEnd()
- {
- var item : SItemUniqueId;
- var combatActionType : float;
- super.OnCombatActionEnd();
- BlockAllActions( 'OnCombatActionStart', false );
- UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
- UnblockAction( EIAB_Movement, 'CombatActionFriendly' );
- oTCameraOffset = 0.f;
- oTCameraPitchOffset = 0.f;
- SetBIsCombatActionAllowed( true );
- SetBIsInputAllowed( true, 'OnCombatActionEnd' );
- SetCanPlayHitAnim( true );
- EnableFindTarget( true );
- SetFinisherVictim( NULL );
- OnBlockAllCombatTickets( false );
- LogStamina("CombatActionEnd");
- SetAttackActionName('');
- combatActionType = GetBehaviorVariable('combatActionType');
- if(GetBehaviorVariable('combatActionType') == (int)CAT_SpecialAttack)
- {
- theGame.GetGameCamera().StopAnimation( 'camera_shake_loop_lvl1_1' );
- OnSpecialAttackHeavyActionProcess();
- }
- substateManager.ReactToChanceToFallAndSlide();
- }
- event OnCombatActionFriendlyStart()
- {
- SetBIsInCombatActionFriendly(true);
- BlockAction( EIAB_Movement, 'CombatActionFriendly', false, false, false );
- OnCombatActionStart();
- }
- event OnCombatActionFriendlyEnd()
- {
- SetBIsInCombatActionFriendly(false);
- UnblockAction( EIAB_Movement, 'CombatActionFriendly' );
- OnCombatActionEnd();
- SetBIsInCombatAction(false);
- }
- event OnHitStart()
- {
- var timeLeft : float;
- var currentEffects : array<CBaseGameplayEffect>;
- var none : SAbilityAttributeValue;
- CancelHoldAttacks();
- WhenCombatActionIsFinished();
- if ( isInFinisher )
- {
- if ( finisherTarget )
- ( (CNewNPC)finisherTarget ).SignalGameplayEvent( 'FinisherInterrupt' );
- isInFinisher = false;
- finisherTarget = NULL;
- SetBIsCombatActionAllowed( true );
- }
- bIsInHitAnim = true;
- OnCombatActionStart();
- ResumeStaminaRegen( 'InsideCombatAction' );
- if( GetHealthPercents() < 0.3f )
- {
- PlayBattleCry('BattleCryBadSituation', 0.10f, true );
- }
- else
- {
- PlayBattleCry('BattleCryBadSituation', 0.05f, true );
- }
- }
- event OnHitStartSwimming()
- {
- OnRangedForceHolster( true, true, false );
- }
- private var finisherSaveLock : int;
- event OnFinisherStart()
- {
- var currentEffects : array<CBaseGameplayEffect>;
- theGame.CreateNoSaveLock("Finisher",finisherSaveLock,true,false);
- isInFinisher = true;
- finisherTarget = slideTarget;
- OnCombatActionStart();
- CancelHoldAttacks();
- PlayFinisherCameraAnimation( theGame.GetSyncAnimManager().GetFinisherCameraAnimName() );
- this.AddAnimEventCallback('SyncEvent','OnFinisherAnimEvent_SyncEvent');
- SetImmortalityMode( AIM_Invulnerable, AIC_SyncedAnim );
- }
- public function IsPerformingFinisher() : bool
- {
- return isInFinisher;
- }
- private function PlayFinisherCameraAnimation( cameraAnimName : name )
- {
- var camera : CCustomCamera = theGame.GetGameCamera();
- var animation : SCameraAnimationDefinition;
- if( IsLastEnemyKilled() && theGame.GetWorld().NavigationCircleTest( this.GetWorldPosition(), 3.f ) )
- {
- camera.StopAnimation('camera_shake_hit_lvl3_1' );
- animation.animation = cameraAnimName;
- animation.priority = CAP_Highest;
- animation.blendIn = 0.15f;
- animation.blendOut = 1.0f;
- animation.weight = 1.f;
- animation.speed = 1.0f;
- animation.reset = true;
- camera.PlayAnimation( animation );
- thePlayer.EnableManualCameraControl( false, 'Finisher' );
- }
- }
- public function IsLastEnemyKilled() : bool
- {
- var tempMoveTargets : array<CActor>;
- FindMoveTarget();
- tempMoveTargets = GetMoveTargets();
- if ( tempMoveTargets.Size() <= 0 || !thePlayer.IsThreat( tempMoveTargets[0] ) )
- return true;
- return false;
- }
- event OnFinisherAnimEvent_SyncEvent( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
- {
- if ( finisherTarget )
- ( (CNewNPC)finisherTarget ).SignalGameplayEvent('FinisherKill');
- finisherTarget = NULL;
- }
- event OnFinisherEnd()
- {
- isInFinisher = false;
- finisherTarget = NULL;
- theGame.ReleaseNoSaveLock(finisherSaveLock);
- this.RemoveAnimEventCallback('SyncEvent');
- SetImmortalityMode( AIM_None, AIC_SyncedAnim );
- theGame.RemoveTimeScale( 'AnimEventSlomoMo' );
- AddTimer( 'FinisherEndEnableCamera', 0.5f );
- OnCombatActionEnd();
- OnCombatActionEndComplete();
- }
- private timer function FinisherEndEnableCamera( dt : float, id : int )
- {
- thePlayer.EnableManualCameraControl( true, 'Finisher' );
- }
- public function SpawnFinisherBlood()
- {
- var weaponEntity : CEntity;
- var weaponSlotMatrix : Matrix;
- var bloodFxPos : Vector;
- var bloodFxRot : EulerAngles;
- var tempEntity : CEntity;
- weaponEntity = this.GetInventory().GetItemEntityUnsafe( GetInventory().GetItemFromSlot('r_weapon') );
- weaponEntity.CalcEntitySlotMatrix( 'blood_fx_point', weaponSlotMatrix );
- bloodFxPos = MatrixGetTranslation( weaponSlotMatrix );
- bloodFxRot = this.GetWorldRotation();
- tempEntity = theGame.CreateEntity( (CEntityTemplate)LoadResource('finisher_blood'), bloodFxPos, bloodFxRot);
- tempEntity.PlayEffect('crawl_blood');
- }
- event OnCombatActionEndComplete()
- {
- var buff : CBaseGameplayEffect;
- buff = ChooseCurrentCriticalBuffForAnim();
- SetCombatAction( EBAT_EMPTY );
- UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart' );
- UnblockAction( EIAB_OpenInventory, 'OnCombatActionStart' );
- UnblockAction( EIAB_UsableItem, 'OnCombatActionStart' );
- UnblockAction( EIAB_DrawWeapon, 'OnCombatActionStart_Attack' );
- SetUnpushableTarget( NULL );
- SetBIsInCombatAction(false);
- SetIsCurrentlyDodging(false);
- SetMoveTargetChangeAllowed( true );
- SetCanPlayHitAnim( true );
- SetFinisherVictim( NULL );
- this.RemoveBuffImmunity(EET_Burning, 'AnimEvent_RemoveBurning');
- if ( rangedWeapon && rangedWeapon.GetCurrentStateName() == 'State_WeaponWait' && !buff )
- {
- ClearCustomOrientationInfoStack();
- SetSlideTarget( NULL );
- }
- UnblockAction( EIAB_Crossbow, 'OnForceHolster' );
- specialAttackCamera = false;
- bIsRollAllowed = false;
- if ( bLAxisReleased )
- {
- ResetRawPlayerHeading();
- ResetCachedRawPlayerHeading();
- }
- ReapplyCriticalBuff();
- SetBIsInputAllowed( true, 'OnCombatActionEndComplete' );
- ResumeStaminaRegen( 'InsideCombatAction' );
- bIsInHitAnim = false;
- SetBIsCombatActionAllowed( true );
- m_LastWeaponTipPos = Vector(0, 0, 0, 0 );
- this.AddTimer('FreeTickets',3.f,false);
- }
- event OnMovementFullyBlended()
- {
- SetBehaviorVariable( 'isPerformingSpecialAttack', 0.f );
- if ( restoreUsableItem )
- {
- restoreUsableItem = false;
- SetPlayerActionToRestore ( PATR_Default );
- OnUseSelectedItem();
- }
- }
- event OnCombatMovementStart()
- {
- SetCombatIdleStance( 1.f );
- OnCombatActionEndComplete();
- }
- timer function FreeTickets( dt : float, id : int )
- {
- FreeTicketAtCombatTarget();
- }
- event OnGuardedReleased(){}
- event OnPerformAttack( playerAttackType : name ){}
- event OnPerformEvade( playerEvadeType : EPlayerEvadeType ){}
- event OnInterruptAttack(){}
- event OnPerformGuard(){}
- event OnSpawnHorse(){}
- event OnDismountActionScriptCallback(){}
- event OnHorseSummonStart()
- {
- thePlayer.BlockAction(EIAB_CallHorse, 'HorseSummon');
- thePlayer.BlockAction(EIAB_Signs, 'HorseSummon');
- thePlayer.BlockAction(EIAB_Crossbow, 'HorseSummon');
- thePlayer.BlockAction(EIAB_UsableItem, 'HorseSummon');
- thePlayer.BlockAction(EIAB_ThrowBomb, 'HorseSummon');
- thePlayer.BlockAction(EIAB_SwordAttack, 'HorseSummon');
- thePlayer.BlockAction(EIAB_Jump, 'HorseSummon');
- thePlayer.BlockAction(EIAB_Dodge, 'HorseSummon');
- thePlayer.BlockAction(EIAB_LightAttacks, 'HorseSummon');
- thePlayer.BlockAction(EIAB_HeavyAttacks, 'HorseSummon');
- thePlayer.BlockAction(EIAB_SpecialAttackLight, 'HorseSummon');
- thePlayer.BlockAction(EIAB_SpecialAttackHeavy, 'HorseSummon');
- horseSummonTimeStamp = theGame.GetEngineTimeAsSeconds();
- }
- event OnHorseSummonStop()
- {
- thePlayer.BlockAllActions('HorseSummon',false);
- }
- event OnCombatActionStartVehicle( action : EVehicleCombatAction )
- {
- this.SetBIsCombatActionAllowed( false );
- if ( action != EHCA_ShootCrossbow )
- {
- SetIsAimingCrossbow( false );
- OnRangedForceHolster();
- }
- }
- event OnCombatActionEndVehicle()
- {
- this.SetBIsCombatActionAllowed( true );
- }
- protected function CriticalBuffInformBehavior(buff : CBaseGameplayEffect)
- {
- if( !CanAnimationReactToCriticalState( buff ) )
- {
- return;
- }
- SetBehaviorVariable( 'CriticalStateType', (int)GetBuffCriticalType(buff) );
- SetBehaviorVariable( 'bCriticalState', 1);
- if(CriticalBuffUsesFullBodyAnim(buff))
- RaiseEvent('CriticalState');
- SetBehaviorVariable( 'IsInAir', (int)IsInAir());
- LogCritical("Sending player critical state event for <<" + buff.GetEffectType() + ">>");
- }
- private function CanAnimationReactToCriticalState( buff : CBaseGameplayEffect ) : bool
- {
- var buffCritical : W3CriticalEffect;
- var buffCriticalDOT : W3CriticalDOTEffect;
- var isHeavyCritical : bool;
- isHeavyCritical = false;
- buffCritical = ( W3CriticalEffect ) buff;
- if( buffCritical )
- {
- isHeavyCritical = buffCritical.explorationStateHandling == ECH_HandleNow;
- }
- else
- {
- buffCriticalDOT = ( W3CriticalDOTEffect ) buff;
- if( buffCriticalDOT )
- {
- isHeavyCritical = buffCriticalDOT.explorationStateHandling == ECH_HandleNow;
- }
- }
- if( !isHeavyCritical )
- {
- if( !CanReactToCriticalState() )
- {
- return false;
- }
- }
- return true;
- }
- public function CanReactToCriticalState() : bool
- {
- return substateManager.CanReactToHardCriticalState();
- }
- event OnCriticalStateAnimStart()
- {
- var heading : float;
- var newCritical : ECriticalStateType;
- var newReqCS : CBaseGameplayEffect;
- OnCombatActionEndComplete();
- newReqCS = newRequestedCS;
- if(super.OnCriticalStateAnimStart())
- {
- RemoveTimer( 'IsItemUseInputHeld' );
- keepRequestingCriticalAnimStart = false;
- CancelHoldAttacks();
- if(!IsUsingVehicle())
- {
- newCritical = GetBuffCriticalType(newReqCS);
- if(newCritical == ECST_HeavyKnockdown
- || newCritical == ECST_Knockdown
- || newCritical == ECST_Stagger
- || newCritical == ECST_Ragdoll
- || newCritical == ECST_LongStagger )
- {
- if(newReqCS.GetCreator())
- heading = VecHeading(newReqCS.GetCreator().GetWorldPosition() - GetWorldPosition());
- else
- heading = GetHeading();
- SetCustomRotation( 'Knockdown', heading, 2160.f, 0.1f, true );
- if ( newCritical != ECST_Stagger && newCritical != ECST_LongStagger )
- substateManager.ReactOnCriticalState( true );
- }
- }
- theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'CriticalEffectStart', -1, 30.0f, -1.f, -1, true );
- return true;
- }
- return false;
- }
- public function StartCSAnim(buff : CBaseGameplayEffect) : bool
- {
- SetBehaviorVariable( 'bCriticalStopped', 0 );
- if(super.StartCSAnim(buff))
- {
- if(!CriticalBuffUsesFullBodyAnim(buff))
- {
- OnCriticalStateAnimStart();
- }
- ResumeStaminaRegen( 'InsideCombatAction' );
- keepRequestingCriticalAnimStart = true;
- AddTimer('RequestCriticalAnimStart', 0, true);
- return true;
- }
- return false;
- }
- public function CriticalEffectAnimationInterrupted(reason : string) : bool
- {
- var ret : bool;
- LogCriticalPlayer("R4Player.CriticalEffectAnimationInterrupted() - because: " + reason);
- ret = super.CriticalEffectAnimationInterrupted(reason);
- if(ret)
- {
- keepRequestingCriticalAnimStart = false;
- }
- substateManager.ReactOnCriticalState( false );
- return ret;
- }
- public function CriticalStateAnimStopped(forceRemoveBuff : bool)
- {
- LogCriticalPlayer("R4Player.CriticalStateAnimStopped() - forced: " + forceRemoveBuff);
- theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'RecoveredFromCriticalEffect', -1, 30.0f, -1.f, -1, true );
- super.CriticalStateAnimStopped(forceRemoveBuff);
- substateManager.ReactOnCriticalState( false );
- }
- timer function RequestCriticalAnimStart(dt : float, id : int)
- {
- if(keepRequestingCriticalAnimStart)
- {
- if(newRequestedCS && newRequestedCS.GetDurationLeft() > 0)
- {
- CriticalBuffInformBehavior(newRequestedCS);
- }
- else
- {
- keepRequestingCriticalAnimStart = false;
- RemoveTimer('RequestCriticalAnimStart');
- }
- }
- else
- {
- RemoveTimer('RequestCriticalAnimStart');
- }
- }
- event OnRagdollUpdate(progress : float)
- {
- SetIsInAir(progress == 0);
- }
- event OnRagdollOnGround()
- {
- TryToEndRagdollOnGround( 0.0f );
- }
- event OnRagdollInAir()
- {
- RemoveTimer('TryToEndRagdollOnGround');
- }
- event OnNoLongerInRagdoll()
- {
- RemoveTimer('TryToEndRagdollOnGround');
- }
- timer function TryToEndRagdollOnGround( td : float, optional id : int)
- {
- var critical : CBaseGameplayEffect;
- var type : EEffectType;
- critical = GetCurrentlyAnimatedCS();
- if(critical)
- {
- type = critical.GetEffectType();
- if(type == EET_Knockdown || type == EET_HeavyKnockdown || type == EET_Ragdoll)
- {
- if (critical.GetTimeActive() >= 2.5f)
- {
- SetIsInAir(false);
- RequestCriticalAnimStop();
- RemoveTimer('TryToEndRagdollOnGround');
- }
- else
- {
- AddTimer('TryToEndRagdollOnGround', 0.2f, true);
- }
- return;
- }
- }
- RemoveTimer('TryToEndRagdollOnGround');
- }
- public function RequestCriticalAnimStop(optional dontSetCriticalToStopped : bool)
- {
- var buff : CBaseGameplayEffect;
- buff = GetCurrentlyAnimatedCS();
- if(buff && !CriticalBuffUsesFullBodyAnim(buff))
- {
- CriticalStateAnimStopped(false);
- }
- if(!buff || !CriticalBuffUsesFullBodyAnim(buff))
- {
- SetBehaviorVariable( 'bCriticalState', 0);
- }
- super.RequestCriticalAnimStop(dontSetCriticalToStopped);
- }
- public function SimulateBuffTimePassing(simulatedTime : float)
- {
- effectManager.SimulateBuffTimePassing(simulatedTime);
- }
- public function AddEffectDefault(effectType : EEffectType, creat : CGameplayEntity, srcName : string, optional isSignEffect : bool) : EEffectInteract
- {
- var params : SCustomEffectParams;
- if(effectType == EET_Stagger || effectType == EET_LongStagger || effectType == EET_Knockdown || effectType == EET_HeavyKnockdown)
- {
- params.effectType = effectType;
- params.creator = creat;
- params.sourceName = srcName;
- params.isSignEffect = isSignEffect;
- if ( effectType == EET_Stagger )
- params.duration = 1.83;
- else if ( effectType == EET_LongStagger )
- params.duration = 4;
- else if ( effectType == EET_Knockdown )
- params.duration = 2.5;
- else if ( effectType == EET_HeavyKnockdown )
- params.duration = 4;
- return super.AddEffectCustom(params);
- }
- else
- {
- return super.AddEffectDefault(effectType, creat, srcName, isSignEffect);
- }
- }
- public function CheatResurrect()
- {
- var items : array< SItemUniqueId >;
- var i, size, itemLevel, maxPrice, itemPrice : int;
- var itemToEquip : SItemUniqueId;
- if(IsAlive())
- return;
- if ( !theGame.GetGuiManager().GetRootMenu() )
- {
- Log(" *** Call this function after DeathScreen appears *** ");
- return;
- }
- SetAlive(true);
- SetKinematic(true);
- EnableFindTarget( true );
- SetBehaviorVariable( 'Ragdoll_Weight', 0.f );
- RaiseForceEvent( 'RecoverFromRagdoll' );
- SetCanPlayHitAnim( true );
- SetBehaviorVariable( 'CriticalStateType', (int)ECST_None );
- GoToStateIfNew('Exploration');
- ( (CDismembermentComponent)this.GetComponent( 'Dismemberment' ) ).ClearVisibleWound();
- SetIsInAir(false);
- theInput.SetContext('Exploration');
- ResetDeathType();
- ForceUnlockAllInputActions(false);
- theGame.CloseMenu('DeathScreenMenu');
- theSound.LeaveGameState(ESGS_Death);
- abilityManager.ForceSetStat(BCS_Vitality, GetStatMax(BCS_Vitality));
- effectManager.StopVitalityRegen();
- abilityManager.ForceSetStat( BCS_Air , 100.f );
- effectManager.StopAirRegen();
- abilityManager.ForceSetStat( BCS_Stamina , 100.f );
- effectManager.StopStaminaRegen();
- abilityManager.ForceSetStat( BCS_Toxicity , 0.f );
- abilityManager.ForceSetStat( BCS_Focus , 0.f );
- GetWitcherPlayer().UpdateEncumbrance();
- if ( !inv.IsThereItemOnSlot( EES_SteelSword ) )
- {
- items = inv.GetItemsByCategory( 'steelsword' );
- }
- else if ( !inv.IsThereItemOnSlot( EES_SilverSword ) )
- {
- items = inv.GetItemsByCategory( 'silversword' );
- }
- size = items.Size();
- maxPrice = -1;
- for ( i = 0; i < size; i += 1 )
- {
- itemPrice = inv.GetItemPrice(items[i]);
- itemLevel = inv.GetItemLevel(items[i]);
- if ( itemLevel <= GetLevel() && itemPrice > maxPrice )
- {
- maxPrice = itemPrice;
- itemToEquip = items[i];
- }
- }
- if( inv.IsIdValid( itemToEquip ) )
- {
- EquipItem( itemToEquip , , true );
- }
- theGame.ReleaseNoSaveLock(deathNoSaveLock);
- }
- public function SetIsInsideInteraction(b : bool) {isInsideInteraction = b;}
- public function IsInsideInteraction() : bool {return isInsideInteraction;}
- public function SetIsInsideHorseInteraction( b : bool, horse : CEntity )
- {
- isInsideHorseInteraction = b;
- horseInteractionSource = horse;
- }
- public function IsInsideHorseInteraction() : bool {return isInsideHorseInteraction;}
- event OnInteractionActivationTest( interactionComponentName : string, activator : CEntity )
- {
- if ( interactionComponentName == "ClimbLadder" )
- {
- if( PlayerHasLadderExplorationReady() )
- {
- return true;
- }
- }
- return false;
- }
- private function PlayerHasLadderExplorationReady() : bool
- {
- if( !substateManager.CanInteract() )
- {
- return false;
- }
- if( !substateManager.m_SharedDataO.HasValidLadderExploration() )
- {
- return false;
- }
- return true;
- }
- public function SetGuarded(flag : bool)
- {
- super.SetGuarded(flag);
- if(flag && FactsQuerySum("tut_fight_use_slomo") > 0)
- {
- theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
- FactsRemove("tut_fight_slomo_ON");
- }
- }
- public function IsGuarded() : bool
- {
- return super.IsGuarded() && ( !rangedWeapon || rangedWeapon.GetCurrentStateName() == 'State_WeaponWait' );
- }
- public function GetSelectedItemId() : SItemUniqueId {return selectedItemId;}
- public function ClearSelectedItemId() {selectedItemId = GetInvalidUniqueId();}
- public function IsHoldingItemInLHand() : bool
- {
- return currentlyEquipedItemL != GetInvalidUniqueId();
- }
- public function GetCurrentlyUsedItemL () : W3UsableItem
- {
- return currentlyUsedItemL;
- }
- public function SetPlayerActionToRestore ( actionToRestoreType : EPlayerActionToRestore )
- {
- playerActionToRestore = actionToRestoreType;
- }
- public function IsCurrentlyUsingItemL () : bool
- {
- return currentlyUsingItem;
- }
- function BlockSlotsOnLItemUse ()
- {
- var slotsToBlock : array<name>;
- slotsToBlock.PushBack( 'Slot1' );
- slotsToBlock.PushBack( 'Slot2' );
- slotsToBlock.PushBack( 'Slot3' );
- slotsToBlock.PushBack( 'Slot4' );
- slotsToBlock.PushBack( 'Slot5' );
- slotsToBlock.PushBack( 'Yrden' );
- slotsToBlock.PushBack( 'Quen' );
- slotsToBlock.PushBack( 'Igni' );
- slotsToBlock.PushBack( 'Axii' );
- slotsToBlock.PushBack( 'Aard' );
- EnableRadialSlotsWithSource ( false, slotsToBlock, 'usableItemL' );
- }
- function UnblockSlotsOnLItemUse ()
- {
- var slotsToBlock : array<name>;
- slotsToBlock.PushBack( 'Slot1' );
- slotsToBlock.PushBack( 'Slot2' );
- slotsToBlock.PushBack( 'Slot3' );
- slotsToBlock.PushBack( 'Slot4' );
- slotsToBlock.PushBack( 'Slot5' );
- slotsToBlock.PushBack( 'Yrden' );
- slotsToBlock.PushBack( 'Quen' );
- slotsToBlock.PushBack( 'Igni' );
- slotsToBlock.PushBack( 'Axii' );
- slotsToBlock.PushBack( 'Aard' );
- EnableRadialSlotsWithSource ( true, slotsToBlock, 'usableItemL' );
- }
- function IsUsableItemLBlocked () : bool
- {
- return isUsableItemBlocked;
- }
- function HideUsableItem( optional force : bool )
- {
- if( currentlyEquipedItemL != GetInvalidUniqueId() )
- {
- if( force )
- {
- if( !RaiseForceEvent( 'ItemEndL' ) )
- {
- OnUsingItemsReset();
- }
- return;
- }
- RaiseEvent( 'ItemUseL' );
- }
- }
- function ProcessUsableItemsTransition ( actionToRestore : EPlayerActionToRestore )
- {
- var category : name;
- var signSkill : ESkill;
- category = inv.GetItemCategory ( selectedItemId );
- signSkill = SignEnumToSkillEnum( GetEquippedSign());
- switch ( actionToRestore )
- {
- case PATR_None:
- if ( currentlyUsedItemL )
- {
- inv.UnmountItem( currentlyEquipedItemL, true );
- }
- currentlyEquipedItemL = GetInvalidUniqueId();
- return;
- case PATR_Default:
- if ( IsSlotQuickslot( inv.GetSlotForItemId ( selectedItemId )) && category == 'usable' && currentlyEquipedItemL != selectedItemId )
- {
- if ( currentlyUsedItemL )
- {
- inv.UnmountItem( currentlyEquipedItemL, true );
- }
- currentlyEquipedItemL = GetInvalidUniqueId();
- OnUseSelectedItem();
- return;
- }
- break;
- case PATR_Crossbow:
- if ( inv.IsItemCrossbow ( selectedItemId ) )
- {
- if ( currentlyUsedItemL )
- {
- inv.UnmountItem( currentlyEquipedItemL, true );
- }
- currentlyEquipedItemL = GetInvalidUniqueId();
- SetIsAimingCrossbow( true );
- if ( theInput.IsActionPressed( 'ThrowItem' ) )
- SetupCombatAction( EBAT_ItemUse, BS_Pressed );
- else
- {
- SetupCombatAction( EBAT_ItemUse, BS_Pressed );
- SetupCombatAction( EBAT_ItemUse, BS_Released );
- }
- return;
- }
- break;
- case PATR_CastSign:
- if( signSkill != S_SUndefined && playerActionToRestore == PATR_CastSign )
- {
- if ( currentlyUsedItemL )
- {
- inv.UnmountItem( currentlyEquipedItemL, true );
- }
- currentlyEquipedItemL = GetInvalidUniqueId();
- if( HasStaminaToUseSkill( signSkill, false ) )
- {
- if( GetInvalidUniqueId() != inv.GetItemFromSlot( 'l_weapon' ) )
- PushCombatActionOnBuffer( EBAT_CastSign, BS_Pressed );
- else
- SetupCombatAction( EBAT_CastSign, BS_Pressed );
- }
- else
- {
- thePlayer.SoundEvent("gui_no_stamina");
- }
- return;
- }
- break;
- case PATR_ThrowBomb:
- if ( inv.IsItemBomb ( selectedItemId ) )
- {
- if ( currentlyUsedItemL )
- {
- inv.UnmountItem( currentlyEquipedItemL, true );
- }
- currentlyEquipedItemL = GetInvalidUniqueId();
- PrepareToAttack();
- SetupCombatAction( EBAT_ItemUse, BS_Pressed );
- return;
- }
- break;
- case PATR_CallHorse:
- theGame.OnSpawnPlayerHorse();
- break;
- default:
- if ( currentlyUsedItemL )
- {
- inv.UnmountItem( currentlyEquipedItemL, true );
- }
- currentlyEquipedItemL = GetInvalidUniqueId();
- return;
- }
- if ( currentlyUsedItemL )
- {
- inv.UnmountItem( currentlyEquipedItemL, true );
- }
- currentlyEquipedItemL = GetInvalidUniqueId();
- }
- function GetUsableItemLtransitionAllowed () : bool
- {
- return isUsableItemLtransitionAllowed;
- }
- function SetUsableItemLtransitionAllowed ( isAllowed : bool)
- {
- isUsableItemLtransitionAllowed = isAllowed;
- }
- event OnItemUseLUnBlocked ()
- {
- if ( isUsableItemBlocked )
- {
- isUsableItemBlocked = false;
- UnblockSlotsOnLItemUse ();
- }
- }
- event OnItemUseLBlocked ()
- {
- if ( !isUsableItemBlocked )
- {
- isUsableItemBlocked = true;
- BlockSlotsOnLItemUse ();
- }
- }
- event OnUsingItemsReset()
- {
- if ( currentlyUsingItem )
- {
- OnItemUseLUnBlocked ();
- OnUsingItemsComplete();
- }
- }
- event OnUsingItemsComplete ()
- {
- if ( isUsableItemBlocked )
- {
- OnItemUseLUnBlocked ();
- }
- currentlyUsingItem = false;
- if ( GetUsableItemLtransitionAllowed () )
- {
- ProcessUsableItemsTransition( playerActionToRestore );
- }
- else
- {
- if ( currentlyUsedItemL )
- {
- inv.UnmountItem( currentlyEquipedItemL, true );
- }
- currentlyEquipedItemL = GetInvalidUniqueId();
- }
- SetPlayerActionToRestore ( PATR_Default );
- }
- event OnUseSelectedItem( optional force : bool )
- {
- var category : name;
- var itemEntity : W3UsableItem;
- if ( isUsableItemBlocked && !force )
- {
- return false;
- }
- if ( IsCastingSign() )
- return false;
- if ( currentlyEquipedItemL != GetInvalidUniqueId() )
- {
- SetBehaviorVariable( 'SelectedItemL', (int)GetUsableItemTypeById( currentlyEquipedItemL ), true );
- if ( force )
- {
- if ( RaiseEvent( 'ItemEndL' ) )
- {
- SetUsableItemLtransitionAllowed ( true );
- return true;
- }
- }
- else
- {
- if ( RaiseEvent( 'ItemUseL' ) )
- {
- SetUsableItemLtransitionAllowed ( true );
- return true;
- }
- }
- }
- else
- {
- category = inv.GetItemCategory( selectedItemId );
- if( category != 'usable' )
- {
- return false;
- }
- SetBehaviorVariable( 'SelectedItemL', (int)GetUsableItemTypeById( selectedItemId ), true );
- if( RaiseEvent( 'ItemUseL' ) )
- {
- currentlyEquipedItemL = selectedItemId;
- SetUsableItemLtransitionAllowed ( false );
- currentlyUsingItem = true;
- return true;
- }
- inv.UnmountItem( selectedItemId, true );
- }
- }
- protected saved var currentlyUsingItem : bool;
- public function ProcessUseSelectedItem( itemEntity : W3UsableItem, optional shouldCallOnUsed : bool )
- {
- currentlyUsedItemL = itemEntity;
- DrainStamina(ESAT_UsableItem);
- if ( shouldCallOnUsed )
- {
- currentlyUsedItemL.OnUsed( thePlayer );
- }
- }
- function GetUsableItemTypeById ( itemId : SItemUniqueId ) : EUsableItemType
- {
- var itemName : name;
- itemName = inv.GetItemName ( itemId );
- return theGame.GetDefinitionsManager().GetUsableItemType ( itemName );
- }
- public function StartWaitForItemSpawnAndProccesTask()
- {
- AddTimer( 'WaitForItemSpawnAndProccesTask', 0.001f, true,,,,true );
- }
- public function KillWaitForItemSpawnAndProccesTask()
- {
- RemoveTimer ( 'WaitForItemSpawnAndProccesTask' );
- }
- public function AllowUseSelectedItem()
- {
- m_useSelectedItemIfSpawned = true;
- }
- timer function WaitForItemSpawnAndProccesTask( timeDelta : float , id : int )
- {
- var itemEntity : W3UsableItem;
- var canTaskBeKilled : bool;
- canTaskBeKilled = false;
- if ( IsCastingSign() )
- {
- return;
- }
- if ( selectedItemId == GetInvalidUniqueId() )
- {
- canTaskBeKilled = true;
- }
- itemEntity = (W3UsableItem)inv.GetItemEntityUnsafe( selectedItemId );
- if ( itemEntity && m_useSelectedItemIfSpawned )
- {
- canTaskBeKilled = true;
- m_useSelectedItemIfSpawned = false;
- ProcessUseSelectedItem( itemEntity, true );
- }
- if ( canTaskBeKilled )
- {
- KillWaitForItemSpawnAndProccesTask();
- }
- }
- event OnBombProjectileReleased()
- {
- ResetRawPlayerHeading();
- UnblockAction(EIAB_ThrowBomb, 'BombThrow');
- UnblockAction(EIAB_Crossbow, 'BombThrow');
- if(GetCurrentStateName() == 'AimThrow')
- PopState();
- FactsAdd("ach_bomb", 1, 4 );
- theGame.GetGamerProfile().CheckLearningTheRopes();
- }
- public function SetIsThrowingItemWithAim(b : bool)
- {
- isThrowingItemWithAim = b;
- }
- public function SetIsThrowingItem( flag : bool ) {isThrowingItem = flag;}
- public function IsThrowingItem() : bool {return isThrowingItem;}
- public function IsThrowingItemWithAim() : bool {return isThrowingItemWithAim;}
- public function SetThrowHold(b : bool) {isThrowHoldPressed = b;}
- public function IsThrowHold() : bool {return isThrowHoldPressed;}
- public function SetIsAimingCrossbow( flag : bool ) {isAimingCrossbow = flag;}
- public function GetIsAimingCrossbow() : bool {return isAimingCrossbow;}
- event OnThrowAnimLeave()
- {
- var throwStage : EThrowStage;
- var thrownEntity : CThrowable;
- thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
- if(thrownEntity && !thrownEntity.WasThrown())
- {
- throwStage = (int)GetBehaviorVariable( 'throwStage', (int)TS_Stop);
- if(inv.IsItemBomb(selectedItemId))
- {
- BombThrowCleanUp();
- }
- else
- {
- ThrowingAbort();
- }
- }
- thrownEntity = NULL;
- SetIsThrowingItem( false );
- SetIsThrowingItemWithAim( false );
- this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
- UnblockAction(EIAB_ThrowBomb, 'BombThrow');
- UnblockAction(EIAB_Crossbow, 'BombThrow');
- }
- protected function BombThrowStart()
- {
- var slideTargetActor : CActor;
- BlockAction( EIAB_ThrowBomb, 'BombThrow' );
- BlockAction(EIAB_Crossbow, 'BombThrow');
- SetBehaviorVariable( 'throwStage', (int)TS_Start );
- SetBehaviorVariable( 'combatActionType', (int)CAT_ItemThrow );
- if ( slideTarget )
- {
- AddCustomOrientationTarget( OT_Actor, 'BombThrow' );
- slideTargetActor = (CActor)( slideTarget );
- }
- else
- {
- if ( lastAxisInputIsMovement )
- AddCustomOrientationTarget( OT_Actor, 'BombThrow' );
- else
- AddCustomOrientationTarget( OT_Camera, 'BombThrow' );
- }
- UpdateLookAtTarget();
- SetCustomRotation( 'Throw', VecHeading( this.GetLookAtPosition() - GetWorldPosition() ), 0.0f, 0.3f, false );
- SetBehaviorVariable( 'itemType', (int)IT_Petard );
- ProcessCanAttackWhenNotInCombatBomb();
- if ( RaiseForceEvent('CombatAction') )
- OnCombatActionStart();
- theTelemetry.LogWithLabel(TE_FIGHT_HERO_THROWS_BOMB, inv.GetItemName( selectedItemId ));
- }
- event OnThrowAnimStart()
- {
- var itemId : SItemUniqueId;
- var thrownEntity : CThrowable;
- this.radialSlots.Clear();
- GetWitcherPlayer().GetItemEquippedOnSlot(EES_Petard1, itemId );
- if( GetSelectedItemId() == itemId )
- {
- this.radialSlots.PushBack( 'Slot2' );
- }
- else
- {
- this.radialSlots.PushBack( 'Slot1' );
- }
- this.radialSlots.PushBack( 'Slot3' );
- this.radialSlots.PushBack( 'Slot4' );
- this.radialSlots.PushBack( 'Slot5' );
- this.EnableRadialSlotsWithSource( false, this.radialSlots, 'throwBomb' );
- thrownEntity = (CThrowable)inv.GetDeploymentItemEntity( selectedItemId,,,true );
- thrownEntity.Initialize( this, selectedItemId );
- EntityHandleSet( thrownEntityHandle, thrownEntity );
- SetIsThrowingItem( true );
- }
- public function BombThrowAbort()
- {
- BombThrowCleanUp();
- UnblockAction( EIAB_ThrowBomb, 'BombThrow' );
- UnblockAction(EIAB_Crossbow, 'BombThrow');
- }
- private function BombThrowCleanUp()
- {
- var throwStage : EThrowStage;
- var thrownEntity : CThrowable;
- var vehicle : CVehicleComponent;
- thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
- this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
- throwStage = (int)GetBehaviorVariable( 'throwStage', (int)TS_Stop);
- SetBehaviorVariable( 'throwStage', (int)TS_Stop );
- if( GetCurrentStateName() == 'AimThrow')
- {
- PopState();
- thrownEntity.StopAiming( true );
- }
- else if ( this.IsUsingHorse() )
- {
- vehicle = (CVehicleComponent)(GetUsedVehicle().GetComponentByClassName('CVehicleComponent'));
- vehicle.GetUserCombatManager().OnForceItemActionAbort();
- }
- if(thrownEntity && !thrownEntity.WasThrown())
- {
- thrownEntity.BreakAttachment();
- thrownEntity.Destroy();
- }
- thrownEntity = NULL;
- SetIsThrowingItem( false );
- SetIsThrowingItemWithAim( false );
- RemoveCustomOrientationTarget( 'BombThrow' );
- }
- public function ProcessCanAttackWhenNotInCombatBomb()
- {
- var targets : array< CGameplayEntity >;
- var temp, throwVector, throwFrom, throwTo, throwVectorU : Vector;
- var temp_n : name;
- var throwVecLen : float;
- var component : CComponent;
- if( FactsQuerySum( "BombThrowSpecificTargets" ) > 0 )
- {
- throwFrom = playerAiming.GetThrowStartPosition();
- throwTo = playerAiming.GetThrowPosition();
- throwVector = throwTo - throwFrom;
- throwVecLen = VecDistance( throwFrom, throwTo );
- throwVectorU = throwVector / throwVecLen;
- if( theGame.GetWorld().StaticTraceWithAdditionalInfo( throwFrom, throwTo + throwVectorU, temp, temp, temp_n, component ) && component && component.GetEntity().HasTag( 'BombThrowSpecificTarget' ) )
- {
- SetIsShootingFriendly( false );
- }
- else
- {
- SetIsShootingFriendly( true );
- }
- }
- else if( FactsQuerySum( "BombThrowDisallowSpecificTargets" ) > 0 )
- {
- throwFrom = playerAiming.GetThrowStartPosition();
- throwTo = playerAiming.GetThrowPosition();
- throwVector = throwTo - throwFrom;
- throwVecLen = VecDistance( throwFrom, throwTo );
- throwVectorU = throwVector / throwVecLen;
- if( theGame.GetWorld().StaticTraceWithAdditionalInfo( throwFrom, throwTo + throwVectorU, temp, temp, temp_n, component ) && component && component.GetEntity().HasTag( 'BombThrowDisallowedTarget' ) )
- {
- SetIsShootingFriendly( true );
- }
- else
- {
- SetIsShootingFriendly( false );
- }
- }
- else
- {
- SetIsShootingFriendly( false );
- }
- SetBehaviorVariable( 'isShootingFriendly', (float)( GetIsShootingFriendly() ) );
- }
- public function SetIsShootingFriendly( flag : bool )
- {
- isShootingFriendly = flag;
- }
- public function GetIsShootingFriendly() : bool
- {
- return isShootingFriendly;
- }
- protected function UsableItemStart()
- {
- var thrownEntity : CThrowable;
- thrownEntity = (CThrowable)inv.GetDeploymentItemEntity( selectedItemId,,,true );
- thrownEntity.Initialize( this, selectedItemId );
- EntityHandleSet( thrownEntityHandle, thrownEntity );
- SetBehaviorVariable( 'throwStage', (int)TS_Start );
- SetIsThrowingItem( true );
- SetBehaviorVariable( 'combatActionType', (int)CAT_ItemThrow );
- if ( slideTarget )
- {
- AddCustomOrientationTarget( OT_Actor, 'UsableItems' );
- }
- else
- {
- if ( lastAxisInputIsMovement )
- AddCustomOrientationTarget( OT_Actor, 'UsableItems' );
- else
- AddCustomOrientationTarget( OT_Camera, 'UsableItems' );
- }
- SetBehaviorVariable( 'itemType', (int)(-1) );
- if ( RaiseForceEvent('CombatAction') )
- OnCombatActionStart();
- }
- protected function BombThrowRelease()
- {
- var stateName : name;
- stateName = playerAiming.GetCurrentStateName();
- OnDelayOrientationChangeOff();
- if( GetIsShootingFriendly() || ( FactsQuerySum( "BombThrowSpecificTargets" ) > 0 && stateName != 'Aiming' ) )
- {
- BombThrowAbort();
- }
- else
- {
- SetBehaviorVariable( 'throwStage', (int)TS_End );
- if ( stateName == 'Aiming' )
- {
- SetCustomRotation( 'Throw', VecHeading( this.GetLookAtPosition() - GetWorldPosition() ), 0.0f, 0.2f, false );
- }
- }
- }
- protected function UsableItemRelease()
- {
- OnDelayOrientationChangeOff();
- SetBehaviorVariable( 'throwStage', (int)TS_End );
- RemoveCustomOrientationTarget( 'UsableItems' );
- }
- public function ThrowingAbort()
- {
- var thrownEntity : CThrowable;
- thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
- SetBehaviorVariable( 'throwStage', (int)TS_Stop );
- RaiseEvent( 'actionStop' );
- if( GetCurrentStateName() == 'AimThrow')
- {
- PopState();
- thrownEntity.StopAiming( true );
- }
- if(thrownEntity && !thrownEntity.WasThrown())
- {
- thrownEntity.BreakAttachment();
- thrownEntity.Destroy();
- }
- this.EnableRadialSlotsWithSource( true, this.radialSlots, 'throwBomb' );
- }
- public function CanSetupCombatAction_Throw() : bool
- {
- if(!inv.IsIdValid( selectedItemId ))
- return false;
- if(!inv.IsItemSingletonItem(selectedItemId))
- return false;
- if(!GetBIsInputAllowed())
- return false;
- if(inv.GetItemQuantity(GetSelectedItemId()) <= 0 && !inv.ItemHasTag(selectedItemId, theGame.params.TAG_INFINITE_AMMO))
- return false;
- if(!inputHandler.IsActionAllowed(EIAB_ThrowBomb) && GetCurrentStateName() != 'Swimming')
- return false;
- return true;
- }
- public function GetThrownEntity() : CThrowable
- {
- return (CThrowable)EntityHandleGet( thrownEntityHandle );
- }
- event OnWeaponWait() { rangedWeapon.OnWeaponWait(); }
- event OnWeaponDrawStart() { rangedWeapon.OnWeaponDrawStart(); }
- event OnWeaponReloadStart() { rangedWeapon.OnWeaponReloadStart(); }
- event OnWeaponReloadEnd() { rangedWeapon.OnWeaponReloadEnd(); }
- event OnWeaponAimStart() { rangedWeapon.OnWeaponAimStart(); }
- event OnWeaponShootStart() { rangedWeapon.OnWeaponShootStart(); }
- event OnWeaponShootEnd() { rangedWeapon.OnWeaponShootEnd(); }
- event OnWeaponAimEnd() { rangedWeapon.OnWeaponAimEnd(); }
- event OnWeaponHolsterStart() { rangedWeapon.OnWeaponHolsterStart(); }
- event OnWeaponHolsterEnd() { rangedWeapon.OnWeaponHolsterEnd(); }
- event OnWeaponToNormalTransStart() { rangedWeapon.OnWeaponToNormalTransStart(); }
- event OnWeaponToNormalTransEnd() { rangedWeapon.OnWeaponToNormalTransEnd(); }
- event OnEnableAimingMode( enable : bool )
- {
- if( !crossbowDontPopStateHack )
- {
- if ( enable )
- PushState( 'AimThrow' );
- else if ( GetCurrentStateName() == 'AimThrow' )
- PopState();
- }
- }
- event OnRangedForceHolster( optional forceUpperBodyAnim, instant, dropItem : bool )
- {
- if(rangedWeapon)
- rangedWeapon.OnForceHolster( forceUpperBodyAnim, instant, dropItem );
- }
- public function IsCrossbowHeld() : bool
- {
- if (rangedWeapon)
- return rangedWeapon.GetCurrentStateName() != 'State_WeaponWait';
- return false;
- }
- event OnBlockAllCombatTickets( release : bool )
- {
- if (!release )
- ((CR4PlayerStateCombat)GetState('Combat')).OnBlockAllCombatTickets(false);
- }
- event OnForceTicketUpdate() {}
- event OnProcessActionPost(action : W3DamageAction)
- {
- var npc : CNewNPC;
- var attackAction : W3Action_Attack;
- var lifeLeech : float;
- super.OnProcessActionPost(action);
- attackAction = (W3Action_Attack)action;
- if(attackAction)
- {
- npc = (CNewNPC)action.victim;
- if(npc && npc.IsHuman() )
- {
- PlayBattleCry('BattleCryHumansHit', 0.05f );
- }
- else
- {
- PlayBattleCry('BattleCryMonstersHit', 0.05f );
- }
- if(attackAction.IsActionMelee())
- {
- IncreaseUninterruptedHitsCount();
- if( IsLightAttack( attackAction.GetAttackName() ) )
- {
- GCameraShake(0.1, false, GetWorldPosition(), 10);
- }
- if(npc && inv.GetItemName(attackAction.GetWeaponId()) == 'PC Caretaker Shovel')
- {
- lifeLeech = CalculateAttributeValue(inv.GetItemAttributeValue(attackAction.GetWeaponId() ,'lifesteal'));
- if (npc.UsesVitality())
- lifeLeech *= action.processedDmg.vitalityDamage;
- else if (UsesEssence())
- lifeLeech *= action.processedDmg.essenceDamage;
- else
- lifeLeech = 0;
- if ( lifeLeech > 0 )
- {
- inv.PlayItemEffect( attackAction.GetWeaponId(), 'stab_attack' );
- PlayEffect('drain_energy_caretaker_shovel');
- GainStat(BCS_Vitality, lifeLeech);
- }
- }
- }
- }
- }
- public function SetHitReactTransScale(f : float) {hitReactTransScale = f;}
- public function GetHitReactTransScale() : float
- {
- if ( ( (CNewNPC)slideTarget ).GetIsTranslationScaled() )
- return hitReactTransScale;
- else
- return 1.f;
- }
- public function GetHorseWithInventory() : CNewNPC
- {
- return (CNewNPC)EntityHandleGet( horseWithInventory );
- }
- public function GetHorseCurrentlyMounted() : CNewNPC
- {
- return currentlyMountedHorse;
- }
- public function _SetHorseCurrentlyMounted( horse : CNewNPC )
- {
- currentlyMountedHorse = horse;
- }
- public function WasHorseRecentlySummoned() : bool
- {
- if ( horseSummonTimeStamp + 5.f > theGame.GetEngineTimeAsSeconds() )
- return true;
- return false;
- }
- private const var MOUNT_DISTANCE_CBT : float;
- default MOUNT_DISTANCE_CBT = 3.0;
- private const var MOUNT_ANGLE_CBT : float;
- default MOUNT_ANGLE_CBT = 35.0;
- private const var MOUNT_ANGLE_EXP : float;
- default MOUNT_ANGLE_EXP = 45.0;
- public function IsMountingHorseAllowed( optional alwaysAllowedInExploration : bool ) : bool
- {
- var angle : float;
- var distance : float;
- if( IsInsideHorseInteraction() )
- {
- angle = AngleDistance( thePlayer.rawPlayerHeading, VecHeading( thePlayer.horseInteractionSource.GetWorldPosition() - thePlayer.GetWorldPosition() ) );
- if( thePlayer.IsInCombat() )
- {
- if( AbsF( angle ) < MOUNT_ANGLE_CBT )
- {
- distance = VecDistance( thePlayer.GetWorldPosition(), thePlayer.horseInteractionSource.GetWorldPosition() );
- if( distance < MOUNT_DISTANCE_CBT )
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- }
- else
- {
- if( alwaysAllowedInExploration )
- {
- return true;
- }
- else
- {
- if( AbsF( angle ) < MOUNT_ANGLE_EXP )
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- }
- }
- else
- {
- return false;
- }
- }
- public function FollowActor( actor : CActor )
- {
- var l_aiTreeDecorator : CAIPlayerActionDecorator;
- var l_aiTree_onFoot : CAIFollowSideBySideAction;
- var l_aiTree_onHorse : CAIRiderFollowSideBySideAction;
- var l_success : bool = false;
- actor.AddTag( 'playerFollowing' );
- if( thePlayer.IsUsingHorse() )
- {
- l_aiTree_onHorse = new CAIRiderFollowSideBySideAction in this;
- l_aiTree_onHorse.OnCreated();
- l_aiTree_onHorse.params.targetTag = 'playerFollowing';
- }
- else
- {
- l_aiTree_onFoot = new CAIFollowSideBySideAction in this;
- l_aiTree_onFoot.OnCreated();
- l_aiTree_onFoot.params.targetTag = 'playerFollowing';
- }
- l_aiTreeDecorator = new CAIPlayerActionDecorator in this;
- l_aiTreeDecorator.OnCreated();
- l_aiTreeDecorator.interruptOnInput = false;
- if( thePlayer.IsUsingHorse() )
- l_aiTreeDecorator.scriptedAction = l_aiTree_onHorse;
- else
- l_aiTreeDecorator.scriptedAction = l_aiTree_onFoot;
- if( l_aiTreeDecorator )
- l_success = ForceAIBehavior( l_aiTreeDecorator, BTAP_Emergency );
- else if( thePlayer.IsUsingHorse() )
- l_success = ForceAIBehavior( l_aiTree_onHorse, BTAP_Emergency );
- else
- l_success = ForceAIBehavior( l_aiTree_onFoot, BTAP_Emergency );
- if ( l_success )
- {
- GetMovingAgentComponent().SetGameplayRelativeMoveSpeed( 0.0f );
- }
- }
- public function SetCanFollowNpc( val : bool, actor : CActor ) { canFollowNpc = val; actorToFollow = actor; }
- public function CanFollowNpc() : bool { return canFollowNpc; }
- public function GetActorToFollow() : CActor { return actorToFollow; }
- public function SetIsSwimming ( toggle : bool )
- {
- if( isSwimming != toggle )
- {
- thePlayer.substateManager.SetBehaviorParamBool( 'isSwimmingForOverlay', toggle );
- isSwimming = toggle;
- }
- }
- public function RepairItemUsingConsumable(item, consumable : SItemUniqueId) : bool
- {
- var curr, max, repairValue, itemValue, repairBonus, newDurability : float;
- if(!inv.IsIdValid(item) || !inv.IsIdValid(consumable) || !inv.HasItemDurability(item))
- return false;
- curr = inv.GetItemDurability(item);
- max = inv.GetItemMaxDurability(item);
- if(curr > max)
- return false;
- if( (inv.IsItemAnyArmor(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_ARMOR)) ||
- (inv.IsItemSilverSwordUsableByPlayer(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_SILVER)) ||
- (inv.IsItemSteelSwordUsableByPlayer(item) && inv.ItemHasTag(consumable, theGame.params.TAG_REPAIR_CONSUMABLE_STEEL)) )
- {
- itemValue = CalculateAttributeValue(inv.GetItemAttributeValue(consumable, 'durabilityRepairValue'));
- if(itemValue <= 0)
- {
- LogAssert(false, "CR4Player.RepairItemUsingConsumable: consumable <<" + inv.GetItemName(consumable) + ">> has <=0 durabilityRepairValue!!!");
- return false;
- }
- repairBonus = CalculateAttributeValue(inv.GetItemAttributeValue(consumable, 'durabilityBonusValue'));
- repairValue = max * itemValue /100;
- newDurability = MinF(max, curr + repairValue);
- inv.SetItemDurabilityScript(item, newDurability);
- inv.RemoveItem(consumable);
- return true;
- }
- return false;
- }
- private function CheckDayNightCycle()
- {
- var time : GameTime;
- var isNight : bool;
- isNight = theGame.envMgr.IsNight();
- if(prevDayNightIsNight != isNight)
- {
- if(isNight)
- OnNightStarted();
- else
- OnDayStarted();
- prevDayNightIsNight = isNight;
- }
- if(isNight)
- time = theGame.envMgr.GetGameTimeTillNextDay();
- else
- time = theGame.envMgr.GetGameTimeTillNextNight();
- AddGameTimeTimer('DayNightCycle', time);
- }
- timer function DayNightCycle(dt : GameTime, id : int)
- {
- CheckDayNightCycle();
- }
- event OnNightStarted()
- {
- var pam : W3PlayerAbilityManager;
- if(CanUseSkill(S_Perk_01))
- {
- pam = (W3PlayerAbilityManager)abilityManager;
- pam.SetPerk01Abilities(false, true);
- }
- }
- event OnDayStarted()
- {
- var pam : W3PlayerAbilityManager;
- if(CanUseSkill(S_Perk_01))
- {
- pam = (W3PlayerAbilityManager)abilityManager;
- pam.SetPerk01Abilities(true, false);
- }
- }
- public function ForceUnlockAllInputActions(alsoQuestLocks : bool)
- {
- if ( inputHandler )
- inputHandler.ForceUnlockAllInputActions(alsoQuestLocks);
- }
- public function SetPrevRawLeftJoyRot()
- {
- prevRawLeftJoyRot = rawLeftJoyRot;
- }
- public function GetPrevRawLeftJoyRot() : float
- {
- return prevRawLeftJoyRot;
- }
- public function GetExplorationInputContext() : name
- {
- return explorationInputContext;
- }
- public function GetCombatInputContext() : name
- {
- return combatInputContext;
- }
- public function SetIsOnBoat(b : bool)
- {
- isOnBoat = b;
- }
- public function IsOnBoat() : bool
- {
- return isOnBoat;
- }
- public function IsInShallowWater() : bool
- {
- return isInShallowWater;
- }
- event OnEnterShallowWater()
- {
- if ( isInShallowWater )
- return false;
- isInShallowWater = true;
- BlockAction( EIAB_Dodge,'ShallowWater', false, false, true );
- BlockAction( EIAB_Sprint,'ShallowWater', false, false, true );
- BlockAction( EIAB_Crossbow,'ShallowWater', false, false, true );
- BlockAction( EIAB_Jump,'ShallowWater', false, false, true );
- SetBehaviorVariable( 'shallowWater',1.0);
- }
- event OnExitShallowWater()
- {
- if ( !isInShallowWater )
- return false;
- isInShallowWater = false;
- BlockAllActions('ShallowWater',false);
- SetBehaviorVariable( 'shallowWater',0.0);
- }
- public function TestIsInSettlement() : bool
- {
- return IsInSettlement();
- }
- public function ProcessGlossaryImageOverride( defaultImage : string, uniqueTag : name ) : string
- {
- var size : int;
- var i : int;
- size = glossaryImageOverride.Size();
- if( size == 0 )
- return defaultImage;
- for( i = 0; i < size; i += 1 )
- {
- if( glossaryImageOverride[i].uniqueTag == uniqueTag )
- return glossaryImageOverride[i].imageFileName;
- }
- return defaultImage;
- }
- public function EnableGlossaryImageOverride( uniqueTag : name, imageFileName : string, enable : bool )
- {
- var imageData : SGlossaryImageOverride;
- var size : int;
- var i : int;
- for( i = 0; i < glossaryImageOverride.Size(); i += 1 )
- {
- if( glossaryImageOverride[i].uniqueTag == uniqueTag )
- {
- glossaryImageOverride.Remove(glossaryImageOverride[i]);
- }
- }
- if( enable )
- {
- if( IsNameValid(uniqueTag) && imageFileName != "" )
- {
- glossaryImageOverride.PushBack( SGlossaryImageOverride( uniqueTag, imageFileName ) );
- }
- }
- }
- public function SetWeatherDisplayDisabled( disable : bool )
- {
- disableWeatherDisplay = disable;
- }
- public function GetWeatherDisplayDisabled() : bool
- {
- return disableWeatherDisplay;
- }
- public function SetCurrentMonsterHuntInvestigationArea ( area : W3MonsterHuntInvestigationArea )
- {
- currentMonsterHuntInvestigationArea = area;
- }
- public function RememberCustomHead( headName : name )
- {
- rememberedCustomHead = headName;
- }
- public function GetRememberedCustomHead() : name
- {
- return rememberedCustomHead;
- }
- public function ClearRememberedCustomHead()
- {
- rememberedCustomHead = '';
- }
- public function CreateTutorialInput()
- {
- var prevInputHandler : CPlayerInput;
- prevInputHandler = inputHandler;
- inputHandler = new W3PlayerTutorialInput in this;
- inputHandler.Initialize(false, prevInputHandler);
- if(prevInputHandler)
- delete prevInputHandler;
- }
- public function CreateInput()
- {
- var oldInputHandler : CPlayerInput;
- oldInputHandler = inputHandler;
- inputHandler = new CPlayerInput in this;
- inputHandler.Initialize(false, oldInputHandler);
- }
- timer function TutorialSilverCombat(dt : float, id : int)
- {
- var i : int;
- var actors : array<CActor>;
- if(IsInCombat())
- {
- actors = GetNPCsAndPlayersInRange(20, 1000000, ,FLAG_ExcludePlayer + FLAG_OnlyAliveActors);
- for(i=0; i<actors.Size(); i+=1)
- {
- if(actors[i] && IsRequiredAttitudeBetween(this, actors[i], true) && actors[i].UsesEssence())
- {
- FactsAdd("TutorialShowSilver");
- RemoveTimer('TutorialSilverCombat');
- break;
- }
- }
- }
- }
- private saved var m_bossTag : name;
- public function GetBossTag() : name
- {
- return m_bossTag;
- }
- public function SetBossTag( bossTag : name )
- {
- m_bossTag = bossTag;
- }
- private saved var m_usingCoatOfArms : bool; default m_usingCoatOfArms = false;
- public function IsUsingCoatOfArms() : bool
- {
- return m_usingCoatOfArms;
- }
- public function SetUsingCoatOfArms( using : bool)
- {
- m_usingCoatOfArms = using;
- }
- private saved var m_initialTimeOut : float;
- private saved var m_currentTimeOut : float;
- public function GetInitialTimeOut() : float
- {
- return m_initialTimeOut;
- }
- public function SetInitialTimeOut( timeOut : float )
- {
- m_initialTimeOut = timeOut;
- }
- public function GetCurrentTimeOut() : float
- {
- return m_currentTimeOut;
- }
- public function SetCurrentTimeOut( timeOut : float )
- {
- m_currentTimeOut = timeOut;
- }
- timer function DelayedFinisherInputTimer(dt : float, id : int)
- {
- }
- timer function RemoveFinisherCameraAnimationCheck(dt : float, id : int)
- {
- if ( !isInFinisher && !bLAxisReleased )
- {
- theGame.GetSyncAnimManager().OnRemoveFinisherCameraAnimation();
- RemoveTimer( 'RemoveFinisherCameraAnimationCheck' );
- }
- }
- timer function GameplayFactRemove(dt : float, timerId : int)
- {
- theGame.GameplayFactRemoveFromTimer(timerId);
- }
- timer function GiveStartingItems(dt : float, timerId : int)
- {
- var template : CEntityTemplate;
- var invEntity : CInventoryComponent;
- var entity : CEntity;
- var items : array<SItemUniqueId>;
- var id : SItemUniqueId;
- var i : int;
- if(inv)
- {
- inv.GetAllItems(items);
- if(items.Size() <= 0)
- {
- return;
- }
- }
- else
- {
- return;
- }
- template = (CEntityTemplate)LoadResource("geralt_inventory_release");
- entity = theGame.CreateEntity(template, Vector(0,0,0));
- invEntity = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
- invEntity.GetAllItems(items);
- for(i=0; i<items.Size(); i+=1)
- {
- id = invEntity.GiveItemTo(inv, items[i], 0, false, true);
- if ( inv.ItemHasTag(id,'Scabbard') )
- {
- inv.MountItem(id);
- }
- else if(!inv.IsItemFists(id) && inv.GetItemName(id) != 'Cat 1')
- {
- EquipItem(id);
- }
- else if(inv.IsItemSingletonItem(id))
- {
- inv.SingletonItemSetAmmo(id, inv.SingletonItemGetMaxAmmo(id));
- }
- }
- entity.Destroy();
- RemoveTimer('GiveStartingItems');
- }
- timer function Debug_GiveTestingItems(dt : float, optional id : int)
- {
- var template : CEntityTemplate;
- var invTesting : CInventoryComponent;
- var entity : CEntity;
- var items : array<SItemUniqueId>;
- var i : int;
- var slot : EEquipmentSlots;
- if(inv)
- {
- inv.GetAllItems(items);
- if(items.Size() <= 0)
- {
- return;
- }
- }
- else
- {
- return;
- }
- template = (CEntityTemplate)LoadResource("geralt_inventory_internal");
- entity = theGame.CreateEntity(template, Vector(0,0,0));
- invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
- invTesting.GiveAllItemsTo(inv, true);
- entity.Destroy();
- RemoveTimer('Debug_GiveTestingItems');
- inv.GetAllItems(items);
- for(i=0; i<items.Size(); i+=1)
- {
- if( inv.IsItemCrossbow(items[i]) || inv.IsItemBomb(items[i]) )
- {
- slot = inv.GetSlotForItemId(items[i]);
- EquipItem(items[i], slot);
- if( (W3PlayerWitcher)this && inv.IsItemCrossbow(items[i]) )
- GetWitcherPlayer().SelectQuickslotItem(slot);
- }
- else if(inv.IsItemBolt(items[i]))
- {
- slot = inv.GetSlotForItemId(items[i]);
- EquipItem(items[i], slot);
- }
- if(inv.IsItemSingletonItem(items[i]))
- {
- inv.SingletonItemSetAmmo(items[i], inv.SingletonItemGetMaxAmmo(items[i]));
- }
- }
- }
- timer function Debug_RemoveTestingItems(dt : float, id : int)
- {
- var template : CEntityTemplate;
- var entity : CEntity;
- var invTesting : CInventoryComponent;
- var ids : array<SItemUniqueId>;
- var i : int;
- template = (CEntityTemplate)LoadResource("geralt_inventory_internal");
- entity = theGame.CreateEntity(template, Vector(0,0,0));
- invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
- invTesting.GetAllItems(ids);
- for(i=0; i<ids.Size(); i+=1)
- inv.RemoveItemByName(invTesting.GetItemName(ids[i]), invTesting.GetItemQuantity(ids[i]));
- entity.Destroy();
- RemoveTimer('Debug_RemoveTestingItems');
- }
- timer function Debug_DelayedConsoleCommand(dt : float, id : int)
- {
- inv.AddAnItem('Boots 2 schematic');
- }
- function DBG_SkillSlots()
- {
- ((W3PlayerAbilityManager)abilityManager).DBG_SkillSlots();
- }
- public final function SetPadBacklightColor(r, g, b : int)
- {
- var padBacklightColor : Vector;
- padBacklightColor.X = r / 255;
- padBacklightColor.Y = g / 255;
- padBacklightColor.Z = b / 255;
- SetBacklightColor(padBacklightColor);
- }
- public final function SetPadBacklightColorFromSign(signType : ESignType)
- {
- LogPS4Light("SetPadBacklightColorFromSign... " + signType);
- switch(signType)
- {
- case ST_Yrden: SetPadBacklightColor( 200 , 81 , 255 ); break;
- case ST_Quen: SetPadBacklightColor( 255 , 205 , 68 ); break;
- case ST_Igni: SetPadBacklightColor( 255 , 79 , 10 ); break;
- case ST_Axii: SetPadBacklightColor( 255 , 255 , 255 ); break;
- case ST_Aard: SetPadBacklightColor( 158 , 214 , 255 ); break;
- }
- }
- timer function ResetPadBacklightColorTimer(dt : float, id : int)
- {
- ResetPadBacklightColor();
- }
- public final function ResetPadBacklightColor(optional skipHeldWeapon : bool)
- {
- var weapons : array<SItemUniqueId>;
- var sword : CWitcherSword;
- var healthPercentage : float;
- var tmpBacklight : Vector;
- if(!skipHeldWeapon)
- {
- weapons = inv.GetHeldWeapons();
- if(weapons.Size() > 0)
- {
- sword = (CWitcherSword)inv.GetItemEntityUnsafe(weapons[0]);
- if(sword)
- {
- tmpBacklight.X = sword.padBacklightColor.X / 255.0f;
- tmpBacklight.Y = sword.padBacklightColor.Y / 255.0f;
- tmpBacklight.Z = sword.padBacklightColor.Z / 255.0f;
- tmpBacklight.W = 1.0f;
- SetBacklightColor( tmpBacklight );
- LogPS4Light("Setting light from sword template: " + NoTrailZeros(sword.padBacklightColor.X) + ", " + NoTrailZeros(sword.padBacklightColor.Y) + ", " + NoTrailZeros(sword.padBacklightColor.Z) );
- return;
- }
- }
- }
- healthPercentage = GetStatPercents( BCS_Vitality );
- SetBacklightFromHealth( healthPercentage );
- LogPS4Light("Setting light from health, " + NoTrailZeros(RoundMath(healthPercentage*100)) + "%");
- }
- event OnOpenningDoor()
- {
- if( !thePlayer.IsUsingHorse() )
- RaiseEvent('OpenDoor');
- }
- public final function SetLoopingCameraShakeAnimName( n : name )
- {
- loopingCameraShakeAnimName = n;
- }
- public var loopingCameraShakeAnimName : name;
- timer function RemoveQuestCameraShakeTimer( dt : float , id : int)
- {
- RemoveQuestCameraShake( loopingCameraShakeAnimName );
- }
- public function RemoveQuestCameraShake( animName : name )
- {
- var camera : CCustomCamera = theGame.GetGameCamera();
- var animation : SCameraAnimationDefinition;
- camera.StopAnimation( animName );
- }
- public function GetCameraPadding() : float
- {
- if( theGame.IsFocusModeActive() )
- {
- return 0.25;
- }
- else
- {
- return 0.02f;
- }
- }
- public function IsPerformingPhaseChangeAnimation() : bool { return isPerformingPhaseChangeAnimation; }
- public function SetIsPerformingPhaseChangeAnimation( val : bool ) { isPerformingPhaseChangeAnimation = val; }
- private function DealCounterDamageToOlgierd()
- {
- var damage : W3DamageAction;
- damage = new W3DamageAction in this;
- damage.Initialize( thePlayer.GetTarget(), thePlayer.GetTarget(), NULL, this, EHRT_None, CPS_Undefined, false, false, false, true );
- damage.AddDamage( theGame.params.DAMAGE_NAME_DIRECT, thePlayer.GetTarget().GetStatMax( BCS_Vitality ) * 3 / 100 );
- theGame.damageMgr.ProcessAction( damage );
- delete damage;
- }
- timer function PlayDelayedCounterDamageEffect( dt : float, id : int )
- {
- thePlayer.GetTarget().PlayEffect( 'olgierd_energy_blast' );
- }
- public function SetTestAdjustRequestedMovementDirection( val : bool )
- {
- testAdjustRequestedMovementDirection = val;
- }
- event OnVisualDebug( frame : CScriptedRenderFrame, flag : EShowFlags )
- {
- var boneFollow : int;
- var bonePosition : Vector;
- var yrdenEntity : W3YrdenEntity;
- substateManager.OnVisualDebug( frame, flag );
- boneFollow = thePlayer.GetBoneIndex( 'Reference' );
- bonePosition = MatrixGetTranslation( thePlayer.GetBoneWorldMatrixByIndex( boneFollow ) );
- frame.DrawText( "R", bonePosition, Color( 50, 200, 70 ) );
- boneFollow = thePlayer.GetBoneIndex( 'Trajectory' );
- bonePosition = MatrixGetTranslation( thePlayer.GetBoneWorldMatrixByIndex( boneFollow ) );
- frame.DrawSphere( bonePosition, 0.1f, Color( 200, 50, 70 ) );
- frame.DrawText( "T", bonePosition, Color( 200, 50, 70 ) );
- yrdenEntity = (W3YrdenEntity)GetWitcherPlayer().GetSignEntity(ST_Yrden);
- yrdenEntity.OnVisualDebug(frame, flag, false);
- return true;
- }
- timer function PotDrinkTimer(dt : float, id : int)
- {
- inputHandler.PotDrinkTimer(false);
- }
- public function SetIsHorseRacing( val : bool )
- {
- isHorseRacing = val;
- }
- public function GetIsHorseRacing() : bool
- {
- return isHorseRacing;
- }
- public function SetHorseCombatSlowMo( val : bool )
- {
- horseCombatSlowMo = val;
- }
- public function GetHorseCombatSlowMo() : bool
- {
- return horseCombatSlowMo;
- }
- public function SetItemsPerLevelGiven( id : int )
- {
- itemsPerLevelGiven[id] = true;
- }
- private function AddItemPerLevelList()
- {
- var i : int;
- itemsPerLevel.Clear();
- itemsPerLevel.PushBack('O');
- itemsPerLevel.PushBack('No Mans Land sword 2');
- itemsPerLevel.PushBack('No Mans Land sword 3');
- itemsPerLevel.PushBack('Silver sword 2');
- itemsPerLevel.PushBack('Boots 01');
- itemsPerLevel.PushBack('Novigraadan sword 2');
- itemsPerLevel.PushBack('Light armor 01');
- itemsPerLevel.PushBack('Heavy boots 01');
- itemsPerLevel.PushBack('Nilfgaardian sword 3');
- itemsPerLevel.PushBack('Silver sword 3');
- itemsPerLevel.PushBack('Heavy gloves 01');
- itemsPerLevel.PushBack('Skellige sword 2');
- itemsPerLevel.PushBack('Heavy pants 01');
- itemsPerLevel.PushBack('Silver sword 4');
- itemsPerLevel.PushBack('No Mans Land sword 4');
- itemsPerLevel.PushBack('Heavy armor 01');
- itemsPerLevel.PushBack('Heavy boots 02');
- itemsPerLevel.PushBack('Skellige sword 3');
- itemsPerLevel.PushBack('Silver sword 5');
- itemsPerLevel.PushBack('Heavy pants 02');
- itemsPerLevel.PushBack('Heavy gloves 02');
- itemsPerLevel.PushBack('Heavy gloves 02');
- itemsPerLevel.PushBack('Heavy armor 02');
- itemsPerLevel.PushBack('Scoiatael sword 1');
- if ( itemsPerLevelGiven.Size() < 49 )
- {
- itemsPerLevelGiven.Clear();
- for (i = 0; i < itemsPerLevel.Size(); i += 1) { itemsPerLevelGiven.PushBack( false ); }
- }
- }
- public function DealDamageToBoat( dmg : float, index : int, optional globalHitPos : Vector )
- {
- var boat : CBoatDestructionComponent;
- if(usedVehicle)
- {
- boat = (CBoatDestructionComponent) usedVehicle.GetComponentByClassName( 'CBoatDestructionComponent' );
- if( boat )
- {
- boat.DealDamage( dmg, index, globalHitPos );
- }
- }
- }
- public function OnStartTeleportingPlayerToPlayableArea()
- {
- var FADEOUT_INTERVAL : float = 0.5;
- if ( thePlayer.IsUsingHorse() )
- {
- if ( thePlayer.GetUsedHorseComponent().OnCheckHorseJump() )
- {
- thePlayer.GetUsedHorseComponent().SetCanTakeDamageFromFalling( false );
- }
- }
- if ( thePlayer.IsActionAllowed( EIAB_FastTravel ) )
- {
- OnOpenMapToLetPlayerGoBackToPlayableArea();
- }
- else
- {
- theGame.FadeOutAsync( FADEOUT_INTERVAL );
- thePlayer.AddTimer( 'BorderTeleportFadeOutTimer', FADEOUT_INTERVAL, false );
- }
- }
- timer function BorderTeleportFadeOutTimer( dt : float, id : int )
- {
- OnTeleportPlayerToPlayableArea( false );
- }
- public function OnOpenMapToLetPlayerGoBackToPlayableArea()
- {
- var initData : W3MapInitData;
- initData = new W3MapInitData in this;
- initData.SetTriggeredExitEntity( true );
- initData.ignoreSaveSystem = true;
- initData.setDefaultState('FastTravel');
- theGame.RequestMenuWithBackground( 'MapMenu', 'CommonMenu', initData );
- }
- public function OnTeleportPlayerToPlayableArea( afterClosingMap : bool )
- {
- var BLACKSCREEN_INTERVAL : float = 0.1;
- var manager : CCommonMapManager = theGame.GetCommonMapManager();
- thePlayer.TeleportWithRotation( manager.GetBorderTeleportPosition(), manager.GetBorderTeleportRotation() );
- thePlayer.AddTimer( 'BorderTeleportFadeInTimer', BLACKSCREEN_INTERVAL, false );
- theGame.FadeOutAsync( 0 );
- theGame.SetFadeLock('PlayerTeleportation');
- }
- timer function BorderTeleportFadeInTimer( dt : float, id : int )
- {
- theGame.ResetFadeLock('PlayerTeleportation');
- theGame.FadeOutAsync( 0 );
- theGame.FadeInAsync( 2.0f );
- }
- public final function SetLastInstantKillTime(g : GameTime)
- {
- lastInstantKillTime = g;
- }
- timer function TestTimer(dt : float, id : int )
- {
- LogChannel('asdf', "asdf");
- theGame.FadeOutAsync( 5 );
- }
- public final function Debug_ReleaseCriticalStateSaveLocks()
- {
- effectManager.Debug_ReleaseCriticalStateSaveLocks();
- }
- timer function Debug_SpamSpeed(dt : float, id : int)
- {
- if(currentlyMountedHorse)
- {
- LogSpeed("curr player's horse speed: " + NoTrailZeros(currentlyMountedHorse.GetMovingAgentComponent().GetSpeed())) ;
- }
- else
- {
- LogSpeed("curr player speed: " + NoTrailZeros(GetMovingAgentComponent().GetSpeed())) ;
- }
- }
- timer function RemoveInstantKillSloMo(dt : float, id : int)
- {
- theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_InstantKill) );
- }
- timer function RemoveForceFinisher(dt : float, id : int)
- {
- forceFinisher = false;
- }
- public final function Debug_ClearAllActionLocks(optional action : EInputActionBlock, optional all : bool)
- {
- inputHandler.Debug_ClearAllActionLocks(action, all);
- }
- function OnFocusedCameraBlendBegin() {}
- function OnFocusedCameraBlendUpdate( progress : float ) {}
- function OnFocusedCameraBlendEnd() {}
- public function GetEtherealCount() : int { return etherealCount; }
- public function IncrementEtherealCount()
- {
- etherealCount += 1;
- if( etherealCount == 6 )
- ResetEtherealCount();
- }
- public function ResetEtherealCount() { etherealCount = 0; }
- public function SetInsideDiveAttackArea( val : bool ) { insideDiveAttackArea = val; }
- public function IsInsideDiveAttackArea() : bool { return insideDiveAttackArea; }
- public function SetDiveAreaNumber( val : int ) { diveAreaNumber = val; }
- public function GetDiveAreaNumber() : int { return diveAreaNumber; }
- public function InitPhantomWeaponMgr()
- {
- if( !phantomWeaponMgr )
- {
- phantomWeaponMgr = new CPhantomWeaponManager in this;
- phantomWeaponMgr.Init( this.GetInventory() );
- }
- }
- public function DestroyPhantomWeaponMgr()
- {
- if( phantomWeaponMgr )
- {
- delete phantomWeaponMgr;
- }
- }
- public function GetPhantomWeaponMgr() : CPhantomWeaponManager
- {
- if( phantomWeaponMgr )
- {
- return phantomWeaponMgr;
- }
- else
- {
- return NULL;
- }
- }
- public timer function DischargeWeaponAfter( td : float, id : int )
- {
- GetPhantomWeaponMgr().DischargeWeapon();
- }
- private var forcedFinisherVictim : CActor;
- timer function PerformFinisher( time : float , id : int )
- {
- var combatTarget : CActor;
- var i : int;
- combatTarget = thePlayer.GetTarget();
- if( combatTarget )
- {
- combatTarget.Kill( 'AutoFinisher', false, thePlayer );
- thePlayer.SetFinisherVictim( combatTarget );
- forcedFinisherVictim = combatTarget;
- thePlayer.CleanCombatActionBuffer();
- thePlayer.OnBlockAllCombatTickets( true );
- moveTargets = thePlayer.GetMoveTargets();
- for( i = 0; i < moveTargets.Size(); i += 1 )
- {
- if( combatTarget != moveTargets[i] )
- moveTargets[i].SignalGameplayEvent( 'InterruptChargeAttack' );
- }
- if( theGame.GetInGameConfigWrapper().GetVarValue( 'Gameplay', 'AutomaticFinishersEnabled' ) == "true" )
- combatTarget.AddAbility( 'ForceFinisher', false );
- if( combatTarget.HasTag( 'ForceFinisher' ) )
- combatTarget.AddAbility( 'ForceFinisher', false );
- combatTarget.SignalGameplayEvent( 'ForceFinisher' );
- thePlayer.FindMoveTarget();
- thePlayer.AddTimer( 'SignalFinisher', 0.2, false );
- }
- }
- timer function SignalFinisher( time : float , id : int )
- {
- forcedFinisherVictim.SignalGameplayEvent( 'Finisher' );
- forcedFinisherVictim = NULL;
- }
- }
- exec function ttt()
- {
- thePlayer.AddTimer( 'TestTimer', 5, false );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement