Advertisement
Guest User

error thing

a guest
Nov 20th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 88.67 KB | None | 0 0
  1. /*
  2. Copyright © CD Projekt RED 2015
  3. */
  4.  
  5.  
  6.  
  7.  
  8.  
  9. enum EConverserType
  10. {
  11.     CT_General,
  12.     CT_Nobleman,
  13.     CT_Guard,
  14.     CT_Mage,
  15.     CT_Bandit,
  16.     CT_Scoiatael,
  17.     CT_Peasant,
  18.     CT_Poor,
  19.     CT_Child
  20. };
  21.  
  22.  
  23. statemachine import class CNewNPC extends CActor
  24. {
  25.    
  26.    
  27.    
  28.     editable var isImmortal         : bool;            
  29.     editable var isInvulnerable     : bool;            
  30.     editable var willBeUnconscious  : bool;            
  31.     editable var minUnconsciousTime : float;            default minUnconsciousTime = 20.f;
  32.    
  33.     editable var unstoppable        : bool;             hint unstoppable = "won't play hit reaction nor critical state reaction";
  34.    
  35.     editable var RemainsTags        : array<name>;      hint RemainsTags="If set then the NPC's remains will be tagged with given tags";
  36.     editable var level              : int;              default level = 1;
  37.              var currentLevel       : int;
  38.     editable saved var levelFakeAddon     : int;                default levelFakeAddon = 0;
  39.              var newGamePlusFakeLevelAddon : bool;      default newGamePlusFakeLevelAddon = false;
  40.  
  41.     editable var isMiniBossLevel    : bool;             default isMiniBossLevel = false;
  42.     editable var suppressBroadcastingReactions      : bool;     default suppressBroadcastingReactions = false;
  43.     editable saved var dontUseReactionOneLiners     : bool;     default dontUseReactionOneLiners = false;
  44.     editable saved var disableConstrainLookat       : bool;     default disableConstrainLookat = false;
  45.    
  46.     editable var isMonsterType_Group   : bool;          default isMonsterType_Group = false;
  47.    
  48.     editable var useSoundValue      : bool;             default useSoundValue = false;
  49.     editable var soundValue         : int; 
  50.    
  51.    
  52.     editable var clearInvOnDeath            : bool;
  53.     default clearInvOnDeath = false;
  54.    
  55.     editable var noAdaptiveBalance : bool;
  56.     default noAdaptiveBalance = false;
  57.    
  58.     editable var grantNoExperienceAfterKill : bool;
  59.     default grantNoExperienceAfterKill = false;
  60.    
  61.  
  62.     hint disableConstrainLookat = "It will disable lookats form reactions and from QuestLookat block";
  63.     hint useSoundValue = "If true it will add the SoundValue to the threat Rating used for combat music control";
  64.     hint soundValue = "This value will be added or subtracted from sound system to achieve final threat Rating";
  65.    
  66.    
  67.    
  68.     import private saved var npcGroupType       : ENPCGroupType;    default npcGroupType = ENGT_Enemy;
  69.    
  70.    
  71.     private optional autobind   horseComponent      : W3HorseComponent = single;
  72.     private var         isHorse             : bool;
  73.     private saved var   canFlee             : bool;     default     canFlee = true;
  74.     private var         isFallingFromHorse  : bool;     default     isFallingFromHorse = false;
  75.    
  76.     private var     immortalityInitialized  : bool;
  77.    
  78.    
  79.     private var     canBeFollowed           : bool;     default         canBeFollowed = false;
  80.  
  81.    
  82.     private var     bAgony                  : bool;     default         bAgony  = false;
  83.     private var     bFinisher               : bool;     default         bFinisher = false;
  84.     private var     bPlayDeathAnim          : bool;     default         bPlayDeathAnim = true;
  85.     private var     bAgonyDisabled          : bool;     default         bAgonyDisabled = false;
  86.     private var     bFinisherInterrupted    : bool;
  87.    
  88.     private var     bIsInHitAnim : bool;
  89.    
  90.    
  91.     private var     threatLevel                 : int;              default         threatLevel = 10;
  92.     private var     counterWindowStartTime      : EngineTime;      
  93.     private var     bIsCountering               : bool;
  94.     private var     allowBehGraphChange         : bool;             default         allowBehGraphChange = true;
  95.     private var     aardedFlight                : bool;            
  96.     public var      lastMeleeHitTime            : EngineTime;      
  97.    
  98.     private saved var preferedCombatStyle : EBehaviorGraph;
  99.    
  100.    
  101.     private var     previousStance              : ENpcStance;       default         previousStance  = NS_Normal;
  102.     private var     regularStance               : ENpcStance;       default         regularStance   = NS_Normal;
  103.    
  104.    
  105.     private var     currentFightStage           : ENPCFightStage;
  106.    
  107.    
  108.     private var     currentState                : CName;            default         autoState = 'NewIdle';
  109.  
  110.     private var     behaviorGraphEventListened  : array<name>;
  111.    
  112.    
  113.     private var     isTemporaryOffGround            : bool;
  114.    
  115.    
  116.  
  117.     private var     isUnderwater                : bool;     default isUnderwater = false;
  118.    
  119.    
  120.     private var isTranslationScaled             : bool;
  121.    
  122.    
  123.     private var tauntedToAttackTimeStamp        : float;
  124.    
  125.     private var hitCounter                      : int;      default hitCounter = 0;
  126.     private var totalHitCounter                 : int;      default totalHitCounter = 0;
  127.     public var customHits                       : bool;     default customHits = false;
  128.    
  129.    
  130.    
  131.    
  132.     public var isTeleporting                    : bool;         default isTeleporting = false;
  133.    
  134.    
  135.    
  136.    
  137.    
  138.    
  139.    
  140.     public var itemToEquip                      : SItemUniqueId;
  141.    
  142.    
  143.     private saved var wasBleedingBurningPoisoned    : bool;     default wasBleedingBurningPoisoned = false;
  144.    
  145.    
  146.     public  var wasInTalkInteraction                : bool;
  147.     private var wasInCutscene                       : bool;
  148.     public  var shieldDebris                        : CItemEntity;
  149.     public  var lastMealTime                        : float;    default lastMealTime = -1;
  150.     public  var packName                            : name;    
  151.     public  var isPackLeader                        : bool;    
  152.     private var mac                                 : CMovingPhysicalAgentComponent;
  153.  
  154.    
  155.    
  156.     private saved  var isTalkDisabled               : bool; default isTalkDisabled = false;
  157.     private        var isTalkDisabledTemporary      : bool; default isTalkDisabledTemporary = false;
  158.    
  159.  
  160.     event OnGameDifficultyChanged( previousDifficulty : int, currentDifficulty : int )
  161.     {
  162.         if ( HasAbility('difficulty_CommonEasy') ) RemoveAbility('difficulty_CommonEasy');
  163.         if ( HasAbility('difficulty_CommonMedium') )  RemoveAbility('difficulty_CommonMedium');
  164.         if ( HasAbility('difficulty_CommonHard') )  RemoveAbility('difficulty_CommonHard');
  165.         if ( HasAbility('difficulty_CommonHardcore') )  RemoveAbility('difficulty_CommonHardcore');
  166.        
  167.         switch ( theGame.GetSpawnDifficultyMode() )
  168.         {
  169.         case EDM_Easy:
  170.             AddAbility('difficulty_CommonEasy');
  171.             break;
  172.         case EDM_Medium:
  173.             AddAbility('difficulty_CommonMedium');
  174.             break;
  175.         case EDM_Hard:
  176.             AddAbility('difficulty_CommonHard');
  177.             break;
  178.         case EDM_Hardcore:
  179.             AddAbility('difficulty_CommonHardcore');
  180.             break;
  181.         }  
  182.  
  183.         AddTimer('AddLevelBonuses', 0.1, true);
  184.  
  185.     }
  186.    
  187.     timer function ResetTalkInteractionFlag( td : float , id : int)
  188.     {
  189.         if ( !IsSpeaking() )
  190.         {
  191.             wasInTalkInteraction = false;
  192.             RemoveTimer('ResetTalkInteractionFlag');
  193.         }
  194.     }
  195.        
  196.     protected function OnCombatModeSet( toggle : bool )
  197.     {
  198.         super.OnCombatModeSet( toggle );
  199.        
  200.         if( toggle )
  201.         {
  202.             SetCombatStartTime();
  203.             SetCombatPartStartTime();
  204.            
  205.            
  206.            
  207.            
  208.             RecalcLevel();
  209.         }
  210.         else
  211.         {
  212.             ResetCombatStartTime();
  213.             ResetCombatPartStartTime();
  214.         }      
  215.     }
  216.    
  217.     public function SetImmortalityInitialized(){ immortalityInitialized = true; }
  218.    
  219.     public function SetNPCType( type : ENPCGroupType ) { npcGroupType = type; }
  220.     public function GetNPCType() : ENPCGroupType { return npcGroupType; }
  221.    
  222.  
  223.     public function SetCanBeFollowed( val : bool ) { canBeFollowed = val; }
  224.     public function CanBeFollowed() : bool { return canBeFollowed; }
  225.    
  226.     event OnPreAttackEvent(animEventName : name, animEventType : EAnimationEventType, data : CPreAttackEventData, animInfo : SAnimationEventAnimInfo )
  227.     {
  228.         var witcher : W3PlayerWitcher;
  229.         var levelDiff : int;
  230.    
  231.         super.OnPreAttackEvent(animEventName, animEventType, data, animInfo);
  232.        
  233.         if(animEventType == AET_DurationStart )
  234.         {
  235.            
  236.            
  237.             witcher = GetWitcherPlayer();
  238.            
  239.            
  240.            
  241.             if(GetTarget() == witcher )
  242.             {
  243.                 levelDiff = GetLevel() - witcher.GetLevel();
  244.                
  245.                 if ( levelDiff < theGame.params.LEVEL_DIFF_DEADLY )
  246.                     this.SetDodgeFeedback( true );
  247.             }
  248.            
  249.             if ( IsCountering() )
  250.             {
  251.                
  252.                 if(GetTarget() == witcher && ( thePlayer.IsActionAllowed(EIAB_Dodge) || thePlayer.IsActionAllowed(EIAB_Roll) ) && witcher.GetStat(BCS_Toxicity) > 0 && witcher.CanUseSkill(S_Alchemy_s16))
  253.                     witcher.StartFrenzy();
  254.             }
  255.         }
  256.         else if(animEventType == AET_DurationEnd )
  257.         {
  258.             witcher = GetWitcherPlayer();
  259.            
  260.             if(GetTarget() == witcher )
  261.             {      
  262.                 this.SetDodgeFeedback( false );
  263.             }
  264.         }
  265.     }
  266.    
  267.     public function SetDodgeFeedback( flag : bool )
  268.     {
  269.        
  270.         if ( flag )
  271.         {
  272.             thePlayer.SetDodgeFeedbackTarget( this );
  273.         }
  274.         else
  275.         {
  276.             thePlayer.SetDodgeFeedbackTarget( NULL );
  277.         }
  278.     }
  279.    
  280.     event OnBlockingSceneEnded( optional output : CStorySceneOutput)
  281.     {
  282.         super.OnBlockingSceneEnded( output );
  283.         wasInCutscene = true;
  284.     }
  285.    
  286.     public function WasInCutscene() : bool
  287.     {
  288.         return wasInCutscene;
  289.     }
  290.    
  291.    
  292.     public function IsVIP() : bool
  293.     {
  294.         var tags : array<name>;
  295.         var i : int;
  296.        
  297.        
  298.         tags = GetTags();
  299.         for ( i = 0; i < tags.Size(); i+=1 )
  300.         {
  301.             if ( tags[i] == 'vip' )
  302.             {
  303.                 return true;
  304.             }
  305.         }
  306.        
  307.         return false;
  308.     }
  309.    
  310.    
  311.    
  312.    
  313.    
  314.    
  315.     event OnSpawned(spawnData : SEntitySpawnData )
  316.     {
  317.         var lvlDiff, playerLevel: int;
  318.         var heading         : float;
  319.         var remainingDuration : float;
  320.         var oldLevel : int;
  321.        
  322.         currentLevel = thePlayer.GetLevel();
  323.  
  324.        
  325.         super.OnSpawned(spawnData);
  326.        
  327.        
  328.         SetThreatLevel();
  329.        
  330.        
  331.         GotoStateAuto();       
  332.        
  333.        
  334.         isTalkDisabledTemporary = false;
  335.        
  336.        
  337.         if(!spawnData.restored && !immortalityInitialized )
  338.         {
  339.  
  340.             SetCanPlayHitAnim( true );
  341.            
  342.             if(isInvulnerable)
  343.             {
  344.                 SetImmortalityMode(AIM_Invulnerable, AIC_Default);
  345.             }
  346.             else if(isImmortal)
  347.             {
  348.                 SetImmortalityMode(AIM_Immortal, AIC_Default);
  349.             }
  350.             else if( willBeUnconscious )
  351.             {
  352.                 SetImmortalityMode(AIM_Unconscious, AIC_Default);
  353.                 SignalGameplayEventParamFloat('ChangeUnconsciousDuration',minUnconsciousTime);
  354.             }
  355.             else if ( npcGroupType == ENGT_Commoner || npcGroupType == ENGT_Guard || npcGroupType == ENGT_Quest )
  356.             {
  357.                 SetImmortalityMode(AIM_Unconscious, AIC_Default);  
  358.             }
  359.         }
  360.  
  361.        
  362.        
  363.         if( npcGroupType == ENGT_Guard )
  364.         {
  365.             SetOriginalInteractionPriority( IP_Prio_5 );
  366.             RestoreOriginalInteractionPriority();
  367.         }
  368.         else if( npcGroupType == ENGT_Quest )
  369.         {
  370.             SetOriginalInteractionPriority( IP_Max_Unpushable );
  371.             RestoreOriginalInteractionPriority();
  372.         }
  373.        
  374.        
  375.        
  376.         mac = (CMovingPhysicalAgentComponent)GetMovingAgentComponent();
  377.         if(mac && IsFlying() )
  378.             mac.SetAnimatedMovement( true );
  379.        
  380.        
  381.         RegisterCollisionEventsListener();     
  382.        
  383.        
  384.         if (focusModeSoundEffectType == FMSET_None)
  385.             SetFocusModeSoundEffectType( FMSET_Gray );
  386.        
  387.         heading = AngleNormalize( GetHeading() );
  388.        
  389.         SetBehaviorVariable( 'requestedFacingDirection', heading );
  390.        
  391.         if ( disableConstrainLookat )
  392.             SetBehaviorVariable( 'disableConstraintLookat', 1.f);
  393.            
  394.        
  395.         SoundSwitch( "vo_3d", 'vo_3d_long', 'head' );
  396.        
  397.         AddAnimEventCallback('EquipItemL' ,         'OnAnimEvent_EquipItemL');
  398.         AddAnimEventCallback('HideItemL' ,          'OnAnimEvent_HideItemL');
  399.         AddAnimEventCallback('HideWeapons' ,        'OnAnimEvent_HideWeapons');
  400.         AddAnimEventCallback('TemporaryOffGround' , 'OnAnimEvent_TemporaryOffGround');
  401.  
  402.         AddAnimEventCallback('OwlSwitchOpen' ,      'OnAnimEvent_OwlSwitchOpen');
  403.         AddAnimEventCallback('OwlSwitchClose' ,     'OnAnimEvent_OwlSwitchClose');
  404.         AddAnimEventCallback('Goose01OpenWings' ,   'OnAnimEvent_Goose01OpenWings');
  405.         AddAnimEventCallback('Goose01CloseWings''OnAnimEvent_Goose01CloseWings');
  406.         AddAnimEventCallback('Goose02OpenWings' ,   'OnAnimEvent_Goose02OpenWings');
  407.         AddAnimEventCallback('Goose02CloseWings''OnAnimEvent_Goose02CloseWings');
  408.         AddAnimEventCallback('NullifyBurning' ,     'OnAnimEvent_NullifyBurning');
  409.         AddAnimEventCallback('setVisible' ,         'OnAnimEvent_setVisible');
  410.         AddAnimEventCallback('extensionWalk' ,      'OnAnimEvent_extensionWalk');
  411.         AddAnimEventCallback('weaponSoundType' ,    'OnAnimEvent_weaponSoundType');
  412.  
  413.        
  414.         if(HasAbility('_canBeFollower') && theGame.GetDifficultyMode() != EDM_Hardcore)
  415.             RemoveAbility('_canBeFollower');
  416.  
  417.        
  418.            
  419.            
  420.        
  421.         if(!spawnData.restored && (FactsQuerySum("NewGamePlus") > 0 || (!HasAbility('NoAdaptBalance') && currentLevel > 1 ) ) )
  422.         {
  423.            
  424.            
  425.             if ( theGame.IsActive() )
  426.             {
  427.                 if( ( FactsQuerySum("NewGamePlus") > 0 ) && !HasTag('animal') )
  428.                 {
  429.                     if( !HasAbility('NPCDoNotGainBoost') && !HasAbility('NewGamePlusFakeLevel') )
  430.                     {
  431.                         currentLevel;
  432.  
  433.                     }
  434.                     else if ( !HasAbility('NPCDoNotGainNGPlusLevel') )
  435.                     {
  436.                         newGamePlusFakeLevelAddon = true;
  437.                     }
  438.                    
  439.  
  440.                 }
  441.                 else
  442.                 {
  443.                    
  444.                     if ( ( theGame.GetDifficultyMode() == EDM_Easy || theGame.GetDifficultyMode() == EDM_Medium ) && playerLevel == 1 && npcGroupType != ENGT_Guard && !HasAbility('PrologModifier'))
  445.                     {
  446.                         AddAbility('PrologModifier');
  447.                     }
  448.                 }
  449.             }  
  450.         }
  451.                
  452.     }
  453.    
  454.    
  455.     protected function SetAbilityManager()
  456.     {
  457.         if(npcGroupType != ENGT_Commoner)
  458.             abilityManager = new W3NonPlayerAbilityManager in this;    
  459.     }
  460.    
  461.     protected function SetEffectManager()
  462.     {
  463.         if(npcGroupType != ENGT_Commoner)
  464.             super.SetEffectManager();
  465.     }
  466.    
  467.     public function  SetLevel ( _level : int )
  468.     {
  469.         currentLevel = thePlayer.GetLevel();
  470.         AddTimer('AddLevelBonuses', 0.1, true);
  471.  
  472.     }
  473.    
  474.     private function SetThreatLevel()
  475.     {
  476.         var temp : float;
  477.        
  478.         temp = CalculateAttributeValue(GetAttributeValue('threat_level'));
  479.         if ( temp >= 0.f )
  480.         {
  481.             threatLevel = (int)temp;
  482.         }
  483.         else
  484.         {
  485.             LogAssert(false,"No threat_level attribute set. Threat level set to 0");
  486.             threatLevel = 0;
  487.         }
  488.     }
  489.     public function ChangeThreatLevel( newValue : int )
  490.     {
  491.         threatLevel = newValue;
  492.     }
  493.    
  494.  
  495.      public function GetHorseUser() : CActor
  496.     {
  497.         if( horseComponent )
  498.         {
  499.             return horseComponent.GetCurrentUser();
  500.         }
  501.        
  502.         return NULL;
  503.     }
  504.    
  505.    
  506.    
  507.    
  508.  
  509.     public function GetPreferedCombatStyle() : EBehaviorGraph
  510.     {
  511.         return preferedCombatStyle;
  512.     }
  513.    
  514.     public function SetPreferedCombatStyle( _preferedCombatStyle : EBehaviorGraph )
  515.     {
  516.         preferedCombatStyle = _preferedCombatStyle;
  517.     }
  518.    
  519.    
  520.     timer function WeatherBonusCheck(dt : float, id : int)
  521.     {
  522.         var curGameTime : GameTime;
  523.         var dayPart : EDayPart;
  524.         var bonusName : name;
  525.         var curEffect : CBaseGameplayEffect;
  526.         var moonState : EMoonState;
  527.         var weather : EWeatherEffect;
  528.         var params : SCustomEffectParams;
  529.        
  530.         if ( !IsAlive() )
  531.         {
  532.             return;
  533.         }
  534.        
  535.         moonState = GetCurMoonState();
  536.        
  537.         curGameTime = GameTimeCreate();
  538.         dayPart = GetDayPart(curGameTime);
  539.        
  540.         weather = GetCurWeather();
  541.        
  542.         bonusName = ((W3NonPlayerAbilityManager)abilityManager).GetWeatherBonus(dayPart, weather, moonState);
  543.        
  544.         curEffect = GetBuff(EET_WeatherBonus);
  545.         if (curEffect)
  546.         {
  547.             if ( curEffect.GetAbilityName() == bonusName )
  548.             {
  549.                 return;
  550.             }
  551.             else
  552.             {
  553.                 RemoveBuff(EET_WeatherBonus);
  554.             }
  555.         }
  556.        
  557.         if (bonusName != 'None')
  558.         {
  559.             params.effectType = EET_WeatherBonus;
  560.             params.creator = this;
  561.             params.sourceName = "WeatherBonus";
  562.             params.customAbilityName = bonusName;
  563.             AddEffectCustom(params);
  564.         }
  565.     }
  566.    
  567.     public function IsFlying() : bool
  568.     {
  569.         var result : bool;
  570.         result = ( this.GetCurrentStance() == NS_Fly );
  571.         return result;
  572.     }
  573.    
  574.     public function IsRanged() : bool
  575.     {
  576.        
  577.         var weapon : SItemUniqueId;
  578.         var weapon2 : SItemUniqueId;
  579.    
  580.  
  581.         weapon = this.GetInventory().GetItemFromSlot( 'l_weapon' );
  582.         weapon2 = this.GetInventory().GetItemFromSlot( 'r_weapon' );
  583.        
  584.         return ( this.GetInventory().GetItemCategory( weapon ) == 'bow' || this.GetInventory().GetItemCategory( weapon2 ) == 'crossbow' );
  585.        
  586.     }
  587.    
  588.    
  589.    
  590.     public function IsVisuallyOffGround() : bool
  591.     {
  592.         if( isTemporaryOffGround )
  593.             return true;
  594.         if( IsFlying() )
  595.             return true;
  596.            
  597.         return false;
  598.     }
  599.  
  600.     public function SetIsHorse()
  601.     {
  602.         if ( horseComponent )
  603.             isHorse = true;
  604.     }
  605.    
  606.     public function IsHorse() : bool
  607.     {
  608.         return isHorse;
  609.     }
  610.    
  611.     public function GetHorseComponent() : W3HorseComponent
  612.     {
  613.         if ( isHorse )
  614.             return horseComponent;
  615.         else
  616.             return NULL;
  617.     }
  618.    
  619.     public function HideHorseAfter( time : float )
  620.     {
  621.         if( !isHorse )
  622.             return;
  623.        
  624.         SetVisibility( false );
  625.         SetGameplayVisibility( false );
  626.        
  627.         AddTimer( 'HideHorse', time );
  628.     }
  629.    
  630.     private timer function HideHorse( delta : float , id : int )
  631.     {
  632.         Teleport( thePlayer.GetWorldPosition() + thePlayer.GetHeadingVector() * 1000.0 );
  633.        
  634.         SetVisibility( true );
  635.         SetGameplayVisibility( true );
  636.     }
  637.    
  638.     public function KillHorseAfter( time : float )
  639.     {
  640.         if( !isHorse )
  641.             return;
  642.         AddTimer( 'KillHorse', time );
  643.     }
  644.    
  645.     private timer function KillHorse( delta : float , id : int )
  646.     {
  647.         SetKinematic( false );
  648.         Kill( true );
  649.         SetAlive( false );
  650.         GetComponentByClassName( 'CInteractionComponent' ).SetEnabled( false );
  651.         PlayEffect( 'hit_ground' );
  652.     }
  653.    
  654.     public timer function RemoveAxiiFromHorse( delta : float , id : int )
  655.     {
  656.         RemoveAbility( 'HorseAxiiBuff' );
  657.     }
  658.    
  659.     public function ToggleCanFlee( val : bool ) { canFlee = val; }
  660.     public function GetCanFlee() : bool         { return canFlee; }
  661.    
  662.     public function SetIsFallingFromHorse( val : bool )        
  663.     {
  664.         if( val )
  665.         {
  666.             AddBuffImmunity( EET_HeavyKnockdown, 'SetIsFallingFromHorse', true );
  667.             isFallingFromHorse = true;
  668.         }
  669.         else
  670.         {
  671.             RemoveBuffImmunity( EET_HeavyKnockdown, 'SetIsFallingFromHorse' );
  672.             isFallingFromHorse = false;
  673.         }
  674.     }
  675.     public function GetIsFallingFromHorse() : bool              { return isFallingFromHorse; }
  676.    
  677.     public function SetCounterWindowStartTime(time : EngineTime)    {counterWindowStartTime = time;}
  678.     public function GetCounterWindowStartTime() : EngineTime        {return counterWindowStartTime;}
  679.    
  680.    
  681.     function GetThreatLevel() : int
  682.     {
  683.         return threatLevel;
  684.     }
  685.    
  686.     function GetSoundValue() : int
  687.     {
  688.         return soundValue;
  689.     }
  690.        
  691.     public function WasTauntedToAttack()
  692.     {
  693.         tauntedToAttackTimeStamp = theGame.GetEngineTimeAsSeconds();
  694.     }
  695.    
  696.    
  697.    
  698.     timer function MaintainSpeedTimer( d : float , id : int)
  699.     {
  700.         this.SetBehaviorVariable( 'Editor_MovementSpeed', 0 );
  701.     }
  702.     timer function MaintainFlySpeedTimer( d : float , id : int)
  703.     {
  704.         this.SetBehaviorVariable( 'Editor_FlySpeed', 0 );
  705.     }
  706.    
  707.    
  708.    
  709.    
  710.     public function SetIsInHitAnim( toggle : bool )
  711.     {
  712.         bIsInHitAnim = toggle;
  713.         if ( !toggle )
  714.             this.SignalGameplayEvent('WasHit');
  715.     }
  716.    
  717.     public function IsInHitAnim() : bool
  718.     {
  719.         return bIsInHitAnim;
  720.     }
  721.    
  722.     public function CanChangeBehGraph() : bool
  723.     {
  724.         return allowBehGraphChange;
  725.     }
  726.    
  727.     public function WeaponSoundType() : CItemEntity
  728.     {
  729.         var weapon : SItemUniqueId;
  730.         weapon = GetInventory().GetItemFromSlot( 'r_weapon' );
  731.        
  732.         return GetInventory().GetItemEntityUnsafe(weapon);
  733.     }
  734.  
  735.    
  736.    
  737.    
  738.     function EnableCounterParryFor( time : float )
  739.     {
  740.         bCanPerformCounter = true;
  741.         AddTimer('DisableCounterParry',time,false);
  742.     }
  743.    
  744.     timer function DisableCounterParry( td : float , id : int)
  745.     {
  746.         bCanPerformCounter = false;
  747.     }
  748.    
  749.     var combatStorage : CBaseAICombatStorage;
  750.    
  751.     public final function IsAttacking() : bool
  752.     {
  753.         if ( !combatStorage )
  754.             combatStorage = (CBaseAICombatStorage)GetAIStorageObject('CombatData');
  755.            
  756.         if(combatStorage)
  757.         {
  758.             return combatStorage.GetIsAttacking();
  759.         }
  760.        
  761.         return false;
  762.     }
  763.        
  764.     public final function RecalcLevel()
  765.     {
  766.         if(!IsAlive())
  767.             return;
  768.            
  769.         currentLevel = thePlayer.GetLevel();   
  770.        
  771.         AddLevelBonuses(0, 0);
  772.     }
  773.    
  774.    
  775.     protected function PerformCounterCheck(parryInfo: SParryInfo) : bool
  776.     {
  777.         return false;
  778.     }
  779.    
  780.    
  781.     protected function PerformParryCheck(parryInfo : SParryInfo) : bool
  782.     {
  783.         var mult : float;
  784.         var isHeavy : bool;
  785.         var npcTarget : CNewNPC;
  786.         var fistFightParry : bool;
  787.        
  788.         if ( !parryInfo.canBeParried )
  789.             return false;
  790.        
  791.         if( this.IsHuman() && ((CHumanAICombatStorage)this.GetAIStorageObject('CombatData')).IsProtectedByQuen() )
  792.             return false;
  793.         if( !CanParryAttack() )
  794.             return false;
  795.         if( !FistFightCheck(parryInfo.target, parryInfo.attacker, fistFightParry) )
  796.             return false;
  797.         if( IsInHitAnim() && HasTag( 'imlerith' ) )
  798.             return false;  
  799.        
  800.         npcTarget = (CNewNPC)parryInfo.target;
  801.        
  802.         if( npcTarget.IsShielded(parryInfo.attacker) || ( !npcTarget.HasShieldedAbility() && parryInfo.targetToAttackerAngleAbs < 90 ) )
  803.         {  
  804.             isHeavy = IsHeavyAttack(parryInfo.attackActionName);
  805.                        
  806.            
  807.             if( HasStaminaToParry( parryInfo.attackActionName ) && ( HasAbility( 'ablParryHeavyAttacks' ) || !isHeavy ) )
  808.             {
  809.                
  810.                 SetBehaviorVariable( 'parryAttackType', (int)PAT_Light );
  811.                
  812.                 if( isHeavy )
  813.                     SignalGameplayEventParamInt( 'ParryPerform', 1 );
  814.                 else
  815.                     SignalGameplayEventParamInt( 'ParryPerform', 0 );
  816.             }
  817.             else
  818.             {
  819.                
  820.                 SetBehaviorVariable( 'parryAttackType', (int)PAT_Heavy );
  821.            
  822.                 if( isHeavy )
  823.                     SignalGameplayEventParamInt( 'ParryStagger', 1 );
  824.                 else
  825.                     SignalGameplayEventParamInt( 'ParryStagger', 0 );
  826.             }
  827.            
  828.             if( parryInfo.attacker == thePlayer && parryInfo.attacker.IsWeaponHeld( 'fist' ) && !parryInfo.target.IsWeaponHeld( 'fist' ) )
  829.             {
  830.                 parryInfo.attacker.SetBehaviorVariable( 'reflectAnim', 1.f );
  831.                 parryInfo.attacker.ReactToReflectedAttack(this);               
  832.             }
  833.             else
  834.             {
  835.                 if( isHeavy )
  836.                 {
  837.                     ToggleEffectOnShield( 'heavy_block', true );
  838.                 }
  839.                 else
  840.                 {
  841.                     ToggleEffectOnShield( 'light_block', true );
  842.                 }
  843.             }
  844.            
  845.             return true;
  846.         }      
  847.        
  848.         return false;
  849.     }
  850.        
  851.     public function GetTotalSignSpellPower(signSkill : ESkill) : SAbilityAttributeValue
  852.     {      
  853.         return GetPowerStatValue(CPS_SpellPower);
  854.     }
  855.    
  856.  
  857.    
  858.    
  859.  
  860.    
  861.  
  862.    
  863.     timer function AddLevelBonuses (dt : float, id : int)
  864.     {
  865.  
  866.         var i : int;
  867.         var lvlDiff : int;
  868.         var ciriEntity  : W3ReplacerCiri;
  869.  
  870.        
  871.         RemoveTimer('AddLevelBonuses');
  872.        
  873.  
  874.         ciriEntity = (W3ReplacerCiri)thePlayer;
  875.  
  876.        
  877.         if( ( ( GetNPCType() != ENGT_Guard ) && ( currentLevel + (int)CalculateAttributeValue(GetAttributeValue('level',,true)) < 2 ) ) ) return;
  878.         if ( HasAbility('NPCDoNotGainBoost') ) return;
  879.        
  880.  
  881.            
  882.         if ( HasAbility(theGame.params.ENEMY_BONUS_DEADLY) ) RemoveAbility(theGame.params.ENEMY_BONUS_DEADLY); else
  883.         if ( HasAbility(theGame.params.ENEMY_BONUS_HIGH) ) RemoveAbility(theGame.params.ENEMY_BONUS_HIGH); else
  884.         //if ( HasAbility(theGame.params.ENEMY_BONUS_LOW) ) RemoveAbility(theGame.params.ENEMY_BONUS_LOW); else
  885.         if ( HasAbility(theGame.params.MONSTER_BONUS_DEADLY) ) RemoveAbility(theGame.params.MONSTER_BONUS_DEADLY); else
  886.         if ( HasAbility(theGame.params.MONSTER_BONUS_HIGH) ) RemoveAbility(theGame.params.MONSTER_BONUS_HIGH); else
  887.         if ( HasAbility(theGame.params.MONSTER_BONUS_LOW) ) RemoveAbility(theGame.params.MONSTER_BONUS_LOW);
  888.  
  889.            
  890.         if ( IsHuman() && GetStat( BCS_Essence, true ) < 0 )
  891.         {
  892.             if ( GetNPCType() != ENGT_Guard )
  893.             {
  894.                 if ( !HasAbility(theGame.params.ENEMY_BONUS_PER_LEVEL) ) AddAbilityMultiple(theGame.params.ENEMY_BONUS_PER_LEVEL, currentLevel-1);
  895.             } else
  896.  
  897.             {
  898.                 if ( !HasAbility(theGame.params.ENEMY_BONUS_PER_LEVEL) ) AddAbilityMultiple(theGame.params.ENEMY_BONUS_PER_LEVEL, 1 + GetWitcherPlayer().GetLevel() + RandRange( 11, 13 ) );
  899.             }
  900.  
  901.            
  902.             if ( thePlayer.IsCiri() && theGame.GetDifficultyMode() == EDM_Hardcore && !HasAbility('CiriHardcoreDebuffHuman') ) AddAbility('CiriHardcoreDebuffHuman');
  903.  
  904.                
  905.             if ( !ciriEntity )
  906.             {
  907.                 lvlDiff = (int)CalculateAttributeValue(GetAttributeValue('level',,true)) - thePlayer.GetLevel();
  908.                 if      ( lvlDiff >= theGame.params.LEVEL_DIFF_DEADLY ) { if ( !HasAbility(theGame.params.ENEMY_BONUS_DEADLY) ) { AddAbility(theGame.params.ENEMY_BONUS_DEADLY, true); AddBuffImmunity(EET_Blindness, 'DeadlyEnemy', true); AddBuffImmunity(EET_WraithBlindness, 'DeadlyEnemy', true); } } 
  909.                 else if ( lvlDiff >= theGame.params.LEVEL_DIFF_HIGH )  { if ( !HasAbility(theGame.params.ENEMY_BONUS_HIGH) ) AddAbility(theGame.params.ENEMY_BONUS_HIGH, true);}
  910.                 else if ( lvlDiff > -theGame.params.LEVEL_DIFF_HIGH )  { }
  911.                 //else                    { if ( !HasAbility(theGame.params.ENEMY_BONUS_LOW) ) AddAbility(theGame.params.ENEMY_BONUS_LOW, true); }     
  912.             }    
  913.  
  914.         }
  915.         else
  916.         {
  917.             if ( GetStat( BCS_Vitality, true ) > 0 )
  918.             {
  919.                 if ( !ciriEntity )
  920.                 {
  921.                     lvlDiff = (int)CalculateAttributeValue(GetAttributeValue('level',,true)) - thePlayer.GetLevel();
  922.                     if      ( lvlDiff >= theGame.params.LEVEL_DIFF_DEADLY ) { if ( !HasAbility(theGame.params.ENEMY_BONUS_DEADLY) ) { AddAbility(theGame.params.ENEMY_BONUS_DEADLY, true); AddBuffImmunity(EET_Blindness, 'DeadlyEnemy', true); AddBuffImmunity(EET_WraithBlindness, 'DeadlyEnemy', true); } } 
  923.                     else if ( lvlDiff >= theGame.params.LEVEL_DIFF_HIGH )  { if ( !HasAbility(theGame.params.ENEMY_BONUS_HIGH) ) AddAbility(theGame.params.ENEMY_BONUS_HIGH, true);}
  924.                     else if ( lvlDiff > -theGame.params.LEVEL_DIFF_HIGH )  { }
  925.                     //else                    { if ( !HasAbility(theGame.params.ENEMY_BONUS_LOW) ) AddAbility(theGame.params.ENEMY_BONUS_LOW, true); }     
  926.                    
  927.                     if ( !HasAbility(theGame.params.ENEMY_BONUS_PER_LEVEL) ) AddAbilityMultiple(theGame.params.ENEMY_BONUS_PER_LEVEL, currentLevel-1);
  928.                 }
  929.             } else
  930.  
  931.             {
  932.            
  933.             if ( (int)CalculateAttributeValue( GetAttributeValue('armor') ) > 0 )
  934.  
  935.             {
  936.                 if ( GetIsMonsterTypeGroup() )
  937.                 {
  938.                     if ( !HasAbility(theGame.params.MONSTER_BONUS_PER_LEVEL_GROUP_ARMORED) ) AddAbilityMultiple(theGame.params.MONSTER_BONUS_PER_LEVEL_GROUP_ARMORED, currentLevel-1);
  939.                 } else
  940.  
  941.                 {
  942.                     if ( !HasAbility(theGame.params.MONSTER_BONUS_PER_LEVEL_ARMORED) ) AddAbilityMultiple(theGame.params.MONSTER_BONUS_PER_LEVEL_ARMORED, currentLevel-1);
  943.                 }
  944.             }
  945.             else
  946.             {
  947.                 if ( GetIsMonsterTypeGroup() )
  948.                 {
  949.                     if ( !HasAbility(theGame.params.MONSTER_BONUS_PER_LEVEL_GROUP) ) AddAbilityMultiple(theGame.params.MONSTER_BONUS_PER_LEVEL_GROUP, currentLevel-1);
  950.                 } else
  951.  
  952.                 {
  953.                     if ( !HasAbility(theGame.params.MONSTER_BONUS_PER_LEVEL) ) AddAbilityMultiple(theGame.params.MONSTER_BONUS_PER_LEVEL, currentLevel-1);
  954.                 }
  955.             }
  956.  
  957.            
  958.            
  959.             if ( thePlayer.IsCiri() && theGame.GetDifficultyMode() == EDM_Hardcore && !HasAbility('CiriHardcoreDebuffMonster') ) AddAbility('CiriHardcoreDebuffMonster');
  960.                
  961.             if ( !ciriEntity )
  962.             {
  963.                 lvlDiff = (int)CalculateAttributeValue(GetAttributeValue('level',,true)) - thePlayer.GetLevel();
  964.                 if      ( lvlDiff >= theGame.params.LEVEL_DIFF_DEADLY ) { if ( !HasAbility(theGame.params.MONSTER_BONUS_DEADLY) ) { AddAbility(theGame.params.MONSTER_BONUS_DEADLY, true); AddBuffImmunity(EET_Blindness, 'DeadlyEnemy', true); AddBuffImmunity(EET_WraithBlindness, 'DeadlyEnemy', true); } } 
  965.                 else if ( lvlDiff >= theGame.params.LEVEL_DIFF_HIGH )  { if ( !HasAbility(theGame.params.MONSTER_BONUS_HIGH) ) AddAbility(theGame.params.MONSTER_BONUS_HIGH, true); }
  966.                 else if ( lvlDiff > -theGame.params.LEVEL_DIFF_HIGH )  { }
  967.                 //else                    { if ( !HasAbility(theGame.params.MONSTER_BONUS_LOW) ) AddAbility(theGame.params.MONSTER_BONUS_LOW, true); }     
  968.             }
  969.             }    
  970.            
  971.         }
  972.        
  973.     }
  974.    
  975.  
  976.     public function GainStat( stat : EBaseCharacterStats, amount : float )
  977.     {
  978.        
  979.         if(stat == BCS_Panic && IsHorse() && thePlayer.GetUsedVehicle() == this && thePlayer.HasBuff(EET_Mutagen25))
  980.         {
  981.             return;
  982.         }
  983.        
  984.         super.GainStat(stat, amount);
  985.     }
  986.    
  987.     public function ForceSetStat(stat : EBaseCharacterStats, val : float)
  988.     {
  989.        
  990.         if(stat == BCS_Panic && IsHorse() && thePlayer.GetUsedVehicle() == this && thePlayer.HasBuff(EET_Mutagen25) && val >= GetStat(BCS_Panic))
  991.         {
  992.             return;
  993.         }
  994.        
  995.         super.ForceSetStat(stat, val);
  996.     }
  997.    
  998.    
  999.    
  1000.    
  1001.    
  1002.     timer function FundamentalsAchFailTimer(dt : float, id : int)
  1003.     {
  1004.         RemoveTag('failedFundamentalsAchievement');
  1005.     }
  1006.    
  1007.    
  1008.    
  1009.    
  1010.  
  1011.     protected function CriticalBuffInformBehavior(buff : CBaseGameplayEffect)
  1012.     {
  1013.         SignalGameplayEventParamInt('CriticalState',(int)GetBuffCriticalType(buff));
  1014.     }
  1015.    
  1016.    
  1017.     public function StartCSAnim(buff : CBaseGameplayEffect) : bool
  1018.     {
  1019.         if(super.StartCSAnim(buff))
  1020.         {
  1021.             CriticalBuffInformBehavior(buff);
  1022.             return true;
  1023.         }
  1024.          
  1025.         return false;
  1026.     }
  1027.    
  1028.     public function CSAnimStarted(buff : CBaseGameplayEffect) : bool
  1029.     {
  1030.         return super.StartCSAnim(buff);
  1031.     }
  1032.    
  1033.     function SetCanPlayHitAnim( flag : bool )
  1034.     {
  1035.         if( !flag && this.IsHuman() && this.GetAttitude( thePlayer ) != AIA_Friendly )
  1036.         {
  1037.             super.SetCanPlayHitAnim( flag );
  1038.         }
  1039.         else
  1040.         {
  1041.             super.SetCanPlayHitAnim( flag );
  1042.         }
  1043.     }
  1044.  
  1045.    
  1046.    
  1047.     event OnStartFistfightMinigame()
  1048.     {
  1049.         super.OnStartFistfightMinigame();
  1050.        
  1051.         thePlayer.ProcessLockTarget( this );
  1052.         SignalGameplayEventParamInt('ChangePreferedCombatStyle',(int)EBG_Combat_Fists );
  1053.         SetTemporaryAttitudeGroup( 'fistfight_opponent', AGP_Fistfight );
  1054.         ForceVulnerableImmortalityMode();
  1055.         if ( !thePlayer.IsFistFightMinigameToTheDeath() )
  1056.             SetImmortalityMode(AIM_Unconscious, AIC_Fistfight);
  1057.         // if(FactsQuerySum("NewGamePlus") > 0) //
  1058.         // {FistFightNewGamePlusSetup();} //
  1059.         // FistFightHealthSetup(); //
  1060.        
  1061.     }
  1062.    
  1063.     event OnEndFistfightMinigame()
  1064.     {  
  1065.         SignalGameplayEvent('ResetPreferedCombatStyle');
  1066.         ResetTemporaryAttitudeGroup( AGP_Fistfight );
  1067.         RestoreImmortalityMode();
  1068.         LowerGuard();
  1069.         if ( IsKnockedUnconscious() )
  1070.         {
  1071.             SignalGameplayEvent('ForceStopUnconscious');
  1072.         }
  1073.         if ( !IsAlive() )
  1074.         {
  1075.             Revive();
  1076.         }
  1077.         FistFightHealthSetup();
  1078.        
  1079.         super.OnEndFistfightMinigame();
  1080.     }
  1081.        
  1082.     private function FistFightHealthSetup()
  1083.     {
  1084.        
  1085.         if ( HasAbility( 'fistfight_minigame' ) )
  1086.         {
  1087.             FistFightersHealthDiff();
  1088.         }
  1089.         else return;
  1090.  
  1091.     }
  1092.    
  1093.     private function FistFightersHealthDiff()
  1094.     {
  1095.         var vitality        : float;
  1096.  
  1097.        
  1098.         if ( HasAbility( 'StatsFistsTutorial' ) )
  1099.         {
  1100.             AddAbility( 'HealthFistFightTutorial', false );
  1101.         }
  1102.         else if ( HasAbility( 'StatsFistsEasy' ) )
  1103.         {
  1104.             AddAbility( 'HealthFistFightEasy', false );
  1105.         }
  1106.         else if ( HasAbility( 'StatsFistsMedium' ) )
  1107.         {
  1108.             AddAbility( 'HealthFistFightMedium', false );
  1109.         }
  1110.         else if ( HasAbility( 'StatsFistsHard' ) )
  1111.         {
  1112.             AddAbility( 'HealthFistFightHard', false );
  1113.         }
  1114.         vitality = abilityManager.GetStatMax( BCS_Vitality );
  1115.         SetHealthPerc( 100 );
  1116.     }
  1117.    
  1118.     private function FistFightNewGamePlusSetup()
  1119.     {
  1120.         if ( HasAbility( 'NPCLevelBonus' ) )
  1121.         {
  1122.             RemoveAbilityMultiple( 'NPCLevelBonus', theGame.params.GetNewGamePlusLevel() );
  1123.             newGamePlusFakeLevelAddon = true;
  1124.             currentLevel = thePlayer.GetLevel();
  1125.             RecalcLevel();
  1126.         }
  1127.     }
  1128.    
  1129.     private function ApplyFistFightLevelDiff()
  1130.     {
  1131.         var lvlDiff     : int;
  1132.         var i           : int;
  1133.         var attribute   : SAbilityAttributeValue;
  1134.         var min, max    : SAbilityAttributeValue;
  1135.         var ffHP, ffAP  : SAbilityAttributeValue;
  1136.         var dm          : CDefinitionsManagerAccessor;
  1137.        
  1138.         lvlDiff = 0;
  1139.        
  1140.         if ( !HasAbility('NPC fists _Stats') )
  1141.         {
  1142.             dm = theGame.GetDefinitionsManager();
  1143.             dm.GetAbilityAttributeValue('NPC fists _Stats', 'vitality', min, max);
  1144.             ffHP = GetAttributeRandomizedValue(min, max);
  1145.             dm.GetAbilityAttributeValue('NPC fists _Stats', 'attack_power', min, max);
  1146.             ffAP = GetAttributeRandomizedValue(min, max);
  1147.         }
  1148.        
  1149.         if ( lvlDiff < -theGame.params.LEVEL_DIFF_HIGH )
  1150.         {
  1151.             for (i=0; i < 5; i+=1)
  1152.             {
  1153.                 AddAbility(theGame.params.ENEMY_BONUS_FISTFIGHT_LOW, true);
  1154.                 attribute = GetAttributeValue('vitality');
  1155.                 attribute += ffHP;
  1156.                 if (attribute.valueMultiplicative <= 0)
  1157.                 {
  1158.                     RemoveAbility(theGame.params.ENEMY_BONUS_FISTFIGHT_LOW);
  1159.                     return;
  1160.                 }
  1161.                 attribute = GetAttributeValue('attack_power');
  1162.                 attribute += ffAP;
  1163.                 if (attribute.valueMultiplicative <= 0)
  1164.                 {
  1165.                     RemoveAbility(theGame.params.ENEMY_BONUS_FISTFIGHT_LOW);
  1166.                     return;
  1167.                 }
  1168.             }
  1169.         }
  1170.         else if ( lvlDiff < 0 )
  1171.         {
  1172.             for (i=0; i < -lvlDiff; i+=1)
  1173.             {
  1174.                 AddAbility(theGame.params.ENEMY_BONUS_FISTFIGHT_LOW, true);
  1175.                 attribute = GetAttributeValue('vitality');
  1176.                 if (attribute.valueMultiplicative <= 0)
  1177.                 {
  1178.                     RemoveAbility(theGame.params.ENEMY_BONUS_FISTFIGHT_LOW);
  1179.                     return;
  1180.                 }
  1181.                 attribute = GetAttributeValue('attack_power');
  1182.                 if (attribute.valueMultiplicative <= 0)
  1183.                 {
  1184.                     RemoveAbility(theGame.params.ENEMY_BONUS_FISTFIGHT_LOW);
  1185.                     return;
  1186.                 }
  1187.             }
  1188.         }
  1189.         else if ( lvlDiff > theGame.params.LEVEL_DIFF_HIGH )
  1190.             AddAbilityMultiple(theGame.params.ENEMY_BONUS_FISTFIGHT_HIGH, 1);
  1191.         else if ( lvlDiff > 0  )
  1192.             AddAbilityMultiple(theGame.params.ENEMY_BONUS_FISTFIGHT_HIGH, 1);
  1193.     }
  1194.    
  1195.     private function RemoveFistFightLevelDiff()
  1196.     {
  1197.         RemoveAbilityMultiple(theGame.params.ENEMY_BONUS_FISTFIGHT_LOW, 5);
  1198.         RemoveAbilityMultiple(theGame.params.ENEMY_BONUS_FISTFIGHT_HIGH, 5);
  1199.     }
  1200.  
  1201.    
  1202.    
  1203.    
  1204.    
  1205.     private function IsThisStanceRegular( Stance : ENpcStance ) : bool
  1206.     {
  1207.         if( Stance == NS_Normal ||
  1208.             Stance == NS_Strafe ||
  1209.             Stance == NS_Retreat )
  1210.         {
  1211.             return true;
  1212.         }
  1213.        
  1214.         return false;
  1215.     }
  1216.    
  1217.     private function IsThisStanceDefensive( Stance : ENpcStance ) : bool
  1218.     {
  1219.         if( Stance == NS_Guarded ||
  1220.             Stance == NS_Guarded )
  1221.         {
  1222.             return true;
  1223.         }
  1224.        
  1225.         return false;
  1226.     }
  1227.    
  1228.     function GetCurrentStance() : ENpcStance
  1229.     {
  1230.         var l_currentStance : int;
  1231.         l_currentStance = (int)this.GetBehaviorVariable( 'npcStance');
  1232.         return l_currentStance;
  1233.     }
  1234.    
  1235.     function GetRegularStance() : ENpcStance
  1236.     {
  1237.         return this.regularStance;
  1238.     }
  1239.    
  1240.     function ReturnToRegularStance()
  1241.     {
  1242.         this.SetBehaviorVariable( 'npcStance',(int)this.regularStance);
  1243.     }
  1244.    
  1245.     function IsInRegularStance() : bool
  1246.     {
  1247.         if( GetCurrentStance() == GetRegularStance() )
  1248.         {
  1249.             return true;
  1250.         }
  1251.        
  1252.         return false;
  1253.     }
  1254.    
  1255.     function ChangeStance( newStance : ENpcStance ) : bool
  1256.     {
  1257.         if ( IsThisStanceDefensive( newStance ) )
  1258.         {
  1259.             LogChannel('NPC ChangeStance', "You shouldn't use this function to change to this stance - " + newStance );
  1260.         }
  1261.         else if ( IsThisStanceRegular( newStance ) )
  1262.         {
  1263.             if ( this.SetBehaviorVariable( 'npcStance',(int)newStance) )
  1264.             {
  1265.                 this.regularStance = newStance;
  1266.                 return true;
  1267.             }
  1268.         }
  1269.         else
  1270.         {
  1271.             return this.SetBehaviorVariable( 'npcStance',(int)newStance);
  1272.         }
  1273.         return false;
  1274.     }
  1275.    
  1276.     function RaiseGuard() : bool
  1277.     {
  1278.         SetGuarded( true );
  1279.         return true;
  1280.     }
  1281.    
  1282.     function LowerGuard() : bool
  1283.     {
  1284.         SetGuarded( false );
  1285.         return true;
  1286.     }
  1287.    
  1288.    
  1289.    
  1290.    
  1291.    
  1292.     function IsInAgony() : bool
  1293.     {
  1294.         return bAgony;
  1295.     }
  1296.    
  1297.     function EnterAgony()
  1298.     {
  1299.         bAgony = true;
  1300.     }
  1301.    
  1302.     function EndAgony()
  1303.     {
  1304.         bAgony = false;
  1305.     }
  1306.    
  1307.     function EnableDeathAndAgony()
  1308.     {
  1309.         bPlayDeathAnim = true;
  1310.         bAgonyDisabled = false;
  1311.     }
  1312.    
  1313.     function EnableDeath()
  1314.     {
  1315.         bPlayDeathAnim = true;
  1316.     }
  1317.    
  1318.     function EnableAgony()
  1319.     {
  1320.         bAgonyDisabled = false;
  1321.     }
  1322.    
  1323.     function DisableDeathAndAgony()
  1324.     {
  1325.         bPlayDeathAnim = false;
  1326.         bAgonyDisabled = true;
  1327.     }
  1328.     function DisableAgony()
  1329.     {
  1330.         bAgonyDisabled = true;
  1331.     }
  1332.    
  1333.     function IsAgonyDisabled() : bool
  1334.     {
  1335.         return bAgonyDisabled;
  1336.     }
  1337.    
  1338.     function IsInFinisherAnim() : bool
  1339.     {
  1340.         return bFinisher;
  1341.     }
  1342.    
  1343.     function FinisherAnimStart()
  1344.     {
  1345.         bPlayDeathAnim = false;    
  1346.         bFinisher = true;
  1347.         SetBehaviorMimicVariable( 'gameplayMimicsMode', (float)(int)GMM_Death );
  1348.     }
  1349.    
  1350.     function FinisherAnimInterrupted()
  1351.     {
  1352.         bPlayDeathAnim          = true;    
  1353.         bFinisher               = false;
  1354.         bFinisherInterrupted    = true;
  1355.     }
  1356.    
  1357.     function ResetFinisherAnimInterruptionState()
  1358.     {
  1359.         bFinisherInterrupted = false;
  1360.     }
  1361.    
  1362.     function WasFinisherAnimInterrupted() : bool
  1363.     {
  1364.         return bFinisherInterrupted;
  1365.     }
  1366.    
  1367.     function FinisherAnimEnd()
  1368.     {
  1369.         bFinisher = false;
  1370.     }
  1371.    
  1372.     function ShouldPlayDeathAnim() : bool
  1373.     {
  1374.         return bPlayDeathAnim;
  1375.     }
  1376.    
  1377.     function NPCGetAgonyAnim() : CName
  1378.     {
  1379.         var agonyType : float;
  1380.         agonyType = GetBehaviorVariable( 'AgonyType');
  1381.        
  1382.         if (agonyType == (int)AT_ThroatCut)
  1383.         {
  1384.             return 'man_throat_cut_start';
  1385.         }
  1386.         else if(agonyType == (int)AT_Knockdown)
  1387.         {
  1388.             return 'man_wounded_crawl_killed';
  1389.         }
  1390.         else
  1391.             return '';
  1392.     }
  1393.    
  1394.     function GeraltGetAgonyAnim() : CName
  1395.     {
  1396.         var agonyType : float;
  1397.         agonyType = GetBehaviorVariable( 'AgonyType');
  1398.        
  1399.         if (agonyType == (int)AT_ThroatCut)
  1400.         {
  1401.             return 'man_ger_throat_cut_attack_01';
  1402.         }
  1403.         else if(agonyType == (int)AT_Knockdown)
  1404.         {
  1405.             return 'man_ger_crawl_finish';
  1406.         }
  1407.         else
  1408.             return '';
  1409.     }
  1410.    
  1411.    
  1412.    
  1413.    
  1414.    
  1415.     protected function PlayHitAnimation(damageAction : W3DamageAction, animType : EHitReactionType)
  1416.     {
  1417.         var node : CNode;
  1418.                
  1419.         SetBehaviorVariable( 'HitReactionWeapon', ProcessSwordOrFistHitReaction( this, (CActor)damageAction.attacker ) );
  1420.         SetBehaviorVariable( 'HitReactionType',(int)animType);
  1421.  
  1422.         if ( damageAction.attacker )
  1423.         {
  1424.  
  1425.             node = (CNode)damageAction.causer;
  1426.             if (node)
  1427.             {
  1428.                 SetHitReactionDirection(node);
  1429.             }
  1430.             else
  1431.             {
  1432.                 SetHitReactionDirection(damageAction.attacker);
  1433.             }
  1434.             SetDetailedHitReaction(damageAction.GetSwingType(), damageAction.GetSwingDirection());
  1435.         }
  1436.        
  1437.         if ( this.customHits )
  1438.         {
  1439.             damageAction.customHitReactionRequested = true;
  1440.         }
  1441.         else
  1442.         {
  1443.             damageAction.hitReactionAnimRequested = true;
  1444.         }
  1445.     }
  1446.    
  1447.  
  1448.     public function ReactToBeingHit(damageAction : W3DamageAction, optional buffNotApplied : bool) : bool
  1449.     {
  1450.         var ret                             : bool;
  1451.         var percentageLoss                  : float;
  1452.         var totalHealth                     : float;
  1453.         var damaveValue                     : float;
  1454.         var healthLossToForceLand_perc      : SAbilityAttributeValue;
  1455.         var witcher                         : W3PlayerWitcher;
  1456.         var node                            : CNode;
  1457.         var boltCauser                      : W3BoltProjectile;
  1458.  
  1459.         var attackAction                    : W3Action_Attack;
  1460.        
  1461.         damaveValue                  = damageAction.GetDamageDealt();
  1462.         totalHealth                  = GetMaxHealth();
  1463.         percentageLoss              = damaveValue / totalHealth;
  1464.         healthLossToForceLand_perc   = GetAttributeValue( 'healthLossToForceLand_perc' );
  1465.        
  1466.        
  1467.         if( percentageLoss >= healthLossToForceLand_perc.valueBase && ( GetCurrentStance() == NS_Fly || ( !IsUsingVehicle() && GetCurrentStance() != NS_Swim && !((CMovingPhysicalAgentComponent) GetMovingAgentComponent()).IsOnGround()) ) )
  1468.         {
  1469.            
  1470.             if( !((CBaseGameplayEffect) damageAction.causer ) )
  1471.             {
  1472.                 damageAction.AddEffectInfo( EET_Knockdown);
  1473.             }
  1474.         }
  1475.        
  1476.        
  1477.         boltCauser = (W3BoltProjectile)( damageAction.causer );
  1478.         if( boltCauser )
  1479.  
  1480.         {
  1481.             if( HasAbility( 'AdditiveHits' ) )
  1482.             {
  1483.                 SetUseAdditiveHit( true, true, true );
  1484.                 ret = super.ReactToBeingHit(damageAction, buffNotApplied);
  1485.                
  1486.                 if( ret || damageAction.DealsAnyDamage())
  1487.                     SignalGameplayDamageEvent('BeingHit', damageAction );
  1488.             }
  1489.             else if( HasAbility( 'mon_wild_hunt_default' ) )
  1490.             {
  1491.                 ret = false;
  1492.             }
  1493.             else if( !boltCauser.HasTag( 'bodkinbolt' ) || this.IsUsingHorse() || RandRange(100) < 75.f )
  1494.             {
  1495.                 ret = super.ReactToBeingHit(damageAction, buffNotApplied);
  1496.                
  1497.                 if( ret || damageAction.DealsAnyDamage())
  1498.                     SignalGameplayDamageEvent('BeingHit', damageAction );
  1499.             }
  1500.             else
  1501.             {
  1502.                 ret = false;
  1503.             }
  1504.         }
  1505.         else
  1506.         {
  1507.             ret = super.ReactToBeingHit(damageAction, buffNotApplied);
  1508.            
  1509.             if( ret || damageAction.DealsAnyDamage() )
  1510.                 SignalGameplayDamageEvent('BeingHit', damageAction );
  1511.         }
  1512.        
  1513.         if( damageAction.additiveHitReactionAnimRequested == true )
  1514.         {
  1515.             node = (CNode)damageAction.causer;
  1516.             if (node)
  1517.             {
  1518.                 SetHitReactionDirection(node);
  1519.             }
  1520.             else
  1521.             {
  1522.                 SetHitReactionDirection(damageAction.attacker);
  1523.             }
  1524.         }
  1525.        
  1526.         if(((CPlayer)damageAction.attacker || !((CNewNPC)damageAction.attacker)) && damageAction.DealsAnyDamage())
  1527.             theTelemetry.LogWithLabelAndValue( TE_FIGHT_ENEMY_GETS_HIT, damageAction.victim.ToString(), (int)damageAction.processedDmg.vitalityDamage + (int)damageAction.processedDmg.essenceDamage );
  1528.        
  1529.        
  1530.         witcher = GetWitcherPlayer();
  1531.         if ( damageAction.attacker == witcher && HasBuff( EET_AxiiGuardMe ) )
  1532.         {
  1533.            
  1534.             if(!witcher.CanUseSkill(S_Magic_s05) || witcher.GetSkillLevel(S_Magic_s05) < 3)
  1535.                 RemoveBuff(EET_AxiiGuardMe, true);
  1536.         }
  1537.        
  1538.         if(damageAction.attacker == thePlayer && damageAction.DealsAnyDamage() && !damageAction.IsDoTDamage())
  1539.         {
  1540.             attackAction = (W3Action_Attack) damageAction;
  1541.            
  1542.         }
  1543.        
  1544.         return ret;
  1545.     }
  1546.    
  1547.    
  1548.     public function GetHitCounter(optional total : bool) : int
  1549.     {
  1550.         if ( total )
  1551.             return totalHitCounter;
  1552.         return hitCounter;
  1553.     }
  1554.    
  1555.     public function IncHitCounter()
  1556.     {
  1557.         hitCounter += 1;
  1558.         totalHitCounter += 1;
  1559.         AddTimer('ResetHitCounter',2.0,false);
  1560.     }
  1561.    
  1562.     private timer function ResetHitCounter( deta : float , id : int)
  1563.     {
  1564.         hitCounter = 0;
  1565.     }  
  1566.    
  1567.    
  1568.    
  1569.    
  1570.     function Kill(optional ignoreImmortalityMode : bool, optional attacker : CGameplayEntity, optional source : name )
  1571.     {
  1572.         var action : W3DamageAction;
  1573.        
  1574.         if ( theGame.CanLog() )
  1575.         {      
  1576.             LogDMHits("CActor.Kill: called for actor <<" + this + ">>");
  1577.         }
  1578.        
  1579.         action = GetKillAction(ignoreImmortalityMode, attacker, source);
  1580.        
  1581.         if ( this.IsKnockedUnconscious() )
  1582.         {
  1583.             DisableDeathAndAgony();
  1584.             OnDeath(action);
  1585.         }
  1586.         else if ( !abilityManager )
  1587.         {
  1588.             OnDeath(action);
  1589.         }
  1590.         else
  1591.         {
  1592.             if ( ignoreImmortalityMode )
  1593.                 this.immortalityFlags = 0;
  1594.                
  1595.             theGame.damageMgr.ProcessAction(action);
  1596.         }
  1597.        
  1598.         delete action;
  1599.     }
  1600.    
  1601.     public final function GetLevel() : int
  1602.     {
  1603.         return (int)CalculateAttributeValue(GetAttributeValue('level',,true));
  1604.     }
  1605.    
  1606.     public final function GetLevelFromLocalVar() : int
  1607.     {
  1608.         return currentLevel;
  1609.     }
  1610.    
  1611.     function GetExperienceDifferenceLevelName( out strLevel : string ) : string
  1612.     {
  1613.         var lvlDiff : int;
  1614.         var currentLevel : int;
  1615.         var ciriEntity  : W3ReplacerCiri;
  1616.  
  1617.         currentLevel = GetLevel() + levelFakeAddon;
  1618.  
  1619.         if ( newGamePlusFakeLevelAddon )
  1620.         {
  1621.             currentLevel += theGame.params.GetNewGamePlusLevel();
  1622.         }
  1623.            
  1624.  
  1625.         if( GetAttitude( thePlayer ) != AIA_Hostile )
  1626.         {
  1627.             if( ( GetAttitudeGroup() != 'npc_charmed' ) )
  1628.             {
  1629.                 strLevel = "";
  1630.                 return "none";
  1631.             }
  1632.         }
  1633.        
  1634.         ciriEntity = (W3ReplacerCiri)thePlayer;
  1635.         if ( ciriEntity )
  1636.         {
  1637.             strLevel = "<font color=\"#66FF66\">" + currentLevel + "</font>";
  1638.             return "normalLevel";
  1639.         }
  1640.        
  1641.         lvlDiff = currentLevel - thePlayer.GetLevel();
  1642.        
  1643.         if ( lvlDiff >= theGame.params.LEVEL_DIFF_DEADLY )
  1644.         {
  1645.             strLevel = "";
  1646.             return "deadlyLevel";
  1647.         }  
  1648.         else if ( lvlDiff >= theGame.params.LEVEL_DIFF_HIGH )
  1649.         {
  1650.             strLevel = "<font color=\"#FF1919\">" + currentLevel + "</font>";
  1651.             return "highLevel";
  1652.         }
  1653.         else if ( lvlDiff > -theGame.params.LEVEL_DIFF_HIGH )
  1654.         {
  1655.             strLevel = "<font color=\"#66FF66\">" + currentLevel + "</font>";
  1656.             return "normalLevel";
  1657.         }
  1658.         else
  1659.         {
  1660.             strLevel = "<font color=\"#E6E6E6\">" + currentLevel + "</font>";
  1661.             return "lowLevel";
  1662.         }
  1663.         return "none";
  1664.     }
  1665.    
  1666.    
  1667.     private function ShouldGiveExp(attacker : CGameplayEntity) : bool
  1668.     {
  1669.         var actor : CActor;
  1670.         var npc : CNewNPC;
  1671.         var victimAt : EAIAttitude;
  1672.         var giveExp : bool;
  1673.        
  1674.         victimAt = GetAttitudeBetween(thePlayer, this);
  1675.         giveExp = false;
  1676.        
  1677.        
  1678.         if(victimAt == AIA_Hostile)
  1679.         {
  1680.             if(attacker == thePlayer && !((W3PlayerWitcher)thePlayer) )
  1681.             {
  1682.                
  1683.                 giveExp = false;
  1684.             }
  1685.             else if(attacker == thePlayer)
  1686.             {
  1687.                
  1688.                 giveExp = true;
  1689.             }
  1690.            
  1691.             else if(VecDistance(thePlayer.GetWorldPosition(), GetWorldPosition()) <= 20)
  1692.             {
  1693.                 npc = (CNewNPC)attacker;
  1694.                 if(!npc || npc.npcGroupType != ENGT_Guard) 
  1695.                 {
  1696.                     actor = (CActor)attacker;
  1697.                     if(!actor)
  1698.                     {
  1699.                        
  1700.                         giveExp = true;
  1701.                     }
  1702.                     else if(actor.HasTag(theGame.params.TAG_NPC_IN_PARTY) || actor.HasBuff(EET_AxiiGuardMe))
  1703.                     {
  1704.                        
  1705.                         giveExp = true;
  1706.                     }                          
  1707.                 }
  1708.             }
  1709.         }
  1710.        
  1711.         return giveExp;
  1712.     }
  1713.    
  1714.     function AddBestiaryKnowledge()
  1715.     {
  1716.         var manager : CWitcherJournalManager;
  1717.  
  1718.         manager = theGame.GetJournalManager();
  1719.  
  1720.         if ( GetSfxTag() == 'sfx_arachas' && HasAbility('mon_arachas_armored') )    activateBaseBestiaryEntryWithAlias("BestiaryArmoredArachas", manager); else
  1721.         if ( GetSfxTag() == 'sfx_arachas' && HasAbility('mon_poison_arachas')  )    activateBaseBestiaryEntryWithAlias("BestiaryPoisonousArachas", manager); else
  1722.         if ( GetSfxTag() == 'sfx_bear' )                                            activateBaseBestiaryEntryWithAlias("BestiaryBear", manager); else
  1723.         if ( GetSfxTag() == 'sfx_alghoul' )                                         activateBaseBestiaryEntryWithAlias("BestiaryAlghoul", manager); else
  1724.         if ( HasAbility('mon_greater_miscreant') )                              activateBaseBestiaryEntryWithAlias("BestiaryMiscreant", manager); else
  1725.         if ( HasAbility('mon_basilisk') )                                       activateBaseBestiaryEntryWithAlias("BestiaryBasilisk", manager); else
  1726.  
  1727.         if ( GetSfxTag() == 'sfx_cockatrice' )                                      activateBaseBestiaryEntryWithAlias("BestiaryCockatrice", manager); else
  1728.         if ( GetSfxTag() == 'sfx_arachas' && !HasAbility('mon_arachas_armored') && !HasAbility('mon_poison_arachas') ) activateBaseBestiaryEntryWithAlias("BestiaryCrabSpider", manager); else
  1729.         if ( GetSfxTag() == 'sfx_katakan' && HasAbility('mon_ekimma') )             activateBaseBestiaryEntryWithAlias("BestiaryEkkima", manager); else
  1730.         if ( GetSfxTag() == 'sfx_elemental_dao' )                                   activateBaseBestiaryEntryWithAlias("BestiaryElemental", manager); else
  1731.         if ( GetSfxTag() == 'sfx_endriaga' && HasAbility('mon_endriaga_soldier_tailed') ) activateBaseBestiaryEntryWithAlias("BestiaryEndriaga", manager); else
  1732.         if ( GetSfxTag() == 'sfx_endriaga' && HasAbility('mon_endriaga_worker') )   activateBaseBestiaryEntryWithAlias("BestiaryEndriagaWorker", manager); else
  1733.         if ( GetSfxTag() == 'sfx_endriaga' && HasAbility('mon_endriaga_soldier_spikey') ) activateBaseBestiaryEntryWithAlias("BestiaryEndriagaTruten", manager); else
  1734.         if ( HasAbility('mon_forktail_young') || HasAbility('mon_forktail') || HasAbility('mon_forktail_mh') ) activateBaseBestiaryEntryWithAlias("BestiaryForktail", manager); else
  1735.         if ( GetSfxTag() == 'sfx_ghoul' )                                           activateBaseBestiaryEntryWithAlias("BestiaryGhoul", manager); else
  1736.         if ( GetSfxTag() == 'sfx_golem' )                                           activateBaseBestiaryEntryWithAlias("BestiaryGolem", manager); else
  1737.         if ( GetSfxTag() == 'sfx_katakan' && !HasAbility('mon_ekimma') )            activateBaseBestiaryEntryWithAlias("BestiaryKatakan", manager); else
  1738.         if ( GetSfxTag() == 'sfx_ghoul' && HasAbility('mon_greater_miscreant') )    activateBaseBestiaryEntryWithAlias("BestiaryMiscreant", manager); else
  1739.         if ( HasAbility('mon_nightwraith')|| HasAbility('mon_nightwraith_mh') ) activateBaseBestiaryEntryWithAlias("BestiaryMoonwright", manager); else
  1740.         if ( HasAbility('mon_noonwraith'))                                      activateBaseBestiaryEntryWithAlias("BestiaryNoonwright", manager); else
  1741.         if ( HasAbility('mon_lycanthrope') )                                    activateBaseBestiaryEntryWithAlias("BestiaryLycanthrope", manager); else
  1742.         if ( GetSfxTag() == 'sfx_werewolf' )                                        activateBaseBestiaryEntryWithAlias("BestiaryWerewolf", manager); else
  1743.         if ( GetSfxTag() == 'sfx_wyvern' )                                          activateBaseBestiaryEntryWithAlias("BestiaryWyvern", manager); else
  1744.         if ( HasAbility('mon_czart') )                                          activateBaseBestiaryEntryWithAlias("BestiaryCzart", manager); else
  1745.         if ( GetSfxTag() == 'sfx_bies' )                                            activateBaseBestiaryEntryWithAlias("BestiaryBies", manager); else
  1746.         if ( GetSfxTag() == 'sfx_wild_dog' )                                        activateBaseBestiaryEntryWithAlias("BestiaryDog", manager); else
  1747.         if ( GetSfxTag() == 'sfx_drowner' )                                         activateBaseBestiaryEntryWithAlias("BestiaryDrowner", manager);
  1748.         if ( GetSfxTag() == 'sfx_elemental_ifryt' )                                 activateBaseBestiaryEntryWithAlias("BestiaryFireElemental", manager); else
  1749.         if ( GetSfxTag() == 'sfx_fogling' )                                         activateBaseBestiaryEntryWithAlias("BestiaryFogling", manager); else
  1750.         if ( GetSfxTag() == 'sfx_gravehag' )                                        activateBaseBestiaryEntryWithAlias("BestiaryGraveHag", manager); else
  1751.         if ( GetSfxTag() == 'sfx_gryphon' )                                         activateBaseBestiaryEntryWithAlias("BestiaryGriffin", manager); else
  1752.         if ( HasAbility('mon_erynia') )                                         activateBaseBestiaryEntryWithAlias("BestiaryErynia", manager); else
  1753.         if ( GetSfxTag() == 'sfx_harpy' )                                           activateBaseBestiaryEntryWithAlias("BestiaryHarpy", manager); else
  1754.         if ( GetSfxTag() == 'sfx_ice_giant' )                                       activateBaseBestiaryEntryWithAlias("BestiaryIceGiant", manager); else
  1755.         if ( GetSfxTag() == 'sfx_lessog' )                                          activateBaseBestiaryEntryWithAlias("BestiaryLeshy", manager); else
  1756.         if ( GetSfxTag() == 'sfx_nekker' )                                          activateBaseBestiaryEntryWithAlias("BestiaryNekker", manager); else
  1757.         if ( GetSfxTag() == 'sfx_siren' )                                           activateBaseBestiaryEntryWithAlias("BestiarySiren", manager); else
  1758.         if ( HasTag('ice_troll') )                                              activateBaseBestiaryEntryWithAlias("BestiaryIceTroll", manager); else
  1759.         if ( GetSfxTag() == 'sfx_troll_cave' )                                      activateBaseBestiaryEntryWithAlias("BestiaryCaveTroll", manager); else
  1760.         if ( GetSfxTag() == 'sfx_waterhag' )                                        activateBaseBestiaryEntryWithAlias("BestiaryWaterHag", manager); else
  1761.         if ( GetSfxTag() == 'sfx_wildhunt_minion' )                                 activateBaseBestiaryEntryWithAlias("BestiaryWhMinion", manager); else
  1762.         if ( GetSfxTag() == 'sfx_wolf' )                                            activateBaseBestiaryEntryWithAlias("BestiaryWolf", manager); else
  1763.         if ( GetSfxTag() == 'sfx_wraith' )                                          activateBaseBestiaryEntryWithAlias("BestiaryWraith", manager); else
  1764.         if ( HasAbility('mon_cyclops') )                                        activateBaseBestiaryEntryWithAlias("BestiaryCyclop", manager); else
  1765.         if ( HasAbility('mon_ice_golem') )                                      activateBaseBestiaryEntryWithAlias("BestiaryIceGolem", manager); else
  1766.         if ( HasAbility('mon_gargoyle') )                                       activateBaseBestiaryEntryWithAlias("BestiaryGargoyle", manager); else
  1767.         if ( HasAbility('mon_rotfiend') || HasAbility('mon_rotfiend_large'))    activateBaseBestiaryEntryWithAlias("BestiaryGreaterRotFiend", manager);
  1768.  
  1769.        
  1770.  
  1771.        
  1772.     }
  1773.    
  1774.    
  1775.     public function CalculateExperiencePoints(optional skipLog : bool) : int
  1776.     {
  1777.         var finalExp : int;
  1778.         var exp : float;
  1779.         var lvlDiff : int;
  1780.         var modDamage, modArmor, modVitality, modOther : float;
  1781.  
  1782.        
  1783.         if ( grantNoExperienceAfterKill || HasAbility('Zero_XP' ) || GetNPCType() == ENGT_Guard ) return 0;
  1784.        
  1785.         modDamage = CalculateAttributeValue(GetAttributeValue('RendingDamage',,true));
  1786.         modDamage += CalculateAttributeValue(GetAttributeValue('BludgeoningDamage',,true));
  1787.         modDamage += CalculateAttributeValue(GetAttributeValue('FireDamage',,true));
  1788.         modDamage += CalculateAttributeValue(GetAttributeValue('ElementalDamage',,true));
  1789.         modDamage += CalculateAttributeValue(GetPowerStatValue(CPS_AttackPower, , true));
  1790.         modDamage *= 5;
  1791.        
  1792.         modArmor = CalculateAttributeValue(GetTotalArmor()) * 100;
  1793.        
  1794.         modVitality = GetStatMax(BCS_Essence) + 3 * GetStatMax(BCS_Vitality);
  1795.  
  1796.         if ( HasAbility('AcidSpit' ) ) modOther = modOther + 2;
  1797.         if ( HasAbility('Aggressive' ) ) modOther = modOther + 2;
  1798.         if ( HasAbility('Charge' ) ) modOther = modOther + 3;
  1799.         if ( HasAbility('ContactBlindness' ) ) modOther = modOther + 2;
  1800.         if ( HasAbility('ContactSlowdown' ) ) modOther = modOther + 2;
  1801.         if ( HasAbility('Cursed' ) ) modOther = modOther + 2;
  1802.         if ( HasAbility('BurnIgnore' ) ) modOther = modOther + 2;
  1803.         if ( HasAbility('DamageBuff' ) ) modOther = modOther + 2;
  1804.         if ( HasAbility('Draconide' ) ) modOther = modOther + 2;
  1805.         if ( HasAbility('Fireball' ) ) modOther = modOther + 2;
  1806.         if ( HasAbility('Flashstep' ) ) modOther = modOther + 2;
  1807.         if ( HasAbility('Flying' ) ) modOther = modOther + 10;
  1808.         if ( HasAbility('Frost' ) ) modOther = modOther + 4;
  1809.         if ( HasAbility('EssenceRegen' ) ) modOther = modOther + 2;
  1810.         if ( HasAbility('Gargoyle' ) ) modOther = modOther + 2;
  1811.         if ( HasAbility('Hypnosis' ) ) modOther = modOther + 2;
  1812.         if ( HasAbility('IceArmor' ) ) modOther = modOther + 5;
  1813.         if ( HasAbility('InstantKillImmune' ) ) modOther = modOther + 2;
  1814.         if ( HasAbility('JumpAttack' ) ) modOther = modOther + 2;
  1815.         if ( HasAbility('Magical' ) ) modOther = modOther + 2;
  1816.         if ( HasAbility('MistForm' ) ) modOther = modOther + 2;
  1817.         if ( HasAbility('MudTeleport' ) ) modOther = modOther + 2;
  1818.         if ( HasAbility('MudAttack' ) ) modOther = modOther + 2;
  1819.         if ( HasAbility('PoisonCloud' ) ) modOther = modOther + 2;
  1820.         if ( HasAbility('PoisonDeath' ) ) modOther = modOther + 2;
  1821.         if ( HasAbility('Rage' ) ) modOther = modOther + 2;
  1822.         if ( HasAbility('Relic' ) ) modOther = modOther + 5;
  1823.         if ( HasAbility('Scream' ) ) modOther = modOther + 2;
  1824.         if ( HasAbility('Shapeshifter' ) ) modOther = modOther + 5;
  1825.         if ( HasAbility('Shout' ) ) modOther = modOther + 2;
  1826.         if ( HasAbility('Spikes' ) ) modOther = modOther + 2;
  1827.         if ( HasAbility('StaggerCounter' ) ) modOther = modOther + 2;
  1828.         if ( HasAbility('StinkCloud' ) ) modOther = modOther + 2;
  1829.         if ( HasAbility('Summon' ) ) modOther = modOther + 2;
  1830.         if ( HasAbility('Tail' ) ) modOther = modOther + 5;
  1831.         if ( HasAbility('Teleport' ) ) modOther = modOther + 5;
  1832.         if ( HasAbility('Thorns' ) ) modOther = modOther + 2;
  1833.         if ( HasAbility('Throw' ) ) modOther = modOther + 2;
  1834.         if ( HasAbility('ThrowFire' ) ) modOther = modOther + 2;
  1835.         if ( HasAbility('ThrowIce' ) ) modOther = modOther + 2;
  1836.         if ( HasAbility('Vampire' ) ) modOther = modOther + 2;
  1837.         if ( HasAbility('Venom' ) ) modOther = modOther + 2;
  1838.         if ( HasAbility('VitalityRegen' ) ) modOther = modOther + 5;
  1839.         if ( HasAbility('Wave' ) ) modOther = modOther + 2;
  1840.         if ( HasAbility('WeakToAard' ) ) modOther = modOther - 2;
  1841.         if ( HasAbility('TongueAttack' ) ) modOther = modOther + 2;
  1842.  
  1843.        
  1844.         exp = ( modDamage + modArmor + modVitality + modOther ) / 99;
  1845.        
  1846.         if( ( FactsQuerySum("NewGamePlus") > 0 ) ) currentLevel -= theGame.params.GetNewGamePlusLevel();
  1847.  
  1848.        
  1849.         if  ( IsHuman() )
  1850.         {
  1851.             if ( exp > 1 + ( currentLevel * 2 ) ) { exp = 1 + ( currentLevel * 2 ); }
  1852.         } else
  1853.         {
  1854.             if ( exp > 5 + ( currentLevel * 4 ) ) { exp = 5 + ( currentLevel * 4 ); }
  1855.         }
  1856.                
  1857.        
  1858.         exp += 1;
  1859.        
  1860.         if( ( FactsQuerySum("NewGamePlus") > 0 ) )
  1861.         {
  1862.             if ( thePlayer.GetLevel() - theGame.params.GetNewGamePlusLevel() < 30 ) exp = ( exp / 4 ); else exp = ( exp / 2 );
  1863.         }
  1864.         else if ( thePlayer.GetLevel() < 30 ) exp = ( exp / 4 ); else exp = ( exp / 2 );
  1865.                
  1866.        
  1867.        
  1868.         if( ( FactsQuerySum("NewGamePlus") > 0 ) )
  1869.             lvlDiff = currentLevel - thePlayer.GetLevel() + theGame.params.GetNewGamePlusLevel();
  1870.         else
  1871.             lvlDiff = currentLevel - thePlayer.GetLevel();
  1872.         if      ( lvlDiff >= theGame.params.LEVEL_DIFF_DEADLY ) { exp = 25 + exp * 1.5; }  
  1873.         else if ( lvlDiff >= theGame.params.LEVEL_DIFF_HIGH )  { exp = exp * 1.05; }
  1874.         else if ( lvlDiff > -theGame.params.LEVEL_DIFF_HIGH )  { }
  1875.         else { exp = 2; }
  1876.  
  1877.         if ( exp > 50 ) exp = 50;
  1878.         if ( theGame.GetDifficultyMode() == EDM_Easy ) exp = exp * 1.2; else
  1879.         if ( theGame.GetDifficultyMode() == EDM_Hard ) exp = exp * 0.9; else
  1880.         if ( theGame.GetDifficultyMode() == EDM_Hardcore ) exp = exp * 0.8;
  1881.         finalExp = RoundF( exp );
  1882.        
  1883.         if(!skipLog)
  1884.         {
  1885.             LogStats("--------------------------------");
  1886.             LogStats("-      [CALCULATED EXP]        -");
  1887.             LogStats("- base, without difficulty and -");
  1888.             LogStats("-   level difference bonuses   -");
  1889.             LogStats("--------------------------------");
  1890.             LogStats(" -> for entity : " + GetName());
  1891.             LogStats("--------------------------------");
  1892.             LogStats("* modDamage : " + modDamage);
  1893.             LogStats("* modArmor : " + modArmor);
  1894.             LogStats("* modVitality : " + modVitality);
  1895.             LogStats("+ modOther : " + modOther);
  1896.             LogStats("--------------------------------");
  1897.             LogStats(" BASE EXPERIENCE POINTS = [ " + finalExp + " ]");
  1898.             LogStats("--------------------------------");
  1899.         }
  1900.        
  1901.         return finalExp;
  1902.     }
  1903.    
  1904.  
  1905.     event OnDeath( damageAction : W3DamageAction  )
  1906.     {      
  1907.         var inWater, fists, tmpBool : bool;    
  1908.         var attackAction : W3Action_Attack;
  1909.         var expPoints, npcLevel, lvlDiff : int;
  1910.  
  1911.         var weaponID : SItemUniqueId;
  1912.         var actor : CActor;
  1913.         var abilityName, tmpName : name;
  1914.         var abilityCount, maxStack, itemExpBonus : float;
  1915.         var addAbility : bool;
  1916.         var min, max, bonusExp : SAbilityAttributeValue;
  1917.         var mutagen : CBaseGameplayEffect;
  1918.         var monsterCategory : EMonsterCategory;
  1919.         var allItems : array<SItemUniqueId>;
  1920.         var attitudeToPlayer : EAIAttitude;
  1921.         var i : int;
  1922.  
  1923.         var ciriEntity  : W3ReplacerCiri;
  1924.  
  1925.         var blizzard : W3Potion_Blizzard;
  1926.  
  1927.        
  1928.         ciriEntity = (W3ReplacerCiri)thePlayer;    
  1929.  
  1930.        
  1931.         super.OnDeath( damageAction );
  1932.        
  1933.         if (!IsHuman() && damageAction.attacker == thePlayer && !ciriEntity ) AddBestiaryKnowledge();
  1934.        
  1935.         if ( !WillBeUnconscious() )
  1936.         {
  1937.             if ( theGame.GetWorld().GetWaterDepth( this.GetWorldPosition() ) > 0 )
  1938.             {
  1939.                 if ( this.HasEffect( 'water_death' ) ) this.PlayEffectSingle( 'water_death' );
  1940.             }
  1941.             else
  1942.             {
  1943.                 if ( this.HasEffect( 'blood_spill' ) ) this.PlayEffectSingle( 'blood_spill' );
  1944.             }
  1945.         }
  1946.        
  1947.        
  1948.         if ( ( ( CMovingPhysicalAgentComponent ) this.GetMovingAgentComponent() ).HasRagdoll() )
  1949.         {
  1950.             SetBehaviorVariable('HasRagdoll', 1 );
  1951.         }
  1952.        
  1953.        
  1954.  
  1955.         SignalGameplayEventParamObject( 'OnDeath', damageAction );
  1956.         theGame.GetBehTreeReactionManager().CreateReactionEvent( this, 'BattlecryGroupDeath', 1.0f, 20.0f, -1.0f, 1 );
  1957.        
  1958.         attackAction = (W3Action_Attack)damageAction;
  1959.        
  1960.        
  1961.         if ( ((CMovingPhysicalAgentComponent)GetMovingAgentComponent()).GetSubmergeDepth() < 0 )
  1962.         {
  1963.             inWater = true;
  1964.             DisableAgony();
  1965.         }
  1966.        
  1967.        
  1968.         if( IsUsingHorse() )
  1969.         {
  1970.             SoundEvent( "cmb_play_hit_heavy" );
  1971.             SoundEvent( "grunt_vo_death" );
  1972.         }
  1973.                        
  1974.         if(damageAction.attacker == thePlayer && ((W3PlayerWitcher)thePlayer) && thePlayer.GetStat(BCS_Toxicity) > 0 && thePlayer.CanUseSkill(S_Alchemy_s17))
  1975.         {
  1976.             thePlayer.AddAbility(SkillEnumToName(S_Alchemy_s17), true);
  1977.             if (thePlayer.GetSkillLevel(S_Alchemy_s17) > 1)
  1978.                 thePlayer.AddAbility(SkillEnumToName(S_Alchemy_s17), true);
  1979.             if (thePlayer.GetSkillLevel(S_Alchemy_s17) > 2)
  1980.                 thePlayer.AddAbility(SkillEnumToName(S_Alchemy_s17), true);
  1981.         }
  1982.        
  1983.         OnChangeDyingInteractionPriorityIfNeeded();
  1984.        
  1985.         actor = (CActor)damageAction.attacker;
  1986.        
  1987.        
  1988.         if(ShouldGiveExp(damageAction.attacker))
  1989.         {
  1990.             npcLevel = (int)CalculateAttributeValue(GetAttributeValue('level',,true));
  1991.             lvlDiff = npcLevel - GetWitcherPlayer().GetLevel();
  1992.             expPoints = CalculateExperiencePoints();
  1993.            
  1994.            
  1995.             if(expPoints > 0)
  1996.             {              
  1997.                 theGame.GetMonsterParamsForActor(this, monsterCategory, tmpName, tmpBool, tmpBool, tmpBool);
  1998.                 if(MonsterCategoryIsMonster(monsterCategory))
  1999.                 {
  2000.                     bonusExp = thePlayer.GetAttributeValue('nonhuman_exp_bonus_when_fatal');
  2001.                 }
  2002.                 else
  2003.                 {
  2004.                     bonusExp = thePlayer.GetAttributeValue('human_exp_bonus_when_fatal');
  2005.                 }              
  2006.                
  2007.                 expPoints = RoundMath( expPoints * (1 + CalculateAttributeValue(bonusExp)) );
  2008.                
  2009.                 GetWitcherPlayer().AddPoints(EExperiencePoint, RoundF( expPoints * theGame.expGlobalMod_kills ), false );
  2010.             }          
  2011.         }
  2012.                
  2013.        
  2014.         attitudeToPlayer = GetAttitudeBetween(this, thePlayer);
  2015.        
  2016.         if(attitudeToPlayer == AIA_Hostile && !HasTag('AchievementKillDontCount'))
  2017.         {
  2018.            
  2019.             if(actor && actor.HasBuff(EET_AxiiGuardMe))
  2020.             {
  2021.                 theGame.GetGamerProfile().IncStat(ES_CharmedNPCKills);
  2022.                 FactsAdd("statistics_cerberus_sign");
  2023.             }
  2024.            
  2025.            
  2026.             if( aardedFlight && damageAction.GetBuffSourceName() == "FallingDamage" )
  2027.             {
  2028.                 theGame.GetGamerProfile().IncStat(ES_AardFallKills);
  2029.             }
  2030.                
  2031.            
  2032.             if(damageAction.IsActionEnvironment())
  2033.             {
  2034.                 theGame.GetGamerProfile().IncStat(ES_EnvironmentKills);
  2035.                 FactsAdd("statistics_cerberus_environment");
  2036.             }
  2037.         }
  2038.        
  2039.        
  2040.  
  2041.         if ( damageAction.attacker == thePlayer )
  2042.         {
  2043.             theGame.GetMonsterParamsForActor(this, monsterCategory, tmpName, tmpBool, tmpBool, tmpBool);
  2044.            
  2045.            
  2046.             if(thePlayer.HasBuff(EET_Mutagen18))
  2047.             {
  2048.                
  2049.                
  2050.                 if(monsterCategory != MC_Animal || IsRequiredAttitudeBetween(this, thePlayer, true))
  2051.                 {          
  2052.                     abilityName = thePlayer.GetBuff(EET_Mutagen18).GetAbilityName();
  2053.                     abilityCount = thePlayer.GetAbilityCount(abilityName);
  2054.                    
  2055.                     if(abilityCount == 0)
  2056.                     {
  2057.                         addAbility = true;
  2058.                     }
  2059.                     else
  2060.                     {
  2061.                         theGame.GetDefinitionsManager().GetAbilityAttributeValue(abilityName, 'mutagen18_max_stack', min, max);
  2062.                         maxStack = CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  2063.                        
  2064.                         if(maxStack >= 0)
  2065.                         {
  2066.                             addAbility = (abilityCount < maxStack);
  2067.                         }
  2068.                         else
  2069.                         {
  2070.                             addAbility = true;
  2071.                         }
  2072.                     }
  2073.                    
  2074.                     if(addAbility)
  2075.                     {
  2076.                         thePlayer.AddAbility(abilityName, true);
  2077.                     }
  2078.                 }
  2079.             }
  2080.            
  2081.            
  2082.             if (thePlayer.HasBuff(EET_Mutagen06))
  2083.             {
  2084.                
  2085.                 if(monsterCategory != MC_Animal || IsRequiredAttitudeBetween(this, thePlayer, true))
  2086.                 {  
  2087.                     mutagen = thePlayer.GetBuff(EET_Mutagen06);
  2088.                     thePlayer.AddAbility(mutagen.GetAbilityName(), true);
  2089.                 }
  2090.             }
  2091.            
  2092.            
  2093.             if(IsRequiredAttitudeBetween(this, thePlayer, true))
  2094.             {
  2095.                 blizzard = (W3Potion_Blizzard)thePlayer.GetBuff(EET_Blizzard);
  2096.                 if(blizzard)
  2097.                     blizzard.KilledEnemy();
  2098.             }
  2099.            
  2100.  
  2101.             if(!HasTag('AchievementKillDontCount'))
  2102.             {
  2103.                 if (damageAction.GetIsHeadShot() && monsterCategory == MC_Human )      
  2104.                     theGame.GetGamerProfile().IncStat(ES_HeadShotKills);
  2105.                    
  2106.                
  2107.                 if( (W3SignEntity)damageAction.causer || (W3SignProjectile)damageAction.causer)
  2108.                 {
  2109.                     FactsAdd("statistics_cerberus_sign");
  2110.                 }
  2111.                 else if( (CBaseGameplayEffect)damageAction.causer && ((CBaseGameplayEffect)damageAction.causer).IsSignEffect())
  2112.                 {
  2113.                     FactsAdd("statistics_cerberus_sign");
  2114.                 }
  2115.                 else if( (W3Petard)damageAction.causer )
  2116.                 {
  2117.                     FactsAdd("statistics_cerberus_petard");
  2118.                 }
  2119.                 else if( (W3BoltProjectile)damageAction.causer )
  2120.                 {
  2121.                     FactsAdd("statistics_cerberus_bolt");
  2122.                 }              
  2123.                 else
  2124.                 {
  2125.                     if(!attackAction)
  2126.                         attackAction = (W3Action_Attack)damageAction;
  2127.                        
  2128.                     fists = false;
  2129.                     if(attackAction)
  2130.                     {
  2131.                         weaponID = attackAction.GetWeaponId();
  2132.                         if(damageAction.attacker.GetInventory().IsItemFists(weaponID))
  2133.                         {
  2134.                             FactsAdd("statistics_cerberus_fists");
  2135.                             fists = true;
  2136.                         }                      
  2137.                     }
  2138.                    
  2139.                     if(!fists && damageAction.IsActionMelee())
  2140.                     {
  2141.                         FactsAdd("statistics_cerberus_melee");
  2142.                     }
  2143.                 }
  2144.             }
  2145.  
  2146.         }
  2147.        
  2148.        
  2149.         if( damageAction.attacker == thePlayer || !((CNewNPC)damageAction.attacker) )
  2150.         {
  2151.             theTelemetry.LogWithLabelAndValue(TE_FIGHT_ENEMY_DIES, this.ToString(), GetLevel());
  2152.         }
  2153.        
  2154.        
  2155.         if(damageAction.attacker == thePlayer && !HasTag('AchievementKillDontCount'))
  2156.         {
  2157.             if ( attitudeToPlayer == AIA_Hostile )
  2158.             {
  2159.                
  2160.                 if(!HasTag('AchievementSwankDontCount'))
  2161.                 {
  2162.                     if(FactsQuerySum("statistic_killed_in_10_sec") >= 4)
  2163.                         theGame.GetGamerProfile().AddAchievement(EA_Swank);
  2164.                     else
  2165.                         FactsAdd("statistic_killed_in_10_sec", 1, 10);
  2166.                 }
  2167.                
  2168.                
  2169.                 if(GetWitcherPlayer() && !thePlayer.ReceivedDamageInCombat() && !GetWitcherPlayer().UsedQuenInCombat())
  2170.                 {
  2171.                     theGame.GetGamerProfile().IncStat(ES_FinesseKills);
  2172.                 }
  2173.             }
  2174.            
  2175.            
  2176.             if((W3PlayerWitcher)thePlayer)
  2177.             {
  2178.                 if(!thePlayer.DidFailFundamentalsFirstAchievementCondition() && HasTag(theGame.params.MONSTER_HUNT_ACTOR_TAG) && !HasTag('failedFundamentalsAchievement'))
  2179.                 {
  2180.                     theGame.GetGamerProfile().IncStat(ES_FundamentalsFirstKills);
  2181.                 }
  2182.             }
  2183.         }
  2184.                    
  2185.        
  2186.         if(!inWater && RandF() < 0.3 && !WillBeUnconscious() && (W3IgniProjectile)damageAction.causer)
  2187.         {
  2188.  
  2189.             AddEffectDefault(EET_Burning, this, 'IgniKill', true);
  2190.             EnableAgony();
  2191.             SignalGameplayEvent('ForceAgony');         
  2192.         }
  2193.  
  2194.        
  2195.        
  2196.         if(attackAction && IsWeaponHeld('fist') && damageAction.attacker == thePlayer && !thePlayer.ReceivedDamageInCombat() && !HasTag('AchievementKillDontCount'))
  2197.         {
  2198.             weaponID = attackAction.GetWeaponId();
  2199.             if(thePlayer.inv.IsItemFists(weaponID))
  2200.                 theGame.GetGamerProfile().AddAchievement(EA_FistOfTheSouthStar);
  2201.         }
  2202.  
  2203.         }
  2204.         //modMonsterHuntChallenge Begin
  2205.         if( damageAction.attacker == thePlayer && HasTag('mhc') )
  2206.         {
  2207.            
  2208.             thePlayer.getMonsterHunt().npcKilled(this) ;
  2209.            
  2210.         }
  2211.         //modMonsterHuntChallenge End
  2212.  
  2213.     }
  2214.    
  2215.     event OnChangeDyingInteractionPriorityIfNeeded()
  2216.     {
  2217.         if ( WillBeUnconscious() )
  2218.             return true;
  2219.         if ( HasTag('animal') )
  2220.         {
  2221.             return true;
  2222.         }
  2223.            
  2224.        
  2225.         this.SetInteractionPriority(IP_Max_Unpushable);
  2226.     }
  2227.    
  2228.  
  2229.     event OnFireHit(source : CGameplayEntity)
  2230.     {  
  2231.         super.OnFireHit(source);
  2232.        
  2233.         if ( HasTag('animal') )
  2234.         {
  2235.             Kill();
  2236.         }
  2237.        
  2238.         if ( !IsAlive() && IsInAgony() )
  2239.         {
  2240.            
  2241.             SignalGameplayEvent('AbandonAgony');
  2242.            
  2243.             SetKinematic(false);
  2244.         }
  2245.     }
  2246.    
  2247.     event OnAardHit( sign : W3AardProjectile )
  2248.     {
  2249.  
  2250.         SignalGameplayEvent( 'AardHitReceived' );
  2251.        
  2252.         aardedFlight = true;
  2253.        
  2254.  
  2255.         RemoveAllBuffsOfType(EET_Frozen);
  2256.  
  2257.        
  2258.        
  2259.        
  2260.        
  2261.         super.OnAardHit(sign);
  2262.        
  2263.         if ( HasTag('small_animal') )
  2264.         {
  2265.             Kill();
  2266.         }
  2267.         if ( IsShielded(sign.GetCaster()) )
  2268.         {
  2269.             ToggleEffectOnShield('aard_cone_hit', true);
  2270.         }
  2271.         else if ( HasAbility('ablIgnoreSigns') )
  2272.         {
  2273.             this.SignalGameplayEvent( 'IgnoreSigns' );
  2274.             this.SetBehaviorVariable( 'bIgnoreSigns',1.f );
  2275.             AddTimer('IgnoreSignsTimeOut',0.2,false);
  2276.         }
  2277.        
  2278.         if ( !IsAlive() )
  2279.  
  2280.         {
  2281.            
  2282.             SignalGameplayEvent('AbandonAgony');
  2283.            
  2284.            
  2285.            
  2286.             if( !HasAbility( 'mon_bear_base' )
  2287.                 && !HasAbility( 'mon_golem_base' )
  2288.                 && !HasAbility( 'mon_endriaga_base' )
  2289.                 && !HasAbility( 'mon_gryphon_base' )
  2290.  
  2291.                 && !IsAnimal()  )
  2292.             {          
  2293.                
  2294.                 SetKinematic(false);
  2295.             }
  2296.         }
  2297.     }
  2298.    
  2299.     event OnAxiiHit( sign : W3AxiiProjectile )
  2300.     {
  2301.         super.OnAxiiHit(sign);
  2302.        
  2303.         if ( HasAbility('ablIgnoreSigns') )
  2304.         {
  2305.             this.SignalGameplayEvent( 'IgnoreSigns' );
  2306.             this.SetBehaviorVariable( 'bIgnoreSigns',1.f );
  2307.             AddTimer('IgnoreSignsTimeOut',0.2,false);
  2308.         }
  2309.     }
  2310.    
  2311.     private const var SHIELD_BURN_TIMER : float;
  2312.     default SHIELD_BURN_TIMER = 1.0;
  2313.    
  2314.     private var beingHitByIgni : bool;
  2315.     private var firstIgniTick, lastIgniTick : float;
  2316.    
  2317.     event OnIgniHit( sign : W3IgniProjectile )
  2318.     {
  2319.         var horseComponent : W3HorseComponent;
  2320.         super.OnIgniHit( sign );
  2321.        
  2322.         SignalGameplayEvent( 'IgniHitReceived' );
  2323.        
  2324.         if ( HasAbility( 'ablIgnoreSigns') )
  2325.         {
  2326.             this.SignalGameplayEvent( 'IgnoreSigns' );
  2327.             this.SetBehaviorVariable('bIgnoreSigns',1.f);
  2328.             AddTimer('IgnoreSignsTimeOut',0.2,false);
  2329.         }
  2330.        
  2331.         if ( HasAbility( 'IceArmor') )
  2332.         {
  2333.             this.RemoveAbility( 'IceArmor' );
  2334.             this.StopEffect( 'ice_armor' );
  2335.             this.PlayEffect( 'ice_armor_hit' );
  2336.         }
  2337.        
  2338.         if( IsShielded( sign.GetCaster() ) )
  2339.         {
  2340.             if( sign.IsProjectileFromChannelMode() )
  2341.             {
  2342.                 SignalGameplayEvent( 'BeingHitByIgni' );
  2343.                
  2344.                 if( !beingHitByIgni )
  2345.                 {
  2346.                     beingHitByIgni = true;
  2347.                     firstIgniTick = theGame.GetEngineTimeAsSeconds();
  2348.                     ToggleEffectOnShield( 'burn', true );
  2349.                     RaiseShield();
  2350.                 }
  2351.                
  2352.                 if( firstIgniTick + SHIELD_BURN_TIMER < theGame.GetEngineTimeAsSeconds() )
  2353.                 {
  2354.                     ProcessShieldDestruction();
  2355.                     return false;
  2356.                 }
  2357.  
  2358.                 AddTimer( 'IgniCleanup', 0.2, false );
  2359.             }
  2360.             else
  2361.             {
  2362.                 ToggleEffectOnShield( 'igni_cone_hit', true );
  2363.             }
  2364.         }
  2365.        
  2366.         horseComponent = GetHorseComponent();
  2367.         if ( horseComponent )
  2368.             horseComponent.OnIgniHit(sign);
  2369.         else
  2370.         {
  2371.             horseComponent = GetUsedHorseComponent();
  2372.             if ( horseComponent )
  2373.                 horseComponent.OnIgniHit(sign);
  2374.         }
  2375.     }
  2376.    
  2377.     public function IsBeingHitByIgni() : bool
  2378.     {
  2379.         return beingHitByIgni;
  2380.     }
  2381.    
  2382.     function ToggleEffectOnShield(effectName : name, toggle : bool)
  2383.     {
  2384.         var itemID : SItemUniqueId;
  2385.         var inv : CInventoryComponent;
  2386.        
  2387.         inv = GetInventory();
  2388.         itemID = inv.GetItemFromSlot('l_weapon');
  2389.         if ( toggle )
  2390.             inv.PlayItemEffect(itemID,effectName);
  2391.         else
  2392.             inv.StopItemEffect(itemID,effectName);
  2393.     }
  2394.    
  2395.     timer function IgniCleanup( dt : float , id : int)
  2396.     {
  2397.         if( beingHitByIgni )
  2398.         {
  2399.             ToggleEffectOnShield( 'burn', false );
  2400.             AddTimer( 'LowerShield', 0.5 );
  2401.             beingHitByIgni = false;
  2402.         }
  2403.     }
  2404.    
  2405.     timer function IgnoreSignsTimeOut( dt : float , id : int)
  2406.     {
  2407.         this.SignalGameplayEvent( 'IgnoreSignsEnd' );
  2408.         this.SetBehaviorVariable( 'bIgnoreSigns',0.f);
  2409.     }
  2410.    
  2411.        
  2412.    
  2413.     function SetIsTeleporting( b : bool )
  2414.     {
  2415.         isTeleporting = b;
  2416.        
  2417.     }
  2418.    
  2419.     function IsTeleporting() : bool
  2420.     {
  2421.         return isTeleporting;
  2422.     }
  2423.  
  2424.     function SetUnstoppable( toggle : bool )
  2425.     {
  2426.         unstoppable = toggle;
  2427.     }
  2428.    
  2429.     function IsUnstoppable() : bool
  2430.     {
  2431.         return unstoppable;
  2432.     }
  2433.    
  2434.     function SetIsCountering( toggle : bool )
  2435.     {
  2436.         bIsCountering = toggle;
  2437.     }
  2438.    
  2439.     function IsCountering() : bool
  2440.     {
  2441.         return bIsCountering;
  2442.     }
  2443.    
  2444.    
  2445.     timer function Tick(deltaTime : float, id : int)
  2446.     {
  2447.        
  2448.        
  2449.     }
  2450.    
  2451.     private function UpdateBumpCollision()
  2452.     {
  2453.         var npc             : CNewNPC;
  2454.         var collisionData   : SCollisionData;
  2455.         var collisionNum    : int;
  2456.         var i               : int;
  2457.        
  2458.        
  2459.        
  2460.        
  2461.        
  2462.         if( mac )
  2463.         {
  2464.            
  2465.             collisionNum    = mac.GetCollisionCharacterDataCount();
  2466.             for( i = 0; i < collisionNum; i += 1 )
  2467.             {
  2468.                 collisionData   = mac.GetCollisionCharacterData( i );
  2469.                 npc = ( CNewNPC ) collisionData.entity;
  2470.                 if( npc )
  2471.                 {
  2472.                     this.SignalGameplayEvent( 'AI_GetOutOfTheWay' );                   
  2473.                     this.SignalGameplayEventParamObject( 'CollideWithPlayer', npc );   
  2474.                     theGame.GetBehTreeReactionManager().CreateReactionEvent( this, 'BumpAction', 1, 1, 1, 1, false );
  2475.                    
  2476.                    
  2477.                     break;
  2478.                 }
  2479.             }
  2480.         }
  2481.     }
  2482.  
  2483.  
  2484.     public function SetIsTranslationScaled(b : bool)                        {isTranslationScaled = b;}
  2485.     public function GetIsTranslationScaled() : bool                     {return isTranslationScaled;}  
  2486.    
  2487.    
  2488.     import final function GetActiveActionPoint() : SActionPointId;
  2489.  
  2490.  
  2491.    
  2492.    
  2493.    
  2494.  
  2495.    
  2496.    
  2497.    
  2498.     import final function IsInInterior() : bool;   
  2499.    
  2500.    
  2501.     import final function IsInDanger() : bool;
  2502.    
  2503.    
  2504.     import final function IsSeeingNonFriendlyNPC() : bool;
  2505.  
  2506.    
  2507.     import final function IsAIEnabled() : bool;
  2508.    
  2509.    
  2510.     import final function FindActionPoint( out apID : SActionPointId, out category : name );
  2511.            
  2512.    
  2513.     import final function GetDefaultDespawnPoint( out spawnPoint : Vector ) : bool;
  2514.    
  2515.  
  2516.    
  2517.     import final function NoticeActor( actor : CActor );
  2518.    
  2519.    
  2520.     import final function ForgetActor( actor : CActor );
  2521.    
  2522.    
  2523.     import final function ForgetAllActors();
  2524.    
  2525.    
  2526.     import final function GetNoticedObject( index : int) : CActor;
  2527.    
  2528.    
  2529.  
  2530.     import final function GetPerceptionRange() : float;
  2531.        
  2532.    
  2533.    
  2534.     import final function PlayDialog( optional forceSpawnedActors : bool ) : bool;
  2535.  
  2536.    
  2537.    
  2538.    
  2539.     import final function GetReactionScript( index : int ) : CReactionScript;
  2540.    
  2541.     import final function IfCanSeePlayer() : bool;
  2542.    
  2543.     import final function GetGuardArea() : CAreaComponent;
  2544.     import final function SetGuardArea( areaComponent : CAreaComponent );
  2545.  
  2546.    
  2547.     import final function IsConsciousAtWork() : bool;
  2548.     import final function GetCurrentJTType() : int;
  2549.     import final function IsInLeaveAction() : bool;
  2550.     import final function IsSittingAtWork() : bool;
  2551.     import final function IsAtWork() : bool;
  2552.     import final function IsPlayingChatScene() : bool;
  2553.     import final function CanUseChatInCurrentAP() : bool;
  2554.    
  2555.    
  2556.     import final function NoticeActorInGuardArea( actor : CActor );
  2557.    
  2558.    
  2559.    
  2560.    
  2561.     event OnAnimEvent_EquipItemL( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2562.     {
  2563.         GetInventory().MountItem( itemToEquip, true );
  2564.     }
  2565.     event OnAnimEvent_HideItemL( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2566.     {
  2567.         GetInventory().UnmountItem( itemToEquip, true );
  2568.     }
  2569.     event OnAnimEvent_HideWeapons( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2570.     {
  2571.         var inventory   : CInventoryComponent = GetInventory();
  2572.         var ids         : array<SItemUniqueId>;
  2573.         var i           : int;
  2574.        
  2575.         ids = inventory.GetAllWeapons();
  2576.         for( i = 0; i < ids.Size() ; i += 1 )
  2577.         {
  2578.             if( inventory.IsItemHeld( ids[i] ) || inventory.IsItemMounted( ids[i] ) )
  2579.                 inventory.UnmountItem( ids[i], true );
  2580.         }
  2581.     }
  2582.    
  2583.     event OnAnimEvent_TemporaryOffGround( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2584.     {
  2585.         if( animEventType == AET_DurationEnd )
  2586.         {
  2587.             isTemporaryOffGround = false;
  2588.         }
  2589.         else
  2590.         {
  2591.             isTemporaryOffGround = true;
  2592.         }
  2593.     }
  2594.     event OnAnimEvent_weaponSoundType( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2595.     {
  2596.         WeaponSoundType().SetupDrawHolsterSounds();
  2597.     }
  2598.    
  2599.  
  2600.    
  2601.     event OnAnimEvent_OwlSwitchOpen( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2602.     {
  2603.         SetAppearance('owl_01');
  2604.     }
  2605.    
  2606.     event OnAnimEvent_OwlSwitchClose( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2607.     {
  2608.         SetAppearance('owl_02');
  2609.     }
  2610.    
  2611.     event OnAnimEvent_Goose01OpenWings( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2612.     {
  2613.         SetAppearance('goose_01_wings');
  2614.     }
  2615.    
  2616.     event OnAnimEvent_Goose01CloseWings( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2617.     {
  2618.         SetAppearance('goose_01');
  2619.     }
  2620.    
  2621.     event OnAnimEvent_Goose02OpenWings( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2622.     {
  2623.         SetAppearance('goose_02_wings');
  2624.     }
  2625.    
  2626.     event OnAnimEvent_Goose02CloseWings( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2627.     {
  2628.         SetAppearance('goose_02');
  2629.     }
  2630.  
  2631.     event OnAnimEvent_NullifyBurning( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2632.     {
  2633.         RemoveAllBuffsOfType(EET_Burning);
  2634.     }
  2635.  
  2636.     event OnAnimEvent_setVisible( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2637.     {
  2638.         SetVisibility( true );
  2639.         SetGameplayVisibility( true );
  2640.     }
  2641.    
  2642.     event OnAnimEvent_extensionWalk( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  2643.     {
  2644.         SetBehaviorVariable( 'UsesExtension', 1 );
  2645.  
  2646.     }
  2647.    
  2648.    
  2649.    
  2650.     event OnEquippedItem( category : name, slotName : name )
  2651.     {
  2652.         if ( slotName == 'r_weapon' )
  2653.         {
  2654.             switch( category )
  2655.             {          
  2656.                 case 'axe1h':
  2657.                 case 'axe2h':
  2658.                     SetBehaviorVariable( 'EquippedItemR', (int) RIT_Axe );
  2659.                     break;     
  2660.                 case 'halberd2h':
  2661.                     SetBehaviorVariable( 'EquippedItemR', (int) RIT_Halberd );
  2662.                     break;
  2663.                 case 'steelsword' :
  2664.                 case 'silversword' :
  2665.                     SetBehaviorVariable( 'EquippedItemR', (int) RIT_Sword );
  2666.                     break;
  2667.                 case 'crossbow' :
  2668.                     SetBehaviorVariable( 'EquippedItemR', (int) RIT_Crossbow );
  2669.                     break;
  2670.                 default:
  2671.                     SetBehaviorVariable( 'EquippedItemR', (int) RIT_None );
  2672.                     break;
  2673.             }
  2674.         }
  2675.         else if ( slotName == 'l_weapon' )
  2676.         {
  2677.             switch( category )
  2678.             {
  2679.                 case 'shield' :
  2680.                     SetBehaviorVariable( 'EquippedItemL', (int) LIT_Shield );
  2681.                     break;
  2682.                 case 'bow' :
  2683.                     SetBehaviorVariable( 'EquippedItemL', (int) LIT_Bow );
  2684.                     break;
  2685.                 case 'usable' :
  2686.                     SetBehaviorVariable( 'EquippedItemL', (int) LIT_Torch );
  2687.                     break;
  2688.                 default:
  2689.                     SetBehaviorVariable( 'EquippedItemL', (int) LIT_None );
  2690.                     break;
  2691.             }
  2692.         }
  2693.        
  2694.         if ( category != 'fist' && category != 'work' && category != 'usable' && IsInCombat() && GetTarget() == thePlayer && thePlayer.GetTarget() == this )
  2695.             thePlayer.OnTargetWeaponDrawn();
  2696.     }
  2697.    
  2698.     event OnHolsteredItem( category : name, slotName : name )
  2699.     {
  2700.         if ( slotName == 'r_weapon' )
  2701.         {
  2702.             SetBehaviorVariable( 'EquippedItemR', (int) RIT_None );
  2703.         }
  2704.         else if ( slotName == 'l_weapon' )
  2705.         {
  2706.             SetBehaviorVariable( 'EquippedItemL', (int) LIT_None );
  2707.         }
  2708.     }
  2709.    
  2710.     function IsTalkDisabled () : bool
  2711.     {
  2712.         return isTalkDisabled || isTalkDisabledTemporary;
  2713.     }
  2714.    
  2715.     public function DisableTalking( disable : bool, optional temporary : bool )
  2716.     {      
  2717.         if ( temporary )
  2718.         {
  2719.             isTalkDisabledTemporary = disable;
  2720.         }
  2721.         else
  2722.         {
  2723.             isTalkDisabled = disable;
  2724.         }
  2725.     }
  2726.  
  2727.     public function CanStartTalk() : bool
  2728.     {
  2729.        
  2730.         if( IsAtWork() && !IsConsciousAtWork() || IsTalkDisabled () )
  2731.             return false;
  2732.            
  2733.         if(HasBuff(EET_AxiiGuardMe) || HasBuff(EET_Confusion))
  2734.             return false;
  2735.            
  2736.         return !IsFrozen() && CanTalk( true );
  2737.     }
  2738.    
  2739.     event OnInteraction( actionName : string, activator : CEntity )
  2740.     {
  2741.         var horseComponent      : W3HorseComponent;
  2742.         var ciriEntity          : W3ReplacerCiri;
  2743.         var isAtWork            : bool;
  2744.         var isConciousAtWork    : bool;
  2745.        
  2746.         LogChannel( 'DialogueTest', "Event Interaction Used" );
  2747.         if ( actionName == "Talk" )
  2748.         {  
  2749.             LogChannel( 'DialogueTest', "Activating TALK Interaction - PLAY DIALOGUE" );
  2750.            
  2751.             if ( !PlayDialog() )
  2752.             {
  2753.                
  2754.                
  2755.                 EnableDynamicLookAt( thePlayer, 5 );
  2756.                 ciriEntity = (W3ReplacerCiri)thePlayer;
  2757.                 if ( ciriEntity )
  2758.                 {
  2759.                 }
  2760.                 else
  2761.                 {
  2762.                    
  2763.                     if( !IsAtWork() || IsConsciousAtWork() )
  2764.                     {
  2765.                         PlayVoiceset(100, "greeting_geralt" );
  2766.                     }
  2767.                     else
  2768.                         PlayVoiceset(100, "sleeping" );
  2769.                    
  2770.                     wasInTalkInteraction = true;
  2771.                     AddTimer( 'ResetTalkInteractionFlag', 1.0, true, , , true);
  2772.                 }
  2773.             }
  2774.         }
  2775.         if ( actionName == "Finish" )
  2776.         {
  2777.            
  2778.         }
  2779.         else if( actionName == "AxiiCalmHorse" )
  2780.         {
  2781.             SignalGameplayEvent( 'HorseAxiiCalmDownStart' );
  2782.         }
  2783.     }
  2784.    
  2785.     event OnInteractionActivationTest( interactionComponentName : string, activator : CEntity )
  2786.     {
  2787.         var stateName : name;
  2788.         var horseComp : W3HorseComponent;
  2789.        
  2790.         if( interactionComponentName == "talk" )
  2791.         {
  2792.             if( activator == thePlayer && thePlayer.CanStartTalk() && CanStartTalk() )
  2793.             {  
  2794.                 return true;
  2795.             }
  2796.         }
  2797.         else if( interactionComponentName == "Finish" && activator == thePlayer )
  2798.         {
  2799.             stateName = thePlayer.GetCurrentStateName();
  2800.             if( stateName == 'CombatSteel' || stateName == 'CombatSilver' )
  2801.                 return true;
  2802.         }
  2803.         else if( interactionComponentName == "horseMount" && activator == thePlayer )
  2804.         {
  2805.             if( !thePlayer.IsActionAllowed( EIAB_MountVehicle ) || thePlayer.IsInAir() )
  2806.                 return false;
  2807.             if ( horseComponent.IsInHorseAction() || !IsAlive() )
  2808.                 return false;
  2809.             if ( GetAttitudeBetween(this,thePlayer) == AIA_Hostile && !( HasBuff(EET_Confusion) || HasBuff(EET_AxiiGuardMe) ) )
  2810.                 return false;
  2811.            
  2812.             if( mac.IsOnNavigableSpace() )
  2813.             {
  2814.                 if( theGame.GetWorld().NavigationLineTest( activator.GetWorldPosition(), this.GetWorldPosition(), 0.05, false, true ) )
  2815.                 {
  2816.                    
  2817.                     if( theGame.TestNoCreaturesOnLine( activator.GetWorldPosition(), this.GetWorldPosition(), 0.4, (CActor)activator, this, true ) )
  2818.                     {
  2819.                         return true;
  2820.                     }
  2821.                    
  2822.                     return false;
  2823.                 }
  2824.             }
  2825.             else
  2826.             {
  2827.                 horseComp = this.GetHorseComponent();
  2828.                
  2829.                 if( horseComp )
  2830.                 {
  2831.                     horseComp.mountTestPlayerPos = activator.GetWorldPosition();
  2832.                     horseComp.mountTestPlayerPos.Z += 0.5;
  2833.                     horseComp.mountTestHorsePos = this.GetWorldPosition();
  2834.                     horseComp.mountTestHorsePos.Z += 0.5;
  2835.                    
  2836.                     if( !theGame.GetWorld().StaticTrace( horseComp.mountTestPlayerPos, horseComp.mountTestHorsePos, horseComp.mountTestEndPos, horseComp.mountTestNormal, horseComp.mountTestCollisionGroups ) )
  2837.                     {
  2838.                         return true;
  2839.                     }
  2840.                 }
  2841.                
  2842.                 return false;
  2843.             }
  2844.         }
  2845.        
  2846.        
  2847.        
  2848.         return false;  
  2849.     }
  2850.    
  2851.     event OnInteractionTalkTest()
  2852.     {
  2853.         return CanStartTalk();     
  2854.     }
  2855.  
  2856.    
  2857.     event OnInteractionActivated( interactionComponentName : string, activator : CEntity )
  2858.     {
  2859.        
  2860.        
  2861.        
  2862.        
  2863.        
  2864.        
  2865.     }
  2866.    
  2867.     event OnInteractionDeactivated( interactionComponentName : string, activator : CEntity )
  2868.     {
  2869.        
  2870.        
  2871.        
  2872.        
  2873.     }
  2874.  
  2875.    
  2876.    
  2877.    
  2878.    
  2879.    
  2880.        
  2881.        
  2882.        
  2883.    
  2884.    
  2885.     event OnBehaviorGraphNotification( notificationName : name, stateName : name )
  2886.     {
  2887.         var i: int;    
  2888.         for ( i = 0; i < behaviorGraphEventListened.Size(); i += 1 )
  2889.         {
  2890.             if( behaviorGraphEventListened[i] == notificationName )
  2891.             {
  2892.                 SignalGameplayEventParamCName( notificationName, stateName );
  2893.             }
  2894.         }
  2895.         super.OnBehaviorGraphNotification( notificationName, stateName );
  2896.     }
  2897.    
  2898.     public function ActivateSignalBehaviorGraphNotification( notificationName : name )
  2899.     {
  2900.         if( !behaviorGraphEventListened.Contains( notificationName ) )
  2901.         {
  2902.             behaviorGraphEventListened.PushBack( notificationName );
  2903.         }
  2904.     }
  2905.    
  2906.     public function DeactivateSignalBehaviorGraphNotification( notificationName : name )
  2907.     {
  2908.         behaviorGraphEventListened.Remove( notificationName );
  2909.     }
  2910.    
  2911.    
  2912.    
  2913.    
  2914.    
  2915.  
  2916.     function IsShielded( target : CNode ) : bool
  2917.     {
  2918.         var targetToSourceAngle : float;
  2919.         var protectionAngleLeft, protectionAngleRight : float;
  2920.        
  2921.         if( target )
  2922.         {
  2923.             if( HasShieldedAbility() && IsGuarded() )
  2924.             {
  2925.                 targetToSourceAngle = NodeToNodeAngleDistance(target, this);
  2926.                 protectionAngleLeft = CalculateAttributeValue( this.GetAttributeValue( 'protection_angle_left' ) );
  2927.                 protectionAngleRight = CalculateAttributeValue( this.GetAttributeValue( 'protection_angle_right' ) );
  2928.                
  2929.                
  2930.                 if( targetToSourceAngle < protectionAngleRight && targetToSourceAngle > protectionAngleLeft )
  2931.                 {
  2932.                     return true;
  2933.                 }
  2934.             }
  2935.             return false;
  2936.         }
  2937.         else
  2938.             return HasShieldedAbility() && IsGuarded();
  2939.     }
  2940.    
  2941.     function HasShieldedAbility() : bool
  2942.     {
  2943.         var attval : float;
  2944.         attval = CalculateAttributeValue( this.GetAttributeValue( 'shielded' ) );
  2945.         if( attval >= 1.f )
  2946.             return true;
  2947.         else
  2948.             return false;
  2949.     }
  2950.    
  2951.     function RaiseShield()
  2952.     {
  2953.         SetBehaviorVariable( 'bShieldUp', 1.f );
  2954.     }
  2955.    
  2956.     timer function LowerShield( td : float , id : int)
  2957.     {
  2958.         SetBehaviorVariable( 'bShieldUp', 0.f );
  2959.     }
  2960.        
  2961.     public function ProcessShieldDestruction()
  2962.     {  
  2963.         var shield : CEntity;
  2964.        
  2965.         if( HasTag( 'imlerith' ) )
  2966.             return;
  2967.            
  2968.         SetBehaviorVariable( 'bShieldbreak', 1.0 );
  2969.         AddEffectDefault( EET_Stagger, thePlayer, "ParryStagger" );
  2970.         shield = GetInventory().GetItemEntityUnsafe( GetInventory().GetItemFromSlot( 'l_weapon' ) );
  2971.         ToggleEffectOnShield( 'heavy_block', true );
  2972.         DropItemFromSlot( 'l_weapon', true );
  2973.     }
  2974.  
  2975.     event OnIncomingProjectile( isBomb : bool )
  2976.     {
  2977.         if( IsShielded( thePlayer ) )
  2978.         {
  2979.             RaiseShield();
  2980.             AddTimer( 'LowerShield', 3.0 );
  2981.         }
  2982.     }
  2983.    
  2984.     function ShouldAttackImmidiately() : bool
  2985.     {
  2986.         return  tauntedToAttackTimeStamp > 0 && ( tauntedToAttackTimeStamp + 10 > theGame.GetEngineTimeAsSeconds() );
  2987.     }
  2988.    
  2989.     function CanAttackKnockeddownTarget() : bool
  2990.     {
  2991.         var attval : float;
  2992.         attval = CalculateAttributeValue(this.GetAttributeValue('attackKnockeddownTarget'));
  2993.         if ( attval >= 1.f )
  2994.             return true;
  2995.         else
  2996.             return false;
  2997.     }
  2998.    
  2999.     event OnProcessRequiredItemsFinish()
  3000.     {
  3001.         var inv : CInventoryComponent = this.GetInventory();
  3002.         var heldItems, heldItemsNames, mountedItems : array<name>;
  3003.        
  3004.         if ( thePlayer.GetTarget() == this )
  3005.             thePlayer.OnTargetWeaponDrawn();
  3006.        
  3007.        
  3008.         SetBehaviorVariable( 'bIsGuarded', (int)IsGuarded() );
  3009.        
  3010.         inv.GetAllHeldAndMountedItemsCategories(heldItems, mountedItems);
  3011.                
  3012.        
  3013.         if ( this.HasShieldedAbility() )
  3014.         {
  3015.             RaiseGuard();
  3016.         }
  3017.        
  3018.         inv.GetAllHeldItemsNames( heldItemsNames );
  3019.        
  3020.         if ( heldItemsNames.Contains('fists_lightning') || heldItemsNames.Contains('fists_fire') )
  3021.         {
  3022.             this.PlayEffect('hand_fx');
  3023.             theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( this, 'FireDanger', -1, 5.0f, 1, -1, true, true );
  3024.         }
  3025.         else
  3026.         {
  3027.             this.StopEffect('hand_fx');
  3028.             theGame.GetBehTreeReactionManager().RemoveReactionEvent( this, 'FireDanger' );
  3029.         }
  3030.        
  3031.         if ( mountedItems.Contains('shield') )
  3032.         {
  3033.             this.AddAbility('CannotBeAttackedFromBehind', false);
  3034.             LowerGuard();
  3035.         }
  3036.         else
  3037.         {
  3038.             this.RemoveAbility('CannotBeAttackedFromBehind');
  3039.         }
  3040.     }
  3041.    
  3042.     public function ProcessSpearDestruction() : bool
  3043.     {
  3044.         var appearanceName : name;
  3045.         var shouldDrop : bool;
  3046.         var spear : CEntity;
  3047.        
  3048.         appearanceName = 'broken';
  3049.         spear = GetInventory().GetItemEntityUnsafe( GetInventory().GetItemFromSlot( 'r_weapon' ) );
  3050.         spear.ApplyAppearance( appearanceName );
  3051.         DropItemFromSlot('r_weapon', true);
  3052.         return true;
  3053.        
  3054.     }  
  3055.    
  3056.    
  3057.    
  3058.    
  3059.    
  3060.     function PlayVitalSpotAmbientSound( soundEvent : string )
  3061.     {
  3062.         SoundEvent( soundEvent, 'pelvis' );
  3063.     }
  3064.    
  3065.     function StopVitalSpotAmbientSound( soundEvent : string)
  3066.     {
  3067.         SoundEvent( soundEvent, 'pelvis' );
  3068.     }
  3069.    
  3070.     event OnScriptReloaded()
  3071.     {
  3072.        
  3073.     }
  3074.        
  3075.  
  3076.    
  3077.    
  3078.    
  3079.    
  3080.    
  3081.     public function ChangeFightStage( fightStage : ENPCFightStage )
  3082.     {
  3083.         currentFightStage =  fightStage;
  3084.         SetCurrentFightStage();
  3085.     }
  3086.    
  3087.     public function SetCurrentFightStage()
  3088.     {
  3089.         SetBehaviorVariable( 'npcFightStage', (float)(int)currentFightStage, true );
  3090.     }
  3091.    
  3092.     public function GetCurrentFightStage() : ENPCFightStage
  3093.     {
  3094.         return currentFightStage;
  3095.     }
  3096.    
  3097.    
  3098.     public function SetBleedBurnPoison()
  3099.     {
  3100.         wasBleedingBurningPoisoned = true;
  3101.     }
  3102.    
  3103.     public function WasBurnedBleedingPoisoned() : bool
  3104.     {
  3105.         return wasBleedingBurningPoisoned;
  3106.     }
  3107.    
  3108.    
  3109.     public function HasAlternateQuen() : bool
  3110.     {
  3111.         var npcStorage : CHumanAICombatStorage;
  3112.        
  3113.         npcStorage = (CHumanAICombatStorage)GetAIStorageObject('CombatData');
  3114.         if(npcStorage && npcStorage.IsProtectedByQuen() )
  3115.         {
  3116.             return true;
  3117.         }      
  3118.        
  3119.         return false;
  3120.     }
  3121.    
  3122.    
  3123.     public function GetIsMonsterTypeGroup() : bool  { return isMonsterType_Group; }
  3124.  
  3125.  
  3126.    
  3127.    
  3128.    
  3129.     function UpdateAIVisualDebug()
  3130.     {  
  3131.     }
  3132.  
  3133.    
  3134.     event OnAllowBehGraphChange()
  3135.     {
  3136.         allowBehGraphChange = true;
  3137.     }
  3138.    
  3139.     event OnDisallowBehGraphChange()
  3140.     {
  3141.         allowBehGraphChange = false;
  3142.     }
  3143.  
  3144.     event OnObstacleCollision( object : CObject, physicalActorindex : int, shapeIndex : int  )
  3145.     {
  3146.         var  ent : CEntity;
  3147.         var component : CComponent;
  3148.         component = (CComponent) object;
  3149.         if( !component )
  3150.         {
  3151.             return false;
  3152.         }
  3153.        
  3154.         ent = component.GetEntity();
  3155.        
  3156.         if ( (CActor)ent != this )
  3157.         {
  3158.            
  3159.             this.SignalGameplayEventParamObject('CollisionWithObstacle',ent);
  3160.         }
  3161.     }
  3162.    
  3163.  
  3164.     event OnActorCollision( object : CObject, physicalActorindex : int, shapeIndex : int  )
  3165.     {
  3166.         var  ent : CEntity;
  3167.         var component : CComponent;
  3168.         component = (CComponent) object;
  3169.         if( !component )
  3170.         {
  3171.             return false;
  3172.         }
  3173.        
  3174.         ent = component.GetEntity();
  3175.         if ( ent != this )
  3176.         {
  3177.             this.SignalGameplayEventParamObject('CollisionWithActor', ent );
  3178.            
  3179.            
  3180.             if( horseComponent )
  3181.             {
  3182.                 horseComponent.OnCharacterCollision( ent );
  3183.             }
  3184.         }
  3185.     }
  3186.    
  3187.     event OnActorSideCollision( object : CObject, physicalActorindex : int, shapeIndex : int  )
  3188.     {
  3189.         var  ent : CEntity;
  3190.         var horseComp : W3HorseComponent;
  3191.         var component : CComponent;
  3192.         component = (CComponent) object;
  3193.         if( !component )
  3194.         {
  3195.             return false;
  3196.         }
  3197.        
  3198.         ent = component.GetEntity();
  3199.         if ( ent != this )
  3200.         {
  3201.             this.SignalGameplayEventParamObject('CollisionWithActor', ent );
  3202.            
  3203.            
  3204.             if( horseComponent )
  3205.             {
  3206.                 horseComponent.OnCharacterSideCollision( ent );
  3207.             }
  3208.         }
  3209.     }
  3210.    
  3211.     event OnStaticCollision( component : CComponent )
  3212.     {
  3213.         SignalGameplayEventParamObject('CollisionWithStatic',component);
  3214.     }
  3215.    
  3216.     event OnBoatCollision( object : CObject, physicalActorindex : int, shapeIndex : int  )
  3217.     {
  3218.         var  ent : CEntity;
  3219.         var component : CComponent;
  3220.         component = (CComponent) object;
  3221.         if( !component )
  3222.         {
  3223.             return false;
  3224.         }
  3225.        
  3226.         ent = component.GetEntity();
  3227.         if ( ent != this )
  3228.         {
  3229.             this.SignalGameplayEventParamObject('CollisionWithBoat', ent );
  3230.         }
  3231.     }
  3232.    
  3233.    
  3234.    
  3235.    
  3236.    
  3237.     public function IsUnderwater() : bool { return isUnderwater; }
  3238.     public function ToggleIsUnderwater ( toggle : bool ) { isUnderwater = toggle; }
  3239.    
  3240.     event OnOceanTriggerEnter()
  3241.     {
  3242.         SignalGameplayEvent('EnterWater');
  3243.     }
  3244.    
  3245.     event OnOceanTriggerLeave()
  3246.     {
  3247.         SignalGameplayEvent('LeaveWater');
  3248.     }
  3249.    
  3250.    
  3251.    
  3252.    
  3253.        
  3254.     var isRagdollOn : bool; default isRagdollOn = false;
  3255.    
  3256.     event OnInAirStarted()
  3257.     {      
  3258.        
  3259.     }
  3260.    
  3261.     event OnRagdollOnGround()
  3262.     {      
  3263.         var params : SCustomEffectParams;
  3264.        
  3265.         if( GetIsFallingFromHorse() )
  3266.         {
  3267.             params.effectType = EET_Ragdoll;
  3268.             params.creator = this;
  3269.             params.sourceName = "ragdoll_dismount";
  3270.             params.duration = 0.5;
  3271.             AddEffectCustom( params );
  3272.             SignalGameplayEvent( 'RagdollFromHorse' );
  3273.             SetIsFallingFromHorse( false );
  3274.         }
  3275.         else if( IsInAir() )
  3276.         {
  3277.             SetIsInAir(false);
  3278.         }
  3279.     }
  3280.    
  3281.     var m_storedInteractionPri : EInteractionPriority;
  3282.     default m_storedInteractionPri = IP_NotSet;
  3283.    
  3284.     event OnRagdollStart()
  3285.     {
  3286.         var currentPri : EInteractionPriority;
  3287.    
  3288.        
  3289.         currentPri = GetInteractionPriority();
  3290.         if ( currentPri != IP_Max_Unpushable && IsAlive() )
  3291.         {
  3292.             m_storedInteractionPri = currentPri;
  3293.             SetInteractionPriority( IP_Max_Unpushable );
  3294.         }
  3295.     }
  3296.    
  3297.     event OnNoLongerInRagdoll()
  3298.     {
  3299.         aardedFlight = false;
  3300.        
  3301.        
  3302.         if ( m_storedInteractionPri != IP_NotSet && IsAlive() )
  3303.         {
  3304.             SetInteractionPriority( m_storedInteractionPri );
  3305.             m_storedInteractionPri = IP_NotSet;
  3306.         }
  3307.     }
  3308.    
  3309.     timer function DelayRagdollSwitch( td : float , id : int)
  3310.     {
  3311.         var params : SCustomEffectParams;
  3312.    
  3313.         if( IsInAir() )
  3314.         {
  3315.             isRagdollOn = true;
  3316.             params.effectType = EET_Ragdoll;
  3317.             params.duration = 5;
  3318.            
  3319.             AddEffectCustom(params);
  3320.         }
  3321.     }
  3322.  
  3323.     event OnRagdollIsAwayFromCapsule( ragdollPosition : Vector, entityPosition : Vector )
  3324.     {
  3325.     }
  3326.    
  3327.     event OnRagdollCloseToCapsule( ragdollPosition : Vector, entityPosition : Vector )
  3328.     {
  3329.     }
  3330.    
  3331.     event OnTakeDamage( action : W3DamageAction )
  3332.     {
  3333.  
  3334.         var abilityName : name;
  3335.         var abilityCount, maxStack : float;
  3336.         var min, max : SAbilityAttributeValue;
  3337.         var addAbility : bool;
  3338.         var witcher : W3PlayerWitcher;
  3339.  
  3340.        
  3341.         super.OnTakeDamage(action);
  3342.        
  3343.        
  3344.         if(action.IsActionMelee() && action.DealsAnyDamage())
  3345.         {
  3346.             witcher = (W3PlayerWitcher)action.attacker;
  3347.             if(witcher && witcher.HasBuff(EET_Mutagen10))
  3348.             {
  3349.                 abilityName = thePlayer.GetBuff(EET_Mutagen10).GetAbilityName();
  3350.                 abilityCount = thePlayer.GetAbilityCount(abilityName);
  3351.                
  3352.                 if(abilityCount == 0)
  3353.                 {
  3354.                     addAbility = true;
  3355.                 }
  3356.                 else
  3357.                 {
  3358.                     theGame.GetDefinitionsManager().GetAbilityAttributeValue(abilityName, 'mutagen10_max_stack', min, max);
  3359.                     maxStack = CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  3360.                    
  3361.                     if(maxStack >= 0)
  3362.                     {
  3363.                         addAbility = (abilityCount < maxStack);
  3364.                     }
  3365.                     else
  3366.                     {
  3367.                         addAbility = true;
  3368.                     }
  3369.                 }
  3370.                
  3371.                 if(addAbility)
  3372.                 {
  3373.                     thePlayer.AddAbility(abilityName, true);
  3374.                 }
  3375.             }
  3376.  
  3377.         }
  3378.        
  3379.         if(action.IsActionMelee())
  3380.             lastMeleeHitTime = theGame.GetEngineTime();
  3381.  
  3382.     }
  3383.    
  3384.     public function GetInteractionData( out actionName : name, out text : string ) : bool
  3385.     {
  3386.         if ( CanStartTalk() && !IsInCombat() )
  3387.         {
  3388.             actionName  = 'Talk';
  3389.             text        = "panel_button_common_talk";
  3390.             return true;
  3391.         }
  3392.         return false;
  3393.     }
  3394.    
  3395.     public function IsAtWorkDependentOnFireSource() : bool
  3396.     {
  3397.         if ( IsAPValid(GetActiveActionPoint()) )
  3398.         {
  3399.             return theGame.GetAPManager().IsFireSourceDependent( GetActiveActionPoint() );
  3400.         }
  3401.        
  3402.         return false;
  3403.     }
  3404.    
  3405.     public function FinishQuen(skipVisuals : bool)
  3406.     {
  3407.         SignalGameplayEvent('FinishQuen');
  3408.     }
  3409.  
  3410.     public function IsAxiied() : Bool
  3411.     {
  3412.         return HasBuff( EET_AxiiGuardMe ) || HasBuff( EET_Confusion );
  3413.     }
  3414.  
  3415. }
  3416.  
  3417. exec function IsFireSource( tag : name )
  3418. {
  3419.     var npc : CNewNPC;
  3420.  
  3421.     npc = ( CNewNPC )theGame.GetEntityByTag( tag );
  3422.    
  3423.     LogChannel('SD', "" + npc.IsAtWorkDependentOnFireSource() );
  3424. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement