lufusol

playerWitcher.ws for AutoLoot Next Gen for Witcher 3 4.01

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