lufusol

playerWitcher.ws for Realtime Gamepad Controls for Witcher 3 4.01

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