lufusol

playerWitcher.ws for E3 Wolf Follower for Witcher 3 4.01

Feb 12th, 2023
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /***********************************************************************/
  2. /**     © 2015 CD PROJEKT S.A. All rights reserved.
  3. /**     THE WITCHER® is a trademark of CD PROJEKT S. A.
  4. /**     The Witcher game is based on the prose of Andrzej Sapkowski.
  5. /***********************************************************************/
  6.  
  7.  
  8.  
  9.  
  10. statemachine class W3PlayerWitcher extends CR4Player
  11. {  
  12.    
  13.     private saved var craftingSchematics                : array<name>;                 
  14.     private saved var expandedCraftingCategories        : array<name>;
  15.     private saved var craftingFilters : SCraftingFilters;
  16.    
  17.    
  18.     private saved var alchemyRecipes                    : array<name>;                 
  19.     private saved var expandedAlchemyCategories         : array<name>;
  20.     private saved var alchemyFilters : SCraftingFilters;
  21.    
  22.    
  23.     private saved var expandedBestiaryCategories        : array<name>;
  24.    
  25.    
  26.     private saved var booksRead                         : array<name>;                 
  27.    
  28.    
  29.     private             var fastAttackCounter, heavyAttackCounter   : int;     
  30.     private             var isInFrenzy : bool;
  31.     private             var hasRecentlyCountered : bool;
  32.     private saved       var cannotUseUndyingSkill : bool;                      
  33.    
  34.    
  35.     protected saved         var amountOfSetPiecesEquipped           : array<int>;
  36.    
  37.    
  38.     public              var canSwitchFocusModeTarget    : bool;
  39.     protected           var switchFocusModeTargetAllowed : bool;
  40.         default canSwitchFocusModeTarget = true;
  41.         default switchFocusModeTargetAllowed = true;
  42.    
  43.    
  44.     private editable    var signs                       : array< SWitcherSign >;
  45.     private saved       var equippedSign                : ESignType;
  46.     private             var currentlyCastSign           : ESignType; default currentlyCastSign = ST_None;
  47.     private             var signOwner                   : W3SignOwnerPlayer;
  48.     private             var usedQuenInCombat            : bool;
  49.     public              var yrdenEntities               : array<W3YrdenEntity>;
  50.     public saved        var m_quenReappliedCount        : int;
  51.     private             var m_quenHitFxTTL              : float;
  52.     private             var m_TriggerEffectDisablePending : bool;
  53.     private             var m_TriggerEffectDisabled     : bool;
  54.     private             var m_TriggerEffectDisableTTW   : float;
  55.    
  56.     default             equippedSign    = ST_Aard;
  57.     default             m_quenReappliedCount = 1;
  58.    
  59.    
  60.    
  61.     private             var bDispalyHeavyAttackIndicator        : bool;
  62.     private             var bDisplayHeavyAttackFirstLevelTimer  : bool;
  63.     public              var specialAttackHeavyAllowed           : bool;
  64.  
  65.     default bIsCombatActionAllowed = true; 
  66.     default bDispalyHeavyAttackIndicator = false;
  67.     default bDisplayHeavyAttackFirstLevelTimer = true;
  68.    
  69.    
  70.    
  71.         default explorationInputContext = 'Exploration';
  72.         default combatInputContext = 'Combat';
  73.         default combatFistsInputContext = 'Combat';
  74.        
  75.    
  76.     private saved var companionNPCTag       : name;
  77.     private saved var companionNPCTag2      : name;
  78.    
  79.     private saved var companionNPCIconPath  : string;
  80.     private saved var companionNPCIconPath2 : string;  
  81.        
  82.    
  83.     private       saved var itemSlots                   : array<SItemUniqueId>;
  84.     private             var remainingBombThrowDelaySlot1    : float;
  85.     private             var remainingBombThrowDelaySlot2    : float;
  86.     private             var previouslyUsedBolt : SItemUniqueId;            
  87.     private       saved var questMarkedSelectedQuickslotItems : array< SSelectedQuickslotItem >;
  88.    
  89.     default isThrowingItem = false;
  90.     default remainingBombThrowDelaySlot1 = 0.f;
  91.     default remainingBombThrowDelaySlot2 = 0.f;
  92.    
  93.    
  94.    
  95.    
  96.    
  97.     private saved var tempLearnedSignSkills : array<SSimpleSkill>;     
  98.     public  saved var autoLevel             : bool;                    
  99.    
  100.    
  101.    
  102.    
  103.     protected saved var skillBonusPotionEffect          : CBaseGameplayEffect;         
  104.    
  105.    
  106.     public saved        var levelManager                : W3LevelManager;
  107.  
  108.    
  109.     saved var reputationManager : W3Reputation;
  110.    
  111.    
  112.     private editable    var medallionEntity         : CEntityTemplate;
  113.     private             var medallionController     : W3MedallionController;
  114.    
  115.     // Wolf Companion - Begin
  116.     private saved var hasFollowerWolf : bool;
  117.     private saved var isWolfFollowing : bool;
  118.     private var followerWolf : CWolfNPC;
  119.     public function GetFollower() : CWolfNPC
  120.     {
  121.         return followerWolf;
  122.     }
  123.    
  124.     public function RemoveFollower()
  125.     {
  126.         hasFollowerWolf = false;
  127.         isWolfFollowing = false;
  128.     }
  129.    
  130.     public function SetIsWolfFollowing( b : bool )
  131.     {
  132.         isWolfFollowing = b;
  133.     }
  134.    
  135.     public function DestroyFollower()
  136.     {
  137.         if( followerWolf )
  138.         {
  139.             followerWolf.Destroy();
  140.             delete followerWolf;
  141.             hasFollowerWolf = false;
  142.             isWolfFollowing = false;
  143.         }
  144.     }
  145.    
  146.     public function ManageFollower( optional silentSpawn : bool )
  147.     {
  148.         var Z : float;
  149.         var spawnPos : Vector;
  150.         var spawnRot : EulerAngles;
  151.         var wolfTemplate : CEntityTemplate;
  152.        
  153.         if( !followerWolf || !followerWolf.IsAlive() || (!WasVisibleInScaledFrame(followerWolf, 1.5f, 1.5f) && VecDistanceSquared(GetWorldPosition(), followerWolf.GetWorldPosition()) > 900) || VecDistanceSquared(GetWorldPosition(), followerWolf.GetWorldPosition()) > 1600 )
  154.         {
  155.             if( !silentSpawn ){
  156.                 if ( !IsUsingHorse() && theGame.GetInGameConfigWrapper().GetVarValue('wolfCompanion' ,'wolfCallSign') )
  157.                     thePlayer.PlayerStartAction( PEA_AardLight );
  158.                 else
  159.                     thePlayer.RaiseEvent('HorseSummon');
  160.             }  
  161.             if( followerWolf )
  162.             {
  163.                 followerWolf.Destroy();
  164.                 delete followerWolf;
  165.                 hasFollowerWolf = false;
  166.                 isWolfFollowing = false;
  167.             }
  168.            
  169.             spawnRot = GetWorldRotation();
  170.             spawnPos = GetWorldPosition(); Z = spawnPos.Z;
  171.             spawnPos += theCamera.GetCameraDirection() * -6;
  172.            
  173.             if( theGame.GetWorld().NavigationLineTest(GetWorldPosition(), spawnPos, 0.2f) )
  174.                 theGame.GetWorld().PhysicsCorrectZ(spawnPos, Z);
  175.                
  176.             spawnPos.Z = Z;
  177.             switch( StringToInt(theGame.GetInGameConfigWrapper().GetVarValue('wolfCompanion' ,'wolfType')) )
  178.             {
  179.                 case 0: wolfTemplate = (CEntityTemplate)LoadResource("dlc\wolfie\data\ents\wolfie_grey.w2ent", true); break;
  180.                 case 1: wolfTemplate = (CEntityTemplate)LoadResource("dlc\wolfie\data\ents\wolfie_timber.w2ent", true); break;
  181.                 case 2: wolfTemplate = (CEntityTemplate)LoadResource("dlc\wolfie\data\ents\wolfie_white.w2ent", true); break;
  182.             }
  183.             followerWolf = (CWolfNPC)theGame.CreateEntity(wolfTemplate, spawnPos, spawnRot);
  184.            
  185.             if( followerWolf )
  186.             {
  187.                 hasFollowerWolf = true;
  188.                 isWolfFollowing = true;
  189.             }
  190.         }
  191.         else followerWolf.OnCompanionInteraction();
  192.     }
  193.    
  194.     timer function CompanionOnSpawn( dt : float, id : int )
  195.     {
  196.         if( hasFollowerWolf && isWolfFollowing )
  197.             ManageFollower(true);
  198.     }
  199.     // Wolf Companion - End
  200.    
  201.    
  202.    
  203.     public              var bShowRadialMenu : bool;
  204.  
  205.     private             var _HoldBeforeOpenRadialMenuTime : float;
  206.    
  207.     default _HoldBeforeOpenRadialMenuTime = 0.5f;
  208.    
  209.     public var MappinToHighlight : array<SHighlightMappin>;
  210.    
  211.    
  212.     protected saved var horseManagerHandle          : EntityHandle;    
  213.  
  214.     private var isInitialized : bool;
  215.     private var timeForPerk21 : float;
  216.    
  217.         default isInitialized = false;
  218.        
  219.    
  220.     private var invUpdateTransaction : bool;
  221.         default invUpdateTransaction = false;
  222.    
  223.     public var lastPressedWithNostamina : bool;
  224.         default lastPressedWithNostamina = false;
  225.    
  226.    
  227.    
  228.    
  229.    
  230.    
  231.    
  232.    
  233.    
  234.    
  235.    
  236.     event OnSpawned( spawnData : SEntitySpawnData )
  237.     {
  238.         var i               : int;
  239.         var items           : array<SItemUniqueId>;
  240.         var items2          : array<SItemUniqueId>;
  241.         var horseTemplate   : CEntityTemplate;
  242.         var horseManager    : W3HorseManager;
  243.        
  244.        
  245.         var exceptions : array<CBaseGameplayEffect>;
  246.         var wolf : CBaseGameplayEffect;
  247.        
  248.        
  249.         AddAnimEventCallback( 'ActionBlend',            'OnAnimEvent_ActionBlend' );
  250.         AddAnimEventCallback('cast_begin',              'OnAnimEvent_Sign');
  251.         AddAnimEventCallback('cast_throw',              'OnAnimEvent_Sign');
  252.         AddAnimEventCallback('cast_end',                'OnAnimEvent_Sign');
  253.         AddAnimEventCallback('cast_friendly_begin',     'OnAnimEvent_Sign');
  254.         AddAnimEventCallback('cast_friendly_throw',     'OnAnimEvent_Sign');
  255.         AddAnimEventCallback('axii_ready',              'OnAnimEvent_Sign');
  256.         AddAnimEventCallback('axii_alternate_ready',    'OnAnimEvent_Sign');
  257.         AddAnimEventCallback('yrden_draw_ready',        'OnAnimEvent_Sign');
  258.        
  259.         AddAnimEventCallback( 'ProjectileThrow',    'OnAnimEvent_Throwable' );
  260.         AddAnimEventCallback( 'OnWeaponReload',     'OnAnimEvent_Throwable' );
  261.         AddAnimEventCallback( 'ProjectileAttach',   'OnAnimEvent_Throwable' );
  262.         AddAnimEventCallback( 'Mutation11AnimEnd',  'OnAnimEvent_Mutation11AnimEnd' );
  263.         AddAnimEventCallback( 'Mutation11ShockWave', 'OnAnimEvent_Mutation11ShockWave' );
  264.        
  265.  
  266.        
  267.         amountOfSetPiecesEquipped.Resize( EnumGetMax( 'EItemSetType' ) + 1 );
  268.        
  269.         runewordInfusionType = ST_None;
  270.                
  271.        
  272.         inv = GetInventory();          
  273.  
  274.        
  275.         signOwner = new W3SignOwnerPlayer in this;
  276.         signOwner.Init( this );
  277.        
  278.         itemSlots.Resize( EnumGetMax('EEquipmentSlots')+1 );
  279.  
  280.         if(!spawnData.restored)
  281.         {
  282.             levelManager = new W3LevelManager in this;         
  283.             levelManager.Initialize();
  284.            
  285.            
  286.             inv.GetAllItems(items);
  287.             for(i=0; i<items.Size(); i+=1)
  288.             {
  289.                 if(inv.IsItemMounted(items[i]) && ( !inv.IsItemBody(items[i]) || inv.GetItemCategory(items[i]) == 'hair' ) )
  290.                     EquipItem(items[i]);
  291.             }
  292.            
  293.            
  294.            
  295.            
  296.            
  297.             AddAlchemyRecipe('Recipe for Swallow 1',true,true);
  298.             AddAlchemyRecipe('Recipe for Cat 1',true,true);
  299.             AddAlchemyRecipe('Recipe for White Honey 1',true,true);
  300.            
  301.             AddAlchemyRecipe('Recipe for Samum 1',true,true);
  302.             AddAlchemyRecipe('Recipe for Grapeshot 1',true,true);
  303.            
  304.             AddAlchemyRecipe('Recipe for Specter Oil 1',true,true);
  305.             AddAlchemyRecipe('Recipe for Necrophage Oil 1',true,true);
  306.             AddAlchemyRecipe('Recipe for Alcohest 1',true,true);
  307.         }
  308.         else
  309.         {
  310.             AddTimer('DelayedOnItemMount', 0.1, true);
  311.            
  312.            
  313.             CheckHairItem();
  314.         }
  315.        
  316.        
  317.         AddStartingSchematics();
  318.  
  319.         super.OnSpawned( spawnData );
  320.        
  321.        
  322.         AddAlchemyRecipe('Recipe for Mutagen red',true,true);
  323.         AddAlchemyRecipe('Recipe for Mutagen green',true,true);
  324.         AddAlchemyRecipe('Recipe for Mutagen blue',true,true);
  325.         AddAlchemyRecipe('Recipe for Greater mutagen red',true,true);
  326.         AddAlchemyRecipe('Recipe for Greater mutagen green',true,true);
  327.         AddAlchemyRecipe('Recipe for Greater mutagen blue',true,true);
  328.        
  329.         AddCraftingSchematic('Starting Armor Upgrade schematic 1',true,true);
  330.        
  331.        
  332.         if( inputHandler )
  333.         {
  334.             inputHandler.BlockAllActions( 'being_ciri', false );
  335.         }
  336.         SetBehaviorVariable( 'test_ciri_replacer', 0.0f);
  337.        
  338.         if(!spawnData.restored)
  339.         {
  340.            
  341.             abilityManager.GainStat(BCS_Toxicity, 0);      
  342.         }      
  343.        
  344.         levelManager.PostInit(this, spawnData.restored, true);
  345.        
  346.         SetBIsCombatActionAllowed( true );     
  347.         SetBIsInputAllowed( true, 'OnSpawned' );               
  348.        
  349.        
  350.         if ( !reputationManager )
  351.         {
  352.             reputationManager = new W3Reputation in this;
  353.             reputationManager.Initialize();
  354.         }
  355.        
  356.         theSound.SoundParameter( "focus_aim", 1.0f, 1.0f );
  357.         theSound.SoundParameter( "focus_distance", 0.0f, 1.0f );
  358.        
  359.        
  360.        
  361.        
  362.            
  363.        
  364.         currentlyCastSign = ST_None;
  365.        
  366.        
  367.         if(!spawnData.restored)
  368.         {
  369.             horseTemplate = (CEntityTemplate)LoadResource("horse_manager");
  370.             horseManager = (W3HorseManager)theGame.CreateEntity(horseTemplate, GetWorldPosition(),,,,,PM_Persist);
  371.             horseManager.CreateAttachment(this);
  372.             horseManager.OnCreated();
  373.             EntityHandleSet( horseManagerHandle, horseManager );
  374.         }
  375.         else
  376.         {
  377.             AddTimer('DelayedHorseUpdate', 0.01, true);
  378.         }
  379.        
  380.        
  381.         RemoveAbility('Ciri_CombatRegen');
  382.         RemoveAbility('Ciri_Rage');
  383.         RemoveAbility('CiriBlink');
  384.         RemoveAbility('CiriCharge');
  385.         RemoveAbility('Ciri_Q205');
  386.         RemoveAbility('Ciri_Q305');
  387.         RemoveAbility('Ciri_Q403');
  388.         RemoveAbility('Ciri_Q111');
  389.         RemoveAbility('Ciri_Q501');
  390.         RemoveAbility('SkillCiri');
  391.        
  392.         if(spawnData.restored)
  393.         {
  394.             RestoreQuen(savedQuenHealth, savedQuenDuration);           
  395.         }
  396.         else
  397.         {
  398.             savedQuenHealth = 0.f;
  399.             savedQuenDuration = 0.f;
  400.         }
  401.        
  402.         if(spawnData.restored)
  403.         {
  404.             ApplyPatchFixes();
  405.         }
  406.         else
  407.         {
  408.            
  409.             FactsAdd( "new_game_started_in_1_20" );
  410.         }
  411.        
  412.         if ( spawnData.restored )
  413.         {
  414.             FixEquippedMutagens();
  415.         }
  416.        
  417.         if ( FactsQuerySum("NewGamePlus") > 0 )
  418.         {
  419.             NewGamePlusAdjustDLC1TemerianSet(inv);
  420.             NewGamePlusAdjustDLC5NilfgardianSet(inv);
  421.             NewGamePlusAdjustDLC10WolfSet(inv);
  422.             NewGamePlusAdjustDLC14SkelligeSet(inv);
  423.            
  424.            
  425.            
  426.            
  427.             if(horseManager)
  428.             {
  429.                 NewGamePlusAdjustDLC1TemerianSet(horseManager.GetInventoryComponent());
  430.                 NewGamePlusAdjustDLC5NilfgardianSet(horseManager.GetInventoryComponent());
  431.                 NewGamePlusAdjustDLC10WolfSet(horseManager.GetInventoryComponent());
  432.                 NewGamePlusAdjustDLC14SkelligeSet(horseManager.GetInventoryComponent());   
  433.                
  434.                
  435.                
  436.                
  437.             }
  438.         }
  439.        
  440.         // Wolf Companion - Begin
  441.         AddTimer('CompanionOnSpawn', 1.f, false);
  442.         // Wolf Companion - End
  443.        
  444.         ResumeStaminaRegen('WhirlSkill');
  445.        
  446.         if(HasAbility('Runeword 4 _Stats', true))
  447.             StartVitalityRegen();
  448.        
  449.        
  450.         if(HasAbility('sword_s19'))
  451.         {
  452.             RemoveTemporarySkills();
  453.         }
  454.        
  455.         HACK_UnequipWolfLiver();
  456.        
  457.        
  458.         if( HasBuff( EET_GryphonSetBonusYrden ) )
  459.         {
  460.             RemoveBuff( EET_GryphonSetBonusYrden, false, "GryphonSetBonusYrden" );
  461.         }
  462.        
  463.         if( spawnData.restored )
  464.         {
  465.            
  466.             UpdateEncumbrance();
  467.            
  468.            
  469.             RemoveBuff( EET_Mutation11Immortal );
  470.             RemoveBuff( EET_Mutation11Buff );
  471.         }
  472.        
  473.        
  474.         theGame.GameplayFactsAdd( "PlayerIsGeralt" );
  475.        
  476.         isInitialized = true;
  477.        
  478.        
  479.         if(IsMutationActive( EPMT_Mutation6 ))
  480.             if(( (W3PlayerAbilityManager)abilityManager).GetMutationSoundBank(( EPMT_Mutation6 )) != "" )
  481.                 theSound.SoundLoadBank(((W3PlayerAbilityManager)abilityManager).GetMutationSoundBank(( EPMT_Mutation6 )), true );
  482.        
  483.        
  484.        
  485.         if( FactsQuerySum("NGE_SkillPointsCheck") < 1 )
  486.         {
  487.            
  488.             ForceSetStat(BCS_Toxicity, 0);
  489.             wolf = GetBuff(EET_WolfHour);
  490.             if(wolf)
  491.                 exceptions.PushBack(wolf);
  492.                
  493.             RemoveAllPotionEffects(exceptions);
  494.            
  495.  
  496.             AddTimer('NGE_FixSkillPoints',1.0f,false);
  497.         }      
  498.        
  499.        
  500.        
  501.         ManageSetBonusesSoundbanks(EIST_Lynx);
  502.         ManageSetBonusesSoundbanks(EIST_Gryphon);
  503.         ManageSetBonusesSoundbanks(EIST_Bear);
  504.        
  505.  
  506.         m_quenHitFxTTL = 0;
  507.         m_TriggerEffectDisablePending = false;
  508.         m_TriggerEffectDisabled = false;
  509.         ApplyGamepadTriggerEffect( equippedSign );
  510.         AddTimer( 'UpdateGamepadTriggerEffect', 0.1, true );
  511.     }
  512.    
  513.    
  514.     private timer function NGE_FixSkillPoints( dt : float, id : int )
  515.     {
  516.         ((W3PlayerAbilityManager)abilityManager).NGEFixSkillPoints();
  517.         FixNGESwords();
  518.         FactsAdd("NGE_SkillPointsCheck");
  519.     }
  520.    
  521.    
  522.    
  523.     private function FixNGESwords()
  524.     {
  525.        
  526.         var swords, swordsTemp : array<SItemUniqueId>;
  527.         var i : int;
  528.         var equipped : bool;
  529.         var runesList : array <name>;
  530.  
  531.         swords = inv.GetItemsByName('sq304 Novigraadan sword 4');
  532.         if(swords.Size() > 0)
  533.         {
  534.             for(i=0;i<swords.Size();i+=1)
  535.             {
  536.                 if( IsItemEquipped(swords[i]) )
  537.                     equipped = true;
  538.                    
  539.                 if ( inv.GetItemEnhancementCount(swords[i]) > 0 )
  540.                 {
  541.                     inv.GetItemEnhancementItems(swords[i], runesList);
  542.                     for (i = 0; i < runesList.Size(); i+=1)
  543.                     {
  544.                         inv.AddAnItem( runesList[i] );
  545.                     }      
  546.                 }
  547.                
  548.                 inv.RemoveItem(swords[i],1);
  549.                 swordsTemp = inv.AddAnItem('sq304 Novigraadan sword 4',1,true,true);
  550.                 if(equipped)
  551.                     EquipItem(swordsTemp[0]);
  552.             }
  553.         }
  554.  
  555.         swords = inv.GetItemsByName('q402 Skellige sword 3');
  556.         if(swords.Size() > 0)
  557.         {
  558.             for(i=0;i<swords.Size();i+=1)
  559.             {
  560.                 if( IsItemEquipped(swords[i]) )
  561.                     equipped = true;
  562.                    
  563.                 if ( inv.GetItemEnhancementCount(swords[i]) > 0 )
  564.                 {
  565.                     inv.GetItemEnhancementItems(swords[i], runesList);
  566.                     for (i = 0; i < runesList.Size(); i+=1)
  567.                     {
  568.                         inv.AddAnItem( runesList[i] );
  569.                     }      
  570.                 }
  571.                
  572.                 inv.RemoveItem(swords[i],1);
  573.                 swordsTemp = inv.AddAnItem('q402 Skellige sword 3',1,true,true);
  574.                 if(equipped)
  575.                     EquipItem( swordsTemp[0]);
  576.             }
  577.         }
  578.     }
  579.    
  580.  
  581.     event OnDestroyed()
  582.     {
  583.         RemoveTimer( 'UpdateGamepadTriggerEffect' );
  584.  
  585.         theGame.ClearTriggerEffect(0);
  586.         theGame.ClearTriggerEffect(1);
  587.  
  588.         super.OnDestroyed();
  589.     }
  590.  
  591.    
  592.    
  593.    
  594.    
  595.     private function HACK_UnequipWolfLiver()
  596.     {
  597.         var itemName1, itemName2, itemName3, itemName4 : name;
  598.         var item1, item2, item3, item4 : SItemUniqueId;
  599.        
  600.         GetItemEquippedOnSlot( EES_Potion1, item1 );
  601.         GetItemEquippedOnSlot( EES_Potion2, item2 );
  602.         GetItemEquippedOnSlot( EES_Potion3, item3 );
  603.         GetItemEquippedOnSlot( EES_Potion4, item4 );
  604.  
  605.         if ( inv.IsIdValid( item1 ) )
  606.             itemName1 = inv.GetItemName( item1 );
  607.         if ( inv.IsIdValid( item2 ) )
  608.             itemName2 = inv.GetItemName( item2 );
  609.         if ( inv.IsIdValid( item3 ) )
  610.             itemName3 = inv.GetItemName( item3 );
  611.         if ( inv.IsIdValid( item4 ) )
  612.             itemName4 = inv.GetItemName( item4 );
  613.  
  614.         if ( itemName1 == 'Wolf liver' || itemName3 == 'Wolf liver' )
  615.         {
  616.             if ( inv.IsIdValid( item1 ) )
  617.                 UnequipItem( item1 );
  618.             if ( inv.IsIdValid( item3 ) )
  619.                 UnequipItem( item3 );
  620.         }
  621.         else if ( itemName2 == 'Wolf liver' || itemName4 == 'Wolf liver' )
  622.         {
  623.             if ( inv.IsIdValid( item2 ) )
  624.                 UnequipItem( item2 );
  625.             if ( inv.IsIdValid( item4 ) )
  626.                 UnequipItem( item4 );
  627.         }
  628.     }
  629.    
  630.    
  631.    
  632.    
  633.  
  634.     timer function DelayedHorseUpdate( dt : float, id : int )
  635.     {
  636.         var man : W3HorseManager;
  637.        
  638.         man = GetHorseManager();
  639.         if(man)
  640.         {
  641.             if ( man.ApplyHorseUpdateOnSpawn() )
  642.             {
  643.                
  644.                 UpdateEncumbrance();
  645.                
  646.                 RemoveTimer( 'DelayedHorseUpdate' );
  647.             }
  648.         }
  649.     }  
  650.    
  651.     event OnAbilityAdded( abilityName : name)
  652.     {
  653.         super.OnAbilityAdded(abilityName);
  654.        
  655.         if( HasAbility('Runeword 4 _Stats', true) )
  656.         {
  657.             StartVitalityRegen();
  658.         }
  659.            
  660.         if ( abilityName == 'Runeword 8 _Stats' && GetStat(BCS_Focus, true) >= GetStatMax(BCS_Focus) && !HasBuff(EET_Runeword8) )
  661.         {
  662.             AddEffectDefault(EET_Runeword8, this, "equipped item");
  663.         }
  664.  
  665.     }
  666.    
  667.     private final function AddStartingSchematics()
  668.     {
  669.         AddCraftingSchematic('Starting Armor Upgrade schematic 1',  true,true);
  670.         AddCraftingSchematic('Thread schematic',                    true, true);
  671.         AddCraftingSchematic('String schematic',                    true, true);
  672.         AddCraftingSchematic('Linen schematic',                     true, true);
  673.         AddCraftingSchematic('Silk schematic',                      true, true);
  674.         AddCraftingSchematic('Resin schematic',                     true, true);
  675.         AddCraftingSchematic('Blasting powder schematic',           true, true);
  676.         AddCraftingSchematic('Haft schematic',                      true, true);
  677.         AddCraftingSchematic('Hardened timber schematic',           true, true);
  678.         AddCraftingSchematic('Leather squares schematic',           true, true);
  679.         AddCraftingSchematic('Leather schematic',                   true, true);
  680.         AddCraftingSchematic('Hardened leather schematic',          true, true);
  681.         AddCraftingSchematic('Draconide leather schematic',         true, true);
  682.         AddCraftingSchematic('Iron ingot schematic',                true, true);
  683.         AddCraftingSchematic('Steel ingot schematic',               true, true);
  684.         AddCraftingSchematic('Steel ingot schematic 1',             true, true);
  685.         AddCraftingSchematic('Steel plate schematic',               true, true);
  686.         AddCraftingSchematic('Dark iron ingot schematic',           true, true);
  687.         AddCraftingSchematic('Dark iron plate schematic',           true, true);
  688.         AddCraftingSchematic('Dark steel ingot schematic',          true, true);
  689.         AddCraftingSchematic('Dark steel ingot schematic 1',        true, true);
  690.         AddCraftingSchematic('Dark steel plate schematic',          true, true);
  691.         AddCraftingSchematic('Silver ore schematic',                true, true);
  692.         AddCraftingSchematic('Silver ingot schematic',              true, true);
  693.         AddCraftingSchematic('Silver ingot schematic 1',            true, true);
  694.         AddCraftingSchematic('Silver plate schematic',              true, true);
  695.         AddCraftingSchematic('Meteorite ingot schematic',           true, true);
  696.         AddCraftingSchematic('Meteorite silver ingot schematic',    true, true);
  697.         AddCraftingSchematic('Meteorite silver plate schematic',    true, true);
  698.         AddCraftingSchematic('Glowing ingot schematic',             true, true);
  699.         AddCraftingSchematic('Dwimeryte ore schematic',             true, true);
  700.         AddCraftingSchematic('Dwimeryte ingot schematic',           true, true);
  701.         AddCraftingSchematic('Dwimeryte ingot schematic 1',         true, true);
  702.         AddCraftingSchematic('Dwimeryte plate schematic',           true, true);
  703.         AddCraftingSchematic('Infused dust schematic',              true, true);
  704.         AddCraftingSchematic('Infused shard schematic',             true, true);
  705.         AddCraftingSchematic('Infused crystal schematic',           true, true);
  706.  
  707.         if ( theGame.GetDLCManager().IsEP2Available() )
  708.         {
  709.             AddCraftingSchematic('Draconide infused leather schematic', true, true);
  710.             AddCraftingSchematic('Nickel ore schematic',                true, true);
  711.             AddCraftingSchematic('Cupronickel ore schematic',           true, true);
  712.             AddCraftingSchematic('Copper ore schematic',                true, true);
  713.             AddCraftingSchematic('Copper ingot schematic',              true, true);
  714.             AddCraftingSchematic('Copper plate schematic',              true, true);
  715.             AddCraftingSchematic('Green gold ore schematic',            true, true);
  716.             AddCraftingSchematic('Green gold ore schematic 1',          true, true);
  717.             AddCraftingSchematic('Green gold ingot schematic',          true, true);
  718.             AddCraftingSchematic('Green gold plate schematic',          true, true);
  719.             AddCraftingSchematic('Orichalcum ore schematic',            true, true);
  720.             AddCraftingSchematic('Orichalcum ore schematic 1',          true, true);
  721.             AddCraftingSchematic('Orichalcum ingot schematic',          true, true);
  722.             AddCraftingSchematic('Orichalcum plate schematic',          true, true);
  723.             AddCraftingSchematic('Dwimeryte enriched ore schematic',    true, true);
  724.             AddCraftingSchematic('Dwimeryte enriched ingot schematic',  true, true);
  725.             AddCraftingSchematic('Dwimeryte enriched plate schematic',  true, true);
  726.         }
  727.     }
  728.    
  729.     private final function ApplyPatchFixes()
  730.     {
  731.         var cnt, transmutationCount, mutagenCount, i, slot : int;
  732.         var transmutationAbility, itemName : name;
  733.         var pam : W3PlayerAbilityManager;
  734.         var slotId : int;
  735.         var offset : float;
  736.         var buffs : array<CBaseGameplayEffect>;
  737.         var mutagen : W3Mutagen_Effect;
  738.         var skill : SSimpleSkill;
  739.         var spentSkillPoints, swordSkillPointsSpent, alchemySkillPointsSpent, perkSkillPointsSpent, pointsToAdd : int;
  740.         var mutagens : array< W3Mutagen_Effect >;
  741.        
  742.         if(FactsQuerySum("ClearingPotionPassiveBonusFix") < 1)
  743.         {
  744.             pam = (W3PlayerAbilityManager)abilityManager;
  745.  
  746.             cnt = GetAbilityCount('sword_adrenalinegain') - pam.GetPathPointsSpent(ESP_Sword);
  747.             if(cnt > 0)
  748.                 RemoveAbilityMultiple('sword_adrenalinegain', cnt);
  749.                
  750.             cnt = GetAbilityCount('magic_staminaregen') - pam.GetPathPointsSpent(ESP_Signs);
  751.             if(cnt > 0)
  752.                 RemoveAbilityMultiple('magic_staminaregen', cnt);
  753.                
  754.             cnt = GetAbilityCount('alchemy_potionduration') - pam.GetPathPointsSpent(ESP_Alchemy);
  755.             if(cnt > 0)
  756.                 RemoveAbilityMultiple('alchemy_potionduration', cnt);
  757.        
  758.             FactsAdd("ClearingPotionPassiveBonusFix");
  759.         }
  760.                
  761.        
  762.         if(FactsQuerySum("DimeritiumSynergyFix") < 1)
  763.         {
  764.             slotId = GetSkillSlotID(S_Alchemy_s19);
  765.             if(slotId != -1)
  766.                 UnequipSkill(S_Alchemy_s19);
  767.                
  768.             RemoveAbilityAll('greater_mutagen_color_green_synergy_bonus');
  769.             RemoveAbilityAll('mutagen_color_green_synergy_bonus');
  770.             RemoveAbilityAll('mutagen_color_lesser_green_synergy_bonus');
  771.            
  772.             RemoveAbilityAll('greater_mutagen_color_blue_synergy_bonus');
  773.             RemoveAbilityAll('mutagen_color_blue_synergy_bonus');
  774.             RemoveAbilityAll('mutagen_color_lesser_blue_synergy_bonus');
  775.            
  776.             RemoveAbilityAll('greater_mutagen_color_red_synergy_bonus');
  777.             RemoveAbilityAll('mutagen_color_red_synergy_bonus');
  778.             RemoveAbilityAll('mutagen_color_lesser_red_synergy_bonus');
  779.            
  780.             if(slotId != -1)
  781.                 EquipSkill(S_Alchemy_s19, slotId);
  782.        
  783.             FactsAdd("DimeritiumSynergyFix");
  784.         }
  785.        
  786.        
  787.         if(FactsQuerySum("DontShowRecipePinTut") < 1)
  788.         {
  789.             FactsAdd( "DontShowRecipePinTut" );
  790.             TutorialScript('alchemyRecipePin', '');
  791.             TutorialScript('craftingRecipePin', '');
  792.         }
  793.        
  794.        
  795.         if(FactsQuerySum("LevelReqPotGiven") < 1)
  796.         {
  797.             FactsAdd("LevelReqPotGiven");
  798.             inv.AddAnItem('Wolf Hour', 1, false, false, true);
  799.         }
  800.        
  801.        
  802.         if(!HasBuff(EET_AutoStaminaRegen))
  803.         {
  804.             AddEffectDefault(EET_AutoStaminaRegen, this, 'autobuff', false);
  805.         }
  806.        
  807.        
  808.        
  809.         buffs = GetBuffs();
  810.         offset = 0;
  811.         mutagenCount = 0;
  812.         for(i=0; i<buffs.Size(); i+=1)
  813.         {
  814.             mutagen = (W3Mutagen_Effect)buffs[i];
  815.             if(mutagen)
  816.             {
  817.                 offset += mutagen.GetToxicityOffset();
  818.                 mutagenCount += 1;
  819.             }
  820.         }
  821.        
  822.        
  823.         if(offset != (GetStat(BCS_Toxicity) - GetStat(BCS_Toxicity, true)))
  824.             SetToxicityOffset(offset);
  825.            
  826.        
  827.         mutagenCount *= GetSkillLevel(S_Alchemy_s13);
  828.         transmutationAbility = GetSkillAbilityName(S_Alchemy_s13);
  829.         transmutationCount = GetAbilityCount(transmutationAbility);
  830.         if(mutagenCount < transmutationCount)
  831.         {
  832.             RemoveAbilityMultiple(transmutationAbility, transmutationCount - mutagenCount);
  833.         }
  834.         else if(mutagenCount > transmutationCount)
  835.         {
  836.             AddAbilityMultiple(transmutationAbility, mutagenCount - transmutationCount);
  837.         }
  838.        
  839.        
  840.         if(theGame.GetDLCManager().IsEP1Available())
  841.         {
  842.             theGame.GetJournalManager().ActivateEntryByScriptTag('TutorialJournalEnchanting', JS_Active);
  843.         }
  844.  
  845.        
  846.         if(HasAbility('sword_s19') && FactsQuerySum("Patch_Sword_s19") < 1)
  847.         {
  848.             pam = (W3PlayerAbilityManager)abilityManager;
  849.  
  850.            
  851.             skill.level = 0;
  852.             for(i = S_Magic_s01; i <= S_Magic_s20; i+=1)
  853.             {
  854.                 skill.skillType = i;               
  855.                 pam.RemoveTemporarySkill(skill);
  856.             }
  857.            
  858.            
  859.             spentSkillPoints = levelManager.GetPointsUsed(ESkillPoint);
  860.             swordSkillPointsSpent = pam.GetPathPointsSpent(ESP_Sword);
  861.             alchemySkillPointsSpent = pam.GetPathPointsSpent(ESP_Alchemy);
  862.             perkSkillPointsSpent = pam.GetPathPointsSpent(ESP_Perks);
  863.            
  864.             pointsToAdd = spentSkillPoints - swordSkillPointsSpent - alchemySkillPointsSpent - perkSkillPointsSpent;
  865.             if(pointsToAdd > 0)
  866.                 levelManager.UnspendPoints(ESkillPoint, pointsToAdd);
  867.            
  868.            
  869.             RemoveAbilityAll('sword_s19');
  870.            
  871.            
  872.             FactsAdd("Patch_Sword_s19");
  873.         }
  874.        
  875.        
  876.         if( HasAbility( 'sword_s19' ) )
  877.         {
  878.             RemoveAbilityAll( 'sword_s19' );
  879.         }
  880.        
  881.        
  882.         if(FactsQuerySum("Patch_Armor_Type_Glyphwords") < 1)
  883.         {
  884.             pam = (W3PlayerAbilityManager)abilityManager;
  885.            
  886.             pam.SetPerkArmorBonus( S_Perk_05, this );
  887.             pam.SetPerkArmorBonus( S_Perk_06, this );
  888.             pam.SetPerkArmorBonus( S_Perk_07, this );
  889.            
  890.             FactsAdd("Patch_Armor_Type_Glyphwords");
  891.         }
  892.         else if( FactsQuerySum("154999") < 1 )
  893.         {
  894.            
  895.             pam = (W3PlayerAbilityManager)abilityManager;
  896.            
  897.             pam.SetPerkArmorBonus( S_Perk_05, this );
  898.             pam.SetPerkArmorBonus( S_Perk_06, this );
  899.             pam.SetPerkArmorBonus( S_Perk_07, this );
  900.            
  901.             FactsAdd("154999");
  902.         }
  903.        
  904.         if( FactsQuerySum( "Patch_Decoction_Buff_Icons" ) < 1 )
  905.         {
  906.             mutagens = GetMutagenBuffs();
  907.             for( i=0; i<mutagens.Size(); i+=1 )
  908.             {
  909.                 itemName = DecoctionEffectTypeToItemName( mutagens[i].GetEffectType() );               
  910.                 mutagens[i].OverrideIcon( itemName );
  911.             }
  912.            
  913.             FactsAdd( "Patch_Decoction_Buff_Icons" );
  914.         }
  915.        
  916.        
  917.         if( FactsQuerySum( "154997" ) < 1 )
  918.         {
  919.             if( IsSkillEquipped( S_Alchemy_s18 ) )
  920.             {
  921.                 slot = GetSkillSlotID( S_Alchemy_s18 );
  922.                 UnequipSkill( slot );
  923.                 EquipSkill( S_Alchemy_s18, slot );
  924.             }
  925.             FactsAdd( "154997" );
  926.         }
  927.         if( FactsQuerySum( "Patch_Mutagen_Ing_Stacking" ) < 1 )
  928.         {
  929.             Patch_MutagenStacking();       
  930.             FactsAdd( "Patch_Mutagen_Ing_Stacking" );
  931.         }
  932.     }
  933.    
  934.     private final function Patch_MutagenStacking()
  935.     {
  936.         var i, j, quantity : int;
  937.         var muts : array< SItemUniqueId >;
  938.         var item : SItemUniqueId;
  939.         var mutName : name;
  940.         var wasInArray : bool;
  941.         var mutsToAdd : array< SItemParts >;
  942.         var mutToAdd : SItemParts;
  943.        
  944.         muts = inv.GetItemsByTag( 'MutagenIngredient' );
  945.         if( GetItemEquippedOnSlot( EES_SkillMutagen1, item ) )
  946.         {
  947.             muts.Remove( item );
  948.             inv.SetItemStackable( item, false );
  949.         }
  950.         if( GetItemEquippedOnSlot( EES_SkillMutagen2, item ) )
  951.         {
  952.             muts.Remove( item );
  953.             inv.SetItemStackable( item, false );
  954.         }
  955.         if( GetItemEquippedOnSlot( EES_SkillMutagen3, item ) )
  956.         {
  957.             muts.Remove( item );
  958.             inv.SetItemStackable( item, false );
  959.         }
  960.         if( GetItemEquippedOnSlot( EES_SkillMutagen4, item ) )
  961.         {
  962.             muts.Remove( item );
  963.             inv.SetItemStackable( item, false );
  964.         }
  965.        
  966.         for( i=0; i<muts.Size(); i+=1 )
  967.         {
  968.             mutName = inv.GetItemName( muts[i] );
  969.             quantity = inv.GetItemQuantity( muts[i] );
  970.            
  971.             wasInArray = false;
  972.             for( j=0; j<mutsToAdd.Size(); j+=1 )
  973.             {
  974.                 if( mutsToAdd[j].itemName == mutName )
  975.                 {
  976.                     mutsToAdd[j].quantity += quantity;
  977.                     wasInArray = true;
  978.                     break;
  979.                 }
  980.             }
  981.            
  982.             if( !wasInArray )
  983.             {
  984.                 mutToAdd.itemName = mutName;
  985.                 mutToAdd.quantity = quantity;
  986.                 mutsToAdd.PushBack( mutToAdd );
  987.             }
  988.            
  989.             inv.RemoveItem( muts[i], quantity );
  990.         }
  991.        
  992.         for( i=0; i<mutsToAdd.Size(); i+=1 )
  993.         {
  994.             inv.AddAnItem( mutsToAdd[i].itemName, mutsToAdd[i].quantity, true, true );
  995.         }
  996.     }
  997.    
  998.     private function FixEquippedMutagens()
  999.     {
  1000.         var item : SItemUniqueId;
  1001.         if( GetItemEquippedOnSlot( EES_SkillMutagen1, item ) )
  1002.         {
  1003.             inv.SetItemStackable( item, false );
  1004.         }
  1005.         if( GetItemEquippedOnSlot( EES_SkillMutagen2, item ) )
  1006.         {
  1007.             inv.SetItemStackable( item, false );
  1008.         }
  1009.         if( GetItemEquippedOnSlot( EES_SkillMutagen3, item ) )
  1010.         {
  1011.             inv.SetItemStackable( item, false );
  1012.         }
  1013.         if( GetItemEquippedOnSlot( EES_SkillMutagen4, item ) )
  1014.         {
  1015.             inv.SetItemStackable( item, false );
  1016.         }
  1017.     }
  1018.  
  1019.     public final function RestoreQuen( quenHealth : float, quenDuration : float, optional alternate : bool ) : bool
  1020.     {
  1021.         var restoredQuen    : W3QuenEntity;
  1022.        
  1023.         if(quenHealth > 0.f && quenDuration >= 3.f)
  1024.         {
  1025.             restoredQuen = (W3QuenEntity)theGame.CreateEntity( signs[ST_Quen].template, GetWorldPosition(), GetWorldRotation() );
  1026.             restoredQuen.Init( signOwner, signs[ST_Quen].entity, true );
  1027.            
  1028.             if( alternate )
  1029.             {
  1030.                 restoredQuen.SetAlternateCast( S_Magic_s04 );
  1031.             }
  1032.            
  1033.             restoredQuen.OnStarted();
  1034.             restoredQuen.OnThrowing();
  1035.            
  1036.             if( !alternate )
  1037.             {
  1038.                 restoredQuen.OnEnded();
  1039.             }
  1040.            
  1041.             restoredQuen.SetDataFromRestore(quenHealth, quenDuration);
  1042.            
  1043.             return true;
  1044.         }
  1045.        
  1046.         return false;
  1047.     }
  1048.    
  1049.     public function IsInitialized() : bool
  1050.     {
  1051.         return isInitialized;
  1052.     }
  1053.    
  1054.     private function NewGamePlusInitialize()
  1055.     {
  1056.         var questItems : array<name>;
  1057.         var horseManager : W3HorseManager;
  1058.         var horseInventory : CInventoryComponent;
  1059.         var i, missingLevels, expDiff : int;
  1060.        
  1061.         super.NewGamePlusInitialize();
  1062.        
  1063.        
  1064.         horseManager = (W3HorseManager)EntityHandleGet(horseManagerHandle);
  1065.         if(horseManager)
  1066.             horseInventory = horseManager.GetInventoryComponent();
  1067.        
  1068.        
  1069.         theGame.params.SetNewGamePlusLevel(GetLevel());
  1070.        
  1071.        
  1072.         if (theGame.GetDLCManager().IsDLCAvailable('ep1'))
  1073.             missingLevels = theGame.params.NEW_GAME_PLUS_EP1_MIN_LEVEL - GetLevel();
  1074.         else
  1075.             missingLevels = theGame.params.NEW_GAME_PLUS_MIN_LEVEL - GetLevel();
  1076.            
  1077.         for(i=0; i<missingLevels; i+=1)
  1078.         {
  1079.            
  1080.             expDiff = levelManager.GetTotalExpForNextLevel() - levelManager.GetPointsTotal(EExperiencePoint);
  1081.             expDiff = CeilF( ((float)expDiff) / 2 );
  1082.             AddPoints(EExperiencePoint, expDiff, false);
  1083.         }
  1084.        
  1085.        
  1086.        
  1087.        
  1088.        
  1089.         inv.RemoveItemByTag('Quest', -1);
  1090.         horseInventory.RemoveItemByTag('Quest', -1);
  1091.  
  1092.        
  1093.        
  1094.         questItems = theGame.GetDefinitionsManager().GetItemsWithTag('Quest');
  1095.         for(i=0; i<questItems.Size(); i+=1)
  1096.         {
  1097.             inv.RemoveItemByName(questItems[i], -1);
  1098.             horseInventory.RemoveItemByName(questItems[i], -1);
  1099.         }
  1100.        
  1101.        
  1102.         inv.RemoveItemByName('mq1002_artifact_3', -1);
  1103.         horseInventory.RemoveItemByName('mq1002_artifact_3', -1);
  1104.        
  1105.        
  1106.         inv.RemoveItemByTag('NotTransferableToNGP', -1);
  1107.         horseInventory.RemoveItemByTag('NotTransferableToNGP', -1);
  1108.        
  1109.        
  1110.         inv.RemoveItemByTag('NoticeBoardNote', -1);
  1111.         horseInventory.RemoveItemByTag('NoticeBoardNote', -1);
  1112.        
  1113.        
  1114.         RemoveAllNonAutoBuffs();
  1115.        
  1116.        
  1117.         RemoveAlchemyRecipe('Recipe for Trial Potion Kit');
  1118.         RemoveAlchemyRecipe('Recipe for Pops Antidote');
  1119.         RemoveAlchemyRecipe('Recipe for Czart Lure');
  1120.         RemoveAlchemyRecipe('q603_diarrhea_potion_recipe');
  1121.        
  1122.        
  1123.         inv.RemoveItemByTag('Trophy', -1);
  1124.         horseInventory.RemoveItemByTag('Trophy', -1);
  1125.        
  1126.        
  1127.         inv.RemoveItemByCategory('usable', -1);
  1128.         horseInventory.RemoveItemByCategory('usable', -1);
  1129.        
  1130.        
  1131.         RemoveAbility('StaminaTutorialProlog');
  1132.         RemoveAbility('TutorialStaminaRegenHack');
  1133.         RemoveAbility('area_novigrad');
  1134.         RemoveAbility('NoRegenEffect');
  1135.         RemoveAbility('HeavySwimmingStaminaDrain');
  1136.         RemoveAbility('AirBoost');
  1137.         RemoveAbility('area_nml');
  1138.         RemoveAbility('area_skellige');
  1139.        
  1140.        
  1141.         inv.RemoveItemByTag('GwintCard', -1);
  1142.         horseInventory.RemoveItemByTag('GwintCard', -1);
  1143.                
  1144.        
  1145.        
  1146.         inv.RemoveItemByTag('ReadableItem', -1);
  1147.         horseInventory.RemoveItemByTag('ReadableItem', -1);
  1148.        
  1149.        
  1150.         abilityManager.RestoreStats();
  1151.        
  1152.        
  1153.         ((W3PlayerAbilityManager)abilityManager).RemoveToxicityOffset(10000);
  1154.        
  1155.        
  1156.         GetInventory().SingletonItemsRefillAmmo();
  1157.        
  1158.        
  1159.         craftingSchematics.Clear();
  1160.         AddStartingSchematics();
  1161.        
  1162.        
  1163.         for( i=0; i<amountOfSetPiecesEquipped.Size(); i+=1 )
  1164.         {
  1165.             amountOfSetPiecesEquipped[i] = 0;
  1166.         }
  1167.  
  1168.        
  1169.         inv.AddAnItem('Clearing Potion', 1, true, false, false);
  1170.        
  1171.        
  1172.         inv.RemoveItemByName('q203_broken_eyeofloki', -1);
  1173.         horseInventory.RemoveItemByName('q203_broken_eyeofloki', -1);
  1174.        
  1175.        
  1176.         NewGamePlusReplaceViperSet(inv);
  1177.         NewGamePlusReplaceViperSet(horseInventory);
  1178.         NewGamePlusReplaceLynxSet(inv);
  1179.         NewGamePlusReplaceLynxSet(horseInventory);
  1180.         NewGamePlusReplaceGryphonSet(inv);
  1181.         NewGamePlusReplaceGryphonSet(horseInventory);
  1182.         NewGamePlusReplaceBearSet(inv);
  1183.         NewGamePlusReplaceBearSet(horseInventory);
  1184.         NewGamePlusReplaceEP1(inv);
  1185.         NewGamePlusReplaceEP1(horseInventory);
  1186.         NewGamePlusReplaceEP2WitcherSets(inv);
  1187.         NewGamePlusReplaceEP2WitcherSets(horseInventory);
  1188.         NewGamePlusReplaceEP2Items(inv);
  1189.         NewGamePlusReplaceEP2Items(horseInventory);
  1190.         NewGamePlusMarkItemsToNotAdjust(inv);
  1191.         NewGamePlusMarkItemsToNotAdjust(horseInventory);
  1192.        
  1193.         NewGamePlusReplaceNetflixSet(inv);
  1194.         NewGamePlusReplaceNetflixSet(horseInventory);
  1195.        
  1196.         NewGamePlusReplaceDolBlathannaSet(inv);
  1197.         NewGamePlusReplaceDolBlathannaSet(horseInventory);
  1198.        
  1199.         NewGamePlusReplaceWhiteTigerSet(inv);
  1200.         NewGamePlusReplaceWhiteTigerSet(horseInventory);
  1201.        
  1202.        
  1203.         inputHandler.ClearLocksForNGP();
  1204.        
  1205.        
  1206.         buffImmunities.Clear();
  1207.         buffRemovedImmunities.Clear();
  1208.        
  1209.         newGamePlusInitialized = true;
  1210.        
  1211.        
  1212.         m_quenReappliedCount = 1;
  1213.        
  1214.        
  1215.        
  1216.        
  1217.         tiedWalk = false;
  1218.         proudWalk = false;
  1219.         injuredWalk = false;
  1220.         SetBehaviorVariable( 'alternateWalk', 0.0f );
  1221.         SetBehaviorVariable( 'proudWalk', 0.0f );
  1222.         if( GetHorseManager().GetHorseMode() == EHM_Unicorn )
  1223.             GetHorseManager().SetHorseMode( EHM_Normal );
  1224.        
  1225.     }
  1226.        
  1227.     private final function NewGamePlusMarkItemsToNotAdjust(out inv : CInventoryComponent)
  1228.     {
  1229.         var ids     : array<SItemUniqueId>;
  1230.         var i       : int;
  1231.         var n       : name;
  1232.        
  1233.         inv.GetAllItems(ids);
  1234.         for( i=0; i<ids.Size(); i+=1 )
  1235.         {
  1236.             inv.SetItemModifierInt(ids[i], 'NGPItemAdjusted', 1);
  1237.         }
  1238.     }
  1239.    
  1240.     private final function NewGamePlusReplaceItem( item : name, new_item : name, out inv : CInventoryComponent)
  1241.     {
  1242.         var i, j                    : int;
  1243.         var ids, new_ids, enh_ids   : array<SItemUniqueId>;
  1244.         var dye_ids                 : array<SItemUniqueId>;
  1245.         var enh                     : array<name>;
  1246.         var wasEquipped             : bool;
  1247.         var wasEnchanted            : bool;
  1248.         var wasDyed                 : bool;
  1249.         var enchantName, colorName  : name;
  1250.        
  1251.         if ( inv.HasItem( item ) )
  1252.         {
  1253.             ids = inv.GetItemsIds(item);
  1254.             for (i = 0; i < ids.Size(); i += 1)
  1255.             {
  1256.                 inv.GetItemEnhancementItems( ids[i], enh );
  1257.                 wasEnchanted = inv.IsItemEnchanted( ids[i] );
  1258.                 if ( wasEnchanted )
  1259.                     enchantName = inv.GetEnchantment( ids[i] );
  1260.                 wasEquipped = IsItemEquipped( ids[i] );
  1261.                 wasDyed = inv.IsItemColored( ids[i] );
  1262.                 if ( wasDyed )
  1263.                 {
  1264.                     colorName = inv.GetItemColor( ids[i] );
  1265.                 }
  1266.                
  1267.                 inv.RemoveItem( ids[i], 1 );
  1268.                 new_ids = inv.AddAnItem( new_item, 1, true, true, false );
  1269.                 if ( wasEquipped )
  1270.                 {
  1271.                     EquipItem( new_ids[0] );
  1272.                 }
  1273.                 if ( wasEnchanted )
  1274.                 {
  1275.                     inv.EnchantItem( new_ids[0], enchantName, getEnchamtmentStatName(enchantName) );
  1276.                 }
  1277.                 for (j = 0; j < enh.Size(); j += 1)
  1278.                 {
  1279.                     enh_ids = inv.AddAnItem( enh[j], 1, true, true, false );
  1280.                     inv.EnhanceItemScript( new_ids[0], enh_ids[0] );
  1281.                 }
  1282.                 if ( wasDyed )
  1283.                 {
  1284.                     dye_ids = inv.AddAnItem( colorName, 1, true, true, false );
  1285.                     inv.ColorItem( new_ids[0], dye_ids[0] );
  1286.                     inv.RemoveItem( dye_ids[0], 1 );
  1287.                 }
  1288.                
  1289.                 inv.SetItemModifierInt( new_ids[0], 'NGPItemAdjusted', 1 );
  1290.             }
  1291.         }
  1292.     }
  1293.    
  1294.     private final function NewGamePlusAdjustDLCItem(item : name, mod : name, inv : CInventoryComponent)
  1295.     {
  1296.         var ids     : array<SItemUniqueId>;
  1297.         var i       : int;
  1298.        
  1299.         if( inv.HasItem(item) )
  1300.         {
  1301.             ids = inv.GetItemsIds(item);
  1302.             for (i = 0; i < ids.Size(); i += 1)
  1303.             {
  1304.                 if ( inv.GetItemModifierInt(ids[i], 'DoNotAdjustNGPDLC') <= 0 )
  1305.                 {
  1306.                     inv.AddItemBaseAbility(ids[i], mod);
  1307.                     inv.SetItemModifierInt(ids[i], 'DoNotAdjustNGPDLC', 1);
  1308.                 }
  1309.             }
  1310.         }
  1311.        
  1312.     }
  1313.    
  1314.     private final function NewGamePlusAdjustDLC1TemerianSet(inv : CInventoryComponent)
  1315.     {
  1316.         NewGamePlusAdjustDLCItem('NGP DLC1 Temerian Armor', 'NGP DLC Compatibility Chest Armor Mod', inv);
  1317.         NewGamePlusAdjustDLCItem('NGP DLC1 Temerian Gloves', 'NGP DLC Compatibility Armor Mod', inv);
  1318.         NewGamePlusAdjustDLCItem('NGP DLC1 Temerian Pants', 'NGP DLC Compatibility Armor Mod', inv);
  1319.         NewGamePlusAdjustDLCItem('NGP DLC1 Temerian Boots', 'NGP DLC Compatibility Armor Mod', inv);
  1320.     }
  1321.    
  1322.     private final function NewGamePlusAdjustDLC5NilfgardianSet(inv : CInventoryComponent)
  1323.     {
  1324.         NewGamePlusAdjustDLCItem('NGP DLC5 Nilfgaardian Armor', 'NGP DLC Compatibility Chest Armor Mod', inv);
  1325.         NewGamePlusAdjustDLCItem('NGP DLC5 Nilfgaardian Gloves', 'NGP DLC Compatibility Armor Mod', inv);
  1326.         NewGamePlusAdjustDLCItem('NGP DLC5 Nilfgaardian Pants', 'NGP DLC Compatibility Armor Mod', inv);
  1327.         NewGamePlusAdjustDLCItem('NGP DLC5 Nilfgaardian Boots', 'NGP DLC Compatibility Armor Mod', inv);
  1328.     }
  1329.    
  1330.     private final function NewGamePlusAdjustDLC10WolfSet(inv : CInventoryComponent)
  1331.     {
  1332.         NewGamePlusAdjustDLCItem('NGP Wolf Armor',   'NGP DLC Compatibility Chest Armor Mod', inv);
  1333.         NewGamePlusAdjustDLCItem('NGP Wolf Armor 1', 'NGP DLC Compatibility Chest Armor Mod', inv);
  1334.         NewGamePlusAdjustDLCItem('NGP Wolf Armor 2', 'NGP DLC Compatibility Chest Armor Mod', inv);
  1335.         NewGamePlusAdjustDLCItem('NGP Wolf Armor 3', 'NGP DLC Compatibility Chest Armor Mod', inv);
  1336.        
  1337.         NewGamePlusAdjustDLCItem('NGP Wolf Boots 1', 'NGP DLC Compatibility Armor Mod', inv);
  1338.         NewGamePlusAdjustDLCItem('NGP Wolf Boots 2', 'NGP DLC Compatibility Armor Mod', inv);
  1339.         NewGamePlusAdjustDLCItem('NGP Wolf Boots 3', 'NGP DLC Compatibility Armor Mod', inv);
  1340.         NewGamePlusAdjustDLCItem('NGP Wolf Boots 4', 'NGP DLC Compatibility Armor Mod', inv);
  1341.        
  1342.         NewGamePlusAdjustDLCItem('NGP Wolf Gloves 1', 'NGP DLC Compatibility Armor Mod', inv);
  1343.         NewGamePlusAdjustDLCItem('NGP Wolf Gloves 2', 'NGP DLC Compatibility Armor Mod', inv);
  1344.         NewGamePlusAdjustDLCItem('NGP Wolf Gloves 3', 'NGP DLC Compatibility Armor Mod', inv);
  1345.         NewGamePlusAdjustDLCItem('NGP Wolf Gloves 4', 'NGP DLC Compatibility Armor Mod', inv);
  1346.        
  1347.         NewGamePlusAdjustDLCItem('NGP Wolf Pants 1', 'NGP DLC Compatibility Armor Mod', inv);
  1348.         NewGamePlusAdjustDLCItem('NGP Wolf Pants 2', 'NGP DLC Compatibility Armor Mod', inv);
  1349.         NewGamePlusAdjustDLCItem('NGP Wolf Pants 3', 'NGP DLC Compatibility Armor Mod', inv);
  1350.         NewGamePlusAdjustDLCItem('NGP Wolf Pants 4', 'NGP DLC Compatibility Armor Mod', inv);
  1351.        
  1352.         NewGamePlusAdjustDLCItem('NGP Wolf School steel sword',   'NGP Wolf Steel Sword Mod', inv);
  1353.         NewGamePlusAdjustDLCItem('NGP Wolf School steel sword 1', 'NGP Wolf Steel Sword Mod', inv);
  1354.         NewGamePlusAdjustDLCItem('NGP Wolf School steel sword 2', 'NGP Wolf Steel Sword Mod', inv);
  1355.         NewGamePlusAdjustDLCItem('NGP Wolf School steel sword 3', 'NGP Wolf Steel Sword Mod', inv);
  1356.        
  1357.         NewGamePlusAdjustDLCItem('NGP Wolf School silver sword',   'NGP Wolf Silver Sword Mod', inv);
  1358.         NewGamePlusAdjustDLCItem('NGP Wolf School silver sword 1', 'NGP Wolf Silver Sword Mod', inv);
  1359.         NewGamePlusAdjustDLCItem('NGP Wolf School silver sword 2', 'NGP Wolf Silver Sword Mod', inv);
  1360.         NewGamePlusAdjustDLCItem('NGP Wolf School silver sword 3', 'NGP Wolf Silver Sword Mod', inv);
  1361.     }
  1362.    
  1363.     private final function NewGamePlusAdjustDLC14SkelligeSet(inv : CInventoryComponent)
  1364.     {
  1365.         NewGamePlusAdjustDLCItem('NGP DLC14 Skellige Armor', 'NGP DLC Compatibility Chest Armor Mod', inv);
  1366.         NewGamePlusAdjustDLCItem('NGP DLC14 Skellige Gloves', 'NGP DLC Compatibility Armor Mod', inv);
  1367.         NewGamePlusAdjustDLCItem('NGP DLC14 Skellige Pants', 'NGP DLC Compatibility Armor Mod', inv);
  1368.         NewGamePlusAdjustDLCItem('NGP DLC14 Skellige Boots', 'NGP DLC Compatibility Armor Mod', inv);
  1369.     }
  1370.    
  1371.    
  1372.     private final function NewGamePlusAdjustDLC18NetflixSet(inv : CInventoryComponent)
  1373.     {
  1374.         NewGamePlusAdjustDLCItem('NGP Netflix Armor',   'NGP DLC Compatibility Chest Armor Mod', inv);
  1375.         NewGamePlusAdjustDLCItem('NGP Netflix Armor 1', 'NGP DLC Compatibility Chest Armor Mod', inv);
  1376.         NewGamePlusAdjustDLCItem('NGP Netflix Armor 2', 'NGP DLC Compatibility Chest Armor Mod', inv);
  1377.        
  1378.         NewGamePlusAdjustDLCItem('NGP Netflix Boots 1', 'NGP DLC Compatibility Armor Mod', inv);
  1379.         NewGamePlusAdjustDLCItem('NGP Netflix Boots 2', 'NGP DLC Compatibility Armor Mod', inv);
  1380.         NewGamePlusAdjustDLCItem('NGP Netflix Boots', 'NGP DLC Compatibility Armor Mod', inv);
  1381.        
  1382.         NewGamePlusAdjustDLCItem('NGP Netflix Gloves 1', 'NGP DLC Compatibility Armor Mod', inv);
  1383.         NewGamePlusAdjustDLCItem('NGP Netflix Gloves 2', 'NGP DLC Compatibility Armor Mod', inv);
  1384.         NewGamePlusAdjustDLCItem('NGP Netflix Gloves', 'NGP DLC Compatibility Armor Mod', inv);
  1385.        
  1386.         NewGamePlusAdjustDLCItem('NGP Netflix Pants 1', 'NGP DLC Compatibility Armor Mod', inv);
  1387.         NewGamePlusAdjustDLCItem('NGP Netflix Pants 2', 'NGP DLC Compatibility Armor Mod', inv);
  1388.         NewGamePlusAdjustDLCItem('NGP Netflix Pants', 'NGP DLC Compatibility Armor Mod', inv);
  1389.        
  1390.         NewGamePlusAdjustDLCItem('NGP Netflix steel sword',   'NGP Wolf Steel Sword Mod', inv);
  1391.         NewGamePlusAdjustDLCItem('NGP Netflix steel sword 1', 'NGP Wolf Steel Sword Mod', inv);
  1392.         NewGamePlusAdjustDLCItem('NGP Netflix steel sword 2', 'NGP Wolf Steel Sword Mod', inv);
  1393.        
  1394.         NewGamePlusAdjustDLCItem('NGP Netflix silver sword',   'NGP Wolf Silver Sword Mod', inv);
  1395.         NewGamePlusAdjustDLCItem('NGP Netflix silver sword 1', 'NGP Wolf Silver Sword Mod', inv);
  1396.         NewGamePlusAdjustDLCItem('NGP Netflix silver sword 2', 'NGP Wolf Silver Sword Mod', inv);
  1397.     }
  1398.    
  1399.    
  1400.    
  1401.     private final function NewGamePlusAdjustDolBlathannaSet(inv : CInventoryComponent)
  1402.     {
  1403.         NewGamePlusAdjustDLCItem('NGP Dol Blathanna Armor',   'NGP DLC Compatibility Chest Armor Mod', inv);
  1404.         NewGamePlusAdjustDLCItem('NGP Dol Blathanna Boots', 'NGP DLC Compatibility Armor Mod', inv);
  1405.         NewGamePlusAdjustDLCItem('NGP Dol Blathanna Gloves', 'NGP DLC Compatibility Armor Mod', inv);      
  1406.         NewGamePlusAdjustDLCItem('NGP Dol Blathanna Pants', 'NGP DLC Compatibility Armor Mod', inv);       
  1407.         NewGamePlusAdjustDLCItem('NGP Dol Blathanna longsword',   'NGP Wolf Steel Sword Mod', inv);    
  1408.         NewGamePlusAdjustDLCItem('NGP White Widow of Dol Blathanna',   'NGP Wolf Silver Sword Mod', inv);
  1409.     }
  1410.    
  1411.    
  1412.    
  1413.     private final function NewGamePlusAdjustWhiteTigerSet(inv : CInventoryComponent)
  1414.     {
  1415.         NewGamePlusAdjustDLCItem('NGP White Tiger Armor',   'NGP DLC Compatibility Chest Armor Mod', inv);
  1416.         NewGamePlusAdjustDLCItem('NGP White Tiger Boots', 'NGP DLC Compatibility Armor Mod', inv);
  1417.         NewGamePlusAdjustDLCItem('NGP White Tiger Gloves', 'NGP DLC Compatibility Armor Mod', inv);    
  1418.         NewGamePlusAdjustDLCItem('NGP White Tiger Pants', 'NGP DLC Compatibility Armor Mod', inv);     
  1419.         NewGamePlusAdjustDLCItem('NGP Steel Vixen',   'NGP Wolf Steel Sword Mod', inv);    
  1420.         NewGamePlusAdjustDLCItem('NGP Silver Vixen',   'NGP Wolf Silver Sword Mod', inv);
  1421.     }
  1422.    
  1423.    
  1424.     private final function NewGamePlusReplaceViperSet(out inv : CInventoryComponent)
  1425.     {
  1426.         NewGamePlusReplaceItem('Viper School steel sword', 'NGP Viper School steel sword', inv);
  1427.        
  1428.         NewGamePlusReplaceItem('Viper School silver sword', 'NGP Viper School silver sword', inv);
  1429.     }
  1430.    
  1431.     private final function NewGamePlusReplaceLynxSet(out inv : CInventoryComponent)
  1432.     {
  1433.         NewGamePlusReplaceItem('Lynx Armor', 'NGP Lynx Armor', inv);
  1434.         NewGamePlusReplaceItem('Lynx Armor 1', 'NGP Lynx Armor 1', inv);
  1435.         NewGamePlusReplaceItem('Lynx Armor 2', 'NGP Lynx Armor 2', inv);
  1436.         NewGamePlusReplaceItem('Lynx Armor 3', 'NGP Lynx Armor 3', inv);
  1437.        
  1438.         NewGamePlusReplaceItem('Lynx Gloves 1', 'NGP Lynx Gloves 1', inv);
  1439.         NewGamePlusReplaceItem('Lynx Gloves 2', 'NGP Lynx Gloves 2', inv);
  1440.         NewGamePlusReplaceItem('Lynx Gloves 3', 'NGP Lynx Gloves 3', inv);
  1441.         NewGamePlusReplaceItem('Lynx Gloves 4', 'NGP Lynx Gloves 4', inv);
  1442.        
  1443.         NewGamePlusReplaceItem('Lynx Pants 1', 'NGP Lynx Pants 1', inv);
  1444.         NewGamePlusReplaceItem('Lynx Pants 2', 'NGP Lynx Pants 2', inv);
  1445.         NewGamePlusReplaceItem('Lynx Pants 3', 'NGP Lynx Pants 3', inv);
  1446.         NewGamePlusReplaceItem('Lynx Pants 4', 'NGP Lynx Pants 4', inv);
  1447.        
  1448.         NewGamePlusReplaceItem('Lynx Boots 1', 'NGP Lynx Boots 1', inv);
  1449.         NewGamePlusReplaceItem('Lynx Boots 2', 'NGP Lynx Boots 2', inv);
  1450.         NewGamePlusReplaceItem('Lynx Boots 3', 'NGP Lynx Boots 3', inv);
  1451.         NewGamePlusReplaceItem('Lynx Boots 4', 'NGP Lynx Boots 4', inv);
  1452.        
  1453.         NewGamePlusReplaceItem('Lynx School steel sword', 'NGP Lynx School steel sword', inv);
  1454.         NewGamePlusReplaceItem('Lynx School steel sword 1', 'NGP Lynx School steel sword 1', inv);
  1455.         NewGamePlusReplaceItem('Lynx School steel sword 2', 'NGP Lynx School steel sword 2', inv);
  1456.         NewGamePlusReplaceItem('Lynx School steel sword 3', 'NGP Lynx School steel sword 3', inv);
  1457.        
  1458.         NewGamePlusReplaceItem('Lynx School silver sword', 'NGP Lynx School silver sword', inv);
  1459.         NewGamePlusReplaceItem('Lynx School silver sword 1', 'NGP Lynx School silver sword 1', inv);
  1460.         NewGamePlusReplaceItem('Lynx School silver sword 2', 'NGP Lynx School silver sword 2', inv);
  1461.         NewGamePlusReplaceItem('Lynx School silver sword 3', 'NGP Lynx School silver sword 3', inv);
  1462.     }
  1463.    
  1464.     private final function NewGamePlusReplaceGryphonSet(out inv : CInventoryComponent)
  1465.     {
  1466.         NewGamePlusReplaceItem('Gryphon Armor', 'NGP Gryphon Armor', inv);
  1467.         NewGamePlusReplaceItem('Gryphon Armor 1', 'NGP Gryphon Armor 1', inv);
  1468.         NewGamePlusReplaceItem('Gryphon Armor 2', 'NGP Gryphon Armor 2', inv);
  1469.         NewGamePlusReplaceItem('Gryphon Armor 3', 'NGP Gryphon Armor 3', inv);
  1470.        
  1471.         NewGamePlusReplaceItem('Gryphon Gloves 1', 'NGP Gryphon Gloves 1', inv);
  1472.         NewGamePlusReplaceItem('Gryphon Gloves 2', 'NGP Gryphon Gloves 2', inv);
  1473.         NewGamePlusReplaceItem('Gryphon Gloves 3', 'NGP Gryphon Gloves 3', inv);
  1474.         NewGamePlusReplaceItem('Gryphon Gloves 4', 'NGP Gryphon Gloves 4', inv);
  1475.        
  1476.         NewGamePlusReplaceItem('Gryphon Pants 1', 'NGP Gryphon Pants 1', inv);
  1477.         NewGamePlusReplaceItem('Gryphon Pants 2', 'NGP Gryphon Pants 2', inv);
  1478.         NewGamePlusReplaceItem('Gryphon Pants 3', 'NGP Gryphon Pants 3', inv);
  1479.         NewGamePlusReplaceItem('Gryphon Pants 4', 'NGP Gryphon Pants 4', inv);
  1480.        
  1481.         NewGamePlusReplaceItem('Gryphon Boots 1', 'NGP Gryphon Boots 1', inv);
  1482.         NewGamePlusReplaceItem('Gryphon Boots 2', 'NGP Gryphon Boots 2', inv);
  1483.         NewGamePlusReplaceItem('Gryphon Boots 3', 'NGP Gryphon Boots 3', inv);
  1484.         NewGamePlusReplaceItem('Gryphon Boots 4', 'NGP Gryphon Boots 4', inv);
  1485.        
  1486.         NewGamePlusReplaceItem('Gryphon School steel sword', 'NGP Gryphon School steel sword', inv);
  1487.         NewGamePlusReplaceItem('Gryphon School steel sword 1', 'NGP Gryphon School steel sword 1', inv);
  1488.         NewGamePlusReplaceItem('Gryphon School steel sword 2', 'NGP Gryphon School steel sword 2', inv);
  1489.         NewGamePlusReplaceItem('Gryphon School steel sword 3', 'NGP Gryphon School steel sword 3', inv);
  1490.        
  1491.         NewGamePlusReplaceItem('Gryphon School silver sword', 'NGP Gryphon School silver sword', inv);
  1492.         NewGamePlusReplaceItem('Gryphon School silver sword 1', 'NGP Gryphon School silver sword 1', inv);
  1493.         NewGamePlusReplaceItem('Gryphon School silver sword 2', 'NGP Gryphon School silver sword 2', inv);
  1494.         NewGamePlusReplaceItem('Gryphon School silver sword 3', 'NGP Gryphon School silver sword 3', inv);
  1495.     }
  1496.    
  1497.     private final function NewGamePlusReplaceBearSet(out inv : CInventoryComponent)
  1498.     {
  1499.         NewGamePlusReplaceItem('Bear Armor', 'NGP Bear Armor', inv);
  1500.         NewGamePlusReplaceItem('Bear Armor 1', 'NGP Bear Armor 1', inv);
  1501.         NewGamePlusReplaceItem('Bear Armor 2', 'NGP Bear Armor 2', inv);
  1502.         NewGamePlusReplaceItem('Bear Armor 3', 'NGP Bear Armor 3', inv);
  1503.        
  1504.         NewGamePlusReplaceItem('Bear Gloves 1', 'NGP Bear Gloves 1', inv);
  1505.         NewGamePlusReplaceItem('Bear Gloves 2', 'NGP Bear Gloves 2', inv);
  1506.         NewGamePlusReplaceItem('Bear Gloves 3', 'NGP Bear Gloves 3', inv);
  1507.         NewGamePlusReplaceItem('Bear Gloves 4', 'NGP Bear Gloves 4', inv);
  1508.        
  1509.         NewGamePlusReplaceItem('Bear Pants 1', 'NGP Bear Pants 1', inv);
  1510.         NewGamePlusReplaceItem('Bear Pants 2', 'NGP Bear Pants 2', inv);
  1511.         NewGamePlusReplaceItem('Bear Pants 3', 'NGP Bear Pants 3', inv);
  1512.         NewGamePlusReplaceItem('Bear Pants 4', 'NGP Bear Pants 4', inv);
  1513.        
  1514.         NewGamePlusReplaceItem('Bear Boots 1', 'NGP Bear Boots 1', inv);
  1515.         NewGamePlusReplaceItem('Bear Boots 2', 'NGP Bear Boots 2', inv);
  1516.         NewGamePlusReplaceItem('Bear Boots 3', 'NGP Bear Boots 3', inv);
  1517.         NewGamePlusReplaceItem('Bear Boots 4', 'NGP Bear Boots 4', inv);
  1518.        
  1519.         NewGamePlusReplaceItem('Bear School steel sword', 'NGP Bear School steel sword', inv);
  1520.         NewGamePlusReplaceItem('Bear School steel sword 1', 'NGP Bear School steel sword 1', inv);
  1521.         NewGamePlusReplaceItem('Bear School steel sword 2', 'NGP Bear School steel sword 2', inv);
  1522.         NewGamePlusReplaceItem('Bear School steel sword 3', 'NGP Bear School steel sword 3', inv);
  1523.        
  1524.         NewGamePlusReplaceItem('Bear School silver sword', 'NGP Bear School silver sword', inv);
  1525.         NewGamePlusReplaceItem('Bear School silver sword 1', 'NGP Bear School silver sword 1', inv);
  1526.         NewGamePlusReplaceItem('Bear School silver sword 2', 'NGP Bear School silver sword 2', inv);
  1527.         NewGamePlusReplaceItem('Bear School silver sword 3', 'NGP Bear School silver sword 3', inv);
  1528.     }
  1529.        
  1530.     private final function NewGamePlusReplaceEP1(out inv : CInventoryComponent)
  1531.     {  
  1532.         NewGamePlusReplaceItem('Ofir Armor', 'NGP Ofir Armor', inv);
  1533.         NewGamePlusReplaceItem('Ofir Sabre 2', 'NGP Ofir Sabre 2', inv);
  1534.        
  1535.         NewGamePlusReplaceItem('Crafted Burning Rose Armor', 'NGP Crafted Burning Rose Armor', inv);
  1536.         NewGamePlusReplaceItem('Crafted Burning Rose Gloves', 'NGP Crafted Burning Rose Gloves', inv);
  1537.         NewGamePlusReplaceItem('Crafted Burning Rose Sword', 'NGP Crafted Burning Rose Sword', inv);
  1538.        
  1539.         NewGamePlusReplaceItem('Crafted Ofir Armor', 'NGP Crafted Ofir Armor', inv);
  1540.         NewGamePlusReplaceItem('Crafted Ofir Boots', 'NGP Crafted Ofir Boots', inv);
  1541.         NewGamePlusReplaceItem('Crafted Ofir Gloves', 'NGP Crafted Ofir Gloves', inv);
  1542.         NewGamePlusReplaceItem('Crafted Ofir Pants', 'NGP Crafted Ofir Pants', inv);
  1543.         NewGamePlusReplaceItem('Crafted Ofir Steel Sword', 'NGP Crafted Ofir Steel Sword', inv);
  1544.        
  1545.         NewGamePlusReplaceItem('EP1 Crafted Witcher Silver Sword', 'NGP EP1 Crafted Witcher Silver Sword', inv);
  1546.         NewGamePlusReplaceItem('Olgierd Sabre', 'NGP Olgierd Sabre', inv);
  1547.        
  1548.         NewGamePlusReplaceItem('EP1 Witcher Armor', 'NGP EP1 Witcher Armor', inv);
  1549.         NewGamePlusReplaceItem('EP1 Witcher Boots', 'NGP EP1 Witcher Boots', inv);
  1550.         NewGamePlusReplaceItem('EP1 Witcher Gloves', 'NGP EP1 Witcher Gloves', inv);
  1551.         NewGamePlusReplaceItem('EP1 Witcher Pants', 'NGP EP1 Witcher Pants', inv);
  1552.         NewGamePlusReplaceItem('EP1 Viper School steel sword', 'NGP EP1 Viper School steel sword', inv);
  1553.         NewGamePlusReplaceItem('EP1 Viper School silver sword', 'NGP EP1 Viper School silver sword', inv);
  1554.     }
  1555.    
  1556.     private final function NewGamePlusReplaceEP2WitcherSets(out inv : CInventoryComponent)
  1557.     {
  1558.         NewGamePlusReplaceItem('Lynx Armor 4', 'NGP Lynx Armor 4', inv);
  1559.         NewGamePlusReplaceItem('Gryphon Armor 4', 'NGP Gryphon Armor 4', inv);
  1560.         NewGamePlusReplaceItem('Bear Armor 4', 'NGP Bear Armor 4', inv);
  1561.         NewGamePlusReplaceItem('Wolf Armor 4', 'NGP Wolf Armor 4', inv);
  1562.         NewGamePlusReplaceItem('Red Wolf Armor 1', 'NGP Red Wolf Armor 1', inv);
  1563.        
  1564.         NewGamePlusReplaceItem('Lynx Gloves 5', 'NGP Lynx Gloves 5', inv);
  1565.         NewGamePlusReplaceItem('Gryphon Gloves 5', 'NGP Gryphon Gloves 5', inv);
  1566.         NewGamePlusReplaceItem('Bear Gloves 5', 'NGP Bear Gloves 5', inv);
  1567.         NewGamePlusReplaceItem('Wolf Gloves 5', 'NGP Wolf Gloves 5', inv);
  1568.         NewGamePlusReplaceItem('Red Wolf Gloves 1', 'NGP Red Wolf Gloves 1', inv);
  1569.        
  1570.         NewGamePlusReplaceItem('Lynx Pants 5', 'NGP Lynx Pants 5', inv);
  1571.         NewGamePlusReplaceItem('Gryphon Pants 5', 'NGP Gryphon Pants 5', inv);
  1572.         NewGamePlusReplaceItem('Bear Pants 5', 'NGP Bear Pants 5', inv);
  1573.         NewGamePlusReplaceItem('Wolf Pants 5', 'NGP Wolf Pants 5', inv);
  1574.         NewGamePlusReplaceItem('Red Wolf Pants 1', 'NGP Red Wolf Pants 1', inv);
  1575.        
  1576.         NewGamePlusReplaceItem('Lynx Boots 5', 'NGP Lynx Boots 5', inv);
  1577.         NewGamePlusReplaceItem('Gryphon Boots 5', 'NGP Gryphon Boots 5', inv);
  1578.         NewGamePlusReplaceItem('Bear Boots 5', 'NGP Bear Boots 5', inv);
  1579.         NewGamePlusReplaceItem('Wolf Boots 5', 'NGP Wolf Boots 5', inv);
  1580.         NewGamePlusReplaceItem('Red Wolf Boots 1', 'NGP Red Wolf Boots 1', inv);
  1581.        
  1582.        
  1583.         NewGamePlusReplaceItem('Lynx School steel sword 4', 'NGP Lynx School steel sword 4', inv);
  1584.         NewGamePlusReplaceItem('Gryphon School steel sword 4', 'NGP Gryphon School steel sword 4', inv);
  1585.         NewGamePlusReplaceItem('Bear School steel sword 4', 'NGP Bear School steel sword 4', inv);
  1586.         NewGamePlusReplaceItem('Wolf School steel sword 4', 'NGP Wolf School steel sword 4', inv);
  1587.         NewGamePlusReplaceItem('Red Wolf School steel sword 1', 'NGP Red Wolf School steel sword 1', inv);
  1588.        
  1589.         NewGamePlusReplaceItem('Lynx School silver sword 4', 'NGP Lynx School silver sword 4', inv);
  1590.         NewGamePlusReplaceItem('Gryphon School silver sword 4', 'NGP Gryphon School silver sword 4', inv);
  1591.         NewGamePlusReplaceItem('Bear School silver sword 4', 'NGP Bear School silver sword 4', inv);
  1592.         NewGamePlusReplaceItem('Wolf School silver sword 4', 'NGP Wolf School silver sword 4', inv);
  1593.         NewGamePlusReplaceItem('Red Wolf School silver sword 1', 'NGP Red Wolf School silver sword 1', inv);
  1594.     }
  1595.    
  1596.     private final function NewGamePlusReplaceEP2Items(out inv : CInventoryComponent)
  1597.     {
  1598.         NewGamePlusReplaceItem('Guard Lvl1 Armor 3', 'NGP Guard Lvl1 Armor 3', inv);
  1599.         NewGamePlusReplaceItem('Guard Lvl1 A Armor 3', 'NGP Guard Lvl1 A Armor 3', inv);
  1600.         NewGamePlusReplaceItem('Guard Lvl2 Armor 3', 'NGP Guard Lvl2 Armor 3', inv);
  1601.         NewGamePlusReplaceItem('Guard Lvl2 A Armor 3', 'NGP Guard Lvl2 A Armor 3', inv);
  1602.         NewGamePlusReplaceItem('Knight Geralt Armor 3', 'NGP Knight Geralt Armor 3', inv);
  1603.         NewGamePlusReplaceItem('Knight Geralt A Armor 3', 'NGP Knight Geralt A Armor 3', inv);
  1604.         NewGamePlusReplaceItem('q702_vampire_armor', 'NGP q702_vampire_armor', inv);
  1605.        
  1606.         NewGamePlusReplaceItem('Guard Lvl1 Gloves 3', 'NGP Guard Lvl1 Gloves 3', inv);
  1607.         NewGamePlusReplaceItem('Guard Lvl1 A Gloves 3', 'NGP Guard Lvl1 A Gloves 3', inv);
  1608.         NewGamePlusReplaceItem('Guard Lvl2 Gloves 3', 'NGP Guard Lvl2 Gloves 3', inv);
  1609.         NewGamePlusReplaceItem('Guard Lvl2 A Gloves 3', 'NGP Guard Lvl2 A Gloves 3', inv);
  1610.         NewGamePlusReplaceItem('Knight Geralt Gloves 3', 'NGP Knight Geralt Gloves 3', inv);
  1611.         NewGamePlusReplaceItem('Knight Geralt A Gloves 3', 'NGP Knight Geralt A Gloves 3', inv);
  1612.         NewGamePlusReplaceItem('q702_vampire_gloves', 'NGP q702_vampire_gloves', inv);
  1613.        
  1614.         NewGamePlusReplaceItem('Guard Lvl1 Pants 3', 'NGP Guard Lvl1 Pants 3', inv);
  1615.         NewGamePlusReplaceItem('Guard Lvl1 A Pants 3', 'NGP Guard Lvl1 A Pants 3', inv);
  1616.         NewGamePlusReplaceItem('Guard Lvl2 Pants 3', 'NGP Guard Lvl2 Pants 3', inv);
  1617.         NewGamePlusReplaceItem('Guard Lvl2 A Pants 3', 'NGP Guard Lvl2 A Pants 3', inv);
  1618.         NewGamePlusReplaceItem('Knight Geralt Pants 3', 'NGP Knight Geralt Pants 3', inv);
  1619.         NewGamePlusReplaceItem('Knight Geralt A Pants 3', 'NGP Knight Geralt A Pants 3', inv);
  1620.         NewGamePlusReplaceItem('q702_vampire_pants', 'NGP q702_vampire_pants', inv);
  1621.        
  1622.         NewGamePlusReplaceItem('Guard Lvl1 Boots 3', 'NGP Guard Lvl1 Boots 3', inv);
  1623.         NewGamePlusReplaceItem('Guard Lvl1 A Boots 3', 'NGP Guard Lvl1 A Boots 3', inv);
  1624.         NewGamePlusReplaceItem('Guard Lvl2 Boots 3', 'NGP Guard Lvl2 Boots 3', inv);
  1625.         NewGamePlusReplaceItem('Guard Lvl2 A Boots 3', 'NGP Guard Lvl2 A Boots 3', inv);
  1626.         NewGamePlusReplaceItem('Knight Geralt Boots 3', 'NGP Knight Geralt Boots 3', inv);
  1627.         NewGamePlusReplaceItem('Knight Geralt A Boots 3', 'NGP Knight Geralt A Boots 3', inv);
  1628.         NewGamePlusReplaceItem('q702_vampire_boots', 'NGP q702_vampire_boots', inv);
  1629.        
  1630.         NewGamePlusReplaceItem('Serpent Steel Sword 1', 'NGP Serpent Steel Sword 1', inv);
  1631.         NewGamePlusReplaceItem('Serpent Steel Sword 2', 'NGP Serpent Steel Sword 2', inv);
  1632.         NewGamePlusReplaceItem('Serpent Steel Sword 3', 'NGP Serpent Steel Sword 3', inv);
  1633.         NewGamePlusReplaceItem('Guard lvl1 steel sword 3', 'NGP Guard lvl1 steel sword 3', inv);
  1634.         NewGamePlusReplaceItem('Guard lvl2 steel sword 3', 'NGP Guard lvl2 steel sword 3', inv);
  1635.         NewGamePlusReplaceItem('Knights steel sword 3', 'NGP Knights steel sword 3', inv);
  1636.         NewGamePlusReplaceItem('Hanza steel sword 3', 'NGP Hanza steel sword 3', inv);
  1637.         NewGamePlusReplaceItem('Toussaint steel sword 3', 'NGP Toussaint steel sword 3', inv);
  1638.         NewGamePlusReplaceItem('q702 vampire steel sword', 'NGP q702 vampire steel sword', inv);
  1639.        
  1640.         NewGamePlusReplaceItem('Serpent Silver Sword 1', 'NGP Serpent Silver Sword 1', inv);
  1641.         NewGamePlusReplaceItem('Serpent Silver Sword 2', 'NGP Serpent Silver Sword 2', inv);
  1642.         NewGamePlusReplaceItem('Serpent Silver Sword 3', 'NGP Serpent Silver Sword 3', inv);
  1643.     }
  1644.    
  1645.    
  1646.    
  1647.     private final function NewGamePlusReplaceNetflixSet(out inv : CInventoryComponent)
  1648.     {
  1649.         NewGamePlusReplaceItem('Netflix Armor', 'NGP Netflix Armor', inv);
  1650.         NewGamePlusReplaceItem('Netflix Armor 1', 'NGP Netflix Armor 1', inv);
  1651.         NewGamePlusReplaceItem('Netflix Armor 2', 'NGP Netflix Armor 2', inv);
  1652.        
  1653.         NewGamePlusReplaceItem('Netflix Gloves 1', 'NGP Netflix Gloves 1', inv);
  1654.         NewGamePlusReplaceItem('Netflix Gloves 2', 'NGP Netflix Gloves 2', inv);
  1655.         NewGamePlusReplaceItem('Netflix Gloves', 'NGP Netflix Gloves', inv);
  1656.        
  1657.         NewGamePlusReplaceItem('Netflix Pants 1', 'NGP Netflix Pants 1', inv);
  1658.         NewGamePlusReplaceItem('Netflix Pants 2', 'NGP Netflix Pants 2', inv);
  1659.         NewGamePlusReplaceItem('Netflix Pants', 'NGP Netflix Pants', inv);
  1660.        
  1661.         NewGamePlusReplaceItem('Netflix Boots 1', 'NGP Netflix Boots 1', inv);
  1662.         NewGamePlusReplaceItem('Netflix Boots 2', 'NGP Netflix Boots 2', inv);
  1663.         NewGamePlusReplaceItem('Netflix Boots', 'NGP Netflix Boots', inv);
  1664.        
  1665.         NewGamePlusReplaceItem('Netflix steel sword', 'NGP Netflix steel sword', inv);
  1666.         NewGamePlusReplaceItem('Netflix steel sword 1', 'NGP Netflix steel sword 1', inv);
  1667.         NewGamePlusReplaceItem('Netflix steel sword 2', 'NGP Netflix steel sword 2', inv);
  1668.        
  1669.         NewGamePlusReplaceItem('Netflix silver sword', 'NGP Netflix silver sword', inv);
  1670.         NewGamePlusReplaceItem('Netflix silver sword 1', 'NGP Netflix silver sword 1', inv);
  1671.         NewGamePlusReplaceItem('Netflix silver sword 2', 'NGP Netflix silver sword 2', inv);
  1672.     }
  1673.    
  1674.    
  1675.    
  1676.     private final function NewGamePlusReplaceDolBlathannaSet(out inv : CInventoryComponent)
  1677.     {
  1678.         NewGamePlusReplaceItem('Dol Blathanna Armor', 'NGP Dol Blathanna Armor', inv);     
  1679.         NewGamePlusReplaceItem('Dol Blathanna Gloves', 'NGP Dol Blathanna Gloves', inv);   
  1680.         NewGamePlusReplaceItem('Dol Blathanna Pants', 'NGP Dol Blathanna Pants', inv);     
  1681.         NewGamePlusReplaceItem('Dol Blathanna Boots', 'NGP Dol Blathanna Boots', inv);     
  1682.         NewGamePlusReplaceItem('Dol Blathanna longsword', 'NGP Dol Blathanna longsword', inv);     
  1683.         NewGamePlusReplaceItem('White Widow of Dol Blathanna', 'NGP White Widow of Dol Blathanna', inv);
  1684.     }
  1685.    
  1686.    
  1687.    
  1688.     private final function NewGamePlusReplaceWhiteTigerSet(out inv : CInventoryComponent)
  1689.     {
  1690.         NewGamePlusReplaceItem('White Tiger Armor', 'NGP White Tiger Armor', inv);     
  1691.         NewGamePlusReplaceItem('White Tiger Gloves', 'NGP White Tiger Gloves', inv);   
  1692.         NewGamePlusReplaceItem('White Tiger Pants', 'NGP White Tiger Pants', inv);     
  1693.         NewGamePlusReplaceItem('White Tiger Boots', 'NGP White Tiger Boots', inv);     
  1694.         NewGamePlusReplaceItem('Steel Vixen', 'NGP Steel Vixen', inv);     
  1695.         NewGamePlusReplaceItem('Silver Vixen', 'NGP Silver Vixen', inv);
  1696.     }
  1697.    
  1698.    
  1699.     public function GetEquippedSword(steel : bool) : SItemUniqueId
  1700.     {
  1701.         var item : SItemUniqueId;
  1702.        
  1703.         if(steel)
  1704.             GetItemEquippedOnSlot(EES_SteelSword, item);
  1705.         else
  1706.             GetItemEquippedOnSlot(EES_SilverSword, item);
  1707.            
  1708.         return item;
  1709.     }
  1710.    
  1711.     timer function BroadcastRain( deltaTime : float, id : int )
  1712.     {
  1713.         var rainStrength : float = 0;
  1714.         rainStrength = GetRainStrength();
  1715.         if( rainStrength > 0.5 )
  1716.         {
  1717.             theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( thePlayer, 'RainAction', 2.0f , 50.0f, -1.f, -1, true);
  1718.             LogReactionSystem( "'RainAction' was sent by Player - single broadcast - distance: 50.0" );
  1719.         }
  1720.     }
  1721.    
  1722.     function InitializeParryType()
  1723.     {
  1724.         var i, j : int;
  1725.        
  1726.         parryTypeTable.Resize( EnumGetMax('EAttackSwingType')+1 );
  1727.         for( i = 0; i < EnumGetMax('EAttackSwingType')+1; i += 1 )
  1728.         {
  1729.             parryTypeTable[i].Resize( EnumGetMax('EAttackSwingDirection')+1 );
  1730.         }
  1731.         parryTypeTable[AST_Horizontal][ASD_UpDown] = PT_None;
  1732.         parryTypeTable[AST_Horizontal][ASD_DownUp] = PT_None;
  1733.         parryTypeTable[AST_Horizontal][ASD_LeftRight] = PT_Left;
  1734.         parryTypeTable[AST_Horizontal][ASD_RightLeft] = PT_Right;
  1735.         parryTypeTable[AST_Vertical][ASD_UpDown] = PT_Up;
  1736.         parryTypeTable[AST_Vertical][ASD_DownUp] = PT_Down;
  1737.         parryTypeTable[AST_Vertical][ASD_LeftRight] = PT_None;
  1738.         parryTypeTable[AST_Vertical][ASD_RightLeft] = PT_None;
  1739.         parryTypeTable[AST_DiagonalUp][ASD_UpDown] = PT_None;
  1740.         parryTypeTable[AST_DiagonalUp][ASD_DownUp] = PT_None;
  1741.         parryTypeTable[AST_DiagonalUp][ASD_LeftRight] = PT_UpLeft;
  1742.         parryTypeTable[AST_DiagonalUp][ASD_RightLeft] = PT_RightUp;
  1743.         parryTypeTable[AST_DiagonalDown][ASD_UpDown] = PT_None;
  1744.         parryTypeTable[AST_DiagonalDown][ASD_DownUp] = PT_None;
  1745.         parryTypeTable[AST_DiagonalDown][ASD_LeftRight] = PT_LeftDown;
  1746.         parryTypeTable[AST_DiagonalDown][ASD_RightLeft] = PT_DownRight;
  1747.         parryTypeTable[AST_Jab][ASD_UpDown] = PT_Jab;
  1748.         parryTypeTable[AST_Jab][ASD_DownUp] = PT_Jab;
  1749.         parryTypeTable[AST_Jab][ASD_LeftRight] = PT_Jab;
  1750.         parryTypeTable[AST_Jab][ASD_RightLeft] = PT_Jab;   
  1751.     }
  1752.    
  1753.    
  1754.    
  1755.    
  1756.    
  1757.    
  1758.     event OnDeath( damageAction : W3DamageAction )
  1759.     {
  1760.         var items       : array< SItemUniqueId >;
  1761.         var i, size     : int; 
  1762.         var slot        : EEquipmentSlots;
  1763.         var holdSlot    : name;
  1764.    
  1765.         super.OnDeath( damageAction );
  1766.    
  1767.         items = GetHeldItems();
  1768.                
  1769.         if( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait')
  1770.         {
  1771.             OnRangedForceHolster( true, true, true );      
  1772.             rangedWeapon.ClearDeployedEntity(true);
  1773.         }
  1774.        
  1775.         size = items.Size();
  1776.        
  1777.         if ( size > 0 )
  1778.         {
  1779.             for ( i = 0; i < size; i += 1 )
  1780.             {
  1781.                 if ( this.inv.IsIdValid( items[i] ) && !( this.inv.IsItemCrossbow( items[i] ) ) )
  1782.                 {
  1783.                     holdSlot = this.inv.GetItemHoldSlot( items[i] );               
  1784.                
  1785.                     if (  holdSlot == 'l_weapon' && this.IsHoldingItemInLHand() )
  1786.                     {
  1787.                         this.OnUseSelectedItem( true );
  1788.                     }          
  1789.            
  1790.                     DropItemFromSlot( holdSlot, false );
  1791.                    
  1792.                     if ( holdSlot == 'r_weapon' )
  1793.                     {
  1794.                         slot = this.GetItemSlot( items[i] );
  1795.                         if ( UnequipItemFromSlot( slot ) )
  1796.                             Log( "Unequip" );
  1797.                     }
  1798.                 }
  1799.             }
  1800.         }
  1801.     }
  1802.    
  1803.    
  1804.    
  1805.    
  1806.    
  1807.    
  1808.    
  1809.     function HandleMovement( deltaTime : float )
  1810.     {
  1811.         super.HandleMovement( deltaTime );
  1812.        
  1813.         rawCameraHeading = theCamera.GetCameraHeading();
  1814.     }
  1815.        
  1816.    
  1817.    
  1818.    
  1819.    
  1820.    
  1821.    
  1822.     function ToggleSpecialAttackHeavyAllowed( toggle : bool)
  1823.     {
  1824.         specialAttackHeavyAllowed = toggle;
  1825.     }
  1826.    
  1827.     function GetReputationManager() : W3Reputation
  1828.     {
  1829.         return reputationManager;
  1830.     }
  1831.            
  1832.     function OnRadialMenuItemChoose( selectedItem : string )
  1833.     {
  1834.         var iSlotId : int;
  1835.         var item : SItemUniqueId;
  1836.        
  1837.         if ( selectedItem != "Crossbow" )
  1838.         {
  1839.             if ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  1840.                 OnRangedForceHolster( true, false );
  1841.         }
  1842.        
  1843.        
  1844.         switch(selectedItem)
  1845.         {
  1846.            
  1847.             case "Meditation":
  1848.                 theGame.RequestMenuWithBackground( 'MeditationClockMenu', 'CommonMenu' );
  1849.                 break;         
  1850.             case "Slot1":
  1851.                 GetItemEquippedOnSlot( EES_Petard1, item );
  1852.                 if( thePlayer.inv.IsIdValid( item ) )
  1853.                 {
  1854.                     SelectQuickslotItem( EES_Petard1 );
  1855.                 }
  1856.                 else
  1857.                 {
  1858.                     SelectQuickslotItem( EES_Petard2 );
  1859.                 }
  1860.                 break;
  1861.                
  1862.             case "Slot2":
  1863.                 GetItemEquippedOnSlot( EES_Petard2, item );
  1864.                 if( thePlayer.inv.IsIdValid( item ) )
  1865.                 {
  1866.                     SelectQuickslotItem( EES_Petard2 );
  1867.                 }
  1868.                 else
  1869.                 {
  1870.                     SelectQuickslotItem( EES_Petard1 );
  1871.                 }
  1872.                 break;
  1873.                
  1874.             case "Crossbow":
  1875.                 SelectQuickslotItem(EES_RangedWeapon);
  1876.                 break;
  1877.                
  1878.             case "Slot3":
  1879.                 GetItemEquippedOnSlot( EES_Quickslot1, item );
  1880.                 if( thePlayer.inv.IsIdValid( item ) )
  1881.                 {
  1882.                     SelectQuickslotItem( EES_Quickslot1 );
  1883.                 }
  1884.                 else
  1885.                 {
  1886.                     SelectQuickslotItem( EES_Quickslot2 );
  1887.                 }
  1888.                 break;
  1889.                
  1890.             case "Slot4":
  1891.                 GetItemEquippedOnSlot( EES_Quickslot2, item );
  1892.                 if( thePlayer.inv.IsIdValid( item ) )
  1893.                 {
  1894.                     SelectQuickslotItem( EES_Quickslot2 );
  1895.                 }
  1896.                 else
  1897.                 {
  1898.                     SelectQuickslotItem( EES_Quickslot1 );
  1899.                 }
  1900.                 break;
  1901.                
  1902.             default:
  1903.                 SetEquippedSign(SignStringToEnum( selectedItem ));
  1904.                 FactsRemove("SignToggled");
  1905.                 break;
  1906.         }
  1907.     }
  1908.    
  1909.     function ToggleNextItem()
  1910.     {
  1911.         var quickSlotItems : array< EEquipmentSlots >;
  1912.         var currentSelectedItem : SItemUniqueId;
  1913.         var item : SItemUniqueId;
  1914.         var i : int;
  1915.        
  1916.         for( i = EES_Quickslot2; i > EES_Petard1 - 1; i -= 1 )
  1917.         {
  1918.             GetItemEquippedOnSlot( i, item );
  1919.             if( inv.IsIdValid( item ) )
  1920.             {
  1921.                 quickSlotItems.PushBack( i );
  1922.             }
  1923.         }
  1924.         if( !quickSlotItems.Size() )
  1925.         {
  1926.             return;
  1927.         }
  1928.        
  1929.         currentSelectedItem = GetSelectedItemId();
  1930.        
  1931.         if( inv.IsIdValid( currentSelectedItem ) )
  1932.         {
  1933.             for( i = 0; i < quickSlotItems.Size(); i += 1 )
  1934.             {
  1935.                 GetItemEquippedOnSlot( quickSlotItems[i], item );
  1936.                 if( currentSelectedItem == item )
  1937.                 {
  1938.                     if( i == quickSlotItems.Size() - 1 )
  1939.                     {
  1940.                         SelectQuickslotItem( quickSlotItems[ 0 ] );
  1941.                     }
  1942.                     else
  1943.                     {
  1944.                         SelectQuickslotItem( quickSlotItems[ i + 1 ] );
  1945.                     }
  1946.                     return;
  1947.                 }
  1948.             }
  1949.         }
  1950.         else
  1951.         {
  1952.             SelectQuickslotItem( quickSlotItems[ 0 ] );
  1953.         }
  1954.     }
  1955.  
  1956.     public function OnShieldHit()
  1957.     {
  1958.         m_quenHitFxTTL = 0.2;
  1959.         ApplyGamepadTriggerEffect( equippedSign );
  1960.     }
  1961.  
  1962.     timer function UpdateGamepadTriggerEffect( dt : float, id : int )
  1963.     {
  1964.         if( m_TriggerEffectDisablePending )
  1965.         {
  1966.             m_TriggerEffectDisableTTW -= dt;
  1967.  
  1968.             if( m_TriggerEffectDisableTTW < 0 )
  1969.             {
  1970.                 m_TriggerEffectDisabled = true;
  1971.                 m_TriggerEffectDisablePending = false;
  1972.             }
  1973.         }
  1974.  
  1975.         if( m_TriggerEffectDisabled  &&  !theInput.IsActionPressed('CastSign') )
  1976.             m_TriggerEffectDisabled = false;
  1977.  
  1978.         m_quenHitFxTTL -= dt;
  1979.         ApplyGamepadTriggerEffect( equippedSign );
  1980.     }
  1981.  
  1982.     public function ApplyCastSettings()
  1983.     {
  1984.         ApplyGamepadTriggerEffect( equippedSign );
  1985.     }
  1986.  
  1987.     private function ApplyGamepadTriggerEffect( type : ESignType )
  1988.     {
  1989.         var mode : int;
  1990.         var param : array<Vector>;
  1991.         var cur_sign : W3SignEntity;
  1992.         var sign_skill : ESkill;
  1993.  
  1994.         sign_skill = SignEnumToSkillEnum( type );
  1995.  
  1996.         if( !thePlayer.CanUseSkill(sign_skill)  ||  !HasStaminaToUseSkill(sign_skill,false) )
  1997.         {
  1998.             theGame.SetTriggerEffect( 1, GTFX_Off, param );
  1999.             theGame.SetTriggerEffect( 0, GTFX_Off, param );
  2000.             if(theInput.IsActionPressed('CastSign'))
  2001.             {
  2002.                 lastPressedWithNostamina = true;
  2003.             }
  2004.             return;
  2005.         }
  2006.         if(lastPressedWithNostamina && !theInput.IsActionPressed('CastSign'))
  2007.         {
  2008.             lastPressedWithNostamina = false;
  2009.         }
  2010.  
  2011.         if(lastPressedWithNostamina)
  2012.         {
  2013.             return;
  2014.         }
  2015.  
  2016.         if( type == ST_Igni  &&  IsCurrentSignChanneled() )
  2017.         {
  2018.             mode = GTFX_MultiVibration;
  2019.            
  2020.             param.Resize( 10 );
  2021.             param[0].Y = 0.3;
  2022.             param[0].X = 0.0;
  2023.             param[1].X = 0.0;
  2024.             param[2].X = 0.0;
  2025.             param[3].X = 0.0;
  2026.             param[4].X = 0.0;
  2027.             param[5].X = 0.0;
  2028.             param[6].X = 0.8;
  2029.             param[7].X = 0.8;
  2030.             param[8].X = 0.8;
  2031.             param[9].X = 0.9;
  2032.  
  2033.             theGame.SetTriggerEffect( 1, mode, param );
  2034.             return;
  2035.         }
  2036.  
  2037.         if( type == ST_Quen  &&  m_quenHitFxTTL > 0  &&  HasBuff( EET_BasicQuen ) )
  2038.         {
  2039.             mode = GTFX_MultiVibration;
  2040.            
  2041.             param.Resize( 10 );
  2042.             param[0].Y = 0.5;
  2043.             param[0].X = 0.0;
  2044.             param[1].X = 0.0;
  2045.             param[2].X = 0.0;
  2046.             param[3].X = 0.0;
  2047.             param[4].X = 0.0;
  2048.             param[5].X = 0.0;
  2049.             param[6].X = 0.8;
  2050.             param[7].X = 0.8;
  2051.             param[8].X = 0.99;
  2052.             param[9].X = 0.99;
  2053.  
  2054.             theGame.SetTriggerEffect( 1, mode, param );
  2055.             return;
  2056.         }
  2057.  
  2058.        
  2059.         if( m_TriggerEffectDisabled )
  2060.         {
  2061.             theGame.SetTriggerEffect( 1, GTFX_Off, param );
  2062.             theGame.SetTriggerEffect( 0, GTFX_Off, param );
  2063.             return;
  2064.         }
  2065.  
  2066.         if(    
  2067.             theGame.IsPaused()
  2068.             || theGame.GetPhotomodeEnabled()
  2069.             || theGame.IsDialogOrCutscenePlaying()
  2070.             || thePlayer.IsInCutsceneIntro()
  2071.             || theGame.IsCurrentlyPlayingNonGameplayScene()
  2072.             )
  2073.         {
  2074.             theGame.SetTriggerEffect( 1, GTFX_Off, param );
  2075.             theGame.SetTriggerEffect( 0, GTFX_Off, param );
  2076.  
  2077.             return;
  2078.         }
  2079.  
  2080.         mode = GTFX_Off;
  2081.        
  2082.         if( GetInputHandler().GetIsAltSignCasting() )
  2083.         {
  2084.             mode = GTFX_Vibration;
  2085.            
  2086.             param.Resize( 1 );
  2087.             param[0].X = 0.9;
  2088.             param[0].Y = 0.1;
  2089.             param[0].Z = 0.15;
  2090.  
  2091.             theGame.SetTriggerEffect( 1, mode, param );
  2092.            
  2093.             if( GetInputHandler().GetIsAltSignCastingPressed() )
  2094.             {
  2095.                 mode = GTFX_Weapon;
  2096.  
  2097.                 param.Resize( 1 );
  2098.                 param[0].X = 0.1;
  2099.                 param[0].Y = 0.5;
  2100.                 param[0].Z = 1.0;
  2101.                
  2102.                 theGame.SetTriggerEffect( 0, mode, param );
  2103.             }
  2104.             else
  2105.             {
  2106.                 theGame.SetTriggerEffect( 0, GTFX_Off, param );
  2107.             }
  2108.         }
  2109.         else
  2110.         {
  2111.             if( type == ST_Aard )
  2112.             {
  2113.                 mode = GTFX_MultiFeedback;
  2114.                
  2115.                 param.Resize( 10 );
  2116.                 param[0].X = 0.0;
  2117.                 param[1].X = 0.0;
  2118.                 param[2].X = 0.0;
  2119.                 param[3].X = 0.1;
  2120.                 param[4].X = 0.2;
  2121.                 param[5].X = 0.2;
  2122.                 param[6].X = 0.0;
  2123.                 param[7].X = 0.0;
  2124.                 param[8].X = 0.4;
  2125.                 param[9].X = 0.4;
  2126.             }
  2127.             else if( type == ST_Axii )
  2128.             {
  2129.                 mode = GTFX_Vibration;
  2130.                
  2131.                 param.Resize( 1 );
  2132.                 param[0].X = 0.8;
  2133.                 param[0].Y = 0.15;
  2134.                 param[0].Z = 0.2;
  2135.             }
  2136.             else if( type == ST_Igni )
  2137.             {
  2138.                 mode = GTFX_Weapon;
  2139.  
  2140.                 param.Resize( 1 );
  2141.                 param[0].X = 0.5;
  2142.                 param[0].Y = 0.7;
  2143.                 param[0].Z = 1.0;
  2144.             }
  2145.             else if( type == ST_Quen )
  2146.             {
  2147.                 mode = GTFX_Vibration;
  2148.                
  2149.                 param.Resize( 1 );
  2150.                 param[0].X = 0.8;
  2151.                 param[0].Y = 0.25;
  2152.                 param[0].Z = 0.7;
  2153.             }
  2154.             else if( type == ST_Yrden )
  2155.             {
  2156.                 mode = GTFX_Vibration;
  2157.                
  2158.                 param.Resize( 1 );
  2159.                 param[0].X = 0.9;
  2160.                 param[0].Y = 0.5;
  2161.                 param[0].Z = 0.99;
  2162.             }
  2163.            
  2164.             theGame.SetTriggerEffect( 1, mode, param );
  2165.             theGame.SetTriggerEffect( 0, GTFX_Off, param );
  2166.         }      
  2167.  
  2168.     }
  2169.        
  2170.    
  2171.     function SetEquippedSign( signType : ESignType )
  2172.     {
  2173.         if(!IsSignBlocked(signType))
  2174.         {
  2175.             equippedSign = signType;
  2176.             FactsSet("CurrentlySelectedSign", equippedSign);
  2177.             ApplyGamepadTriggerEffect( signType );
  2178.         }
  2179.     }
  2180.    
  2181.     function GetEquippedSign() : ESignType
  2182.     {
  2183.         return equippedSign;
  2184.     }
  2185.    
  2186.     function GetCurrentlyCastSign() : ESignType
  2187.     {
  2188.         return currentlyCastSign;
  2189.     }
  2190.    
  2191.     function SetCurrentlyCastSign( type : ESignType, entity : W3SignEntity )
  2192.     {
  2193.         currentlyCastSign = type;
  2194.        
  2195.         if( type != ST_None )
  2196.         {
  2197.             signs[currentlyCastSign].entity = entity;
  2198.         }
  2199.     }
  2200.    
  2201.     function GetCurrentSignEntity() : W3SignEntity
  2202.     {
  2203.         if(currentlyCastSign == ST_None)
  2204.             return NULL;
  2205.            
  2206.         return signs[currentlyCastSign].entity;
  2207.     }
  2208.    
  2209.     public function GetSignEntity(type : ESignType) : W3SignEntity
  2210.     {
  2211.         if(type == ST_None)
  2212.             return NULL;
  2213.            
  2214.         return signs[type].entity;
  2215.     }
  2216.    
  2217.     public function GetSignTemplate(type : ESignType) : CEntityTemplate
  2218.     {
  2219.         if(type == ST_None)
  2220.             return NULL;
  2221.            
  2222.         return signs[type].template;
  2223.     }
  2224.    
  2225.     public function IsCurrentSignChanneled() : bool
  2226.     {
  2227.         if( currentlyCastSign != ST_None && signs[currentlyCastSign].entity)
  2228.             return signs[currentlyCastSign].entity.OnCheckChanneling();
  2229.        
  2230.         return false;
  2231.     }
  2232.    
  2233.     function IsCastingSign() : bool
  2234.     {
  2235.         return currentlyCastSign != ST_None;
  2236.     }
  2237.    
  2238.    
  2239.     protected function IsInCombatActionCameraRotationEnabled() : bool
  2240.     {
  2241.         if( IsInCombatAction() && ( GetCombatAction() == EBAT_EMPTY || GetCombatAction() == EBAT_Parry ) )
  2242.         {
  2243.             return true;
  2244.         }
  2245.        
  2246.         return !bIsInCombatAction;
  2247.     }
  2248.    
  2249.     function SetHoldBeforeOpenRadialMenuTime ( time : float )
  2250.     {
  2251.         _HoldBeforeOpenRadialMenuTime = time;
  2252.     }
  2253.    
  2254.    
  2255.    
  2256.    
  2257.    
  2258.    
  2259.    
  2260.     public function RepairItem (  rapairKitId : SItemUniqueId, usedOnItem : SItemUniqueId )
  2261.     {
  2262.         var itemMaxDurablity        : float;
  2263.         var itemCurrDurablity       : float;
  2264.         var baseRepairValue         : float;
  2265.         var reapirValue             : float;
  2266.         var itemAttribute           : SAbilityAttributeValue;
  2267.        
  2268.         itemMaxDurablity = inv.GetItemMaxDurability(usedOnItem);
  2269.         itemCurrDurablity = inv.GetItemDurability(usedOnItem);
  2270.         itemAttribute = inv.GetItemAttributeValue ( rapairKitId, 'repairValue' );
  2271.        
  2272.         if( itemCurrDurablity >= itemMaxDurablity )
  2273.         {
  2274.             return;
  2275.         }
  2276.        
  2277.         if ( inv.IsItemAnyArmor ( usedOnItem )|| inv.IsItemWeapon( usedOnItem ) )
  2278.         {          
  2279.            
  2280.             baseRepairValue = itemMaxDurablity * itemAttribute.valueMultiplicative;                
  2281.             reapirValue = MinF( itemCurrDurablity + baseRepairValue, itemMaxDurablity );
  2282.            
  2283.             inv.SetItemDurabilityScript ( usedOnItem, MinF ( reapirValue, itemMaxDurablity ));
  2284.         }
  2285.        
  2286.         inv.RemoveItem ( rapairKitId, 1 );
  2287.        
  2288.     }
  2289.     public function HasRepairAbleGearEquiped ( ) : bool
  2290.     {
  2291.         var curEquipedItem : SItemUniqueId;
  2292.        
  2293.         return ( GetItemEquippedOnSlot(EES_Armor, curEquipedItem) || GetItemEquippedOnSlot(EES_Boots, curEquipedItem) || GetItemEquippedOnSlot(EES_Pants, curEquipedItem) || GetItemEquippedOnSlot(EES_Gloves, curEquipedItem)) == true;
  2294.     }
  2295.     public function HasRepairAbleWaponEquiped () : bool
  2296.     {
  2297.         var curEquipedItem : SItemUniqueId;
  2298.        
  2299.         return ( GetItemEquippedOnSlot(EES_SilverSword, curEquipedItem) || GetItemEquippedOnSlot(EES_SteelSword, curEquipedItem) ) == true;
  2300.     }
  2301.     public function IsItemRepairAble ( item : SItemUniqueId ) : bool
  2302.     {
  2303.         return inv.GetItemDurabilityRatio(item) <= 0.99999f;
  2304.     }
  2305.    
  2306.    
  2307.    
  2308.    
  2309.    
  2310.    
  2311.        
  2312.    
  2313.     public function ApplyOil( oilId : SItemUniqueId, usedOnItem : SItemUniqueId ) : bool
  2314.     {
  2315.         var tutStateOil : W3TutorialManagerUIHandlerStateOils;     
  2316.        
  2317.         if( !super.ApplyOil( oilId, usedOnItem ))
  2318.             return false;
  2319.                
  2320.        
  2321.         if(ShouldProcessTutorial('TutorialOilCanEquip3'))
  2322.         {
  2323.             tutStateOil = (W3TutorialManagerUIHandlerStateOils)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  2324.             if(tutStateOil)
  2325.             {
  2326.                 tutStateOil.OnOilApplied();
  2327.             }
  2328.         }
  2329.        
  2330.         return true;
  2331.     }
  2332.    
  2333.    
  2334.     public final function RemoveExtraOilsFromItem( item : SItemUniqueId )
  2335.     {
  2336.         var oils : array< CBaseGameplayEffect >;
  2337.         var i, cnt : int;
  2338.         var buff : W3Effect_Oil;
  2339.  
  2340.        
  2341.         inv.RemoveAllOilsFromItem(item);
  2342.         return;    
  2343.        
  2344.        
  2345.        
  2346.     }
  2347.    
  2348.    
  2349.    
  2350.    
  2351.    
  2352.    
  2353.    
  2354.    
  2355.     function ReduceDamage(out damageData : W3DamageAction)
  2356.     {
  2357.         var actorAttacker : CActor;
  2358.         var quen : W3QuenEntity;
  2359.         var attackRange : CAIAttackRange;
  2360.         var attackerMovementAdjustor : CMovementAdjustor;
  2361.         var dist, distToAttacker, actionHeading, attackerHeading, currAdrenaline, adrenReducedDmg, focus : float;
  2362.         var attackName : name;
  2363.         var useQuenForBleeding : bool;
  2364.         var min, max : SAbilityAttributeValue;
  2365.         var skillLevel : int;
  2366.        
  2367.         super.ReduceDamage(damageData);
  2368.        
  2369.        
  2370.        
  2371.         quen = (W3QuenEntity)signs[ST_Quen].entity;
  2372.         useQuenForBleeding = false;
  2373.         if(quen && !damageData.DealsAnyDamage() && ((W3Effect_Bleeding)damageData.causer) && damageData.GetDamageValue(theGame.params.DAMAGE_NAME_DIRECT) > 0.f)
  2374.             useQuenForBleeding = true;
  2375.        
  2376.        
  2377.         if(!useQuenForBleeding && !damageData.DealsAnyDamage())
  2378.             return;
  2379.        
  2380.         actorAttacker = (CActor)damageData.attacker;
  2381.        
  2382.        
  2383.         if(actorAttacker && IsCurrentlyDodging() && damageData.CanBeDodged())
  2384.         {
  2385.            
  2386.            
  2387.             actionHeading = evadeHeading;
  2388.             attackerHeading = actorAttacker.GetHeading();
  2389.             dist = AngleDistance(actionHeading, attackerHeading);
  2390.             distToAttacker = VecDistance(this.GetWorldPosition(),damageData.attacker.GetWorldPosition());
  2391.             attackName = actorAttacker.GetLastAttackRangeName();
  2392.             attackRange = theGame.GetAttackRangeForEntity( actorAttacker, attackName );
  2393.             attackerMovementAdjustor = actorAttacker.GetMovingAgentComponent().GetMovementAdjustor();
  2394.             if( ( AbsF(dist) < 150 && attackName != 'stomp' && attackName != 'anchor_special_far' && attackName != 'anchor_far' )
  2395.                 || ( ( attackName == 'stomp' || attackName == 'anchor_special_far' || attackName == 'anchor_far' ) && distToAttacker > attackRange.rangeMax * 0.75 ) )
  2396.             {
  2397.                 if ( theGame.CanLog() )
  2398.                 {
  2399.                     LogDMHits("W3PlayerWitcher.ReduceDamage: Attack dodged by player - no damage done", damageData);
  2400.                 }
  2401.                 damageData.SetAllProcessedDamageAs(0);
  2402.                 damageData.SetWasDodged();
  2403.             }
  2404.            
  2405.             else if( !damageData.IsActionEnvironment() && !damageData.IsDoTDamage() && CanUseSkill( S_Sword_s09 ) )
  2406.             {
  2407.                 skillLevel = GetSkillLevel( S_Sword_s09 );
  2408.                 if( skillLevel == GetSkillMaxLevel( S_Sword_s09 ) )
  2409.                 {
  2410.                     damageData.SetAllProcessedDamageAs(0);
  2411.                     damageData.SetWasDodged();
  2412.                 }
  2413.                 else
  2414.                 {
  2415.                     damageData.processedDmg.vitalityDamage *= 1 - CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s09, 'damage_reduction', false, true)) * skillLevel;
  2416.                 }
  2417.                
  2418.                 if ( theGame.CanLog() )
  2419.                 {
  2420.                     LogDMHits("W3PlayerWitcher.ReduceDamage: skill S_Sword_s09 reduced damage while dodging", damageData );
  2421.                 }
  2422.             }
  2423.         }
  2424.        
  2425.        
  2426.         if(quen && damageData.GetBuffSourceName() != "FallingDamage")
  2427.         {
  2428.             if ( theGame.CanLog() )
  2429.             {      
  2430.                 LogDMHits("W3PlayerWitcher.ReduceDamage: Processing Quen sign damage reduction...", damageData);
  2431.             }
  2432.             quen.OnTargetHit( damageData );
  2433.         }  
  2434.        
  2435.        
  2436.         if( HasBuff( EET_GryphonSetBonusYrden ) )
  2437.         {
  2438.             min = GetAttributeValue( 'gryphon_set_bns_dmg_reduction' );
  2439.             damageData.processedDmg.vitalityDamage *= 1 - min.valueAdditive;
  2440.         }
  2441.        
  2442.        
  2443.         if( IsMutationActive( EPMT_Mutation5 ) && !IsAnyQuenActive() && !damageData.IsDoTDamage() )
  2444.         {
  2445.             focus = GetStat( BCS_Focus );
  2446.             currAdrenaline = FloorF( focus );
  2447.             if( currAdrenaline >= 1 )
  2448.             {
  2449.                 theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Mutation5', 'mut5_dmg_red_perc', min, max );
  2450.                 adrenReducedDmg = ( currAdrenaline * min.valueAdditive );
  2451.                 damageData.processedDmg.vitalityDamage *= 1 - adrenReducedDmg;
  2452.                
  2453.                
  2454.                 theGame.MutationHUDFeedback( MFT_PlayOnce );
  2455.                
  2456.                 if( focus >= 3.f )
  2457.                 {
  2458.                     PlayEffect( 'mutation_5_stage_03' );
  2459.                 }
  2460.                 else if( focus >= 2.f )
  2461.                 {
  2462.                     PlayEffect( 'mutation_5_stage_02' );
  2463.                 }
  2464.                 else
  2465.                 {
  2466.                     PlayEffect( 'mutation_5_stage_01' );
  2467.                 }
  2468.             }
  2469.         }
  2470.        
  2471.        
  2472.         if(!damageData.GetIgnoreImmortalityMode())
  2473.         {
  2474.             if(!((W3PlayerWitcher)this))
  2475.                 Log("");
  2476.            
  2477.            
  2478.             if( IsInvulnerable() )
  2479.             {
  2480.                 if ( theGame.CanLog() )
  2481.                 {
  2482.                     LogDMHits("CActor.ReduceDamage: victim Invulnerable - no damage will be dealt", damageData );
  2483.                 }
  2484.                 damageData.SetAllProcessedDamageAs(0);
  2485.                 return;
  2486.             }
  2487.            
  2488.             if(actorAttacker && damageData.DealsAnyDamage() )
  2489.                 actorAttacker.SignalGameplayEventParamObject( 'DamageInstigated', damageData );
  2490.            
  2491.            
  2492.             if( IsImmortal() )
  2493.             {
  2494.                 if ( theGame.CanLog() )
  2495.                 {
  2496.                     LogDMHits("CActor.ReduceDamage: victim is Immortal, clamping damage", damageData );
  2497.                 }
  2498.                 damageData.processedDmg.vitalityDamage = ClampF(damageData.processedDmg.vitalityDamage, 0, GetStat(BCS_Vitality)-1 );
  2499.                 damageData.processedDmg.essenceDamage  = ClampF(damageData.processedDmg.essenceDamage, 0, GetStat(BCS_Essence)-1 );
  2500.                 return;
  2501.             }
  2502.         }
  2503.         else
  2504.         {
  2505.            
  2506.             if(actorAttacker && damageData.DealsAnyDamage() )
  2507.                 actorAttacker.SignalGameplayEventParamObject( 'DamageInstigated', damageData );
  2508.         }
  2509.     }
  2510.    
  2511.     timer function UndyingSkillCooldown(dt : float, id : int)
  2512.     {
  2513.         cannotUseUndyingSkill = false;
  2514.     }
  2515.    
  2516.    
  2517.     public function GetCannotUseUndying() : bool
  2518.     {
  2519.         return cannotUseUndyingSkill;
  2520.     }  
  2521.    
  2522.     public function SetCannotUseUndyingSkill(set : bool)
  2523.     {
  2524.         cannotUseUndyingSkill = set;
  2525.     }
  2526.    
  2527.    
  2528.     event OnTakeDamage( action : W3DamageAction)
  2529.     {
  2530.         var currVitality, rgnVitality, hpTriggerTreshold : float;
  2531.         var healingFactor : float;
  2532.         var abilityName : name;
  2533.         var abilityCount, maxStack, itemDurability : float;
  2534.         var addAbility : bool;
  2535.         var min, max : SAbilityAttributeValue;
  2536.         var mutagenQuen : W3SignEntity;
  2537.         var equipped : array<SItemUniqueId>;
  2538.         var i : int;
  2539.         var killSourceName : string;
  2540.         var aerondight  : W3Effect_Aerondight;
  2541.    
  2542.         currVitality = GetStat(BCS_Vitality);
  2543.        
  2544.        
  2545.         if(action.processedDmg.vitalityDamage >= currVitality)
  2546.         {
  2547.             killSourceName = action.GetBuffSourceName();
  2548.            
  2549.            
  2550.             if( killSourceName != "Quest" && killSourceName != "Kill Trigger" && killSourceName != "Trap" && killSourceName != "FallingDamage" )
  2551.             {          
  2552.                
  2553.                 if(!cannotUseUndyingSkill && FloorF(GetStat(BCS_Focus)) >= 1 && CanUseSkill(S_Sword_s18) && HasBuff(EET_BattleTrance) )
  2554.                 {
  2555.                     healingFactor = CalculateAttributeValue( GetSkillAttributeValue(S_Sword_s18, 'healing_factor', false, true) );
  2556.                     healingFactor *= GetStatMax(BCS_Vitality);
  2557.                     healingFactor *= GetStat(BCS_Focus);
  2558.                     healingFactor *= 1 + CalculateAttributeValue( GetSkillAttributeValue(S_Sword_s18, 'healing_bonus', false, true) ) * (GetSkillLevel(S_Sword_s18) - 1);
  2559.                     ForceSetStat(BCS_Vitality, GetStatMax(BCS_Vitality));
  2560.                     DrainFocus(GetStat(BCS_Focus));
  2561.                     RemoveBuff(EET_BattleTrance);
  2562.                     cannotUseUndyingSkill = true;
  2563.                     AddTimer('UndyingSkillCooldown', CalculateAttributeValue( GetSkillAttributeValue(S_Sword_s18, 'trigger_delay', false, true) ), false, , , true);
  2564.                 }
  2565.                
  2566.                 else if( IsMutationActive( EPMT_Mutation11 ) && !HasBuff( EET_Mutation11Debuff ) && !IsInAir() )
  2567.                 {
  2568.                     theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Mutation11', 'health_prc', min, max );
  2569.  
  2570.                     action.SetAllProcessedDamageAs( 0 );
  2571.                    
  2572.                     OnMutation11Triggered();                   
  2573.                 }
  2574.                 else
  2575.                 {
  2576.                    
  2577.                     equipped = GetEquippedItems();
  2578.                    
  2579.                     for(i=0; i<equipped.Size(); i+=1)
  2580.                     {
  2581.                         if ( !inv.IsIdValid( equipped[i] ) )
  2582.                         {
  2583.                             continue;
  2584.                         }
  2585.                         itemDurability = inv.GetItemDurability(equipped[i]);
  2586.                         if(inv.ItemHasAbility(equipped[i], 'MA_Reinforced') && itemDurability > 0)
  2587.                         {
  2588.                            
  2589.                             inv.SetItemDurabilityScript(equipped[i], MaxF(0, itemDurability - action.processedDmg.vitalityDamage) );
  2590.                            
  2591.                            
  2592.                             action.processedDmg.vitalityDamage = 0;
  2593.                             ForceSetStat(BCS_Vitality, 1);
  2594.                            
  2595.                             break;
  2596.                         }
  2597.                     }
  2598.                 }
  2599.             }
  2600.         }
  2601.        
  2602.        
  2603.         if(action.DealsAnyDamage() && !((W3Effect_Toxicity)action.causer) )
  2604.         {
  2605.             if(HasBuff(EET_Mutagen10))
  2606.                 RemoveAbilityAll( GetBuff(EET_Mutagen10).GetAbilityName() );
  2607.            
  2608.             if(HasBuff(EET_Mutagen15))
  2609.                 RemoveAbilityAll( GetBuff(EET_Mutagen15).GetAbilityName() );
  2610.         }
  2611.                
  2612.        
  2613.         if(HasBuff(EET_Mutagen19))
  2614.         {
  2615.             theGame.GetDefinitionsManager().GetAbilityAttributeValue(GetBuff(EET_Mutagen19).GetAbilityName(), 'max_hp_perc_trigger', min, max);
  2616.             hpTriggerTreshold = GetStatMax(BCS_Vitality) * CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  2617.            
  2618.             if(action.GetDamageDealt() >= hpTriggerTreshold)
  2619.             {
  2620.                 mutagenQuen = (W3SignEntity)theGame.CreateEntity( signs[ST_Quen].template, GetWorldPosition(), GetWorldRotation() );
  2621.                 mutagenQuen.Init( signOwner, signs[ST_Quen].entity, true );
  2622.                 mutagenQuen.OnStarted();
  2623.                 mutagenQuen.OnThrowing();
  2624.                 mutagenQuen.OnEnded();
  2625.             }
  2626.         }
  2627.        
  2628.        
  2629.         if(action.DealsAnyDamage() && !action.IsDoTDamage() && HasBuff(EET_Mutagen27))
  2630.         {
  2631.             abilityName = GetBuff(EET_Mutagen27).GetAbilityName();
  2632.             abilityCount = GetAbilityCount(abilityName);
  2633.            
  2634.             if(abilityCount == 0)
  2635.             {
  2636.                 addAbility = true;
  2637.             }
  2638.             else
  2639.             {
  2640.                 theGame.GetDefinitionsManager().GetAbilityAttributeValue(abilityName, 'mutagen27_max_stack', min, max);
  2641.                 maxStack = CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  2642.                
  2643.                 if(maxStack >= 0)
  2644.                 {
  2645.                     addAbility = (abilityCount < maxStack);
  2646.                 }
  2647.                 else
  2648.                 {
  2649.                     addAbility = true;
  2650.                 }
  2651.             }
  2652.            
  2653.             if(addAbility)
  2654.             {
  2655.                 AddAbility(abilityName, true);
  2656.             }
  2657.         }
  2658.        
  2659.         if(HasBuff(EET_Trap) && !action.IsDoTDamage() && action.attacker.HasAbility( 'mon_dettlaff_monster_base' ))
  2660.         {
  2661.             action.AddEffectInfo(EET_Knockdown);
  2662.             RemoveBuff(EET_Trap, true);
  2663.         }      
  2664.        
  2665.         super.OnTakeDamage(action);
  2666.        
  2667.        
  2668.         if( !action.WasDodged() && action.DealtDamage() && inv.ItemHasTag( inv.GetCurrentlyHeldSword(), 'Aerondight' ) && !action.IsDoTDamage() && !( (W3Effect_Toxicity) action.causer ) )
  2669.         {
  2670.             aerondight = (W3Effect_Aerondight)GetBuff( EET_Aerondight );
  2671.             if( aerondight && aerondight.GetCurrentCount() != 0 )
  2672.             {
  2673.                 aerondight.ReduceAerondightStacks();
  2674.             }
  2675.         }
  2676.        
  2677.        
  2678.         if( !action.WasDodged() && action.DealtDamage() && !( (W3Effect_Toxicity) action.causer ) )
  2679.         {
  2680.             RemoveBuff( EET_Mutation3 );
  2681.         }
  2682.     }
  2683.    
  2684.    
  2685.    
  2686.    
  2687.    
  2688.    
  2689.    
  2690.     event OnStartFistfightMinigame()
  2691.     {
  2692.         var i : int;
  2693.         var buffs : array< CBaseGameplayEffect >;
  2694.        
  2695.        
  2696.         effectManager.RemoveAllPotionEffects();
  2697.        
  2698.         abilityManager.DrainToxicity(GetStatMax( BCS_Toxicity ));
  2699.        
  2700.         buffs = GetBuffs( EET_WellFed );
  2701.         for( i=buffs.Size()-1; i>=0; i-=1 )
  2702.         {
  2703.             RemoveEffect( buffs[i] );
  2704.         }
  2705.        
  2706.        
  2707.         buffs.Clear();
  2708.         buffs = GetBuffs( EET_WellHydrated );
  2709.         for( i=buffs.Size()-1; i>=0; i-=1 )
  2710.         {
  2711.             RemoveEffect( buffs[i] );
  2712.         }
  2713.        
  2714.         super.OnStartFistfightMinigame();
  2715.     }
  2716.    
  2717.     event OnEndFistfightMinigame()
  2718.     {
  2719.         super.OnEndFistfightMinigame();
  2720.     }
  2721.    
  2722.    
  2723.     public function GetCriticalHitChance( isLightAttack : bool, isHeavyAttack : bool, target : CActor, victimMonsterCategory : EMonsterCategory, isBolt : bool ) : float
  2724.     {
  2725.         var ret : float;
  2726.         var thunder : W3Potion_Thunderbolt;
  2727.         var min, max : SAbilityAttributeValue;
  2728.        
  2729.         ret = super.GetCriticalHitChance( isLightAttack, isHeavyAttack, target, victimMonsterCategory, isBolt );
  2730.        
  2731.        
  2732.        
  2733.        
  2734.        
  2735.        
  2736.        
  2737.         thunder = ( W3Potion_Thunderbolt )GetBuff( EET_Thunderbolt );
  2738.         if( thunder && thunder.GetBuffLevel() == 3 && GetCurWeather() == EWE_Storm )
  2739.         {
  2740.             ret += 1.0f;
  2741.         }
  2742.        
  2743.        
  2744.         if( isBolt && IsMutationActive( EPMT_Mutation9 ) )
  2745.         {
  2746.             theGame.GetDefinitionsManager().GetAbilityAttributeValue('Mutation9', 'critical_hit_chance', min, max);
  2747.             ret += min.valueMultiplicative;
  2748.         }
  2749.        
  2750.        
  2751.         if( isBolt && CanUseSkill( S_Sword_s07 ) )
  2752.         {
  2753.             ret += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s07, theGame.params.CRITICAL_HIT_CHANCE, false, true)) * GetSkillLevel(S_Sword_s07);
  2754.         }
  2755.            
  2756.         return ret;
  2757.     }
  2758.    
  2759.    
  2760.     public function GetCriticalHitDamageBonus(weaponId : SItemUniqueId, victimMonsterCategory : EMonsterCategory, isStrikeAtBack : bool) : SAbilityAttributeValue
  2761.     {
  2762.         var min, max, bonus, null, oilBonus : SAbilityAttributeValue;
  2763.         var mutagen : CBaseGameplayEffect;
  2764.         var monsterBonusType : name;
  2765.        
  2766.         bonus = super.GetCriticalHitDamageBonus(weaponId, victimMonsterCategory, isStrikeAtBack);
  2767.        
  2768.        
  2769.         if( inv.ItemHasActiveOilApplied( weaponId, victimMonsterCategory ) && GetStat( BCS_Focus ) >= 3 && CanUseSkill( S_Alchemy_s07 ) )
  2770.         {
  2771.             monsterBonusType = MonsterCategoryToAttackPowerBonus( victimMonsterCategory );
  2772.             oilBonus = inv.GetItemAttributeValue( weaponId, monsterBonusType );
  2773.             if(oilBonus != null)   
  2774.             {
  2775.                 bonus += GetSkillAttributeValue(S_Alchemy_s07, theGame.params.CRITICAL_HIT_DAMAGE_BONUS, false, true) * GetSkillLevel(S_Alchemy_s07);
  2776.             }
  2777.         }
  2778.        
  2779.        
  2780.         if (isStrikeAtBack && HasBuff(EET_Mutagen11))
  2781.         {
  2782.             mutagen = GetBuff(EET_Mutagen11);
  2783.             theGame.GetDefinitionsManager().GetAbilityAttributeValue(mutagen.GetAbilityName(), 'damageIncrease', min, max);
  2784.             bonus += GetAttributeRandomizedValue(min, max);
  2785.         }
  2786.            
  2787.         return bonus;      
  2788.     }
  2789.    
  2790.     public function ProcessLockTarget( optional newLockTarget : CActor, optional checkLeftStickHeading : bool ) : bool
  2791.     {
  2792.         var newLockTargetFound  : bool;
  2793.    
  2794.         newLockTargetFound = super.ProcessLockTarget(newLockTarget, checkLeftStickHeading);
  2795.        
  2796.         if(GetCurrentlyCastSign() == ST_Axii)
  2797.         {
  2798.             ((W3AxiiEntity)GetCurrentSignEntity()).OnDisplayTargetChange(newLockTarget);
  2799.         }
  2800.        
  2801.         return newLockTargetFound;
  2802.     }
  2803.    
  2804.    
  2805.    
  2806.    
  2807.    
  2808.    
  2809.    
  2810.      event OnProcessActionPost(action : W3DamageAction)
  2811.     {
  2812.         var attackAction : W3Action_Attack;
  2813.         var rendLoad : float;
  2814.         var value : SAbilityAttributeValue;
  2815.         var actorVictim : CActor;
  2816.         var weaponId : SItemUniqueId;
  2817.         var usesSteel, usesSilver, usesVitality, usesEssence : bool;
  2818.         var abs : array<name>;
  2819.         var i : int;
  2820.         var dm : CDefinitionsManagerAccessor;
  2821.         var items : array<SItemUniqueId>;
  2822.         var weaponEnt : CEntity;
  2823.        
  2824.         super.OnProcessActionPost(action);
  2825.        
  2826.         attackAction = (W3Action_Attack)action;
  2827.         actorVictim = (CActor)action.victim;
  2828.        
  2829.         if(attackAction)
  2830.         {
  2831.             if(attackAction.IsActionMelee())
  2832.             {
  2833.                
  2834.                 if(SkillNameToEnum(attackAction.GetAttackTypeName()) == S_Sword_s02)
  2835.                 {
  2836.                     rendLoad = GetSpecialAttackTimeRatio();
  2837.                    
  2838.                    
  2839.                     rendLoad = MinF(rendLoad * GetStatMax(BCS_Focus), GetStat(BCS_Focus));
  2840.                    
  2841.                    
  2842.                     rendLoad = FloorF(rendLoad);                   
  2843.                     DrainFocus(rendLoad);
  2844.                    
  2845.                     OnSpecialAttackHeavyActionProcess();
  2846.                 }
  2847.                 else if(actorVictim && IsRequiredAttitudeBetween(this, actorVictim, true))
  2848.                 {
  2849.                    
  2850.                    
  2851.                     value = GetAttributeValue('focus_gain');
  2852.                    
  2853.                     if( FactsQuerySum("debug_fact_focus_boy") > 0 )
  2854.                     {
  2855.                         Debug_FocusBoyFocusGain();
  2856.                     }
  2857.                    
  2858.                    
  2859.                     if ( CanUseSkill(S_Sword_s20) )
  2860.                     {
  2861.                         value += GetSkillAttributeValue(S_Sword_s20, 'focus_gain', false, true) * GetSkillLevel(S_Sword_s20);
  2862.                     }
  2863.                    
  2864.                    
  2865.                     if( IsMutationActive( EPMT_Mutation3 ) && IsRequiredAttitudeBetween( this, action.victim, true ) && !action.victim.HasTag( 'Mutation3InvalidTarget' ) && !attackAction.IsParried() && !attackAction.WasDodged() && !attackAction.IsCountered() && !inv.IsItemFists( attackAction.GetWeaponId() ) && !attackAction.WasDamageReturnedToAttacker() && attackAction.DealtDamage() )
  2866.                     {
  2867.                         AddEffectDefault( EET_Mutation3, this, "", false );
  2868.                     }
  2869.                    
  2870.                     GainStat(BCS_Focus, 0.1f * (1 + CalculateAttributeValue(value)) );
  2871.                 }
  2872.                
  2873.                
  2874.                 weaponId = attackAction.GetWeaponId();
  2875.                 if(actorVictim && (ShouldProcessTutorial('TutorialWrongSwordSteel') || ShouldProcessTutorial('TutorialWrongSwordSilver')) && GetAttitudeBetween(actorVictim, this) == AIA_Hostile)
  2876.                 {
  2877.                     usesSteel = inv.IsItemSteelSwordUsableByPlayer(weaponId);
  2878.                     usesSilver = inv.IsItemSilverSwordUsableByPlayer(weaponId);
  2879.                     usesVitality = actorVictim.UsesVitality();
  2880.                     usesEssence = actorVictim.UsesEssence();
  2881.                    
  2882.                     if(usesSilver && usesVitality)
  2883.                     {
  2884.                         FactsAdd('tut_wrong_sword_silver',1);
  2885.                     }
  2886.                     else if(usesSteel && usesEssence)
  2887.                     {
  2888.                         FactsAdd('tut_wrong_sword_steel',1);
  2889.                     }
  2890.                     else if(FactsQuerySum('tut_wrong_sword_steel') && usesSilver && usesEssence)
  2891.                     {
  2892.                         FactsAdd('tut_proper_sword_silver',1);
  2893.                         FactsRemove('tut_wrong_sword_steel');
  2894.                     }
  2895.                     else if(FactsQuerySum('tut_wrong_sword_silver') && usesSteel && usesVitality)
  2896.                     {
  2897.                         FactsAdd('tut_proper_sword_steel',1);
  2898.                         FactsRemove('tut_wrong_sword_silver');
  2899.                     }
  2900.                 }
  2901.                
  2902.                
  2903.                 if(!action.WasDodged() && HasAbility('Runeword 1 _Stats', true))
  2904.                 {
  2905.                     if(runewordInfusionType == ST_Axii)
  2906.                     {
  2907.                         actorVictim.SoundEvent('sign_axii_release');
  2908.                     }
  2909.                     else if(runewordInfusionType == ST_Igni)
  2910.                     {
  2911.                         actorVictim.SoundEvent('sign_igni_charge_begin');
  2912.                     }
  2913.                     else if(runewordInfusionType == ST_Quen)
  2914.                     {
  2915.                         value = GetAttributeValue('runeword1_quen_heal');
  2916.                         Heal( action.GetDamageDealt() * value.valueMultiplicative );
  2917.                         PlayEffectSingle('drain_energy_caretaker_shovel');
  2918.                     }
  2919.                     else if(runewordInfusionType == ST_Yrden)
  2920.                     {
  2921.                         actorVictim.SoundEvent('sign_yrden_shock_activate');
  2922.                     }
  2923.                     runewordInfusionType = ST_None;
  2924.                    
  2925.                    
  2926.                     items = inv.GetHeldWeapons();
  2927.                     weaponEnt = inv.GetItemEntityUnsafe(items[0]);
  2928.                     weaponEnt.StopEffect('runeword_aard');
  2929.                     weaponEnt.StopEffect('runeword_axii');
  2930.                     weaponEnt.StopEffect('runeword_igni');
  2931.                     weaponEnt.StopEffect('runeword_quen');
  2932.                     weaponEnt.StopEffect('runeword_yrden');
  2933.                 }
  2934.                
  2935.                
  2936.                 if(ShouldProcessTutorial('TutorialLightAttacks') || ShouldProcessTutorial('TutorialHeavyAttacks'))
  2937.                 {
  2938.                     if(IsLightAttack(attackAction.GetAttackName()))
  2939.                     {
  2940.                         theGame.GetTutorialSystem().IncreaseGeraltsLightAttacksCount(action.victim.GetTags());
  2941.                     }
  2942.                     else if(IsHeavyAttack(attackAction.GetAttackName()))
  2943.                     {
  2944.                         theGame.GetTutorialSystem().IncreaseGeraltsHeavyAttacksCount(action.victim.GetTags());
  2945.                     }
  2946.                 }
  2947.             }
  2948.             else if(attackAction.IsActionRanged())
  2949.             {
  2950.                
  2951.                 if(CanUseSkill(S_Sword_s15))
  2952.                 {              
  2953.                     value = GetSkillAttributeValue(S_Sword_s15, 'focus_gain', false, true) * GetSkillLevel(S_Sword_s15) ;
  2954.                     GainStat(BCS_Focus, CalculateAttributeValue(value) );
  2955.                 }
  2956.                
  2957.                
  2958.                 if(CanUseSkill(S_Sword_s12) && attackAction.IsCriticalHit() && actorVictim)
  2959.                 {
  2960.                    
  2961.                     actorVictim.GetCharacterStats().GetAbilities(abs, false);
  2962.                     dm = theGame.GetDefinitionsManager();
  2963.                     for(i=abs.Size()-1; i>=0; i-=1)
  2964.                     {
  2965.                         if(!dm.AbilityHasTag(abs[i], theGame.params.TAG_MONSTER_SKILL) || actorVictim.IsAbilityBlocked(abs[i]))
  2966.                         {
  2967.                             abs.EraseFast(i);
  2968.                         }
  2969.                     }
  2970.                    
  2971.                    
  2972.                     if(abs.Size() > 0)
  2973.                     {
  2974.                         value = GetSkillAttributeValue(S_Sword_s12, 'duration', true, true) * GetSkillLevel(S_Sword_s12);
  2975.                         actorVictim.BlockAbility(abs[ RandRange(abs.Size()) ], true, CalculateAttributeValue(value));
  2976.                     }
  2977.                 }
  2978.             }
  2979.         }
  2980.        
  2981.        
  2982.         if( IsMutationActive( EPMT_Mutation10 ) && actorVictim && ( action.IsActionMelee() || action.IsActionWitcherSign() ) && !IsCurrentSignChanneled() )
  2983.         {
  2984.             PlayEffectSingle( 'mutation_10_energy' );
  2985.         }
  2986.        
  2987.        
  2988.         if(CanUseSkill(S_Perk_18) && ((W3Petard)action.causer) && action.DealsAnyDamage() && !action.IsDoTDamage())
  2989.         {
  2990.             value = GetSkillAttributeValue(S_Perk_18, 'focus_gain', false, true);
  2991.             GainStat(BCS_Focus, CalculateAttributeValue(value));
  2992.         }      
  2993.        
  2994.        
  2995.         if( attackAction && IsHeavyAttack( attackAction.GetAttackName() ) && !IsUsingHorse() && attackAction.DealtDamage() && IsSetBonusActive( EISB_Lynx_1 ) && !attackAction.WasDodged() && !attackAction.IsParried() && !attackAction.IsCountered() && ( inv.IsItemSteelSwordUsableByPlayer( attackAction.GetWeaponId() ) || inv.IsItemSilverSwordUsableByPlayer( attackAction.GetWeaponId() ) ) )
  2996.         {
  2997.             AddEffectDefault( EET_LynxSetBonus, NULL, "HeavyAttack" );
  2998.             SoundEvent( "ep2_setskill_lynx_activate" );
  2999.         }      
  3000.     }
  3001.    
  3002.    
  3003.     timer function Mutagen14Timer(dt : float, id : int)
  3004.     {
  3005.         var abilityName : name;
  3006.         var abilityCount, maxStack : float;
  3007.         var min, max : SAbilityAttributeValue;
  3008.         var addAbility : bool;
  3009.        
  3010.         abilityName = GetBuff(EET_Mutagen14).GetAbilityName();
  3011.         abilityCount = GetAbilityCount(abilityName);
  3012.        
  3013.         if(abilityCount == 0)
  3014.         {
  3015.             addAbility = true;
  3016.         }
  3017.         else
  3018.         {
  3019.             theGame.GetDefinitionsManager().GetAbilityAttributeValue(abilityName, 'mutagen14_max_stack', min, max);
  3020.             maxStack = CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  3021.            
  3022.             if(maxStack >= 0)
  3023.             {
  3024.                 addAbility = (abilityCount < maxStack);
  3025.             }
  3026.             else
  3027.             {
  3028.                 addAbility = true;
  3029.             }
  3030.         }
  3031.        
  3032.         if(addAbility)
  3033.         {
  3034.             AddAbility(abilityName, true);
  3035.         }
  3036.         else
  3037.         {
  3038.            
  3039.             RemoveTimer('Mutagen14Timer');
  3040.         }
  3041.     }
  3042.    
  3043.     public final function FailFundamentalsFirstAchievementCondition()
  3044.     {
  3045.         SetFailedFundamentalsFirstAchievementCondition(true);
  3046.     }
  3047.        
  3048.     public final function SetUsedQuenInCombat()
  3049.     {
  3050.         usedQuenInCombat = true;
  3051.     }
  3052.    
  3053.     public final function UsedQuenInCombat() : bool
  3054.     {
  3055.         return usedQuenInCombat;
  3056.     }
  3057.    
  3058.     event OnCombatStart()
  3059.     {
  3060.         var quenEntity, glyphQuen : W3QuenEntity;
  3061.         var focus, stamina : float;
  3062.         var glowTargets, moTargets, actors : array< CActor >;
  3063.         var delays : array< float >;
  3064.         var rand, i : int;
  3065.         var isHostile, isAlive, isUnconscious : bool;
  3066.        
  3067.         super.OnCombatStart();
  3068.        
  3069.         if ( IsInCombatActionFriendly() )
  3070.         {
  3071.             SetBIsCombatActionAllowed(true);
  3072.             SetBIsInputAllowed(true, 'OnCombatActionStart' );
  3073.         }
  3074.        
  3075.        
  3076.         if(HasBuff(EET_Mutagen14))
  3077.         {
  3078.             AddTimer('Mutagen14Timer', 2, true);
  3079.         }
  3080.        
  3081.        
  3082.         if(HasBuff(EET_Mutagen15))
  3083.         {
  3084.             AddAbility(GetBuff(EET_Mutagen15).GetAbilityName(), false);
  3085.         }
  3086.        
  3087.        
  3088.         mutation12IsOnCooldown = false;
  3089.        
  3090.        
  3091.         quenEntity = (W3QuenEntity)signs[ST_Quen].entity;      
  3092.        
  3093.        
  3094.         if(quenEntity)
  3095.         {
  3096.             usedQuenInCombat = quenEntity.IsAnyQuenActive();
  3097.         }
  3098.         else
  3099.         {
  3100.             usedQuenInCombat = false;
  3101.         }
  3102.        
  3103.         if(usedQuenInCombat || HasPotionBuff() || IsEquippedSwordUpgradedWithOil(true) || IsEquippedSwordUpgradedWithOil(false))
  3104.         {
  3105.             SetFailedFundamentalsFirstAchievementCondition(true);
  3106.         }
  3107.         else
  3108.         {
  3109.             if(IsAnyItemEquippedOnSlot(EES_PotionMutagen1) || IsAnyItemEquippedOnSlot(EES_PotionMutagen2) || IsAnyItemEquippedOnSlot(EES_PotionMutagen3) || IsAnyItemEquippedOnSlot(EES_PotionMutagen4))
  3110.                 SetFailedFundamentalsFirstAchievementCondition(true);
  3111.             else
  3112.                 SetFailedFundamentalsFirstAchievementCondition(false);
  3113.         }
  3114.        
  3115.         if(CanUseSkill(S_Sword_s20) && IsThreatened())
  3116.         {
  3117.             focus = GetStat(BCS_Focus);
  3118.             if(focus < 1)
  3119.             {
  3120.                 GainStat(BCS_Focus, 1 - focus);
  3121.             }
  3122.         }
  3123.  
  3124.         if ( HasAbility('Glyphword 17 _Stats', true) && RandF() < CalculateAttributeValue(GetAttributeValue('quen_apply_chance')) )
  3125.         {
  3126.             stamina = GetStat(BCS_Stamina);
  3127.             glyphQuen = (W3QuenEntity)theGame.CreateEntity( signs[ST_Quen].template, GetWorldPosition(), GetWorldRotation() );
  3128.             glyphQuen.Init( signOwner, signs[ST_Quen].entity, true );
  3129.             glyphQuen.OnStarted();
  3130.             glyphQuen.OnThrowing();
  3131.             glyphQuen.OnEnded();
  3132.             ForceSetStat(BCS_Stamina, stamina);
  3133.         }
  3134.        
  3135.        
  3136.         MeditationForceAbort(true);
  3137.        
  3138.        
  3139.        
  3140.  
  3141.        
  3142.         if( IsMutationActive( EPMT_Mutation4 ) )
  3143.         {
  3144.             AddEffectDefault( EET_Mutation4, this, "combat start", false );
  3145.         }
  3146.         else if( IsMutationActive( EPMT_Mutation5 ) && GetStat( BCS_Focus ) >= 1.f )
  3147.         {
  3148.             AddEffectDefault( EET_Mutation5, this, "", false );
  3149.         }
  3150.        
  3151.         else if( IsMutationActive( EPMT_Mutation7 ) )
  3152.         {
  3153.            
  3154.                
  3155.                 RemoveTimer( 'Mutation7CombatStartHackFixGo' );
  3156.                
  3157.                
  3158.                 AddTimer( 'Mutation7CombatStartHackFix', 1.f, true, , , , true );
  3159.            
  3160.         }
  3161.         else if( IsMutationActive( EPMT_Mutation8 ) )
  3162.         {
  3163.             theGame.MutationHUDFeedback( MFT_PlayRepeat );
  3164.         }
  3165.        
  3166.         else if( IsMutationActive( EPMT_Mutation10 ) )
  3167.         {
  3168.             if( !HasBuff( EET_Mutation10 ) && GetStat( BCS_Toxicity ) > 0.f )
  3169.             {
  3170.                 AddEffectDefault( EET_Mutation10, this, "Mutation 10" );
  3171.             }
  3172.            
  3173.            
  3174.             PlayEffect( 'mutation_10' );
  3175.            
  3176.            
  3177.             PlayEffect( 'critical_toxicity' );
  3178.             AddTimer( 'Mutation10StopEffect', 5.f );
  3179.         }
  3180.     }
  3181.    
  3182.     timer function Mutation7CombatStartHackFix( dt : float, id : int )
  3183.     {
  3184.         var actors : array< CActor >;
  3185.        
  3186.         actors = GetEnemies();
  3187.        
  3188.         if( actors.Size() > 0 )
  3189.         {
  3190.            
  3191.             AddTimer( 'Mutation7CombatStartHackFixGo', 0.5f );
  3192.             RemoveTimer( 'Mutation7CombatStartHackFix' );
  3193.         }
  3194.     }
  3195.    
  3196.     timer function Mutation7CombatStartHackFixGo( dt : float, id : int )
  3197.     {
  3198.         var actors : array< CActor >;
  3199.  
  3200.         if( IsMutationActive( EPMT_Mutation7 ) )
  3201.         {
  3202.             actors = GetEnemies();
  3203.            
  3204.             if( actors.Size() > 1 )
  3205.             {      
  3206.                 AddEffectDefault( EET_Mutation7Buff, this, "Mutation 7, combat start" );           
  3207.             }
  3208.         }
  3209.     }
  3210.    
  3211.     public final function IsInFistFight() : bool
  3212.     {
  3213.         var enemies : array< CActor >;
  3214.         var i, j : int;
  3215.         var invent : CInventoryComponent;
  3216.         var weapons : array< SItemUniqueId >;
  3217.        
  3218.         if( IsInFistFightMiniGame() )
  3219.         {
  3220.             return true;
  3221.         }
  3222.        
  3223.         enemies = GetEnemies();
  3224.         for( i=0; i<enemies.Size(); i+=1 )
  3225.         {
  3226.             weapons.Clear();
  3227.             invent = enemies[i].GetInventory();
  3228.             weapons = invent.GetHeldWeapons();
  3229.            
  3230.             for( j=0; j<weapons.Size(); j+=1 )
  3231.             {
  3232.                 if( invent.IsItemFists( weapons[j] ) )
  3233.                 {
  3234.                     return true;
  3235.                 }
  3236.             }
  3237.         }
  3238.        
  3239.         return false;
  3240.     }
  3241.    
  3242.     timer function Mutation10StopEffect( dt : float, id : int )
  3243.     {
  3244.         StopEffect( 'critical_toxicity' );
  3245.     }
  3246.    
  3247.    
  3248.     event OnCombatFinished()
  3249.     {
  3250.         var mut17 : W3Mutagen17_Effect;
  3251.         var inGameConfigWrapper : CInGameConfigWrapper;
  3252.         var disableAutoSheathe : bool;
  3253.        
  3254.         super.OnCombatFinished();
  3255.        
  3256.        
  3257.         if(HasBuff(EET_Mutagen10))
  3258.         {
  3259.             RemoveAbilityAll( GetBuff(EET_Mutagen10).GetAbilityName() );
  3260.         }
  3261.        
  3262.        
  3263.         if(HasBuff(EET_Mutagen14))
  3264.         {
  3265.             RemoveAbilityAll( GetBuff(EET_Mutagen14).GetAbilityName() );
  3266.         }
  3267.        
  3268.        
  3269.         if(HasBuff(EET_Mutagen15))
  3270.         {
  3271.             RemoveAbilityAll( GetBuff(EET_Mutagen15).GetAbilityName() );
  3272.         }
  3273.        
  3274.        
  3275.         if(HasBuff(EET_Mutagen17))
  3276.         {
  3277.             mut17 = (W3Mutagen17_Effect)GetBuff(EET_Mutagen17);
  3278.             mut17.ClearBoost();
  3279.         }
  3280.        
  3281.        
  3282.         if(HasBuff(EET_Mutagen18))
  3283.         {
  3284.             RemoveAbilityAll( GetBuff(EET_Mutagen18).GetAbilityName() );
  3285.         }
  3286.        
  3287.        
  3288.         if(HasBuff(EET_Mutagen22))
  3289.         {
  3290.             RemoveAbilityAll( GetBuff(EET_Mutagen22).GetAbilityName() );
  3291.         }
  3292.        
  3293.        
  3294.         if(HasBuff(EET_Mutagen27))
  3295.         {
  3296.             RemoveAbilityAll( GetBuff(EET_Mutagen27).GetAbilityName() );
  3297.         }
  3298.        
  3299.        
  3300.         RemoveBuff( EET_Mutation3 );
  3301.        
  3302.        
  3303.         RemoveBuff( EET_Mutation4 );
  3304.        
  3305.        
  3306.         RemoveBuff( EET_Mutation5 );
  3307.        
  3308.        
  3309.         RemoveBuff( EET_Mutation7Buff );
  3310.         RemoveBuff( EET_Mutation7Debuff );
  3311.            
  3312.         if( IsMutationActive( EPMT_Mutation7 ) )
  3313.         {
  3314.             theGame.MutationHUDFeedback( MFT_PlayHide );
  3315.         }
  3316.         else if( IsMutationActive( EPMT_Mutation8 ) )
  3317.         {
  3318.             theGame.MutationHUDFeedback( MFT_PlayHide );
  3319.         }
  3320.        
  3321.        
  3322.         RemoveBuff( EET_Mutation10 );
  3323.        
  3324.        
  3325.         RemoveBuff( EET_LynxSetBonus );
  3326.        
  3327.        
  3328.         if(GetStat(BCS_Focus) > 0)
  3329.         {
  3330.             AddTimer('DelayedAdrenalineDrain', theGame.params.ADRENALINE_DRAIN_AFTER_COMBAT_DELAY, , , , true);
  3331.         }
  3332.        
  3333.        
  3334.         thePlayer.abilityManager.ResetOverhealBonus();
  3335.        
  3336.         usedQuenInCombat = false;      
  3337.        
  3338.         theGame.GetGamerProfile().ResetStat(ES_FinesseKills);
  3339.        
  3340.         LogChannel( 'OnCombatFinished', "OnCombatFinished: DelayedSheathSword timer added" );
  3341.        
  3342.        
  3343.         inGameConfigWrapper = (CInGameConfigWrapper)theGame.GetInGameConfigWrapper();
  3344.         disableAutoSheathe = inGameConfigWrapper.GetVarValue( 'Gameplay', 'DisableAutomaticSwordSheathe' );        
  3345.         if( !disableAutoSheathe )
  3346.         {
  3347.             if ( ShouldAutoSheathSwordInstantly() )
  3348.                 AddTimer( 'DelayedSheathSword', 0.5f );
  3349.             else
  3350.                 AddTimer( 'DelayedSheathSword', 2.f );
  3351.         }
  3352.        
  3353.         OnBlockAllCombatTickets( false );
  3354.        
  3355.        
  3356.         runewordInfusionType = ST_None;
  3357.        
  3358.        
  3359.        
  3360.        
  3361.        
  3362.     }
  3363.    
  3364.     public function PlayHitEffect( damageAction : W3DamageAction )
  3365.     {
  3366.         var hitReactionType     : EHitReactionType;
  3367.         var isAtBack            : bool;
  3368.        
  3369.        
  3370.         if( damageAction.GetMutation4Triggered() )
  3371.         {
  3372.             hitReactionType = damageAction.GetHitReactionType();
  3373.             isAtBack = IsAttackerAtBack( damageAction.attacker );
  3374.            
  3375.             if( hitReactionType != EHRT_Heavy )
  3376.             {
  3377.                 if( isAtBack )
  3378.                 {
  3379.                     damageAction.SetHitEffect( 'light_hit_back_toxic', true );                 
  3380.                 }
  3381.                 else
  3382.                 {
  3383.                     damageAction.SetHitEffect( 'light_hit_toxic' );
  3384.                 }
  3385.             }
  3386.             else
  3387.             {
  3388.                 if( isAtBack )
  3389.                 {
  3390.                     damageAction.SetHitEffect( 'heavy_hit_back_toxic' ,true );
  3391.                 }
  3392.                 else
  3393.                 {
  3394.                     damageAction.SetHitEffect( 'heavy_hit_toxic' );
  3395.                 }
  3396.             }
  3397.         }
  3398.        
  3399.         super.PlayHitEffect( damageAction );
  3400.     }
  3401.    
  3402.     timer function DelayedAdrenalineDrain(dt : float, id : int)
  3403.     {
  3404.         if ( !HasBuff(EET_Runeword8) )
  3405.             AddEffectDefault(EET_AdrenalineDrain, this, "after_combat_adrenaline_drain");
  3406.     }
  3407.    
  3408.    
  3409.     protected function Attack( hitTarget : CGameplayEntity, animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float, weaponEntity : CItemEntity)
  3410.     {
  3411.         var mutagen17 : W3Mutagen17_Effect;
  3412.        
  3413.         super.Attack(hitTarget, animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime, weaponEntity);
  3414.        
  3415.         if( (CActor)hitTarget && HasBuff(EET_Mutagen17) )
  3416.         {
  3417.             mutagen17 = (W3Mutagen17_Effect)GetBuff(EET_Mutagen17);
  3418.             if(mutagen17.HasBoost())
  3419.             {
  3420.                 mutagen17.ClearBoost();
  3421.             }
  3422.         }
  3423.     }
  3424.    
  3425.     public final timer function SpecialAttackLightSustainCost(dt : float, id : int)
  3426.     {
  3427.         var focusPerSec, cost, delay : float;
  3428.         var reduction : SAbilityAttributeValue;
  3429.         var skillLevel : int;
  3430.        
  3431.         if(abilityManager && abilityManager.IsInitialized() && IsAlive())
  3432.         {
  3433.             PauseStaminaRegen('WhirlSkill');
  3434.            
  3435.             if(GetStat(BCS_Stamina) > 0)
  3436.             {
  3437.                 cost = GetStaminaActionCost(ESAT_Ability, GetSkillAbilityName(S_Sword_s01), dt);
  3438.                 delay = GetStaminaActionDelay(ESAT_Ability, GetSkillAbilityName(S_Sword_s01), dt);
  3439.                 skillLevel = GetSkillLevel(S_Sword_s01);
  3440.                
  3441.                 if(skillLevel > 1)
  3442.                 {
  3443.                     reduction = GetSkillAttributeValue(S_Sword_s01, 'cost_reduction', false, true) * (skillLevel - 1);
  3444.                     cost = MaxF(0, cost * (1 - reduction.valueMultiplicative) - reduction.valueAdditive);
  3445.                 }
  3446.                
  3447.                 DrainStamina(ESAT_FixedValue, cost, delay, GetSkillAbilityName(S_Sword_s01));
  3448.             }
  3449.             else               
  3450.             {              
  3451.                 GetSkillAttributeValue(S_Sword_s01, 'focus_cost_per_sec', false, true);
  3452.                 focusPerSec = GetWhirlFocusCostPerSec();
  3453.                 DrainFocus(focusPerSec * dt);
  3454.             }
  3455.         }
  3456.        
  3457.         if(GetStat(BCS_Stamina) <= 0 && GetStat(BCS_Focus) <= 0)
  3458.         {
  3459.             OnPerformSpecialAttack(true, false);
  3460.         }
  3461.     }
  3462.    
  3463.     public final function GetWhirlFocusCostPerSec() : float
  3464.     {
  3465.         var ability : SAbilityAttributeValue;
  3466.         var val : float;
  3467.         var skillLevel : int;
  3468.        
  3469.         ability = GetSkillAttributeValue(S_Sword_s01, 'focus_cost_per_sec_initial', false, false);
  3470.         skillLevel = GetSkillLevel(S_Sword_s01);
  3471.        
  3472.         if(skillLevel > 1)
  3473.             ability -= GetSkillAttributeValue(S_Sword_s01, 'cost_reduction', false, false) * (skillLevel-1);
  3474.            
  3475.         val = CalculateAttributeValue(ability);
  3476.        
  3477.         return val;
  3478.     }
  3479.    
  3480.     public final timer function SpecialAttackHeavySustainCost(dt : float, id : int)
  3481.     {
  3482.         var focusHighlight, ratio : float;
  3483.         var hud : CR4ScriptedHud;
  3484.         var hudWolfHeadModule : CR4HudModuleWolfHead;      
  3485.  
  3486.        
  3487.         DrainStamina(ESAT_Ability, 0, 0, GetSkillAbilityName(S_Sword_s02), dt);
  3488.  
  3489.        
  3490.         if(GetStat(BCS_Stamina) <= 0)
  3491.             OnPerformSpecialAttack(false, false);
  3492.            
  3493.        
  3494.         ratio = EngineTimeToFloat(theGame.GetEngineTime() - specialHeavyStartEngineTime) / specialHeavyChargeDuration;
  3495.        
  3496.        
  3497.         if(ratio > 0.95)
  3498.             ratio = 1;
  3499.            
  3500.         SetSpecialAttackTimeRatio(ratio);
  3501.        
  3502.        
  3503.        
  3504.        
  3505.        
  3506.     }
  3507.    
  3508.     public function OnSpecialAttackHeavyActionProcess()
  3509.     {
  3510.         var hud : CR4ScriptedHud;
  3511.         var hudWolfHeadModule : CR4HudModuleWolfHead;
  3512.        
  3513.         super.OnSpecialAttackHeavyActionProcess();
  3514.  
  3515.         hud = (CR4ScriptedHud)theGame.GetHud();
  3516.         if ( hud )
  3517.         {
  3518.             hudWolfHeadModule = (CR4HudModuleWolfHead)hud.GetHudModule( "WolfHeadModule" );
  3519.             if ( hudWolfHeadModule )
  3520.             {
  3521.                 hudWolfHeadModule.ResetFocusPoints();
  3522.             }      
  3523.         }
  3524.     }
  3525.    
  3526.     timer function IsSpecialLightAttackInputHeld ( time : float, id : int )
  3527.     {
  3528.         var hasResource : bool;
  3529.        
  3530.         if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
  3531.         {
  3532.             if ( GetBIsCombatActionAllowed() && inputHandler.IsActionAllowed(EIAB_SwordAttack))
  3533.             {
  3534.                 if(GetStat(BCS_Stamina) > 0)
  3535.                 {
  3536.                     hasResource = true;
  3537.                 }
  3538.                 else
  3539.                 {
  3540.                     hasResource = (GetStat(BCS_Focus) >= GetWhirlFocusCostPerSec() * time);                
  3541.                 }
  3542.                
  3543.                 if(hasResource)
  3544.                 {
  3545.                     SetupCombatAction( EBAT_SpecialAttack_Light, BS_Pressed );
  3546.                     RemoveTimer('IsSpecialLightAttackInputHeld');
  3547.                 }
  3548.                 else if(!playedSpecialAttackMissingResourceSound)
  3549.                 {
  3550.                     IndicateTooLowAdrenaline();
  3551.                     playedSpecialAttackMissingResourceSound = true;
  3552.                 }
  3553.             }          
  3554.         }
  3555.         else
  3556.         {
  3557.             RemoveTimer('IsSpecialLightAttackInputHeld');
  3558.         }
  3559.     }  
  3560.    
  3561.     timer function IsSpecialHeavyAttackInputHeld ( time : float, id : int )
  3562.     {      
  3563.         var cost : float;
  3564.        
  3565.         if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
  3566.         {
  3567.             cost = CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s02, 'stamina_cost_per_sec', false, false));
  3568.            
  3569.             if( GetBIsCombatActionAllowed() && inputHandler.IsActionAllowed(EIAB_SwordAttack))
  3570.             {
  3571.                 if(GetStat(BCS_Stamina) >= cost)
  3572.                 {
  3573.                     SetupCombatAction( EBAT_SpecialAttack_Heavy, BS_Pressed );
  3574.                     RemoveTimer('IsSpecialHeavyAttackInputHeld');
  3575.                     theGame.HapticStart( "haptic_rend_stop" );
  3576.                 }
  3577.                 else if(!playedSpecialAttackMissingResourceSound)
  3578.                 {
  3579.                     IndicateTooLowAdrenaline();
  3580.                     playedSpecialAttackMissingResourceSound = true;
  3581.                     theGame.HapticStart( "haptic_rend_stop" );
  3582.                 }
  3583.             }
  3584.         }
  3585.         else
  3586.         {
  3587.             RemoveTimer('IsSpecialHeavyAttackInputHeld');
  3588.             theGame.HapticStart( "haptic_rend_stop" );
  3589.         }
  3590.     }
  3591.    
  3592.     public function EvadePressed( bufferAction : EBufferActionType )
  3593.     {
  3594.         var cat : float;
  3595.        
  3596.         if( (bufferAction == EBAT_Dodge && IsActionAllowed(EIAB_Dodge)) || (bufferAction == EBAT_Roll && IsActionAllowed(EIAB_Roll)) )
  3597.         {
  3598.            
  3599.             if(bufferAction != EBAT_Roll && ShouldProcessTutorial('TutorialDodge'))
  3600.             {
  3601.                 FactsAdd("tut_in_dodge", 1, 2);
  3602.                
  3603.                 if(FactsQuerySum("tut_fight_use_slomo") > 0)
  3604.                 {
  3605.                     theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
  3606.                     FactsRemove("tut_fight_slomo_ON");
  3607.                 }
  3608.             }              
  3609.             else if(bufferAction == EBAT_Roll && ShouldProcessTutorial('TutorialRoll'))
  3610.             {
  3611.                 FactsAdd("tut_in_roll", 1, 2);
  3612.                
  3613.                 if(FactsQuerySum("tut_fight_use_slomo") > 0)
  3614.                 {
  3615.                     theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
  3616.                     FactsRemove("tut_fight_slomo_ON");
  3617.                 }
  3618.             }
  3619.                
  3620.             if ( GetBIsInputAllowed() )
  3621.             {          
  3622.                 if ( GetBIsCombatActionAllowed() )
  3623.                 {
  3624.                     CriticalEffectAnimationInterrupted("Dodge 2");
  3625.                     PushCombatActionOnBuffer( bufferAction, BS_Released );
  3626.                     ProcessCombatActionBuffer();
  3627.                 }                  
  3628.                 else if ( IsInCombatAction() && GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
  3629.                 {
  3630.                     if ( CanPlayHitAnim() && IsThreatened() )
  3631.                     {
  3632.                         CriticalEffectAnimationInterrupted("Dodge 1");
  3633.                         PushCombatActionOnBuffer( bufferAction, BS_Released );
  3634.                         ProcessCombatActionBuffer();                           
  3635.                     }
  3636.                     else
  3637.                         PushCombatActionOnBuffer( bufferAction, BS_Released );
  3638.                 }
  3639.                
  3640.                 else if ( !( IsCurrentSignChanneled() ) )
  3641.                 {
  3642.                    
  3643.                     PushCombatActionOnBuffer( bufferAction, BS_Released );
  3644.                 }
  3645.             }
  3646.             else
  3647.             {
  3648.                 if ( IsInCombatAction() && GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
  3649.                 {
  3650.                     if ( CanPlayHitAnim() && IsThreatened() )
  3651.                     {
  3652.                         CriticalEffectAnimationInterrupted("Dodge 3");
  3653.                         PushCombatActionOnBuffer( bufferAction, BS_Released );
  3654.                         ProcessCombatActionBuffer();                           
  3655.                     }
  3656.                     else
  3657.                         PushCombatActionOnBuffer( bufferAction, BS_Released );
  3658.                 }
  3659.                 LogChannel( 'InputNotAllowed', "InputNotAllowed" );
  3660.             }
  3661.         }
  3662.         else
  3663.         {
  3664.             DisplayActionDisallowedHudMessage(EIAB_Dodge);
  3665.         }
  3666.     }
  3667.        
  3668.    
  3669.     public function ProcessCombatActionBuffer() : bool
  3670.     {
  3671.         var action              : EBufferActionType         = this.BufferCombatAction;
  3672.         var stage               : EButtonStage              = this.BufferButtonStage;      
  3673.         var throwStage          : EThrowStage;     
  3674.         var actionResult        : bool = true;
  3675.        
  3676.        
  3677.         if( isInFinisher )
  3678.         {
  3679.             return false;
  3680.         }
  3681.        
  3682.         if ( action != EBAT_SpecialAttack_Heavy )
  3683.             specialAttackCamera = false;           
  3684.        
  3685.        
  3686.         if(super.ProcessCombatActionBuffer())
  3687.             return true;       
  3688.            
  3689.         switch ( action )
  3690.         {          
  3691.             case EBAT_CastSign :
  3692.             {
  3693.                 switch ( stage )
  3694.                 {
  3695.                     case BS_Pressed :
  3696.                     {
  3697.  
  3698.  
  3699.  
  3700.  
  3701.    
  3702.    
  3703.                                 actionResult = this.CastSign();
  3704.                                 LogChannel('SignDebug', "CastSign()");
  3705.    
  3706.  
  3707.                     } break;
  3708.                    
  3709.                     default :
  3710.                     {
  3711.                         actionResult = false;
  3712.                     } break;
  3713.                 }
  3714.             } break;
  3715.            
  3716.             case EBAT_SpecialAttack_Light :
  3717.             {
  3718.                 switch ( stage )
  3719.                 {
  3720.                     case BS_Pressed :
  3721.                     {
  3722.                        
  3723.                         actionResult = this.OnPerformSpecialAttack( true, true );
  3724.                     } break;
  3725.                    
  3726.                     case BS_Released :
  3727.                     {                      
  3728.                         actionResult = this.OnPerformSpecialAttack( true, false );
  3729.                     } break;
  3730.                    
  3731.                     default :
  3732.                     {
  3733.                         actionResult = false;
  3734.                     } break;
  3735.                 }
  3736.             } break;
  3737.  
  3738.             case EBAT_SpecialAttack_Heavy :
  3739.             {
  3740.                 switch ( stage )
  3741.                 {
  3742.                     case BS_Pressed :
  3743.                     {
  3744.                        
  3745.                         actionResult = this.OnPerformSpecialAttack( false, true );
  3746.                     } break;
  3747.                    
  3748.                     case BS_Released :
  3749.                     {
  3750.                         actionResult = this.OnPerformSpecialAttack( false, false );
  3751.                     } break;
  3752.                    
  3753.                     default :
  3754.                     {
  3755.                         actionResult = false;
  3756.                     } break;
  3757.                 }
  3758.             } break;
  3759.            
  3760.             default:
  3761.                 return false;  
  3762.         }
  3763.        
  3764.        
  3765.         this.CleanCombatActionBuffer();
  3766.        
  3767.         if (actionResult)
  3768.         {
  3769.             SetCombatAction( action ) ;
  3770.         }
  3771.        
  3772.         return true;
  3773.     }
  3774.        
  3775.        
  3776.     event OnPerformSpecialAttack( isLightAttack : bool, enableAttack : bool ){}
  3777.    
  3778.     public final function GetEnemies() : array< CActor >
  3779.     {
  3780.         var actors, actors2 : array<CActor>;
  3781.         var i : int;
  3782.        
  3783.        
  3784.         actors = GetWitcherPlayer().GetHostileEnemies();
  3785.         ArrayOfActorsAppendUnique( actors, GetWitcherPlayer().GetMoveTargets() );
  3786.        
  3787.        
  3788.         thePlayer.GetVisibleEnemies( actors2 );
  3789.         ArrayOfActorsAppendUnique( actors, actors2 );
  3790.        
  3791.         for( i=actors.Size()-1; i>=0; i-=1 )
  3792.         {
  3793.             if( !IsRequiredAttitudeBetween( actors[i], this, true ) )
  3794.             {
  3795.                 actors.EraseFast( i );
  3796.             }
  3797.         }
  3798.        
  3799.         return actors;
  3800.     }
  3801.    
  3802.     event OnPlayerTickTimer( deltaTime : float )
  3803.     {
  3804.         super.OnPlayerTickTimer( deltaTime );
  3805.        
  3806.         if ( !IsInCombat() )
  3807.         {
  3808.             fastAttackCounter = 0;
  3809.             heavyAttackCounter = 0;        
  3810.         }      
  3811.     }
  3812.    
  3813.    
  3814.    
  3815.    
  3816.    
  3817.     protected function PrepareAttackAction( hitTarget : CGameplayEntity, animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float, weaponEntity : CItemEntity, out attackAction : W3Action_Attack) : bool
  3818.     {
  3819.         var ret : bool;
  3820.         var skill : ESkill;
  3821.    
  3822.         ret = super.PrepareAttackAction(hitTarget, animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime, weaponEntity, attackAction);
  3823.        
  3824.         if(!ret)
  3825.             return false;
  3826.        
  3827.        
  3828.         if(attackAction.IsActionMelee())
  3829.         {          
  3830.             skill = SkillNameToEnum( attackAction.GetAttackTypeName() );
  3831.             if( skill != S_SUndefined && CanUseSkill(skill))
  3832.             {
  3833.                 if(IsLightAttack(animData.attackName))
  3834.                     fastAttackCounter += 1;
  3835.                 else
  3836.                     fastAttackCounter = 0;
  3837.                
  3838.                 if(IsHeavyAttack(animData.attackName))
  3839.                     heavyAttackCounter += 1;
  3840.                 else
  3841.                     heavyAttackCounter = 0;            
  3842.             }      
  3843.         }
  3844.        
  3845.         AddTimer('FastAttackCounterDecay',5.0);
  3846.         AddTimer('HeavyAttackCounterDecay',5.0);
  3847.        
  3848.         return true;
  3849.     }
  3850.    
  3851.     protected function TestParryAndCounter(data : CPreAttackEventData, weaponId : SItemUniqueId, out parried : bool, out countered : bool) : array<CActor>
  3852.     {
  3853.        
  3854.         if(SkillNameToEnum(attackActionName) == S_Sword_s02)
  3855.             data.Can_Parry_Attack = false;
  3856.            
  3857.         return super.TestParryAndCounter(data, weaponId, parried, countered);
  3858.     }
  3859.        
  3860.     private timer function FastAttackCounterDecay(delta : float, id : int)
  3861.     {
  3862.         fastAttackCounter = 0;
  3863.     }
  3864.    
  3865.     private timer function HeavyAttackCounterDecay(delta : float, id : int)
  3866.     {
  3867.         heavyAttackCounter = 0;
  3868.     }
  3869.        
  3870.    
  3871.     public function GetCraftingSchematicsNames() : array<name>      {return craftingSchematics;}
  3872.    
  3873.     public function RemoveAllCraftingSchematics()
  3874.     {
  3875.         craftingSchematics.Clear();
  3876.     }
  3877.    
  3878.    
  3879.     function AddCraftingSchematic( nam : name, optional isSilent : bool, optional skipTutorialUpdate : bool ) : bool
  3880.     {
  3881.         var i : int;
  3882.        
  3883.         if(!skipTutorialUpdate && ShouldProcessTutorial('TutorialCraftingGotRecipe'))
  3884.         {
  3885.             FactsAdd("tut_received_schematic");
  3886.         }
  3887.        
  3888.         for(i=0; i<craftingSchematics.Size(); i+=1)
  3889.         {
  3890.             if(craftingSchematics[i] == nam)
  3891.                 return false;
  3892.            
  3893.            
  3894.             if(StrCmp(craftingSchematics[i],nam) > 0)
  3895.             {
  3896.                 craftingSchematics.Insert(i,nam);
  3897.                 AddCraftingHudNotification( nam, isSilent );
  3898.                 theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_CraftingSchematics );
  3899.                 return true;
  3900.             }          
  3901.         }  
  3902.  
  3903.        
  3904.         craftingSchematics.PushBack(nam);
  3905.         AddCraftingHudNotification( nam, isSilent );
  3906.         theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_CraftingSchematics );
  3907.         return true;   
  3908.     }
  3909.    
  3910.     function AddCraftingHudNotification( nam : name, isSilent : bool )
  3911.     {
  3912.         var hud : CR4ScriptedHud;
  3913.         if( !isSilent )
  3914.         {
  3915.             hud = (CR4ScriptedHud)theGame.GetHud();
  3916.             if( hud )
  3917.             {
  3918.                 hud.OnCraftingSchematicUpdate( nam );
  3919.             }
  3920.         }
  3921.     }  
  3922.    
  3923.     function AddAlchemyHudNotification( nam : name, isSilent : bool )
  3924.     {
  3925.         var hud : CR4ScriptedHud;
  3926.         if( !isSilent )
  3927.         {
  3928.             hud = (CR4ScriptedHud)theGame.GetHud();
  3929.             if( hud )
  3930.             {
  3931.                 hud.OnAlchemySchematicUpdate( nam );
  3932.             }
  3933.         }
  3934.     }
  3935.    
  3936.     public function GetExpandedCraftingCategories() : array< name >
  3937.     {
  3938.         return expandedCraftingCategories;
  3939.     }
  3940.    
  3941.     public function AddExpandedCraftingCategory( category : name )
  3942.     {
  3943.         if ( IsNameValid( category ) )
  3944.         {
  3945.             ArrayOfNamesPushBackUnique( expandedCraftingCategories, category );
  3946.         }
  3947.     }
  3948.  
  3949.     public function RemoveExpandedCraftingCategory( category : name )
  3950.     {
  3951.         if ( IsNameValid( category ) )
  3952.         {
  3953.             expandedCraftingCategories.Remove( category );
  3954.         }
  3955.     }
  3956.    
  3957.     public function SetCraftingFilters(showHasIngre : bool, showMissingIngre : bool, showAlreadyCrafted : bool )
  3958.     {
  3959.         craftingFilters.showCraftable = showHasIngre;
  3960.         craftingFilters.showMissingIngre = showMissingIngre;
  3961.         craftingFilters.showAlreadyCrafted = showAlreadyCrafted;
  3962.     }
  3963.    
  3964.     public function GetCraftingFilters() : SCraftingFilters
  3965.     {
  3966.        
  3967.         if ( craftingFilters.showCraftable == false && craftingFilters.showMissingIngre == false && craftingFilters.showAlreadyCrafted == false )
  3968.         {
  3969.             craftingFilters.showCraftable = true;
  3970.             craftingFilters.showMissingIngre = true;
  3971.             craftingFilters.showAlreadyCrafted = false;
  3972.         }
  3973.        
  3974.         return craftingFilters;
  3975.     }
  3976.  
  3977.    
  3978.    
  3979.    
  3980.    
  3981.     event OnMutation11Triggered()
  3982.     {
  3983.         var min, max : SAbilityAttributeValue;
  3984.         var healValue : float;
  3985.         var quenEntity : W3QuenEntity;
  3986.        
  3987.        
  3988.         if( IsSwimming() || IsDiving() || IsSailing() || IsUsingHorse() || IsUsingBoat() || IsUsingVehicle() || IsUsingExploration() )
  3989.         {
  3990.            
  3991.             ForceSetStat( BCS_Vitality, GetStatMax( BCS_Vitality ) );
  3992.            
  3993.            
  3994.             theGame.MutationHUDFeedback( MFT_PlayOnce );
  3995.            
  3996.            
  3997.             GCameraShake( 1.0f, , , , true, 'camera_shake_loop_lvl1_1' );
  3998.             AddTimer( 'StopMutation11CamShake', 2.f );
  3999.            
  4000.            
  4001.             theGame.VibrateControllerVeryHard( 2.f );
  4002.            
  4003.            
  4004.             Mutation11ShockWave( true );
  4005.            
  4006.            
  4007.             AddEffectDefault( EET_Mutation11Debuff, NULL, "Mutation 11 Debuff", false );
  4008.         }
  4009.         else
  4010.         {
  4011.             AddEffectDefault( EET_Mutation11Buff, this, "Mutation 11", false );
  4012.         }
  4013.     }
  4014.    
  4015.     timer function StopMutation11CamShake( dt : float, id : int )
  4016.     {
  4017.         theGame.GetGameCamera().StopAnimation( 'camera_shake_loop_lvl1_1' );
  4018.     }
  4019.    
  4020.     private var mutation12IsOnCooldown : bool;
  4021.    
  4022.     public final function AddMutation12Decoction()
  4023.     {
  4024.         var params : SCustomEffectParams;
  4025.         var buffs : array< EEffectType >;
  4026.         var existingDecoctionBuffs : array<CBaseGameplayEffect>;
  4027.         var i : int;
  4028.         var effectType : EEffectType;
  4029.         var decoctions : array< SItemUniqueId >;
  4030.         var tmpName : name;
  4031.         var min, max : SAbilityAttributeValue;
  4032.        
  4033.         if( mutation12IsOnCooldown )
  4034.         {
  4035.             return;
  4036.         }
  4037.        
  4038.        
  4039.         existingDecoctionBuffs = GetDrunkMutagens( "Mutation12" );
  4040.         theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Mutation12', 'maxcap', min, max );
  4041.         if( existingDecoctionBuffs.Size() >= min.valueAdditive )
  4042.         {
  4043.             return;
  4044.         }
  4045.        
  4046.        
  4047.         mutation12IsOnCooldown = true;     
  4048.         theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Mutation12', 'cooldown', min, max );
  4049.         AddTimer( 'Mutation12Cooldown', CalculateAttributeValue( min ) );
  4050.        
  4051.        
  4052.         decoctions = inv.GetItemsByTag( 'Mutagen' );
  4053.        
  4054.        
  4055.         for( i=decoctions.Size()-1; i>=0; i-=1 )
  4056.         {
  4057.             inv.GetPotionItemBuffData( decoctions[i], effectType, tmpName );
  4058.             if( HasBuff( effectType ) )
  4059.             {
  4060.                 decoctions.EraseFast( i );
  4061.                 continue;
  4062.             }
  4063.             buffs.PushBack( effectType );
  4064.         }
  4065.        
  4066.        
  4067.         if( buffs.Size() == 0 )
  4068.         {
  4069.             for( i=EET_Mutagen01; i<=EET_Mutagen28; i+=1 )
  4070.             {
  4071.                 if( !HasBuff( i ) )
  4072.                 {
  4073.                     buffs.PushBack( i );
  4074.                 }
  4075.             }
  4076.         }
  4077.        
  4078.        
  4079.         buffs.Remove( EET_Mutagen16 );
  4080.         buffs.Remove( EET_Mutagen24 );
  4081.        
  4082.        
  4083.         if( buffs.Size() == 0 )
  4084.         {
  4085.             return;
  4086.         }
  4087.        
  4088.        
  4089.         theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Mutation12', 'duration', min, max );
  4090.         params.effectType = buffs[ RandRange( buffs.Size() ) ];
  4091.         params.creator = this;
  4092.         params.sourceName = "Mutation12";
  4093.         params.duration = min.valueAdditive;
  4094.         AddEffectCustom( params );
  4095.         ( ( W3Mutagen_Effect ) GetBuff( params.effectType, params.sourceName ) ).OverrideIcon( DecoctionEffectTypeToItemName( params.effectType ) );
  4096.        
  4097.        
  4098.         if ( !IsEffectActive( 'invisible' ) )
  4099.         {
  4100.             PlayEffect( 'use_potion' );
  4101.         }
  4102.        
  4103.         theGame.MutationHUDFeedback( MFT_PlayOnce );
  4104.     }
  4105.    
  4106.     timer function Mutation12Cooldown( dt : float, id : int )
  4107.     {
  4108.         mutation12IsOnCooldown = false;
  4109.     }
  4110.    
  4111.    
  4112.     public final function HasResourcesToStartAnyMutationResearch() : bool
  4113.     {
  4114.         var greenPoints, redPoints, bluePoints, count : int;
  4115.         var itemIDs : array< SItemUniqueId >;
  4116.        
  4117.         if( levelManager.GetPointsFree( ESkillPoint ) > 0 )
  4118.         {
  4119.             return true;
  4120.         }
  4121.        
  4122.        
  4123.         count = inv.GetItemQuantityByName( 'Greater mutagen green' );
  4124.         if( count > 0 )
  4125.         {
  4126.             itemIDs = inv.GetItemsByName( 'Greater mutagen green' );
  4127.             greenPoints = inv.GetMutationResearchPoints( SC_Green, itemIDs[0] );
  4128.             if( greenPoints > 0 )
  4129.             {
  4130.                 return true;
  4131.             }
  4132.         }  
  4133.         count = inv.GetItemQuantityByName( 'Greater mutagen red' );
  4134.         if( count > 0 )
  4135.         {
  4136.             itemIDs.Clear();
  4137.             itemIDs = inv.GetItemsByName( 'Greater mutagen red' );
  4138.             redPoints = inv.GetMutationResearchPoints( SC_Red, itemIDs[0] );
  4139.             if( redPoints > 0 )
  4140.             {
  4141.                 return true;
  4142.             }
  4143.         }      
  4144.         count = inv.GetItemQuantityByName( 'Greater mutagen blue' );
  4145.         if( count > 0 )
  4146.         {
  4147.             itemIDs.Clear();
  4148.             itemIDs = inv.GetItemsByName( 'Greater mutagen blue' );
  4149.             bluePoints = inv.GetMutationResearchPoints( SC_Blue, itemIDs[0] );
  4150.             if( bluePoints > 0 )
  4151.             {
  4152.                 return true;
  4153.             }
  4154.         }      
  4155.        
  4156.         return false;
  4157.     }
  4158.    
  4159.    
  4160.     public final function Mutation11StartAnimation()
  4161.     {
  4162.        
  4163.         thePlayer.ActionPlaySlotAnimationAsync( 'PLAYER_SLOT', 'geralt_mutation_11', 0.2, 0.2 );
  4164.        
  4165.        
  4166.         BlockAllActions( 'Mutation11', true );
  4167.        
  4168.        
  4169.         loopingCameraShakeAnimName = 'camera_shake_loop_lvl1_1';
  4170.         GCameraShake( 1.0f, , , , true, loopingCameraShakeAnimName );
  4171.        
  4172.        
  4173.         theGame.VibrateControllerVeryHard( 15.f );
  4174.        
  4175.        
  4176.         storedInteractionPriority = GetInteractionPriority();
  4177.         SetInteractionPriority( IP_Max_Unpushable );
  4178.     }
  4179.    
  4180.     event OnAnimEvent_Mutation11ShockWave( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  4181.     {
  4182.         Mutation11ShockWave( false );
  4183.     }
  4184.    
  4185.     private final function Mutation11ShockWave( skipQuenSign : bool )
  4186.     {
  4187.         var action : W3DamageAction;
  4188.         var ents : array< CGameplayEntity >;
  4189.         var i, j : int;
  4190.         var damages : array< SRawDamage >;
  4191.    
  4192.        
  4193.         FindGameplayEntitiesInSphere(ents, GetWorldPosition(), 5.f, 1000, '', FLAG_OnlyAliveActors + FLAG_ExcludeTarget + FLAG_Attitude_Hostile + FLAG_Attitude_Neutral, this);
  4194.        
  4195.         if( ents.Size() > 0 )
  4196.         {
  4197.             damages = theGame.GetDefinitionsManager().GetDamagesFromAbility( 'Mutation11' );
  4198.         }
  4199.        
  4200.        
  4201.         for(i=0; i<ents.Size(); i+=1)
  4202.         {
  4203.             action = new W3DamageAction in theGame;
  4204.             action.Initialize( this, ents[i], NULL, "Mutation11", EHRT_Heavy, CPS_SpellPower, false, false, true, false );
  4205.            
  4206.             for( j=0; j<damages.Size(); j+=1 )
  4207.             {
  4208.                 action.AddDamage( damages[j].dmgType, damages[j].dmgVal );
  4209.             }
  4210.            
  4211.             action.SetCannotReturnDamage( true );
  4212.             action.SetProcessBuffsIfNoDamage( true );
  4213.             action.AddEffectInfo( EET_KnockdownTypeApplicator );
  4214.             action.SetHitAnimationPlayType( EAHA_ForceYes );
  4215.             action.SetCanPlayHitParticle( false );
  4216.            
  4217.             theGame.damageMgr.ProcessAction( action );
  4218.             delete action;
  4219.         }
  4220.        
  4221.        
  4222.        
  4223.        
  4224.        
  4225.         mutation11QuenEntity = ( W3QuenEntity )GetSignEntity( ST_Quen );
  4226.         if( !mutation11QuenEntity )
  4227.         {
  4228.             mutation11QuenEntity = (W3QuenEntity)theGame.CreateEntity( GetSignTemplate( ST_Quen ), GetWorldPosition(), GetWorldRotation() );
  4229.             mutation11QuenEntity.CreateAttachment( this, 'quen_sphere' );
  4230.             AddTimer( 'DestroyMutation11QuenEntity', 2.f );
  4231.         }
  4232.         mutation11QuenEntity.PlayHitEffect( 'quen_impulse_explode', mutation11QuenEntity.GetWorldRotation() );
  4233.        
  4234.         if( !skipQuenSign )
  4235.         {
  4236.            
  4237.             PlayEffect( 'mutation_11_second_life' );
  4238.            
  4239.            
  4240.             RestoreQuen( 1000000.f, 10.f, true );
  4241.         }
  4242.     }
  4243.    
  4244.     private var mutation11QuenEntity : W3QuenEntity;
  4245.     private var storedInteractionPriority : EInteractionPriority;
  4246.    
  4247.     timer function DestroyMutation11QuenEntity( dt : float, id : int )
  4248.     {
  4249.         if( mutation11QuenEntity )
  4250.         {
  4251.             mutation11QuenEntity.Destroy();
  4252.         }
  4253.     }
  4254.    
  4255.     event OnAnimEvent_Mutation11AnimEnd( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  4256.     {
  4257.         if( animEventType == AET_DurationEnd )
  4258.         {
  4259.            
  4260.             BlockAllActions( 'Mutation11', false );        
  4261.            
  4262.            
  4263.             theGame.GetGameCamera().StopAnimation( 'camera_shake_loop_lvl1_1' );
  4264.            
  4265.            
  4266.             theGame.StopVibrateController();
  4267.            
  4268.            
  4269.             SetInteractionPriority( storedInteractionPriority );
  4270.            
  4271.            
  4272.             RemoveBuff( EET_Mutation11Buff, true );
  4273.         }
  4274.         else if ( animEventType == AET_DurationStart || animEventType == AET_DurationStartInTheMiddle )
  4275.         {
  4276.            
  4277.             SetBehaviorVariable( 'AIControlled', 0.f );
  4278.         }
  4279.     }
  4280.        
  4281.     public final function MutationSystemEnable( enable : bool )
  4282.     {
  4283.         ( ( W3PlayerAbilityManager ) abilityManager ).MutationSystemEnable( enable );
  4284.     }
  4285.    
  4286.     public final function IsMutationSystemEnabled() : bool
  4287.     {
  4288.         return ( ( W3PlayerAbilityManager ) abilityManager ).IsMutationSystemEnabled();
  4289.     }
  4290.    
  4291.     public final function GetMutation( mutationType : EPlayerMutationType ) : SMutation
  4292.     {
  4293.         return ( ( W3PlayerAbilityManager ) abilityManager ).GetMutation( mutationType );
  4294.     }
  4295.    
  4296.     public final function IsMutationActive( mutationType : EPlayerMutationType) : bool
  4297.     {
  4298.         var swordQuality : int;
  4299.         var sword : SItemUniqueId;
  4300.        
  4301.         if( GetEquippedMutationType() != mutationType )
  4302.         {
  4303.             return false;
  4304.         }
  4305.        
  4306.         switch( mutationType )
  4307.         {
  4308.             case EPMT_Mutation4 :
  4309.             case EPMT_Mutation5 :
  4310.             case EPMT_Mutation7 :
  4311.             case EPMT_Mutation8 :
  4312.             case EPMT_Mutation10 :
  4313.             case EPMT_Mutation11 :
  4314.             case EPMT_Mutation12 :
  4315.                 if( IsInFistFight() )
  4316.                 {
  4317.                     return false;
  4318.                 }
  4319.         }
  4320.        
  4321.         if( mutationType == EPMT_Mutation1 )
  4322.         {
  4323.             sword = inv.GetCurrentlyHeldSword();           
  4324.             swordQuality = inv.GetItemQuality( sword );
  4325.            
  4326.            
  4327.             if( swordQuality < 3 )
  4328.             {
  4329.                 return false;
  4330.             }
  4331.         }
  4332.        
  4333.         return true;
  4334.     }
  4335.        
  4336.     public final function SetEquippedMutation( mutationType : EPlayerMutationType ) : bool
  4337.     {
  4338.         return ( ( W3PlayerAbilityManager ) abilityManager ).SetEquippedMutation( mutationType );
  4339.     }
  4340.    
  4341.     public final function GetEquippedMutationType() : EPlayerMutationType
  4342.     {
  4343.         return ( ( W3PlayerAbilityManager ) abilityManager ).GetEquippedMutationType();
  4344.     }
  4345.    
  4346.     public final function CanEquipMutation(mutationType : EPlayerMutationType) : bool
  4347.     {
  4348.         return ( ( W3PlayerAbilityManager ) abilityManager ).CanEquipMutation( mutationType );
  4349.     }
  4350.    
  4351.     public final function CanResearchMutation( mutationType : EPlayerMutationType ) : bool
  4352.     {
  4353.         return ( ( W3PlayerAbilityManager ) abilityManager ).CanResearchMutation( mutationType );
  4354.     }
  4355.    
  4356.     public final function IsMutationResearched(mutationType : EPlayerMutationType) : bool
  4357.     {
  4358.         return ( ( W3PlayerAbilityManager ) abilityManager ).IsMutationResearched( mutationType );
  4359.     }
  4360.    
  4361.     public final function GetMutationResearchProgress(mutationType : EPlayerMutationType) : int
  4362.     {
  4363.         return ( ( W3PlayerAbilityManager ) abilityManager ).GetMutationResearchProgress( mutationType );
  4364.     }
  4365.    
  4366.     public final function GetMasterMutationStage() : int
  4367.     {
  4368.         return ( ( W3PlayerAbilityManager ) abilityManager ).GetMasterMutationStage();
  4369.     }
  4370.    
  4371.     public final function MutationResearchWithSkillPoints(mutation : EPlayerMutationType, skillPoints : int) : bool
  4372.     {
  4373.         return ( ( W3PlayerAbilityManager ) abilityManager ).MutationResearchWithSkillPoints( mutation, skillPoints );
  4374.     }
  4375.    
  4376.     public final function MutationResearchWithItem(mutation : EPlayerMutationType, item : SItemUniqueId, optional count: int) : bool
  4377.     {
  4378.         return ( ( W3PlayerAbilityManager ) abilityManager ).MutationResearchWithItem( mutation, item, count );
  4379.     }
  4380.    
  4381.     public final function GetMutationLocalizedName( mutationType : EPlayerMutationType ) : string
  4382.     {
  4383.         var pam : W3PlayerAbilityManager;
  4384.         var locKey : name;
  4385.    
  4386.         pam = (W3PlayerAbilityManager)GetWitcherPlayer().abilityManager;
  4387.         locKey = pam.GetMutationNameLocalizationKey( mutationType );
  4388.        
  4389.         return GetLocStringByKeyExt( locKey );
  4390.     }
  4391.    
  4392.     public final function GetMutationLocalizedDescription( mutationType : EPlayerMutationType ) : string
  4393.     {
  4394.         var pam : W3PlayerAbilityManager;
  4395.         var locKey : name;
  4396.         var arrStr : array< string >;
  4397.         var dm : CDefinitionsManagerAccessor;
  4398.         var min, max, sp : SAbilityAttributeValue;
  4399.         var tmp, tmp2, tox, critBonusDamage, val : float;
  4400.         var stats, stats2 : SPlayerOffenseStats;
  4401.         var buffPerc, exampleEnemyCount, debuffPerc : int;
  4402.    
  4403.         pam = (W3PlayerAbilityManager)GetWitcherPlayer().abilityManager;
  4404.         locKey = pam.GetMutationDescriptionLocalizationKey( mutationType );
  4405.         dm = theGame.GetDefinitionsManager();
  4406.        
  4407.         switch( mutationType )
  4408.         {
  4409.             case EPMT_Mutation1 :
  4410.                 dm.GetAbilityAttributeValue('Mutation1', 'dmg_bonus_factor', min, max);                        
  4411.                 arrStr.PushBack( NoTrailZeros( RoundMath( 100 * min.valueAdditive ) ) );
  4412.                 break;
  4413.                
  4414.             case EPMT_Mutation2 :
  4415.                 sp = GetPowerStatValue( CPS_SpellPower );
  4416.                
  4417.                
  4418.                 dm.GetAbilityAttributeValue( 'Mutation2', 'crit_chance_factor', min, max );
  4419.                 arrStr.PushBack( NoTrailZeros( RoundMath( 100 * ( min.valueAdditive + sp.valueMultiplicative * min.valueMultiplicative ) ) ) );
  4420.                
  4421.                
  4422.                 dm.GetAbilityAttributeValue( 'Mutation2', 'crit_damage_factor', min, max );
  4423.                 critBonusDamage = sp.valueMultiplicative * min.valueMultiplicative;
  4424.                
  4425.                 arrStr.PushBack( NoTrailZeros( RoundMath( 100 * critBonusDamage ) ) );
  4426.                 break;
  4427.                
  4428.             case EPMT_Mutation3 :
  4429.                
  4430.                 dm.GetAbilityAttributeValue( 'Mutation3', 'attack_power', min, max );
  4431.                 tmp = min.valueMultiplicative;
  4432.                 arrStr.PushBack( NoTrailZeros( RoundMath( 100 * tmp ) ) );
  4433.                
  4434.                
  4435.                 dm.GetAbilityAttributeValue( 'Mutation3', 'maxcap', min, max );
  4436.                 arrStr.PushBack( NoTrailZeros( RoundMath( 100 * tmp * min.valueAdditive ) ) );
  4437.                 break;
  4438.                
  4439.             case EPMT_Mutation4 :
  4440.                
  4441.                 dm.GetAbilityAttributeValue( 'AcidEffect', 'DirectDamage', min, max );
  4442.                 tmp2 = 100 * min.valueAdditive;
  4443.                 dm.GetAbilityAttributeValue( 'AcidEffect', 'duration', min, max );
  4444.                 tmp2 *= min.valueAdditive;
  4445.                 arrStr.PushBack( NoTrailZeros( tmp2 ) );
  4446.                
  4447.                
  4448.                 tox = GetStat( BCS_Toxicity );
  4449.                 if( tox > 0 )
  4450.                 {
  4451.                     tmp = RoundMath( tmp2 * tox );
  4452.                 }
  4453.                 else
  4454.                 {
  4455.                     tmp = tmp2;
  4456.                 }
  4457.                 arrStr.PushBack( NoTrailZeros( tmp ) );
  4458.                
  4459.                
  4460.                 tox = GetStatMax( BCS_Toxicity );
  4461.                 tmp = RoundMath( tmp2 * tox );
  4462.                 arrStr.PushBack( NoTrailZeros( tmp ) );
  4463.                 break;
  4464.                
  4465.             case EPMT_Mutation5 :
  4466.                
  4467.                 dm.GetAbilityAttributeValue( 'Mutation5', 'mut5_dmg_red_perc', min, max );
  4468.                 tmp = min.valueAdditive;
  4469.                 arrStr.PushBack( NoTrailZeros( 100 * tmp ) );
  4470.                
  4471.                
  4472.                 arrStr.PushBack( NoTrailZeros( 100 * tmp * 3 ) );
  4473.                
  4474.                 break;
  4475.            
  4476.             case EPMT_Mutation6 :  
  4477.                
  4478.                 theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Mutation6', 'full_freeze_chance', min, max );
  4479.                 arrStr.PushBack( NoTrailZeros( 100 * min.valueMultiplicative ) );  
  4480.                
  4481.                
  4482.                 theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Mutation6', 'ForceDamage', min, max );
  4483.                 sp = GetTotalSignSpellPower( S_Magic_1 );
  4484.                 val = sp.valueAdditive + sp.valueMultiplicative * ( sp.valueBase + min.valueAdditive );
  4485.                 arrStr.PushBack( NoTrailZeros( RoundMath( val ) ) );   
  4486.            
  4487.                 break;
  4488.                
  4489.             case EPMT_Mutation7 :
  4490.                
  4491.                 dm.GetAbilityAttributeValue( 'Mutation7Buff', 'attack_power', min, max );
  4492.                 buffPerc = (int) ( 100 * min.valueMultiplicative );
  4493.                 arrStr.PushBack( NoTrailZeros( buffPerc ) );
  4494.                
  4495.                
  4496.                 dm.GetAbilityAttributeValue( 'Mutation7BuffEffect', 'duration', min, max );
  4497.                 arrStr.PushBack( NoTrailZeros( min.valueAdditive ) );
  4498.                
  4499.                
  4500.                 exampleEnemyCount = 11;
  4501.                 arrStr.PushBack( exampleEnemyCount );
  4502.                
  4503.                
  4504.                 arrStr.PushBack( buffPerc * ( exampleEnemyCount -1 ) );
  4505.                
  4506.                
  4507.                 dm.GetAbilityAttributeValue( 'Mutation7Debuff', 'attack_power', min, max );
  4508.                 debuffPerc = (int) ( - 100 * min.valueMultiplicative );
  4509.                 arrStr.PushBack( NoTrailZeros( debuffPerc ) );
  4510.                
  4511.                
  4512.                 theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Mutation7Debuff', 'minCapStacks', min, max );
  4513.                 arrStr.PushBack( NoTrailZeros( debuffPerc * min.valueAdditive ) );
  4514.                
  4515.                
  4516.                 dm.GetAbilityAttributeValue( 'Mutation7DebuffEffect', 'duration', min, max );
  4517.                 arrStr.PushBack( NoTrailZeros( min.valueAdditive ) );
  4518.                    
  4519.                 break;
  4520.            
  4521.             case EPMT_Mutation8 :
  4522.                
  4523.                 dm.GetAbilityAttributeValue( 'Mutation8', 'dmg_bonus', min, max );
  4524.                 arrStr.PushBack( NoTrailZeros( 100 * min.valueMultiplicative ) );
  4525.                
  4526.                
  4527.                 dm.GetAbilityAttributeValue( 'Mutation8', 'hp_perc_trigger', min, max );
  4528.                 arrStr.PushBack( NoTrailZeros( 100 * min.valueMultiplicative ) );
  4529.                
  4530.                 break;
  4531.                
  4532.             case EPMT_Mutation9 :
  4533.                
  4534.                
  4535.                
  4536.                
  4537.                 stats = GetOffenseStatsList( 1 );
  4538.                 arrStr.PushBack( NoTrailZeros( RoundMath( stats.crossbowSteelDmg ) ) );
  4539.                
  4540.                
  4541.                 stats2 = GetOffenseStatsList( 2 );
  4542.                 arrStr.PushBack( NoTrailZeros( RoundMath( stats2.crossbowSteelDmg ) ) );
  4543.                
  4544.                
  4545.                 dm.GetAbilityAttributeValue( 'Mutation9', 'critical_hit_chance', min, max );
  4546.                 arrStr.PushBack( NoTrailZeros( 100 * min.valueMultiplicative ) );
  4547.                
  4548.                
  4549.                 dm.GetAbilityAttributeValue( 'Mutation9', 'health_reduction', min, max );
  4550.                 arrStr.PushBack( NoTrailZeros( 100 * min.valueMultiplicative ) );
  4551.                
  4552.                 break;
  4553.                
  4554.             case EPMT_Mutation10 :
  4555.                
  4556.                 dm.GetAbilityAttributeValue( 'Mutation10Effect', 'mutation10_stat_boost', min, max );
  4557.                 arrStr.PushBack( NoTrailZeros( 100 * min.valueMultiplicative ) );
  4558.                
  4559.                
  4560.                 arrStr.PushBack( NoTrailZeros( 100 * min.valueMultiplicative * GetStatMax( BCS_Toxicity ) ) );
  4561.                
  4562.                 break;
  4563.                
  4564.             case EPMT_Mutation11 :
  4565.                
  4566.                 arrStr.PushBack( 100 );
  4567.                
  4568.                
  4569.                 dm.GetAbilityAttributeValue( 'Mutation11DebuffEffect', 'duration', min, max);
  4570.                 arrStr.PushBack( NoTrailZeros( min.valueAdditive ) );
  4571.                 break;
  4572.                
  4573.             case EPMT_Mutation12 :
  4574.                
  4575.                 dm.GetAbilityAttributeValue( 'Mutation12', 'duration', min, max );
  4576.                 arrStr.PushBack( NoTrailZeros( min.valueAdditive ) );              
  4577.                
  4578.                
  4579.                 dm.GetAbilityAttributeValue( 'Mutation12', 'maxcap', min, max );
  4580.                 arrStr.PushBack( NoTrailZeros( min.valueAdditive ) );  
  4581.                 break;
  4582.                
  4583.             case EPMT_MutationMaster :
  4584.                
  4585.                 arrStr.PushBack( "4" );
  4586.                
  4587.                 break;
  4588.         }
  4589.        
  4590.         return GetLocStringByKeyExtWithParams( locKey, , , arrStr );
  4591.     }
  4592.        
  4593.     public final function ApplyMutation10StatBoost( out statValue : SAbilityAttributeValue )
  4594.     {
  4595.         var attValue            : SAbilityAttributeValue;
  4596.         var currToxicity        : float;
  4597.        
  4598.         if( IsMutationActive( EPMT_Mutation10 ) )
  4599.         {
  4600.             currToxicity = GetStat( BCS_Toxicity );
  4601.             if( currToxicity > 0.f )
  4602.             {
  4603.                 attValue = GetAttributeValue( 'mutation10_stat_boost' );
  4604.                 currToxicity *= attValue.valueMultiplicative;
  4605.                 statValue.valueMultiplicative += currToxicity;
  4606.             }
  4607.         }
  4608.     }
  4609.  
  4610.    
  4611.    
  4612.    
  4613.    
  4614.    
  4615.  
  4616.     public final function IsBookRead( bookName : name ):bool
  4617.     {
  4618.         return booksRead.Contains( bookName );
  4619.     }  
  4620.    
  4621.     public final function AddReadBook( bookName : name ):void
  4622.     {
  4623.         if( !booksRead.Contains( bookName ) )
  4624.         {
  4625.             booksRead.PushBack( bookName );
  4626.         }
  4627.     }
  4628.    
  4629.     public final function RemoveReadBook( bookName : name ):void
  4630.     {
  4631.         var idx : int = booksRead.FindFirst( bookName );
  4632.        
  4633.         if( idx > -1 )
  4634.         {
  4635.             booksRead.Erase( idx );
  4636.         }
  4637.     }
  4638.    
  4639.    
  4640.    
  4641.    
  4642.    
  4643.    
  4644.    
  4645.     public final function GetMutagenBuffs() : array< W3Mutagen_Effect >
  4646.     {
  4647.         var null : array< W3Mutagen_Effect >;
  4648.        
  4649.         if(effectManager)
  4650.         {
  4651.             return effectManager.GetMutagenBuffs();
  4652.         }
  4653.    
  4654.         return null;
  4655.     }
  4656.    
  4657.     public function GetAlchemyRecipes() : array<name>
  4658.     {
  4659.         return alchemyRecipes;
  4660.     }
  4661.        
  4662.     public function CanLearnAlchemyRecipe(recipeName : name) : bool
  4663.     {
  4664.         var dm : CDefinitionsManagerAccessor;
  4665.         var recipeNode : SCustomNode;
  4666.         var i, tmpInt : int;
  4667.         var tmpName : name;
  4668.    
  4669.         dm = theGame.GetDefinitionsManager();
  4670.         if ( dm.GetSubNodeByAttributeValueAsCName( recipeNode, 'alchemy_recipes', 'name_name', recipeName ) )
  4671.         {
  4672.             return true;
  4673.            
  4674.         }
  4675.        
  4676.         return false;
  4677.     }
  4678.    
  4679.     private final function RemoveAlchemyRecipe(recipeName : name)
  4680.     {
  4681.         alchemyRecipes.Remove(recipeName);
  4682.     }
  4683.    
  4684.     private final function RemoveAllAlchemyRecipes()
  4685.     {
  4686.         alchemyRecipes.Clear();
  4687.     }
  4688.  
  4689.    
  4690.     function AddAlchemyRecipe(nam : name, optional isSilent : bool, optional skipTutorialUpdate : bool) : bool
  4691.     {
  4692.         var i, potions, bombs : int;
  4693.         var found : bool;
  4694.         var m_alchemyManager : W3AlchemyManager;
  4695.         var recipe : SAlchemyRecipe;
  4696.         var knownBombTypes : array<string>;
  4697.         var strRecipeName, recipeNameWithoutLevel : string;
  4698.        
  4699.         if(!IsAlchemyRecipe(nam))
  4700.             return false;
  4701.        
  4702.         found = false;
  4703.         for(i=0; i<alchemyRecipes.Size(); i+=1)
  4704.         {
  4705.             if(alchemyRecipes[i] == nam)
  4706.                 return false;
  4707.            
  4708.            
  4709.             if(StrCmp(alchemyRecipes[i],nam) > 0)
  4710.             {
  4711.                 alchemyRecipes.Insert(i,nam);
  4712.                 found = true;
  4713.                 AddAlchemyHudNotification(nam,isSilent);
  4714.                 break;
  4715.             }          
  4716.         }  
  4717.  
  4718.         if(!found)
  4719.         {
  4720.             alchemyRecipes.PushBack(nam);
  4721.             AddAlchemyHudNotification(nam,isSilent);
  4722.         }
  4723.        
  4724.         m_alchemyManager = new W3AlchemyManager in this;
  4725.         m_alchemyManager.Init(alchemyRecipes);
  4726.         m_alchemyManager.GetRecipe(nam, recipe);
  4727.            
  4728.        
  4729.         if(CanUseSkill(S_Alchemy_s18))
  4730.         {
  4731.             if ((recipe.cookedItemType != EACIT_Bolt) && (recipe.cookedItemType != EACIT_Undefined) && (recipe.cookedItemType != EACIT_Dye) && (recipe.level <= GetSkillLevel(S_Alchemy_s18)))
  4732.                 AddAbility(SkillEnumToName(S_Alchemy_s18), true);
  4733.            
  4734.         }
  4735.        
  4736.        
  4737.         if(recipe.cookedItemType == EACIT_Bomb)
  4738.         {
  4739.             bombs = 0;
  4740.             for(i=0; i<alchemyRecipes.Size(); i+=1)
  4741.             {
  4742.                 m_alchemyManager.GetRecipe(alchemyRecipes[i], recipe);
  4743.                
  4744.                
  4745.                 if(recipe.cookedItemType == EACIT_Bomb)
  4746.                 {
  4747.                     strRecipeName = NameToString(alchemyRecipes[i]);
  4748.                     recipeNameWithoutLevel = StrLeft(strRecipeName, StrLen(strRecipeName)-2);
  4749.                     if(!knownBombTypes.Contains(recipeNameWithoutLevel))
  4750.                     {
  4751.                         bombs += 1;
  4752.                         knownBombTypes.PushBack(recipeNameWithoutLevel);
  4753.                     }
  4754.                 }
  4755.             }
  4756.            
  4757.             theGame.GetGamerProfile().SetStat(ES_KnownBombRecipes, bombs);
  4758.         }      
  4759.        
  4760.         else if(recipe.cookedItemType == EACIT_Potion || recipe.cookedItemType == EACIT_MutagenPotion || recipe.cookedItemType == EACIT_Alcohol || recipe.cookedItemType == EACIT_Quest)
  4761.         {
  4762.             potions = 0;
  4763.             for(i=0; i<alchemyRecipes.Size(); i+=1)
  4764.             {
  4765.                 m_alchemyManager.GetRecipe(alchemyRecipes[i], recipe);
  4766.                
  4767.                
  4768.                 if(recipe.cookedItemType == EACIT_Potion || recipe.cookedItemType == EACIT_MutagenPotion || recipe.cookedItemType == EACIT_Alcohol || recipe.cookedItemType == EACIT_Quest)
  4769.                 {
  4770.                     potions += 1;
  4771.                 }              
  4772.             }      
  4773.             theGame.GetGamerProfile().SetStat(ES_KnownPotionRecipes, potions);
  4774.         }
  4775.        
  4776.         theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_AlchemyRecipe );
  4777.                
  4778.         return true;
  4779.     }
  4780.    
  4781.     public function GetExpandedAlchemyCategories() : array< name >
  4782.     {
  4783.         return expandedAlchemyCategories;
  4784.     }
  4785.    
  4786.     public function AddExpandedAlchemyCategory( category : name )
  4787.     {
  4788.         if ( IsNameValid( category ) )
  4789.         {
  4790.             ArrayOfNamesPushBackUnique( expandedAlchemyCategories, category );
  4791.         }
  4792.     }
  4793.  
  4794.     public function RemoveExpandedAlchemyCategory( category : name )
  4795.     {
  4796.         if ( IsNameValid( category ) )
  4797.         {
  4798.             expandedAlchemyCategories.Remove( category );
  4799.         }
  4800.     }
  4801.    
  4802.     public function SetAlchemyFilters(showHasIngre : bool, showMissingIngre : bool, showAlreadyCrafted : bool )
  4803.     {
  4804.         alchemyFilters.showCraftable = showHasIngre;
  4805.         alchemyFilters.showMissingIngre = showMissingIngre;
  4806.         alchemyFilters.showAlreadyCrafted = showAlreadyCrafted;
  4807.     }
  4808.    
  4809.     public function GetAlchemyFilters() : SCraftingFilters
  4810.     {
  4811.        
  4812.         if ( alchemyFilters.showCraftable == false && alchemyFilters.showMissingIngre == false && alchemyFilters.showAlreadyCrafted == false )
  4813.         {
  4814.             alchemyFilters.showCraftable = true;
  4815.             alchemyFilters.showMissingIngre = true;
  4816.             alchemyFilters.showAlreadyCrafted = false;
  4817.         }
  4818.  
  4819.         return alchemyFilters;
  4820.     }
  4821.    
  4822.    
  4823.    
  4824.    
  4825.    
  4826.    
  4827.  
  4828.     public function GetExpandedBestiaryCategories() : array< name >
  4829.     {
  4830.         return expandedBestiaryCategories;
  4831.     }
  4832.    
  4833.     public function AddExpandedBestiaryCategory( category : name )
  4834.     {
  4835.         if ( IsNameValid( category ) )
  4836.         {
  4837.             ArrayOfNamesPushBackUnique( expandedBestiaryCategories, category );
  4838.         }
  4839.     }
  4840.  
  4841.     public function RemoveExpandedBestiaryCategory( category : name )
  4842.     {
  4843.         if ( IsNameValid( category ) )
  4844.         {
  4845.             expandedBestiaryCategories.Remove( category );
  4846.         }
  4847.     }
  4848.    
  4849.    
  4850.    
  4851.    
  4852.    
  4853.    
  4854.    
  4855.     public function GetDisplayHeavyAttackIndicator() : bool
  4856.     {
  4857.         return bDispalyHeavyAttackIndicator;
  4858.     }
  4859.  
  4860.     public function SetDisplayHeavyAttackIndicator( val : bool )
  4861.     {
  4862.         bDispalyHeavyAttackIndicator = val;
  4863.     }
  4864.  
  4865.     public function GetDisplayHeavyAttackFirstLevelTimer() : bool
  4866.     {
  4867.         return bDisplayHeavyAttackFirstLevelTimer;
  4868.     }
  4869.  
  4870.     public function SetDisplayHeavyAttackFirstLevelTimer( val : bool )
  4871.     {
  4872.         bDisplayHeavyAttackFirstLevelTimer = val;
  4873.     }
  4874.    
  4875.    
  4876.    
  4877.    
  4878.    
  4879.    
  4880.  
  4881.     public function SelectQuickslotItem( slot : EEquipmentSlots )
  4882.     {
  4883.         var item : SItemUniqueId;
  4884.    
  4885.         GetItemEquippedOnSlot(slot, item);
  4886.         selectedItemId = item;         
  4887.     }  
  4888.    
  4889.    
  4890.    
  4891.    
  4892.    
  4893.    
  4894.    
  4895.     public function GetMedallion() : W3MedallionController
  4896.     {
  4897.         if ( !medallionController )
  4898.         {
  4899.             medallionController = new W3MedallionController in this;
  4900.         }
  4901.         return medallionController;
  4902.     }
  4903.    
  4904.    
  4905.     public final function HighlightObjects(range : float, optional highlightTime : float )
  4906.     {
  4907.         var ents : array<CGameplayEntity>;
  4908.         var i : int;
  4909.  
  4910.         FindGameplayEntitiesInSphere(ents, GetWorldPosition(), range, 100, 'HighlightedByMedalionFX', FLAG_ExcludePlayer);
  4911.  
  4912.         if(highlightTime == 0)
  4913.             highlightTime = 30;
  4914.        
  4915.         for(i=0; i<ents.Size(); i+=1)
  4916.         {
  4917.             if(!ents[i].IsHighlighted())
  4918.             {
  4919.                 ents[i].SetHighlighted( true );
  4920.                 ents[i].PlayEffectSingle( 'medalion_detection_fx' );
  4921.                 ents[i].AddTimer( 'MedallionEffectOff', highlightTime );
  4922.             }
  4923.         }
  4924.     }
  4925.    
  4926.    
  4927.     public final function HighlightEnemies(range : float, optional highlightTime : float )
  4928.     {
  4929.         var ents : array<CGameplayEntity>;
  4930.         var i : int;
  4931.         var catComponent : CGameplayEffectsComponent;
  4932.  
  4933.         FindGameplayEntitiesInSphere(ents, GetWorldPosition(), range, 100, , FLAG_ExcludePlayer + FLAG_OnlyAliveActors);
  4934.  
  4935.         if(highlightTime == 0)
  4936.             highlightTime = 5;
  4937.        
  4938.         for(i=0; i<ents.Size(); i+=1)
  4939.         {
  4940.             if(IsRequiredAttitudeBetween(this, ents[i], true))
  4941.             {
  4942.                 catComponent = GetGameplayEffectsComponent(ents[i]);
  4943.                 if(catComponent)
  4944.                 {
  4945.                     catComponent.SetGameplayEffectFlag(EGEF_CatViewHiglight, true);
  4946.                     ents[i].AddTimer( 'EnemyHighlightOff', highlightTime, , , , , true );
  4947.                 }
  4948.             }
  4949.         }
  4950.     }  
  4951.    
  4952.     function SpawnMedallionEntity()
  4953.     {
  4954.         var rot                 : EulerAngles;
  4955.         var spawnedMedallion    : CEntity;
  4956.                
  4957.         spawnedMedallion = theGame.GetEntityByTag( 'new_Witcher_medallion_FX' );
  4958.        
  4959.         if ( !spawnedMedallion )
  4960.             theGame.CreateEntity( medallionEntity, GetWorldPosition(), rot, true, false );
  4961.     }
  4962.    
  4963.    
  4964.    
  4965.    
  4966.    
  4967.    
  4968.    
  4969.    
  4970.    
  4971.     public final function InterruptCombatFocusMode()
  4972.     {
  4973.         if( this.GetCurrentStateName() == 'CombatFocusMode_SelectSpot' )
  4974.         {  
  4975.             SetCanPlayHitAnim( true );
  4976.             PopState();
  4977.         }
  4978.     }
  4979.    
  4980.     public final function IsInDarkPlace() : bool
  4981.     {
  4982.         var envs : array< string >;
  4983.        
  4984.         if( FactsQuerySum( "tut_in_dark_place" ) )
  4985.         {
  4986.             return true;
  4987.         }
  4988.        
  4989.         GetActiveAreaEnvironmentDefinitions( envs );
  4990.        
  4991.         if( envs.Contains( 'env_novigrad_cave' ) || envs.Contains( 'cave_catacombs' ) )
  4992.         {
  4993.             return true;
  4994.         }
  4995.        
  4996.         return false;
  4997.     }
  4998.    
  4999.    
  5000.    
  5001.    
  5002.    
  5003.     private saved var selectedPotionSlotUpper, selectedPotionSlotLower : EEquipmentSlots;
  5004.     private var potionDoubleTapTimerRunning, potionDoubleTapSlotIsUpper : bool;
  5005.         default selectedPotionSlotUpper = EES_Potion1;
  5006.         default selectedPotionSlotLower = EES_Potion2;
  5007.         default potionDoubleTapTimerRunning = false;
  5008.    
  5009.     public final function SetPotionDoubleTapRunning(b : bool, optional isUpperSlot : bool)
  5010.     {
  5011.         if(b)
  5012.         {
  5013.             AddTimer('PotionDoubleTap', 0.3);
  5014.         }
  5015.         else
  5016.         {
  5017.             RemoveTimer('PotionDoubleTap');
  5018.         }
  5019.        
  5020.         potionDoubleTapTimerRunning = b;
  5021.         potionDoubleTapSlotIsUpper = isUpperSlot;
  5022.     }
  5023.    
  5024.     public final function IsPotionDoubleTapRunning() : bool
  5025.     {
  5026.         return potionDoubleTapTimerRunning;
  5027.     }
  5028.    
  5029.     timer function PotionDoubleTap(dt : float, id : int)
  5030.     {
  5031.         potionDoubleTapTimerRunning = false;
  5032.         OnPotionDrinkInput(potionDoubleTapSlotIsUpper);
  5033.     }
  5034.    
  5035.     public final function OnPotionDrinkInput(fromUpperSlot : bool)
  5036.     {
  5037.         var slot : EEquipmentSlots;
  5038.        
  5039.         if(fromUpperSlot)
  5040.             slot = GetSelectedPotionSlotUpper();
  5041.         else
  5042.             slot = GetSelectedPotionSlotLower();
  5043.            
  5044.         DrinkPotionFromSlot(slot);
  5045.     }
  5046.    
  5047.     public final function OnPotionDrinkKeyboardsInput(slot : EEquipmentSlots)
  5048.     {
  5049.         DrinkPotionFromSlot(slot);
  5050.     }
  5051.    
  5052.     private function DrinkPotionFromSlot(slot : EEquipmentSlots):void
  5053.     {
  5054.         var item : SItemUniqueId;      
  5055.         var hud : CR4ScriptedHud;
  5056.         var module : CR4HudModuleItemInfo;
  5057.        
  5058.         GetItemEquippedOnSlot(slot, item);
  5059.         if(inv.ItemHasTag(item, 'Edibles'))
  5060.         {
  5061.             ConsumeItem( item );
  5062.         }
  5063.         else
  5064.         {          
  5065.             if (ToxicityLowEnoughToDrinkPotion(slot))
  5066.             {
  5067.                 DrinkPreparedPotion(slot);
  5068.             }
  5069.             else
  5070.             {
  5071.                 SendToxicityTooHighMessage();
  5072.             }
  5073.         }
  5074.        
  5075.         hud = (CR4ScriptedHud)theGame.GetHud();
  5076.         if ( hud )
  5077.         {
  5078.             module = (CR4HudModuleItemInfo)hud.GetHudModule("ItemInfoModule");
  5079.             if( module )
  5080.             {
  5081.                 module.ForceShowElement();
  5082.             }
  5083.         }
  5084.     }
  5085.    
  5086.     private function SendToxicityTooHighMessage()
  5087.     {
  5088.         var messageText : string;
  5089.         var language : string;
  5090.         var audioLanguage : string;
  5091.        
  5092.         if (GetHudMessagesSize() < 2)
  5093.         {
  5094.             messageText = GetLocStringByKeyExt("menu_cannot_perform_action_now") + " " + GetLocStringByKeyExt("panel_common_statistics_tooltip_current_toxicity");
  5095.            
  5096.             theGame.GetGameLanguageName(audioLanguage,language);
  5097.             if (language == "AR")
  5098.             {
  5099.                 messageText += (int)(abilityManager.GetStat(BCS_Toxicity, false)) + " / " +  (int)(abilityManager.GetStatMax(BCS_Toxicity)) + " :";
  5100.             }
  5101.             else
  5102.             {
  5103.                 messageText += ": " + (int)(abilityManager.GetStat(BCS_Toxicity, false)) + " / " +  (int)(abilityManager.GetStatMax(BCS_Toxicity));
  5104.             }
  5105.            
  5106.             DisplayHudMessage(messageText);
  5107.         }
  5108.         theSound.SoundEvent("gui_global_denied");
  5109.     }
  5110.    
  5111.     public final function GetSelectedPotionSlotUpper() : EEquipmentSlots
  5112.     {
  5113.         return selectedPotionSlotUpper;
  5114.     }
  5115.    
  5116.     public final function GetSelectedPotionSlotLower() : EEquipmentSlots
  5117.     {
  5118.         return selectedPotionSlotLower;
  5119.     }
  5120.    
  5121.    
  5122.     public final function FlipSelectedPotion(isUpperSlot : bool) : bool
  5123.     {
  5124.         if(isUpperSlot)
  5125.         {
  5126.             if(selectedPotionSlotUpper == EES_Potion1 && IsAnyItemEquippedOnSlot(EES_Potion3))
  5127.             {
  5128.                 selectedPotionSlotUpper = EES_Potion3;
  5129.                 return true;
  5130.             }
  5131.             else if(selectedPotionSlotUpper == EES_Potion3 && IsAnyItemEquippedOnSlot(EES_Potion1))
  5132.             {
  5133.                 selectedPotionSlotUpper = EES_Potion1;
  5134.                 return true;
  5135.             }
  5136.         }
  5137.         else
  5138.         {
  5139.             if(selectedPotionSlotLower == EES_Potion2 && IsAnyItemEquippedOnSlot(EES_Potion4))
  5140.             {
  5141.                 selectedPotionSlotLower = EES_Potion4;
  5142.                 return true;
  5143.             }
  5144.             else if(selectedPotionSlotLower == EES_Potion4 && IsAnyItemEquippedOnSlot(EES_Potion2))
  5145.             {
  5146.                 selectedPotionSlotLower = EES_Potion2;
  5147.                 return true;
  5148.             }
  5149.         }
  5150.        
  5151.         return false;
  5152.     }
  5153.    
  5154.     public final function AddBombThrowDelay( bombId : SItemUniqueId )
  5155.     {
  5156.         var slot : EEquipmentSlots;
  5157.        
  5158.         slot = GetItemSlot( bombId );
  5159.        
  5160.         if( slot == EES_Unused )
  5161.         {
  5162.             return;
  5163.         }
  5164.            
  5165.         if( slot == EES_Petard1 || slot == EES_Quickslot1 )
  5166.         {
  5167.             remainingBombThrowDelaySlot1 = theGame.params.BOMB_THROW_DELAY;
  5168.             AddTimer( 'BombDelay', 0.0f, true );
  5169.         }
  5170.         else if( slot == EES_Petard2 || slot == EES_Quickslot2 )
  5171.         {
  5172.             remainingBombThrowDelaySlot2 = theGame.params.BOMB_THROW_DELAY;
  5173.             AddTimer( 'BombDelay', 0.0f, true );
  5174.         }
  5175.         else
  5176.         {
  5177.             return;
  5178.         }
  5179.     }
  5180.    
  5181.     public final function GetBombDelay( slot : EEquipmentSlots ) : float
  5182.     {
  5183.         if( slot == EES_Petard1 || slot == EES_Quickslot1 )
  5184.         {
  5185.             return remainingBombThrowDelaySlot1;
  5186.         }
  5187.         else if( slot == EES_Petard2 || slot == EES_Quickslot2 )
  5188.         {
  5189.             return remainingBombThrowDelaySlot2;
  5190.         }
  5191.        
  5192.         return 0;
  5193.     }
  5194.    
  5195.     timer function BombDelay( dt : float, id : int )
  5196.     {
  5197.         remainingBombThrowDelaySlot1 = MaxF( 0.f , remainingBombThrowDelaySlot1 - dt );
  5198.         remainingBombThrowDelaySlot2 = MaxF( 0.f , remainingBombThrowDelaySlot2 - dt );
  5199.        
  5200.         if( remainingBombThrowDelaySlot1 <= 0.0f && remainingBombThrowDelaySlot2  <= 0.0f )
  5201.         {
  5202.             RemoveTimer('BombDelay');
  5203.         }
  5204.     }
  5205.    
  5206.     public function ResetCharacterDev()
  5207.     {
  5208.        
  5209.         UnequipItemFromSlot(EES_SkillMutagen1);
  5210.         UnequipItemFromSlot(EES_SkillMutagen2);
  5211.         UnequipItemFromSlot(EES_SkillMutagen3);
  5212.         UnequipItemFromSlot(EES_SkillMutagen4);
  5213.        
  5214.         levelManager.ResetCharacterDev();
  5215.         ((W3PlayerAbilityManager)abilityManager).ResetCharacterDev();      
  5216.     }
  5217.    
  5218.     public final function ResetMutationsDev()
  5219.     {
  5220.         levelManager.ResetMutationsDev();
  5221.         ((W3PlayerAbilityManager)abilityManager).ResetMutationsDev();
  5222.     }
  5223.    
  5224.     public final function GetHeldSword() : SItemUniqueId
  5225.     {
  5226.         var i : int;
  5227.         var weapons : array< SItemUniqueId >;
  5228.        
  5229.         weapons = inv.GetHeldWeapons();
  5230.         for( i=0; i<weapons.Size(); i+=1 )
  5231.         {
  5232.             if( inv.IsItemSilverSwordUsableByPlayer( weapons[i] ) || inv.IsItemSteelSwordUsableByPlayer( weapons[i] ) )
  5233.             {
  5234.                 return weapons[i];
  5235.             }
  5236.         }
  5237.        
  5238.         return GetInvalidUniqueId();
  5239.     }
  5240.    
  5241.     public function ConsumeItem( itemId : SItemUniqueId ) : bool
  5242.     {
  5243.         var itemName : name;
  5244.         var removedItem, willRemoveItem : bool;
  5245.         var edibles : array<SItemUniqueId>;
  5246.         var toSlot : EEquipmentSlots;
  5247.         var i : int;
  5248.         var equippedNewEdible : bool;
  5249.        
  5250.         itemName = inv.GetItemName( itemId );
  5251.        
  5252.         if (itemName == 'q111_imlerith_acorn' )
  5253.         {
  5254.             AddPoints(ESkillPoint, 2, true);
  5255.             removedItem = inv.RemoveItem( itemId, 1 );
  5256.             theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt("panel_character_popup_title_buy_skill") + "<br>" + GetLocStringByKeyExt("panel_character_availablepoints") + " +2");
  5257.             theSound.SoundEvent("gui_character_buy_skill");
  5258.         }
  5259.         else if ( itemName == 'Clearing Potion' )
  5260.         {
  5261.             ResetCharacterDev();
  5262.             removedItem = inv.RemoveItem( itemId, 1 );
  5263.             theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt("panel_character_popup_character_cleared") );
  5264.             theSound.SoundEvent("gui_character_synergy_effect");
  5265.         }
  5266.         else if ( itemName == 'Restoring Potion' )
  5267.         {
  5268.             ResetMutationsDev();
  5269.             removedItem = inv.RemoveItem( itemId, 1 );
  5270.             theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt("panel_character_popup_character_cleared") );
  5271.             theSound.SoundEvent("gui_character_synergy_effect");
  5272.         }
  5273.         else if(itemName == 'Wolf Hour')
  5274.         {
  5275.             removedItem = inv.RemoveItem( itemId, 1 );
  5276.             theSound.SoundEvent("gui_character_synergy_effect");
  5277.             AddEffectDefault(EET_WolfHour, thePlayer, 'wolf hour');
  5278.         }
  5279.         else if ( itemName == 'q704_ft_golden_egg' )
  5280.         {
  5281.             AddPoints(ESkillPoint, 1, true);
  5282.             removedItem = inv.RemoveItem( itemId, 1 );
  5283.             theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt("panel_character_popup_title_buy_skill") + "<br>" + GetLocStringByKeyExt("panel_character_availablepoints") + " +1");
  5284.             theSound.SoundEvent("gui_character_buy_skill");
  5285.         }
  5286.         else if ( itemName == 'mq7023_cake' )
  5287.         {
  5288.             this.AddAbility('mq7023_cake_vitality_bonus');
  5289.             removedItem = inv.RemoveItem( itemId, 1 );
  5290.             theSound.SoundEvent("gui_character_synergy_effect");
  5291.         }
  5292.         else
  5293.         {
  5294.             willRemoveItem = inv.GetItemQuantity(itemId) == 1 && !inv.ItemHasTag(itemId, 'InfiniteUse');
  5295.            
  5296.             if(willRemoveItem)
  5297.                 toSlot = GetItemSlot(itemId);
  5298.                
  5299.             removedItem = super.ConsumeItem(itemId);
  5300.            
  5301.             if(willRemoveItem && removedItem)
  5302.             {
  5303.                 edibles = inv.GetItemsByTag('Edibles');
  5304.                 equippedNewEdible = false;
  5305.                
  5306.                
  5307.                 for(i=0; i<edibles.Size(); i+=1)
  5308.                 {
  5309.                     if(!IsItemEquipped(edibles[i]) && !inv.ItemHasTag(edibles[i], 'Alcohol') && inv.GetItemName(edibles[i]) != 'Clearing Potion' && inv.GetItemName(edibles[i]) != 'Wolf Hour')
  5310.                     {
  5311.                         EquipItemInGivenSlot(edibles[i], toSlot, true, false);
  5312.                         equippedNewEdible = true;
  5313.                         break;
  5314.                     }
  5315.                 }
  5316.                
  5317.                
  5318.                 if(!equippedNewEdible)
  5319.                 {
  5320.                     for(i=0; i<edibles.Size(); i+=1)
  5321.                     {
  5322.                         if(!IsItemEquipped(edibles[i]) && inv.GetItemName(edibles[i]) != 'Clearing Potion' && inv.GetItemName(edibles[i]) != 'Wolf Hour')
  5323.                         {
  5324.                             EquipItemInGivenSlot(edibles[i], toSlot, true, false);
  5325.                             break;
  5326.                         }
  5327.                     }
  5328.                 }
  5329.             }
  5330.         }
  5331.        
  5332.         return removedItem;
  5333.     }
  5334.    
  5335.    
  5336.     public final function GetAlcoholForAlchemicalItemsRefill() : SItemUniqueId
  5337.     {
  5338.         var alcos : array<SItemUniqueId>;
  5339.         var id : SItemUniqueId;
  5340.         var i, price, minPrice : int;
  5341.        
  5342.         alcos = inv.GetItemsByTag(theGame.params.TAG_ALCHEMY_REFILL_ALCO);
  5343.        
  5344.         if(alcos.Size() > 0)
  5345.         {
  5346.             if(inv.ItemHasTag(alcos[0], theGame.params.TAG_INFINITE_USE))
  5347.                 return alcos[0];
  5348.                
  5349.             minPrice = inv.GetItemPrice(alcos[0]);
  5350.             price = minPrice;
  5351.             id = alcos[0];
  5352.            
  5353.             for(i=1; i<alcos.Size(); i+=1)
  5354.             {
  5355.                 if(inv.ItemHasTag(alcos[i], theGame.params.TAG_INFINITE_USE))
  5356.                     return alcos[i];
  5357.                
  5358.                 price = inv.GetItemPrice(alcos[i]);
  5359.                
  5360.                 if(price < minPrice)
  5361.                 {
  5362.                     minPrice = price;
  5363.                     id = alcos[i];
  5364.                 }
  5365.             }
  5366.            
  5367.             return id;
  5368.         }
  5369.        
  5370.         return GetInvalidUniqueId();
  5371.     }
  5372.    
  5373.     public final function ClearPreviouslyUsedBolt()
  5374.     {
  5375.         previouslyUsedBolt = GetInvalidUniqueId();
  5376.     }
  5377.    
  5378.     public function ShouldUseInfiniteWaterBolts() : bool
  5379.     {
  5380.         return GetCurrentStateName() == 'Swimming' || IsSwimming() || IsDiving();
  5381.     }
  5382.    
  5383.     public function GetCurrentInfiniteBoltName( optional forceBodkin : bool, optional forceHarpoon : bool ) : name
  5384.     {
  5385.         if(!forceBodkin && (forceHarpoon || ShouldUseInfiniteWaterBolts()) )
  5386.         {
  5387.             return 'Harpoon Bolt';
  5388.         }
  5389.         return 'Bodkin Bolt';
  5390.     }
  5391.    
  5392.    
  5393.     public final function AddAndEquipInfiniteBolt(optional forceBodkin : bool, optional forceHarpoon : bool)
  5394.     {
  5395.         var bolt, bodkins, harpoons : array<SItemUniqueId>;
  5396.         var boltItemName : name;
  5397.         var i : int;
  5398.        
  5399.        
  5400.         bodkins = inv.GetItemsByName('Bodkin Bolt');
  5401.         harpoons = inv.GetItemsByName('Harpoon Bolt');
  5402.        
  5403.         for(i=bodkins.Size()-1; i>=0; i-=1)
  5404.             inv.RemoveItem(bodkins[i], inv.GetItemQuantity(bodkins[i]) );
  5405.            
  5406.         for(i=harpoons.Size()-1; i>=0; i-=1)
  5407.             inv.RemoveItem(harpoons[i], inv.GetItemQuantity(harpoons[i]) );
  5408.            
  5409.        
  5410.        
  5411.         boltItemName = GetCurrentInfiniteBoltName( forceBodkin, forceHarpoon );
  5412.        
  5413.        
  5414.         if(boltItemName == 'Bodkin Bolt' && inv.IsIdValid(previouslyUsedBolt))
  5415.         {
  5416.             bolt.PushBack(previouslyUsedBolt);
  5417.         }
  5418.         else
  5419.         {
  5420.            
  5421.             bolt = inv.AddAnItem(boltItemName, 1, true, true);
  5422.            
  5423.            
  5424.             if(boltItemName == 'Harpoon Bolt')
  5425.             {
  5426.                 GetItemEquippedOnSlot(EES_Bolt, previouslyUsedBolt);
  5427.             }
  5428.         }
  5429.        
  5430.         EquipItem(bolt[0], EES_Bolt);
  5431.     }
  5432.    
  5433.    
  5434.     event OnItemGiven(data : SItemChangedData)
  5435.     {
  5436.         var m_guiManager    : CR4GuiManager;
  5437.        
  5438.         super.OnItemGiven(data);
  5439.        
  5440.        
  5441.         if(!inv)
  5442.             inv = GetInventory();
  5443.        
  5444.        
  5445.         if(inv.IsItemEncumbranceItem(data.ids[0]))
  5446.             UpdateEncumbrance();
  5447.        
  5448.         m_guiManager = theGame.GetGuiManager();
  5449.         if(m_guiManager)
  5450.             m_guiManager.RegisterNewItem(data.ids[0]);
  5451.     }
  5452.        
  5453.    
  5454.     public final function CheckForFullyArmedAchievement()
  5455.     {
  5456.         if( HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_BEAR) || HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_GRYPHON) ||
  5457.             HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_LYNX) || HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_WOLF) ||
  5458.             HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_VIPER) || HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_NETFLIX)           
  5459.         )
  5460.         {
  5461.             theGame.GetGamerProfile().AddAchievement(EA_FullyArmed);
  5462.         }
  5463.     }
  5464.    
  5465.    
  5466.     public final function HasAllItemsFromSet(setItemTag : name) : bool
  5467.     {
  5468.         var item : SItemUniqueId;
  5469.        
  5470.         if(!GetItemEquippedOnSlot(EES_SteelSword, item) || !inv.ItemHasTag(item, setItemTag))
  5471.             return false;
  5472.        
  5473.         if(!GetItemEquippedOnSlot(EES_SilverSword, item) || !inv.ItemHasTag(item, setItemTag))
  5474.             return false;
  5475.            
  5476.         if(!GetItemEquippedOnSlot(EES_Boots, item) || !inv.ItemHasTag(item, setItemTag))
  5477.             return false;
  5478.            
  5479.         if(!GetItemEquippedOnSlot(EES_Pants, item) || !inv.ItemHasTag(item, setItemTag))
  5480.             return false;
  5481.            
  5482.         if(!GetItemEquippedOnSlot(EES_Gloves, item) || !inv.ItemHasTag(item, setItemTag))
  5483.             return false;
  5484.            
  5485.         if(!GetItemEquippedOnSlot(EES_Armor, item) || !inv.ItemHasTag(item, setItemTag))
  5486.             return false;
  5487.            
  5488.        
  5489.         if(setItemTag == theGame.params.ITEM_SET_TAG_BEAR || setItemTag == theGame.params.ITEM_SET_TAG_LYNX)
  5490.         {
  5491.             if(!GetItemEquippedOnSlot(EES_RangedWeapon, item) || !inv.ItemHasTag(item, setItemTag))
  5492.                 return false;
  5493.         }
  5494.  
  5495.         return true;
  5496.     }
  5497.    
  5498.    
  5499.     public final function CheckForFullyArmedByTag(setItemTag : name)
  5500.     {
  5501.         var doneParts, totalParts : int;
  5502.         var item : SItemUniqueId;
  5503.        
  5504.         if(setItemTag == '')
  5505.             return;
  5506.            
  5507.        
  5508.         doneParts = 0;
  5509.         totalParts = 6;
  5510.         if(GetItemEquippedOnSlot(EES_SteelSword, item) && inv.ItemHasTag(item, setItemTag))
  5511.             doneParts += 1;
  5512.        
  5513.         if(GetItemEquippedOnSlot(EES_SilverSword, item) && inv.ItemHasTag(item, setItemTag))
  5514.             doneParts += 1;
  5515.            
  5516.         if(GetItemEquippedOnSlot(EES_Boots, item) && inv.ItemHasTag(item, setItemTag))
  5517.             doneParts += 1;
  5518.            
  5519.         if(GetItemEquippedOnSlot(EES_Pants, item) && inv.ItemHasTag(item, setItemTag))
  5520.             doneParts += 1;
  5521.            
  5522.         if(GetItemEquippedOnSlot(EES_Gloves, item) && inv.ItemHasTag(item, setItemTag))
  5523.             doneParts += 1;
  5524.            
  5525.         if(GetItemEquippedOnSlot(EES_Armor, item) && inv.ItemHasTag(item, setItemTag))
  5526.             doneParts += 1;
  5527.            
  5528.        
  5529.         if(setItemTag == theGame.params.ITEM_SET_TAG_BEAR || setItemTag == theGame.params.ITEM_SET_TAG_LYNX)
  5530.         {
  5531.             totalParts += 1;
  5532.             if(GetItemEquippedOnSlot(EES_RangedWeapon, item) && inv.ItemHasTag(item, setItemTag))
  5533.                 doneParts += 1;
  5534.         }
  5535.        
  5536.        
  5537.         if(doneParts >= totalParts)
  5538.         {
  5539.             theGame.GetGamerProfile().AddAchievement(EA_FullyArmed);
  5540.         }
  5541.         else
  5542.         {
  5543.             theGame.GetGamerProfile().NoticeAchievementProgress(EA_FullyArmed, doneParts, totalParts);
  5544.         }
  5545.     }
  5546.    
  5547.    
  5548.    
  5549.    
  5550.     public function GetTotalArmor() : SAbilityAttributeValue
  5551.     {
  5552.         var armor : SAbilityAttributeValue;
  5553.         var armorItem : SItemUniqueId;
  5554.        
  5555.         armor = super.GetTotalArmor();
  5556.        
  5557.         if(GetItemEquippedOnSlot(EES_Armor, armorItem))
  5558.         {
  5559.            
  5560.             armor -= inv.GetItemAttributeValue(armorItem, theGame.params.ARMOR_VALUE_NAME);
  5561.            
  5562.            
  5563.             armor += inv.GetItemArmorTotal(armorItem);         
  5564.         }
  5565.        
  5566.         if(GetItemEquippedOnSlot(EES_Pants, armorItem))
  5567.         {
  5568.            
  5569.             armor -= inv.GetItemAttributeValue(armorItem, theGame.params.ARMOR_VALUE_NAME);
  5570.            
  5571.            
  5572.             armor += inv.GetItemArmorTotal(armorItem);         
  5573.         }
  5574.            
  5575.         if(GetItemEquippedOnSlot(EES_Boots, armorItem))
  5576.         {
  5577.            
  5578.             armor -= inv.GetItemAttributeValue(armorItem, theGame.params.ARMOR_VALUE_NAME);
  5579.            
  5580.            
  5581.             armor += inv.GetItemArmorTotal(armorItem);         
  5582.         }
  5583.            
  5584.         if(GetItemEquippedOnSlot(EES_Gloves, armorItem))
  5585.         {
  5586.            
  5587.             armor -= inv.GetItemAttributeValue(armorItem, theGame.params.ARMOR_VALUE_NAME);
  5588.            
  5589.            
  5590.             armor += inv.GetItemArmorTotal(armorItem);         
  5591.         }
  5592.            
  5593.         return armor;
  5594.     }
  5595.    
  5596.    
  5597.    
  5598.     public function ReduceArmorDurability() : EEquipmentSlots
  5599.     {
  5600.         var r, sum : int;
  5601.         var slot : EEquipmentSlots;
  5602.         var id : SItemUniqueId;
  5603.         var prevDurMult, currDurMult, ratio : float;
  5604.    
  5605.        
  5606.         sum = theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT;
  5607.         sum += theGame.params.DURABILITY_ARMOR_PANTS_WEIGHT;
  5608.         sum += theGame.params.DURABILITY_ARMOR_GLOVES_WEIGHT;
  5609.         sum += theGame.params.DURABILITY_ARMOR_BOOTS_WEIGHT;
  5610.         sum += theGame.params.DURABILITY_ARMOR_MISS_WEIGHT;
  5611.        
  5612.         r = RandRange(sum);
  5613.        
  5614.         if(r < theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT)
  5615.             slot = EES_Armor;
  5616.         else if (r < theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT + theGame.params.DURABILITY_ARMOR_PANTS_WEIGHT)
  5617.             slot = EES_Pants;
  5618.         else if (r < theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT + theGame.params.DURABILITY_ARMOR_PANTS_WEIGHT + theGame.params.DURABILITY_ARMOR_GLOVES_WEIGHT)
  5619.             slot = EES_Gloves;
  5620.         else if (r < theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT + theGame.params.DURABILITY_ARMOR_PANTS_WEIGHT + theGame.params.DURABILITY_ARMOR_GLOVES_WEIGHT + theGame.params.DURABILITY_ARMOR_BOOTS_WEIGHT)
  5621.             slot = EES_Boots;
  5622.         else
  5623.             return EES_InvalidSlot;                
  5624.        
  5625.         GetItemEquippedOnSlot(slot, id);               
  5626.         ratio = inv.GetItemDurabilityRatio(id);    
  5627.         if(inv.ReduceItemDurability(id))           
  5628.         {
  5629.             prevDurMult = theGame.params.GetDurabilityMultiplier(ratio, false);
  5630.            
  5631.             ratio = inv.GetItemDurabilityRatio(id);
  5632.             currDurMult = theGame.params.GetDurabilityMultiplier(ratio, false);
  5633.            
  5634.             if(currDurMult != prevDurMult)
  5635.             {
  5636.                
  5637.                
  5638.                
  5639.                
  5640.             }
  5641.                
  5642.             return slot;
  5643.         }
  5644.        
  5645.         return EES_InvalidSlot;
  5646.     }
  5647.    
  5648.    
  5649.     public function DismantleItem(dismantledItem : SItemUniqueId, toolItem : SItemUniqueId) : bool
  5650.     {
  5651.         var parts : array<SItemParts>;
  5652.         var i : int;
  5653.        
  5654.         if(!inv.IsItemDismantleKit(toolItem))
  5655.             return false;
  5656.        
  5657.         parts = inv.GetItemRecyclingParts(dismantledItem);
  5658.        
  5659.         if(parts.Size() <= 0)
  5660.             return false;
  5661.            
  5662.         for(i=0; i<parts.Size(); i+=1)
  5663.             inv.AddAnItem(parts[i].itemName, parts[i].quantity, true, false);
  5664.            
  5665.         inv.RemoveItem(toolItem);
  5666.         inv.RemoveItem(dismantledItem);
  5667.         return true;
  5668.     }
  5669.    
  5670.    
  5671.     public function GetItemEquippedOnSlot(slot : EEquipmentSlots, out item : SItemUniqueId) : bool
  5672.     {
  5673.         if(slot == EES_InvalidSlot || slot < 0 || slot > EnumGetMax('EEquipmentSlots'))
  5674.             return false;
  5675.        
  5676.         item = itemSlots[slot];
  5677.        
  5678.         return inv.IsIdValid(item);
  5679.     }
  5680.    
  5681.    
  5682.     public function GetItemSlotByItemName(itemName : name) : EEquipmentSlots
  5683.     {
  5684.         var ids : array<SItemUniqueId>;
  5685.         var i : int;
  5686.         var slot : EEquipmentSlots;
  5687.        
  5688.         ids = inv.GetItemsByName(itemName);
  5689.         for(i=0; i<ids.Size(); i+=1)
  5690.         {
  5691.             slot = GetItemSlot(ids[i]);
  5692.             if(slot != EES_InvalidSlot)
  5693.                 return slot;
  5694.         }
  5695.        
  5696.         return EES_InvalidSlot;
  5697.     }
  5698.    
  5699.    
  5700.     public function GetItemSlot(item : SItemUniqueId) : EEquipmentSlots
  5701.     {
  5702.         var i : int;
  5703.        
  5704.         if(!inv.IsIdValid(item))
  5705.             return EES_InvalidSlot;
  5706.            
  5707.         for(i=0; i<itemSlots.Size(); i+=1)
  5708.             if(itemSlots[i] == item)
  5709.                 return i;
  5710.        
  5711.         return EES_InvalidSlot;
  5712.     }
  5713.    
  5714.     public function GetEquippedItems() : array<SItemUniqueId>
  5715.     {
  5716.         return itemSlots;
  5717.     }
  5718.    
  5719.     public function IsItemEquipped(item : SItemUniqueId) : bool
  5720.     {
  5721.         if(!inv.IsIdValid(item))
  5722.             return false;
  5723.            
  5724.         return itemSlots.Contains(item);
  5725.     }
  5726.  
  5727.     public function IsItemHeld(item : SItemUniqueId) : bool
  5728.     {
  5729.         if(!inv.IsIdValid(item))
  5730.             return false;
  5731.            
  5732.         return inv.IsItemHeld(item);
  5733.     }
  5734.  
  5735.    
  5736.     public function IsAnyItemEquippedOnSlot(slot : EEquipmentSlots) : bool
  5737.     {
  5738.         if(slot == EES_InvalidSlot || slot < 0 || slot > EnumGetMax('EEquipmentSlots'))
  5739.             return false;
  5740.            
  5741.         return inv.IsIdValid(itemSlots[slot]);
  5742.     }
  5743.    
  5744.    
  5745.     public function GetFreeQuickslot() : EEquipmentSlots
  5746.     {
  5747.         if(!inv.IsIdValid(itemSlots[EES_Quickslot1]))       return EES_Quickslot1;
  5748.         if(!inv.IsIdValid(itemSlots[EES_Quickslot2]))       return EES_Quickslot2;
  5749.        
  5750.        
  5751.         return EES_InvalidSlot;
  5752.     }
  5753.    
  5754.    
  5755.     event OnEquipItemRequested(item : SItemUniqueId, ignoreMount : bool)
  5756.     {
  5757.         var slot : EEquipmentSlots;
  5758.        
  5759.         if(inv.IsIdValid(item))
  5760.         {
  5761.             slot = inv.GetSlotForItemId(item);
  5762.                
  5763.             if (slot != EES_InvalidSlot)
  5764.             {
  5765.                
  5766.                
  5767.                 EquipItemInGivenSlot(item, slot, ignoreMount);
  5768.             }
  5769.         }
  5770.     }
  5771.    
  5772.     event OnUnequipItemRequested(item : SItemUniqueId)
  5773.     {
  5774.         UnequipItem(item);
  5775.     }
  5776.    
  5777.    
  5778.     public function EquipItem(item : SItemUniqueId, optional slot : EEquipmentSlots, optional toHand : bool) : bool
  5779.     {
  5780.         if(!inv.IsIdValid(item))
  5781.             return false;
  5782.            
  5783.         if(slot == EES_InvalidSlot)
  5784.         {
  5785.             slot = inv.GetSlotForItemId(item);
  5786.            
  5787.             if(slot == EES_InvalidSlot)
  5788.                 return false;
  5789.         }
  5790.        
  5791.         ForceSoundAppearanceUpdate();
  5792.        
  5793.         return EquipItemInGivenSlot(item, slot, false, toHand);
  5794.     }
  5795.    
  5796.     protected function ShouldMount(slot : EEquipmentSlots, item : SItemUniqueId, category : name):bool
  5797.     {
  5798.        
  5799.        
  5800.         return !IsSlotPotionMutagen(slot) && category != 'usable' && category != 'potion' && category != 'petard' && !inv.ItemHasTag(item, 'PlayerUnwearable');
  5801.     }
  5802.        
  5803.     protected function ShouldMountItemWithName( itemName: name ): bool
  5804.     {
  5805.         var slot : EEquipmentSlots;
  5806.         var items : array<SItemUniqueId>;
  5807.         var category : name;
  5808.         var i : int;
  5809.        
  5810.         items = inv.GetItemsByName( itemName );
  5811.        
  5812.         category = inv.GetItemCategory( items[0] );
  5813.        
  5814.         slot = GetItemSlot( items[0] );
  5815.        
  5816.         return ShouldMount( slot, items[0], category );
  5817.     }  
  5818.    
  5819.     public function GetMountableItems( out items : array< SItemUniqueId > )
  5820.     {
  5821.         var i : int;
  5822.         var mountable : bool;
  5823.         var mountableItems : array< SItemUniqueId >;
  5824.         var slot : EEquipmentSlots;
  5825.         var category : name;
  5826.         var item: SItemUniqueId;
  5827.        
  5828.         for ( i = 0; i < items.Size(); i += 1 )
  5829.         {
  5830.             item = items[i];
  5831.        
  5832.             category = inv.GetItemCategory( item );
  5833.        
  5834.             slot = GetItemSlot( item );
  5835.        
  5836.             mountable = ShouldMount( slot, item, category );
  5837.        
  5838.             if ( mountable )
  5839.             {
  5840.                 mountableItems.PushBack( items[ i ] );
  5841.             }
  5842.         }
  5843.         items = mountableItems;
  5844.     }
  5845.    
  5846.     public final function AddAndEquipItem( item : name ) : bool
  5847.     {
  5848.         var ids : array< SItemUniqueId >;
  5849.        
  5850.         ids = inv.AddAnItem( item );
  5851.         if( inv.IsIdValid( ids[ 0 ] ) )
  5852.         {
  5853.             return EquipItem( ids[ 0 ] );
  5854.         }
  5855.        
  5856.         return false;
  5857.     }
  5858.    
  5859.     public final function AddQuestMarkedSelectedQuickslotItem( sel : SSelectedQuickslotItem )
  5860.     {
  5861.         questMarkedSelectedQuickslotItems.PushBack( sel );
  5862.     }
  5863.    
  5864.     public final function GetQuestMarkedSelectedQuickslotItem( sourceName : name ) : SItemUniqueId
  5865.     {
  5866.         var i : int;
  5867.        
  5868.         for( i=0; i<questMarkedSelectedQuickslotItems.Size(); i+=1 )
  5869.         {
  5870.             if( questMarkedSelectedQuickslotItems[i].sourceName == sourceName )
  5871.             {
  5872.                 return questMarkedSelectedQuickslotItems[i].itemID;
  5873.             }
  5874.         }
  5875.        
  5876.         return GetInvalidUniqueId();
  5877.     }
  5878.    
  5879.     public final function SwapEquippedItems(slot1 : EEquipmentSlots, slot2 : EEquipmentSlots)
  5880.     {
  5881.         var temp : SItemUniqueId;
  5882.         var pam : W3PlayerAbilityManager;
  5883.        
  5884.         temp = itemSlots[slot1];
  5885.         itemSlots[slot1] = itemSlots[slot2];
  5886.         itemSlots[slot2] = temp;
  5887.        
  5888.         if(IsSlotSkillMutagen(slot1))
  5889.         {
  5890.             pam = (W3PlayerAbilityManager)abilityManager;
  5891.             if(pam)
  5892.                 pam.OnSwappedMutagensPost(itemSlots[slot1], itemSlots[slot2]);
  5893.         }
  5894.     }
  5895.    
  5896.     public final function GetSlotForEquippedItem( itemID : SItemUniqueId ) : EEquipmentSlots
  5897.     {
  5898.         var i : int;
  5899.        
  5900.         for( i=0; i<itemSlots.Size(); i+=1 )
  5901.         {
  5902.             if( itemSlots[i] == itemID )
  5903.             {
  5904.                 return i;
  5905.             }
  5906.         }
  5907.        
  5908.         return EES_InvalidSlot;
  5909.     }
  5910.    
  5911.     public function EquipItemInGivenSlot(item : SItemUniqueId, slot : EEquipmentSlots, ignoreMounting : bool, optional toHand : bool) : bool
  5912.     {          
  5913.         var i, groupID, quantity : int;
  5914.         var fistsID : array<SItemUniqueId>;
  5915.         var pam : W3PlayerAbilityManager;
  5916.         var isSkillMutagen : bool;     
  5917.         var armorEntity : CItemEntity;
  5918.         var armorMeshComponent : CComponent;
  5919.         var armorSoundIdentification : name;
  5920.         var category : name;
  5921.         var tagOfASet : name;
  5922.         var prevSkillColor : ESkillColor;
  5923.         var containedAbilities : array<name>;
  5924.         var dm : CDefinitionsManagerAccessor;
  5925.         var armorType : EArmorType;
  5926.         var otherMask, previousItemInSlot : SItemUniqueId;
  5927.         var tutStatePot : W3TutorialManagerUIHandlerStatePotions;
  5928.         var tutStateFood : W3TutorialManagerUIHandlerStateFood;
  5929.         var tutStateSecondPotionEquip : W3TutorialManagerUIHandlerStateSecondPotionEquip;
  5930.         var boltItem : SItemUniqueId;
  5931.         var aerondight : W3Effect_Aerondight;
  5932.        
  5933.         if(!inv.IsIdValid(item))
  5934.         {
  5935.             LogAssert(false, "W3PlayerWitcher.EquipItemInGivenSlot: invalid item");
  5936.             return false;
  5937.         }
  5938.         if(slot == EES_InvalidSlot || slot == EES_HorseBlinders || slot == EES_HorseSaddle || slot == EES_HorseBag || slot == EES_HorseTrophy)
  5939.         {
  5940.             LogAssert(false, "W3PlayerWitcher.EquipItem: Cannot equip item <<" + inv.GetItemName(item) + ">> - provided slot <<" + slot + ">> is invalid");
  5941.             return false;
  5942.         }
  5943.         if(itemSlots[slot] == item)
  5944.         {
  5945.             return true;
  5946.         }  
  5947.        
  5948.         if(!HasRequiredLevelToEquipItem(item))
  5949.         {
  5950.            
  5951.             return false;
  5952.         }
  5953.        
  5954.         if(inv.ItemHasTag(item, 'PhantomWeapon') && !GetPhantomWeaponMgr())
  5955.         {
  5956.             InitPhantomWeaponMgr();
  5957.         }
  5958.        
  5959.        
  5960.         if( slot == EES_SilverSword && inv.ItemHasTag( item, 'Aerondight' ) )
  5961.         {
  5962.             AddEffectDefault( EET_Aerondight, this, "Aerondight" );
  5963.            
  5964.            
  5965.             aerondight = (W3Effect_Aerondight)GetBuff( EET_Aerondight );
  5966.             aerondight.Pause( 'ManageAerondightBuff' );
  5967.         }      
  5968.        
  5969.        
  5970.         previousItemInSlot = itemSlots[slot];
  5971.         if( IsItemEquipped(item))
  5972.         {
  5973.             SwapEquippedItems(slot, GetItemSlot(item));
  5974.             return true;
  5975.         }
  5976.        
  5977.        
  5978.         isSkillMutagen = IsSlotSkillMutagen(slot);
  5979.         if(isSkillMutagen)
  5980.         {
  5981.             pam = (W3PlayerAbilityManager)abilityManager;
  5982.             if(!pam.IsSkillMutagenSlotUnlocked(slot))
  5983.             {
  5984.                 return false;
  5985.             }
  5986.         }
  5987.        
  5988.        
  5989.         if(inv.IsIdValid(previousItemInSlot))
  5990.         {          
  5991.             if(!UnequipItemFromSlot(slot, true))
  5992.             {
  5993.                 LogAssert(false, "W3PlayerWitcher.EquipItem: Cannot equip item <<" + inv.GetItemName(item) + ">> !!");
  5994.                 return false;
  5995.             }
  5996.         }      
  5997.        
  5998.        
  5999.         if(inv.IsItemMask(item))
  6000.         {
  6001.             if(slot == EES_Quickslot1)
  6002.                 GetItemEquippedOnSlot(EES_Quickslot2, otherMask);
  6003.             else
  6004.                 GetItemEquippedOnSlot(EES_Quickslot1, otherMask);
  6005.                
  6006.             if(inv.IsItemMask(otherMask))
  6007.                 UnequipItem(otherMask);
  6008.         }
  6009.        
  6010.         if(isSkillMutagen)
  6011.         {
  6012.             groupID = pam.GetSkillGroupIdOfMutagenSlot(slot);
  6013.             prevSkillColor = pam.GetSkillGroupColor(groupID);
  6014.         }
  6015.        
  6016.         itemSlots[slot] = item;
  6017.        
  6018.         category = inv.GetItemCategory( item );
  6019.    
  6020.        
  6021.         if( !ignoreMounting && ShouldMount(slot, item, category) )
  6022.         {
  6023.            
  6024.             inv.MountItem( item, toHand, IsSlotSkillMutagen( slot ) );
  6025.         }      
  6026.        
  6027.         theTelemetry.LogWithLabelAndValue( TE_INV_ITEM_EQUIPPED, inv.GetItemName(item), slot );
  6028.                
  6029.         if(slot == EES_RangedWeapon)
  6030.         {          
  6031.             rangedWeapon = ( Crossbow )( inv.GetItemEntityUnsafe(item) );
  6032.             if(!rangedWeapon)
  6033.                 AddTimer('DelayedOnItemMount', 0.1, true);
  6034.            
  6035.             if ( IsSwimming() || IsDiving() )
  6036.             {
  6037.                 GetItemEquippedOnSlot(EES_Bolt, boltItem);
  6038.                
  6039.                 if(inv.IsIdValid(boltItem))
  6040.                 {
  6041.                     if ( !inv.ItemHasTag(boltItem, 'UnderwaterAmmo' ))
  6042.                     {
  6043.                         AddAndEquipInfiniteBolt(false, true);
  6044.                     }
  6045.                 }
  6046.                 else if(!IsAnyItemEquippedOnSlot(EES_Bolt))
  6047.                 {
  6048.                     AddAndEquipInfiniteBolt(false, true);
  6049.                 }
  6050.             }
  6051.            
  6052.             else if(!IsAnyItemEquippedOnSlot(EES_Bolt))
  6053.                 AddAndEquipInfiniteBolt();
  6054.         }
  6055.         else if(slot == EES_Bolt)
  6056.         {
  6057.             if(rangedWeapon)
  6058.             {   if ( !IsSwimming() || !IsDiving() )
  6059.                 {
  6060.                     rangedWeapon.OnReplaceAmmo();
  6061.                     rangedWeapon.OnWeaponReload();
  6062.                 }
  6063.                 else
  6064.                 {
  6065.                     DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_now" ));
  6066.                 }
  6067.             }
  6068.         }      
  6069.        
  6070.         else if(isSkillMutagen)
  6071.         {
  6072.             theGame.GetGuiManager().IgnoreNewItemNotifications( true );
  6073.            
  6074.            
  6075.             quantity = inv.GetItemQuantity( item );
  6076.             if( quantity > 1 )
  6077.             {
  6078.                 inv.SplitItem( item, quantity - 1 );
  6079.             }
  6080.            
  6081.             pam.OnSkillMutagenEquipped(item, slot, prevSkillColor);
  6082.             LogSkillColors("Mutagen <<" + inv.GetItemName(item) + ">> equipped to slot <<" + slot + ">>");
  6083.             LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
  6084.             LogSkillColors("");
  6085.            
  6086.             theGame.GetGuiManager().IgnoreNewItemNotifications( false );
  6087.         }
  6088.         else if(slot == EES_Gloves && HasWeaponDrawn(false))
  6089.         {
  6090.             PlayRuneword4FX(PW_Steel);
  6091.             PlayRuneword4FX(PW_Silver);
  6092.         }
  6093.        
  6094.         else if( ( slot == EES_Petard1 || slot == EES_Petard2 ) && inv.IsItemBomb( GetSelectedItemId() ) )
  6095.         {
  6096.             SelectQuickslotItem( slot );
  6097.         }
  6098.  
  6099.        
  6100.         if(inv.ItemHasAbility(item, 'MA_HtH'))
  6101.         {
  6102.             inv.GetItemContainedAbilities(item, containedAbilities);
  6103.             fistsID = inv.GetItemsByName('fists');
  6104.             dm = theGame.GetDefinitionsManager();
  6105.             for(i=0; i<containedAbilities.Size(); i+=1)
  6106.             {
  6107.                 if(dm.AbilityHasTag(containedAbilities[i], 'MA_HtH'))
  6108.                 {                  
  6109.                     inv.AddItemCraftedAbility(fistsID[0], containedAbilities[i], true);
  6110.                 }
  6111.             }
  6112.         }      
  6113.        
  6114.        
  6115.         if(inv.IsItemAnyArmor(item))
  6116.         {
  6117.             armorType = inv.GetArmorType(item);
  6118.             pam = (W3PlayerAbilityManager)abilityManager;
  6119.            
  6120.             if(armorType == EAT_Light)
  6121.             {
  6122.                 if(CanUseSkill(S_Perk_05))
  6123.                     pam.SetPerkArmorBonus(S_Perk_05);
  6124.             }
  6125.             else if(armorType == EAT_Medium)
  6126.             {
  6127.                 if(CanUseSkill(S_Perk_06))
  6128.                     pam.SetPerkArmorBonus(S_Perk_06);
  6129.             }
  6130.             else if(armorType == EAT_Heavy)
  6131.             {
  6132.                 if(CanUseSkill(S_Perk_07))
  6133.                     pam.SetPerkArmorBonus(S_Perk_07);
  6134.             }
  6135.         }
  6136.        
  6137.        
  6138.         UpdateItemSetBonuses( item, true );
  6139.                
  6140.        
  6141.         theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnItemEquipped );
  6142.    
  6143.        
  6144.         if(ShouldProcessTutorial('TutorialPotionCanEquip3'))
  6145.         {
  6146.             if(IsSlotPotionSlot(slot))
  6147.             {
  6148.                 tutStatePot = (W3TutorialManagerUIHandlerStatePotions)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  6149.                 if(tutStatePot)
  6150.                 {
  6151.                     tutStatePot.OnPotionEquipped(inv.GetItemName(item));
  6152.                 }
  6153.                
  6154.                 tutStateSecondPotionEquip = (W3TutorialManagerUIHandlerStateSecondPotionEquip)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  6155.                 if(tutStateSecondPotionEquip)
  6156.                 {
  6157.                     tutStateSecondPotionEquip.OnPotionEquipped(inv.GetItemName(item));
  6158.                 }
  6159.                
  6160.             }
  6161.         }
  6162.        
  6163.         if(ShouldProcessTutorial('TutorialFoodSelectTab'))
  6164.         {
  6165.             if( IsSlotPotionSlot(slot) && inv.IsItemFood(item))
  6166.             {
  6167.                 tutStateFood = (W3TutorialManagerUIHandlerStateFood)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  6168.                 if(tutStateFood)
  6169.                 {
  6170.                     tutStateFood.OnFoodEquipped();
  6171.                 }
  6172.             }
  6173.         }
  6174.        
  6175.        
  6176.        
  6177.        
  6178.         tagOfASet = inv.DetectTagOfASet(item);
  6179.         CheckForFullyArmedByTag(tagOfASet);
  6180.        
  6181.         return true;
  6182.     }
  6183.  
  6184.     private function CheckHairItem()
  6185.     {
  6186.         var ids : array<SItemUniqueId>;
  6187.         var i   : int;
  6188.         var itemName : name;
  6189.         var hairApplied : bool;
  6190.        
  6191.         ids = inv.GetItemsByCategory('hair');
  6192.        
  6193.         for(i=0; i<ids.Size(); i+= 1)
  6194.         {
  6195.             itemName = inv.GetItemName( ids[i] );
  6196.            
  6197.             if( itemName != 'Preview Hair' )
  6198.             {
  6199.                 if( hairApplied == false )
  6200.                 {
  6201.                     inv.MountItem( ids[i], false );
  6202.                     hairApplied = true;
  6203.                 }
  6204.                 else
  6205.                 {
  6206.                     inv.RemoveItem( ids[i], 1 );
  6207.                 }
  6208.                
  6209.             }
  6210.         }
  6211.        
  6212.         if( hairApplied == false )
  6213.         {
  6214.             ids = inv.AddAnItem('Half With Tail Hairstyle', 1, true, false);
  6215.             inv.MountItem( ids[0], false );
  6216.         }
  6217.        
  6218.     }
  6219.  
  6220.    
  6221.     timer function DelayedOnItemMount( dt : float, id : int )
  6222.     {
  6223.         var crossbowID : SItemUniqueId;
  6224.         var invent : CInventoryComponent;
  6225.        
  6226.         invent = GetInventory();
  6227.         if(!invent)
  6228.             return;
  6229.        
  6230.        
  6231.         GetItemEquippedOnSlot(EES_RangedWeapon, crossbowID);
  6232.                
  6233.         if(invent.IsIdValid(crossbowID))
  6234.         {
  6235.            
  6236.             rangedWeapon = ( Crossbow )(invent.GetItemEntityUnsafe(crossbowID) );
  6237.            
  6238.             if(rangedWeapon)
  6239.             {
  6240.                
  6241.                 RemoveTimer('DelayedOnItemMount');
  6242.             }
  6243.         }
  6244.         else
  6245.         {
  6246.            
  6247.             RemoveTimer('DelayedOnItemMount');
  6248.         }
  6249.     }
  6250.  
  6251.     public function GetHeldItems() : array<SItemUniqueId>
  6252.     {
  6253.         var items : array<SItemUniqueId>;
  6254.         var item : SItemUniqueId;
  6255.    
  6256.         if( inv.GetItemEquippedOnSlot(EES_SilverSword, item) && inv.IsItemHeld(item))
  6257.             items.PushBack(item);
  6258.            
  6259.         if( inv.GetItemEquippedOnSlot(EES_SteelSword, item) && inv.IsItemHeld(item))
  6260.             items.PushBack(item);
  6261.  
  6262.         if( inv.GetItemEquippedOnSlot(EES_RangedWeapon, item) && inv.IsItemHeld(item))
  6263.             items.PushBack(item);
  6264.  
  6265.         if( inv.GetItemEquippedOnSlot(EES_Quickslot1, item) && inv.IsItemHeld(item))
  6266.             items.PushBack(item);
  6267.  
  6268.         if( inv.GetItemEquippedOnSlot(EES_Quickslot2, item) && inv.IsItemHeld(item))
  6269.             items.PushBack(item);
  6270.  
  6271.         if( inv.GetItemEquippedOnSlot(EES_Petard1, item) && inv.IsItemHeld(item))
  6272.             items.PushBack(item);
  6273.  
  6274.         if( inv.GetItemEquippedOnSlot(EES_Petard2, item) && inv.IsItemHeld(item))
  6275.             items.PushBack(item);
  6276.  
  6277.         return items;          
  6278.     }
  6279.    
  6280.     public function MoveMutagenToSlot( item : SItemUniqueId, slotFrom : EEquipmentSlots, slotTo : EEquipmentSlots )
  6281.     {
  6282.         var pam : W3PlayerAbilityManager;
  6283.         var prevSkillColor : ESkillColor;
  6284.         var groupID : int;
  6285.        
  6286.         if( IsSlotSkillMutagen( slotTo ) )
  6287.         {  
  6288.             itemSlots[slotFrom] = GetInvalidUniqueId();
  6289.            
  6290.            
  6291.             groupID = pam.GetSkillGroupIdOfMutagenSlot(slotFrom);
  6292.             prevSkillColor = pam.GetSkillGroupColor(groupID);
  6293.             pam = (W3PlayerAbilityManager)abilityManager;
  6294.             pam.OnSkillMutagenUnequipped(item, slotFrom, prevSkillColor, true);
  6295.            
  6296.            
  6297.            
  6298.             EquipItemInGivenSlot( item, slotTo, false );
  6299.         }
  6300.     }
  6301.    
  6302.    
  6303.     public function UnequipItemFromSlot(slot : EEquipmentSlots, optional reequipped : bool) : bool
  6304.     {
  6305.         var item, bolts, id : SItemUniqueId;
  6306.         var items : array<SItemUniqueId>;
  6307.         var retBool : bool;
  6308.         var fistsID, bolt : array<SItemUniqueId>;
  6309.         var i, groupID : int;
  6310.         var pam : W3PlayerAbilityManager;
  6311.         var prevSkillColor : ESkillColor;
  6312.         var containedAbilities : array<name>;
  6313.         var dm : CDefinitionsManagerAccessor;
  6314.         var armorType : EArmorType;
  6315.         var isSwimming : bool;
  6316.         var hud                 : CR4ScriptedHud;
  6317.         var damagedItemModule   : CR4HudModuleDamagedItems;
  6318.        
  6319.         if(slot == EES_InvalidSlot || slot < 0 || slot > EnumGetMax('EEquipmentSlots') || !inv.IsIdValid(itemSlots[slot]))
  6320.             return false;
  6321.            
  6322.        
  6323.         if(IsSlotSkillMutagen(slot))
  6324.         {
  6325.            
  6326.             pam = (W3PlayerAbilityManager)abilityManager;
  6327.             groupID = pam.GetSkillGroupIdOfMutagenSlot(slot);
  6328.             prevSkillColor = pam.GetSkillGroupColor(groupID);
  6329.         }
  6330.        
  6331.        
  6332.         if(slot == EES_SilverSword  || slot == EES_SteelSword)
  6333.         {
  6334.             PauseOilBuffs( slot == EES_SteelSword );
  6335.         }
  6336.            
  6337.         item = itemSlots[slot];
  6338.         itemSlots[slot] = GetInvalidUniqueId();
  6339.        
  6340.        
  6341.         if(inv.ItemHasTag( item, 'PhantomWeapon' ) && GetPhantomWeaponMgr())
  6342.         {
  6343.             DestroyPhantomWeaponMgr();
  6344.         }
  6345.        
  6346.        
  6347.        
  6348.        
  6349.         if( slot == EES_SilverSword && inv.ItemHasTag( item, 'Aerondight' ) )
  6350.         {
  6351.             RemoveBuff( EET_Aerondight );
  6352.         }
  6353.        
  6354.        
  6355.         if(slot == EES_RangedWeapon)
  6356.         {
  6357.            
  6358.             this.OnRangedForceHolster( true, true );
  6359.             rangedWeapon.ClearDeployedEntity(true);
  6360.             rangedWeapon = NULL;
  6361.        
  6362.            
  6363.             if(GetItemEquippedOnSlot(EES_Bolt, bolts))
  6364.             {
  6365.                 if(inv.ItemHasTag(bolts, theGame.params.TAG_INFINITE_AMMO))
  6366.                 {
  6367.                     inv.RemoveItem(bolts, inv.GetItemQuantity(bolts) );
  6368.                 }
  6369.             }
  6370.         }
  6371.         else if(IsSlotSkillMutagen(slot))
  6372.         {          
  6373.             pam.OnSkillMutagenUnequipped(item, slot, prevSkillColor);
  6374.             LogSkillColors("Mutagen <<" + inv.GetItemName(item) + ">> unequipped from slot <<" + slot + ">>");
  6375.             LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
  6376.             LogSkillColors("");
  6377.         }
  6378.        
  6379.        
  6380.         if(currentlyEquipedItem == item)
  6381.         {
  6382.             currentlyEquipedItem = GetInvalidUniqueId();
  6383.             RaiseEvent('ForcedUsableItemUnequip');
  6384.         }
  6385.         if(currentlyEquipedItemL == item)
  6386.         {
  6387.             if ( currentlyUsedItemL )
  6388.             {
  6389.                 currentlyUsedItemL.OnHidden( this );
  6390.             }
  6391.             HideUsableItem ( true );
  6392.         }
  6393.                
  6394.        
  6395.         if( !IsSlotPotionMutagen(slot) )
  6396.         {
  6397.             GetInventory().UnmountItem(item, true);
  6398.         }
  6399.        
  6400.         retBool = true;
  6401.                
  6402.        
  6403.         if(IsAnyItemEquippedOnSlot(EES_RangedWeapon) && slot == EES_Bolt)
  6404.         {          
  6405.             if(inv.ItemHasTag(item, theGame.params.TAG_INFINITE_AMMO))
  6406.             {
  6407.                
  6408.                 inv.RemoveItem(item, inv.GetItemQuantityByName( inv.GetItemName(item) ) );
  6409.             }
  6410.             else if (!reequipped)
  6411.             {
  6412.                
  6413.                 AddAndEquipInfiniteBolt();
  6414.             }
  6415.         }
  6416.        
  6417.        
  6418.         if(slot == EES_SilverSword  || slot == EES_SteelSword)
  6419.         {
  6420.             OnEquipMeleeWeapon(PW_None, true);         
  6421.         }
  6422.        
  6423.         if(  GetSelectedItemId() == item )
  6424.         {
  6425.             ClearSelectedItemId();
  6426.         }
  6427.        
  6428.         if(inv.IsItemBody(item))
  6429.         {
  6430.             retBool = true;
  6431.         }      
  6432.        
  6433.         if(retBool && !reequipped)
  6434.         {
  6435.             theTelemetry.LogWithLabelAndValue( TE_INV_ITEM_UNEQUIPPED, inv.GetItemName(item), slot );
  6436.            
  6437.            
  6438.             if(slot == EES_SteelSword && !IsAnyItemEquippedOnSlot(EES_SilverSword))
  6439.             {
  6440.                 RemoveBuff(EET_EnhancedWeapon);
  6441.             }
  6442.             else if(slot == EES_SilverSword && !IsAnyItemEquippedOnSlot(EES_SteelSword))
  6443.             {
  6444.                 RemoveBuff(EET_EnhancedWeapon);
  6445.             }
  6446.             else if(inv.IsItemAnyArmor(item))
  6447.             {
  6448.                 if( !IsAnyItemEquippedOnSlot(EES_Armor) && !IsAnyItemEquippedOnSlot(EES_Gloves) && !IsAnyItemEquippedOnSlot(EES_Boots) && !IsAnyItemEquippedOnSlot(EES_Pants))
  6449.                     RemoveBuff(EET_EnhancedArmor);
  6450.             }
  6451.         }
  6452.        
  6453.        
  6454.         if(inv.ItemHasAbility(item, 'MA_HtH'))
  6455.         {
  6456.             inv.GetItemContainedAbilities(item, containedAbilities);
  6457.             fistsID = inv.GetItemsByName('fists');
  6458.             dm = theGame.GetDefinitionsManager();
  6459.             for(i=0; i<containedAbilities.Size(); i+=1)
  6460.             {
  6461.                 if(dm.AbilityHasTag(containedAbilities[i], 'MA_HtH'))
  6462.                 {
  6463.                     inv.RemoveItemCraftedAbility(fistsID[0], containedAbilities[i]);
  6464.                 }
  6465.             }
  6466.         }
  6467.        
  6468.        
  6469.         if(inv.IsItemAnyArmor(item))
  6470.         {
  6471.             armorType = inv.GetArmorType(item);
  6472.             pam = (W3PlayerAbilityManager)abilityManager;
  6473.            
  6474.             if(CanUseSkill(S_Perk_05) && (armorType == EAT_Light || GetCharacterStats().HasAbility('Glyphword 2 _Stats', true) || inv.ItemHasAbility(item, 'Glyphword 2 _Stats')))
  6475.             {
  6476.                 pam.SetPerkArmorBonus(S_Perk_05);
  6477.             }
  6478.             if(CanUseSkill(S_Perk_06) && (armorType == EAT_Medium || GetCharacterStats().HasAbility('Glyphword 3 _Stats', true) || inv.ItemHasAbility(item, 'Glyphword 3 _Stats')) )
  6479.             {
  6480.                 pam.SetPerkArmorBonus(S_Perk_06);
  6481.             }
  6482.             if(CanUseSkill(S_Perk_07) && (armorType == EAT_Heavy || GetCharacterStats().HasAbility('Glyphword 4 _Stats', true) || inv.ItemHasAbility(item, 'Glyphword 4 _Stats')) )
  6483.             {
  6484.                 pam.SetPerkArmorBonus(S_Perk_07);
  6485.             }
  6486.         }
  6487.        
  6488.        
  6489.         UpdateItemSetBonuses( item, false );
  6490.        
  6491.        
  6492.         if( inv.ItemHasTag( item, theGame.params.ITEM_SET_TAG_BONUS ) && !IsSetBonusActive( EISB_RedWolf_2 ) )
  6493.         {
  6494.             SkillReduceBombAmmoBonus();
  6495.         }
  6496.  
  6497.         if( slot == EES_Gloves )
  6498.         {
  6499.             thePlayer.DestroyEffect('runeword_4');
  6500.         }
  6501.        
  6502.        
  6503.         hud = (CR4ScriptedHud)theGame.GetHud();
  6504.         if ( hud )
  6505.         {
  6506.             damagedItemModule = hud.GetDamagedItemModule();
  6507.             if ( damagedItemModule )
  6508.             {
  6509.                 damagedItemModule.OnItemUnequippedFromSlot( slot );
  6510.             }
  6511.         }
  6512.        
  6513.        
  6514.         theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnItemEquipped );
  6515.        
  6516.         return retBool;
  6517.     }
  6518.        
  6519.     public function UnequipItem(item : SItemUniqueId) : bool
  6520.     {
  6521.         if(!inv.IsIdValid(item))
  6522.             return false;
  6523.        
  6524.         return UnequipItemFromSlot( itemSlots.FindFirst(item) );
  6525.     }
  6526.    
  6527.     public function DropItem( item : SItemUniqueId, quantity : int ) : bool
  6528.     {
  6529.         if(!inv.IsIdValid(item))
  6530.             return false;
  6531.         if(IsItemEquipped(item))
  6532.             return UnequipItem(item);
  6533.        
  6534.         return true;
  6535.     }  
  6536.    
  6537.    
  6538.     public function IsItemEquippedByName(itemName : name) : bool
  6539.     {
  6540.         var i : int;
  6541.    
  6542.         for(i=0; i<itemSlots.Size(); i+=1)
  6543.             if(inv.GetItemName(itemSlots[i]) == itemName)
  6544.                 return true;
  6545.  
  6546.         return false;
  6547.     }
  6548.  
  6549.    
  6550.     public function IsItemEquippedByCategoryName(categoryName : name) : bool
  6551.     {
  6552.         var i : int;
  6553.    
  6554.         for(i=0; i<itemSlots.Size(); i+=1)
  6555.             if(inv.GetItemCategory(itemSlots[i]) == categoryName)
  6556.                 return true;
  6557.                
  6558.         return false;
  6559.     }
  6560.    
  6561.     public function GetMaxRunEncumbrance(out usesHorseBonus : bool) : float
  6562.     {
  6563.         var value : float;
  6564.        
  6565.         value = CalculateAttributeValue(GetHorseManager().GetHorseAttributeValue('encumbrance', false));
  6566.         usesHorseBonus = (value > 0);
  6567.         value += CalculateAttributeValue( GetAttributeValue('encumbrance') );
  6568.        
  6569.         return value;
  6570.     }
  6571.        
  6572.     public function GetEncumbrance() : float
  6573.     {
  6574.         var i: int;
  6575.         var encumbrance : float;
  6576.         var items : array<SItemUniqueId>;
  6577.         var inve : CInventoryComponent;
  6578.    
  6579.         inve = GetInventory();         
  6580.         inve.GetAllItems(items);
  6581.  
  6582.         for(i=0; i<items.Size(); i+=1)
  6583.         {
  6584.             encumbrance += inve.GetItemEncumbrance( items[i] );
  6585.            
  6586.            
  6587.            
  6588.         }      
  6589.         return encumbrance;
  6590.     }
  6591.    
  6592.    
  6593.    
  6594.     public function StartInvUpdateTransaction():void
  6595.     {
  6596.         invUpdateTransaction = true;
  6597.     }
  6598.    
  6599.     public function FinishInvUpdateTransaction():void
  6600.     {
  6601.         invUpdateTransaction = false;
  6602.        
  6603.        
  6604.        
  6605.         UpdateEncumbrance();
  6606.     }
  6607.    
  6608.    
  6609.     public function UpdateEncumbrance()
  6610.     {
  6611.         var temp : bool;
  6612.        
  6613.         if (invUpdateTransaction)
  6614.         {
  6615.            
  6616.             return;
  6617.         }
  6618.        
  6619.        
  6620.        
  6621.         if ( GetEncumbrance() >= (GetMaxRunEncumbrance(temp) + 1) )
  6622.         {
  6623.             if( !HasBuff(EET_OverEncumbered) && FactsQuerySum( "DEBUG_EncumbranceBoy" ) == 0 )
  6624.             {
  6625.                 AddEffectDefault(EET_OverEncumbered, NULL, "OverEncumbered");
  6626.             }
  6627.         }
  6628.         else if(HasBuff(EET_OverEncumbered))
  6629.         {
  6630.             RemoveAllBuffsOfType(EET_OverEncumbered);
  6631.         }
  6632.     }
  6633.    
  6634.     public final function GetSkillGroupIDFromIndex(idx : int) : int
  6635.     {
  6636.         var pam : W3PlayerAbilityManager;
  6637.        
  6638.         pam = (W3PlayerAbilityManager)abilityManager;
  6639.         if(pam && pam.IsInitialized())
  6640.             return pam.GetSkillGroupIDFromIndex(idx);
  6641.            
  6642.         return -1;
  6643.     }
  6644.    
  6645.     public final function GetSkillGroupColor(groupID : int) : ESkillColor
  6646.     {
  6647.         var pam : W3PlayerAbilityManager;
  6648.        
  6649.         pam = (W3PlayerAbilityManager)abilityManager;
  6650.         if(pam && pam.IsInitialized())
  6651.             return pam.GetSkillGroupColor(groupID);
  6652.            
  6653.         return SC_None;
  6654.     }
  6655.    
  6656.     public final function GetSkillGroupsCount() : int
  6657.     {
  6658.         var pam : W3PlayerAbilityManager;
  6659.        
  6660.         pam = (W3PlayerAbilityManager)abilityManager;
  6661.         if(pam && pam.IsInitialized())
  6662.             return pam.GetSkillGroupsCount();
  6663.            
  6664.         return 0;
  6665.     }
  6666.    
  6667.    
  6668.    
  6669.    
  6670.    
  6671.    
  6672.    
  6673.    
  6674.     function CycleSelectSign( bIsCyclingLeft : bool ) : ESignType
  6675.     {
  6676.         var signOrder : array<ESignType>;
  6677.         var i : int;
  6678.        
  6679.         signOrder.PushBack( ST_Yrden );
  6680.         signOrder.PushBack( ST_Quen );
  6681.         signOrder.PushBack( ST_Igni );
  6682.         signOrder.PushBack( ST_Axii );
  6683.         signOrder.PushBack( ST_Aard );
  6684.            
  6685.         for( i = 0; i < signOrder.Size(); i += 1 )
  6686.             if( signOrder[i] == equippedSign )
  6687.                 break;
  6688.        
  6689.         if(bIsCyclingLeft)
  6690.             return signOrder[ (4 + i) % 5 ];   
  6691.         else
  6692.             return signOrder[ (6 + i) % 5 ];
  6693.     }
  6694.    
  6695.     function ToggleNextSign()
  6696.     {
  6697.         SetEquippedSign(CycleSelectSign( false ));
  6698.         FactsAdd("SignToggled", 1, 1);
  6699.     }
  6700.    
  6701.     function TogglePreviousSign()
  6702.     {
  6703.         SetEquippedSign(CycleSelectSign( true ));
  6704.         FactsAdd("SignToggled", 1, 1);
  6705.     }
  6706.    
  6707.     function ProcessSignEvent( eventName : name ) : bool
  6708.     {
  6709.         if( currentlyCastSign != ST_None && signs[currentlyCastSign].entity)
  6710.         {
  6711.             return signs[currentlyCastSign].entity.OnProcessSignEvent( eventName );
  6712.         }
  6713.        
  6714.         return false;
  6715.     }
  6716.    
  6717.     var findActorTargetTimeStamp : float;
  6718.     var pcModeChanneledSignTimeStamp    : float;
  6719.     event OnProcessCastingOrientation( isContinueCasting : bool )
  6720.     {
  6721.         var customOrientationTarget : EOrientationTarget;
  6722.         var checkHeading            : float;
  6723.         var rotHeading              : float;
  6724.         var playerToHeadingDist     : float;
  6725.         var slideTargetActor        : CActor;
  6726.         var newLockTarget           : CActor;
  6727.        
  6728.         var enableNoTargetOrientation   : bool;
  6729.        
  6730.         var currTime : float;
  6731.        
  6732.         enableNoTargetOrientation = true;
  6733.         if ( GetDisplayTarget() && this.IsDisplayTargetTargetable() )
  6734.         {
  6735.             enableNoTargetOrientation = false;
  6736.             if ( theInput.GetActionValue( 'CastSignHold' ) > 0 || this.IsCurrentSignChanneled() )
  6737.             {
  6738.                 if ( IsPCModeEnabled() )
  6739.                 {
  6740.                     if ( EngineTimeToFloat( theGame.GetEngineTime() ) >  pcModeChanneledSignTimeStamp + 1.f )
  6741.                         enableNoTargetOrientation = true;
  6742.                 }
  6743.                 else
  6744.                 {
  6745.                     if ( GetCurrentlyCastSign() == ST_Igni || GetCurrentlyCastSign() == ST_Axii )
  6746.                     {
  6747.                         slideTargetActor = (CActor)GetDisplayTarget();
  6748.                         if ( slideTargetActor
  6749.                             && ( !slideTargetActor.GetGameplayVisibility() || !CanBeTargetedIfSwimming( slideTargetActor ) || !slideTargetActor.IsAlive() ) )
  6750.                         {
  6751.                             SetSlideTarget( NULL );
  6752.                             if ( ProcessLockTarget() )
  6753.                                 slideTargetActor = (CActor)slideTarget;
  6754.                         }              
  6755.                        
  6756.                         if ( !slideTargetActor )
  6757.                         {
  6758.                             LockToTarget( false );
  6759.                             enableNoTargetOrientation = true;
  6760.                         }
  6761.                         else if ( IsThreat( slideTargetActor ) || GetCurrentlyCastSign() == ST_Axii )
  6762.                             LockToTarget( true );
  6763.                         else
  6764.                         {
  6765.                             LockToTarget( false );
  6766.                             enableNoTargetOrientation = true;
  6767.                         }
  6768.                     }
  6769.                 }
  6770.             }
  6771.  
  6772.             if ( !enableNoTargetOrientation )
  6773.             {          
  6774.                 customOrientationTarget = OT_Actor;
  6775.             }
  6776.         }
  6777.        
  6778.         if ( enableNoTargetOrientation )
  6779.         {
  6780.             if ( GetPlayerCombatStance() == PCS_AlertNear && theInput.GetActionValue( 'CastSignHold' ) > 0 )
  6781.             {
  6782.                 if ( GetDisplayTarget() && !slideTargetActor )
  6783.                 {
  6784.                     currTime = EngineTimeToFloat( theGame.GetEngineTime() );
  6785.                     if ( currTime > findActorTargetTimeStamp + 1.5f )
  6786.                     {
  6787.                         findActorTargetTimeStamp = currTime;
  6788.                        
  6789.                         newLockTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, 0.f, true );
  6790.                        
  6791.                         if ( newLockTarget && IsThreat( newLockTarget ) && IsCombatMusicEnabled() )
  6792.                         {
  6793.                             SetTarget( newLockTarget, true );
  6794.                             SetMoveTargetChangeAllowed( true );
  6795.                             SetMoveTarget( newLockTarget );
  6796.                             SetMoveTargetChangeAllowed( false );
  6797.                             SetSlideTarget( newLockTarget );                           
  6798.                         }  
  6799.                     }
  6800.                 }
  6801.                 else
  6802.                     ProcessLockTarget();
  6803.             }
  6804.            
  6805.             if ( wasBRAxisPushed )
  6806.                 customOrientationTarget = OT_CameraOffset;
  6807.             else
  6808.             {
  6809.                 if ( !lastAxisInputIsMovement || theInput.LastUsedPCInput() )
  6810.                     customOrientationTarget = OT_CameraOffset;
  6811.                 else if ( theInput.GetActionValue( 'CastSignHold' ) > 0 )
  6812.                 {
  6813.                     if ( GetOrientationTarget() == OT_CameraOffset )
  6814.                         customOrientationTarget = OT_CameraOffset;
  6815.                     else if ( GetPlayerCombatStance() == PCS_AlertNear || GetPlayerCombatStance() == PCS_Guarded )
  6816.                         customOrientationTarget = OT_CameraOffset;
  6817.                     else
  6818.                         customOrientationTarget = OT_Player;   
  6819.                 }
  6820.                 else
  6821.                     customOrientationTarget = OT_CustomHeading;
  6822.             }          
  6823.         }      
  6824.        
  6825.         if ( GetCurrentlyCastSign() == ST_Quen )
  6826.         {
  6827.             if ( theInput.LastUsedPCInput() )
  6828.             {
  6829.                 customOrientationTarget = OT_Camera;
  6830.             }
  6831.             else if ( IsCurrentSignChanneled() )
  6832.             {
  6833.                 if ( bLAxisReleased )
  6834.                     customOrientationTarget = OT_Player;
  6835.                 else
  6836.                     customOrientationTarget = OT_Camera;
  6837.             }
  6838.             else
  6839.                 customOrientationTarget = OT_Player;
  6840.         }  
  6841.        
  6842.         if ( GetCurrentlyCastSign() == ST_Axii && IsCurrentSignChanneled() )
  6843.         {  
  6844.             if ( slideTarget && (CActor)slideTarget )
  6845.             {
  6846.                 checkHeading = VecHeading( slideTarget.GetWorldPosition() - this.GetWorldPosition() );
  6847.                 rotHeading = checkHeading;
  6848.                 playerToHeadingDist = AngleDistance( GetHeading(), checkHeading );
  6849.                
  6850.                 if ( playerToHeadingDist > 45 )
  6851.                     SetCustomRotation( 'ChanneledSignAxii', rotHeading, 0.0, 0.5, false );
  6852.                 else if ( playerToHeadingDist < -45 )
  6853.                     SetCustomRotation( 'ChanneledSignAxii', rotHeading, 0.0, 0.5, false );                 
  6854.             }
  6855.             else
  6856.             {
  6857.                 checkHeading = VecHeading( theCamera.GetCameraDirection() );
  6858.                 rotHeading = GetHeading();
  6859.                 playerToHeadingDist = AngleDistance( GetHeading(), checkHeading );
  6860.                
  6861.                 if ( playerToHeadingDist > 45 )
  6862.                     SetCustomRotation( 'ChanneledSignAxii', rotHeading - 22.5, 0.0, 0.5, false );
  6863.                 else if ( playerToHeadingDist < -45 )
  6864.                     SetCustomRotation( 'ChanneledSignAxii', rotHeading + 22.5, 0.0, 0.5, false );              
  6865.             }
  6866.         }      
  6867.            
  6868.         if ( IsActorLockedToTarget() )
  6869.             customOrientationTarget = OT_Actor;
  6870.        
  6871.         AddCustomOrientationTarget( customOrientationTarget, 'Signs' );
  6872.        
  6873.         if ( customOrientationTarget == OT_CustomHeading )
  6874.             SetOrientationTargetCustomHeading( GetCombatActionHeading(), 'Signs' );        
  6875.     }
  6876.    
  6877.     event OnRaiseSignEvent()
  6878.     {
  6879.         var newTarget : CActor;
  6880.    
  6881.         if ( ( !IsCombatMusicEnabled() && !CanAttackWhenNotInCombat( EBAT_CastSign, false, newTarget ) ) || ( IsOnBoat() && !IsCombatMusicEnabled() ) )
  6882.         {      
  6883.             if ( CastSignFriendly() )
  6884.                 return true;
  6885.         }
  6886.         else
  6887.         {
  6888.             RaiseEvent('CombatActionFriendlyEnd');
  6889.             SetBehaviorVariable( 'SignNum', (int)equippedSign );
  6890.             SetBehaviorVariable( 'combatActionType', (int)CAT_CastSign );
  6891.  
  6892.             if ( IsPCModeEnabled() )
  6893.                 pcModeChanneledSignTimeStamp = EngineTimeToFloat( theGame.GetEngineTime() );
  6894.        
  6895.             if( RaiseForceEvent('CombatAction') )
  6896.             {
  6897.                 OnCombatActionStart();
  6898.                 findActorTargetTimeStamp = EngineTimeToFloat( theGame.GetEngineTime() );
  6899.                 theTelemetry.LogWithValueStr(TE_FIGHT_PLAYER_USE_SIGN, SignEnumToString( equippedSign ));
  6900.                 return true;
  6901.             }
  6902.         }
  6903.        
  6904.         return false;
  6905.     }
  6906.    
  6907.     function CastSignFriendly() : bool
  6908.     {
  6909.         var actor : CActor;
  6910.    
  6911.         SetBehaviorVariable( 'combatActionTypeForOverlay', (int)CAT_CastSign );        
  6912.         if ( RaiseCombatActionFriendlyEvent() )
  6913.         {
  6914.                        
  6915.             return true;
  6916.         }  
  6917.        
  6918.         return false;
  6919.     }
  6920.    
  6921.     function CastSign() : bool
  6922.     {
  6923.         var equippedSignStr : string;
  6924.         var newSignEnt : W3SignEntity;
  6925.         var spawnPos : Vector;
  6926.         var slotMatrix : Matrix;
  6927.         var target : CActor;
  6928.        
  6929.         if ( IsInAir() )
  6930.         {
  6931.             return false;
  6932.         }
  6933.        
  6934.         AddTemporarySkills();
  6935.        
  6936.        
  6937.        
  6938.         if(equippedSign == ST_Aard)
  6939.         {
  6940.             CalcEntitySlotMatrix('l_weapon', slotMatrix);
  6941.             spawnPos = MatrixGetTranslation(slotMatrix);
  6942.         }
  6943.         else
  6944.         {
  6945.             spawnPos = GetWorldPosition();
  6946.         }
  6947.        
  6948.         if( equippedSign == ST_Aard || equippedSign == ST_Igni )
  6949.         {
  6950.             target = GetTarget();
  6951.             if(target)
  6952.                 target.SignalGameplayEvent( 'DodgeSign' );
  6953.         }
  6954.  
  6955.         m_TriggerEffectDisablePending = true;
  6956.         m_TriggerEffectDisableTTW = 0.3;
  6957.        
  6958.         newSignEnt = (W3SignEntity)theGame.CreateEntity( signs[equippedSign].template, spawnPos, GetWorldRotation() );
  6959.         return newSignEnt.Init( signOwner, signs[equippedSign].entity );
  6960.     }
  6961.    
  6962.    
  6963.     private function HAX_SignToThrowItemRestore()
  6964.     {
  6965.         var action : SInputAction;
  6966.        
  6967.         action.value = theInput.GetActionValue('ThrowItemHold');
  6968.         action.lastFrameValue = 0;
  6969.        
  6970.         if(IsPressed(action) && CanSetupCombatAction_Throw())
  6971.         {
  6972.             if(inv.IsItemBomb(selectedItemId))
  6973.             {
  6974.                 BombThrowStart();
  6975.             }
  6976.             else
  6977.             {
  6978.                 UsableItemStart();
  6979.             }
  6980.            
  6981.             SetThrowHold( true );
  6982.         }
  6983.     }
  6984.    
  6985.     event OnCFMCameraZoomFail(){}
  6986.        
  6987.    
  6988.  
  6989.     public final function GetDrunkMutagens( optional sourceName : string ) : array<CBaseGameplayEffect>
  6990.     {
  6991.         return effectManager.GetDrunkMutagens( sourceName );
  6992.     }
  6993.    
  6994.     public final function GetPotionBuffs() : array<CBaseGameplayEffect>
  6995.     {
  6996.         return effectManager.GetPotionBuffs();
  6997.     }
  6998.    
  6999.     public final function RecalcPotionsDurations()
  7000.     {
  7001.         var i : int;
  7002.         var buffs : array<CBaseGameplayEffect>;
  7003.        
  7004.         buffs = GetPotionBuffs();
  7005.         for(i=0; i<buffs.Size(); i+=1)
  7006.         {
  7007.             buffs[i].RecalcPotionDuration();
  7008.         }
  7009.     }
  7010.  
  7011.     public function StartFrenzy()
  7012.     {
  7013.         var ratio, duration : float;
  7014.         var skillLevel : int;
  7015.    
  7016.         isInFrenzy = true;
  7017.         skillLevel = GetSkillLevel(S_Alchemy_s16);
  7018.         ratio = 0.48f - skillLevel * CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s16, 'slowdown_ratio', false, true));
  7019.         duration = skillLevel * CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s16, 'slowdown_duration', false, true));
  7020.    
  7021.         theGame.SetTimeScale(ratio, theGame.GetTimescaleSource(ETS_SkillFrenzy), theGame.GetTimescalePriority(ETS_SkillFrenzy) );
  7022.         AddTimer('SkillFrenzyFinish', duration * ratio, , , , true);
  7023.     }
  7024.    
  7025.     timer function SkillFrenzyFinish(dt : float, optional id : int)
  7026.     {      
  7027.         theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_SkillFrenzy) );
  7028.         isInFrenzy = false;
  7029.     }
  7030.    
  7031.     public function GetToxicityDamageThreshold() : float
  7032.     {
  7033.         var ret : float;
  7034.        
  7035.         ret = theGame.params.TOXICITY_DAMAGE_THRESHOLD;
  7036.        
  7037.         if(CanUseSkill(S_Alchemy_s01))
  7038.             ret += CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s01, 'threshold', false, true)) * GetSkillLevel(S_Alchemy_s01);
  7039.        
  7040.         return ret;
  7041.     }
  7042.    
  7043.    
  7044.    
  7045.     public final function AddToxicityOffset( val : float)
  7046.     {
  7047.         ((W3PlayerAbilityManager)abilityManager).AddToxicityOffset(val);       
  7048.     }
  7049.    
  7050.     public final function SetToxicityOffset( val : float)
  7051.     {
  7052.         ((W3PlayerAbilityManager)abilityManager).SetToxicityOffset(val);
  7053.     }
  7054.    
  7055.     public final function RemoveToxicityOffset( val : float)
  7056.     {
  7057.         ((W3PlayerAbilityManager)abilityManager).RemoveToxicityOffset(val);    
  7058.     }
  7059.    
  7060.    
  7061.     public final function CalculatePotionDuration(item : SItemUniqueId, isMutagenPotion : bool, optional itemName : name) : float
  7062.     {
  7063.         var duration, skillPassiveMod, mutagenSkillMod : float;
  7064.         var val, min, max : SAbilityAttributeValue;
  7065.        
  7066.        
  7067.         if(inv.IsIdValid(item))
  7068.         {
  7069.             duration = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'duration'));           
  7070.         }
  7071.         else
  7072.         {
  7073.             theGame.GetDefinitionsManager().GetItemAttributeValueNoRandom(itemName, true, 'duration', min, max);
  7074.             duration = CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  7075.         }
  7076.            
  7077.         skillPassiveMod = CalculateAttributeValue(GetAttributeValue('potion_duration'));
  7078.        
  7079.         if(isMutagenPotion && CanUseSkill(S_Alchemy_s14))
  7080.         {
  7081.             val = GetSkillAttributeValue(S_Alchemy_s14, 'duration', false, true);
  7082.             mutagenSkillMod = val.valueMultiplicative * GetSkillLevel(S_Alchemy_s14);
  7083.         }
  7084.        
  7085.         duration = duration * (1 + skillPassiveMod + mutagenSkillMod);
  7086.        
  7087.        
  7088.         if( IsSetBonusActive( EISB_Netflix_1 ) )
  7089.         {
  7090.             duration += (duration * (amountOfSetPiecesEquipped[ EIST_Netflix ] * 7 )) / 100 ;
  7091.         }
  7092.        
  7093.         return duration;
  7094.     }
  7095.    
  7096.     public function ToxicityLowEnoughToDrinkPotion( slotid : EEquipmentSlots, optional itemId : SItemUniqueId ) : bool
  7097.     {
  7098.         var item                : SItemUniqueId;
  7099.         var maxTox              : float;
  7100.         var potionToxicity      : float;
  7101.         var toxicityOffset      : float;
  7102.         var effectType          : EEffectType;
  7103.         var customAbilityName   : name;
  7104.        
  7105.         if(itemId != GetInvalidUniqueId())
  7106.             item = itemId;
  7107.         else
  7108.             item = itemSlots[slotid];
  7109.        
  7110.         inv.GetPotionItemBuffData(item, effectType, customAbilityName);
  7111.         maxTox = abilityManager.GetStatMax(BCS_Toxicity);
  7112.         potionToxicity = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity'));
  7113.         toxicityOffset = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity_offset'));
  7114.        
  7115.         if(effectType != EET_WhiteHoney)
  7116.         {
  7117.             if(abilityManager.GetStat(BCS_Toxicity, false) + potionToxicity + toxicityOffset > maxTox )
  7118.             {
  7119.                 return false;
  7120.             }
  7121.         }
  7122.        
  7123.         return true;
  7124.     }
  7125.    
  7126.     public final function HasFreeToxicityToDrinkPotion( item : SItemUniqueId, effectType : EEffectType, out finalPotionToxicity : float ) : bool
  7127.     {
  7128.         var i : int;
  7129.         var maxTox, toxicityOffset, adrenaline : float;
  7130.         var costReduction : SAbilityAttributeValue;
  7131.        
  7132.        
  7133.         if( effectType == EET_WhiteHoney )
  7134.         {
  7135.             return true;
  7136.         }
  7137.        
  7138.        
  7139.         maxTox = abilityManager.GetStatMax(BCS_Toxicity);
  7140.         finalPotionToxicity = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity'));
  7141.         toxicityOffset = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity_offset'));
  7142.        
  7143.        
  7144.         if(CanUseSkill(S_Perk_13))
  7145.         {
  7146.             costReduction = GetSkillAttributeValue(S_Perk_13, 'cost_reduction', false, true);
  7147.             adrenaline = FloorF(GetStat(BCS_Focus));
  7148.             costReduction = costReduction * adrenaline;
  7149.             finalPotionToxicity = (finalPotionToxicity - costReduction.valueBase) * (1 - costReduction.valueMultiplicative) - costReduction.valueAdditive;
  7150.             finalPotionToxicity = MaxF(0.f, finalPotionToxicity);
  7151.         }
  7152.        
  7153.        
  7154.         if(abilityManager.GetStat(BCS_Toxicity, false) + finalPotionToxicity + toxicityOffset > maxTox )
  7155.         {
  7156.             return false;
  7157.         }
  7158.        
  7159.         return true;
  7160.     }
  7161.    
  7162.     public function DrinkPreparedPotion( slotid : EEquipmentSlots, optional itemId : SItemUniqueId )
  7163.     {  
  7164.         var potParams : W3PotionParams;
  7165.         var potionParams : SCustomEffectParams;
  7166.         var factPotionParams : W3Potion_Fact_Params;
  7167.         var adrenaline, hpGainValue, duration, finalPotionToxicity : float;
  7168.         var ret : EEffectInteract;
  7169.         var effectType : EEffectType;
  7170.         var item : SItemUniqueId;
  7171.         var customAbilityName, factId : name;
  7172.         var atts : array<name>;
  7173.         var i : int;
  7174.         var mutagenParams : W3MutagenBuffCustomParams;
  7175.        
  7176.        
  7177.         if(itemId != GetInvalidUniqueId())
  7178.             item = itemId;
  7179.         else
  7180.             item = itemSlots[slotid];
  7181.        
  7182.        
  7183.         if(!inv.IsIdValid(item))
  7184.             return;
  7185.            
  7186.        
  7187.         if( inv.SingletonItemGetAmmo(item) == 0 )
  7188.             return;
  7189.            
  7190.        
  7191.         inv.GetPotionItemBuffData(item, effectType, customAbilityName);
  7192.            
  7193.        
  7194.         if( !HasFreeToxicityToDrinkPotion( item, effectType, finalPotionToxicity ) )
  7195.         {
  7196.             return;
  7197.         }
  7198.                
  7199.        
  7200.         if(effectType == EET_Fact)
  7201.         {
  7202.             inv.GetItemAttributes(item, atts);
  7203.            
  7204.             for(i=0; i<atts.Size(); i+=1)
  7205.             {
  7206.                 if(StrBeginsWith(NameToString(atts[i]), "fact_"))
  7207.                 {
  7208.                     factId = atts[i];
  7209.                     break;
  7210.                 }
  7211.             }
  7212.            
  7213.             factPotionParams = new W3Potion_Fact_Params in theGame;
  7214.             factPotionParams.factName = factId;
  7215.             factPotionParams.potionItemName = inv.GetItemName(item);
  7216.            
  7217.             potionParams.buffSpecificParams = factPotionParams;
  7218.         }
  7219.        
  7220.         else if(inv.ItemHasTag( item, 'Mutagen' ))
  7221.         {
  7222.             mutagenParams = new W3MutagenBuffCustomParams in theGame;
  7223.             mutagenParams.toxicityOffset = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity_offset'));
  7224.             mutagenParams.potionItemName = inv.GetItemName(item);
  7225.            
  7226.             finalPotionToxicity += 0.001f;
  7227.            
  7228.             potionParams.buffSpecificParams = mutagenParams;
  7229.            
  7230.             if( IsMutationActive( EPMT_Mutation10 ) && !HasBuff( EET_Mutation10 ) )
  7231.             {
  7232.                 AddEffectDefault( EET_Mutation10, this, "Mutation 10" );
  7233.             }
  7234.         }
  7235.        
  7236.         else
  7237.         {
  7238.             potParams = new W3PotionParams in theGame;
  7239.             potParams.potionItemName = inv.GetItemName(item);
  7240.            
  7241.             potionParams.buffSpecificParams = potParams;
  7242.         }
  7243.    
  7244.        
  7245.         duration = CalculatePotionDuration(item, inv.ItemHasTag( item, 'Mutagen' ));       
  7246.  
  7247.        
  7248.         potionParams.effectType = effectType;
  7249.         potionParams.creator = this;
  7250.         potionParams.sourceName = "drank_potion";
  7251.         potionParams.duration = duration;
  7252.         potionParams.customAbilityName = customAbilityName;
  7253.         ret = AddEffectCustom(potionParams);
  7254.  
  7255.        
  7256.         if(factPotionParams)
  7257.             delete factPotionParams;
  7258.            
  7259.         if(mutagenParams)
  7260.             delete mutagenParams;
  7261.            
  7262.        
  7263.         inv.SingletonItemRemoveAmmo(item);
  7264.        
  7265.        
  7266.         if(ret == EI_Pass || ret == EI_Override || ret == EI_Cumulate)
  7267.         {
  7268.             if( finalPotionToxicity > 0.f )
  7269.             {              
  7270.                 abilityManager.GainStat(BCS_Toxicity, finalPotionToxicity );
  7271.             }
  7272.            
  7273.            
  7274.             if(CanUseSkill(S_Perk_13))
  7275.             {
  7276.                 abilityManager.DrainFocus(adrenaline);
  7277.             }
  7278.            
  7279.             if (!IsEffectActive('invisible'))
  7280.             {
  7281.                 PlayEffect('use_potion');
  7282.             }
  7283.            
  7284.             if ( inv.ItemHasTag( item, 'Mutagen' ) )
  7285.             {
  7286.                
  7287.                 theGame.GetGamerProfile().CheckTrialOfGrasses();
  7288.                
  7289.                
  7290.                 SetFailedFundamentalsFirstAchievementCondition(true);
  7291.             }
  7292.            
  7293.            
  7294.             if(CanUseSkill(S_Alchemy_s02))
  7295.             {
  7296.                 hpGainValue = ClampF(GetStatMax(BCS_Vitality) * CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s02, 'vitality_gain_perc', false, true)) * GetSkillLevel(S_Alchemy_s02), 0, GetStatMax(BCS_Vitality));
  7297.                 GainStat(BCS_Vitality, hpGainValue);
  7298.             }          
  7299.            
  7300.            
  7301.             if(CanUseSkill(S_Alchemy_s04) && !skillBonusPotionEffect && (RandF() < CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s04, 'apply_chance', false, true)) * GetSkillLevel(S_Alchemy_s04)))
  7302.             {
  7303.                 AddRandomPotionEffectFromAlch4Skill( effectType );             
  7304.             }
  7305.            
  7306.             theGame.GetGamerProfile().SetStat(ES_ActivePotions, effectManager.GetPotionBuffsCount());
  7307.         }
  7308.        
  7309.         theTelemetry.LogWithLabel(TE_ELIXIR_USED, inv.GetItemName(item));
  7310.        
  7311.         if(ShouldProcessTutorial('TutorialPotionAmmo'))
  7312.         {
  7313.             FactsAdd("tut_used_potion");
  7314.         }
  7315.        
  7316.         SetFailedFundamentalsFirstAchievementCondition(true);
  7317.     }
  7318.    
  7319.    
  7320.     private final function AddRandomPotionEffectFromAlch4Skill( currentlyDrankPotion : EEffectType )
  7321.     {
  7322.         var randomPotions : array<EEffectType>;
  7323.         var currentPotion : CBaseGameplayEffect;
  7324.         var effectsOld, effectsNew : array<CBaseGameplayEffect>;
  7325.         var i, ind : int;
  7326.         var duration : float;
  7327.         var params : SCustomEffectParams;
  7328.         var ret : EEffectInteract;
  7329.        
  7330.        
  7331.         randomPotions.PushBack( EET_BlackBlood );
  7332.         randomPotions.PushBack( EET_Blizzard );
  7333.         randomPotions.PushBack( EET_FullMoon );
  7334.         randomPotions.PushBack( EET_GoldenOriole );
  7335.        
  7336.         randomPotions.PushBack( EET_MariborForest );
  7337.         randomPotions.PushBack( EET_PetriPhiltre );
  7338.         randomPotions.PushBack( EET_Swallow );
  7339.         randomPotions.PushBack( EET_TawnyOwl );
  7340.         randomPotions.PushBack( EET_Thunderbolt );
  7341.        
  7342.        
  7343.         randomPotions.Remove( currentlyDrankPotion );
  7344.        
  7345.        
  7346.         ind = RandRange( randomPotions.Size() );
  7347.  
  7348.        
  7349.         if( HasBuff( randomPotions[ ind ] ) )
  7350.         {
  7351.             currentPotion = GetBuff( randomPotions[ ind ] );
  7352.             currentPotion.SetTimeLeft( currentPotion.GetInitialDurationAfterResists() );
  7353.         }
  7354.        
  7355.         else
  7356.         {          
  7357.             duration = BonusPotionGetDurationFromXML( randomPotions[ ind ] );
  7358.            
  7359.             if(duration > 0)
  7360.             {
  7361.                 effectsOld = GetCurrentEffects();
  7362.                                    
  7363.                 params.effectType = randomPotions[ ind ];
  7364.                 params.creator = this;
  7365.                 params.sourceName = SkillEnumToName( S_Alchemy_s04 );
  7366.                 params.duration = duration;
  7367.                 ret = AddEffectCustom( params );
  7368.                
  7369.                
  7370.                 if( ret != EI_Undefined && ret != EI_Deny )
  7371.                 {
  7372.                     effectsNew = GetCurrentEffects();
  7373.                    
  7374.                     ind = -1;
  7375.                     for( i=effectsNew.Size()-1; i>=0; i-=1)
  7376.                     {
  7377.                         if( !effectsOld.Contains( effectsNew[i] ) )
  7378.                         {
  7379.                             ind = i;
  7380.                             break;
  7381.                         }
  7382.                     }
  7383.                    
  7384.                     if(ind > -1)
  7385.                     {
  7386.                         skillBonusPotionEffect = effectsNew[ind];
  7387.                     }
  7388.                 }
  7389.             }      
  7390.         }
  7391.     }
  7392.    
  7393.    
  7394.     private function BonusPotionGetDurationFromXML(type : EEffectType) : float
  7395.     {
  7396.         var dm : CDefinitionsManagerAccessor;
  7397.         var main, ingredients : SCustomNode;
  7398.         var tmpName, typeName, itemName : name;
  7399.         var abs : array<name>;
  7400.         var min, max : SAbilityAttributeValue;
  7401.         var tmpInt : int;
  7402.         var temp                                : array<float>;
  7403.         var i, temp2, temp3 : int;
  7404.                        
  7405.         dm = theGame.GetDefinitionsManager();
  7406.         main = dm.GetCustomDefinition('alchemy_recipes');
  7407.         typeName = EffectTypeToName(type);
  7408.        
  7409.        
  7410.         for(i=0; i<main.subNodes.Size(); i+=1)
  7411.         {
  7412.             if(dm.GetCustomNodeAttributeValueName(main.subNodes[i], 'type_name', tmpName))
  7413.             {
  7414.                
  7415.                 if(tmpName == typeName)
  7416.                 {
  7417.                     if(dm.GetCustomNodeAttributeValueInt(main.subNodes[i], 'level', tmpInt))
  7418.                     {
  7419.                        
  7420.                         if(tmpInt == 1)
  7421.                         {
  7422.                             if(dm.GetCustomNodeAttributeValueName(main.subNodes[i], 'cookedItem_name', itemName))
  7423.                             {
  7424.                                
  7425.                                 if(IsNameValid(itemName))
  7426.                                 {
  7427.                                     break;
  7428.                                 }
  7429.                             }
  7430.                         }
  7431.                     }
  7432.                 }
  7433.             }
  7434.         }
  7435.        
  7436.         if(!IsNameValid(itemName))
  7437.             return 0;
  7438.        
  7439.        
  7440.         dm.GetItemAbilitiesWithWeights(itemName, true, abs, temp, temp2, temp3);
  7441.         dm.GetAbilitiesAttributeValue(abs, 'duration', min, max);                      
  7442.         return CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  7443.     }
  7444.    
  7445.     public function ClearSkillBonusPotionEffect()
  7446.     {
  7447.         skillBonusPotionEffect = NULL;
  7448.     }
  7449.    
  7450.     public function GetSkillBonusPotionEffect() : CBaseGameplayEffect
  7451.     {
  7452.         return skillBonusPotionEffect;
  7453.     }
  7454.    
  7455.    
  7456.    
  7457.    
  7458.    
  7459.    
  7460.    
  7461.     public final function HasRunewordActive(abilityName : name) : bool
  7462.     {
  7463.         var item : SItemUniqueId;
  7464.         var hasRuneword : bool;
  7465.        
  7466.         if(GetItemEquippedOnSlot(EES_SteelSword, item))
  7467.         {
  7468.             hasRuneword = inv.ItemHasAbility(item, abilityName);               
  7469.         }
  7470.        
  7471.         if(!hasRuneword)
  7472.         {
  7473.             if(GetItemEquippedOnSlot(EES_SilverSword, item))
  7474.             {
  7475.                 hasRuneword = inv.ItemHasAbility(item, abilityName);
  7476.             }
  7477.         }
  7478.        
  7479.         return hasRuneword;
  7480.     }
  7481.    
  7482.     public final function GetShrineBuffs() : array<CBaseGameplayEffect>
  7483.     {
  7484.         var null : array<CBaseGameplayEffect>;
  7485.        
  7486.         if(effectManager && effectManager.IsReady())
  7487.             return effectManager.GetShrineBuffs();
  7488.            
  7489.         return null;
  7490.     }
  7491.    
  7492.     public final function AddRepairObjectBuff(armor : bool, weapon : bool) : bool
  7493.     {
  7494.         var added : bool;
  7495.        
  7496.         added = false;
  7497.        
  7498.         if(weapon && (IsAnyItemEquippedOnSlot(EES_SilverSword) || IsAnyItemEquippedOnSlot(EES_SteelSword)) )
  7499.         {
  7500.             AddEffectDefault(EET_EnhancedWeapon, this, "repair_object", false);
  7501.             added = true;
  7502.         }
  7503.        
  7504.         if(armor && (IsAnyItemEquippedOnSlot(EES_Armor) || IsAnyItemEquippedOnSlot(EES_Gloves) || IsAnyItemEquippedOnSlot(EES_Boots) || IsAnyItemEquippedOnSlot(EES_Pants)) )
  7505.         {
  7506.             AddEffectDefault(EET_EnhancedArmor, this, "repair_object", false);
  7507.             added = true;
  7508.         }
  7509.        
  7510.         return added;
  7511.     }
  7512.    
  7513.    
  7514.     public function StartCSAnim(buff : CBaseGameplayEffect) : bool
  7515.     {
  7516.        
  7517.         if(IsAnyQuenActive() && (W3CriticalDOTEffect)buff)
  7518.             return false;
  7519.            
  7520.         return super.StartCSAnim(buff);
  7521.     }
  7522.    
  7523.     public function GetPotionBuffLevel(effectType : EEffectType) : int
  7524.     {
  7525.         if(effectManager && effectManager.IsReady())
  7526.             return effectManager.GetPotionBuffLevel(effectType);
  7527.            
  7528.         return 0;
  7529.     }  
  7530.  
  7531.    
  7532.    
  7533.    
  7534.    
  7535.    
  7536.    
  7537.     event OnLevelGained(currentLevel : int, show : bool)
  7538.     {
  7539.        
  7540.         var swords : array<SItemUniqueId>;
  7541.         var i : int;
  7542.        
  7543.    
  7544.         var hud : CR4ScriptedHud;
  7545.         hud = (CR4ScriptedHud)theGame.GetHud();
  7546.        
  7547.         if(abilityManager && abilityManager.IsInitialized())
  7548.         {
  7549.             ((W3PlayerAbilityManager)abilityManager).OnLevelGained(currentLevel);
  7550.         }
  7551.        
  7552.         if ( theGame.GetDifficultyMode() != EDM_Hardcore )
  7553.         {
  7554.             Heal(GetStatMax(BCS_Vitality));
  7555.         }
  7556.    
  7557.        
  7558.         if(currentLevel >= 35)
  7559.         {
  7560.             theGame.GetGamerProfile().AddAchievement(EA_Immortal);
  7561.         }
  7562.         else
  7563.         {
  7564.             theGame.GetGamerProfile().NoticeAchievementProgress(EA_Immortal, currentLevel);
  7565.         }
  7566.    
  7567.         if ( hud && currentLevel < levelManager.GetMaxLevel() && FactsQuerySum( "DebugNoLevelUpUpdates" ) == 0 )
  7568.         {
  7569.             hud.OnLevelUpUpdate(currentLevel, show);
  7570.         }
  7571.        
  7572.        
  7573.         swords = inv.GetItemsByName('sq304 Novigraadan sword 4');
  7574.         for(i=0;i<swords.Size();i+=1)
  7575.         {
  7576.             inv.AddItemCraftedAbility(swords[i], 'sq304_sword_upgrade _Stats', true);          
  7577.         }
  7578.        
  7579.         swords.Clear();
  7580.         swords = inv.GetItemsByName('q402 Skellige sword 3');
  7581.         for(i=0;i<swords.Size();i+=1)
  7582.         {
  7583.             inv.AddItemCraftedAbility(swords[i], 'q402_sword_upgrade _Stats', true);           
  7584.         }
  7585.        
  7586.        
  7587.         theGame.RequestAutoSave( "level gained", false );
  7588.     }
  7589.    
  7590.     public function GetSignStats(skill : ESkill, out damageType : name, out damageVal : float, out spellPower : SAbilityAttributeValue)
  7591.     {
  7592.         var i, size : int;
  7593.         var dm : CDefinitionsManagerAccessor;
  7594.         var attrs : array<name>;
  7595.    
  7596.         spellPower = GetPowerStatValue(CPS_SpellPower);
  7597.        
  7598.         dm = theGame.GetDefinitionsManager();
  7599.         dm.GetAbilityAttributes(GetSkillAbilityName(skill), attrs);
  7600.         size = attrs.Size();
  7601.        
  7602.         for( i = 0; i < size; i += 1 )
  7603.         {
  7604.             if( IsDamageTypeNameValid(attrs[i]) )
  7605.             {
  7606.                 damageVal = CalculateAttributeValue(GetSkillAttributeValue(skill, attrs[i], false, true));
  7607.                 damageType = attrs[i];
  7608.                 break;
  7609.             }
  7610.         }
  7611.     }
  7612.        
  7613.    
  7614.     public function SetIgnorePainMaxVitality(val : float)
  7615.     {
  7616.         if(abilityManager && abilityManager.IsInitialized())
  7617.             abilityManager.SetStatPointMax(BCS_Vitality, val);
  7618.     }
  7619.    
  7620.     event OnAnimEvent_ActionBlend( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  7621.     {
  7622.         if ( animEventType == AET_DurationStart && !disableActionBlend )
  7623.         {
  7624.             if ( this.IsCastingSign() )
  7625.                 ProcessSignEvent( 'cast_end' );
  7626.            
  7627.            
  7628.             FindMoveTarget();
  7629.             SetCanPlayHitAnim( true );
  7630.             this.SetBIsCombatActionAllowed( true );
  7631.            
  7632.             if ( this.GetFinisherVictim() && this.GetFinisherVictim().HasAbility( 'ForceFinisher' ) && !isInFinisher )
  7633.             {
  7634.                 this.GetFinisherVictim().SignalGameplayEvent( 'Finisher' );
  7635.             }
  7636.             else if (this.BufferCombatAction != EBAT_EMPTY )
  7637.             {
  7638.                
  7639.                
  7640.                    
  7641.                     if ( !IsCombatMusicEnabled() )
  7642.                     {
  7643.                         SetCombatActionHeading( ProcessCombatActionHeading( this.BufferCombatAction ) );
  7644.                         FindTarget();
  7645.                         UpdateDisplayTarget( true );
  7646.                     }
  7647.            
  7648.                     if ( AllowAttack( GetTarget(), this.BufferCombatAction ) )
  7649.                         this.ProcessCombatActionBuffer();
  7650.             }
  7651.             else
  7652.             {
  7653.                
  7654.                 ResumeStaminaRegen( 'InsideCombatAction' );
  7655.                
  7656.                
  7657.                
  7658.             }
  7659.         }
  7660.         else if ( disableActionBlend )
  7661.         {
  7662.             disableActionBlend = false;
  7663.         }
  7664.     }
  7665.    
  7666.    
  7667.     event OnAnimEvent_Sign( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  7668.     {
  7669.         if( animEventType == AET_Tick )
  7670.         {
  7671.             ProcessSignEvent( animEventName );
  7672.         }
  7673.     }
  7674.    
  7675.     event OnAnimEvent_Throwable( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  7676.     {
  7677.         var thrownEntity        : CThrowable;  
  7678.        
  7679.         thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  7680.            
  7681.         if ( inv.IsItemCrossbow( inv.GetItemFromSlot('l_weapon') ) &&  rangedWeapon.OnProcessThrowEvent( animEventName ) )
  7682.         {      
  7683.             return true;
  7684.         }
  7685.         else if( thrownEntity && IsThrowingItem() && thrownEntity.OnProcessThrowEvent( animEventName ) )
  7686.         {
  7687.             return true;
  7688.         }
  7689.     }
  7690.    
  7691.     event OnTaskSyncAnim( npc : CNewNPC, animNameLeft : name )
  7692.     {
  7693.         var tmpBool : bool;
  7694.         var tmpName : name;
  7695.         var damage, points, resistance : float;
  7696.         var min, max : SAbilityAttributeValue;
  7697.         var mc : EMonsterCategory;
  7698.        
  7699.         super.OnTaskSyncAnim( npc, animNameLeft );
  7700.        
  7701.         if( animNameLeft == 'BruxaBite' && IsMutationActive( EPMT_Mutation4 ) )
  7702.         {
  7703.             theGame.GetMonsterParamsForActor( npc, mc, tmpName, tmpBool, tmpBool, tmpBool );
  7704.            
  7705.             if( mc == MC_Vampire )
  7706.             {
  7707.                 GetResistValue( CDS_BleedingRes, points, resistance );
  7708.                
  7709.                 theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'BleedingEffect', 'DirectDamage', min, max );
  7710.                 damage = MaxF( 0.f, max.valueMultiplicative * GetMaxHealth() - points );
  7711.                
  7712.                 theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'BleedingEffect', 'duration', min, max );
  7713.                 damage *= min.valueAdditive * ( 1 - MinF( 1.f, resistance ) );
  7714.                
  7715.                 if( damage > 0.f )
  7716.                 {
  7717.                     npc.AddAbility( 'Mutation4BloodDebuff' );
  7718.                     ProcessActionMutation4ReturnedDamage( damage, npc, EAHA_ForceNo );                 
  7719.                     npc.AddTimer( 'RemoveMutation4BloodDebuff', 15.f, , , , , true );
  7720.                 }
  7721.             }
  7722.         }
  7723.     }
  7724.    
  7725.    
  7726.     public function ProcessActionMutation4ReturnedDamage( damageDealt : float, attacker : CActor, hitAnimationType : EActionHitAnim, optional action : W3DamageAction ) : bool
  7727.     {
  7728.         var customParams                : SCustomEffectParams;
  7729.         var currToxicity                : float;
  7730.         var min, max, customDamageValue : SAbilityAttributeValue;
  7731.         var dm                          : CDefinitionsManagerAccessor;
  7732.         var animAction                  : W3DamageAction;
  7733.  
  7734.         if( damageDealt <= 0 )
  7735.         {
  7736.             return false;
  7737.         }
  7738.        
  7739.         if( action )
  7740.         {
  7741.             action.SetMutation4Triggered();
  7742.         }
  7743.            
  7744.         dm = theGame.GetDefinitionsManager();
  7745.         currToxicity = GetStat( BCS_Toxicity );
  7746.        
  7747.         dm.GetAbilityAttributeValue( 'AcidEffect', 'DirectDamage', min, max );
  7748.         customDamageValue.valueAdditive = damageDealt * min.valueAdditive;
  7749.        
  7750.         if( currToxicity > 0 )
  7751.         {
  7752.             customDamageValue.valueAdditive *= currToxicity;
  7753.         }
  7754.        
  7755.         dm.GetAbilityAttributeValue( 'AcidEffect', 'duration', min, max );
  7756.         customDamageValue.valueAdditive /= min.valueAdditive;
  7757.        
  7758.         customParams.effectType = EET_Acid;
  7759.         customParams.effectValue = customDamageValue;
  7760.         customParams.duration = min.valueAdditive;
  7761.         customParams.creator = this;
  7762.         customParams.sourceName = 'Mutation4';
  7763.        
  7764.         attacker.AddEffectCustom( customParams );
  7765.        
  7766.        
  7767.         animAction = new W3DamageAction in theGame;
  7768.         animAction.Initialize( this, attacker, NULL, 'Mutation4', EHRT_Reflect, CPS_Undefined, true, false, false, false );
  7769.         animAction.SetCannotReturnDamage( true );
  7770.         animAction.SetCanPlayHitParticle( false );
  7771.         animAction.SetHitAnimationPlayType( hitAnimationType );
  7772.         theGame.damageMgr.ProcessAction( animAction );
  7773.         delete animAction;
  7774.        
  7775.         theGame.MutationHUDFeedback( MFT_PlayOnce );
  7776.        
  7777.         return true;
  7778.     }
  7779.    
  7780.     event OnPlayerActionEnd()
  7781.     {
  7782.         var l_i             : int;
  7783.         var l_bed           : W3WitcherBed;
  7784.        
  7785.         l_i = (int)GetBehaviorVariable( 'playerExplorationAction' );
  7786.        
  7787.         if( l_i == PEA_GoToSleep )
  7788.         {
  7789.             l_bed = (W3WitcherBed)theGame.GetEntityByTag( 'witcherBed' );
  7790.             BlockAllActions( 'WitcherBed', false );
  7791.             l_bed.ApplyAppearance( "collision" );
  7792.             l_bed.GotoState( 'WakeUp' );
  7793.             theGame.ReleaseNoSaveLock( l_bed.m_bedSaveLock );
  7794.            
  7795.            
  7796.             substateManager.m_MovementCorrectorO.disallowRotWhenGoingToSleep = false;
  7797.         }
  7798.        
  7799.         super.OnPlayerActionEnd();
  7800.     }
  7801.    
  7802.     event OnPlayerActionStartFinished()
  7803.     {
  7804.         var l_initData          : W3SingleMenuInitData;    
  7805.         var l_i                 : int;
  7806.        
  7807.         l_i = (int)GetBehaviorVariable( 'playerExplorationAction' );
  7808.        
  7809.         if( l_i == PEA_GoToSleep )
  7810.         {
  7811.             l_initData = new W3SingleMenuInitData in this;
  7812.             l_initData.SetBlockOtherPanels( true );
  7813.             l_initData.ignoreSaveSystem = true;
  7814.             l_initData.ignoreMeditationCheck = true;
  7815.             l_initData.setDefaultState( '' );
  7816.             l_initData.isBonusMeditationAvailable = true;
  7817.             l_initData.fixedMenuName = 'MeditationClockMenu';
  7818.            
  7819.             theGame.RequestMenuWithBackground( 'MeditationClockMenu', 'CommonMenu', l_initData );
  7820.         }
  7821.        
  7822.         super.OnPlayerActionStartFinished();
  7823.     }
  7824.    
  7825.     public function IsInCombatAction_SpecialAttack() : bool
  7826.     {
  7827.         if ( IsInCombatAction() && ( GetCombatAction() == EBAT_SpecialAttack_Light || GetCombatAction() == EBAT_SpecialAttack_Heavy ) )
  7828.             return true;
  7829.         else
  7830.             return false;
  7831.     }
  7832.    
  7833.     public function IsInCombatAction_SpecialAttackHeavy() : bool
  7834.     {
  7835.         if ( IsInCombatAction() && GetCombatAction() == EBAT_SpecialAttack_Heavy )
  7836.             return true;
  7837.         else
  7838.             return false;
  7839.     }
  7840.    
  7841.     protected function WhenCombatActionIsFinished()
  7842.     {
  7843.         super.WhenCombatActionIsFinished();
  7844.         RemoveTimer( 'ProcessAttackTimer' );
  7845.         RemoveTimer( 'AttackTimerEnd' );
  7846.         CastSignAbort();
  7847.         specialAttackCamera = false;
  7848.         this.OnPerformSpecialAttack( true, false );
  7849.     }
  7850.    
  7851.     event OnCombatActionEnd()
  7852.     {
  7853.         this.CleanCombatActionBuffer();    
  7854.         super.OnCombatActionEnd();
  7855.        
  7856.         RemoveTemporarySkills();
  7857.     }
  7858.    
  7859.     event OnCombatActionFriendlyEnd()
  7860.     {
  7861.         if ( IsCastingSign() )
  7862.         {
  7863.             SetBehaviorVariable( 'IsCastingSign', 0 );
  7864.             SetCurrentlyCastSign( ST_None, NULL );
  7865.             LogChannel( 'ST_None', "ST_None" );                
  7866.         }
  7867.  
  7868.         super.OnCombatActionFriendlyEnd();
  7869.     }
  7870.    
  7871.     public function GetPowerStatValue( stat : ECharacterPowerStats, optional ablName : name, optional ignoreDeath : bool ) : SAbilityAttributeValue
  7872.     {
  7873.         var result :  SAbilityAttributeValue;
  7874.        
  7875.        
  7876.         result = super.GetPowerStatValue( stat, ablName, ignoreDeath );
  7877.         ApplyMutation10StatBoost( result );
  7878.        
  7879.         return result;
  7880.     }
  7881.    
  7882.    
  7883.    
  7884.     timer function OpenRadialMenu( time: float, id : int )
  7885.     {
  7886.        
  7887.         if( GetBIsCombatActionAllowed() && !IsUITakeInput() )
  7888.         {
  7889.             bShowRadialMenu = true;
  7890.         }
  7891.        
  7892.         this.RemoveTimer('OpenRadialMenu');
  7893.     }
  7894.    
  7895.     public function OnAddRadialMenuOpenTimer(  )
  7896.     {
  7897.        
  7898.        
  7899.        
  7900.            
  7901.            
  7902.             this.AddTimer('OpenRadialMenu', _HoldBeforeOpenRadialMenuTime * theGame.GetTimeScale() );
  7903.        
  7904.     }
  7905.  
  7906.     public function SetShowRadialMenuOpenFlag( bSet : bool  )
  7907.     {
  7908.        
  7909.         bShowRadialMenu = bSet;
  7910.     }
  7911.    
  7912.     public function OnRemoveRadialMenuOpenTimer()
  7913.     {
  7914.        
  7915.         this.RemoveTimer('OpenRadialMenu');
  7916.     }
  7917.    
  7918.     public function ResetRadialMenuOpenTimer()
  7919.     {
  7920.        
  7921.         this.RemoveTimer('OpenRadialMenu');
  7922.         if( GetBIsCombatActionAllowed() )
  7923.         {
  7924.            
  7925.            
  7926.             AddTimer('OpenRadialMenu', _HoldBeforeOpenRadialMenuTime * theGame.GetTimeScale() );
  7927.         }
  7928.     }
  7929.  
  7930.    
  7931.    
  7932.     timer function ResendCompanionDisplayName(dt : float, id : int)
  7933.     {
  7934.         var hud : CR4ScriptedHud;
  7935.         var companionModule : CR4HudModuleCompanion;
  7936.        
  7937.         hud = (CR4ScriptedHud)theGame.GetHud();
  7938.         if( hud )
  7939.         {
  7940.             companionModule = (CR4HudModuleCompanion)hud.GetHudModule("CompanionModule");
  7941.             if( companionModule )
  7942.             {
  7943.                 companionModule.ResendDisplayName();
  7944.             }
  7945.         }
  7946.     }
  7947.  
  7948.     timer function ResendCompanionDisplayNameSecond(dt : float, id : int)
  7949.     {
  7950.         var hud : CR4ScriptedHud;
  7951.         var companionModule : CR4HudModuleCompanion;
  7952.        
  7953.         hud = (CR4ScriptedHud)theGame.GetHud();
  7954.         if( hud )
  7955.         {
  7956.             companionModule = (CR4HudModuleCompanion)hud.GetHudModule("CompanionModule");
  7957.             if( companionModule )
  7958.             {
  7959.                 companionModule.ResendDisplayNameSecond();
  7960.             }
  7961.         }
  7962.     }
  7963.    
  7964.     public function RemoveCompanionDisplayNameTimer()
  7965.     {
  7966.         this.RemoveTimer('ResendCompanionDisplayName');
  7967.     }
  7968.        
  7969.     public function RemoveCompanionDisplayNameTimerSecond()
  7970.     {
  7971.         this.RemoveTimer('ResendCompanionDisplayNameSecond');
  7972.     }
  7973.    
  7974.        
  7975.     public function GetCompanionNPCTag() : name
  7976.     {
  7977.         return companionNPCTag;
  7978.     }
  7979.  
  7980.     public function SetCompanionNPCTag( value : name )
  7981.     {
  7982.         companionNPCTag = value;
  7983.     }  
  7984.  
  7985.     public function GetCompanionNPCTag2() : name
  7986.     {
  7987.         return companionNPCTag2;
  7988.     }
  7989.  
  7990.     public function SetCompanionNPCTag2( value : name )
  7991.     {
  7992.         companionNPCTag2 = value;
  7993.     }
  7994.  
  7995.     public function GetCompanionNPCIconPath() : string
  7996.     {
  7997.         return companionNPCIconPath;
  7998.     }
  7999.  
  8000.     public function SetCompanionNPCIconPath( value : string )
  8001.     {
  8002.         companionNPCIconPath = value;
  8003.     }
  8004.  
  8005.     public function GetCompanionNPCIconPath2() : string
  8006.     {
  8007.         return companionNPCIconPath2;
  8008.     }
  8009.  
  8010.     public function SetCompanionNPCIconPath2( value : string )
  8011.     {
  8012.         companionNPCIconPath2 = value;
  8013.     }
  8014.    
  8015.    
  8016.  
  8017.     public function ReactToBeingHit(damageAction : W3DamageAction, optional buffNotApplied : bool) : bool
  8018.     {
  8019.         var chance : float;
  8020.         var procQuen : W3SignEntity;
  8021.        
  8022.         if(!damageAction.IsDoTDamage() && damageAction.DealsAnyDamage())
  8023.         {
  8024.             if(inv.IsItemBomb(selectedItemId))
  8025.             {
  8026.                 BombThrowAbort();
  8027.             }
  8028.             else
  8029.             {
  8030.                
  8031.                 ThrowingAbort();
  8032.             }          
  8033.         }      
  8034.        
  8035.        
  8036.         if(damageAction.IsActionRanged())
  8037.         {
  8038.             chance = CalculateAttributeValue(GetAttributeValue('quen_chance_on_projectile'));
  8039.             if(chance > 0)
  8040.             {
  8041.                 chance = ClampF(chance, 0, 1);
  8042.                
  8043.                 if(RandF() < chance)
  8044.                 {
  8045.                     procQuen = (W3SignEntity)theGame.CreateEntity(signs[ST_Quen].template, GetWorldPosition(), GetWorldRotation() );
  8046.                     procQuen.Init(signOwner, signs[ST_Quen].entity, true );
  8047.                     procQuen.OnStarted();
  8048.                     procQuen.OnThrowing();
  8049.                     procQuen.OnEnded();
  8050.                 }
  8051.             }
  8052.         }
  8053.        
  8054.        
  8055.         if( !((W3Effect_Toxicity)damageAction.causer) )
  8056.             MeditationForceAbort(true);
  8057.        
  8058.        
  8059.         if(IsDoingSpecialAttack(false))
  8060.             damageAction.SetHitAnimationPlayType(EAHA_ForceNo);
  8061.        
  8062.         return super.ReactToBeingHit(damageAction, buffNotApplied);
  8063.     }
  8064.    
  8065.     protected function ShouldPauseHealthRegenOnHit() : bool
  8066.     {
  8067.        
  8068.         if( ( HasBuff( EET_Swallow ) && GetPotionBuffLevel( EET_Swallow ) >= 3 ) || HasBuff( EET_Runeword8 ) || HasBuff( EET_Mutation11Buff ) )
  8069.         {
  8070.             return false;
  8071.         }
  8072.            
  8073.         return true;
  8074.     }
  8075.        
  8076.     public function SetMappinToHighlight( mappinName : name, mappinState : bool )
  8077.     {
  8078.         var mappinDef : SHighlightMappin;
  8079.         mappinDef.MappinName = mappinName;
  8080.         mappinDef.MappinState = mappinState;
  8081.         MappinToHighlight.PushBack(mappinDef);
  8082.     }  
  8083.  
  8084.     public function ClearMappinToHighlight()
  8085.     {
  8086.         MappinToHighlight.Clear();
  8087.     }
  8088.    
  8089.     public function CastSignAbort()
  8090.     {
  8091.         if( currentlyCastSign != ST_None && signs[currentlyCastSign].entity)
  8092.         {
  8093.             signs[currentlyCastSign].entity.OnSignAborted();
  8094.         }
  8095.        
  8096.        
  8097.     }
  8098.    
  8099.     event OnBlockingSceneStarted( scene: CStoryScene )
  8100.     {
  8101.         var med : W3PlayerWitcherStateMeditationWaiting;
  8102.                
  8103.        
  8104.         med = (W3PlayerWitcherStateMeditationWaiting)GetCurrentState();
  8105.         if(med)
  8106.         {
  8107.             med.StopRequested(true);
  8108.         }
  8109.        
  8110.        
  8111.         super.OnBlockingSceneStarted( scene );
  8112.     }
  8113.    
  8114.    
  8115.    
  8116.    
  8117.    
  8118.     public function GetHorseManager() : W3HorseManager
  8119.     {
  8120.         return (W3HorseManager)EntityHandleGet( horseManagerHandle );
  8121.     }
  8122.    
  8123.    
  8124.     public function HorseEquipItem(horsesItemId : SItemUniqueId) : bool
  8125.     {
  8126.         var man : W3HorseManager;
  8127.        
  8128.         man = GetHorseManager();
  8129.         if(man)
  8130.             return man.EquipItem(horsesItemId) != GetInvalidUniqueId();
  8131.            
  8132.         return false;
  8133.     }
  8134.    
  8135.    
  8136.     public function HorseUnequipItem(slot : EEquipmentSlots) : bool
  8137.     {
  8138.         var man : W3HorseManager;
  8139.        
  8140.         man = GetHorseManager();
  8141.         if(man)
  8142.             return man.UnequipItem(slot) != GetInvalidUniqueId();
  8143.            
  8144.         return false;
  8145.     }
  8146.    
  8147.    
  8148.     public final function HorseRemoveItemByName(itemName : name, quantity : int)
  8149.     {
  8150.         var man : W3HorseManager;
  8151.        
  8152.         man = GetHorseManager();
  8153.         if(man)
  8154.             man.HorseRemoveItemByName(itemName, quantity);
  8155.     }
  8156.    
  8157.    
  8158.     public final function HorseRemoveItemByCategory(itemCategory : name, quantity : int)
  8159.     {
  8160.         var man : W3HorseManager;
  8161.        
  8162.         man = GetHorseManager();
  8163.         if(man)
  8164.             man.HorseRemoveItemByCategory(itemCategory, quantity);
  8165.     }
  8166.    
  8167.    
  8168.     public final function HorseRemoveItemByTag(itemTag : name, quantity : int)
  8169.     {
  8170.         var man : W3HorseManager;
  8171.        
  8172.         man = GetHorseManager();
  8173.         if(man)
  8174.             man.HorseRemoveItemByTag(itemTag, quantity);
  8175.     }
  8176.    
  8177.     public function GetAssociatedInventory() : CInventoryComponent
  8178.     {
  8179.         var man : W3HorseManager;
  8180.        
  8181.         man = GetHorseManager();
  8182.         if(man)
  8183.             return man.GetInventoryComponent();
  8184.            
  8185.         return NULL;
  8186.     }
  8187.    
  8188.    
  8189.    
  8190.    
  8191.    
  8192.     public final function TutorialMutagensUnequipPlayerSkills() : array<STutorialSavedSkill>
  8193.     {
  8194.         var pam : W3PlayerAbilityManager;
  8195.        
  8196.         pam = (W3PlayerAbilityManager)abilityManager;
  8197.         return pam.TutorialMutagensUnequipPlayerSkills();
  8198.     }
  8199.    
  8200.     public final function TutorialMutagensEquipOneGoodSkill()
  8201.     {
  8202.         var pam : W3PlayerAbilityManager;
  8203.        
  8204.         pam = (W3PlayerAbilityManager)abilityManager;
  8205.         pam.TutorialMutagensEquipOneGoodSkill();
  8206.     }
  8207.    
  8208.     public final function TutorialMutagensEquipOneGoodOneBadSkill()
  8209.     {
  8210.         var pam : W3PlayerAbilityManager;
  8211.        
  8212.         pam = (W3PlayerAbilityManager)abilityManager;
  8213.         if(pam)
  8214.             pam.TutorialMutagensEquipOneGoodOneBadSkill();
  8215.     }
  8216.    
  8217.     public final function TutorialMutagensEquipThreeGoodSkills()
  8218.     {
  8219.         var pam : W3PlayerAbilityManager;
  8220.        
  8221.         pam = (W3PlayerAbilityManager)abilityManager;
  8222.         if(pam)
  8223.             pam.TutorialMutagensEquipThreeGoodSkills();
  8224.     }
  8225.    
  8226.     public final function TutorialMutagensCleanupTempSkills(savedEquippedSkills : array<STutorialSavedSkill>)
  8227.     {
  8228.         var pam : W3PlayerAbilityManager;
  8229.        
  8230.         pam = (W3PlayerAbilityManager)abilityManager;
  8231.         return pam.TutorialMutagensCleanupTempSkills(savedEquippedSkills);
  8232.     }
  8233.    
  8234.    
  8235.    
  8236.    
  8237.    
  8238.     public final function CalculatedArmorStaminaRegenBonus() : float
  8239.     {
  8240.         var armorEq, glovesEq, pantsEq, bootsEq : bool;
  8241.         var tempItem : SItemUniqueId;
  8242.         var staminaRegenVal : float;
  8243.         var armorRegenVal : SAbilityAttributeValue;
  8244.        
  8245.         if( HasAbility( 'Glyphword 2 _Stats', true ) )
  8246.         {
  8247.             armorEq = inv.GetItemEquippedOnSlot( EES_Armor, tempItem );
  8248.             glovesEq = inv.GetItemEquippedOnSlot( EES_Gloves, tempItem );
  8249.             pantsEq = inv.GetItemEquippedOnSlot( EES_Pants, tempItem );
  8250.             bootsEq = inv.GetItemEquippedOnSlot( EES_Boots, tempItem );
  8251.            
  8252.             if ( armorEq )
  8253.                 staminaRegenVal += 0.1;
  8254.             if ( glovesEq )
  8255.                 staminaRegenVal += 0.02;
  8256.             if ( pantsEq )
  8257.                 staminaRegenVal += 0.1;
  8258.             if ( bootsEq )
  8259.                 staminaRegenVal += 0.03;
  8260.            
  8261.         }
  8262.         else if( HasAbility( 'Glyphword 3 _Stats', true ) )
  8263.         {
  8264.             staminaRegenVal = 0;
  8265.         }
  8266.         else if( HasAbility( 'Glyphword 4 _Stats', true ) )
  8267.         {
  8268.             armorEq = inv.GetItemEquippedOnSlot( EES_Armor, tempItem );
  8269.             glovesEq = inv.GetItemEquippedOnSlot( EES_Gloves, tempItem );
  8270.             pantsEq = inv.GetItemEquippedOnSlot( EES_Pants, tempItem );
  8271.             bootsEq = inv.GetItemEquippedOnSlot( EES_Boots, tempItem );
  8272.            
  8273.             if ( armorEq )
  8274.                 staminaRegenVal -= 0.1;
  8275.             if ( glovesEq )
  8276.                 staminaRegenVal -= 0.02;
  8277.             if ( pantsEq )
  8278.                 staminaRegenVal -= 0.1;
  8279.             if ( bootsEq )
  8280.                 staminaRegenVal -= 0.03;
  8281.         }
  8282.         else
  8283.         {
  8284.             armorRegenVal = GetAttributeValue('staminaRegen_armor_mod');
  8285.             staminaRegenVal = armorRegenVal.valueMultiplicative;
  8286.         }
  8287.        
  8288.         return staminaRegenVal;
  8289.     }
  8290.    
  8291.     public function GetOffenseStatsList( optional hackMode : int ) : SPlayerOffenseStats
  8292.     {
  8293.         var playerOffenseStats:SPlayerOffenseStats;
  8294.         var steelDmg, silverDmg, elementalSteel, elementalSilver : float;
  8295.         var steelCritChance, steelCritDmg : float;
  8296.         var silverCritChance, silverCritDmg : float;
  8297.         var attackPower : SAbilityAttributeValue;
  8298.         var fastCritChance, fastCritDmg : float;
  8299.         var strongCritChance, strongCritDmg : float;
  8300.         var fastAP, strongAP, min, max : SAbilityAttributeValue;
  8301.         var item, crossbow : SItemUniqueId;
  8302.         var value : SAbilityAttributeValue;
  8303.         var mutagen : CBaseGameplayEffect;
  8304.         var thunder : W3Potion_Thunderbolt;
  8305.        
  8306.         if(!abilityManager || !abilityManager.IsInitialized())
  8307.             return playerOffenseStats;
  8308.        
  8309.         if (CanUseSkill(S_Sword_s21))
  8310.             fastAP += GetSkillAttributeValue(S_Sword_s21, PowerStatEnumToName(CPS_AttackPower), false, true) * GetSkillLevel(S_Sword_s21);
  8311.         if (CanUseSkill(S_Perk_05))
  8312.         {
  8313.             fastAP += GetAttributeValue('attack_power_fast_style');
  8314.             fastCritDmg += CalculateAttributeValue(GetAttributeValue('critical_hit_chance_fast_style'));
  8315.             strongCritDmg += CalculateAttributeValue(GetAttributeValue('critical_hit_chance_fast_style'));
  8316.         }
  8317.         if (CanUseSkill(S_Sword_s04))
  8318.             strongAP += GetSkillAttributeValue(S_Sword_s04, PowerStatEnumToName(CPS_AttackPower), false, true) * GetSkillLevel(S_Sword_s04);
  8319.         if (CanUseSkill(S_Perk_07))
  8320.             strongAP += GetAttributeValue('attack_power_heavy_style');
  8321.            
  8322.         if (CanUseSkill(S_Sword_s17))
  8323.         {
  8324.             fastCritChance += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s17, theGame.params.CRITICAL_HIT_CHANCE, false, true)) * GetSkillLevel(S_Sword_s17);
  8325.             fastCritDmg += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s17, theGame.params.CRITICAL_HIT_DAMAGE_BONUS, false, true)) * GetSkillLevel(S_Sword_s17);
  8326.         }
  8327.        
  8328.         if (CanUseSkill(S_Sword_s08))
  8329.         {
  8330.             strongCritChance += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s08, theGame.params.CRITICAL_HIT_CHANCE, false, true)) * GetSkillLevel(S_Sword_s08);
  8331.             strongCritDmg += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s08, theGame.params.CRITICAL_HIT_DAMAGE_BONUS, false, true)) * GetSkillLevel(S_Sword_s08);
  8332.         }
  8333.        
  8334.         if ( HasBuff(EET_Mutagen05) && (GetStat(BCS_Vitality) == GetStatMax(BCS_Vitality)) )
  8335.         {
  8336.             attackPower += GetAttributeValue('damageIncrease');
  8337.         }
  8338.        
  8339.         steelCritChance += CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_CHANCE));
  8340.         silverCritChance += CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_CHANCE));
  8341.         steelCritDmg += CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  8342.         silverCritDmg += CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  8343.         attackPower += GetPowerStatValue(CPS_AttackPower);
  8344.        
  8345.         if (GetItemEquippedOnSlot(EES_SteelSword, item))
  8346.         {
  8347.             steelDmg = GetTotalWeaponDamage(item, theGame.params.DAMAGE_NAME_SLASHING, GetInvalidUniqueId());
  8348.             steelDmg += GetTotalWeaponDamage(item, theGame.params.DAMAGE_NAME_PIERCING, GetInvalidUniqueId());
  8349.             steelDmg += GetTotalWeaponDamage(item, theGame.params.DAMAGE_NAME_BLUDGEONING, GetInvalidUniqueId());
  8350.             elementalSteel = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FIRE));
  8351.             elementalSteel += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FROST));
  8352.             if ( GetInventory().IsItemHeld(item) )
  8353.             {
  8354.                 steelCritChance -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  8355.                 silverCritChance -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  8356.                 steelCritDmg -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  8357.                 silverCritDmg -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  8358.             }
  8359.             steelCritChance += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  8360.             steelCritDmg += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  8361.            
  8362.             thunder = (W3Potion_Thunderbolt)GetBuff(EET_Thunderbolt);
  8363.             if(thunder && thunder.GetBuffLevel() == 3 && GetCurWeather() == EWE_Storm)
  8364.             {
  8365.                 steelCritChance += 1.0f;
  8366.             }
  8367.         }
  8368.         else
  8369.         {
  8370.             steelDmg += 0;
  8371.             steelCritChance += 0;
  8372.             steelCritDmg +=0;
  8373.         }
  8374.        
  8375.         if (GetItemEquippedOnSlot(EES_SilverSword, item))
  8376.         {
  8377.             silverDmg = GetTotalWeaponDamage(item, theGame.params.DAMAGE_NAME_SILVER, GetInvalidUniqueId());
  8378.             elementalSilver = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FIRE));
  8379.             elementalSilver += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FROST));
  8380.             if ( GetInventory().IsItemHeld(item) )
  8381.             {
  8382.                 steelCritChance -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  8383.                 silverCritChance -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  8384.                 steelCritDmg -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  8385.                 silverCritDmg -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  8386.             }
  8387.             silverCritChance += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  8388.             silverCritDmg += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  8389.            
  8390.             thunder = (W3Potion_Thunderbolt)GetBuff(EET_Thunderbolt);
  8391.             if(thunder && thunder.GetBuffLevel() == 3 && GetCurWeather() == EWE_Storm)
  8392.             {
  8393.                 silverCritChance += 1.0f;
  8394.             }
  8395.         }
  8396.         else
  8397.         {
  8398.             silverDmg += 0;
  8399.             silverCritChance += 0;
  8400.             silverCritDmg +=0;
  8401.         }
  8402.        
  8403.         if ( HasAbility('Runeword 4 _Stats', true) )
  8404.         {
  8405.             steelDmg += steelDmg * (abilityManager.GetOverhealBonus() / GetStatMax(BCS_Vitality));
  8406.             silverDmg += silverDmg * (abilityManager.GetOverhealBonus() / GetStatMax(BCS_Vitality));
  8407.         }
  8408.        
  8409.         fastAP += attackPower;
  8410.         strongAP += attackPower;
  8411.        
  8412.         playerOffenseStats.steelFastCritChance = (steelCritChance + fastCritChance) * 100;
  8413.         playerOffenseStats.steelFastCritDmg = steelCritDmg + fastCritDmg;
  8414.         if ( steelDmg != 0 )
  8415.         {
  8416.             playerOffenseStats.steelFastDmg = (steelDmg + fastAP.valueBase) * fastAP.valueMultiplicative + fastAP.valueAdditive + elementalSteel;
  8417.             playerOffenseStats.steelFastCritDmg = (steelDmg + fastAP.valueBase) * (fastAP.valueMultiplicative + playerOffenseStats.steelFastCritDmg) + fastAP.valueAdditive + elementalSteel;
  8418.         }
  8419.         else
  8420.         {
  8421.             playerOffenseStats.steelFastDmg = 0;
  8422.             playerOffenseStats.steelFastCritDmg = 0;
  8423.         }
  8424.         playerOffenseStats.steelFastDPS = (playerOffenseStats.steelFastDmg * (100 - playerOffenseStats.steelFastCritChance) + playerOffenseStats.steelFastCritDmg * playerOffenseStats.steelFastCritChance) / 100;
  8425.         playerOffenseStats.steelFastDPS = playerOffenseStats.steelFastDPS / 0.6;
  8426.        
  8427.        
  8428.         playerOffenseStats.steelStrongCritChance = (steelCritChance + strongCritChance) * 100;
  8429.         playerOffenseStats.steelStrongCritDmg = steelCritDmg + strongCritDmg;
  8430.         if ( steelDmg != 0 )
  8431.         {
  8432.             playerOffenseStats.steelStrongDmg = (steelDmg + strongAP.valueBase) * strongAP.valueMultiplicative + strongAP.valueAdditive + elementalSteel;
  8433.             playerOffenseStats.steelStrongDmg *= 1.833f;
  8434.             playerOffenseStats.steelStrongCritDmg = (steelDmg + strongAP.valueBase) * (strongAP.valueMultiplicative + playerOffenseStats.steelStrongCritDmg) + strongAP.valueAdditive + elementalSteel;
  8435.             playerOffenseStats.steelStrongCritDmg *= 1.833f;        }
  8436.         else
  8437.         {
  8438.             playerOffenseStats.steelStrongDmg = 0;
  8439.             playerOffenseStats.steelStrongCritDmg = 0;
  8440.         }
  8441.         playerOffenseStats.steelStrongDPS = (playerOffenseStats.steelStrongDmg * (100 - playerOffenseStats.steelStrongCritChance) + playerOffenseStats.steelStrongCritDmg * playerOffenseStats.steelStrongCritChance) / 100;
  8442.         playerOffenseStats.steelStrongDPS = playerOffenseStats.steelStrongDPS / 1.1;
  8443.        
  8444.    
  8445.        
  8446.         playerOffenseStats.silverFastCritChance = (silverCritChance + fastCritChance) * 100;
  8447.         playerOffenseStats.silverFastCritDmg = silverCritDmg + fastCritDmg;
  8448.         if ( silverDmg != 0 )
  8449.         {
  8450.             playerOffenseStats.silverFastDmg = (silverDmg + fastAP.valueBase) * fastAP.valueMultiplicative + fastAP.valueAdditive + elementalSilver;
  8451.             playerOffenseStats.silverFastCritDmg = (silverDmg + fastAP.valueBase) * (fastAP.valueMultiplicative + playerOffenseStats.silverFastCritDmg) + fastAP.valueAdditive + elementalSilver;  
  8452.         }
  8453.         else
  8454.         {
  8455.             playerOffenseStats.silverFastDmg = 0;
  8456.             playerOffenseStats.silverFastCritDmg = 0;  
  8457.         }
  8458.         playerOffenseStats.silverFastDPS = (playerOffenseStats.silverFastDmg * (100 - playerOffenseStats.silverFastCritChance) + playerOffenseStats.silverFastCritDmg * playerOffenseStats.silverFastCritChance) / 100;
  8459.         playerOffenseStats.silverFastDPS = playerOffenseStats.silverFastDPS / 0.6;
  8460.        
  8461.        
  8462.         playerOffenseStats.silverStrongCritChance = (silverCritChance + strongCritChance) * 100;
  8463.         playerOffenseStats.silverStrongCritDmg = silverCritDmg + strongCritDmg;    
  8464.         if ( silverDmg != 0 )
  8465.         {
  8466.             playerOffenseStats.silverStrongDmg = (silverDmg + strongAP.valueBase) * strongAP.valueMultiplicative + strongAP.valueAdditive + elementalSilver;
  8467.             playerOffenseStats.silverStrongDmg *= 1.833f;
  8468.             playerOffenseStats.silverStrongCritDmg = (silverDmg + strongAP.valueBase) * (strongAP.valueMultiplicative + playerOffenseStats.silverStrongCritDmg) + strongAP.valueAdditive + elementalSilver;
  8469.             playerOffenseStats.silverStrongCritDmg *= 1.833f;
  8470.         }
  8471.         else
  8472.         {
  8473.             playerOffenseStats.silverStrongDmg = 0;
  8474.             playerOffenseStats.silverStrongCritDmg = 0;
  8475.         }
  8476.         playerOffenseStats.silverStrongDPS = (playerOffenseStats.silverStrongDmg * (100 - playerOffenseStats.silverStrongCritChance) + playerOffenseStats.silverStrongCritDmg * playerOffenseStats.silverStrongCritChance) / 100;
  8477.         playerOffenseStats.silverStrongDPS = playerOffenseStats.silverStrongDPS / 1.1;
  8478.        
  8479.        
  8480.         playerOffenseStats.crossbowCritChance = GetCriticalHitChance( false, false, NULL, MC_NotSet, true );
  8481.    
  8482.        
  8483.         playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_PIERCING;
  8484.         if (GetItemEquippedOnSlot(EES_Bolt, item))
  8485.         {
  8486.            
  8487.            
  8488.             steelDmg = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FIRE));
  8489.             if(steelDmg > 0)
  8490.             {
  8491.                 playerOffenseStats.crossbowSteelDmg = steelDmg;
  8492.                
  8493.                 playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_FIRE;
  8494.                 playerOffenseStats.crossbowSilverDmg = steelDmg;
  8495.             }
  8496.             else
  8497.             {
  8498.                 playerOffenseStats.crossbowSilverDmg = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_SILVER));
  8499.                
  8500.                 steelDmg = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_PIERCING));
  8501.                 if(steelDmg > 0)
  8502.                 {
  8503.                     playerOffenseStats.crossbowSteelDmg = steelDmg;
  8504.                     playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_PIERCING;
  8505.                 }
  8506.                 else
  8507.                 {
  8508.                     playerOffenseStats.crossbowSteelDmg = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_BLUDGEONING));
  8509.                     playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_BLUDGEONING;
  8510.                 }
  8511.             }
  8512.         }
  8513.        
  8514.         if (GetItemEquippedOnSlot(EES_RangedWeapon, item))
  8515.         {
  8516.             attackPower += GetInventory().GetItemAttributeValue(item, PowerStatEnumToName(CPS_AttackPower));
  8517.             if(CanUseSkill(S_Perk_02))
  8518.             {              
  8519.                 attackPower += GetSkillAttributeValue(S_Perk_02, PowerStatEnumToName(CPS_AttackPower), false, true);
  8520.             }
  8521.  
  8522.            
  8523.             if( hackMode != 1 && ( IsMutationActive( EPMT_Mutation9 ) || hackMode == 2 ) )
  8524.             {
  8525.                 theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Mutation9', 'damage', min, max );
  8526.                 playerOffenseStats.crossbowSteelDmg += min.valueAdditive;
  8527.                 playerOffenseStats.crossbowSilverDmg += min.valueAdditive;
  8528.             }      
  8529.            
  8530.             playerOffenseStats.crossbowSteelDmg = (playerOffenseStats.crossbowSteelDmg + attackPower.valueBase) * attackPower.valueMultiplicative + attackPower.valueAdditive;
  8531.             playerOffenseStats.crossbowSilverDmg = (playerOffenseStats.crossbowSilverDmg + attackPower.valueBase) * attackPower.valueMultiplicative + attackPower.valueAdditive;
  8532.         }
  8533.         else
  8534.         {
  8535.             playerOffenseStats.crossbowSteelDmg = 0;
  8536.             playerOffenseStats.crossbowSilverDmg = 0;
  8537.             playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_PIERCING;
  8538.         }
  8539.        
  8540.         return playerOffenseStats;
  8541.     }
  8542.    
  8543.     public function GetTotalWeaponDamage(weaponId : SItemUniqueId, damageTypeName : name, crossbowId : SItemUniqueId) : float
  8544.     {
  8545.         var damage, durRatio, durMod, itemMod : float;
  8546.         var repairObjectBonus, min, max : SAbilityAttributeValue;
  8547.        
  8548.         durMod = 0;
  8549.         damage = super.GetTotalWeaponDamage(weaponId, damageTypeName, crossbowId);
  8550.        
  8551.        
  8552.         if( IsMutationActive( EPMT_Mutation9 ) && inv.IsItemBolt( weaponId ) && IsDamageTypeAnyPhysicalType( damageTypeName ) )
  8553.         {
  8554.             theGame.GetDefinitionsManager().GetAbilityAttributeValue('Mutation9', 'damage', min, max);
  8555.             damage += min.valueAdditive;
  8556.         }
  8557.        
  8558.        
  8559.         if(IsPhysicalResistStat(GetResistForDamage(damageTypeName, false)))
  8560.         {
  8561.             repairObjectBonus = inv.GetItemAttributeValue(weaponId, theGame.params.REPAIR_OBJECT_BONUS);
  8562.             durRatio = -1;
  8563.            
  8564.             if(inv.IsIdValid(crossbowId) && inv.HasItemDurability(crossbowId))
  8565.             {
  8566.                 durRatio = inv.GetItemDurabilityRatio(crossbowId);
  8567.             }
  8568.             else if(inv.IsIdValid(weaponId) && inv.HasItemDurability(weaponId))
  8569.             {
  8570.                 durRatio = inv.GetItemDurabilityRatio(weaponId);
  8571.             }
  8572.            
  8573.            
  8574.             if(durRatio >= 0)
  8575.                 durMod = theGame.params.GetDurabilityMultiplier(durRatio, true);
  8576.             else
  8577.                 durMod = 1;
  8578.         }
  8579.        
  8580.        
  8581.         if( damageTypeName == 'SilverDamage' && inv.ItemHasTag( weaponId, 'Aerondight' ) )
  8582.         {
  8583.             itemMod = inv.GetItemModifierFloat( weaponId, 'PermDamageBoost' );
  8584.             if( itemMod > 0.f )
  8585.             {
  8586.                 damage += itemMod;
  8587.             }
  8588.         }
  8589.        
  8590.         return damage * (durMod + repairObjectBonus.valueMultiplicative);
  8591.     }
  8592.    
  8593.    
  8594.    
  8595.    
  8596.    
  8597.     public final function GetSkillPathType(skill : ESkill) : ESkillPath
  8598.     {
  8599.         if(abilityManager && abilityManager.IsInitialized())
  8600.             return ((W3PlayerAbilityManager)abilityManager).GetSkillPathType(skill);
  8601.            
  8602.         return ESP_NotSet;
  8603.     }
  8604.    
  8605.     public function GetSkillLevel(s : ESkill) : int
  8606.     {
  8607.         if(abilityManager && abilityManager.IsInitialized())
  8608.             return ((W3PlayerAbilityManager)abilityManager).GetSkillLevel(s);
  8609.            
  8610.         return -1;
  8611.     }
  8612.    
  8613.     public function GetSkillMaxLevel(s : ESkill) : int
  8614.     {
  8615.         if(abilityManager && abilityManager.IsInitialized())
  8616.             return ((W3PlayerAbilityManager)abilityManager).GetSkillMaxLevel(s);
  8617.            
  8618.         return -1;
  8619.     }
  8620.    
  8621.     public function GetBoughtSkillLevel(s : ESkill) : int
  8622.     {
  8623.         if(abilityManager && abilityManager.IsInitialized())
  8624.             return ((W3PlayerAbilityManager)abilityManager).GetBoughtSkillLevel(s);
  8625.            
  8626.         return -1;
  8627.     }
  8628.    
  8629.    
  8630.     public function GetAxiiLevel() : int
  8631.     {
  8632.         var level : int;
  8633.        
  8634.         level = 1;
  8635.        
  8636.         if(CanUseSkill(S_Magic_s17)) level += GetSkillLevel(S_Magic_s17);
  8637.            
  8638.         return Clamp(level, 1, 4);
  8639.     }
  8640.    
  8641.     public function IsInFrenzy() : bool
  8642.     {
  8643.         return isInFrenzy;
  8644.     }
  8645.    
  8646.     public function HasRecentlyCountered() : bool
  8647.     {
  8648.         return hasRecentlyCountered;
  8649.     }
  8650.    
  8651.     public function SetRecentlyCountered(counter : bool)
  8652.     {
  8653.         hasRecentlyCountered = counter;
  8654.     }
  8655.    
  8656.     timer function CheckBlockedSkills(dt : float, id : int)
  8657.     {
  8658.         var nextCallTime : float;
  8659.        
  8660.         nextCallTime = ((W3PlayerAbilityManager)abilityManager).CheckBlockedSkills(dt);
  8661.         if(nextCallTime != -1)
  8662.             AddTimer('CheckBlockedSkills', nextCallTime, , , , true);
  8663.     }
  8664.        
  8665.    
  8666.     public function RemoveTemporarySkills()
  8667.     {
  8668.         var i : int;
  8669.         var pam : W3PlayerAbilityManager;
  8670.        
  8671.        
  8672.         if ( IsCastingSign() )
  8673.         {
  8674.             AddTimer( 'DelayedRemoveTemporarySkills', 0.1,,,, true );
  8675.             return;
  8676.         }
  8677.        
  8678.         AddTimer( 'SuperchargedSignCleanup', 0.1,,,, true );
  8679.        
  8680.    
  8681.         if(tempLearnedSignSkills.Size() > 0)
  8682.         {
  8683.             pam = (W3PlayerAbilityManager)abilityManager;
  8684.             for(i=0; i<tempLearnedSignSkills.Size(); i+=1)
  8685.             {
  8686.                 pam.RemoveTemporarySkill(tempLearnedSignSkills[i]);
  8687.             }
  8688.            
  8689.             tempLearnedSignSkills.Clear();                     
  8690.         }
  8691.         RemoveAbilityAll(SkillEnumToName(S_Sword_s19));
  8692.     }
  8693.    
  8694.    
  8695.    
  8696.     public timer function SuperchargedSignCleanup(dt : float, id : int)
  8697.     {
  8698.         superchargedSign = false;
  8699.     }
  8700.    
  8701.     public timer function DelayedRemoveTemporarySkills(dt : float, id : int)
  8702.     {
  8703.         var i : int;
  8704.         var pam : W3PlayerAbilityManager;
  8705.        
  8706.         if ( IsCastingSign() )
  8707.         {
  8708.             AddTimer( 'DelayedRemoveTemporarySkills', 0.1,,,, true );
  8709.             return;
  8710.         }
  8711.        
  8712.         AddTimer( 'SuperchargedSignCleanup', 0.1,,,, true );
  8713.        
  8714.         if(tempLearnedSignSkills.Size() > 0)
  8715.         {
  8716.             pam = (W3PlayerAbilityManager)abilityManager;
  8717.             for(i=0; i<tempLearnedSignSkills.Size(); i+=1)
  8718.             {
  8719.                 pam.RemoveTemporarySkill(tempLearnedSignSkills[i]);
  8720.             }
  8721.            
  8722.             tempLearnedSignSkills.Clear();
  8723.         }
  8724.         RemoveAbilityAll(SkillEnumToName(S_Sword_s19));
  8725.     }
  8726.    
  8727.    
  8728.    
  8729.     public function RemoveTemporarySkill(skill : SSimpleSkill) : bool
  8730.     {
  8731.         var pam : W3PlayerAbilityManager;
  8732.        
  8733.         pam = (W3PlayerAbilityManager)abilityManager;
  8734.         if(pam && pam.IsInitialized())
  8735.             return pam.RemoveTemporarySkill(skill);
  8736.            
  8737.         return false;
  8738.     }
  8739.    
  8740.    
  8741.    
  8742.     private var superchargedSign : bool;
  8743.     public function IsSuperchargedSign() : bool
  8744.     {
  8745.         return superchargedSign;
  8746.     }
  8747.    
  8748.    
  8749.    
  8750.    
  8751.     private function AddTemporarySkills()
  8752.     {
  8753.         if(CanUseSkill(S_Sword_s19) && GetStat(BCS_Focus) >= 3)
  8754.         {
  8755.             RemoveTemporarySkills();
  8756.             tempLearnedSignSkills = ((W3PlayerAbilityManager)abilityManager).AddTempNonAlchemySkills();                    
  8757.             DrainFocus(GetStat(BCS_Focus));
  8758.             if ( !this.HasAbility( SkillEnumToName(S_Sword_s19) ) )
  8759.                 AddAbilityMultiple(SkillEnumToName(S_Sword_s19), GetSkillLevel(S_Sword_s19));
  8760.            
  8761.             superchargedSign = true;
  8762.            
  8763.         }
  8764.     }
  8765.  
  8766.    
  8767.    
  8768.     public function HasAlternateQuen() : bool
  8769.     {
  8770.         var quenEntity : W3QuenEntity;
  8771.        
  8772.         quenEntity = (W3QuenEntity)GetCurrentSignEntity();
  8773.         if(quenEntity)
  8774.         {
  8775.             return quenEntity.IsAlternateCast();
  8776.         }
  8777.        
  8778.         return false;
  8779.     }
  8780.    
  8781.    
  8782.    
  8783.    
  8784.    
  8785.     public function AddPoints(type : ESpendablePointType, amount : int, show : bool)
  8786.     {
  8787.         levelManager.AddPoints(type, amount, show);
  8788.     }
  8789.    
  8790.     public function GetLevel() : int                                            {return levelManager.GetLevel();}
  8791.     public function GetMaxLevel() : int                                         {return levelManager.GetMaxLevel();}
  8792.     public function GetTotalExpForNextLevel() : int                             {return levelManager.GetTotalExpForNextLevel();}   
  8793.     public function GetPointsTotal(type : ESpendablePointType) : int            {return levelManager.GetPointsTotal(type);}
  8794.     public function IsAutoLeveling() : bool                                     {return autoLevel;}
  8795.     public function SetAutoLeveling( b : bool )                                 {autoLevel = b;}
  8796.    
  8797.     public function GetMissingExpForNextLevel() : int
  8798.     {
  8799.         return Max(0, GetTotalExpForNextLevel() - GetPointsTotal(EExperiencePoint));
  8800.     }
  8801.    
  8802.    
  8803.    
  8804.    
  8805.     private saved var runewordInfusionType : ESignType;
  8806.     default runewordInfusionType = ST_None;
  8807.    
  8808.     public final function GetRunewordInfusionType() : ESignType
  8809.     {
  8810.         return runewordInfusionType;
  8811.     }
  8812.    
  8813.    
  8814.     public function QuenImpulse( isAlternate : bool, signEntity : W3QuenEntity, source : string, optional forceSkillLevel : int )
  8815.     {
  8816.         var level, i, j : int;
  8817.         var atts, damages : array<name>;
  8818.         var ents : array<CGameplayEntity>;
  8819.         var action : W3DamageAction;
  8820.         var dm : CDefinitionsManagerAccessor;
  8821.         var skillAbilityName : name;
  8822.         var dmg : float;
  8823.         var min, max : SAbilityAttributeValue;
  8824.         var pos : Vector;
  8825.        
  8826.         if( forceSkillLevel > 0 )
  8827.         {
  8828.             level = forceSkillLevel;
  8829.         }
  8830.         else
  8831.         {
  8832.             level = GetSkillLevel(S_Magic_s13);
  8833.         }
  8834.        
  8835.         dm = theGame.GetDefinitionsManager();
  8836.         skillAbilityName = GetSkillAbilityName(S_Magic_s13);
  8837.        
  8838.         if(level >= 2)
  8839.         {
  8840.            
  8841.             dm.GetAbilityAttributes(skillAbilityName, atts);
  8842.             for(i=0; i<atts.Size(); i+=1)
  8843.             {
  8844.                 if(IsDamageTypeNameValid(atts[i]))
  8845.                 {
  8846.                     damages.PushBack(atts[i]);
  8847.                 }
  8848.             }
  8849.         }
  8850.        
  8851.        
  8852.         pos = signEntity.GetWorldPosition();
  8853.         FindGameplayEntitiesInSphere(ents, pos, 3, 1000, '', FLAG_OnlyAliveActors + FLAG_ExcludeTarget + FLAG_Attitude_Hostile + FLAG_Attitude_Neutral + FLAG_TestLineOfSight, this);
  8854.        
  8855.        
  8856.         for(i=0; i<ents.Size(); i+=1)
  8857.         {
  8858.             action = new W3DamageAction in theGame;
  8859.             action.Initialize(this, ents[i], signEntity, source, EHRT_Heavy, CPS_SpellPower, false, false, true, false);
  8860.             action.SetSignSkill(S_Magic_s13);
  8861.             action.SetCannotReturnDamage(true);
  8862.             action.SetProcessBuffsIfNoDamage(true);
  8863.            
  8864.            
  8865.             if(!isAlternate && level >= 2)
  8866.             {
  8867.                 action.SetHitEffect('hit_electric_quen');
  8868.                 action.SetHitEffect('hit_electric_quen', true);
  8869.                 action.SetHitEffect('hit_electric_quen', false, true);
  8870.                 action.SetHitEffect('hit_electric_quen', true, true);
  8871.             }
  8872.            
  8873.             if(level >= 1)
  8874.             {
  8875.                 action.AddEffectInfo(EET_Stagger);
  8876.             }
  8877.             if(level >= 2)
  8878.             {
  8879.                 for(j=0; j<damages.Size(); j+=1)
  8880.                 {
  8881.                     dm.GetAbilityAttributeValue(skillAbilityName, damages[j], min, max);
  8882.                     dmg = CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  8883.                     if( IsSetBonusActive( EISB_Bear_2 ) )
  8884.                     {
  8885.                         dm.GetAbilityAttributeValue( GetSetBonusAbility( EISB_Bear_2 ), 'quen_dmg_boost', min, max );
  8886.                         dmg *= 1 + min.valueMultiplicative;                    
  8887.                     }                  
  8888.                     action.AddDamage(damages[j], dmg);
  8889.                 }
  8890.             }
  8891.             if(level == 3)
  8892.             {
  8893.                 action.AddEffectInfo(EET_KnockdownTypeApplicator);
  8894.             }
  8895.            
  8896.             theGame.damageMgr.ProcessAction( action );
  8897.             delete action;
  8898.         }
  8899.        
  8900.        
  8901.         if(isAlternate)
  8902.         {
  8903.             signEntity.PlayHitEffect('quen_impulse_explode', signEntity.GetWorldRotation());
  8904.             signEntity.EraseFirstTimeStamp();
  8905.                        
  8906.            
  8907.             if(level >= 2)
  8908.             {
  8909.                 if( !IsSetBonusActive( EISB_Bear_2 ) )
  8910.                 {
  8911.                     signEntity.PlayHitEffect('quen_electric_explode', signEntity.GetWorldRotation());
  8912.                 }
  8913.                 else
  8914.                 {
  8915.                     signEntity.PlayHitEffect('quen_electric_explode_bear_abl2', signEntity.GetWorldRotation());
  8916.                 }
  8917.             }
  8918.         }
  8919.         else
  8920.         {
  8921.             signEntity.PlayEffect('lasting_shield_impulse');
  8922.         }      
  8923.     }
  8924.  
  8925.     public function OnSignCastPerformed(signType : ESignType, isAlternate : bool)
  8926.     {
  8927.         var items : array<SItemUniqueId>;
  8928.         var weaponEnt : CEntity;
  8929.         var fxName : name;
  8930.         var pos : Vector;
  8931.        
  8932.         super.OnSignCastPerformed(signType, isAlternate);
  8933.        
  8934.         if(HasAbility('Runeword 1 _Stats', true) && GetStat(BCS_Focus) >= 1.0f)
  8935.         {
  8936.             DrainFocus(1.0f);
  8937.             runewordInfusionType = signType;
  8938.             items = inv.GetHeldWeapons();
  8939.             weaponEnt = inv.GetItemEntityUnsafe(items[0]);
  8940.            
  8941.            
  8942.             weaponEnt.StopEffect('runeword_aard');
  8943.             weaponEnt.StopEffect('runeword_axii');
  8944.             weaponEnt.StopEffect('runeword_igni');
  8945.             weaponEnt.StopEffect('runeword_quen');
  8946.             weaponEnt.StopEffect('runeword_yrden');
  8947.                    
  8948.            
  8949.             if(signType == ST_Aard)
  8950.                 fxName = 'runeword_aard';
  8951.             else if(signType == ST_Axii)
  8952.                 fxName = 'runeword_axii';
  8953.             else if(signType == ST_Igni)
  8954.                 fxName = 'runeword_igni';
  8955.             else if(signType == ST_Quen)
  8956.                 fxName = 'runeword_quen';
  8957.             else if(signType == ST_Yrden)
  8958.                 fxName = 'runeword_yrden';
  8959.                
  8960.             weaponEnt.PlayEffect(fxName);
  8961.         }
  8962.        
  8963.        
  8964.         if( IsMutationActive( EPMT_Mutation6 ) && signType == ST_Aard && !isAlternate )
  8965.         {
  8966.             pos = GetWorldPosition() + GetWorldForward() * 2;
  8967.            
  8968.             theGame.GetSurfacePostFX().AddSurfacePostFXGroup( pos, 0.f, 3.f, 2.f, 5.f, 0 );
  8969.         }
  8970.     }
  8971.    
  8972.     public saved var savedQuenHealth, savedQuenDuration : float;
  8973.    
  8974.     timer function HACK_QuenSaveStatus(dt : float, id : int)
  8975.     {
  8976.         var quenEntity : W3QuenEntity;
  8977.        
  8978.         quenEntity = (W3QuenEntity)signs[ST_Quen].entity;
  8979.         savedQuenHealth = quenEntity.GetShieldHealth();
  8980.         savedQuenDuration = quenEntity.GetShieldRemainingDuration();
  8981.     }
  8982.    
  8983.     timer function DelayedRestoreQuen(dt : float, id : int)
  8984.     {
  8985.         RestoreQuen(savedQuenHealth, savedQuenDuration);
  8986.     }
  8987.    
  8988.     public final function OnBasicQuenFinishing()
  8989.     {
  8990.         RemoveTimer('HACK_QuenSaveStatus');
  8991.         savedQuenHealth = 0.f;
  8992.         savedQuenDuration = 0.f;
  8993.     }
  8994.    
  8995.     public final function IsAnyQuenActive() : bool
  8996.     {
  8997.         var quen : W3QuenEntity;
  8998.        
  8999.         quen = (W3QuenEntity)GetSignEntity(ST_Quen);
  9000.         if(quen)
  9001.             return quen.IsAnyQuenActive();
  9002.            
  9003.         return false;
  9004.     }
  9005.    
  9006.     public final function IsQuenActive(alternateMode : bool) : bool
  9007.     {
  9008.         if(IsAnyQuenActive() && GetSignEntity(ST_Quen).IsAlternateCast() == alternateMode)
  9009.             return true;
  9010.            
  9011.         return false;
  9012.     }
  9013.    
  9014.     public function FinishQuen( skipVisuals : bool, optional forceNoBearSetBonus : bool )
  9015.     {
  9016.         var quen : W3QuenEntity;
  9017.        
  9018.         quen = (W3QuenEntity)GetSignEntity(ST_Quen);
  9019.         if(quen)
  9020.             quen.ForceFinishQuen( skipVisuals, forceNoBearSetBonus );
  9021.     }
  9022.    
  9023.    
  9024.     public function GetTotalSignSpellPower(signSkill : ESkill) : SAbilityAttributeValue
  9025.     {
  9026.         var sp : SAbilityAttributeValue;
  9027.         var penalty : SAbilityAttributeValue;
  9028.         var penaltyReduction : float;
  9029.         var penaltyReductionLevel : int;
  9030.        
  9031.        
  9032.         sp = GetSkillAttributeValue(signSkill, PowerStatEnumToName(CPS_SpellPower), true, true);
  9033.        
  9034.        
  9035.         if ( signSkill == S_Magic_s01 )
  9036.         {
  9037.            
  9038.             penaltyReductionLevel = GetSkillLevel(S_Magic_s01) + 1;
  9039.             if(penaltyReductionLevel > 0)
  9040.             {
  9041.                 penaltyReduction = 1 - penaltyReductionLevel * CalculateAttributeValue(GetSkillAttributeValue(S_Magic_s01, 'spell_power_penalty_reduction', true, true));
  9042.                 penalty = GetSkillAttributeValue(S_Magic_s01, PowerStatEnumToName(CPS_SpellPower), false, false);
  9043.                 sp += penalty * penaltyReduction;  
  9044.             }
  9045.         }
  9046.        
  9047.        
  9048.         if(signSkill == S_Magic_1 || signSkill == S_Magic_s01)
  9049.         {
  9050.             sp += GetAttributeValue('spell_power_aard');
  9051.         }
  9052.         else if(signSkill == S_Magic_2 || signSkill == S_Magic_s02)
  9053.         {
  9054.             sp += GetAttributeValue('spell_power_igni');
  9055.         }
  9056.         else if(signSkill == S_Magic_3 || signSkill == S_Magic_s03)
  9057.         {
  9058.             sp += GetAttributeValue('spell_power_yrden');
  9059.         }
  9060.         else if(signSkill == S_Magic_4 || signSkill == S_Magic_s04)
  9061.         {
  9062.             sp += GetAttributeValue('spell_power_quen');
  9063.         }
  9064.         else if(signSkill == S_Magic_5 || signSkill == S_Magic_s05)
  9065.         {
  9066.             sp += GetAttributeValue('spell_power_axii');
  9067.         }
  9068.        
  9069.        
  9070.         ApplyMutation10StatBoost( sp );
  9071.    
  9072.         return sp;
  9073.     }
  9074.    
  9075.    
  9076.    
  9077.    
  9078.    
  9079.     public final function GetGwentCardIndex( cardName : name ) : int
  9080.     {
  9081.         var dm : CDefinitionsManagerAccessor;
  9082.        
  9083.         dm = theGame.GetDefinitionsManager();
  9084.        
  9085.         if(dm.ItemHasTag( cardName , 'GwintCardLeader' ))
  9086.         {
  9087.             return theGame.GetGwintManager().GwentLeadersNametoInt( cardName );
  9088.         }
  9089.         else if(dm.ItemHasTag( cardName , 'GwintCardNrkd' ))
  9090.         {
  9091.             return theGame.GetGwintManager().GwentNrkdNameToInt( cardName );
  9092.         }
  9093.         else if(dm.ItemHasTag( cardName , 'GwintCardNlfg' ))
  9094.         {
  9095.             return theGame.GetGwintManager().GwentNlfgNameToInt( cardName );
  9096.         }
  9097.         else if(dm.ItemHasTag( cardName , 'GwintCardSctl' ))
  9098.         {
  9099.             return theGame.GetGwintManager().GwentSctlNameToInt( cardName );
  9100.         }
  9101.         else if(dm.ItemHasTag( cardName , 'GwintCardMstr' ))
  9102.         {
  9103.             return theGame.GetGwintManager().GwentMstrNameToInt( cardName );
  9104.         }
  9105.         else if(dm.ItemHasTag( cardName , 'GwintCardSke' ))
  9106.         {
  9107.             return theGame.GetGwintManager().GwentSkeNameToInt( cardName );
  9108.         }  
  9109.         else if(dm.ItemHasTag( cardName , 'GwintCardNeutral' ))
  9110.         {
  9111.             return theGame.GetGwintManager().GwentNeutralNameToInt( cardName );
  9112.         }
  9113.         else if(dm.ItemHasTag( cardName , 'GwintCardSpcl' ))
  9114.         {
  9115.             return theGame.GetGwintManager().GwentSpecialNameToInt( cardName );
  9116.         }
  9117.        
  9118.         return -1;
  9119.     }
  9120.    
  9121.     public final function AddGwentCard(cardName : name, amount : int) : bool
  9122.     {
  9123.         var dm : CDefinitionsManagerAccessor;
  9124.         var cardIndex, i : int;
  9125.         var tut : STutorialMessage;
  9126.         var gwintManager : CR4GwintManager;
  9127.        
  9128.        
  9129.        
  9130.         if(FactsQuerySum("q001_nightmare_ended") > 0 && ShouldProcessTutorial('TutorialGwentDeckBuilder2'))
  9131.         {
  9132.             tut.type = ETMT_Hint;
  9133.             tut.tutorialScriptTag = 'TutorialGwentDeckBuilder2';
  9134.             tut.journalEntryName = 'TutorialGwentDeckBuilder2';
  9135.             tut.hintPositionType = ETHPT_DefaultGlobal;
  9136.             tut.markAsSeenOnShow = true;
  9137.             tut.hintDurationType = ETHDT_Long;
  9138.  
  9139.             theGame.GetTutorialSystem().DisplayTutorial(tut);
  9140.         }
  9141.        
  9142.         dm = theGame.GetDefinitionsManager();
  9143.        
  9144.         cardIndex = GetGwentCardIndex(cardName);
  9145.        
  9146.         if (cardIndex != -1)
  9147.         {
  9148.             FactsAdd("Gwint_Card_Looted");
  9149.            
  9150.             for(i = 0; i < amount; i += 1)
  9151.             {
  9152.                 theGame.GetGwintManager().AddCardToCollection( cardIndex );
  9153.             }
  9154.         }
  9155.        
  9156.         if( dm.ItemHasTag( cardName, 'GwentTournament' ) )
  9157.         {
  9158.             if ( dm.ItemHasTag( cardName, 'GT1' ) )
  9159.             {
  9160.                 FactsAdd( "GwentTournament", 1 );
  9161.             }
  9162.            
  9163.             else if ( dm.ItemHasTag( cardName, 'GT2' ) )
  9164.             {
  9165.                 FactsAdd( "GwentTournament", 2 );
  9166.             }
  9167.            
  9168.             else if ( dm.ItemHasTag( cardName, 'GT3' ) )
  9169.             {
  9170.                 FactsAdd( "GwentTournament", 3 );
  9171.             }
  9172.            
  9173.             else if ( dm.ItemHasTag( cardName, 'GT4' ) )
  9174.             {
  9175.                 FactsAdd( "GwentTournament", 4 );
  9176.             }
  9177.            
  9178.             else if ( dm.ItemHasTag( cardName, 'GT5' ) )
  9179.             {
  9180.                 FactsAdd( "GwentTournament", 5 );
  9181.             }
  9182.            
  9183.             else if ( dm.ItemHasTag( cardName, 'GT6' ) )
  9184.             {
  9185.                 FactsAdd( "GwentTournament", 6 );
  9186.             }
  9187.            
  9188.             else if ( dm.ItemHasTag( cardName, 'GT7' ) )
  9189.             {
  9190.                 FactsAdd( "GwentTournament", 7 );
  9191.             }
  9192.            
  9193.             CheckGwentTournamentDeck();
  9194.         }
  9195.        
  9196.         if( dm.ItemHasTag( cardName, 'EP2Tournament' ) )
  9197.         {
  9198.             if ( dm.ItemHasTag( cardName, 'GT1' ) )
  9199.             {
  9200.                 FactsAdd( "EP2Tournament", 1 );
  9201.             }
  9202.            
  9203.             else if ( dm.ItemHasTag( cardName, 'GT2' ) )
  9204.             {
  9205.                 FactsAdd( "EP2Tournament", 2 );
  9206.             }
  9207.            
  9208.             else if ( dm.ItemHasTag( cardName, 'GT3' ) )
  9209.             {
  9210.                 FactsAdd( "EP2Tournament", 3 );
  9211.             }
  9212.            
  9213.             else if ( dm.ItemHasTag( cardName, 'GT4' ) )
  9214.             {
  9215.                 FactsAdd( "EP2Tournament", 4 );
  9216.             }
  9217.            
  9218.             else if ( dm.ItemHasTag( cardName, 'GT5' ) )
  9219.             {
  9220.                 FactsAdd( "EP2Tournament", 5 );
  9221.             }
  9222.            
  9223.             else if ( dm.ItemHasTag( cardName, 'GT6' ) )
  9224.             {
  9225.                 FactsAdd( "EP2Tournament", 6 );
  9226.             }
  9227.            
  9228.             else if ( dm.ItemHasTag( cardName, 'GT7' ) )
  9229.             {
  9230.                 FactsAdd( "EP2Tournament", 7 );
  9231.             }
  9232.            
  9233.             CheckEP2TournamentDeck();
  9234.         }
  9235.        
  9236.         gwintManager = theGame.GetGwintManager();
  9237.         if( !gwintManager.IsDeckUnlocked( GwintFaction_Skellige ) &&
  9238.             gwintManager.HasCardsOfFactionInCollection( GwintFaction_Skellige, false ) )
  9239.         {
  9240.             gwintManager.UnlockDeck( GwintFaction_Skellige );
  9241.         }
  9242.        
  9243.         return true;
  9244.     }
  9245.    
  9246.    
  9247.     public final function RemoveGwentCard(cardName : name, amount : int) : bool
  9248.     {
  9249.         var dm : CDefinitionsManagerAccessor;
  9250.         var cardIndex, i : int;
  9251.        
  9252.         dm = theGame.GetDefinitionsManager();
  9253.        
  9254.         if(dm.ItemHasTag( cardName , 'GwintCardLeader' ))
  9255.         {
  9256.             cardIndex = theGame.GetGwintManager().GwentLeadersNametoInt( cardName );
  9257.             for(i=0; i<amount; i+=1)
  9258.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  9259.         }
  9260.         else if(dm.ItemHasTag( cardName , 'GwintCardNrkd' ))
  9261.         {
  9262.             cardIndex = theGame.GetGwintManager().GwentNrkdNameToInt( cardName );
  9263.             for(i=0; i<amount; i+=1)
  9264.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  9265.         }
  9266.         else if(dm.ItemHasTag( cardName , 'GwintCardNlfg' ))
  9267.         {
  9268.             cardIndex = theGame.GetGwintManager().GwentNlfgNameToInt( cardName );
  9269.             for(i=0; i<amount; i+=1)
  9270.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  9271.         }
  9272.         else if(dm.ItemHasTag( cardName , 'GwintCardSctl' ))
  9273.         {
  9274.             cardIndex = theGame.GetGwintManager().GwentSctlNameToInt( cardName );
  9275.             for(i=0; i<amount; i+=1)
  9276.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  9277.         }
  9278.         else if(dm.ItemHasTag( cardName , 'GwintCardMstr' ))
  9279.         {
  9280.             cardIndex = theGame.GetGwintManager().GwentMstrNameToInt( cardName );
  9281.             for(i=0; i<amount; i+=1)
  9282.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  9283.         }
  9284.         else if(dm.ItemHasTag( cardName , 'GwintCardNeutral' ))
  9285.         {
  9286.             cardIndex = theGame.GetGwintManager().GwentNeutralNameToInt( cardName );
  9287.             for(i=0; i<amount; i+=1)
  9288.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  9289.         }
  9290.         else if(dm.ItemHasTag( cardName , 'GwintCardSpcl' ))
  9291.         {
  9292.             cardIndex = theGame.GetGwintManager().GwentSpecialNameToInt( cardName );
  9293.             for(i=0; i<amount; i+=1)
  9294.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  9295.         }
  9296.        
  9297.         if( dm.ItemHasTag( cardName, 'GwentTournament' ) )
  9298.         {
  9299.             if ( dm.ItemHasTag( cardName, 'GT1' ) )
  9300.             {
  9301.                 FactsSubstract( "GwentTournament", 1 );
  9302.             }
  9303.            
  9304.             else if ( dm.ItemHasTag( cardName, 'GT2' ) )
  9305.             {
  9306.                 FactsSubstract( "GwentTournament", 2 );
  9307.             }
  9308.            
  9309.             else if ( dm.ItemHasTag( cardName, 'GT3' ) )
  9310.             {
  9311.                 FactsSubstract( "GwentTournament", 3 );
  9312.             }
  9313.            
  9314.             else if ( dm.ItemHasTag( cardName, 'GT4' ) )
  9315.             {
  9316.                 FactsSubstract( "GwentTournament", 4 );
  9317.             }
  9318.            
  9319.             else if ( dm.ItemHasTag( cardName, 'GT5' ) )
  9320.             {
  9321.                 FactsSubstract( "GwentTournament", 5 );
  9322.             }
  9323.            
  9324.             else if ( dm.ItemHasTag( cardName, 'GT6' ) )
  9325.             {
  9326.                 FactsSubstract( "GwentTournament", 6 );
  9327.             }
  9328.            
  9329.             else if ( dm.ItemHasTag( cardName, 'GT7' ) )
  9330.             {
  9331.                 FactsSubstract( "GwentTournament", 7 );
  9332.             }
  9333.            
  9334.             CheckGwentTournamentDeck();
  9335.         }
  9336.            
  9337.            
  9338.         if( dm.ItemHasTag( cardName, 'EP2Tournament' ) )
  9339.         {
  9340.             if ( dm.ItemHasTag( cardName, 'GT1' ) )
  9341.             {
  9342.                 FactsSubstract( "EP2Tournament", 1 );
  9343.             }
  9344.            
  9345.             else if ( dm.ItemHasTag( cardName, 'GT2' ) )
  9346.             {
  9347.                 FactsSubstract( "EP2Tournament", 2 );
  9348.             }
  9349.            
  9350.             else if ( dm.ItemHasTag( cardName, 'GT3' ) )
  9351.             {
  9352.                 FactsSubstract( "EP2Tournament", 3 );
  9353.             }
  9354.            
  9355.             else if ( dm.ItemHasTag( cardName, 'GT4' ) )
  9356.             {
  9357.                 FactsSubstract( "EP2Tournament", 4 );
  9358.             }
  9359.            
  9360.             else if ( dm.ItemHasTag( cardName, 'GT5' ) )
  9361.             {
  9362.                 FactsSubstract( "EP2Tournament", 5 );
  9363.             }
  9364.            
  9365.             else if ( dm.ItemHasTag( cardName, 'GT6' ) )
  9366.             {
  9367.                 FactsSubstract( "EP2Tournament", 6 );
  9368.             }
  9369.            
  9370.             else if ( dm.ItemHasTag( cardName, 'GT7' ) )
  9371.             {
  9372.                 FactsSubstract( "EP2Tournament", 7 );
  9373.             }
  9374.            
  9375.             CheckEP2TournamentDeck();
  9376.         }
  9377.        
  9378.         return true;
  9379.     }
  9380.    
  9381.     function CheckGwentTournamentDeck()
  9382.     {
  9383.         var gwentPower          : int;
  9384.         var neededGwentPower    : int;
  9385.         var checkBreakpoint     : int;
  9386.        
  9387.         neededGwentPower = 70;
  9388.        
  9389.         checkBreakpoint = neededGwentPower/5;
  9390.         gwentPower = FactsQuerySum( "GwentTournament" );
  9391.        
  9392.         if ( gwentPower >= neededGwentPower )
  9393.         {
  9394.             FactsAdd( "HasGwentTournamentDeck", 1 );
  9395.         }
  9396.         else
  9397.         {
  9398.             if( FactsDoesExist( "HasGwentTournamentDeck" ) )
  9399.             {
  9400.                 FactsRemove( "HasGwentTournamentDeck" );
  9401.             }
  9402.            
  9403.             if ( gwentPower >= checkBreakpoint )
  9404.             {
  9405.                 FactsAdd( "GwentTournamentObjective1", 1 );
  9406.             }
  9407.             else if ( FactsDoesExist( "GwentTournamentObjective1" ) )
  9408.             {
  9409.                 FactsRemove( "GwentTournamentObjective1" );
  9410.             }
  9411.            
  9412.             if ( gwentPower >= checkBreakpoint*2 )
  9413.             {
  9414.                 FactsAdd( "GwentTournamentObjective2", 1 );
  9415.             }
  9416.             else if ( FactsDoesExist( "GwentTournamentObjective2" ) )
  9417.             {
  9418.                 FactsRemove( "GwentTournamentObjective2" );
  9419.             }
  9420.            
  9421.             if ( gwentPower >= checkBreakpoint*3 )
  9422.             {
  9423.                 FactsAdd( "GwentTournamentObjective3", 1 );
  9424.             }
  9425.             else if ( FactsDoesExist( "GwentTournamentObjective3" ) )
  9426.             {
  9427.                 FactsRemove( "GwentTournamentObjective3" );
  9428.             }
  9429.            
  9430.             if ( gwentPower >= checkBreakpoint*4 )
  9431.             {
  9432.                 FactsAdd( "GwentTournamentObjective4", 1 );
  9433.             }
  9434.             else if ( FactsDoesExist( "GwentTournamentObjective4" ) )
  9435.             {
  9436.                 FactsRemove( "GwentTournamentObjective4" );
  9437.             }
  9438.         }
  9439.     }
  9440.    
  9441.     function CheckEP2TournamentDeck()
  9442.     {
  9443.         var gwentPower          : int;
  9444.         var neededGwentPower    : int;
  9445.         var checkBreakpoint     : int;
  9446.        
  9447.         neededGwentPower = 24;
  9448.        
  9449.         checkBreakpoint = neededGwentPower/5;
  9450.         gwentPower = FactsQuerySum( "EP2Tournament" );
  9451.        
  9452.         if ( gwentPower >= neededGwentPower )
  9453.         {
  9454.             if( FactsQuerySum( "HasEP2TournamentDeck") == 0 )
  9455.             {
  9456.                 FactsAdd( "HasEP2TournamentDeck", 1 );
  9457.             }
  9458.            
  9459.         }
  9460.         else
  9461.         {
  9462.             if( FactsDoesExist( "HasEP2TournamentDeck" ) )
  9463.             {
  9464.                 FactsRemove( "HasEP2TournamentDeck" );
  9465.             }
  9466.            
  9467.             if ( gwentPower >= checkBreakpoint )
  9468.             {
  9469.                 FactsAdd( "EP2TournamentObjective1", 1 );
  9470.             }
  9471.             else if ( FactsDoesExist( "EP2TournamentObjective1" ) )
  9472.             {
  9473.                 FactsRemove( "EP2TournamentObjective1" );
  9474.             }
  9475.            
  9476.             if ( gwentPower >= checkBreakpoint*2 )
  9477.             {
  9478.                 FactsAdd( "EP2TournamentObjective2", 1 );
  9479.             }
  9480.             else if ( FactsDoesExist( "EP2TournamentObjective2" ) )
  9481.             {
  9482.                 FactsRemove( "EP2TournamentObjective2" );
  9483.             }
  9484.            
  9485.             if ( gwentPower >= checkBreakpoint*3 )
  9486.             {
  9487.                 FactsAdd( "EP2TournamentObjective3", 1 );
  9488.             }
  9489.             else if ( FactsDoesExist( "EP2TournamentObjective3" ) )
  9490.             {
  9491.                 FactsRemove( "EP2TournamentObjective3" );
  9492.             }
  9493.            
  9494.             if ( gwentPower >= checkBreakpoint*4 )
  9495.             {
  9496.                 FactsAdd( "EP2TournamentObjective4", 1 );
  9497.             }
  9498.             else if ( FactsDoesExist( "EP2TournamentObjective4" ) )
  9499.             {
  9500.                 FactsRemove( "EP2TournamentObjective4" );
  9501.             }
  9502.         }
  9503.     }
  9504.    
  9505.    
  9506.    
  9507.    
  9508.    
  9509.    
  9510.     public function SimulateBuffTimePassing(simulatedTime : float)
  9511.     {
  9512.         super.SimulateBuffTimePassing(simulatedTime);
  9513.        
  9514.         FinishQuen(true);
  9515.     }
  9516.    
  9517.    
  9518.     public function CanMeditate() : bool
  9519.     {
  9520.         var currentStateName : name;
  9521.        
  9522.         currentStateName = GetCurrentStateName();
  9523.        
  9524.        
  9525.         if(currentStateName == 'Exploration' && !CanPerformPlayerAction())
  9526.             return false;
  9527.        
  9528.        
  9529.         if(GetCurrentStateName() != 'Exploration' && GetCurrentStateName() != 'Meditation' && GetCurrentStateName() != 'MeditationWaiting')
  9530.             return false;
  9531.            
  9532.        
  9533.         if(GetUsedVehicle())
  9534.             return false;
  9535.            
  9536.        
  9537.         return CanMeditateHere();
  9538.     }
  9539.    
  9540.    
  9541.     public final function CanMeditateWait(optional skipMeditationStateCheck : bool) : bool
  9542.     {
  9543.         var currState : name;
  9544.        
  9545.         currState = GetCurrentStateName();
  9546.        
  9547.        
  9548.        
  9549.         if(!skipMeditationStateCheck && currState != 'Meditation')
  9550.             return false;
  9551.            
  9552.        
  9553.         if(theGame.IsGameTimePaused())
  9554.             return false;
  9555.            
  9556.         if(!IsActionAllowed( EIAB_MeditationWaiting ))
  9557.             return false;
  9558.            
  9559.         return true;
  9560.     }
  9561.  
  9562.    
  9563.     public final function CanMeditateHere() : bool
  9564.     {
  9565.         var pos : Vector;
  9566.        
  9567.         pos = GetWorldPosition();
  9568.         if(pos.Z <= theGame.GetWorld().GetWaterLevel(pos, true) && IsInShallowWater())
  9569.             return false;
  9570.        
  9571.         if(IsThreatened())
  9572.             return false;
  9573.        
  9574.         return true;
  9575.     }
  9576.    
  9577.    
  9578.     public function Meditate() : bool
  9579.     {
  9580.         var medState            : W3PlayerWitcherStateMeditation;
  9581.         var stateName           : name;
  9582.    
  9583.         stateName = GetCurrentStateName();
  9584.    
  9585.        
  9586.         if (!CanMeditate()  || stateName == 'MeditationWaiting' )
  9587.             return false;
  9588.    
  9589.         GotoState('Meditation');
  9590.         medState = (W3PlayerWitcherStateMeditation)GetState('Meditation');     
  9591.         medState.SetMeditationPointHeading(GetHeading());
  9592.        
  9593.         return true;
  9594.     }
  9595.    
  9596.    
  9597.     public final function MeditationRestoring(simulatedTime : float)
  9598.     {          
  9599.        
  9600.         if ( theGame.GetDifficultyMode() != EDM_Hard && theGame.GetDifficultyMode() != EDM_Hardcore )
  9601.         {
  9602.             Heal(GetStatMax(BCS_Vitality));
  9603.         }
  9604.        
  9605.        
  9606.         abilityManager.DrainToxicity( abilityManager.GetStat( BCS_Toxicity ) );
  9607.         abilityManager.DrainFocus( abilityManager.GetStat( BCS_Focus ) );
  9608.        
  9609.        
  9610.         inv.SingletonItemsRefillAmmo();
  9611.        
  9612.        
  9613.         SimulateBuffTimePassing(simulatedTime);
  9614.        
  9615.        
  9616.         ApplyWitcherHouseBuffs();
  9617.     }
  9618.    
  9619.     var clockMenu : CR4MeditationClockMenu;
  9620.    
  9621.     public function MeditationClockStart(m : CR4MeditationClockMenu)
  9622.     {
  9623.         clockMenu = m;
  9624.         AddTimer('UpdateClockTime',0.1,true);
  9625.     }
  9626.    
  9627.     public function MeditationClockStop()
  9628.     {
  9629.         clockMenu = NULL;
  9630.         RemoveTimer('UpdateClockTime');
  9631.     }
  9632.    
  9633.     public timer function UpdateClockTime(dt : float, id : int)
  9634.     {
  9635.         if(clockMenu)
  9636.             clockMenu.UpdateCurrentHours();
  9637.         else
  9638.             RemoveTimer('UpdateClockTime');
  9639.     }
  9640.    
  9641.     private var waitTimeHour : int;
  9642.     public function SetWaitTargetHour(t : int)
  9643.     {
  9644.         waitTimeHour = t;
  9645.     }
  9646.     public function GetWaitTargetHour() : int
  9647.     {
  9648.         return waitTimeHour;
  9649.     }
  9650.    
  9651.     public function MeditationForceAbort(forceCloseUI : bool)
  9652.     {
  9653.         var waitt : W3PlayerWitcherStateMeditationWaiting;
  9654.         var medd : W3PlayerWitcherStateMeditation;
  9655.         var currentStateName : name;
  9656.        
  9657.         currentStateName = GetCurrentStateName();
  9658.        
  9659.         if(currentStateName == 'MeditationWaiting')
  9660.         {
  9661.             waitt = (W3PlayerWitcherStateMeditationWaiting)GetCurrentState();
  9662.             if(waitt)
  9663.             {
  9664.                 waitt.StopRequested(forceCloseUI);
  9665.             }
  9666.         }
  9667.         else if(currentStateName == 'Meditation')
  9668.         {
  9669.             medd = (W3PlayerWitcherStateMeditation)GetCurrentState();
  9670.             if(medd)
  9671.             {
  9672.                 medd.StopRequested(forceCloseUI);
  9673.             }
  9674.         }
  9675.        
  9676.        
  9677.        
  9678.         if( forceCloseUI && theGame.GetGuiManager().IsAnyMenu() && !theGame.GetPhotomodeEnabled() )
  9679.         {
  9680.             theGame.GetGuiManager().GetRootMenu().CloseMenu();
  9681.             DisplayActionDisallowedHudMessage(EIAB_MeditationWaiting, false, false, true, false);
  9682.         }
  9683.     }
  9684.    
  9685.     public function Runeword10Triggerred()
  9686.     {
  9687.         var min, max : SAbilityAttributeValue;
  9688.         var amount : float;
  9689.        
  9690.        
  9691.        
  9692.         theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Runeword 10 _Stats', 'stamina_runeword_gain', min, max );
  9693.        
  9694.        
  9695.         amount = min.valueMultiplicative * GetStatMax(BCS_Stamina);
  9696.         if ( GetStat(BCS_Stamina) + amount > GetStatMax(BCS_Stamina) )
  9697.         {
  9698.             amount = GetStatMax(BCS_Stamina) - GetStat(BCS_Stamina);
  9699.         }
  9700.         GainStat(BCS_Stamina, amount);
  9701.        
  9702.        
  9703.         PlayEffect('runeword_10_stamina');
  9704.     }
  9705.    
  9706.     public function Runeword12Triggerred()
  9707.     {
  9708.         var min, max : SAbilityAttributeValue;
  9709.         var amount : float;
  9710.        
  9711.        
  9712.        
  9713.         theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Runeword 12 _Stats', 'focus_runeword_gain', min, max );
  9714.        
  9715.        
  9716.         amount = RandRangeF(max.valueAdditive, min.valueAdditive);
  9717.         if ( GetStat(BCS_Focus) + amount > GetStatMax(BCS_Focus) )
  9718.         {
  9719.             amount = GetStatMax(BCS_Focus) - GetStat(BCS_Focus);
  9720.         }
  9721.         GainStat(BCS_Focus, amount);
  9722.        
  9723.        
  9724.         PlayEffect('runeword_20_adrenaline');  
  9725.     }
  9726.    
  9727.     var runeword10TriggerredOnFinisher, runeword12TriggerredOnFinisher : bool;
  9728.    
  9729.     event OnFinisherStart()
  9730.     {
  9731.         super.OnFinisherStart();
  9732.        
  9733.         runeword10TriggerredOnFinisher = false;
  9734.         runeword12TriggerredOnFinisher = false;
  9735.     }
  9736.    
  9737.     public function ApplyWitcherHouseBuffs()
  9738.     {
  9739.         var l_bed           : W3WitcherBed;
  9740.        
  9741.         if( FactsQuerySum( "PlayerInsideInnerWitcherHouse" ) > 0 )
  9742.         {
  9743.             l_bed = (W3WitcherBed)theGame.GetEntityByTag( 'witcherBed' );
  9744.            
  9745.             if( l_bed.GetWasUsed() )
  9746.             {
  9747.                 if( l_bed.GetBedLevel() != 0 )
  9748.                 {
  9749.                     AddEffectDefault( EET_WellRested, this, "Bed Buff" );
  9750.                 }
  9751.  
  9752.                 if( FactsQuerySum( "StablesExists" ) )
  9753.                 {
  9754.                     AddEffectDefault( EET_HorseStableBuff, this, "Stables" );
  9755.                 }
  9756.                
  9757.                 if( l_bed.GetWereItemsRefilled() )
  9758.                 {
  9759.                     theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_common_alchemy_table_buff_applied" ),, true );
  9760.                     l_bed.SetWereItemsRefilled( false );
  9761.                 }
  9762.                
  9763.                 AddEffectDefault( EET_BookshelfBuff, this, "Bookshelf" );
  9764.                
  9765.                 Heal( GetStatMax( BCS_Vitality ) );
  9766.             }
  9767.         }
  9768.     }
  9769.    
  9770.    
  9771.    
  9772.    
  9773.    
  9774.     public function CheatResurrect()
  9775.     {
  9776.         super.CheatResurrect();
  9777.         theGame.ReleaseNoSaveLock(theGame.deathSaveLockId);
  9778.         theInput.RestoreContext( 'Exploration', true );
  9779.     }
  9780.    
  9781.    
  9782.     public function Debug_EquipTestingSkills(equip : bool, force : bool)
  9783.     {
  9784.         var skills : array<ESkill>;
  9785.         var i, slot : int;
  9786.        
  9787.        
  9788.         ((W3PlayerAbilityManager)abilityManager).OnLevelGained(36);
  9789.        
  9790.         skills.PushBack(S_Magic_s01);
  9791.         skills.PushBack(S_Magic_s02);
  9792.         skills.PushBack(S_Magic_s03);
  9793.         skills.PushBack(S_Magic_s04);
  9794.         skills.PushBack(S_Magic_s05);
  9795.         skills.PushBack(S_Sword_s01);
  9796.         skills.PushBack(S_Sword_s02);
  9797.        
  9798.        
  9799.         if(equip)
  9800.         {
  9801.             for(i=0; i<skills.Size(); i+=1)
  9802.             {
  9803.                 if(!force && IsSkillEquipped(skills[i]))
  9804.                     continue;
  9805.                    
  9806.                
  9807.                 if(GetSkillLevel(skills[i]) == 0)
  9808.                     AddSkill(skills[i]);
  9809.                
  9810.                
  9811.                 if(force)
  9812.                     slot = i+1;    
  9813.                 else
  9814.                     slot = GetFreeSkillSlot();
  9815.                
  9816.                
  9817.                 EquipSkill(skills[i], slot);
  9818.             }
  9819.         }
  9820.         else
  9821.         {
  9822.             for(i=0; i<skills.Size(); i+=1)
  9823.             {
  9824.                 UnequipSkill(GetSkillSlotID(skills[i]));
  9825.             }
  9826.         }
  9827.     }
  9828.    
  9829.     public function Debug_ClearCharacterDevelopment(optional keepInv : bool)
  9830.     {
  9831.         var template : CEntityTemplate;
  9832.         var entity : CEntity;
  9833.         var invTesting : CInventoryComponent;
  9834.         var i : int;
  9835.         var items : array<SItemUniqueId>;
  9836.         var abs : array<name>;
  9837.    
  9838.         delete abilityManager;
  9839.         delete levelManager;
  9840.         delete effectManager;
  9841.        
  9842.        
  9843.         GetCharacterStats().GetAbilities(abs, false);
  9844.         for(i=0; i<abs.Size(); i+=1)
  9845.             RemoveAbility(abs[i]);
  9846.            
  9847.        
  9848.         abs.Clear();
  9849.         GetCharacterStatsParam(abs);       
  9850.         for(i=0; i<abs.Size(); i+=1)
  9851.             AddAbility(abs[i]);
  9852.                    
  9853.        
  9854.         levelManager = new W3LevelManager in this;         
  9855.         levelManager.Initialize();
  9856.         levelManager.PostInit(this, false, true);      
  9857.                        
  9858.        
  9859.         AddAbility('GeraltSkills_Testing');
  9860.         SetAbilityManager();       
  9861.         abilityManager.Init(this, GetCharacterStats(), false, theGame.GetDifficultyMode());
  9862.        
  9863.         SetEffectManager();
  9864.        
  9865.         abilityManager.PostInit();                     
  9866.        
  9867.        
  9868.        
  9869.        
  9870.        
  9871.         if(!keepInv)
  9872.         {
  9873.             inv.RemoveAllItems();
  9874.         }      
  9875.        
  9876.        
  9877.         template = (CEntityTemplate)LoadResource("geralt_inventory_release");
  9878.         entity = theGame.CreateEntity(template, Vector(0,0,0));
  9879.         invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  9880.         invTesting.GiveAllItemsTo(inv, true);
  9881.         entity.Destroy();
  9882.        
  9883.        
  9884.         inv.GetAllItems(items);
  9885.         for(i=0; i<items.Size(); i+=1)
  9886.         {
  9887.             if(!inv.ItemHasTag(items[i], 'NoDrop'))        
  9888.                 EquipItem(items[i]);
  9889.         }
  9890.            
  9891.        
  9892.         Debug_GiveTestingItems(0);
  9893.     }
  9894.    
  9895.     function Debug_BearSetBonusQuenSkills()
  9896.     {
  9897.         var skills  : array<ESkill>;
  9898.         var i, slot : int;
  9899.        
  9900.         skills.PushBack(S_Magic_s04);
  9901.         skills.PushBack(S_Magic_s14);
  9902.        
  9903.         for(i=0; i<skills.Size(); i+=1)
  9904.         {              
  9905.            
  9906.             if(GetSkillLevel(skills[i]) == 0)
  9907.             {
  9908.                 AddSkill(skills[i]);
  9909.             }
  9910.            
  9911.             slot = GetFreeSkillSlot();
  9912.            
  9913.            
  9914.             EquipSkill(skills[i], slot);
  9915.         }
  9916.     }
  9917.    
  9918.     final function Debug_HAX_UnlockSkillSlot(slotIndex : int) : bool
  9919.     {
  9920.         if(abilityManager && abilityManager.IsInitialized())
  9921.             return ((W3PlayerAbilityManager)abilityManager).Debug_HAX_UnlockSkillSlot(slotIndex);
  9922.            
  9923.         return false;
  9924.     }
  9925.    
  9926.    
  9927.     public function GetLevelupAbility( id : int) : name
  9928.     {
  9929.         switch(id)
  9930.         {
  9931.             case 1: return 'Lvl1';
  9932.             case 2: return 'Lvl2';
  9933.             case 3: return 'Lvl3';
  9934.             case 4: return 'Lvl4';
  9935.             case 5: return 'Lvl5';
  9936.             case 6: return 'Lvl6';
  9937.             case 7: return 'Lvl7';
  9938.             case 8: return 'Lvl8';
  9939.             case 9: return 'Lvl9';
  9940.             case 10: return 'Lvl10';
  9941.             case 11: return 'Lvl11';
  9942.             case 12: return 'Lvl12';
  9943.             case 13: return 'Lvl13';
  9944.             case 14: return 'Lvl14';
  9945.             case 15: return 'Lvl15';
  9946.             case 16: return 'Lvl16';
  9947.             case 17: return 'Lvl17';
  9948.             case 18: return 'Lvl18';
  9949.             case 19: return 'Lvl19';
  9950.             case 20: return 'Lvl20';
  9951.             case 21: return 'Lvl21';
  9952.             case 22: return 'Lvl22';
  9953.             case 23: return 'Lvl23';
  9954.             case 24: return 'Lvl24';
  9955.             case 25: return 'Lvl25';
  9956.             case 26: return 'Lvl26';
  9957.             case 27: return 'Lvl27';
  9958.             case 28: return 'Lvl28';
  9959.             case 29: return 'Lvl29';
  9960.             case 30: return 'Lvl30';
  9961.             case 31: return 'Lvl31';
  9962.             case 32: return 'Lvl32';
  9963.             case 33: return 'Lvl33';
  9964.             case 34: return 'Lvl34';
  9965.             case 35: return 'Lvl35';
  9966.             case 36: return 'Lvl36';
  9967.             case 37: return 'Lvl37';
  9968.             case 38: return 'Lvl38';
  9969.             case 39: return 'Lvl39';
  9970.             case 40: return 'Lvl40';
  9971.             case 41: return 'Lvl41';
  9972.             case 42: return 'Lvl42';
  9973.             case 43: return 'Lvl43';
  9974.             case 44: return 'Lvl44';
  9975.             case 45: return 'Lvl45';
  9976.             case 46: return 'Lvl46';
  9977.             case 47: return 'Lvl47';
  9978.             case 48: return 'Lvl48';
  9979.             case 49: return 'Lvl49';
  9980.             case 50: return 'Lvl50';
  9981.        
  9982.             default: return '';
  9983.         }
  9984.        
  9985.         return '';
  9986.     }  
  9987.    
  9988.     public function CanSprint( speed : float ) : bool
  9989.     {
  9990.         if( !super.CanSprint( speed ) )
  9991.         {
  9992.             return false;
  9993.         }      
  9994.         if( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  9995.         {
  9996.             if ( this.GetPlayerCombatStance() ==  PCS_AlertNear )
  9997.             {
  9998.                 if ( IsSprintActionPressed() )
  9999.                     OnRangedForceHolster( true, false );
  10000.             }
  10001.             else
  10002.                 return false;
  10003.         }
  10004.         if( GetCurrentStateName() != 'Swimming' && GetStat(BCS_Stamina) <= 0 )
  10005.         {
  10006.             SetSprintActionPressed(false,true);
  10007.             return false;
  10008.         }
  10009.        
  10010.         return true;
  10011.     }
  10012.    
  10013.     public function ManageSleeping()
  10014.     {
  10015.         thePlayer.RemoveBuffImmunity_AllCritical( 'Bed' );
  10016.         thePlayer.RemoveBuffImmunity_AllNegative( 'Bed' );
  10017.  
  10018.         thePlayer.PlayerStopAction( PEA_GoToSleep );
  10019.     }
  10020.    
  10021.    
  10022.    
  10023.     public function RestoreHorseManager() : bool
  10024.     {
  10025.         var horseTemplate   : CEntityTemplate;
  10026.         var horseManager    : W3HorseManager;  
  10027.        
  10028.         if ( GetHorseManager() )
  10029.         {
  10030.             return false;
  10031.         }
  10032.        
  10033.         horseTemplate = (CEntityTemplate)LoadResource("horse_manager");
  10034.         horseManager = (W3HorseManager)theGame.CreateEntity(horseTemplate, GetWorldPosition(),,,,,PM_Persist);
  10035.         horseManager.CreateAttachment(this);
  10036.         horseManager.OnCreated();
  10037.         EntityHandleSet( horseManagerHandle, horseManager );   
  10038.        
  10039.         return true;
  10040.     }
  10041.    
  10042.    
  10043.    
  10044.    
  10045.    
  10046.    
  10047.     final function PerformParryCheck( parryInfo : SParryInfo ) : bool
  10048.     {
  10049.         if( super.PerformParryCheck( parryInfo ) )
  10050.         {
  10051.             GainAdrenalineFromPerk21( 'parry' );
  10052.             return true;
  10053.         }
  10054.         return false;
  10055.     }  
  10056.    
  10057.     protected final function PerformCounterCheck( parryInfo: SParryInfo ) : bool
  10058.     {
  10059.         var fistFightCheck, isInFistFight       : bool;
  10060.        
  10061.         if( super.PerformCounterCheck( parryInfo ) )
  10062.         {
  10063.             GainAdrenalineFromPerk21( 'counter' );
  10064.            
  10065.             isInFistFight = FistFightCheck( parryInfo.target, parryInfo.attacker, fistFightCheck );
  10066.            
  10067.             if( isInFistFight && fistFightCheck )
  10068.             {
  10069.                 FactsAdd( "statistics_fist_fight_counter" );
  10070.                 AddTimer( 'FistFightCounterTimer', 0.5f, , , , true );
  10071.             }
  10072.            
  10073.             return true;
  10074.         }
  10075.         return false;
  10076.     }
  10077.    
  10078.     public function GainAdrenalineFromPerk21( n : name )
  10079.     {
  10080.         var perkStats, perkTime : SAbilityAttributeValue;
  10081.         var targets : array<CActor>;
  10082.        
  10083.         targets = GetHostileEnemies();
  10084.        
  10085.         if( !CanUseSkill( S_Perk_21 ) || targets.Size() == 0 )
  10086.         {
  10087.             return;
  10088.         }
  10089.        
  10090.         perkTime = GetSkillAttributeValue( S_Perk_21, 'perk21Time', false, false );
  10091.        
  10092.         if( theGame.GetEngineTimeAsSeconds() >= timeForPerk21 + perkTime.valueAdditive )
  10093.         {
  10094.             perkStats = GetSkillAttributeValue( S_Perk_21, n , false, false );
  10095.             GainStat( BCS_Focus, perkStats.valueAdditive );
  10096.             timeForPerk21 = theGame.GetEngineTimeAsSeconds();
  10097.            
  10098.             AddEffectDefault( EET_Perk21InternalCooldown, this, "Perk21", false );
  10099.         }  
  10100.     }
  10101.    
  10102.     timer function FistFightCounterTimer( dt : float, id : int )
  10103.     {
  10104.         FactsRemove( "statistics_fist_fight_counter" );
  10105.     }
  10106.    
  10107.     public final function IsSignBlocked(signType : ESignType) : bool
  10108.     {
  10109.         switch( signType )
  10110.         {
  10111.             case ST_Aard :
  10112.                 return IsRadialSlotBlocked ( 'Aard');
  10113.                 break;
  10114.             case ST_Axii :
  10115.                 return IsRadialSlotBlocked ( 'Axii');
  10116.                 break;
  10117.             case ST_Igni :
  10118.                 return IsRadialSlotBlocked ( 'Igni');
  10119.                 break;
  10120.             case ST_Quen :
  10121.                 return IsRadialSlotBlocked ( 'Quen');
  10122.                 break;
  10123.             case ST_Yrden :
  10124.                 return IsRadialSlotBlocked ( 'Yrden');
  10125.                 break;
  10126.             default:
  10127.                 break;
  10128.         }
  10129.         return false;
  10130.        
  10131.     }
  10132.    
  10133.     public final function AddAnItemWithAutogenLevelAndQuality(itemName : name, desiredLevel : int, minQuality : int, optional equipItem : bool)
  10134.     {
  10135.         var itemLevel, quality : int;
  10136.         var ids : array<SItemUniqueId>;
  10137.         var attemptCounter : int;
  10138.        
  10139.         itemLevel = 0;
  10140.         quality = 0;
  10141.         attemptCounter = 0;
  10142.         while(itemLevel != desiredLevel || quality < minQuality)
  10143.         {
  10144.             attemptCounter += 1;
  10145.             ids.Clear();
  10146.             ids = inv.AddAnItem(itemName, 1, true);
  10147.             itemLevel = inv.GetItemLevel(ids[0]);
  10148.             quality = RoundMath(CalculateAttributeValue(inv.GetItemAttributeValue(ids[0], 'quality')));
  10149.            
  10150.            
  10151.             if(attemptCounter >= 1000)
  10152.                 break;
  10153.            
  10154.             if(itemLevel != desiredLevel || quality < minQuality)
  10155.                 inv.RemoveItem(ids[0]);
  10156.         }
  10157.        
  10158.         if(equipItem)
  10159.             EquipItem(ids[0]);
  10160.     }
  10161.    
  10162.     public final function AddAnItemWithAutogenLevel(itemName : name, desiredLevel : int)
  10163.     {
  10164.         var itemLevel : int;
  10165.         var ids : array<SItemUniqueId>;
  10166.         var attemptCounter : int;
  10167.  
  10168.         itemLevel = 0;
  10169.         while(itemLevel != desiredLevel)
  10170.         {
  10171.             attemptCounter += 1;
  10172.             ids.Clear();
  10173.             ids = inv.AddAnItem(itemName, 1, true);
  10174.             itemLevel = inv.GetItemLevel(ids[0]);
  10175.            
  10176.            
  10177.             if(attemptCounter >= 1000)
  10178.                 break;
  10179.                
  10180.             if(itemLevel != desiredLevel)
  10181.                 inv.RemoveItem(ids[0]);
  10182.         }
  10183.     }
  10184.    
  10185.     public final function AddAnItemWithMinQuality(itemName : name, minQuality : int, optional equip : bool)
  10186.     {
  10187.         var quality : int;
  10188.         var ids : array<SItemUniqueId>;
  10189.         var attemptCounter : int;
  10190.  
  10191.         quality = 0;
  10192.         while(quality < minQuality)
  10193.         {
  10194.             attemptCounter += 1;
  10195.             ids.Clear();
  10196.             ids = inv.AddAnItem(itemName, 1, true);
  10197.             quality = RoundMath(CalculateAttributeValue(inv.GetItemAttributeValue(ids[0], 'quality')));
  10198.            
  10199.            
  10200.             if(attemptCounter >= 1000)
  10201.                 break;
  10202.                
  10203.             if(quality < minQuality)
  10204.                 inv.RemoveItem(ids[0]);
  10205.         }
  10206.        
  10207.         if(equip)
  10208.             EquipItem(ids[0]);
  10209.     }
  10210.    
  10211.    
  10212.    
  10213.    
  10214.    
  10215.    
  10216.     public function IsSetBonusActive( bonus : EItemSetBonus ) : bool
  10217.     {
  10218.         switch(bonus)
  10219.         {
  10220.             case EISB_Lynx_1:           return amountOfSetPiecesEquipped[ EIST_Lynx ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS;
  10221.             case EISB_Lynx_2:           return amountOfSetPiecesEquipped[ EIST_Lynx ] >= theGame.params.ITEMS_REQUIRED_FOR_MAJOR_SET_BONUS;
  10222.             case EISB_Gryphon_1:        return amountOfSetPiecesEquipped[ EIST_Gryphon ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS;
  10223.             case EISB_Gryphon_2:        return amountOfSetPiecesEquipped[ EIST_Gryphon ] >= theGame.params.ITEMS_REQUIRED_FOR_MAJOR_SET_BONUS;
  10224.             case EISB_Bear_1:           return amountOfSetPiecesEquipped[ EIST_Bear ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS;
  10225.             case EISB_Bear_2:           return amountOfSetPiecesEquipped[ EIST_Bear ] >= theGame.params.ITEMS_REQUIRED_FOR_MAJOR_SET_BONUS;
  10226.             case EISB_Wolf_1:           return amountOfSetPiecesEquipped[ EIST_Wolf ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS;
  10227.             case EISB_Wolf_2:           return amountOfSetPiecesEquipped[ EIST_Wolf ] >= theGame.params.ITEMS_REQUIRED_FOR_MAJOR_SET_BONUS;
  10228.             case EISB_RedWolf_1:        return amountOfSetPiecesEquipped[ EIST_RedWolf ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS;
  10229.             case EISB_RedWolf_2:        return amountOfSetPiecesEquipped[ EIST_RedWolf ] >= theGame.params.ITEMS_REQUIRED_FOR_MAJOR_SET_BONUS;
  10230.             case EISB_Vampire:          return amountOfSetPiecesEquipped[ EIST_Vampire ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS;
  10231.             case EISB_Netflix_1:        return amountOfSetPiecesEquipped[ EIST_Netflix ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS;
  10232.             case EISB_Netflix_2:        return amountOfSetPiecesEquipped[ EIST_Netflix ] >= theGame.params.ITEMS_REQUIRED_FOR_MAJOR_SET_BONUS;
  10233.             default:                    return false;
  10234.         }
  10235.     }
  10236.    
  10237.     public function GetSetPartsEquipped( setType : EItemSetType ) : int
  10238.     {
  10239.         return amountOfSetPiecesEquipped[ setType ];
  10240.     }
  10241.    
  10242.     protected function UpdateItemSetBonuses( item : SItemUniqueId, increment : bool )
  10243.     {
  10244.         var setType : EItemSetType;
  10245.         var tutorialStateSets : W3TutorialManagerUIHandlerStateSetItemsUnlocked;
  10246.         var id : SItemUniqueId;
  10247.                    
  10248.         if( !inv.IsIdValid( item ) || !inv.ItemHasTag(item, theGame.params.ITEM_SET_TAG_BONUS ) )  
  10249.         {
  10250.            
  10251.            
  10252.            
  10253.            
  10254.             return;
  10255.         }
  10256.        
  10257.         setType = CheckSetType( item );
  10258.        
  10259.         if( increment )
  10260.         {
  10261.             amountOfSetPiecesEquipped[ setType ] += 1;
  10262.            
  10263.             if( amountOfSetPiecesEquipped[ setType ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS && ShouldProcessTutorial( 'TutorialSetBonusesUnlocked' ) && theGame.GetTutorialSystem().uiHandler && theGame.GetTutorialSystem().uiHandler.GetCurrentStateName() == 'SetItemsUnlocked' )
  10264.             {
  10265.                 tutorialStateSets = ( W3TutorialManagerUIHandlerStateSetItemsUnlocked )theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  10266.                 tutorialStateSets.OnSetBonusCompleted();
  10267.             }
  10268.         }
  10269.         else if( amountOfSetPiecesEquipped[ setType ] > 0 )
  10270.         {
  10271.             amountOfSetPiecesEquipped[ setType ] -= 1;
  10272.         }
  10273.        
  10274.        
  10275.         if( setType != EIST_Vampire )
  10276.         {
  10277.             if(amountOfSetPiecesEquipped[ setType ] == theGame.params.ITEMS_REQUIRED_FOR_MAJOR_SET_BONUS)
  10278.             {
  10279.                 theGame.GetGamerProfile().AddAchievement( EA_ReadyToRoll );
  10280.             }
  10281.             else
  10282.             {
  10283.                 theGame.GetGamerProfile().NoticeAchievementProgress( EA_ReadyToRoll, amountOfSetPiecesEquipped[ setType ]);
  10284.             }
  10285.         }
  10286.        
  10287.        
  10288.        
  10289.        
  10290.        
  10291.        
  10292.         ManageActiveSetBonuses( setType );
  10293.        
  10294.        
  10295.         ManageSetBonusesSoundbanks( setType );
  10296.     }
  10297.    
  10298.     public function ManageActiveSetBonuses( setType : EItemSetType )
  10299.     {
  10300.         var l_i             : int;
  10301.        
  10302.        
  10303.         if( setType == EIST_Lynx )
  10304.         {
  10305.            
  10306.             if( HasBuff( EET_LynxSetBonus ) && !IsSetBonusActive( EISB_Lynx_1 ) )
  10307.             {
  10308.                 RemoveBuff( EET_LynxSetBonus );
  10309.             }
  10310.         }
  10311.        
  10312.         else if( setType == EIST_Gryphon )
  10313.         {
  10314.            
  10315.             if( !IsSetBonusActive( EISB_Gryphon_1 ) )
  10316.             {
  10317.                 RemoveBuff( EET_GryphonSetBonus );
  10318.             }
  10319.            
  10320.             if( IsSetBonusActive( EISB_Gryphon_2 ) && !HasBuff( EET_GryphonSetBonusYrden ) )
  10321.             {
  10322.                 for( l_i = 0 ; l_i < yrdenEntities.Size() ; l_i += 1 )
  10323.                 {
  10324.                     if( yrdenEntities[ l_i ].GetIsPlayerInside() && !yrdenEntities[ l_i ].IsAlternateCast() )
  10325.                     {
  10326.                         AddEffectDefault( EET_GryphonSetBonusYrden, this, "GryphonSetBonusYrden" );
  10327.                         break;
  10328.                     }
  10329.                 }
  10330.             }
  10331.             else
  10332.             {
  10333.                 RemoveBuff( EET_GryphonSetBonusYrden );
  10334.             }
  10335.         }
  10336.     }
  10337.    
  10338.     public function CheckSetTypeByName( itemName : name ) : EItemSetType
  10339.     {
  10340.         var dm : CDefinitionsManagerAccessor;
  10341.        
  10342.         dm = theGame.GetDefinitionsManager();
  10343.        
  10344.         if( dm.ItemHasTag( itemName, theGame.params.ITEM_SET_TAG_LYNX ) )
  10345.         {
  10346.             return EIST_Lynx;
  10347.         }
  10348.         else
  10349.         if( dm.ItemHasTag( itemName, theGame.params.ITEM_SET_TAG_GRYPHON ) )
  10350.         {
  10351.             return EIST_Gryphon;
  10352.         }
  10353.         else
  10354.         if( dm.ItemHasTag( itemName, theGame.params.ITEM_SET_TAG_BEAR ) )
  10355.         {
  10356.             return EIST_Bear;
  10357.         }
  10358.         else
  10359.         if( dm.ItemHasTag( itemName, theGame.params.ITEM_SET_TAG_WOLF ) )
  10360.         {
  10361.             return EIST_Wolf;
  10362.         }
  10363.         else
  10364.         if( dm.ItemHasTag( itemName, theGame.params.ITEM_SET_TAG_RED_WOLF ) )
  10365.         {
  10366.             return EIST_RedWolf;
  10367.         }
  10368.         else
  10369.         if( dm.ItemHasTag( itemName, theGame.params.ITEM_SET_TAG_VAMPIRE ) )
  10370.         {
  10371.             return EIST_Vampire;
  10372.         }
  10373.         else
  10374.         if( dm.ItemHasTag( itemName, theGame.params.ITEM_SET_TAG_VIPER ) )
  10375.         {
  10376.             return EIST_Viper;
  10377.         }
  10378.         else
  10379.         if( dm.ItemHasTag( itemName, theGame.params.ITEM_SET_TAG_NETFLIX ) )
  10380.         {
  10381.             return EIST_Netflix;
  10382.         }
  10383.         else
  10384.         {
  10385.             return EIST_Undefined;
  10386.         }
  10387.     }
  10388.    
  10389.     public function CheckSetType( item : SItemUniqueId ) : EItemSetType
  10390.     {
  10391.         var stopLoop    : bool;
  10392.         var tags        : array<name>;
  10393.         var i           : int;
  10394.         var setType     : EItemSetType;
  10395.        
  10396.         stopLoop = false;
  10397.        
  10398.         inv.GetItemTags( item, tags );
  10399.        
  10400.        
  10401.         for( i=0; i<tags.Size(); i+=1 )
  10402.         {
  10403.             switch( tags[i] )
  10404.             {
  10405.                 case theGame.params.ITEM_SET_TAG_LYNX:
  10406.                 case theGame.params.ITEM_SET_TAG_GRYPHON:
  10407.                 case theGame.params.ITEM_SET_TAG_BEAR:
  10408.                 case theGame.params.ITEM_SET_TAG_WOLF:
  10409.                 case theGame.params.ITEM_SET_TAG_RED_WOLF:
  10410.                 case theGame.params.ITEM_SET_TAG_VAMPIRE:
  10411.                 case theGame.params.ITEM_SET_TAG_VIPER:
  10412.                 case theGame.params.ITEM_SET_TAG_NETFLIX:
  10413.                     setType = SetItemNameToType( tags[i] );
  10414.                     stopLoop = true;
  10415.                     break;
  10416.             }      
  10417.             if ( stopLoop )
  10418.             {
  10419.                 break;
  10420.             }
  10421.         }
  10422.        
  10423.         return setType;
  10424.     }
  10425.    
  10426.     public function GetSetBonusStatusByName( itemName : name, out desc1, desc2 : string, out isActive1, isActive2 : bool ) : EItemSetType
  10427.     {
  10428.         var setType : EItemSetType;
  10429.        
  10430.         if( theGame.GetDLCManager().IsEP2Enabled() )
  10431.         {
  10432.             setType = CheckSetTypeByName( itemName );
  10433.             SetBonusStatusByType( setType, desc1, desc2, isActive1, isActive2 );
  10434.            
  10435.             return setType;    
  10436.         }
  10437.         else
  10438.         {
  10439.             return EIST_Undefined;
  10440.         }
  10441.     }
  10442.    
  10443.     public function GetSetBonusStatus( item : SItemUniqueId, out desc1, desc2 : string, out isActive1, isActive2 : bool ) : EItemSetType
  10444.     {
  10445.         var setType : EItemSetType;
  10446.        
  10447.         if( theGame.GetDLCManager().IsEP2Enabled() )
  10448.         {
  10449.             setType = CheckSetType( item );
  10450.             SetBonusStatusByType( setType, desc1, desc2, isActive1, isActive2 );
  10451.            
  10452.             return setType;
  10453.         }
  10454.         else
  10455.         {
  10456.             return EIST_Undefined;
  10457.         }
  10458.     }
  10459.    
  10460.     private function SetBonusStatusByType(setType : EItemSetType, out desc1, desc2 : string, out isActive1, isActive2 : bool):void
  10461.     {
  10462.         var setBonus : EItemSetBonus;
  10463.        
  10464.         if( amountOfSetPiecesEquipped[ setType ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS )
  10465.         {
  10466.             isActive1 = true;          
  10467.         }
  10468.        
  10469.         if( amountOfSetPiecesEquipped[ setType ] >= theGame.params.ITEMS_REQUIRED_FOR_MAJOR_SET_BONUS )
  10470.         {
  10471.             isActive2 = true;
  10472.         }
  10473.        
  10474.         setBonus = ItemSetTypeToItemSetBonus( setType, 1 );
  10475.         desc1 = GetSetBonusTooltipDescription( setBonus );
  10476.        
  10477.         setBonus = ItemSetTypeToItemSetBonus( setType, 2 );
  10478.         desc2 = GetSetBonusTooltipDescription( setBonus );
  10479.     }
  10480.    
  10481.     public function ItemSetTypeToItemSetBonus( setType : EItemSetType, nr : int ) : EItemSetBonus
  10482.     {
  10483.         var setBonus : EItemSetBonus;
  10484.    
  10485.         if( nr == 1 )
  10486.         {
  10487.             switch( setType )
  10488.             {
  10489.                 case EIST_Lynx:             setBonus = EISB_Lynx_1;     break;
  10490.                 case EIST_Gryphon:          setBonus = EISB_Gryphon_1;  break;
  10491.                 case EIST_Bear:             setBonus = EISB_Bear_1;     break;
  10492.                 case EIST_Wolf:             setBonus = EISB_Wolf_1;     break;
  10493.                 case EIST_RedWolf:          setBonus = EISB_RedWolf_1;  break;
  10494.                 case EIST_Vampire:          setBonus = EISB_Vampire;    break;
  10495.                 case EIST_Netflix:          setBonus = EISB_Netflix_1;  break;
  10496.             }
  10497.         }
  10498.         else
  10499.         {
  10500.             switch( setType )
  10501.             {
  10502.                 case EIST_Lynx:             setBonus = EISB_Lynx_2;     break;
  10503.                 case EIST_Gryphon:          setBonus = EISB_Gryphon_2;  break;
  10504.                 case EIST_Bear:             setBonus = EISB_Bear_2;     break;
  10505.                 case EIST_Wolf:             setBonus = EISB_Wolf_2;     break;
  10506.                 case EIST_RedWolf:          setBonus = EISB_RedWolf_2;  break;
  10507.                 case EIST_Vampire:          setBonus = EISB_Undefined;  break;
  10508.                 case EIST_Netflix:          setBonus = EISB_Netflix_2;  break;
  10509.             }
  10510.         }
  10511.    
  10512.         return setBonus;
  10513.     }
  10514.    
  10515.     public function GetSetBonusTooltipDescription( bonus : EItemSetBonus ) : string
  10516.     {
  10517.         var finalString : string;
  10518.         var arrString   : array<string>;
  10519.         var dm          : CDefinitionsManagerAccessor;
  10520.         var min, max    : SAbilityAttributeValue;
  10521.         var tempString  : string;
  10522.        
  10523.         switch( bonus )
  10524.         {
  10525.             case EISB_Lynx_1:           tempString = "skill_desc_lynx_set_ability1"; break;
  10526.             case EISB_Lynx_2:           tempString = "skill_desc_lynx_set_ability2"; break;
  10527.             case EISB_Gryphon_1:        tempString = "skill_desc_gryphon_set_ability1"; break;
  10528.             case EISB_Gryphon_2:        tempString = "skill_desc_gryphon_set_ability2"; break;
  10529.             case EISB_Bear_1:           tempString = "skill_desc_bear_set_ability1"; break;
  10530.             case EISB_Bear_2:           tempString = "skill_desc_bear_set_ability2"; break;
  10531.             case EISB_Wolf_1:           tempString = "skill_desc_wolf_set_ability2"; break;
  10532.             case EISB_Wolf_2:           tempString = "skill_desc_wolf_set_ability1"; break;
  10533.             case EISB_RedWolf_1:        tempString = "skill_desc_red_wolf_set_ability1"; break;
  10534.             case EISB_RedWolf_2:        tempString = "skill_desc_red_wolf_set_ability2"; break;
  10535.             case EISB_Vampire:          tempString = "skill_desc_vampire_set_ability1"; break;
  10536.             case EISB_Netflix_1:        tempString = "skill_desc_netflix_set_ability1"; break;
  10537.             case EISB_Netflix_2:        tempString = "skill_desc_netflix_set_ability2"; break;
  10538.             default:                    tempString = ""; break;
  10539.         }
  10540.        
  10541.         dm = theGame.GetDefinitionsManager();
  10542.        
  10543.         switch( bonus )
  10544.         {
  10545.         case EISB_Lynx_1:
  10546.             dm.GetAbilityAttributeValue( 'LynxSetBonusEffect', 'duration', min, max );
  10547.             arrString.PushBack( FloatToString( min.valueAdditive ) );
  10548.             dm.GetAbilityAttributeValue( 'LynxSetBonusEffect', 'lynx_dmg_boost', min, max );
  10549.             arrString.PushBack( FloatToString( min.valueAdditive * 100 ) );
  10550.             arrString.PushBack( FloatToString( min.valueAdditive * 100 * amountOfSetPiecesEquipped[ EIST_Lynx ] ) );
  10551.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10552.             break;
  10553.         case EISB_Lynx_2:
  10554.             dm.GetAbilityAttributeValue( GetSetBonusAbility( EISB_Lynx_2 ), 'lynx_2_dmg_boost', min, max );
  10555.             arrString.PushBack( FloatToString( min.valueAdditive * 100 ) );
  10556.            
  10557.             dm.GetAbilityAttributeValue( GetSetBonusAbility( EISB_Lynx_2 ), 'lynx_2_adrenaline_cost', min, max );
  10558.             arrString.PushBack( FloatToString( min.valueAdditive ) );
  10559.            
  10560.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10561.             break;
  10562.         case EISB_Gryphon_1:
  10563.             dm.GetAbilityAttributeValue( 'GryphonSetBonusEffect', 'duration', min, max );
  10564.             arrString.PushBack( FloatToString( min.valueAdditive ) );
  10565.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10566.             break;     
  10567.         case EISB_Gryphon_2:
  10568.             dm.GetAbilityAttributeValue( 'GryphonSetBonusYrdenEffect', 'trigger_scale', min, max );
  10569.             arrString.PushBack( FloatToString( ( min.valueAdditive - 1 )* 100) );
  10570.             dm.GetAbilityAttributeValue( 'GryphonSetBonusYrdenEffect', 'staminaRegen', min, max );
  10571.             arrString.PushBack( FloatToString( min.valueMultiplicative * 100) );
  10572.             dm.GetAbilityAttributeValue( 'GryphonSetBonusYrdenEffect', 'spell_power', min, max );
  10573.             arrString.PushBack( FloatToString( min.valueMultiplicative * 100) );
  10574.             dm.GetAbilityAttributeValue( 'GryphonSetBonusYrdenEffect', 'gryphon_set_bns_dmg_reduction', min, max );
  10575.             arrString.PushBack( FloatToString( min.valueAdditive * 100) );
  10576.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10577.             break;
  10578.         case EISB_Bear_1:
  10579.             dm.GetAbilityAttributeValue( 'setBonusAbilityBear_1', 'quen_reapply_chance', min, max );
  10580.             arrString.PushBack( FloatToString( min.valueMultiplicative * 100 ) );
  10581.            
  10582.             arrString.PushBack( FloatToString( min.valueMultiplicative * 100 * amountOfSetPiecesEquipped[ EIST_Bear ] ) );
  10583.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10584.             break;
  10585.         case EISB_Bear_2:
  10586.             dm.GetAbilityAttributeValue( 'setBonusAbilityBear_2', 'quen_dmg_boost', min, max );
  10587.             arrString.PushBack( FloatToString( min.valueMultiplicative * 100 ) );
  10588.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10589.             break;
  10590.         case EISB_RedWolf_2:
  10591.             dm.GetAbilityAttributeValue( 'setBonusAbilityRedWolf_2', 'amount', min, max );
  10592.             arrString.PushBack( FloatToString( min.valueAdditive ) );
  10593.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10594.             break;
  10595.         case EISB_Vampire:
  10596.             dm.GetAbilityAttributeValue( 'setBonusAbilityVampire', 'life_percent', min, max );
  10597.             arrString.PushBack( FloatToString( min.valueAdditive ) );
  10598.             arrString.PushBack( FloatToString( min.valueAdditive * amountOfSetPiecesEquipped[ EIST_Vampire ] ) );
  10599.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10600.             break;
  10601.        
  10602.         case EISB_Wolf_1:
  10603.             arrString.PushBack( FloatToString( 1 * amountOfSetPiecesEquipped[ EIST_Wolf ] ) );
  10604.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10605.             break;
  10606.        
  10607.         default:
  10608.             finalString = GetLocStringByKeyExtWithParams( tempString );
  10609.         }
  10610.        
  10611.         return finalString;
  10612.     }
  10613.    
  10614.     public function ManageSetBonusesSoundbanks( setType : EItemSetType )
  10615.     {
  10616.         if( amountOfSetPiecesEquipped[ setType ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS )
  10617.         {
  10618.             switch( setType )
  10619.             {
  10620.                 case EIST_Lynx:
  10621.                     LoadSetBonusSoundBank( "ep2_setbonus_lynx.bnk" );
  10622.                     break;
  10623.                 case EIST_Gryphon:
  10624.                     LoadSetBonusSoundBank( "ep2_setbonus_gryphon.bnk" );
  10625.                     break;
  10626.                 case EIST_Bear:
  10627.                     LoadSetBonusSoundBank( "ep2_setbonus_bear.bnk" );
  10628.                     break;
  10629.             }
  10630.         }
  10631.         else
  10632.         {
  10633.             switch( setType )
  10634.             {
  10635.                 case EIST_Lynx:
  10636.                     UnloadSetBonusSoundBank( "ep2_setbonus_lynx.bnk" );
  10637.                     break;
  10638.                 case EIST_Gryphon:
  10639.                     UnloadSetBonusSoundBank( "ep2_setbonus_gryphon.bnk" );
  10640.                     break;
  10641.                 case EIST_Bear:
  10642.                     UnloadSetBonusSoundBank( "ep2_setbonus_bear.bnk" );
  10643.                     break;
  10644.             }
  10645.         }
  10646.     }
  10647.    
  10648.     public function VampiricSetAbilityRegeneration()
  10649.     {
  10650.         var healthMax       : float;
  10651.         var healthToReg     : float;
  10652.        
  10653.         healthMax = GetStatMax( BCS_Vitality );
  10654.        
  10655.         healthToReg = ( amountOfSetPiecesEquipped[ EIST_Vampire ] * healthMax ) / 100;
  10656.        
  10657.         PlayEffect('drain_energy_caretaker_shovel');
  10658.         GainStat( BCS_Vitality, healthToReg );
  10659.     }
  10660.    
  10661.     private function LoadSetBonusSoundBank( bankName : string )
  10662.     {
  10663.         if( !theSound.SoundIsBankLoaded( bankName ) )
  10664.         {
  10665.             theSound.SoundLoadBank( bankName, true );
  10666.         }
  10667.     }
  10668.    
  10669.     private function UnloadSetBonusSoundBank( bankName : string )
  10670.     {
  10671.         if( theSound.SoundIsBankLoaded( bankName ) )
  10672.         {
  10673.             theSound.SoundUnloadBank( bankName );
  10674.         }
  10675.     }
  10676.    
  10677.     timer function BearSetBonusQuenReapply( dt : float, id : int )
  10678.     {
  10679.         var newQuen     : W3QuenEntity;
  10680.        
  10681.         newQuen = (W3QuenEntity)theGame.CreateEntity( GetSignTemplate( ST_Quen ), GetWorldPosition(), GetWorldRotation() );
  10682.         newQuen.Init( signOwner, GetSignEntity( ST_Quen ), true );
  10683.         newQuen.freeFromBearSetBonus = true;
  10684.         newQuen.OnStarted();
  10685.         newQuen.OnThrowing();
  10686.         newQuen.OnEnded();
  10687.        
  10688.         m_quenReappliedCount += 1;
  10689.        
  10690.         RemoveTimer( 'BearSetBonusQuenReapply');
  10691.     }
  10692.    
  10693.     public final function StandaloneEp1_1()
  10694.     {
  10695.         var i, inc, quantityLow, randLow, quantityMedium, randMedium, quantityHigh, randHigh, startingMoney : int;
  10696.         var pam : W3PlayerAbilityManager;
  10697.         var ids : array<SItemUniqueId>;
  10698.         var STARTING_LEVEL : int;
  10699.        
  10700.         FactsAdd("StandAloneEP1", 1);
  10701.        
  10702.        
  10703.         inv.RemoveAllItems();
  10704.        
  10705.        
  10706.         inv.AddAnItem('Illusion Medallion', 1, true, true, false);
  10707.         inv.AddAnItem('q103_safe_conduct', 1, true, true, false);
  10708.        
  10709.        
  10710.         theGame.GetGamerProfile().ClearAllAchievementsForEP1();
  10711.        
  10712.        
  10713.         STARTING_LEVEL = 32;
  10714.         inc = STARTING_LEVEL - GetLevel();
  10715.         for(i=0; i<inc; i+=1)
  10716.         {
  10717.             levelManager.AddPoints(EExperiencePoint, levelManager.GetTotalExpForNextLevel() - levelManager.GetPointsTotal(EExperiencePoint), false);
  10718.         }
  10719.        
  10720.        
  10721.         levelManager.ResetCharacterDev();
  10722.         pam = (W3PlayerAbilityManager)abilityManager;
  10723.         if(pam)
  10724.         {
  10725.             pam.ResetCharacterDev();
  10726.         }
  10727.         levelManager.SetFreeSkillPoints(levelManager.GetLevel() - 1 + 11); 
  10728.        
  10729.        
  10730.         inv.AddAnItem('Mutagen red', 4);
  10731.         inv.AddAnItem('Mutagen green', 4);
  10732.         inv.AddAnItem('Mutagen blue', 4);
  10733.         inv.AddAnItem('Lesser mutagen red', 2);
  10734.         inv.AddAnItem('Lesser mutagen green', 2);
  10735.         inv.AddAnItem('Lesser mutagen blue', 2);
  10736.         inv.AddAnItem('Greater mutagen green', 1);
  10737.         inv.AddAnItem('Greater mutagen blue', 2);
  10738.        
  10739.        
  10740.         startingMoney = 40000;
  10741.         if(GetMoney() > startingMoney)
  10742.         {
  10743.             RemoveMoney(GetMoney() - startingMoney);
  10744.         }
  10745.         else
  10746.         {
  10747.             AddMoney( 40000 - GetMoney() );
  10748.         }
  10749.        
  10750.        
  10751.        
  10752.        
  10753.        
  10754.         ids.Clear();
  10755.         ids = inv.AddAnItem('EP1 Standalone Starting Armor');
  10756.         EquipItem(ids[0]);
  10757.         ids.Clear();
  10758.         ids = inv.AddAnItem('EP1 Standalone Starting Boots');
  10759.         EquipItem(ids[0]);
  10760.         ids.Clear();
  10761.         ids = inv.AddAnItem('EP1 Standalone Starting Gloves');
  10762.         EquipItem(ids[0]);
  10763.         ids.Clear();
  10764.         ids = inv.AddAnItem('EP1 Standalone Starting Pants');
  10765.         EquipItem(ids[0]);
  10766.        
  10767.        
  10768.         ids.Clear();
  10769.         ids = inv.AddAnItem('EP1 Standalone Starting Steel Sword');
  10770.         EquipItem(ids[0]);
  10771.         ids.Clear();
  10772.         ids = inv.AddAnItem('EP1 Standalone Starting Silver Sword');
  10773.         EquipItem(ids[0]);
  10774.        
  10775.        
  10776.         inv.AddAnItem('Torch', 1, true, true, false);
  10777.        
  10778.        
  10779.         quantityLow = 1;
  10780.         randLow = 3;
  10781.         quantityMedium = 4;
  10782.         randMedium = 4;
  10783.         quantityHigh = 8;
  10784.         randHigh = 6;
  10785.        
  10786.         inv.AddAnItem('Alghoul bone marrow',quantityMedium+RandRange(randMedium));
  10787.         inv.AddAnItem('Amethyst dust',quantityLow+RandRange(randLow));
  10788.         inv.AddAnItem('Arachas eyes',quantityLow+RandRange(randLow));
  10789.         inv.AddAnItem('Arachas venom',quantityLow+RandRange(randLow));
  10790.         inv.AddAnItem('Basilisk hide',quantityLow+RandRange(randLow));
  10791.         inv.AddAnItem('Basilisk venom',quantityLow+RandRange(randLow));
  10792.         inv.AddAnItem('Bear pelt',quantityHigh+RandRange(randHigh));
  10793.         inv.AddAnItem('Berserker pelt',quantityLow+RandRange(randLow));
  10794.         inv.AddAnItem('Coal',quantityHigh+RandRange(randHigh));
  10795.         inv.AddAnItem('Cotton',quantityHigh+RandRange(randHigh));
  10796.         inv.AddAnItem('Dark iron ingot',quantityLow+RandRange(randLow));
  10797.         inv.AddAnItem('Dark iron ore',quantityLow+RandRange(randLow));
  10798.         inv.AddAnItem('Deer hide',quantityHigh+RandRange(randHigh));
  10799.         inv.AddAnItem('Diamond dust',quantityLow+RandRange(randLow));
  10800.         inv.AddAnItem('Draconide leather',quantityLow+RandRange(randLow));
  10801.         inv.AddAnItem('Drowned dead tongue',quantityLow+RandRange(randLow));
  10802.         inv.AddAnItem('Drowner brain',quantityMedium+RandRange(randMedium));
  10803.         inv.AddAnItem('Dwimeryte ingot',quantityLow+RandRange(randLow));
  10804.         inv.AddAnItem('Dwimeryte ore',quantityLow+RandRange(randLow));
  10805.         inv.AddAnItem('Emerald dust',quantityLow+RandRange(randLow));
  10806.         inv.AddAnItem('Endriag chitin plates',quantityMedium+RandRange(randMedium));
  10807.         inv.AddAnItem('Endriag embryo',quantityLow+RandRange(randLow));
  10808.         inv.AddAnItem('Ghoul blood',quantityMedium+RandRange(randMedium));
  10809.         inv.AddAnItem('Goat hide',quantityMedium+RandRange(randMedium));
  10810.         inv.AddAnItem('Hag teeth',quantityMedium+RandRange(randMedium));
  10811.         inv.AddAnItem('Hardened leather',quantityMedium+RandRange(randMedium));
  10812.         inv.AddAnItem('Hardened timber',quantityMedium+RandRange(randMedium));
  10813.         inv.AddAnItem('Harpy feathers',quantityMedium+RandRange(randMedium));
  10814.         inv.AddAnItem('Horse hide',quantityLow+RandRange(randLow));
  10815.         inv.AddAnItem('Iron ore',quantityHigh+RandRange(randHigh));
  10816.         inv.AddAnItem('Leather straps',quantityHigh+RandRange(randHigh));
  10817.         inv.AddAnItem('Leather',quantityHigh+RandRange(randHigh));
  10818.         inv.AddAnItem('Linen',quantityMedium+RandRange(randMedium));
  10819.         inv.AddAnItem('Meteorite ingot',quantityLow+RandRange(randLow));
  10820.         inv.AddAnItem('Meteorite ore',quantityMedium+RandRange(randMedium));
  10821.         inv.AddAnItem('Necrophage skin',quantityLow+RandRange(randLow));
  10822.         inv.AddAnItem('Nekker blood',quantityHigh+RandRange(randHigh));
  10823.         inv.AddAnItem('Nekker heart',quantityMedium+RandRange(randMedium));
  10824.         inv.AddAnItem('Oil',quantityHigh+RandRange(randHigh));
  10825.         inv.AddAnItem('Phosphorescent crystal',quantityLow+RandRange(randLow));
  10826.         inv.AddAnItem('Pig hide',quantityMedium+RandRange(randMedium));
  10827.         inv.AddAnItem('Pure silver',quantityMedium+RandRange(randMedium));
  10828.         inv.AddAnItem('Rabbit pelt',quantityMedium+RandRange(randMedium));
  10829.         inv.AddAnItem('Rotfiend blood',quantityMedium+RandRange(randMedium));
  10830.         inv.AddAnItem('Sapphire dust',quantityLow+RandRange(randLow));
  10831.         inv.AddAnItem('Silk',quantityHigh+RandRange(randHigh));
  10832.         inv.AddAnItem('Silver ingot',quantityMedium+RandRange(randMedium));
  10833.         inv.AddAnItem('Silver ore',quantityHigh+RandRange(randHigh));
  10834.         inv.AddAnItem('Specter dust',quantityMedium+RandRange(randMedium));
  10835.         inv.AddAnItem('Steel ingot',quantityHigh+RandRange(randHigh));
  10836.         inv.AddAnItem('Steel plate',quantityHigh+RandRange(randHigh));
  10837.         inv.AddAnItem('String',quantityHigh+RandRange(randHigh));
  10838.         inv.AddAnItem('Thread',quantityHigh+RandRange(randHigh));
  10839.         inv.AddAnItem('Timber',quantityHigh+RandRange(randHigh));
  10840.         inv.AddAnItem('Twine',quantityMedium+RandRange(randMedium));
  10841.         inv.AddAnItem('Venom extract',quantityMedium+RandRange(randMedium));
  10842.         inv.AddAnItem('Water essence',quantityMedium+RandRange(randMedium));
  10843.         inv.AddAnItem('Wolf liver',quantityHigh+RandRange(randHigh));
  10844.         inv.AddAnItem('Wolf pelt',quantityMedium+RandRange(randMedium));
  10845.        
  10846.         inv.AddAnItem('Alcohest', 5);
  10847.         inv.AddAnItem('Dwarven spirit', 5);
  10848.    
  10849.        
  10850.         ids.Clear();
  10851.         ids = inv.AddAnItem('Crossbow 5');
  10852.         EquipItem(ids[0]);
  10853.         ids.Clear();
  10854.         ids = inv.AddAnItem('Blunt Bolt', 100);
  10855.         EquipItem(ids[0]);
  10856.         inv.AddAnItem('Broadhead Bolt', 100);
  10857.         inv.AddAnItem('Split Bolt', 100);
  10858.        
  10859.        
  10860.         RemoveAllAlchemyRecipes();
  10861.         RemoveAllCraftingSchematics();
  10862.        
  10863.        
  10864.        
  10865.        
  10866.         AddAlchemyRecipe('Recipe for Cat 1');
  10867.        
  10868.        
  10869.        
  10870.         AddAlchemyRecipe('Recipe for Maribor Forest 1');
  10871.         AddAlchemyRecipe('Recipe for Petris Philtre 1');
  10872.         AddAlchemyRecipe('Recipe for Swallow 1');
  10873.         AddAlchemyRecipe('Recipe for Tawny Owl 1');
  10874.        
  10875.         AddAlchemyRecipe('Recipe for White Gull 1');
  10876.         AddAlchemyRecipe('Recipe for White Honey 1');
  10877.         AddAlchemyRecipe('Recipe for White Raffards Decoction 1');
  10878.        
  10879.        
  10880.        
  10881.         AddAlchemyRecipe('Recipe for Beast Oil 1');
  10882.         AddAlchemyRecipe('Recipe for Cursed Oil 1');
  10883.         AddAlchemyRecipe('Recipe for Hanged Man Venom 1');
  10884.         AddAlchemyRecipe('Recipe for Hybrid Oil 1');
  10885.         AddAlchemyRecipe('Recipe for Insectoid Oil 1');
  10886.         AddAlchemyRecipe('Recipe for Magicals Oil 1');
  10887.         AddAlchemyRecipe('Recipe for Necrophage Oil 1');
  10888.         AddAlchemyRecipe('Recipe for Specter Oil 1');
  10889.         AddAlchemyRecipe('Recipe for Vampire Oil 1');
  10890.         AddAlchemyRecipe('Recipe for Draconide Oil 1');
  10891.         AddAlchemyRecipe('Recipe for Ogre Oil 1');
  10892.         AddAlchemyRecipe('Recipe for Relic Oil 1');
  10893.         AddAlchemyRecipe('Recipe for Beast Oil 2');
  10894.         AddAlchemyRecipe('Recipe for Cursed Oil 2');
  10895.         AddAlchemyRecipe('Recipe for Hanged Man Venom 2');
  10896.         AddAlchemyRecipe('Recipe for Hybrid Oil 2');
  10897.         AddAlchemyRecipe('Recipe for Insectoid Oil 2');
  10898.         AddAlchemyRecipe('Recipe for Magicals Oil 2');
  10899.         AddAlchemyRecipe('Recipe for Necrophage Oil 2');
  10900.         AddAlchemyRecipe('Recipe for Specter Oil 2');
  10901.         AddAlchemyRecipe('Recipe for Vampire Oil 2');
  10902.         AddAlchemyRecipe('Recipe for Draconide Oil 2');
  10903.         AddAlchemyRecipe('Recipe for Ogre Oil 2');
  10904.         AddAlchemyRecipe('Recipe for Relic Oil 2');
  10905.        
  10906.        
  10907.         AddAlchemyRecipe('Recipe for Dancing Star 1');
  10908.        
  10909.         AddAlchemyRecipe('Recipe for Dwimeritum Bomb 1');
  10910.        
  10911.         AddAlchemyRecipe('Recipe for Grapeshot 1');
  10912.         AddAlchemyRecipe('Recipe for Samum 1');
  10913.        
  10914.         AddAlchemyRecipe('Recipe for White Frost 1');
  10915.        
  10916.        
  10917.        
  10918.         AddAlchemyRecipe('Recipe for Dwarven spirit 1');
  10919.         AddAlchemyRecipe('Recipe for Alcohest 1');
  10920.         AddAlchemyRecipe('Recipe for White Gull 1');
  10921.        
  10922.        
  10923.         AddStartingSchematics();
  10924.        
  10925.        
  10926.         ids.Clear();
  10927.         ids = inv.AddAnItem('Swallow 2');
  10928.         EquipItem(ids[0]);
  10929.         ids.Clear();
  10930.         ids = inv.AddAnItem('Thunderbolt 2');
  10931.         EquipItem(ids[0]);
  10932.         ids.Clear();
  10933.         ids = inv.AddAnItem('Tawny Owl 2');
  10934.         EquipItem(ids[0]);
  10935.         ids.Clear();
  10936.        
  10937.         ids = inv.AddAnItem('Grapeshot 2');
  10938.         EquipItem(ids[0]);
  10939.         ids.Clear();
  10940.         ids = inv.AddAnItem('Samum 2');
  10941.         EquipItem(ids[0]);
  10942.        
  10943.         inv.AddAnItem('Dwimeritum Bomb 1');
  10944.         inv.AddAnItem('Dragons Dream 1');
  10945.         inv.AddAnItem('Silver Dust Bomb 1');
  10946.         inv.AddAnItem('White Frost 2');
  10947.         inv.AddAnItem('Devils Puffball 2');
  10948.         inv.AddAnItem('Dancing Star 2');
  10949.         inv.AddAnItem('Beast Oil 1');
  10950.         inv.AddAnItem('Cursed Oil 1');
  10951.         inv.AddAnItem('Hanged Man Venom 2');
  10952.         inv.AddAnItem('Hybrid Oil 1');
  10953.         inv.AddAnItem('Insectoid Oil 1');
  10954.         inv.AddAnItem('Magicals Oil 1');
  10955.         inv.AddAnItem('Necrophage Oil 2');
  10956.         inv.AddAnItem('Specter Oil 1');
  10957.         inv.AddAnItem('Vampire Oil 1');
  10958.         inv.AddAnItem('Draconide Oil 1');
  10959.         inv.AddAnItem('Relic Oil 1');
  10960.         inv.AddAnItem('Black Blood 1');
  10961.         inv.AddAnItem('Blizzard 1');
  10962.         inv.AddAnItem('Cat 2');
  10963.         inv.AddAnItem('Full Moon 1');
  10964.         inv.AddAnItem('Maribor Forest 1');
  10965.         inv.AddAnItem('Petris Philtre 1');
  10966.         inv.AddAnItem('White Gull 1', 3);
  10967.         inv.AddAnItem('White Honey 2');
  10968.         inv.AddAnItem('White Raffards Decoction 1');
  10969.        
  10970.        
  10971.         inv.AddAnItem('Mutagen 17');   
  10972.         inv.AddAnItem('Mutagen 19');   
  10973.         inv.AddAnItem('Mutagen 27');   
  10974.         inv.AddAnItem('Mutagen 26');   
  10975.        
  10976.        
  10977.         inv.AddAnItem('weapon_repair_kit_1', 5);
  10978.         inv.AddAnItem('weapon_repair_kit_2', 3);
  10979.         inv.AddAnItem('armor_repair_kit_1', 5);
  10980.         inv.AddAnItem('armor_repair_kit_2', 3);
  10981.        
  10982.        
  10983.         quantityMedium = 2;
  10984.         quantityLow = 1;
  10985.         inv.AddAnItem('Rune stribog lesser', quantityMedium);
  10986.         inv.AddAnItem('Rune stribog', quantityLow);
  10987.         inv.AddAnItem('Rune dazhbog lesser', quantityMedium);
  10988.         inv.AddAnItem('Rune dazhbog', quantityLow);
  10989.         inv.AddAnItem('Rune devana lesser', quantityMedium);
  10990.         inv.AddAnItem('Rune devana', quantityLow);
  10991.         inv.AddAnItem('Rune zoria lesser', quantityMedium);
  10992.         inv.AddAnItem('Rune zoria', quantityLow);
  10993.         inv.AddAnItem('Rune morana lesser', quantityMedium);
  10994.         inv.AddAnItem('Rune morana', quantityLow);
  10995.         inv.AddAnItem('Rune triglav lesser', quantityMedium);
  10996.         inv.AddAnItem('Rune triglav', quantityLow);
  10997.         inv.AddAnItem('Rune svarog lesser', quantityMedium);
  10998.         inv.AddAnItem('Rune svarog', quantityLow);
  10999.         inv.AddAnItem('Rune veles lesser', quantityMedium);
  11000.         inv.AddAnItem('Rune veles', quantityLow);
  11001.         inv.AddAnItem('Rune perun lesser', quantityMedium);
  11002.         inv.AddAnItem('Rune perun', quantityLow);
  11003.         inv.AddAnItem('Rune elemental lesser', quantityMedium);
  11004.         inv.AddAnItem('Rune elemental', quantityLow);
  11005.        
  11006.         inv.AddAnItem('Glyph aard lesser', quantityMedium);
  11007.         inv.AddAnItem('Glyph aard', quantityLow);
  11008.         inv.AddAnItem('Glyph axii lesser', quantityMedium);
  11009.         inv.AddAnItem('Glyph axii', quantityLow);
  11010.         inv.AddAnItem('Glyph igni lesser', quantityMedium);
  11011.         inv.AddAnItem('Glyph igni', quantityLow);
  11012.         inv.AddAnItem('Glyph quen lesser', quantityMedium);
  11013.         inv.AddAnItem('Glyph quen', quantityLow);
  11014.         inv.AddAnItem('Glyph yrden lesser', quantityMedium);
  11015.         inv.AddAnItem('Glyph yrden', quantityLow);
  11016.        
  11017.        
  11018.         StandaloneEp1_2();
  11019.     }
  11020.    
  11021.     public final function StandaloneEp1_2()
  11022.     {
  11023.         var horseId : SItemUniqueId;
  11024.         var ids : array<SItemUniqueId>;
  11025.         var ents : array< CJournalBase >;
  11026.         var i : int;
  11027.         var manager : CWitcherJournalManager;
  11028.        
  11029.        
  11030.         inv.AddAnItem( 'Cows milk', 20 );
  11031.         ids.Clear();
  11032.         ids = inv.AddAnItem( 'Dumpling', 44 );
  11033.         EquipItem(ids[0]);
  11034.        
  11035.        
  11036.         inv.AddAnItem('Clearing Potion', 2, true, false, false);
  11037.        
  11038.        
  11039.         GetHorseManager().RemoveAllItems();
  11040.        
  11041.         ids.Clear();
  11042.         ids = inv.AddAnItem('Horse Bag 2');
  11043.         horseId = GetHorseManager().MoveItemToHorse(ids[0]);
  11044.         GetHorseManager().EquipItem(horseId);
  11045.        
  11046.         ids.Clear();
  11047.         ids = inv.AddAnItem('Horse Blinder 2');
  11048.         horseId = GetHorseManager().MoveItemToHorse(ids[0]);
  11049.         GetHorseManager().EquipItem(horseId);
  11050.        
  11051.         ids.Clear();
  11052.         ids = inv.AddAnItem('Horse Saddle 2');
  11053.         horseId = GetHorseManager().MoveItemToHorse(ids[0]);
  11054.         GetHorseManager().EquipItem(horseId);
  11055.        
  11056.         manager = theGame.GetJournalManager();
  11057.  
  11058.        
  11059.         manager.GetActivatedOfType( 'CJournalCreature', ents );
  11060.         for(i=0; i<ents.Size(); i+=1)
  11061.         {
  11062.             manager.ActivateEntry(ents[i], JS_Inactive, false, true);
  11063.         }
  11064.        
  11065.        
  11066.         ents.Clear();
  11067.         manager.GetActivatedOfType( 'CJournalCharacter', ents );
  11068.         for(i=0; i<ents.Size(); i+=1)
  11069.         {
  11070.             manager.ActivateEntry(ents[i], JS_Inactive, false, true);
  11071.         }
  11072.        
  11073.        
  11074.         ents.Clear();
  11075.         manager.GetActivatedOfType( 'CJournalQuest', ents );
  11076.         for(i=0; i<ents.Size(); i+=1)
  11077.         {
  11078.            
  11079.             if( StrStartsWith(ents[i].baseName, "q60"))
  11080.                 continue;
  11081.                
  11082.             manager.ActivateEntry(ents[i], JS_Inactive, false, true);
  11083.         }
  11084.        
  11085.        
  11086.         manager.ActivateEntryByScriptTag('TutorialAard', JS_Active);
  11087.         manager.ActivateEntryByScriptTag('TutorialAdrenaline', JS_Active);
  11088.         manager.ActivateEntryByScriptTag('TutorialAxii', JS_Active);
  11089.         manager.ActivateEntryByScriptTag('TutorialAxiiDialog', JS_Active);
  11090.         manager.ActivateEntryByScriptTag('TutorialCamera', JS_Active);
  11091.         manager.ActivateEntryByScriptTag('TutorialCamera_pad', JS_Active);
  11092.         manager.ActivateEntryByScriptTag('TutorialCiriBlink', JS_Active);
  11093.         manager.ActivateEntryByScriptTag('TutorialCiriCharge', JS_Active);
  11094.         manager.ActivateEntryByScriptTag('TutorialCiriStamina', JS_Active);
  11095.         manager.ActivateEntryByScriptTag('TutorialCounter', JS_Active);
  11096.         manager.ActivateEntryByScriptTag('TutorialDialogClose', JS_Active);
  11097.         manager.ActivateEntryByScriptTag('TutorialFallingRoll', JS_Active);
  11098.         manager.ActivateEntryByScriptTag('TutorialFocus', JS_Active);
  11099.         manager.ActivateEntryByScriptTag('TutorialFocusClues', JS_Active);
  11100.         manager.ActivateEntryByScriptTag('TutorialFocusClues', JS_Active);
  11101.         manager.ActivateEntryByScriptTag('TutorialHorseRoad', JS_Active);
  11102.         manager.ActivateEntryByScriptTag('TutorialHorseSpeed0', JS_Active);
  11103.         manager.ActivateEntryByScriptTag('TutorialHorseSpeed0_pad', JS_Active);
  11104.         manager.ActivateEntryByScriptTag('TutorialHorseSpeed1', JS_Active);
  11105.         manager.ActivateEntryByScriptTag('TutorialHorseSpeed2', JS_Active);
  11106.         manager.ActivateEntryByScriptTag('TutorialHorseSummon', JS_Active);
  11107.         manager.ActivateEntryByScriptTag('TutorialHorseSummon_pad', JS_Active);
  11108.         manager.ActivateEntryByScriptTag('TutorialIgni', JS_Active);
  11109.         manager.ActivateEntryByScriptTag('TutorialJournalAlternateSings', JS_Active);
  11110.         manager.ActivateEntryByScriptTag('TutorialJournalBoatDamage', JS_Active);
  11111.         manager.ActivateEntryByScriptTag('TutorialJournalBoatMount', JS_Active);
  11112.         manager.ActivateEntryByScriptTag('TutorialJournalBuffs', JS_Active);
  11113.         manager.ActivateEntryByScriptTag('TutorialJournalCharDevLeveling', JS_Active);
  11114.         manager.ActivateEntryByScriptTag('TutorialJournalCharDevSkills', JS_Active);
  11115.         manager.ActivateEntryByScriptTag('TutorialJournalCrafting', JS_Active);
  11116.         manager.ActivateEntryByScriptTag('TutorialJournalCrossbow', JS_Active);
  11117.         manager.ActivateEntryByScriptTag('TutorialJournalDialogGwint', JS_Active);
  11118.         manager.ActivateEntryByScriptTag('TutorialJournalDialogShop', JS_Active);
  11119.         manager.ActivateEntryByScriptTag('TutorialJournalDive', JS_Active);
  11120.         manager.ActivateEntryByScriptTag('TutorialJournalDodge', JS_Active);
  11121.         manager.ActivateEntryByScriptTag('TutorialJournalDodge_pad', JS_Active);
  11122.         manager.ActivateEntryByScriptTag('TutorialJournalDrawWeapon', JS_Active);
  11123.         manager.ActivateEntryByScriptTag('TutorialJournalDrawWeapon_pad', JS_Active);
  11124.         manager.ActivateEntryByScriptTag('TutorialJournalDurability', JS_Active);
  11125.         manager.ActivateEntryByScriptTag('TutorialJournalExplorations', JS_Active);
  11126.         manager.ActivateEntryByScriptTag('TutorialJournalExplorations_pad', JS_Active);
  11127.         manager.ActivateEntryByScriptTag('TutorialJournalFastTravel', JS_Active);
  11128.         manager.ActivateEntryByScriptTag('TutorialJournalFocusRedObjects', JS_Active);
  11129.         manager.ActivateEntryByScriptTag('TutorialJournalGasClouds', JS_Active);
  11130.         manager.ActivateEntryByScriptTag('TutorialJournalHeavyAttacks', JS_Active);
  11131.         manager.ActivateEntryByScriptTag('TutorialJournalHorse', JS_Active);
  11132.         manager.ActivateEntryByScriptTag('TutorialJournalHorseStamina', JS_Active);
  11133.         manager.ActivateEntryByScriptTag('TutorialJournalJump', JS_Active);
  11134.         manager.ActivateEntryByScriptTag('TutorialJournalLightAttacks', JS_Active);
  11135.         manager.ActivateEntryByScriptTag('TutorialJournalLightAttacks_pad', JS_Active);
  11136.         manager.ActivateEntryByScriptTag('TutorialJournalMeditation', JS_Active);
  11137.         manager.ActivateEntryByScriptTag('TutorialJournalMeditation_pad', JS_Active);
  11138.         manager.ActivateEntryByScriptTag('TutorialJournalMonsterThreatLevels', JS_Active);
  11139.         manager.ActivateEntryByScriptTag('TutorialJournalMovement', JS_Active);
  11140.         manager.ActivateEntryByScriptTag('TutorialJournalMovement_pad', JS_Active);
  11141.         manager.ActivateEntryByScriptTag('TutorialJournalMutagenIngredient', JS_Active);
  11142.         manager.ActivateEntryByScriptTag('TutorialJournalMutagenPotion', JS_Active);
  11143.         manager.ActivateEntryByScriptTag('TutorialJournalOils', JS_Active);
  11144.         manager.ActivateEntryByScriptTag('TutorialJournalPetards', JS_Active);
  11145.         manager.ActivateEntryByScriptTag('TutorialJournalPotions', JS_Active);
  11146.         manager.ActivateEntryByScriptTag('TutorialJournalPotions_pad', JS_Active);
  11147.         manager.ActivateEntryByScriptTag('TutorialJournalQuestArea', JS_Active);
  11148.         manager.ActivateEntryByScriptTag('TutorialJournalRadial', JS_Active);
  11149.         manager.ActivateEntryByScriptTag('TutorialJournalRifts', JS_Active);
  11150.         manager.ActivateEntryByScriptTag('TutorialJournalRun', JS_Active);
  11151.         manager.ActivateEntryByScriptTag('TutorialJournalShopDescription', JS_Active);
  11152.         manager.ActivateEntryByScriptTag('TutorialJournalSignCast', JS_Active);
  11153.         manager.ActivateEntryByScriptTag('TutorialJournalSignCast_pad', JS_Active);
  11154.         manager.ActivateEntryByScriptTag('TutorialJournalSpecialAttacks', JS_Active);
  11155.         manager.ActivateEntryByScriptTag('TutorialJournalStaminaExploration', JS_Active);
  11156.         manager.ActivateEntryByScriptTag('TutorialJumpHang', JS_Active);
  11157.         manager.ActivateEntryByScriptTag('TutorialLadder', JS_Active);
  11158.         manager.ActivateEntryByScriptTag('TutorialLadderMove', JS_Active);
  11159.         manager.ActivateEntryByScriptTag('TutorialLadderMove_pad', JS_Active);
  11160.         manager.ActivateEntryByScriptTag('TutorialObjectiveSwitching', JS_Active);
  11161.         manager.ActivateEntryByScriptTag('TutorialOxygen', JS_Active);
  11162.         manager.ActivateEntryByScriptTag('TutorialParry', JS_Active);
  11163.         manager.ActivateEntryByScriptTag('TutorialPOIUncovered', JS_Active);
  11164.         manager.ActivateEntryByScriptTag('TutorialQuen', JS_Active);
  11165.         manager.ActivateEntryByScriptTag('TutorialRoll', JS_Active);
  11166.         manager.ActivateEntryByScriptTag('TutorialRoll_pad', JS_Active);
  11167.         manager.ActivateEntryByScriptTag('TutorialSpeedPairing', JS_Active);
  11168.         manager.ActivateEntryByScriptTag('TutorialSprint', JS_Active);
  11169.         manager.ActivateEntryByScriptTag('TutorialStaminaSigns', JS_Active);
  11170.         manager.ActivateEntryByScriptTag('TutorialStealing', JS_Active);
  11171.         manager.ActivateEntryByScriptTag('TutorialSwimmingSpeed', JS_Active);
  11172.         manager.ActivateEntryByScriptTag('TutorialTimedChoiceDialog', JS_Active);
  11173.         manager.ActivateEntryByScriptTag('TutorialYrden', JS_Active);
  11174.        
  11175.        
  11176.         FactsAdd('kill_base_tutorials');
  11177.        
  11178.        
  11179.         theGame.GetTutorialSystem().RemoveAllQueuedTutorials();
  11180.        
  11181.        
  11182.         FactsAdd('standalone_ep1');
  11183.         FactsRemove("StandAloneEP1");
  11184.        
  11185.         theGame.GetJournalManager().ForceUntrackingQuestForEP1Savegame();
  11186.     }
  11187.    
  11188.     final function Debug_FocusBoyFocusGain()
  11189.     {
  11190.         var focusGain : float;
  11191.        
  11192.         focusGain = FactsQuerySum( "debug_fact_focus_boy" ) ;
  11193.         GainStat( BCS_Focus, focusGain );
  11194.     }
  11195.    
  11196.     public final function StandaloneEp2_1()
  11197.     {
  11198.         var i, inc, quantityLow, randLow, quantityMedium, randMedium, quantityHigh, randHigh, startingMoney : int;
  11199.         var pam : W3PlayerAbilityManager;
  11200.         var ids : array<SItemUniqueId>;
  11201.         var STARTING_LEVEL : int;
  11202.        
  11203.         FactsAdd( "StandAloneEP2", 1 );
  11204.        
  11205.        
  11206.         inv.RemoveAllItems();
  11207.        
  11208.        
  11209.         inv.AddAnItem( 'Illusion Medallion', 1, true, true, false );
  11210.         inv.AddAnItem( 'q103_safe_conduct', 1, true, true, false );
  11211.        
  11212.        
  11213.         theGame.GetGamerProfile().ClearAllAchievementsForEP2();
  11214.        
  11215.        
  11216.         levelManager.Hack_EP2StandaloneLevelShrink( 35 );
  11217.        
  11218.        
  11219.         levelManager.ResetCharacterDev();
  11220.         pam = ( W3PlayerAbilityManager )abilityManager;
  11221.         if( pam )
  11222.         {
  11223.             pam.ResetCharacterDev();
  11224.         }
  11225.         levelManager.SetFreeSkillPoints( levelManager.GetLevel() - 1 + 11 );   
  11226.        
  11227.        
  11228.         inv.AddAnItem( 'Mutagen red', 4 );
  11229.         inv.AddAnItem( 'Mutagen green', 4 );
  11230.         inv.AddAnItem( 'Mutagen blue', 4 );
  11231.         inv.AddAnItem( 'Lesser mutagen red', 2 );
  11232.         inv.AddAnItem( 'Lesser mutagen green', 2 );
  11233.         inv.AddAnItem( 'Lesser mutagen blue', 2 );
  11234.         inv.AddAnItem( 'Greater mutagen red', 2 );
  11235.         inv.AddAnItem( 'Greater mutagen green', 2 );
  11236.         inv.AddAnItem( 'Greater mutagen blue', 2 );
  11237.        
  11238.        
  11239.         startingMoney = 20000;
  11240.         if( GetMoney() > startingMoney )
  11241.         {
  11242.             RemoveMoney( GetMoney() - startingMoney );
  11243.         }
  11244.         else
  11245.         {
  11246.             AddMoney( 20000 - GetMoney() );
  11247.         }
  11248.        
  11249.        
  11250.         ids.Clear();
  11251.         ids = inv.AddAnItem( 'EP2 Standalone Starting Armor' );
  11252.         EquipItem( ids[0] );
  11253.         ids.Clear();
  11254.         ids = inv.AddAnItem( 'EP2 Standalone Starting Boots' );
  11255.         EquipItem( ids[0] );
  11256.         ids.Clear();
  11257.         ids = inv.AddAnItem( 'EP2 Standalone Starting Gloves' );
  11258.         EquipItem( ids[0] );
  11259.         ids.Clear();
  11260.         ids = inv.AddAnItem( 'EP2 Standalone Starting Pants' );
  11261.         EquipItem( ids[0] );
  11262.        
  11263.        
  11264.         ids.Clear();
  11265.         ids = inv.AddAnItem( 'EP2 Standalone Starting Steel Sword' );
  11266.         EquipItem( ids[0] );
  11267.         ids.Clear();
  11268.         ids = inv.AddAnItem( 'EP2 Standalone Starting Silver Sword' );
  11269.         EquipItem( ids[0] );
  11270.        
  11271.        
  11272.         inv.AddAnItem( 'Torch', 1, true, true, false );
  11273.        
  11274.        
  11275.         quantityLow = 1;
  11276.         randLow = 3;
  11277.         quantityMedium = 4;
  11278.         randMedium = 4;
  11279.         quantityHigh = 8;
  11280.         randHigh = 6;
  11281.        
  11282.         inv.AddAnItem( 'Alghoul bone marrow',quantityMedium+RandRange( randMedium ) );
  11283.         inv.AddAnItem( 'Amethyst dust',quantityLow+RandRange( randLow ) );
  11284.         inv.AddAnItem( 'Arachas eyes',quantityLow+RandRange( randLow ) );
  11285.         inv.AddAnItem( 'Arachas venom',quantityLow+RandRange( randLow ) );
  11286.         inv.AddAnItem( 'Basilisk hide',quantityLow+RandRange( randLow ) );
  11287.         inv.AddAnItem( 'Basilisk venom',quantityLow+RandRange( randLow ) );
  11288.         inv.AddAnItem( 'Bear pelt',quantityHigh+RandRange( randHigh ) );
  11289.         inv.AddAnItem( 'Berserker pelt',quantityLow+RandRange( randLow ) );
  11290.         inv.AddAnItem( 'Coal',quantityHigh+RandRange( randHigh ) );
  11291.         inv.AddAnItem( 'Cotton',quantityHigh+RandRange( randHigh ) );
  11292.  
  11293.  
  11294.         inv.AddAnItem( 'Deer hide',quantityHigh+RandRange( randHigh ) );
  11295.         inv.AddAnItem( 'Diamond dust',quantityLow+RandRange( randLow ) );
  11296.  
  11297.         inv.AddAnItem( 'Drowned dead tongue',quantityLow+RandRange( randLow ) );
  11298.         inv.AddAnItem( 'Drowner brain',quantityMedium+RandRange( randMedium ) );
  11299.  
  11300.  
  11301.  
  11302.         inv.AddAnItem( 'Endriag chitin plates',quantityMedium+RandRange( randMedium ) );
  11303.         inv.AddAnItem( 'Endriag embryo',quantityLow+RandRange( randLow ) );
  11304.         inv.AddAnItem( 'Ghoul blood',quantityMedium+RandRange( randMedium ) );
  11305.         inv.AddAnItem( 'Goat hide',quantityMedium+RandRange( randMedium ) );
  11306.         inv.AddAnItem( 'Hag teeth',quantityMedium+RandRange( randMedium ) );
  11307.         inv.AddAnItem( 'Hardened leather',quantityMedium+RandRange( randMedium ) );
  11308.         inv.AddAnItem( 'Hardened timber',quantityMedium+RandRange( randMedium ) );
  11309.         inv.AddAnItem( 'Harpy feathers',quantityMedium+RandRange( randMedium ) );
  11310.         inv.AddAnItem( 'Horse hide',quantityLow+RandRange( randLow ) );
  11311.  
  11312.  
  11313.  
  11314.  
  11315.  
  11316.  
  11317.         inv.AddAnItem( 'Necrophage skin',quantityLow+RandRange( randLow ) );
  11318.         inv.AddAnItem( 'Nekker blood',quantityHigh+RandRange( randHigh ) );
  11319.         inv.AddAnItem( 'Nekker heart',quantityMedium+RandRange( randMedium ) );
  11320.  
  11321.         inv.AddAnItem( 'Phosphorescent crystal',quantityLow+RandRange( randLow ) );
  11322.         inv.AddAnItem( 'Pig hide',quantityMedium+RandRange( randMedium ) );
  11323.  
  11324.         inv.AddAnItem( 'Rabbit pelt',quantityMedium+RandRange( randMedium ) );
  11325.         inv.AddAnItem( 'Rotfiend blood',quantityMedium+RandRange( randMedium ) );
  11326.         inv.AddAnItem( 'Sapphire dust',quantityLow+RandRange( randLow ) );
  11327.  
  11328.  
  11329.  
  11330.         inv.AddAnItem( 'Specter dust',quantityMedium+RandRange( randMedium ) );
  11331.  
  11332.  
  11333.  
  11334.  
  11335.  
  11336.  
  11337.  
  11338.         inv.AddAnItem( 'Water essence',quantityMedium+RandRange( randMedium ) );
  11339.         inv.AddAnItem( 'Wolf liver',quantityHigh+RandRange( randHigh ) );
  11340.         inv.AddAnItem( 'Wolf pelt',quantityMedium+RandRange( randMedium ) );
  11341.        
  11342.         inv.AddAnItem( 'Alcohest', 5 );
  11343.         inv.AddAnItem( 'Dwarven spirit', 5 );
  11344.    
  11345.        
  11346.         ids.Clear();
  11347.         ids = inv.AddAnItem( 'Crossbow 5' );
  11348.         EquipItem( ids[0] );
  11349.         ids.Clear();
  11350.         ids = inv.AddAnItem( 'Blunt Bolt', 100 );
  11351.         EquipItem( ids[0] );
  11352.         inv.AddAnItem( 'Broadhead Bolt', 100 );
  11353.         inv.AddAnItem( 'Split Bolt', 100 );
  11354.        
  11355.        
  11356.         RemoveAllAlchemyRecipes();
  11357.         RemoveAllCraftingSchematics();
  11358.        
  11359.        
  11360.        
  11361.        
  11362.        
  11363.        
  11364.        
  11365.        
  11366.        
  11367.         AddAlchemyRecipe( 'Recipe for Petris Philtre 2' );
  11368.         AddAlchemyRecipe( 'Recipe for Swallow 1' );
  11369.         AddAlchemyRecipe( 'Recipe for Tawny Owl 1' );
  11370.        
  11371.         AddAlchemyRecipe( 'Recipe for White Gull 1' );
  11372.        
  11373.        
  11374.        
  11375.        
  11376.        
  11377.         AddAlchemyRecipe( 'Recipe for Beast Oil 1' );
  11378.         AddAlchemyRecipe( 'Recipe for Cursed Oil 1' );
  11379.         AddAlchemyRecipe( 'Recipe for Hanged Man Venom 1' );
  11380.         AddAlchemyRecipe( 'Recipe for Hybrid Oil 1' );
  11381.         AddAlchemyRecipe( 'Recipe for Insectoid Oil 2' );
  11382.         AddAlchemyRecipe( 'Recipe for Magicals Oil 1' );
  11383.         AddAlchemyRecipe( 'Recipe for Necrophage Oil 1' );
  11384.         AddAlchemyRecipe( 'Recipe for Specter Oil 1' );
  11385.         AddAlchemyRecipe( 'Recipe for Vampire Oil 2' );
  11386.         AddAlchemyRecipe( 'Recipe for Draconide Oil 2' );
  11387.         AddAlchemyRecipe( 'Recipe for Ogre Oil 1' );
  11388.         AddAlchemyRecipe( 'Recipe for Relic Oil 1' );
  11389.         AddAlchemyRecipe( 'Recipe for Beast Oil 2' );
  11390.         AddAlchemyRecipe( 'Recipe for Cursed Oil 2' );
  11391.         AddAlchemyRecipe( 'Recipe for Hanged Man Venom 2' );
  11392.         AddAlchemyRecipe( 'Recipe for Hybrid Oil 2' );
  11393.         AddAlchemyRecipe( 'Recipe for Insectoid Oil 2' );
  11394.         AddAlchemyRecipe( 'Recipe for Magicals Oil 2' );
  11395.         AddAlchemyRecipe( 'Recipe for Necrophage Oil 2' );
  11396.         AddAlchemyRecipe( 'Recipe for Specter Oil 2' );
  11397.         AddAlchemyRecipe( 'Recipe for Vampire Oil 2' );
  11398.         AddAlchemyRecipe( 'Recipe for Draconide Oil 2' );
  11399.         AddAlchemyRecipe( 'Recipe for Ogre Oil 2' );
  11400.         AddAlchemyRecipe( 'Recipe for Relic Oil 2' );
  11401.        
  11402.        
  11403.         AddAlchemyRecipe( 'Recipe for Dancing Star 1' );
  11404.        
  11405.         AddAlchemyRecipe( 'Recipe for Dwimeritum Bomb 1' );
  11406.        
  11407.         AddAlchemyRecipe( 'Recipe for Grapeshot 1' );
  11408.         AddAlchemyRecipe( 'Recipe for Samum 1' );
  11409.        
  11410.         AddAlchemyRecipe( 'Recipe for White Frost 1' );
  11411.        
  11412.        
  11413.        
  11414.         AddAlchemyRecipe( 'Recipe for Dwarven spirit 1' );
  11415.         AddAlchemyRecipe( 'Recipe for Alcohest 1' );
  11416.         AddAlchemyRecipe( 'Recipe for White Gull 1' );
  11417.        
  11418.        
  11419.         AddStartingSchematics();
  11420.        
  11421.        
  11422.         ids.Clear();
  11423.         ids = inv.AddAnItem( 'Swallow 2' );
  11424.         EquipItem( ids[0] );
  11425.         ids.Clear();
  11426.         ids = inv.AddAnItem( 'Thunderbolt 2' );
  11427.         EquipItem( ids[0] );
  11428.         ids.Clear();
  11429.         ids = inv.AddAnItem( 'Tawny Owl 2' );
  11430.         EquipItem( ids[0] );
  11431.         ids.Clear();
  11432.        
  11433.         ids = inv.AddAnItem( 'Grapeshot 2' );
  11434.         EquipItem( ids[0] );
  11435.         ids.Clear();
  11436.         ids = inv.AddAnItem( 'Samum 2' );
  11437.         EquipItem( ids[0] );
  11438.        
  11439.         inv.AddAnItem( 'Dwimeritum Bomb 1' );
  11440.         inv.AddAnItem( 'Dragons Dream 1' );
  11441.         inv.AddAnItem( 'Silver Dust Bomb 1' );
  11442.         inv.AddAnItem( 'White Frost 2' );
  11443.         inv.AddAnItem( 'Devils Puffball 2' );
  11444.         inv.AddAnItem( 'Dancing Star 2' );
  11445.         inv.AddAnItem( 'Beast Oil 1' );
  11446.         inv.AddAnItem( 'Cursed Oil 1' );
  11447.         inv.AddAnItem( 'Hanged Man Venom 2' );
  11448.         inv.AddAnItem( 'Hybrid Oil 2' );
  11449.         inv.AddAnItem( 'Insectoid Oil 2' );
  11450.         inv.AddAnItem( 'Magicals Oil 1' );
  11451.         inv.AddAnItem( 'Necrophage Oil 2' );
  11452.         inv.AddAnItem( 'Ogre Oil 1' );
  11453.         inv.AddAnItem( 'Specter Oil 1' );
  11454.         inv.AddAnItem( 'Vampire Oil 2' );
  11455.         inv.AddAnItem( 'Draconide Oil 2' );
  11456.         inv.AddAnItem( 'Relic Oil 1' );
  11457.         inv.AddAnItem( 'Black Blood 1' );
  11458.         inv.AddAnItem( 'Blizzard 1' );
  11459.         inv.AddAnItem( 'Cat 2' );
  11460.         inv.AddAnItem( 'Full Moon 1' );
  11461.         inv.AddAnItem( 'Golden Oriole 1' );
  11462.         inv.AddAnItem( 'Killer Whale 1' );
  11463.         inv.AddAnItem( 'Maribor Forest 1' );
  11464.         inv.AddAnItem( 'Petris Philtre 2' );
  11465.         inv.AddAnItem( 'White Gull 1', 3 );
  11466.         inv.AddAnItem( 'White Honey 2' );
  11467.         inv.AddAnItem( 'White Raffards Decoction 1' );
  11468.        
  11469.        
  11470.         inv.AddAnItem( 'Mutagen 17' ); 
  11471.         inv.AddAnItem( 'Mutagen 19' ); 
  11472.         inv.AddAnItem( 'Mutagen 27' ); 
  11473.         inv.AddAnItem( 'Mutagen 26' ); 
  11474.        
  11475.        
  11476.         inv.AddAnItem( 'weapon_repair_kit_1', 5 );
  11477.         inv.AddAnItem( 'weapon_repair_kit_2', 3 );
  11478.         inv.AddAnItem( 'armor_repair_kit_1', 5 );
  11479.         inv.AddAnItem( 'armor_repair_kit_2', 3 );
  11480.        
  11481.        
  11482.         quantityMedium = 2;
  11483.         quantityLow = 1;
  11484.         inv.AddAnItem( 'Rune stribog lesser', quantityMedium );
  11485.         inv.AddAnItem( 'Rune stribog', quantityLow );
  11486.         inv.AddAnItem( 'Rune dazhbog lesser', quantityMedium );
  11487.         inv.AddAnItem( 'Rune dazhbog', quantityLow );
  11488.         inv.AddAnItem( 'Rune devana lesser', quantityMedium );
  11489.         inv.AddAnItem( 'Rune devana', quantityLow );
  11490.         inv.AddAnItem( 'Rune zoria lesser', quantityMedium );
  11491.         inv.AddAnItem( 'Rune zoria', quantityLow );
  11492.         inv.AddAnItem( 'Rune morana lesser', quantityMedium );
  11493.         inv.AddAnItem( 'Rune morana', quantityLow );
  11494.         inv.AddAnItem( 'Rune triglav lesser', quantityMedium );
  11495.         inv.AddAnItem( 'Rune triglav', quantityLow );
  11496.         inv.AddAnItem( 'Rune svarog lesser', quantityMedium );
  11497.         inv.AddAnItem( 'Rune svarog', quantityLow );
  11498.         inv.AddAnItem( 'Rune veles lesser', quantityMedium );
  11499.         inv.AddAnItem( 'Rune veles', quantityLow );
  11500.         inv.AddAnItem( 'Rune perun lesser', quantityMedium );
  11501.         inv.AddAnItem( 'Rune perun', quantityLow );
  11502.         inv.AddAnItem( 'Rune elemental lesser', quantityMedium );
  11503.         inv.AddAnItem( 'Rune elemental', quantityLow );
  11504.        
  11505.         inv.AddAnItem( 'Glyph aard lesser', quantityMedium );
  11506.         inv.AddAnItem( 'Glyph aard', quantityLow );
  11507.         inv.AddAnItem( 'Glyph axii lesser', quantityMedium );
  11508.         inv.AddAnItem( 'Glyph axii', quantityLow );
  11509.         inv.AddAnItem( 'Glyph igni lesser', quantityMedium );
  11510.         inv.AddAnItem( 'Glyph igni', quantityLow );
  11511.         inv.AddAnItem( 'Glyph quen lesser', quantityMedium );
  11512.         inv.AddAnItem( 'Glyph quen', quantityLow );
  11513.         inv.AddAnItem( 'Glyph yrden lesser', quantityMedium );
  11514.         inv.AddAnItem( 'Glyph yrden', quantityLow );
  11515.        
  11516.        
  11517.         StandaloneEp2_2();
  11518.     }
  11519.    
  11520.     public final function StandaloneEp2_2()
  11521.     {
  11522.         var horseId : SItemUniqueId;
  11523.         var ids : array<SItemUniqueId>;
  11524.         var ents : array< CJournalBase >;
  11525.         var i : int;
  11526.         var manager : CWitcherJournalManager;
  11527.        
  11528.        
  11529.         inv.AddAnItem( 'Cows milk', 20 );
  11530.         ids.Clear();
  11531.         ids = inv.AddAnItem( 'Dumpling', 44 );
  11532.         EquipItem( ids[0] );
  11533.        
  11534.        
  11535.         inv.AddAnItem( 'Clearing Potion', 2, true, false, false );
  11536.        
  11537.        
  11538.         GetHorseManager().RemoveAllItems();
  11539.        
  11540.         ids.Clear();
  11541.         ids = inv.AddAnItem( 'Horse Bag 2' );
  11542.         horseId = GetHorseManager( ).MoveItemToHorse( ids[0] );
  11543.         GetHorseManager().EquipItem( horseId );
  11544.        
  11545.         ids.Clear();
  11546.         ids = inv.AddAnItem( 'Horse Blinder 2' );
  11547.         horseId = GetHorseManager().MoveItemToHorse( ids[0] );
  11548.         GetHorseManager().EquipItem( horseId );
  11549.        
  11550.         ids.Clear();
  11551.         ids = inv.AddAnItem( 'Horse Saddle 2' );
  11552.         horseId = GetHorseManager().MoveItemToHorse( ids[0] );
  11553.         GetHorseManager().EquipItem( horseId );
  11554.        
  11555.         manager = theGame.GetJournalManager();
  11556.  
  11557.        
  11558.         manager.GetActivatedOfType( 'CJournalCreature', ents );
  11559.         for(i=0; i<ents.Size(); i+=1)
  11560.         {
  11561.             manager.ActivateEntry( ents[i], JS_Inactive, false, true );
  11562.         }
  11563.        
  11564.        
  11565.         ents.Clear();
  11566.         manager.GetActivatedOfType( 'CJournalCharacter', ents );
  11567.         for(i=0; i<ents.Size(); i+=1)
  11568.         {
  11569.             manager.ActivateEntry( ents[i], JS_Inactive, false, true );
  11570.         }
  11571.        
  11572.        
  11573.         ents.Clear();
  11574.         manager.GetActivatedOfType( 'CJournalQuest', ents );
  11575.         for(i=0; i<ents.Size(); i+=1)
  11576.         {
  11577.            
  11578.             if( StrStartsWith( ents[i].baseName, "q60" ) )
  11579.                 continue;
  11580.                
  11581.             manager.ActivateEntry( ents[i], JS_Inactive, false, true );
  11582.         }
  11583.        
  11584.        
  11585.         manager.ActivateEntryByScriptTag( 'TutorialAard', JS_Active );
  11586.         manager.ActivateEntryByScriptTag( 'TutorialAdrenaline', JS_Active );
  11587.         manager.ActivateEntryByScriptTag( 'TutorialAxii', JS_Active );
  11588.         manager.ActivateEntryByScriptTag( 'TutorialAxiiDialog', JS_Active );
  11589.         manager.ActivateEntryByScriptTag( 'TutorialCamera', JS_Active );
  11590.         manager.ActivateEntryByScriptTag( 'TutorialCamera_pad', JS_Active );
  11591.         manager.ActivateEntryByScriptTag( 'TutorialCiriBlink', JS_Active );
  11592.         manager.ActivateEntryByScriptTag( 'TutorialCiriCharge', JS_Active );
  11593.         manager.ActivateEntryByScriptTag( 'TutorialCiriStamina', JS_Active );
  11594.         manager.ActivateEntryByScriptTag( 'TutorialCounter', JS_Active );
  11595.         manager.ActivateEntryByScriptTag( 'TutorialDialogClose', JS_Active );
  11596.         manager.ActivateEntryByScriptTag( 'TutorialFallingRoll', JS_Active );
  11597.         manager.ActivateEntryByScriptTag( 'TutorialFocus', JS_Active );
  11598.         manager.ActivateEntryByScriptTag( 'TutorialFocusClues', JS_Active );
  11599.         manager.ActivateEntryByScriptTag( 'TutorialFocusClues', JS_Active );
  11600.         manager.ActivateEntryByScriptTag( 'TutorialHorseRoad', JS_Active );
  11601.         manager.ActivateEntryByScriptTag( 'TutorialHorseSpeed0', JS_Active );
  11602.         manager.ActivateEntryByScriptTag( 'TutorialHorseSpeed0_pad', JS_Active );
  11603.         manager.ActivateEntryByScriptTag( 'TutorialHorseSpeed1', JS_Active );
  11604.         manager.ActivateEntryByScriptTag( 'TutorialHorseSpeed2', JS_Active );
  11605.         manager.ActivateEntryByScriptTag( 'TutorialHorseSummon', JS_Active );
  11606.         manager.ActivateEntryByScriptTag( 'TutorialHorseSummon_pad', JS_Active );
  11607.         manager.ActivateEntryByScriptTag( 'TutorialIgni', JS_Active );
  11608.         manager.ActivateEntryByScriptTag( 'TutorialJournalAlternateSings', JS_Active );
  11609.         manager.ActivateEntryByScriptTag( 'TutorialJournalBoatDamage', JS_Active );
  11610.         manager.ActivateEntryByScriptTag( 'TutorialJournalBoatMount', JS_Active );
  11611.         manager.ActivateEntryByScriptTag( 'TutorialJournalBuffs', JS_Active );
  11612.         manager.ActivateEntryByScriptTag( 'TutorialJournalCharDevLeveling', JS_Active );
  11613.         manager.ActivateEntryByScriptTag( 'TutorialJournalCharDevSkills', JS_Active );
  11614.         manager.ActivateEntryByScriptTag( 'TutorialJournalCrafting', JS_Active );
  11615.         manager.ActivateEntryByScriptTag( 'TutorialJournalCrossbow', JS_Active );
  11616.         manager.ActivateEntryByScriptTag( 'TutorialJournalDialogGwint', JS_Active );
  11617.         manager.ActivateEntryByScriptTag( 'TutorialJournalDialogShop', JS_Active );
  11618.         manager.ActivateEntryByScriptTag( 'TutorialJournalDive', JS_Active );
  11619.         manager.ActivateEntryByScriptTag( 'TutorialJournalDodge', JS_Active );
  11620.         manager.ActivateEntryByScriptTag( 'TutorialJournalDodge_pad', JS_Active );
  11621.         manager.ActivateEntryByScriptTag( 'TutorialJournalDrawWeapon', JS_Active );
  11622.         manager.ActivateEntryByScriptTag( 'TutorialJournalDrawWeapon_pad', JS_Active );
  11623.         manager.ActivateEntryByScriptTag( 'TutorialJournalDurability', JS_Active );
  11624.         manager.ActivateEntryByScriptTag( 'TutorialJournalExplorations', JS_Active );
  11625.         manager.ActivateEntryByScriptTag( 'TutorialJournalExplorations_pad', JS_Active );
  11626.         manager.ActivateEntryByScriptTag( 'TutorialJournalFastTravel', JS_Active );
  11627.         manager.ActivateEntryByScriptTag( 'TutorialJournalFocusRedObjects', JS_Active );
  11628.         manager.ActivateEntryByScriptTag( 'TutorialJournalGasClouds', JS_Active );
  11629.         manager.ActivateEntryByScriptTag( 'TutorialJournalHeavyAttacks', JS_Active );
  11630.         manager.ActivateEntryByScriptTag( 'TutorialJournalHorse', JS_Active );
  11631.         manager.ActivateEntryByScriptTag( 'TutorialJournalHorseStamina', JS_Active );
  11632.         manager.ActivateEntryByScriptTag( 'TutorialJournalJump', JS_Active );
  11633.         manager.ActivateEntryByScriptTag( 'TutorialJournalLightAttacks', JS_Active );
  11634.         manager.ActivateEntryByScriptTag( 'TutorialJournalLightAttacks_pad', JS_Active );
  11635.         manager.ActivateEntryByScriptTag( 'TutorialJournalMeditation', JS_Active );
  11636.         manager.ActivateEntryByScriptTag( 'TutorialJournalMeditation_pad', JS_Active );
  11637.         manager.ActivateEntryByScriptTag( 'TutorialJournalMonsterThreatLevels', JS_Active );
  11638.         manager.ActivateEntryByScriptTag( 'TutorialJournalMovement', JS_Active );
  11639.         manager.ActivateEntryByScriptTag( 'TutorialJournalMovement_pad', JS_Active );
  11640.         manager.ActivateEntryByScriptTag( 'TutorialJournalMutagenIngredient', JS_Active );
  11641.         manager.ActivateEntryByScriptTag( 'TutorialJournalMutagenPotion', JS_Active );
  11642.         manager.ActivateEntryByScriptTag( 'TutorialJournalOils', JS_Active );
  11643.         manager.ActivateEntryByScriptTag( 'TutorialJournalPetards', JS_Active );
  11644.         manager.ActivateEntryByScriptTag( 'TutorialJournalPotions', JS_Active );
  11645.         manager.ActivateEntryByScriptTag( 'TutorialJournalPotions_pad', JS_Active );
  11646.         manager.ActivateEntryByScriptTag( 'TutorialJournalQuestArea', JS_Active );
  11647.         manager.ActivateEntryByScriptTag( 'TutorialJournalRadial', JS_Active );
  11648.         manager.ActivateEntryByScriptTag( 'TutorialJournalRifts', JS_Active );
  11649.         manager.ActivateEntryByScriptTag( 'TutorialJournalRun', JS_Active );
  11650.         manager.ActivateEntryByScriptTag( 'TutorialJournalShopDescription', JS_Active );
  11651.         manager.ActivateEntryByScriptTag( 'TutorialJournalSignCast', JS_Active );
  11652.         manager.ActivateEntryByScriptTag( 'TutorialJournalSignCast_pad', JS_Active );
  11653.         manager.ActivateEntryByScriptTag( 'TutorialJournalSpecialAttacks', JS_Active );
  11654.         manager.ActivateEntryByScriptTag( 'TutorialJournalStaminaExploration', JS_Active );
  11655.         manager.ActivateEntryByScriptTag( 'TutorialJumpHang', JS_Active );
  11656.         manager.ActivateEntryByScriptTag( 'TutorialLadder', JS_Active );
  11657.         manager.ActivateEntryByScriptTag( 'TutorialLadderMove', JS_Active );
  11658.         manager.ActivateEntryByScriptTag( 'TutorialLadderMove_pad', JS_Active );
  11659.         manager.ActivateEntryByScriptTag( 'TutorialObjectiveSwitching', JS_Active );
  11660.         manager.ActivateEntryByScriptTag( 'TutorialOxygen', JS_Active );
  11661.         manager.ActivateEntryByScriptTag( 'TutorialParry', JS_Active );
  11662.         manager.ActivateEntryByScriptTag( 'TutorialPOIUncovered', JS_Active );
  11663.         manager.ActivateEntryByScriptTag( 'TutorialQuen', JS_Active );
  11664.         manager.ActivateEntryByScriptTag( 'TutorialRoll', JS_Active );
  11665.         manager.ActivateEntryByScriptTag( 'TutorialRoll_pad', JS_Active );
  11666.         manager.ActivateEntryByScriptTag( 'TutorialSpeedPairing', JS_Active );
  11667.         manager.ActivateEntryByScriptTag( 'TutorialSprint', JS_Active );
  11668.         manager.ActivateEntryByScriptTag( 'TutorialStaminaSigns', JS_Active );
  11669.         manager.ActivateEntryByScriptTag( 'TutorialStealing', JS_Active );
  11670.         manager.ActivateEntryByScriptTag( 'TutorialSwimmingSpeed', JS_Active );
  11671.         manager.ActivateEntryByScriptTag( 'TutorialTimedChoiceDialog', JS_Active );
  11672.         manager.ActivateEntryByScriptTag( 'TutorialYrden', JS_Active );
  11673.        
  11674.         inv.AddAnItem( 'Geralt Shirt', 1 );
  11675.         inv.AddAnItem( 'Thread', 13 );
  11676.         inv.AddAnItem( 'String', 9 );
  11677.         inv.AddAnItem( 'Linen', 4 );
  11678.         inv.AddAnItem( 'Silk', 6 );
  11679.         inv.AddAnItem( 'Nigredo', 3 );
  11680.         inv.AddAnItem( 'Albedo', 1 );
  11681.         inv.AddAnItem( 'Rubedo', 1 );
  11682.         inv.AddAnItem( 'Rebis', 1 );
  11683.         inv.AddAnItem( 'Dog tallow', 4 );
  11684.         inv.AddAnItem( 'Lunar shards', 3 );
  11685.         inv.AddAnItem( 'Quicksilver solution', 5 );
  11686.         inv.AddAnItem( 'Aether', 1 );
  11687.         inv.AddAnItem( 'Optima mater', 3 );
  11688.         inv.AddAnItem( 'Fifth essence', 2 );
  11689.         inv.AddAnItem( 'Hardened timber', 6 );
  11690.         inv.AddAnItem( 'Fur square', 1 );
  11691.         inv.AddAnItem( 'Leather straps', 11 );
  11692.         inv.AddAnItem( 'Leather squares', 6 );
  11693.         inv.AddAnItem( 'Leather', 3 );
  11694.         inv.AddAnItem( 'Hardened leather', 14 );
  11695.         inv.AddAnItem( 'Chitin scale', 8 );
  11696.         inv.AddAnItem( 'Draconide leather', 5 );
  11697.         inv.AddAnItem( 'Infused draconide leather', 0 );
  11698.         inv.AddAnItem( 'Steel ingot', 5 );
  11699.         inv.AddAnItem( 'Dark iron ore', 2 );
  11700.         inv.AddAnItem( 'Dark iron ingot', 3 );
  11701.         inv.AddAnItem( 'Dark iron plate', 1 );
  11702.         inv.AddAnItem( 'Dark steel ingot', 10 );
  11703.         inv.AddAnItem( 'Dark steel plate', 6 );
  11704.         inv.AddAnItem( 'Silver ore', 2 );
  11705.         inv.AddAnItem( 'Silver ingot', 6 );
  11706.         inv.AddAnItem( 'Meteorite ore', 3 );
  11707.         inv.AddAnItem( 'Meteorite ingot', 3 );
  11708.         inv.AddAnItem( 'Meteorite plate', 2 );
  11709.         inv.AddAnItem( 'Meteorite silver ingot', 6 );
  11710.         inv.AddAnItem( 'Meteorite silver plate', 5 );
  11711.         inv.AddAnItem( 'Orichalcum ingot', 0 );
  11712.         inv.AddAnItem( 'Orichalcum plate', 1 );
  11713.         inv.AddAnItem( 'Dwimeryte ingot', 6 );
  11714.         inv.AddAnItem( 'Dwimeryte plate', 5 );
  11715.         inv.AddAnItem( 'Dwimeryte enriched ingot', 0 );
  11716.         inv.AddAnItem( 'Dwimeryte enriched plate', 0 );
  11717.         inv.AddAnItem( 'Emerald dust', 0 );
  11718.         inv.AddAnItem( 'Ruby dust', 4 );
  11719.         inv.AddAnItem( 'Ruby', 2 );
  11720.         inv.AddAnItem( 'Ruby flawless', 1 );
  11721.         inv.AddAnItem( 'Sapphire dust', 0 );
  11722.         inv.AddAnItem( 'Sapphire', 0 );
  11723.         inv.AddAnItem( 'Monstrous brain', 8 );
  11724.         inv.AddAnItem( 'Monstrous blood', 14 );
  11725.         inv.AddAnItem( 'Monstrous bone', 9 );
  11726.         inv.AddAnItem( 'Monstrous claw', 14 );
  11727.         inv.AddAnItem( 'Monstrous dust', 9 );
  11728.         inv.AddAnItem( 'Monstrous ear', 5 );
  11729.         inv.AddAnItem( 'Monstrous egg', 1 );
  11730.         inv.AddAnItem( 'Monstrous eye', 10 );
  11731.         inv.AddAnItem( 'Monstrous essence', 7 );
  11732.         inv.AddAnItem( 'Monstrous feather', 8 );
  11733.         inv.AddAnItem( 'Monstrous hair', 12 );
  11734.         inv.AddAnItem( 'Monstrous heart', 7 );
  11735.         inv.AddAnItem( 'Monstrous hide', 4 );
  11736.         inv.AddAnItem( 'Monstrous liver', 5 );
  11737.         inv.AddAnItem( 'Monstrous plate', 1 );
  11738.         inv.AddAnItem( 'Monstrous saliva', 6 );
  11739.         inv.AddAnItem( 'Monstrous stomach', 3 );
  11740.         inv.AddAnItem( 'Monstrous tongue', 5 );
  11741.         inv.AddAnItem( 'Monstrous tooth', 9 );
  11742.         inv.AddAnItem( 'Venom extract', 0 );
  11743.         inv.AddAnItem( 'Siren vocal cords', 1 );
  11744.        
  11745.        
  11746.         SelectQuickslotItem( EES_RangedWeapon );
  11747.        
  11748.        
  11749.         FactsAdd( 'kill_base_tutorials' );
  11750.        
  11751.        
  11752.         theGame.GetTutorialSystem().RemoveAllQueuedTutorials();
  11753.        
  11754.        
  11755.         FactsAdd( 'standalone_ep2' );
  11756.         FactsRemove( "StandAloneEP2" );
  11757.        
  11758.         theGame.GetJournalManager().ForceUntrackingQuestForEP1Savegame();
  11759.     }
  11760. }
  11761.  
  11762. exec function fuqfep1()
  11763. {
  11764.     theGame.GetJournalManager().ForceUntrackingQuestForEP1Savegame();
  11765. }
  11766.  
  11767.  
  11768.  
  11769.  
  11770.  
  11771. function GetWitcherPlayer() : W3PlayerWitcher
  11772. {
  11773.     return (W3PlayerWitcher)thePlayer;
  11774. }
  11775.  
Add Comment
Please, Sign In to add comment