lufusol

playerWitcher.ws for No Inventory Weight Limit for Witcher 3 4.01

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