lufusol

playerWitcher.ws for Holy Sword Aerondight (Fire FX) for Witcher 3 4.01

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