lufusol

playerWitcher.ws for Smooth Mount and Dismount for Witcher 3 4.01

Feb 12th, 2023
274
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.     // ++modSmoothHorseMounting
  4948.     timer function ActivateHorseCameraForFastTravelFromAnywhereMods(dt : float, id : int)
  4949.     {
  4950.         if (thePlayer.IsUsingHorse())
  4951.         {
  4952.             theGame.ActivateHorseCamera( true, 0.f );
  4953.         }
  4954.     }
  4955.     // --modSmoothHorseMounting
  4956.    
  4957.     public final function OnPotionDrinkInput(fromUpperSlot : bool)
  4958.     {
  4959.         var slot : EEquipmentSlots;
  4960.        
  4961.         if(fromUpperSlot)
  4962.             slot = GetSelectedPotionSlotUpper();
  4963.         else
  4964.             slot = GetSelectedPotionSlotLower();
  4965.            
  4966.         DrinkPotionFromSlot(slot);
  4967.     }
  4968.    
  4969.     public final function OnPotionDrinkKeyboardsInput(slot : EEquipmentSlots)
  4970.     {
  4971.         DrinkPotionFromSlot(slot);
  4972.     }
  4973.    
  4974.     private function DrinkPotionFromSlot(slot : EEquipmentSlots):void
  4975.     {
  4976.         var item : SItemUniqueId;      
  4977.         var hud : CR4ScriptedHud;
  4978.         var module : CR4HudModuleItemInfo;
  4979.        
  4980.         GetItemEquippedOnSlot(slot, item);
  4981.         if(inv.ItemHasTag(item, 'Edibles'))
  4982.         {
  4983.             ConsumeItem( item );
  4984.         }
  4985.         else
  4986.         {          
  4987.             if (ToxicityLowEnoughToDrinkPotion(slot))
  4988.             {
  4989.                 DrinkPreparedPotion(slot);
  4990.             }
  4991.             else
  4992.             {
  4993.                 SendToxicityTooHighMessage();
  4994.             }
  4995.         }
  4996.        
  4997.         hud = (CR4ScriptedHud)theGame.GetHud();
  4998.         if ( hud )
  4999.         {
  5000.             module = (CR4HudModuleItemInfo)hud.GetHudModule("ItemInfoModule");
  5001.             if( module )
  5002.             {
  5003.                 module.ForceShowElement();
  5004.             }
  5005.         }
  5006.     }
  5007.    
  5008.     private function SendToxicityTooHighMessage()
  5009.     {
  5010.         var messageText : string;
  5011.         var language : string;
  5012.         var audioLanguage : string;
  5013.        
  5014.         if (GetHudMessagesSize() < 2)
  5015.         {
  5016.             messageText = GetLocStringByKeyExt("menu_cannot_perform_action_now") + " " + GetLocStringByKeyExt("panel_common_statistics_tooltip_current_toxicity");
  5017.            
  5018.             theGame.GetGameLanguageName(audioLanguage,language);
  5019.             if (language == "AR")
  5020.             {
  5021.                 messageText += (int)(abilityManager.GetStat(BCS_Toxicity, false)) + " / " +  (int)(abilityManager.GetStatMax(BCS_Toxicity)) + " :";
  5022.             }
  5023.             else
  5024.             {
  5025.                 messageText += ": " + (int)(abilityManager.GetStat(BCS_Toxicity, false)) + " / " +  (int)(abilityManager.GetStatMax(BCS_Toxicity));
  5026.             }
  5027.            
  5028.             DisplayHudMessage(messageText);
  5029.         }
  5030.         theSound.SoundEvent("gui_global_denied");
  5031.     }
  5032.    
  5033.     public final function GetSelectedPotionSlotUpper() : EEquipmentSlots
  5034.     {
  5035.         return selectedPotionSlotUpper;
  5036.     }
  5037.    
  5038.     public final function GetSelectedPotionSlotLower() : EEquipmentSlots
  5039.     {
  5040.         return selectedPotionSlotLower;
  5041.     }
  5042.    
  5043.    
  5044.     public final function FlipSelectedPotion(isUpperSlot : bool) : bool
  5045.     {
  5046.         if(isUpperSlot)
  5047.         {
  5048.             if(selectedPotionSlotUpper == EES_Potion1 && IsAnyItemEquippedOnSlot(EES_Potion3))
  5049.             {
  5050.                 selectedPotionSlotUpper = EES_Potion3;
  5051.                 return true;
  5052.             }
  5053.             else if(selectedPotionSlotUpper == EES_Potion3 && IsAnyItemEquippedOnSlot(EES_Potion1))
  5054.             {
  5055.                 selectedPotionSlotUpper = EES_Potion1;
  5056.                 return true;
  5057.             }
  5058.         }
  5059.         else
  5060.         {
  5061.             if(selectedPotionSlotLower == EES_Potion2 && IsAnyItemEquippedOnSlot(EES_Potion4))
  5062.             {
  5063.                 selectedPotionSlotLower = EES_Potion4;
  5064.                 return true;
  5065.             }
  5066.             else if(selectedPotionSlotLower == EES_Potion4 && IsAnyItemEquippedOnSlot(EES_Potion2))
  5067.             {
  5068.                 selectedPotionSlotLower = EES_Potion2;
  5069.                 return true;
  5070.             }
  5071.         }
  5072.        
  5073.         return false;
  5074.     }
  5075.    
  5076.     public final function AddBombThrowDelay( bombId : SItemUniqueId )
  5077.     {
  5078.         var slot : EEquipmentSlots;
  5079.        
  5080.         slot = GetItemSlot( bombId );
  5081.        
  5082.         if( slot == EES_Unused )
  5083.         {
  5084.             return;
  5085.         }
  5086.            
  5087.         if( slot == EES_Petard1 || slot == EES_Quickslot1 )
  5088.         {
  5089.             remainingBombThrowDelaySlot1 = theGame.params.BOMB_THROW_DELAY;
  5090.             AddTimer( 'BombDelay', 0.0f, true );
  5091.         }
  5092.         else if( slot == EES_Petard2 || slot == EES_Quickslot2 )
  5093.         {
  5094.             remainingBombThrowDelaySlot2 = theGame.params.BOMB_THROW_DELAY;
  5095.             AddTimer( 'BombDelay', 0.0f, true );
  5096.         }
  5097.         else
  5098.         {
  5099.             return;
  5100.         }
  5101.     }
  5102.    
  5103.     public final function GetBombDelay( slot : EEquipmentSlots ) : float
  5104.     {
  5105.         if( slot == EES_Petard1 || slot == EES_Quickslot1 )
  5106.         {
  5107.             return remainingBombThrowDelaySlot1;
  5108.         }
  5109.         else if( slot == EES_Petard2 || slot == EES_Quickslot2 )
  5110.         {
  5111.             return remainingBombThrowDelaySlot2;
  5112.         }
  5113.        
  5114.         return 0;
  5115.     }
  5116.    
  5117.     timer function BombDelay( dt : float, id : int )
  5118.     {
  5119.         remainingBombThrowDelaySlot1 = MaxF( 0.f , remainingBombThrowDelaySlot1 - dt );
  5120.         remainingBombThrowDelaySlot2 = MaxF( 0.f , remainingBombThrowDelaySlot2 - dt );
  5121.        
  5122.         if( remainingBombThrowDelaySlot1 <= 0.0f && remainingBombThrowDelaySlot2  <= 0.0f )
  5123.         {
  5124.             RemoveTimer('BombDelay');
  5125.         }
  5126.     }
  5127.    
  5128.     public function ResetCharacterDev()
  5129.     {
  5130.        
  5131.         UnequipItemFromSlot(EES_SkillMutagen1);
  5132.         UnequipItemFromSlot(EES_SkillMutagen2);
  5133.         UnequipItemFromSlot(EES_SkillMutagen3);
  5134.         UnequipItemFromSlot(EES_SkillMutagen4);
  5135.        
  5136.         levelManager.ResetCharacterDev();
  5137.         ((W3PlayerAbilityManager)abilityManager).ResetCharacterDev();      
  5138.     }
  5139.    
  5140.     public final function ResetMutationsDev()
  5141.     {
  5142.         levelManager.ResetMutationsDev();
  5143.         ((W3PlayerAbilityManager)abilityManager).ResetMutationsDev();
  5144.     }
  5145.    
  5146.     public final function GetHeldSword() : SItemUniqueId
  5147.     {
  5148.         var i : int;
  5149.         var weapons : array< SItemUniqueId >;
  5150.        
  5151.         weapons = inv.GetHeldWeapons();
  5152.         for( i=0; i<weapons.Size(); i+=1 )
  5153.         {
  5154.             if( inv.IsItemSilverSwordUsableByPlayer( weapons[i] ) || inv.IsItemSteelSwordUsableByPlayer( weapons[i] ) )
  5155.             {
  5156.                 return weapons[i];
  5157.             }
  5158.         }
  5159.        
  5160.         return GetInvalidUniqueId();
  5161.     }
  5162.    
  5163.     public function ConsumeItem( itemId : SItemUniqueId ) : bool
  5164.     {
  5165.         var itemName : name;
  5166.         var removedItem, willRemoveItem : bool;
  5167.         var edibles : array<SItemUniqueId>;
  5168.         var toSlot : EEquipmentSlots;
  5169.         var i : int;
  5170.         var equippedNewEdible : bool;
  5171.        
  5172.         itemName = inv.GetItemName( itemId );
  5173.        
  5174.         if (itemName == 'q111_imlerith_acorn' )
  5175.         {
  5176.             AddPoints(ESkillPoint, 2, true);
  5177.             removedItem = inv.RemoveItem( itemId, 1 );
  5178.             theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt("panel_character_popup_title_buy_skill") + "<br>" + GetLocStringByKeyExt("panel_character_availablepoints") + " +2");
  5179.             theSound.SoundEvent("gui_character_buy_skill");
  5180.         }
  5181.         else if ( itemName == 'Clearing Potion' )
  5182.         {
  5183.             ResetCharacterDev();
  5184.             removedItem = inv.RemoveItem( itemId, 1 );
  5185.             theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt("panel_character_popup_character_cleared") );
  5186.             theSound.SoundEvent("gui_character_synergy_effect");
  5187.         }
  5188.         else if ( itemName == 'Restoring Potion' )
  5189.         {
  5190.             ResetMutationsDev();
  5191.             removedItem = inv.RemoveItem( itemId, 1 );
  5192.             theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt("panel_character_popup_character_cleared") );
  5193.             theSound.SoundEvent("gui_character_synergy_effect");
  5194.         }
  5195.         else if(itemName == 'Wolf Hour')
  5196.         {
  5197.             removedItem = inv.RemoveItem( itemId, 1 );
  5198.             theSound.SoundEvent("gui_character_synergy_effect");
  5199.             AddEffectDefault(EET_WolfHour, thePlayer, 'wolf hour');
  5200.         }
  5201.         else if ( itemName == 'q704_ft_golden_egg' )
  5202.         {
  5203.             AddPoints(ESkillPoint, 1, true);
  5204.             removedItem = inv.RemoveItem( itemId, 1 );
  5205.             theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt("panel_character_popup_title_buy_skill") + "<br>" + GetLocStringByKeyExt("panel_character_availablepoints") + " +1");
  5206.             theSound.SoundEvent("gui_character_buy_skill");
  5207.         }
  5208.         else if ( itemName == 'mq7023_cake' )
  5209.         {
  5210.             this.AddAbility('mq7023_cake_vitality_bonus');
  5211.             removedItem = inv.RemoveItem( itemId, 1 );
  5212.             theSound.SoundEvent("gui_character_synergy_effect");
  5213.         }
  5214.         else
  5215.         {
  5216.             willRemoveItem = inv.GetItemQuantity(itemId) == 1 && !inv.ItemHasTag(itemId, 'InfiniteUse');
  5217.            
  5218.             if(willRemoveItem)
  5219.                 toSlot = GetItemSlot(itemId);
  5220.                
  5221.             removedItem = super.ConsumeItem(itemId);
  5222.            
  5223.             if(willRemoveItem && removedItem)
  5224.             {
  5225.                 edibles = inv.GetItemsByTag('Edibles');
  5226.                 equippedNewEdible = false;
  5227.                
  5228.                
  5229.                 for(i=0; i<edibles.Size(); i+=1)
  5230.                 {
  5231.                     if(!IsItemEquipped(edibles[i]) && !inv.ItemHasTag(edibles[i], 'Alcohol') && inv.GetItemName(edibles[i]) != 'Clearing Potion' && inv.GetItemName(edibles[i]) != 'Wolf Hour')
  5232.                     {
  5233.                         EquipItemInGivenSlot(edibles[i], toSlot, true, false);
  5234.                         equippedNewEdible = true;
  5235.                         break;
  5236.                     }
  5237.                 }
  5238.                
  5239.                
  5240.                 if(!equippedNewEdible)
  5241.                 {
  5242.                     for(i=0; i<edibles.Size(); i+=1)
  5243.                     {
  5244.                         if(!IsItemEquipped(edibles[i]) && inv.GetItemName(edibles[i]) != 'Clearing Potion' && inv.GetItemName(edibles[i]) != 'Wolf Hour')
  5245.                         {
  5246.                             EquipItemInGivenSlot(edibles[i], toSlot, true, false);
  5247.                             break;
  5248.                         }
  5249.                     }
  5250.                 }
  5251.             }
  5252.         }
  5253.        
  5254.         return removedItem;
  5255.     }
  5256.    
  5257.    
  5258.     public final function GetAlcoholForAlchemicalItemsRefill() : SItemUniqueId
  5259.     {
  5260.         var alcos : array<SItemUniqueId>;
  5261.         var id : SItemUniqueId;
  5262.         var i, price, minPrice : int;
  5263.        
  5264.         alcos = inv.GetItemsByTag(theGame.params.TAG_ALCHEMY_REFILL_ALCO);
  5265.        
  5266.         if(alcos.Size() > 0)
  5267.         {
  5268.             if(inv.ItemHasTag(alcos[0], theGame.params.TAG_INFINITE_USE))
  5269.                 return alcos[0];
  5270.                
  5271.             minPrice = inv.GetItemPrice(alcos[0]);
  5272.             price = minPrice;
  5273.             id = alcos[0];
  5274.            
  5275.             for(i=1; i<alcos.Size(); i+=1)
  5276.             {
  5277.                 if(inv.ItemHasTag(alcos[i], theGame.params.TAG_INFINITE_USE))
  5278.                     return alcos[i];
  5279.                
  5280.                 price = inv.GetItemPrice(alcos[i]);
  5281.                
  5282.                 if(price < minPrice)
  5283.                 {
  5284.                     minPrice = price;
  5285.                     id = alcos[i];
  5286.                 }
  5287.             }
  5288.            
  5289.             return id;
  5290.         }
  5291.        
  5292.         return GetInvalidUniqueId();
  5293.     }
  5294.    
  5295.     public final function ClearPreviouslyUsedBolt()
  5296.     {
  5297.         previouslyUsedBolt = GetInvalidUniqueId();
  5298.     }
  5299.    
  5300.     public function ShouldUseInfiniteWaterBolts() : bool
  5301.     {
  5302.         return GetCurrentStateName() == 'Swimming' || IsSwimming() || IsDiving();
  5303.     }
  5304.    
  5305.     public function GetCurrentInfiniteBoltName( optional forceBodkin : bool, optional forceHarpoon : bool ) : name
  5306.     {
  5307.         if(!forceBodkin && (forceHarpoon || ShouldUseInfiniteWaterBolts()) )
  5308.         {
  5309.             return 'Harpoon Bolt';
  5310.         }
  5311.         return 'Bodkin Bolt';
  5312.     }
  5313.    
  5314.    
  5315.     public final function AddAndEquipInfiniteBolt(optional forceBodkin : bool, optional forceHarpoon : bool)
  5316.     {
  5317.         var bolt, bodkins, harpoons : array<SItemUniqueId>;
  5318.         var boltItemName : name;
  5319.         var i : int;
  5320.        
  5321.        
  5322.         bodkins = inv.GetItemsByName('Bodkin Bolt');
  5323.         harpoons = inv.GetItemsByName('Harpoon Bolt');
  5324.        
  5325.         for(i=bodkins.Size()-1; i>=0; i-=1)
  5326.             inv.RemoveItem(bodkins[i], inv.GetItemQuantity(bodkins[i]) );
  5327.            
  5328.         for(i=harpoons.Size()-1; i>=0; i-=1)
  5329.             inv.RemoveItem(harpoons[i], inv.GetItemQuantity(harpoons[i]) );
  5330.            
  5331.        
  5332.        
  5333.         boltItemName = GetCurrentInfiniteBoltName( forceBodkin, forceHarpoon );
  5334.        
  5335.        
  5336.         if(boltItemName == 'Bodkin Bolt' && inv.IsIdValid(previouslyUsedBolt))
  5337.         {
  5338.             bolt.PushBack(previouslyUsedBolt);
  5339.         }
  5340.         else
  5341.         {
  5342.            
  5343.             bolt = inv.AddAnItem(boltItemName, 1, true, true);
  5344.            
  5345.            
  5346.             if(boltItemName == 'Harpoon Bolt')
  5347.             {
  5348.                 GetItemEquippedOnSlot(EES_Bolt, previouslyUsedBolt);
  5349.             }
  5350.         }
  5351.        
  5352.         EquipItem(bolt[0], EES_Bolt);
  5353.     }
  5354.    
  5355.    
  5356.     event OnItemGiven(data : SItemChangedData)
  5357.     {
  5358.         var m_guiManager    : CR4GuiManager;
  5359.        
  5360.         super.OnItemGiven(data);
  5361.        
  5362.        
  5363.         if(!inv)
  5364.             inv = GetInventory();
  5365.        
  5366.        
  5367.         if(inv.IsItemEncumbranceItem(data.ids[0]))
  5368.             UpdateEncumbrance();
  5369.        
  5370.         m_guiManager = theGame.GetGuiManager();
  5371.         if(m_guiManager)
  5372.             m_guiManager.RegisterNewItem(data.ids[0]);
  5373.     }
  5374.        
  5375.    
  5376.     public final function CheckForFullyArmedAchievement()
  5377.     {
  5378.         if( HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_BEAR) || HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_GRYPHON) ||
  5379.             HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_LYNX) || HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_WOLF) ||
  5380.             HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_VIPER) || HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_NETFLIX)           
  5381.         )
  5382.         {
  5383.             theGame.GetGamerProfile().AddAchievement(EA_FullyArmed);
  5384.         }
  5385.     }
  5386.    
  5387.    
  5388.     public final function HasAllItemsFromSet(setItemTag : name) : bool
  5389.     {
  5390.         var item : SItemUniqueId;
  5391.        
  5392.         if(!GetItemEquippedOnSlot(EES_SteelSword, item) || !inv.ItemHasTag(item, setItemTag))
  5393.             return false;
  5394.        
  5395.         if(!GetItemEquippedOnSlot(EES_SilverSword, item) || !inv.ItemHasTag(item, setItemTag))
  5396.             return false;
  5397.            
  5398.         if(!GetItemEquippedOnSlot(EES_Boots, item) || !inv.ItemHasTag(item, setItemTag))
  5399.             return false;
  5400.            
  5401.         if(!GetItemEquippedOnSlot(EES_Pants, item) || !inv.ItemHasTag(item, setItemTag))
  5402.             return false;
  5403.            
  5404.         if(!GetItemEquippedOnSlot(EES_Gloves, item) || !inv.ItemHasTag(item, setItemTag))
  5405.             return false;
  5406.            
  5407.         if(!GetItemEquippedOnSlot(EES_Armor, item) || !inv.ItemHasTag(item, setItemTag))
  5408.             return false;
  5409.            
  5410.        
  5411.         if(setItemTag == theGame.params.ITEM_SET_TAG_BEAR || setItemTag == theGame.params.ITEM_SET_TAG_LYNX)
  5412.         {
  5413.             if(!GetItemEquippedOnSlot(EES_RangedWeapon, item) || !inv.ItemHasTag(item, setItemTag))
  5414.                 return false;
  5415.         }
  5416.  
  5417.         return true;
  5418.     }
  5419.    
  5420.    
  5421.     public final function CheckForFullyArmedByTag(setItemTag : name)
  5422.     {
  5423.         var doneParts, totalParts : int;
  5424.         var item : SItemUniqueId;
  5425.        
  5426.         if(setItemTag == '')
  5427.             return;
  5428.            
  5429.        
  5430.         doneParts = 0;
  5431.         totalParts = 6;
  5432.         if(GetItemEquippedOnSlot(EES_SteelSword, item) && inv.ItemHasTag(item, setItemTag))
  5433.             doneParts += 1;
  5434.        
  5435.         if(GetItemEquippedOnSlot(EES_SilverSword, item) && inv.ItemHasTag(item, setItemTag))
  5436.             doneParts += 1;
  5437.            
  5438.         if(GetItemEquippedOnSlot(EES_Boots, item) && inv.ItemHasTag(item, setItemTag))
  5439.             doneParts += 1;
  5440.            
  5441.         if(GetItemEquippedOnSlot(EES_Pants, item) && inv.ItemHasTag(item, setItemTag))
  5442.             doneParts += 1;
  5443.            
  5444.         if(GetItemEquippedOnSlot(EES_Gloves, item) && inv.ItemHasTag(item, setItemTag))
  5445.             doneParts += 1;
  5446.            
  5447.         if(GetItemEquippedOnSlot(EES_Armor, item) && inv.ItemHasTag(item, setItemTag))
  5448.             doneParts += 1;
  5449.            
  5450.        
  5451.         if(setItemTag == theGame.params.ITEM_SET_TAG_BEAR || setItemTag == theGame.params.ITEM_SET_TAG_LYNX)
  5452.         {
  5453.             totalParts += 1;
  5454.             if(GetItemEquippedOnSlot(EES_RangedWeapon, item) && inv.ItemHasTag(item, setItemTag))
  5455.                 doneParts += 1;
  5456.         }
  5457.        
  5458.        
  5459.         if(doneParts >= totalParts)
  5460.         {
  5461.             theGame.GetGamerProfile().AddAchievement(EA_FullyArmed);
  5462.         }
  5463.         else
  5464.         {
  5465.             theGame.GetGamerProfile().NoticeAchievementProgress(EA_FullyArmed, doneParts, totalParts);
  5466.         }
  5467.     }
  5468.    
  5469.    
  5470.    
  5471.    
  5472.     public function GetTotalArmor() : SAbilityAttributeValue
  5473.     {
  5474.         var armor : SAbilityAttributeValue;
  5475.         var armorItem : SItemUniqueId;
  5476.        
  5477.         armor = super.GetTotalArmor();
  5478.        
  5479.         if(GetItemEquippedOnSlot(EES_Armor, armorItem))
  5480.         {
  5481.            
  5482.             armor -= inv.GetItemAttributeValue(armorItem, theGame.params.ARMOR_VALUE_NAME);
  5483.            
  5484.            
  5485.             armor += inv.GetItemArmorTotal(armorItem);         
  5486.         }
  5487.        
  5488.         if(GetItemEquippedOnSlot(EES_Pants, armorItem))
  5489.         {
  5490.            
  5491.             armor -= inv.GetItemAttributeValue(armorItem, theGame.params.ARMOR_VALUE_NAME);
  5492.            
  5493.            
  5494.             armor += inv.GetItemArmorTotal(armorItem);         
  5495.         }
  5496.            
  5497.         if(GetItemEquippedOnSlot(EES_Boots, armorItem))
  5498.         {
  5499.            
  5500.             armor -= inv.GetItemAttributeValue(armorItem, theGame.params.ARMOR_VALUE_NAME);
  5501.            
  5502.            
  5503.             armor += inv.GetItemArmorTotal(armorItem);         
  5504.         }
  5505.            
  5506.         if(GetItemEquippedOnSlot(EES_Gloves, armorItem))
  5507.         {
  5508.            
  5509.             armor -= inv.GetItemAttributeValue(armorItem, theGame.params.ARMOR_VALUE_NAME);
  5510.            
  5511.            
  5512.             armor += inv.GetItemArmorTotal(armorItem);         
  5513.         }
  5514.            
  5515.         return armor;
  5516.     }
  5517.    
  5518.    
  5519.    
  5520.     public function ReduceArmorDurability() : EEquipmentSlots
  5521.     {
  5522.         var r, sum : int;
  5523.         var slot : EEquipmentSlots;
  5524.         var id : SItemUniqueId;
  5525.         var prevDurMult, currDurMult, ratio : float;
  5526.    
  5527.        
  5528.         sum = theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT;
  5529.         sum += theGame.params.DURABILITY_ARMOR_PANTS_WEIGHT;
  5530.         sum += theGame.params.DURABILITY_ARMOR_GLOVES_WEIGHT;
  5531.         sum += theGame.params.DURABILITY_ARMOR_BOOTS_WEIGHT;
  5532.         sum += theGame.params.DURABILITY_ARMOR_MISS_WEIGHT;
  5533.        
  5534.         r = RandRange(sum);
  5535.        
  5536.         if(r < theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT)
  5537.             slot = EES_Armor;
  5538.         else if (r < theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT + theGame.params.DURABILITY_ARMOR_PANTS_WEIGHT)
  5539.             slot = EES_Pants;
  5540.         else if (r < theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT + theGame.params.DURABILITY_ARMOR_PANTS_WEIGHT + theGame.params.DURABILITY_ARMOR_GLOVES_WEIGHT)
  5541.             slot = EES_Gloves;
  5542.         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)
  5543.             slot = EES_Boots;
  5544.         else
  5545.             return EES_InvalidSlot;                
  5546.        
  5547.         GetItemEquippedOnSlot(slot, id);               
  5548.         ratio = inv.GetItemDurabilityRatio(id);    
  5549.         if(inv.ReduceItemDurability(id))           
  5550.         {
  5551.             prevDurMult = theGame.params.GetDurabilityMultiplier(ratio, false);
  5552.            
  5553.             ratio = inv.GetItemDurabilityRatio(id);
  5554.             currDurMult = theGame.params.GetDurabilityMultiplier(ratio, false);
  5555.            
  5556.             if(currDurMult != prevDurMult)
  5557.             {
  5558.                
  5559.                
  5560.                
  5561.                
  5562.             }
  5563.                
  5564.             return slot;
  5565.         }
  5566.        
  5567.         return EES_InvalidSlot;
  5568.     }
  5569.    
  5570.    
  5571.     public function DismantleItem(dismantledItem : SItemUniqueId, toolItem : SItemUniqueId) : bool
  5572.     {
  5573.         var parts : array<SItemParts>;
  5574.         var i : int;
  5575.        
  5576.         if(!inv.IsItemDismantleKit(toolItem))
  5577.             return false;
  5578.        
  5579.         parts = inv.GetItemRecyclingParts(dismantledItem);
  5580.        
  5581.         if(parts.Size() <= 0)
  5582.             return false;
  5583.            
  5584.         for(i=0; i<parts.Size(); i+=1)
  5585.             inv.AddAnItem(parts[i].itemName, parts[i].quantity, true, false);
  5586.            
  5587.         inv.RemoveItem(toolItem);
  5588.         inv.RemoveItem(dismantledItem);
  5589.         return true;
  5590.     }
  5591.    
  5592.    
  5593.     public function GetItemEquippedOnSlot(slot : EEquipmentSlots, out item : SItemUniqueId) : bool
  5594.     {
  5595.         if(slot == EES_InvalidSlot || slot < 0 || slot > EnumGetMax('EEquipmentSlots'))
  5596.             return false;
  5597.        
  5598.         item = itemSlots[slot];
  5599.        
  5600.         return inv.IsIdValid(item);
  5601.     }
  5602.    
  5603.    
  5604.     public function GetItemSlotByItemName(itemName : name) : EEquipmentSlots
  5605.     {
  5606.         var ids : array<SItemUniqueId>;
  5607.         var i : int;
  5608.         var slot : EEquipmentSlots;
  5609.        
  5610.         ids = inv.GetItemsByName(itemName);
  5611.         for(i=0; i<ids.Size(); i+=1)
  5612.         {
  5613.             slot = GetItemSlot(ids[i]);
  5614.             if(slot != EES_InvalidSlot)
  5615.                 return slot;
  5616.         }
  5617.        
  5618.         return EES_InvalidSlot;
  5619.     }
  5620.    
  5621.    
  5622.     public function GetItemSlot(item : SItemUniqueId) : EEquipmentSlots
  5623.     {
  5624.         var i : int;
  5625.        
  5626.         if(!inv.IsIdValid(item))
  5627.             return EES_InvalidSlot;
  5628.            
  5629.         for(i=0; i<itemSlots.Size(); i+=1)
  5630.             if(itemSlots[i] == item)
  5631.                 return i;
  5632.        
  5633.         return EES_InvalidSlot;
  5634.     }
  5635.    
  5636.     public function GetEquippedItems() : array<SItemUniqueId>
  5637.     {
  5638.         return itemSlots;
  5639.     }
  5640.    
  5641.     public function IsItemEquipped(item : SItemUniqueId) : bool
  5642.     {
  5643.         if(!inv.IsIdValid(item))
  5644.             return false;
  5645.            
  5646.         return itemSlots.Contains(item);
  5647.     }
  5648.  
  5649.     public function IsItemHeld(item : SItemUniqueId) : bool
  5650.     {
  5651.         if(!inv.IsIdValid(item))
  5652.             return false;
  5653.            
  5654.         return inv.IsItemHeld(item);
  5655.     }
  5656.  
  5657.    
  5658.     public function IsAnyItemEquippedOnSlot(slot : EEquipmentSlots) : bool
  5659.     {
  5660.         if(slot == EES_InvalidSlot || slot < 0 || slot > EnumGetMax('EEquipmentSlots'))
  5661.             return false;
  5662.            
  5663.         return inv.IsIdValid(itemSlots[slot]);
  5664.     }
  5665.    
  5666.    
  5667.     public function GetFreeQuickslot() : EEquipmentSlots
  5668.     {
  5669.         if(!inv.IsIdValid(itemSlots[EES_Quickslot1]))       return EES_Quickslot1;
  5670.         if(!inv.IsIdValid(itemSlots[EES_Quickslot2]))       return EES_Quickslot2;
  5671.        
  5672.        
  5673.         return EES_InvalidSlot;
  5674.     }
  5675.    
  5676.    
  5677.     event OnEquipItemRequested(item : SItemUniqueId, ignoreMount : bool)
  5678.     {
  5679.         var slot : EEquipmentSlots;
  5680.        
  5681.         if(inv.IsIdValid(item))
  5682.         {
  5683.             slot = inv.GetSlotForItemId(item);
  5684.                
  5685.             if (slot != EES_InvalidSlot)
  5686.             {
  5687.                
  5688.                
  5689.                 EquipItemInGivenSlot(item, slot, ignoreMount);
  5690.             }
  5691.         }
  5692.     }
  5693.    
  5694.     event OnUnequipItemRequested(item : SItemUniqueId)
  5695.     {
  5696.         UnequipItem(item);
  5697.     }
  5698.    
  5699.    
  5700.     public function EquipItem(item : SItemUniqueId, optional slot : EEquipmentSlots, optional toHand : bool) : bool
  5701.     {
  5702.         if(!inv.IsIdValid(item))
  5703.             return false;
  5704.            
  5705.         if(slot == EES_InvalidSlot)
  5706.         {
  5707.             slot = inv.GetSlotForItemId(item);
  5708.            
  5709.             if(slot == EES_InvalidSlot)
  5710.                 return false;
  5711.         }
  5712.        
  5713.         ForceSoundAppearanceUpdate();
  5714.        
  5715.         return EquipItemInGivenSlot(item, slot, false, toHand);
  5716.     }
  5717.    
  5718.     protected function ShouldMount(slot : EEquipmentSlots, item : SItemUniqueId, category : name):bool
  5719.     {
  5720.        
  5721.        
  5722.         return !IsSlotPotionMutagen(slot) && category != 'usable' && category != 'potion' && category != 'petard' && !inv.ItemHasTag(item, 'PlayerUnwearable');
  5723.     }
  5724.        
  5725.     protected function ShouldMountItemWithName( itemName: name ): bool
  5726.     {
  5727.         var slot : EEquipmentSlots;
  5728.         var items : array<SItemUniqueId>;
  5729.         var category : name;
  5730.         var i : int;
  5731.        
  5732.         items = inv.GetItemsByName( itemName );
  5733.        
  5734.         category = inv.GetItemCategory( items[0] );
  5735.        
  5736.         slot = GetItemSlot( items[0] );
  5737.        
  5738.         return ShouldMount( slot, items[0], category );
  5739.     }  
  5740.    
  5741.     public function GetMountableItems( out items : array< SItemUniqueId > )
  5742.     {
  5743.         var i : int;
  5744.         var mountable : bool;
  5745.         var mountableItems : array< SItemUniqueId >;
  5746.         var slot : EEquipmentSlots;
  5747.         var category : name;
  5748.         var item: SItemUniqueId;
  5749.        
  5750.         for ( i = 0; i < items.Size(); i += 1 )
  5751.         {
  5752.             item = items[i];
  5753.        
  5754.             category = inv.GetItemCategory( item );
  5755.        
  5756.             slot = GetItemSlot( item );
  5757.        
  5758.             mountable = ShouldMount( slot, item, category );
  5759.        
  5760.             if ( mountable )
  5761.             {
  5762.                 mountableItems.PushBack( items[ i ] );
  5763.             }
  5764.         }
  5765.         items = mountableItems;
  5766.     }
  5767.    
  5768.     public final function AddAndEquipItem( item : name ) : bool
  5769.     {
  5770.         var ids : array< SItemUniqueId >;
  5771.        
  5772.         ids = inv.AddAnItem( item );
  5773.         if( inv.IsIdValid( ids[ 0 ] ) )
  5774.         {
  5775.             return EquipItem( ids[ 0 ] );
  5776.         }
  5777.        
  5778.         return false;
  5779.     }
  5780.    
  5781.     public final function AddQuestMarkedSelectedQuickslotItem( sel : SSelectedQuickslotItem )
  5782.     {
  5783.         questMarkedSelectedQuickslotItems.PushBack( sel );
  5784.     }
  5785.    
  5786.     public final function GetQuestMarkedSelectedQuickslotItem( sourceName : name ) : SItemUniqueId
  5787.     {
  5788.         var i : int;
  5789.        
  5790.         for( i=0; i<questMarkedSelectedQuickslotItems.Size(); i+=1 )
  5791.         {
  5792.             if( questMarkedSelectedQuickslotItems[i].sourceName == sourceName )
  5793.             {
  5794.                 return questMarkedSelectedQuickslotItems[i].itemID;
  5795.             }
  5796.         }
  5797.        
  5798.         return GetInvalidUniqueId();
  5799.     }
  5800.    
  5801.     public final function SwapEquippedItems(slot1 : EEquipmentSlots, slot2 : EEquipmentSlots)
  5802.     {
  5803.         var temp : SItemUniqueId;
  5804.         var pam : W3PlayerAbilityManager;
  5805.        
  5806.         temp = itemSlots[slot1];
  5807.         itemSlots[slot1] = itemSlots[slot2];
  5808.         itemSlots[slot2] = temp;
  5809.        
  5810.         if(IsSlotSkillMutagen(slot1))
  5811.         {
  5812.             pam = (W3PlayerAbilityManager)abilityManager;
  5813.             if(pam)
  5814.                 pam.OnSwappedMutagensPost(itemSlots[slot1], itemSlots[slot2]);
  5815.         }
  5816.     }
  5817.    
  5818.     public final function GetSlotForEquippedItem( itemID : SItemUniqueId ) : EEquipmentSlots
  5819.     {
  5820.         var i : int;
  5821.        
  5822.         for( i=0; i<itemSlots.Size(); i+=1 )
  5823.         {
  5824.             if( itemSlots[i] == itemID )
  5825.             {
  5826.                 return i;
  5827.             }
  5828.         }
  5829.        
  5830.         return EES_InvalidSlot;
  5831.     }
  5832.    
  5833.     public function EquipItemInGivenSlot(item : SItemUniqueId, slot : EEquipmentSlots, ignoreMounting : bool, optional toHand : bool) : bool
  5834.     {          
  5835.         var i, groupID, quantity : int;
  5836.         var fistsID : array<SItemUniqueId>;
  5837.         var pam : W3PlayerAbilityManager;
  5838.         var isSkillMutagen : bool;     
  5839.         var armorEntity : CItemEntity;
  5840.         var armorMeshComponent : CComponent;
  5841.         var armorSoundIdentification : name;
  5842.         var category : name;
  5843.         var tagOfASet : name;
  5844.         var prevSkillColor : ESkillColor;
  5845.         var containedAbilities : array<name>;
  5846.         var dm : CDefinitionsManagerAccessor;
  5847.         var armorType : EArmorType;
  5848.         var otherMask, previousItemInSlot : SItemUniqueId;
  5849.         var tutStatePot : W3TutorialManagerUIHandlerStatePotions;
  5850.         var tutStateFood : W3TutorialManagerUIHandlerStateFood;
  5851.         var tutStateSecondPotionEquip : W3TutorialManagerUIHandlerStateSecondPotionEquip;
  5852.         var boltItem : SItemUniqueId;
  5853.         var aerondight : W3Effect_Aerondight;
  5854.        
  5855.         if(!inv.IsIdValid(item))
  5856.         {
  5857.             LogAssert(false, "W3PlayerWitcher.EquipItemInGivenSlot: invalid item");
  5858.             return false;
  5859.         }
  5860.         if(slot == EES_InvalidSlot || slot == EES_HorseBlinders || slot == EES_HorseSaddle || slot == EES_HorseBag || slot == EES_HorseTrophy)
  5861.         {
  5862.             LogAssert(false, "W3PlayerWitcher.EquipItem: Cannot equip item <<" + inv.GetItemName(item) + ">> - provided slot <<" + slot + ">> is invalid");
  5863.             return false;
  5864.         }
  5865.         if(itemSlots[slot] == item)
  5866.         {
  5867.             return true;
  5868.         }  
  5869.        
  5870.         if(!HasRequiredLevelToEquipItem(item))
  5871.         {
  5872.            
  5873.             return false;
  5874.         }
  5875.        
  5876.         if(inv.ItemHasTag(item, 'PhantomWeapon') && !GetPhantomWeaponMgr())
  5877.         {
  5878.             InitPhantomWeaponMgr();
  5879.         }
  5880.        
  5881.        
  5882.         if( slot == EES_SilverSword && inv.ItemHasTag( item, 'Aerondight' ) )
  5883.         {
  5884.             AddEffectDefault( EET_Aerondight, this, "Aerondight" );
  5885.            
  5886.            
  5887.             aerondight = (W3Effect_Aerondight)GetBuff( EET_Aerondight );
  5888.             aerondight.Pause( 'ManageAerondightBuff' );
  5889.         }      
  5890.        
  5891.        
  5892.         previousItemInSlot = itemSlots[slot];
  5893.         if( IsItemEquipped(item))
  5894.         {
  5895.             SwapEquippedItems(slot, GetItemSlot(item));
  5896.             return true;
  5897.         }
  5898.        
  5899.        
  5900.         isSkillMutagen = IsSlotSkillMutagen(slot);
  5901.         if(isSkillMutagen)
  5902.         {
  5903.             pam = (W3PlayerAbilityManager)abilityManager;
  5904.             if(!pam.IsSkillMutagenSlotUnlocked(slot))
  5905.             {
  5906.                 return false;
  5907.             }
  5908.         }
  5909.        
  5910.        
  5911.         if(inv.IsIdValid(previousItemInSlot))
  5912.         {          
  5913.             if(!UnequipItemFromSlot(slot, true))
  5914.             {
  5915.                 LogAssert(false, "W3PlayerWitcher.EquipItem: Cannot equip item <<" + inv.GetItemName(item) + ">> !!");
  5916.                 return false;
  5917.             }
  5918.         }      
  5919.        
  5920.        
  5921.         if(inv.IsItemMask(item))
  5922.         {
  5923.             if(slot == EES_Quickslot1)
  5924.                 GetItemEquippedOnSlot(EES_Quickslot2, otherMask);
  5925.             else
  5926.                 GetItemEquippedOnSlot(EES_Quickslot1, otherMask);
  5927.                
  5928.             if(inv.IsItemMask(otherMask))
  5929.                 UnequipItem(otherMask);
  5930.         }
  5931.        
  5932.         if(isSkillMutagen)
  5933.         {
  5934.             groupID = pam.GetSkillGroupIdOfMutagenSlot(slot);
  5935.             prevSkillColor = pam.GetSkillGroupColor(groupID);
  5936.         }
  5937.        
  5938.         itemSlots[slot] = item;
  5939.        
  5940.         category = inv.GetItemCategory( item );
  5941.    
  5942.        
  5943.         if( !ignoreMounting && ShouldMount(slot, item, category) )
  5944.         {
  5945.            
  5946.             inv.MountItem( item, toHand, IsSlotSkillMutagen( slot ) );
  5947.         }      
  5948.        
  5949.         theTelemetry.LogWithLabelAndValue( TE_INV_ITEM_EQUIPPED, inv.GetItemName(item), slot );
  5950.                
  5951.         if(slot == EES_RangedWeapon)
  5952.         {          
  5953.             rangedWeapon = ( Crossbow )( inv.GetItemEntityUnsafe(item) );
  5954.             if(!rangedWeapon)
  5955.                 AddTimer('DelayedOnItemMount', 0.1, true);
  5956.            
  5957.             if ( IsSwimming() || IsDiving() )
  5958.             {
  5959.                 GetItemEquippedOnSlot(EES_Bolt, boltItem);
  5960.                
  5961.                 if(inv.IsIdValid(boltItem))
  5962.                 {
  5963.                     if ( !inv.ItemHasTag(boltItem, 'UnderwaterAmmo' ))
  5964.                     {
  5965.                         AddAndEquipInfiniteBolt(false, true);
  5966.                     }
  5967.                 }
  5968.                 else if(!IsAnyItemEquippedOnSlot(EES_Bolt))
  5969.                 {
  5970.                     AddAndEquipInfiniteBolt(false, true);
  5971.                 }
  5972.             }
  5973.            
  5974.             else if(!IsAnyItemEquippedOnSlot(EES_Bolt))
  5975.                 AddAndEquipInfiniteBolt();
  5976.         }
  5977.         else if(slot == EES_Bolt)
  5978.         {
  5979.             if(rangedWeapon)
  5980.             {   if ( !IsSwimming() || !IsDiving() )
  5981.                 {
  5982.                     rangedWeapon.OnReplaceAmmo();
  5983.                     rangedWeapon.OnWeaponReload();
  5984.                 }
  5985.                 else
  5986.                 {
  5987.                     DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_now" ));
  5988.                 }
  5989.             }
  5990.         }      
  5991.        
  5992.         else if(isSkillMutagen)
  5993.         {
  5994.             theGame.GetGuiManager().IgnoreNewItemNotifications( true );
  5995.            
  5996.            
  5997.             quantity = inv.GetItemQuantity( item );
  5998.             if( quantity > 1 )
  5999.             {
  6000.                 inv.SplitItem( item, quantity - 1 );
  6001.             }
  6002.            
  6003.             pam.OnSkillMutagenEquipped(item, slot, prevSkillColor);
  6004.             LogSkillColors("Mutagen <<" + inv.GetItemName(item) + ">> equipped to slot <<" + slot + ">>");
  6005.             LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
  6006.             LogSkillColors("");
  6007.            
  6008.             theGame.GetGuiManager().IgnoreNewItemNotifications( false );
  6009.         }
  6010.         else if(slot == EES_Gloves && HasWeaponDrawn(false))
  6011.         {
  6012.             PlayRuneword4FX(PW_Steel);
  6013.             PlayRuneword4FX(PW_Silver);
  6014.         }
  6015.        
  6016.         else if( ( slot == EES_Petard1 || slot == EES_Petard2 ) && inv.IsItemBomb( GetSelectedItemId() ) )
  6017.         {
  6018.             SelectQuickslotItem( slot );
  6019.         }
  6020.  
  6021.        
  6022.         if(inv.ItemHasAbility(item, 'MA_HtH'))
  6023.         {
  6024.             inv.GetItemContainedAbilities(item, containedAbilities);
  6025.             fistsID = inv.GetItemsByName('fists');
  6026.             dm = theGame.GetDefinitionsManager();
  6027.             for(i=0; i<containedAbilities.Size(); i+=1)
  6028.             {
  6029.                 if(dm.AbilityHasTag(containedAbilities[i], 'MA_HtH'))
  6030.                 {                  
  6031.                     inv.AddItemCraftedAbility(fistsID[0], containedAbilities[i], true);
  6032.                 }
  6033.             }
  6034.         }      
  6035.        
  6036.        
  6037.         if(inv.IsItemAnyArmor(item))
  6038.         {
  6039.             armorType = inv.GetArmorType(item);
  6040.             pam = (W3PlayerAbilityManager)abilityManager;
  6041.            
  6042.             if(armorType == EAT_Light)
  6043.             {
  6044.                 if(CanUseSkill(S_Perk_05))
  6045.                     pam.SetPerkArmorBonus(S_Perk_05);
  6046.             }
  6047.             else if(armorType == EAT_Medium)
  6048.             {
  6049.                 if(CanUseSkill(S_Perk_06))
  6050.                     pam.SetPerkArmorBonus(S_Perk_06);
  6051.             }
  6052.             else if(armorType == EAT_Heavy)
  6053.             {
  6054.                 if(CanUseSkill(S_Perk_07))
  6055.                     pam.SetPerkArmorBonus(S_Perk_07);
  6056.             }
  6057.         }
  6058.        
  6059.        
  6060.         UpdateItemSetBonuses( item, true );
  6061.                
  6062.        
  6063.         theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnItemEquipped );
  6064.    
  6065.        
  6066.         if(ShouldProcessTutorial('TutorialPotionCanEquip3'))
  6067.         {
  6068.             if(IsSlotPotionSlot(slot))
  6069.             {
  6070.                 tutStatePot = (W3TutorialManagerUIHandlerStatePotions)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  6071.                 if(tutStatePot)
  6072.                 {
  6073.                     tutStatePot.OnPotionEquipped(inv.GetItemName(item));
  6074.                 }
  6075.                
  6076.                 tutStateSecondPotionEquip = (W3TutorialManagerUIHandlerStateSecondPotionEquip)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  6077.                 if(tutStateSecondPotionEquip)
  6078.                 {
  6079.                     tutStateSecondPotionEquip.OnPotionEquipped(inv.GetItemName(item));
  6080.                 }
  6081.                
  6082.             }
  6083.         }
  6084.        
  6085.         if(ShouldProcessTutorial('TutorialFoodSelectTab'))
  6086.         {
  6087.             if( IsSlotPotionSlot(slot) && inv.IsItemFood(item))
  6088.             {
  6089.                 tutStateFood = (W3TutorialManagerUIHandlerStateFood)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  6090.                 if(tutStateFood)
  6091.                 {
  6092.                     tutStateFood.OnFoodEquipped();
  6093.                 }
  6094.             }
  6095.         }
  6096.        
  6097.        
  6098.        
  6099.        
  6100.         tagOfASet = inv.DetectTagOfASet(item);
  6101.         CheckForFullyArmedByTag(tagOfASet);
  6102.        
  6103.         return true;
  6104.     }
  6105.  
  6106.     private function CheckHairItem()
  6107.     {
  6108.         var ids : array<SItemUniqueId>;
  6109.         var i   : int;
  6110.         var itemName : name;
  6111.         var hairApplied : bool;
  6112.        
  6113.         ids = inv.GetItemsByCategory('hair');
  6114.        
  6115.         for(i=0; i<ids.Size(); i+= 1)
  6116.         {
  6117.             itemName = inv.GetItemName( ids[i] );
  6118.            
  6119.             if( itemName != 'Preview Hair' )
  6120.             {
  6121.                 if( hairApplied == false )
  6122.                 {
  6123.                     inv.MountItem( ids[i], false );
  6124.                     hairApplied = true;
  6125.                 }
  6126.                 else
  6127.                 {
  6128.                     inv.RemoveItem( ids[i], 1 );
  6129.                 }
  6130.                
  6131.             }
  6132.         }
  6133.        
  6134.         if( hairApplied == false )
  6135.         {
  6136.             ids = inv.AddAnItem('Half With Tail Hairstyle', 1, true, false);
  6137.             inv.MountItem( ids[0], false );
  6138.         }
  6139.        
  6140.     }
  6141.  
  6142.    
  6143.     timer function DelayedOnItemMount( dt : float, id : int )
  6144.     {
  6145.         var crossbowID : SItemUniqueId;
  6146.         var invent : CInventoryComponent;
  6147.        
  6148.         invent = GetInventory();
  6149.         if(!invent)
  6150.             return;
  6151.        
  6152.        
  6153.         GetItemEquippedOnSlot(EES_RangedWeapon, crossbowID);
  6154.                
  6155.         if(invent.IsIdValid(crossbowID))
  6156.         {
  6157.            
  6158.             rangedWeapon = ( Crossbow )(invent.GetItemEntityUnsafe(crossbowID) );
  6159.            
  6160.             if(rangedWeapon)
  6161.             {
  6162.                
  6163.                 RemoveTimer('DelayedOnItemMount');
  6164.             }
  6165.         }
  6166.         else
  6167.         {
  6168.            
  6169.             RemoveTimer('DelayedOnItemMount');
  6170.         }
  6171.     }
  6172.  
  6173.     public function GetHeldItems() : array<SItemUniqueId>
  6174.     {
  6175.         var items : array<SItemUniqueId>;
  6176.         var item : SItemUniqueId;
  6177.    
  6178.         if( inv.GetItemEquippedOnSlot(EES_SilverSword, item) && inv.IsItemHeld(item))
  6179.             items.PushBack(item);
  6180.            
  6181.         if( inv.GetItemEquippedOnSlot(EES_SteelSword, item) && inv.IsItemHeld(item))
  6182.             items.PushBack(item);
  6183.  
  6184.         if( inv.GetItemEquippedOnSlot(EES_RangedWeapon, item) && inv.IsItemHeld(item))
  6185.             items.PushBack(item);
  6186.  
  6187.         if( inv.GetItemEquippedOnSlot(EES_Quickslot1, item) && inv.IsItemHeld(item))
  6188.             items.PushBack(item);
  6189.  
  6190.         if( inv.GetItemEquippedOnSlot(EES_Quickslot2, item) && inv.IsItemHeld(item))
  6191.             items.PushBack(item);
  6192.  
  6193.         if( inv.GetItemEquippedOnSlot(EES_Petard1, item) && inv.IsItemHeld(item))
  6194.             items.PushBack(item);
  6195.  
  6196.         if( inv.GetItemEquippedOnSlot(EES_Petard2, item) && inv.IsItemHeld(item))
  6197.             items.PushBack(item);
  6198.  
  6199.         return items;          
  6200.     }
  6201.    
  6202.     public function MoveMutagenToSlot( item : SItemUniqueId, slotFrom : EEquipmentSlots, slotTo : EEquipmentSlots )
  6203.     {
  6204.         var pam : W3PlayerAbilityManager;
  6205.         var prevSkillColor : ESkillColor;
  6206.         var groupID : int;
  6207.        
  6208.         if( IsSlotSkillMutagen( slotTo ) )
  6209.         {  
  6210.             itemSlots[slotFrom] = GetInvalidUniqueId();
  6211.            
  6212.            
  6213.             groupID = pam.GetSkillGroupIdOfMutagenSlot(slotFrom);
  6214.             prevSkillColor = pam.GetSkillGroupColor(groupID);
  6215.             pam = (W3PlayerAbilityManager)abilityManager;
  6216.             pam.OnSkillMutagenUnequipped(item, slotFrom, prevSkillColor, true);
  6217.            
  6218.            
  6219.            
  6220.             EquipItemInGivenSlot( item, slotTo, false );
  6221.         }
  6222.     }
  6223.    
  6224.    
  6225.     public function UnequipItemFromSlot(slot : EEquipmentSlots, optional reequipped : bool) : bool
  6226.     {
  6227.         var item, bolts, id : SItemUniqueId;
  6228.         var items : array<SItemUniqueId>;
  6229.         var retBool : bool;
  6230.         var fistsID, bolt : array<SItemUniqueId>;
  6231.         var i, groupID : int;
  6232.         var pam : W3PlayerAbilityManager;
  6233.         var prevSkillColor : ESkillColor;
  6234.         var containedAbilities : array<name>;
  6235.         var dm : CDefinitionsManagerAccessor;
  6236.         var armorType : EArmorType;
  6237.         var isSwimming : bool;
  6238.         var hud                 : CR4ScriptedHud;
  6239.         var damagedItemModule   : CR4HudModuleDamagedItems;
  6240.        
  6241.         if(slot == EES_InvalidSlot || slot < 0 || slot > EnumGetMax('EEquipmentSlots') || !inv.IsIdValid(itemSlots[slot]))
  6242.             return false;
  6243.            
  6244.        
  6245.         if(IsSlotSkillMutagen(slot))
  6246.         {
  6247.            
  6248.             pam = (W3PlayerAbilityManager)abilityManager;
  6249.             groupID = pam.GetSkillGroupIdOfMutagenSlot(slot);
  6250.             prevSkillColor = pam.GetSkillGroupColor(groupID);
  6251.         }
  6252.        
  6253.        
  6254.         if(slot == EES_SilverSword  || slot == EES_SteelSword)
  6255.         {
  6256.             PauseOilBuffs( slot == EES_SteelSword );
  6257.         }
  6258.            
  6259.         item = itemSlots[slot];
  6260.         itemSlots[slot] = GetInvalidUniqueId();
  6261.        
  6262.        
  6263.         if(inv.ItemHasTag( item, 'PhantomWeapon' ) && GetPhantomWeaponMgr())
  6264.         {
  6265.             DestroyPhantomWeaponMgr();
  6266.         }
  6267.        
  6268.        
  6269.        
  6270.        
  6271.         if( slot == EES_SilverSword && inv.ItemHasTag( item, 'Aerondight' ) )
  6272.         {
  6273.             RemoveBuff( EET_Aerondight );
  6274.         }
  6275.        
  6276.        
  6277.         if(slot == EES_RangedWeapon)
  6278.         {
  6279.            
  6280.             this.OnRangedForceHolster( true, true );
  6281.             rangedWeapon.ClearDeployedEntity(true);
  6282.             rangedWeapon = NULL;
  6283.        
  6284.            
  6285.             if(GetItemEquippedOnSlot(EES_Bolt, bolts))
  6286.             {
  6287.                 if(inv.ItemHasTag(bolts, theGame.params.TAG_INFINITE_AMMO))
  6288.                 {
  6289.                     inv.RemoveItem(bolts, inv.GetItemQuantity(bolts) );
  6290.                 }
  6291.             }
  6292.         }
  6293.         else if(IsSlotSkillMutagen(slot))
  6294.         {          
  6295.             pam.OnSkillMutagenUnequipped(item, slot, prevSkillColor);
  6296.             LogSkillColors("Mutagen <<" + inv.GetItemName(item) + ">> unequipped from slot <<" + slot + ">>");
  6297.             LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
  6298.             LogSkillColors("");
  6299.         }
  6300.        
  6301.        
  6302.         if(currentlyEquipedItem == item)
  6303.         {
  6304.             currentlyEquipedItem = GetInvalidUniqueId();
  6305.             RaiseEvent('ForcedUsableItemUnequip');
  6306.         }
  6307.         if(currentlyEquipedItemL == item)
  6308.         {
  6309.             if ( currentlyUsedItemL )
  6310.             {
  6311.                 currentlyUsedItemL.OnHidden( this );
  6312.             }
  6313.             HideUsableItem ( true );
  6314.         }
  6315.                
  6316.        
  6317.         if( !IsSlotPotionMutagen(slot) )
  6318.         {
  6319.             GetInventory().UnmountItem(item, true);
  6320.         }
  6321.        
  6322.         retBool = true;
  6323.                
  6324.        
  6325.         if(IsAnyItemEquippedOnSlot(EES_RangedWeapon) && slot == EES_Bolt)
  6326.         {          
  6327.             if(inv.ItemHasTag(item, theGame.params.TAG_INFINITE_AMMO))
  6328.             {
  6329.                
  6330.                 inv.RemoveItem(item, inv.GetItemQuantityByName( inv.GetItemName(item) ) );
  6331.             }
  6332.             else if (!reequipped)
  6333.             {
  6334.                
  6335.                 AddAndEquipInfiniteBolt();
  6336.             }
  6337.         }
  6338.        
  6339.        
  6340.         if(slot == EES_SilverSword  || slot == EES_SteelSword)
  6341.         {
  6342.             OnEquipMeleeWeapon(PW_None, true);         
  6343.         }
  6344.        
  6345.         if(  GetSelectedItemId() == item )
  6346.         {
  6347.             ClearSelectedItemId();
  6348.         }
  6349.        
  6350.         if(inv.IsItemBody(item))
  6351.         {
  6352.             retBool = true;
  6353.         }      
  6354.        
  6355.         if(retBool && !reequipped)
  6356.         {
  6357.             theTelemetry.LogWithLabelAndValue( TE_INV_ITEM_UNEQUIPPED, inv.GetItemName(item), slot );
  6358.            
  6359.            
  6360.             if(slot == EES_SteelSword && !IsAnyItemEquippedOnSlot(EES_SilverSword))
  6361.             {
  6362.                 RemoveBuff(EET_EnhancedWeapon);
  6363.             }
  6364.             else if(slot == EES_SilverSword && !IsAnyItemEquippedOnSlot(EES_SteelSword))
  6365.             {
  6366.                 RemoveBuff(EET_EnhancedWeapon);
  6367.             }
  6368.             else if(inv.IsItemAnyArmor(item))
  6369.             {
  6370.                 if( !IsAnyItemEquippedOnSlot(EES_Armor) && !IsAnyItemEquippedOnSlot(EES_Gloves) && !IsAnyItemEquippedOnSlot(EES_Boots) && !IsAnyItemEquippedOnSlot(EES_Pants))
  6371.                     RemoveBuff(EET_EnhancedArmor);
  6372.             }
  6373.         }
  6374.        
  6375.        
  6376.         if(inv.ItemHasAbility(item, 'MA_HtH'))
  6377.         {
  6378.             inv.GetItemContainedAbilities(item, containedAbilities);
  6379.             fistsID = inv.GetItemsByName('fists');
  6380.             dm = theGame.GetDefinitionsManager();
  6381.             for(i=0; i<containedAbilities.Size(); i+=1)
  6382.             {
  6383.                 if(dm.AbilityHasTag(containedAbilities[i], 'MA_HtH'))
  6384.                 {
  6385.                     inv.RemoveItemCraftedAbility(fistsID[0], containedAbilities[i]);
  6386.                 }
  6387.             }
  6388.         }
  6389.        
  6390.        
  6391.         if(inv.IsItemAnyArmor(item))
  6392.         {
  6393.             armorType = inv.GetArmorType(item);
  6394.             pam = (W3PlayerAbilityManager)abilityManager;
  6395.            
  6396.             if(CanUseSkill(S_Perk_05) && (armorType == EAT_Light || GetCharacterStats().HasAbility('Glyphword 2 _Stats', true) || inv.ItemHasAbility(item, 'Glyphword 2 _Stats')))
  6397.             {
  6398.                 pam.SetPerkArmorBonus(S_Perk_05);
  6399.             }
  6400.             if(CanUseSkill(S_Perk_06) && (armorType == EAT_Medium || GetCharacterStats().HasAbility('Glyphword 3 _Stats', true) || inv.ItemHasAbility(item, 'Glyphword 3 _Stats')) )
  6401.             {
  6402.                 pam.SetPerkArmorBonus(S_Perk_06);
  6403.             }
  6404.             if(CanUseSkill(S_Perk_07) && (armorType == EAT_Heavy || GetCharacterStats().HasAbility('Glyphword 4 _Stats', true) || inv.ItemHasAbility(item, 'Glyphword 4 _Stats')) )
  6405.             {
  6406.                 pam.SetPerkArmorBonus(S_Perk_07);
  6407.             }
  6408.         }
  6409.        
  6410.        
  6411.         UpdateItemSetBonuses( item, false );
  6412.        
  6413.        
  6414.         if( inv.ItemHasTag( item, theGame.params.ITEM_SET_TAG_BONUS ) && !IsSetBonusActive( EISB_RedWolf_2 ) )
  6415.         {
  6416.             SkillReduceBombAmmoBonus();
  6417.         }
  6418.  
  6419.         if( slot == EES_Gloves )
  6420.         {
  6421.             thePlayer.DestroyEffect('runeword_4');
  6422.         }
  6423.        
  6424.        
  6425.         hud = (CR4ScriptedHud)theGame.GetHud();
  6426.         if ( hud )
  6427.         {
  6428.             damagedItemModule = hud.GetDamagedItemModule();
  6429.             if ( damagedItemModule )
  6430.             {
  6431.                 damagedItemModule.OnItemUnequippedFromSlot( slot );
  6432.             }
  6433.         }
  6434.        
  6435.        
  6436.         theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnItemEquipped );
  6437.        
  6438.         return retBool;
  6439.     }
  6440.        
  6441.     public function UnequipItem(item : SItemUniqueId) : bool
  6442.     {
  6443.         if(!inv.IsIdValid(item))
  6444.             return false;
  6445.        
  6446.         return UnequipItemFromSlot( itemSlots.FindFirst(item) );
  6447.     }
  6448.    
  6449.     public function DropItem( item : SItemUniqueId, quantity : int ) : bool
  6450.     {
  6451.         if(!inv.IsIdValid(item))
  6452.             return false;
  6453.         if(IsItemEquipped(item))
  6454.             return UnequipItem(item);
  6455.        
  6456.         return true;
  6457.     }  
  6458.    
  6459.    
  6460.     public function IsItemEquippedByName(itemName : name) : bool
  6461.     {
  6462.         var i : int;
  6463.    
  6464.         for(i=0; i<itemSlots.Size(); i+=1)
  6465.             if(inv.GetItemName(itemSlots[i]) == itemName)
  6466.                 return true;
  6467.  
  6468.         return false;
  6469.     }
  6470.  
  6471.    
  6472.     public function IsItemEquippedByCategoryName(categoryName : name) : bool
  6473.     {
  6474.         var i : int;
  6475.    
  6476.         for(i=0; i<itemSlots.Size(); i+=1)
  6477.             if(inv.GetItemCategory(itemSlots[i]) == categoryName)
  6478.                 return true;
  6479.                
  6480.         return false;
  6481.     }
  6482.    
  6483.     public function GetMaxRunEncumbrance(out usesHorseBonus : bool) : float
  6484.     {
  6485.         var value : float;
  6486.        
  6487.         value = CalculateAttributeValue(GetHorseManager().GetHorseAttributeValue('encumbrance', false));
  6488.         usesHorseBonus = (value > 0);
  6489.         value += CalculateAttributeValue( GetAttributeValue('encumbrance') );
  6490.        
  6491.         return value;
  6492.     }
  6493.        
  6494.     public function GetEncumbrance() : float
  6495.     {
  6496.         var i: int;
  6497.         var encumbrance : float;
  6498.         var items : array<SItemUniqueId>;
  6499.         var inve : CInventoryComponent;
  6500.    
  6501.         inve = GetInventory();         
  6502.         inve.GetAllItems(items);
  6503.  
  6504.         for(i=0; i<items.Size(); i+=1)
  6505.         {
  6506.             encumbrance += inve.GetItemEncumbrance( items[i] );
  6507.            
  6508.            
  6509.            
  6510.         }      
  6511.         return encumbrance;
  6512.     }
  6513.    
  6514.    
  6515.    
  6516.     public function StartInvUpdateTransaction():void
  6517.     {
  6518.         invUpdateTransaction = true;
  6519.     }
  6520.    
  6521.     public function FinishInvUpdateTransaction():void
  6522.     {
  6523.         invUpdateTransaction = false;
  6524.        
  6525.        
  6526.        
  6527.         UpdateEncumbrance();
  6528.     }
  6529.    
  6530.    
  6531.     public function UpdateEncumbrance()
  6532.     {
  6533.         var temp : bool;
  6534.        
  6535.         if (invUpdateTransaction)
  6536.         {
  6537.            
  6538.             return;
  6539.         }
  6540.        
  6541.        
  6542.        
  6543.         if ( GetEncumbrance() >= (GetMaxRunEncumbrance(temp) + 1) )
  6544.         {
  6545.             if( !HasBuff(EET_OverEncumbered) && FactsQuerySum( "DEBUG_EncumbranceBoy" ) == 0 )
  6546.             {
  6547.                 AddEffectDefault(EET_OverEncumbered, NULL, "OverEncumbered");
  6548.             }
  6549.         }
  6550.         else if(HasBuff(EET_OverEncumbered))
  6551.         {
  6552.             RemoveAllBuffsOfType(EET_OverEncumbered);
  6553.         }
  6554.     }
  6555.    
  6556.     public final function GetSkillGroupIDFromIndex(idx : int) : int
  6557.     {
  6558.         var pam : W3PlayerAbilityManager;
  6559.        
  6560.         pam = (W3PlayerAbilityManager)abilityManager;
  6561.         if(pam && pam.IsInitialized())
  6562.             return pam.GetSkillGroupIDFromIndex(idx);
  6563.            
  6564.         return -1;
  6565.     }
  6566.    
  6567.     public final function GetSkillGroupColor(groupID : int) : ESkillColor
  6568.     {
  6569.         var pam : W3PlayerAbilityManager;
  6570.        
  6571.         pam = (W3PlayerAbilityManager)abilityManager;
  6572.         if(pam && pam.IsInitialized())
  6573.             return pam.GetSkillGroupColor(groupID);
  6574.            
  6575.         return SC_None;
  6576.     }
  6577.    
  6578.     public final function GetSkillGroupsCount() : int
  6579.     {
  6580.         var pam : W3PlayerAbilityManager;
  6581.        
  6582.         pam = (W3PlayerAbilityManager)abilityManager;
  6583.         if(pam && pam.IsInitialized())
  6584.             return pam.GetSkillGroupsCount();
  6585.            
  6586.         return 0;
  6587.     }
  6588.    
  6589.    
  6590.    
  6591.    
  6592.    
  6593.    
  6594.    
  6595.    
  6596.     function CycleSelectSign( bIsCyclingLeft : bool ) : ESignType
  6597.     {
  6598.         var signOrder : array<ESignType>;
  6599.         var i : int;
  6600.        
  6601.         signOrder.PushBack( ST_Yrden );
  6602.         signOrder.PushBack( ST_Quen );
  6603.         signOrder.PushBack( ST_Igni );
  6604.         signOrder.PushBack( ST_Axii );
  6605.         signOrder.PushBack( ST_Aard );
  6606.            
  6607.         for( i = 0; i < signOrder.Size(); i += 1 )
  6608.             if( signOrder[i] == equippedSign )
  6609.                 break;
  6610.        
  6611.         if(bIsCyclingLeft)
  6612.             return signOrder[ (4 + i) % 5 ];   
  6613.         else
  6614.             return signOrder[ (6 + i) % 5 ];
  6615.     }
  6616.    
  6617.     function ToggleNextSign()
  6618.     {
  6619.         SetEquippedSign(CycleSelectSign( false ));
  6620.         FactsAdd("SignToggled", 1, 1);
  6621.     }
  6622.    
  6623.     function TogglePreviousSign()
  6624.     {
  6625.         SetEquippedSign(CycleSelectSign( true ));
  6626.         FactsAdd("SignToggled", 1, 1);
  6627.     }
  6628.    
  6629.     function ProcessSignEvent( eventName : name ) : bool
  6630.     {
  6631.         if( currentlyCastSign != ST_None && signs[currentlyCastSign].entity)
  6632.         {
  6633.             return signs[currentlyCastSign].entity.OnProcessSignEvent( eventName );
  6634.         }
  6635.        
  6636.         return false;
  6637.     }
  6638.    
  6639.     var findActorTargetTimeStamp : float;
  6640.     var pcModeChanneledSignTimeStamp    : float;
  6641.     event OnProcessCastingOrientation( isContinueCasting : bool )
  6642.     {
  6643.         var customOrientationTarget : EOrientationTarget;
  6644.         var checkHeading            : float;
  6645.         var rotHeading              : float;
  6646.         var playerToHeadingDist     : float;
  6647.         var slideTargetActor        : CActor;
  6648.         var newLockTarget           : CActor;
  6649.        
  6650.         var enableNoTargetOrientation   : bool;
  6651.        
  6652.         var currTime : float;
  6653.        
  6654.         enableNoTargetOrientation = true;
  6655.         if ( GetDisplayTarget() && this.IsDisplayTargetTargetable() )
  6656.         {
  6657.             enableNoTargetOrientation = false;
  6658.             if ( theInput.GetActionValue( 'CastSignHold' ) > 0 || this.IsCurrentSignChanneled() )
  6659.             {
  6660.                 if ( IsPCModeEnabled() )
  6661.                 {
  6662.                     if ( EngineTimeToFloat( theGame.GetEngineTime() ) >  pcModeChanneledSignTimeStamp + 1.f )
  6663.                         enableNoTargetOrientation = true;
  6664.                 }
  6665.                 else
  6666.                 {
  6667.                     if ( GetCurrentlyCastSign() == ST_Igni || GetCurrentlyCastSign() == ST_Axii )
  6668.                     {
  6669.                         slideTargetActor = (CActor)GetDisplayTarget();
  6670.                         if ( slideTargetActor
  6671.                             && ( !slideTargetActor.GetGameplayVisibility() || !CanBeTargetedIfSwimming( slideTargetActor ) || !slideTargetActor.IsAlive() ) )
  6672.                         {
  6673.                             SetSlideTarget( NULL );
  6674.                             if ( ProcessLockTarget() )
  6675.                                 slideTargetActor = (CActor)slideTarget;
  6676.                         }              
  6677.                        
  6678.                         if ( !slideTargetActor )
  6679.                         {
  6680.                             LockToTarget( false );
  6681.                             enableNoTargetOrientation = true;
  6682.                         }
  6683.                         else if ( IsThreat( slideTargetActor ) || GetCurrentlyCastSign() == ST_Axii )
  6684.                             LockToTarget( true );
  6685.                         else
  6686.                         {
  6687.                             LockToTarget( false );
  6688.                             enableNoTargetOrientation = true;
  6689.                         }
  6690.                     }
  6691.                 }
  6692.             }
  6693.  
  6694.             if ( !enableNoTargetOrientation )
  6695.             {          
  6696.                 customOrientationTarget = OT_Actor;
  6697.             }
  6698.         }
  6699.        
  6700.         if ( enableNoTargetOrientation )
  6701.         {
  6702.             if ( GetPlayerCombatStance() == PCS_AlertNear && theInput.GetActionValue( 'CastSignHold' ) > 0 )
  6703.             {
  6704.                 if ( GetDisplayTarget() && !slideTargetActor )
  6705.                 {
  6706.                     currTime = EngineTimeToFloat( theGame.GetEngineTime() );
  6707.                     if ( currTime > findActorTargetTimeStamp + 1.5f )
  6708.                     {
  6709.                         findActorTargetTimeStamp = currTime;
  6710.                        
  6711.                         newLockTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, 0.f, true );
  6712.                        
  6713.                         if ( newLockTarget && IsThreat( newLockTarget ) && IsCombatMusicEnabled() )
  6714.                         {
  6715.                             SetTarget( newLockTarget, true );
  6716.                             SetMoveTargetChangeAllowed( true );
  6717.                             SetMoveTarget( newLockTarget );
  6718.                             SetMoveTargetChangeAllowed( false );
  6719.                             SetSlideTarget( newLockTarget );                           
  6720.                         }  
  6721.                     }
  6722.                 }
  6723.                 else
  6724.                     ProcessLockTarget();
  6725.             }
  6726.            
  6727.             if ( wasBRAxisPushed )
  6728.                 customOrientationTarget = OT_CameraOffset;
  6729.             else
  6730.             {
  6731.                 if ( !lastAxisInputIsMovement || theInput.LastUsedPCInput() )
  6732.                     customOrientationTarget = OT_CameraOffset;
  6733.                 else if ( theInput.GetActionValue( 'CastSignHold' ) > 0 )
  6734.                 {
  6735.                     if ( GetOrientationTarget() == OT_CameraOffset )
  6736.                         customOrientationTarget = OT_CameraOffset;
  6737.                     else if ( GetPlayerCombatStance() == PCS_AlertNear || GetPlayerCombatStance() == PCS_Guarded )
  6738.                         customOrientationTarget = OT_CameraOffset;
  6739.                     else
  6740.                         customOrientationTarget = OT_Player;   
  6741.                 }
  6742.                 else
  6743.                     customOrientationTarget = OT_CustomHeading;
  6744.             }          
  6745.         }      
  6746.        
  6747.         if ( GetCurrentlyCastSign() == ST_Quen )
  6748.         {
  6749.             if ( theInput.LastUsedPCInput() )
  6750.             {
  6751.                 customOrientationTarget = OT_Camera;
  6752.             }
  6753.             else if ( IsCurrentSignChanneled() )
  6754.             {
  6755.                 if ( bLAxisReleased )
  6756.                     customOrientationTarget = OT_Player;
  6757.                 else
  6758.                     customOrientationTarget = OT_Camera;
  6759.             }
  6760.             else
  6761.                 customOrientationTarget = OT_Player;
  6762.         }  
  6763.        
  6764.         if ( GetCurrentlyCastSign() == ST_Axii && IsCurrentSignChanneled() )
  6765.         {  
  6766.             if ( slideTarget && (CActor)slideTarget )
  6767.             {
  6768.                 checkHeading = VecHeading( slideTarget.GetWorldPosition() - this.GetWorldPosition() );
  6769.                 rotHeading = checkHeading;
  6770.                 playerToHeadingDist = AngleDistance( GetHeading(), checkHeading );
  6771.                
  6772.                 if ( playerToHeadingDist > 45 )
  6773.                     SetCustomRotation( 'ChanneledSignAxii', rotHeading, 0.0, 0.5, false );
  6774.                 else if ( playerToHeadingDist < -45 )
  6775.                     SetCustomRotation( 'ChanneledSignAxii', rotHeading, 0.0, 0.5, false );                 
  6776.             }
  6777.             else
  6778.             {
  6779.                 checkHeading = VecHeading( theCamera.GetCameraDirection() );
  6780.                 rotHeading = GetHeading();
  6781.                 playerToHeadingDist = AngleDistance( GetHeading(), checkHeading );
  6782.                
  6783.                 if ( playerToHeadingDist > 45 )
  6784.                     SetCustomRotation( 'ChanneledSignAxii', rotHeading - 22.5, 0.0, 0.5, false );
  6785.                 else if ( playerToHeadingDist < -45 )
  6786.                     SetCustomRotation( 'ChanneledSignAxii', rotHeading + 22.5, 0.0, 0.5, false );              
  6787.             }
  6788.         }      
  6789.            
  6790.         if ( IsActorLockedToTarget() )
  6791.             customOrientationTarget = OT_Actor;
  6792.        
  6793.         AddCustomOrientationTarget( customOrientationTarget, 'Signs' );
  6794.        
  6795.         if ( customOrientationTarget == OT_CustomHeading )
  6796.             SetOrientationTargetCustomHeading( GetCombatActionHeading(), 'Signs' );        
  6797.     }
  6798.    
  6799.     event OnRaiseSignEvent()
  6800.     {
  6801.         var newTarget : CActor;
  6802.    
  6803.         if ( ( !IsCombatMusicEnabled() && !CanAttackWhenNotInCombat( EBAT_CastSign, false, newTarget ) ) || ( IsOnBoat() && !IsCombatMusicEnabled() ) )
  6804.         {      
  6805.             if ( CastSignFriendly() )
  6806.                 return true;
  6807.         }
  6808.         else
  6809.         {
  6810.             RaiseEvent('CombatActionFriendlyEnd');
  6811.             SetBehaviorVariable( 'SignNum', (int)equippedSign );
  6812.             SetBehaviorVariable( 'combatActionType', (int)CAT_CastSign );
  6813.  
  6814.             if ( IsPCModeEnabled() )
  6815.                 pcModeChanneledSignTimeStamp = EngineTimeToFloat( theGame.GetEngineTime() );
  6816.        
  6817.             if( RaiseForceEvent('CombatAction') )
  6818.             {
  6819.                 OnCombatActionStart();
  6820.                 findActorTargetTimeStamp = EngineTimeToFloat( theGame.GetEngineTime() );
  6821.                 theTelemetry.LogWithValueStr(TE_FIGHT_PLAYER_USE_SIGN, SignEnumToString( equippedSign ));
  6822.                 return true;
  6823.             }
  6824.         }
  6825.        
  6826.         return false;
  6827.     }
  6828.    
  6829.     function CastSignFriendly() : bool
  6830.     {
  6831.         var actor : CActor;
  6832.    
  6833.         SetBehaviorVariable( 'combatActionTypeForOverlay', (int)CAT_CastSign );        
  6834.         if ( RaiseCombatActionFriendlyEvent() )
  6835.         {
  6836.                        
  6837.             return true;
  6838.         }  
  6839.        
  6840.         return false;
  6841.     }
  6842.    
  6843.     function CastSign() : bool
  6844.     {
  6845.         var equippedSignStr : string;
  6846.         var newSignEnt : W3SignEntity;
  6847.         var spawnPos : Vector;
  6848.         var slotMatrix : Matrix;
  6849.         var target : CActor;
  6850.        
  6851.         if ( IsInAir() )
  6852.         {
  6853.             return false;
  6854.         }
  6855.        
  6856.         AddTemporarySkills();
  6857.        
  6858.        
  6859.        
  6860.         if(equippedSign == ST_Aard)
  6861.         {
  6862.             CalcEntitySlotMatrix('l_weapon', slotMatrix);
  6863.             spawnPos = MatrixGetTranslation(slotMatrix);
  6864.         }
  6865.         else
  6866.         {
  6867.             spawnPos = GetWorldPosition();
  6868.         }
  6869.        
  6870.         if( equippedSign == ST_Aard || equippedSign == ST_Igni )
  6871.         {
  6872.             target = GetTarget();
  6873.             if(target)
  6874.                 target.SignalGameplayEvent( 'DodgeSign' );
  6875.         }
  6876.  
  6877.         m_TriggerEffectDisablePending = true;
  6878.         m_TriggerEffectDisableTTW = 0.3;
  6879.        
  6880.         newSignEnt = (W3SignEntity)theGame.CreateEntity( signs[equippedSign].template, spawnPos, GetWorldRotation() );
  6881.         return newSignEnt.Init( signOwner, signs[equippedSign].entity );
  6882.     }
  6883.    
  6884.    
  6885.     private function HAX_SignToThrowItemRestore()
  6886.     {
  6887.         var action : SInputAction;
  6888.        
  6889.         action.value = theInput.GetActionValue('ThrowItemHold');
  6890.         action.lastFrameValue = 0;
  6891.        
  6892.         if(IsPressed(action) && CanSetupCombatAction_Throw())
  6893.         {
  6894.             if(inv.IsItemBomb(selectedItemId))
  6895.             {
  6896.                 BombThrowStart();
  6897.             }
  6898.             else
  6899.             {
  6900.                 UsableItemStart();
  6901.             }
  6902.            
  6903.             SetThrowHold( true );
  6904.         }
  6905.     }
  6906.    
  6907.     event OnCFMCameraZoomFail(){}
  6908.        
  6909.    
  6910.  
  6911.     public final function GetDrunkMutagens( optional sourceName : string ) : array<CBaseGameplayEffect>
  6912.     {
  6913.         return effectManager.GetDrunkMutagens( sourceName );
  6914.     }
  6915.    
  6916.     public final function GetPotionBuffs() : array<CBaseGameplayEffect>
  6917.     {
  6918.         return effectManager.GetPotionBuffs();
  6919.     }
  6920.    
  6921.     public final function RecalcPotionsDurations()
  6922.     {
  6923.         var i : int;
  6924.         var buffs : array<CBaseGameplayEffect>;
  6925.        
  6926.         buffs = GetPotionBuffs();
  6927.         for(i=0; i<buffs.Size(); i+=1)
  6928.         {
  6929.             buffs[i].RecalcPotionDuration();
  6930.         }
  6931.     }
  6932.  
  6933.     public function StartFrenzy()
  6934.     {
  6935.         var ratio, duration : float;
  6936.         var skillLevel : int;
  6937.    
  6938.         isInFrenzy = true;
  6939.         skillLevel = GetSkillLevel(S_Alchemy_s16);
  6940.         ratio = 0.48f - skillLevel * CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s16, 'slowdown_ratio', false, true));
  6941.         duration = skillLevel * CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s16, 'slowdown_duration', false, true));
  6942.    
  6943.         theGame.SetTimeScale(ratio, theGame.GetTimescaleSource(ETS_SkillFrenzy), theGame.GetTimescalePriority(ETS_SkillFrenzy) );
  6944.         AddTimer('SkillFrenzyFinish', duration * ratio, , , , true);
  6945.     }
  6946.    
  6947.     timer function SkillFrenzyFinish(dt : float, optional id : int)
  6948.     {      
  6949.         theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_SkillFrenzy) );
  6950.         isInFrenzy = false;
  6951.     }
  6952.    
  6953.     public function GetToxicityDamageThreshold() : float
  6954.     {
  6955.         var ret : float;
  6956.        
  6957.         ret = theGame.params.TOXICITY_DAMAGE_THRESHOLD;
  6958.        
  6959.         if(CanUseSkill(S_Alchemy_s01))
  6960.             ret += CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s01, 'threshold', false, true)) * GetSkillLevel(S_Alchemy_s01);
  6961.        
  6962.         return ret;
  6963.     }
  6964.    
  6965.    
  6966.    
  6967.     public final function AddToxicityOffset( val : float)
  6968.     {
  6969.         ((W3PlayerAbilityManager)abilityManager).AddToxicityOffset(val);       
  6970.     }
  6971.    
  6972.     public final function SetToxicityOffset( val : float)
  6973.     {
  6974.         ((W3PlayerAbilityManager)abilityManager).SetToxicityOffset(val);
  6975.     }
  6976.    
  6977.     public final function RemoveToxicityOffset( val : float)
  6978.     {
  6979.         ((W3PlayerAbilityManager)abilityManager).RemoveToxicityOffset(val);    
  6980.     }
  6981.    
  6982.    
  6983.     public final function CalculatePotionDuration(item : SItemUniqueId, isMutagenPotion : bool, optional itemName : name) : float
  6984.     {
  6985.         var duration, skillPassiveMod, mutagenSkillMod : float;
  6986.         var val, min, max : SAbilityAttributeValue;
  6987.        
  6988.        
  6989.         if(inv.IsIdValid(item))
  6990.         {
  6991.             duration = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'duration'));           
  6992.         }
  6993.         else
  6994.         {
  6995.             theGame.GetDefinitionsManager().GetItemAttributeValueNoRandom(itemName, true, 'duration', min, max);
  6996.             duration = CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  6997.         }
  6998.            
  6999.         skillPassiveMod = CalculateAttributeValue(GetAttributeValue('potion_duration'));
  7000.        
  7001.         if(isMutagenPotion && CanUseSkill(S_Alchemy_s14))
  7002.         {
  7003.             val = GetSkillAttributeValue(S_Alchemy_s14, 'duration', false, true);
  7004.             mutagenSkillMod = val.valueMultiplicative * GetSkillLevel(S_Alchemy_s14);
  7005.         }
  7006.        
  7007.         duration = duration * (1 + skillPassiveMod + mutagenSkillMod);
  7008.        
  7009.        
  7010.         if( IsSetBonusActive( EISB_Netflix_1 ) )
  7011.         {
  7012.             duration += (duration * (amountOfSetPiecesEquipped[ EIST_Netflix ] * 7 )) / 100 ;
  7013.         }
  7014.        
  7015.         return duration;
  7016.     }
  7017.    
  7018.     public function ToxicityLowEnoughToDrinkPotion( slotid : EEquipmentSlots, optional itemId : SItemUniqueId ) : bool
  7019.     {
  7020.         var item                : SItemUniqueId;
  7021.         var maxTox              : float;
  7022.         var potionToxicity      : float;
  7023.         var toxicityOffset      : float;
  7024.         var effectType          : EEffectType;
  7025.         var customAbilityName   : name;
  7026.        
  7027.         if(itemId != GetInvalidUniqueId())
  7028.             item = itemId;
  7029.         else
  7030.             item = itemSlots[slotid];
  7031.        
  7032.         inv.GetPotionItemBuffData(item, effectType, customAbilityName);
  7033.         maxTox = abilityManager.GetStatMax(BCS_Toxicity);
  7034.         potionToxicity = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity'));
  7035.         toxicityOffset = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity_offset'));
  7036.        
  7037.         if(effectType != EET_WhiteHoney)
  7038.         {
  7039.             if(abilityManager.GetStat(BCS_Toxicity, false) + potionToxicity + toxicityOffset > maxTox )
  7040.             {
  7041.                 return false;
  7042.             }
  7043.         }
  7044.        
  7045.         return true;
  7046.     }
  7047.    
  7048.     public final function HasFreeToxicityToDrinkPotion( item : SItemUniqueId, effectType : EEffectType, out finalPotionToxicity : float ) : bool
  7049.     {
  7050.         var i : int;
  7051.         var maxTox, toxicityOffset, adrenaline : float;
  7052.         var costReduction : SAbilityAttributeValue;
  7053.        
  7054.        
  7055.         if( effectType == EET_WhiteHoney )
  7056.         {
  7057.             return true;
  7058.         }
  7059.        
  7060.        
  7061.         maxTox = abilityManager.GetStatMax(BCS_Toxicity);
  7062.         finalPotionToxicity = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity'));
  7063.         toxicityOffset = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity_offset'));
  7064.        
  7065.        
  7066.         if(CanUseSkill(S_Perk_13))
  7067.         {
  7068.             costReduction = GetSkillAttributeValue(S_Perk_13, 'cost_reduction', false, true);
  7069.             adrenaline = FloorF(GetStat(BCS_Focus));
  7070.             costReduction = costReduction * adrenaline;
  7071.             finalPotionToxicity = (finalPotionToxicity - costReduction.valueBase) * (1 - costReduction.valueMultiplicative) - costReduction.valueAdditive;
  7072.             finalPotionToxicity = MaxF(0.f, finalPotionToxicity);
  7073.         }
  7074.        
  7075.        
  7076.         if(abilityManager.GetStat(BCS_Toxicity, false) + finalPotionToxicity + toxicityOffset > maxTox )
  7077.         {
  7078.             return false;
  7079.         }
  7080.        
  7081.         return true;
  7082.     }
  7083.    
  7084.     public function DrinkPreparedPotion( slotid : EEquipmentSlots, optional itemId : SItemUniqueId )
  7085.     {  
  7086.         var potParams : W3PotionParams;
  7087.         var potionParams : SCustomEffectParams;
  7088.         var factPotionParams : W3Potion_Fact_Params;
  7089.         var adrenaline, hpGainValue, duration, finalPotionToxicity : float;
  7090.         var ret : EEffectInteract;
  7091.         var effectType : EEffectType;
  7092.         var item : SItemUniqueId;
  7093.         var customAbilityName, factId : name;
  7094.         var atts : array<name>;
  7095.         var i : int;
  7096.         var mutagenParams : W3MutagenBuffCustomParams;
  7097.        
  7098.        
  7099.         if(itemId != GetInvalidUniqueId())
  7100.             item = itemId;
  7101.         else
  7102.             item = itemSlots[slotid];
  7103.        
  7104.        
  7105.         if(!inv.IsIdValid(item))
  7106.             return;
  7107.            
  7108.        
  7109.         if( inv.SingletonItemGetAmmo(item) == 0 )
  7110.             return;
  7111.            
  7112.        
  7113.         inv.GetPotionItemBuffData(item, effectType, customAbilityName);
  7114.            
  7115.        
  7116.         if( !HasFreeToxicityToDrinkPotion( item, effectType, finalPotionToxicity ) )
  7117.         {
  7118.             return;
  7119.         }
  7120.                
  7121.        
  7122.         if(effectType == EET_Fact)
  7123.         {
  7124.             inv.GetItemAttributes(item, atts);
  7125.            
  7126.             for(i=0; i<atts.Size(); i+=1)
  7127.             {
  7128.                 if(StrBeginsWith(NameToString(atts[i]), "fact_"))
  7129.                 {
  7130.                     factId = atts[i];
  7131.                     break;
  7132.                 }
  7133.             }
  7134.            
  7135.             factPotionParams = new W3Potion_Fact_Params in theGame;
  7136.             factPotionParams.factName = factId;
  7137.             factPotionParams.potionItemName = inv.GetItemName(item);
  7138.            
  7139.             potionParams.buffSpecificParams = factPotionParams;
  7140.         }
  7141.        
  7142.         else if(inv.ItemHasTag( item, 'Mutagen' ))
  7143.         {
  7144.             mutagenParams = new W3MutagenBuffCustomParams in theGame;
  7145.             mutagenParams.toxicityOffset = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity_offset'));
  7146.             mutagenParams.potionItemName = inv.GetItemName(item);
  7147.            
  7148.             finalPotionToxicity += 0.001f;
  7149.            
  7150.             potionParams.buffSpecificParams = mutagenParams;
  7151.            
  7152.             if( IsMutationActive( EPMT_Mutation10 ) && !HasBuff( EET_Mutation10 ) )
  7153.             {
  7154.                 AddEffectDefault( EET_Mutation10, this, "Mutation 10" );
  7155.             }
  7156.         }
  7157.        
  7158.         else
  7159.         {
  7160.             potParams = new W3PotionParams in theGame;
  7161.             potParams.potionItemName = inv.GetItemName(item);
  7162.            
  7163.             potionParams.buffSpecificParams = potParams;
  7164.         }
  7165.    
  7166.        
  7167.         duration = CalculatePotionDuration(item, inv.ItemHasTag( item, 'Mutagen' ));       
  7168.  
  7169.        
  7170.         potionParams.effectType = effectType;
  7171.         potionParams.creator = this;
  7172.         potionParams.sourceName = "drank_potion";
  7173.         potionParams.duration = duration;
  7174.         potionParams.customAbilityName = customAbilityName;
  7175.         ret = AddEffectCustom(potionParams);
  7176.  
  7177.        
  7178.         if(factPotionParams)
  7179.             delete factPotionParams;
  7180.            
  7181.         if(mutagenParams)
  7182.             delete mutagenParams;
  7183.            
  7184.        
  7185.         inv.SingletonItemRemoveAmmo(item);
  7186.        
  7187.        
  7188.         if(ret == EI_Pass || ret == EI_Override || ret == EI_Cumulate)
  7189.         {
  7190.             if( finalPotionToxicity > 0.f )
  7191.             {              
  7192.                 abilityManager.GainStat(BCS_Toxicity, finalPotionToxicity );
  7193.             }
  7194.            
  7195.            
  7196.             if(CanUseSkill(S_Perk_13))
  7197.             {
  7198.                 abilityManager.DrainFocus(adrenaline);
  7199.             }
  7200.            
  7201.             if (!IsEffectActive('invisible'))
  7202.             {
  7203.                 PlayEffect('use_potion');
  7204.             }
  7205.            
  7206.             if ( inv.ItemHasTag( item, 'Mutagen' ) )
  7207.             {
  7208.                
  7209.                 theGame.GetGamerProfile().CheckTrialOfGrasses();
  7210.                
  7211.                
  7212.                 SetFailedFundamentalsFirstAchievementCondition(true);
  7213.             }
  7214.            
  7215.            
  7216.             if(CanUseSkill(S_Alchemy_s02))
  7217.             {
  7218.                 hpGainValue = ClampF(GetStatMax(BCS_Vitality) * CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s02, 'vitality_gain_perc', false, true)) * GetSkillLevel(S_Alchemy_s02), 0, GetStatMax(BCS_Vitality));
  7219.                 GainStat(BCS_Vitality, hpGainValue);
  7220.             }          
  7221.            
  7222.            
  7223.             if(CanUseSkill(S_Alchemy_s04) && !skillBonusPotionEffect && (RandF() < CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s04, 'apply_chance', false, true)) * GetSkillLevel(S_Alchemy_s04)))
  7224.             {
  7225.                 AddRandomPotionEffectFromAlch4Skill( effectType );             
  7226.             }
  7227.            
  7228.             theGame.GetGamerProfile().SetStat(ES_ActivePotions, effectManager.GetPotionBuffsCount());
  7229.         }
  7230.        
  7231.         theTelemetry.LogWithLabel(TE_ELIXIR_USED, inv.GetItemName(item));
  7232.        
  7233.         if(ShouldProcessTutorial('TutorialPotionAmmo'))
  7234.         {
  7235.             FactsAdd("tut_used_potion");
  7236.         }
  7237.        
  7238.         SetFailedFundamentalsFirstAchievementCondition(true);
  7239.     }
  7240.    
  7241.    
  7242.     private final function AddRandomPotionEffectFromAlch4Skill( currentlyDrankPotion : EEffectType )
  7243.     {
  7244.         var randomPotions : array<EEffectType>;
  7245.         var currentPotion : CBaseGameplayEffect;
  7246.         var effectsOld, effectsNew : array<CBaseGameplayEffect>;
  7247.         var i, ind : int;
  7248.         var duration : float;
  7249.         var params : SCustomEffectParams;
  7250.         var ret : EEffectInteract;
  7251.        
  7252.        
  7253.         randomPotions.PushBack( EET_BlackBlood );
  7254.         randomPotions.PushBack( EET_Blizzard );
  7255.         randomPotions.PushBack( EET_FullMoon );
  7256.         randomPotions.PushBack( EET_GoldenOriole );
  7257.        
  7258.         randomPotions.PushBack( EET_MariborForest );
  7259.         randomPotions.PushBack( EET_PetriPhiltre );
  7260.         randomPotions.PushBack( EET_Swallow );
  7261.         randomPotions.PushBack( EET_TawnyOwl );
  7262.         randomPotions.PushBack( EET_Thunderbolt );
  7263.        
  7264.        
  7265.         randomPotions.Remove( currentlyDrankPotion );
  7266.        
  7267.        
  7268.         ind = RandRange( randomPotions.Size() );
  7269.  
  7270.        
  7271.         if( HasBuff( randomPotions[ ind ] ) )
  7272.         {
  7273.             currentPotion = GetBuff( randomPotions[ ind ] );
  7274.             currentPotion.SetTimeLeft( currentPotion.GetInitialDurationAfterResists() );
  7275.         }
  7276.        
  7277.         else
  7278.         {          
  7279.             duration = BonusPotionGetDurationFromXML( randomPotions[ ind ] );
  7280.            
  7281.             if(duration > 0)
  7282.             {
  7283.                 effectsOld = GetCurrentEffects();
  7284.                                    
  7285.                 params.effectType = randomPotions[ ind ];
  7286.                 params.creator = this;
  7287.                 params.sourceName = SkillEnumToName( S_Alchemy_s04 );
  7288.                 params.duration = duration;
  7289.                 ret = AddEffectCustom( params );
  7290.                
  7291.                
  7292.                 if( ret != EI_Undefined && ret != EI_Deny )
  7293.                 {
  7294.                     effectsNew = GetCurrentEffects();
  7295.                    
  7296.                     ind = -1;
  7297.                     for( i=effectsNew.Size()-1; i>=0; i-=1)
  7298.                     {
  7299.                         if( !effectsOld.Contains( effectsNew[i] ) )
  7300.                         {
  7301.                             ind = i;
  7302.                             break;
  7303.                         }
  7304.                     }
  7305.                    
  7306.                     if(ind > -1)
  7307.                     {
  7308.                         skillBonusPotionEffect = effectsNew[ind];
  7309.                     }
  7310.                 }
  7311.             }      
  7312.         }
  7313.     }
  7314.    
  7315.    
  7316.     private function BonusPotionGetDurationFromXML(type : EEffectType) : float
  7317.     {
  7318.         var dm : CDefinitionsManagerAccessor;
  7319.         var main, ingredients : SCustomNode;
  7320.         var tmpName, typeName, itemName : name;
  7321.         var abs : array<name>;
  7322.         var min, max : SAbilityAttributeValue;
  7323.         var tmpInt : int;
  7324.         var temp                                : array<float>;
  7325.         var i, temp2, temp3 : int;
  7326.                        
  7327.         dm = theGame.GetDefinitionsManager();
  7328.         main = dm.GetCustomDefinition('alchemy_recipes');
  7329.         typeName = EffectTypeToName(type);
  7330.        
  7331.        
  7332.         for(i=0; i<main.subNodes.Size(); i+=1)
  7333.         {
  7334.             if(dm.GetCustomNodeAttributeValueName(main.subNodes[i], 'type_name', tmpName))
  7335.             {
  7336.                
  7337.                 if(tmpName == typeName)
  7338.                 {
  7339.                     if(dm.GetCustomNodeAttributeValueInt(main.subNodes[i], 'level', tmpInt))
  7340.                     {
  7341.                        
  7342.                         if(tmpInt == 1)
  7343.                         {
  7344.                             if(dm.GetCustomNodeAttributeValueName(main.subNodes[i], 'cookedItem_name', itemName))
  7345.                             {
  7346.                                
  7347.                                 if(IsNameValid(itemName))
  7348.                                 {
  7349.                                     break;
  7350.                                 }
  7351.                             }
  7352.                         }
  7353.                     }
  7354.                 }
  7355.             }
  7356.         }
  7357.        
  7358.         if(!IsNameValid(itemName))
  7359.             return 0;
  7360.        
  7361.        
  7362.         dm.GetItemAbilitiesWithWeights(itemName, true, abs, temp, temp2, temp3);
  7363.         dm.GetAbilitiesAttributeValue(abs, 'duration', min, max);                      
  7364.         return CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  7365.     }
  7366.    
  7367.     public function ClearSkillBonusPotionEffect()
  7368.     {
  7369.         skillBonusPotionEffect = NULL;
  7370.     }
  7371.    
  7372.     public function GetSkillBonusPotionEffect() : CBaseGameplayEffect
  7373.     {
  7374.         return skillBonusPotionEffect;
  7375.     }
  7376.    
  7377.    
  7378.    
  7379.    
  7380.    
  7381.    
  7382.    
  7383.     public final function HasRunewordActive(abilityName : name) : bool
  7384.     {
  7385.         var item : SItemUniqueId;
  7386.         var hasRuneword : bool;
  7387.        
  7388.         if(GetItemEquippedOnSlot(EES_SteelSword, item))
  7389.         {
  7390.             hasRuneword = inv.ItemHasAbility(item, abilityName);               
  7391.         }
  7392.        
  7393.         if(!hasRuneword)
  7394.         {
  7395.             if(GetItemEquippedOnSlot(EES_SilverSword, item))
  7396.             {
  7397.                 hasRuneword = inv.ItemHasAbility(item, abilityName);
  7398.             }
  7399.         }
  7400.        
  7401.         return hasRuneword;
  7402.     }
  7403.    
  7404.     public final function GetShrineBuffs() : array<CBaseGameplayEffect>
  7405.     {
  7406.         var null : array<CBaseGameplayEffect>;
  7407.        
  7408.         if(effectManager && effectManager.IsReady())
  7409.             return effectManager.GetShrineBuffs();
  7410.            
  7411.         return null;
  7412.     }
  7413.    
  7414.     public final function AddRepairObjectBuff(armor : bool, weapon : bool) : bool
  7415.     {
  7416.         var added : bool;
  7417.        
  7418.         added = false;
  7419.        
  7420.         if(weapon && (IsAnyItemEquippedOnSlot(EES_SilverSword) || IsAnyItemEquippedOnSlot(EES_SteelSword)) )
  7421.         {
  7422.             AddEffectDefault(EET_EnhancedWeapon, this, "repair_object", false);
  7423.             added = true;
  7424.         }
  7425.        
  7426.         if(armor && (IsAnyItemEquippedOnSlot(EES_Armor) || IsAnyItemEquippedOnSlot(EES_Gloves) || IsAnyItemEquippedOnSlot(EES_Boots) || IsAnyItemEquippedOnSlot(EES_Pants)) )
  7427.         {
  7428.             AddEffectDefault(EET_EnhancedArmor, this, "repair_object", false);
  7429.             added = true;
  7430.         }
  7431.        
  7432.         return added;
  7433.     }
  7434.    
  7435.    
  7436.     public function StartCSAnim(buff : CBaseGameplayEffect) : bool
  7437.     {
  7438.        
  7439.         if(IsAnyQuenActive() && (W3CriticalDOTEffect)buff)
  7440.             return false;
  7441.            
  7442.         return super.StartCSAnim(buff);
  7443.     }
  7444.    
  7445.     public function GetPotionBuffLevel(effectType : EEffectType) : int
  7446.     {
  7447.         if(effectManager && effectManager.IsReady())
  7448.             return effectManager.GetPotionBuffLevel(effectType);
  7449.            
  7450.         return 0;
  7451.     }  
  7452.  
  7453.    
  7454.    
  7455.    
  7456.    
  7457.    
  7458.    
  7459.     event OnLevelGained(currentLevel : int, show : bool)
  7460.     {
  7461.        
  7462.         var swords : array<SItemUniqueId>;
  7463.         var i : int;
  7464.        
  7465.    
  7466.         var hud : CR4ScriptedHud;
  7467.         hud = (CR4ScriptedHud)theGame.GetHud();
  7468.        
  7469.         if(abilityManager && abilityManager.IsInitialized())
  7470.         {
  7471.             ((W3PlayerAbilityManager)abilityManager).OnLevelGained(currentLevel);
  7472.         }
  7473.        
  7474.         if ( theGame.GetDifficultyMode() != EDM_Hardcore )
  7475.         {
  7476.             Heal(GetStatMax(BCS_Vitality));
  7477.         }
  7478.    
  7479.        
  7480.         if(currentLevel >= 35)
  7481.         {
  7482.             theGame.GetGamerProfile().AddAchievement(EA_Immortal);
  7483.         }
  7484.         else
  7485.         {
  7486.             theGame.GetGamerProfile().NoticeAchievementProgress(EA_Immortal, currentLevel);
  7487.         }
  7488.    
  7489.         if ( hud && currentLevel < levelManager.GetMaxLevel() && FactsQuerySum( "DebugNoLevelUpUpdates" ) == 0 )
  7490.         {
  7491.             hud.OnLevelUpUpdate(currentLevel, show);
  7492.         }
  7493.        
  7494.        
  7495.         swords = inv.GetItemsByName('sq304 Novigraadan sword 4');
  7496.         for(i=0;i<swords.Size();i+=1)
  7497.         {
  7498.             inv.AddItemCraftedAbility(swords[i], 'sq304_sword_upgrade _Stats', true);          
  7499.         }
  7500.        
  7501.         swords.Clear();
  7502.         swords = inv.GetItemsByName('q402 Skellige sword 3');
  7503.         for(i=0;i<swords.Size();i+=1)
  7504.         {
  7505.             inv.AddItemCraftedAbility(swords[i], 'q402_sword_upgrade _Stats', true);           
  7506.         }
  7507.        
  7508.        
  7509.         theGame.RequestAutoSave( "level gained", false );
  7510.     }
  7511.    
  7512.     public function GetSignStats(skill : ESkill, out damageType : name, out damageVal : float, out spellPower : SAbilityAttributeValue)
  7513.     {
  7514.         var i, size : int;
  7515.         var dm : CDefinitionsManagerAccessor;
  7516.         var attrs : array<name>;
  7517.    
  7518.         spellPower = GetPowerStatValue(CPS_SpellPower);
  7519.        
  7520.         dm = theGame.GetDefinitionsManager();
  7521.         dm.GetAbilityAttributes(GetSkillAbilityName(skill), attrs);
  7522.         size = attrs.Size();
  7523.        
  7524.         for( i = 0; i < size; i += 1 )
  7525.         {
  7526.             if( IsDamageTypeNameValid(attrs[i]) )
  7527.             {
  7528.                 damageVal = CalculateAttributeValue(GetSkillAttributeValue(skill, attrs[i], false, true));
  7529.                 damageType = attrs[i];
  7530.                 break;
  7531.             }
  7532.         }
  7533.     }
  7534.        
  7535.    
  7536.     public function SetIgnorePainMaxVitality(val : float)
  7537.     {
  7538.         if(abilityManager && abilityManager.IsInitialized())
  7539.             abilityManager.SetStatPointMax(BCS_Vitality, val);
  7540.     }
  7541.    
  7542.     event OnAnimEvent_ActionBlend( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  7543.     {
  7544.         if ( animEventType == AET_DurationStart && !disableActionBlend )
  7545.         {
  7546.             if ( this.IsCastingSign() )
  7547.                 ProcessSignEvent( 'cast_end' );
  7548.            
  7549.            
  7550.             FindMoveTarget();
  7551.             SetCanPlayHitAnim( true );
  7552.             this.SetBIsCombatActionAllowed( true );
  7553.            
  7554.             if ( this.GetFinisherVictim() && this.GetFinisherVictim().HasAbility( 'ForceFinisher' ) && !isInFinisher )
  7555.             {
  7556.                 this.GetFinisherVictim().SignalGameplayEvent( 'Finisher' );
  7557.             }
  7558.             else if (this.BufferCombatAction != EBAT_EMPTY )
  7559.             {
  7560.                
  7561.                
  7562.                    
  7563.                     if ( !IsCombatMusicEnabled() )
  7564.                     {
  7565.                         SetCombatActionHeading( ProcessCombatActionHeading( this.BufferCombatAction ) );
  7566.                         FindTarget();
  7567.                         UpdateDisplayTarget( true );
  7568.                     }
  7569.            
  7570.                     if ( AllowAttack( GetTarget(), this.BufferCombatAction ) )
  7571.                         this.ProcessCombatActionBuffer();
  7572.             }
  7573.             else
  7574.             {
  7575.                
  7576.                 ResumeStaminaRegen( 'InsideCombatAction' );
  7577.                
  7578.                
  7579.                
  7580.             }
  7581.         }
  7582.         else if ( disableActionBlend )
  7583.         {
  7584.             disableActionBlend = false;
  7585.         }
  7586.     }
  7587.    
  7588.    
  7589.     event OnAnimEvent_Sign( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  7590.     {
  7591.         if( animEventType == AET_Tick )
  7592.         {
  7593.             ProcessSignEvent( animEventName );
  7594.         }
  7595.     }
  7596.    
  7597.     event OnAnimEvent_Throwable( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  7598.     {
  7599.         var thrownEntity        : CThrowable;  
  7600.        
  7601.         thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  7602.            
  7603.         if ( inv.IsItemCrossbow( inv.GetItemFromSlot('l_weapon') ) &&  rangedWeapon.OnProcessThrowEvent( animEventName ) )
  7604.         {      
  7605.             return true;
  7606.         }
  7607.         else if( thrownEntity && IsThrowingItem() && thrownEntity.OnProcessThrowEvent( animEventName ) )
  7608.         {
  7609.             return true;
  7610.         }
  7611.     }
  7612.    
  7613.     event OnTaskSyncAnim( npc : CNewNPC, animNameLeft : name )
  7614.     {
  7615.         var tmpBool : bool;
  7616.         var tmpName : name;
  7617.         var damage, points, resistance : float;
  7618.         var min, max : SAbilityAttributeValue;
  7619.         var mc : EMonsterCategory;
  7620.        
  7621.         super.OnTaskSyncAnim( npc, animNameLeft );
  7622.        
  7623.         if( animNameLeft == 'BruxaBite' && IsMutationActive( EPMT_Mutation4 ) )
  7624.         {
  7625.             theGame.GetMonsterParamsForActor( npc, mc, tmpName, tmpBool, tmpBool, tmpBool );
  7626.            
  7627.             if( mc == MC_Vampire )
  7628.             {
  7629.                 GetResistValue( CDS_BleedingRes, points, resistance );
  7630.                
  7631.                 theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'BleedingEffect', 'DirectDamage', min, max );
  7632.                 damage = MaxF( 0.f, max.valueMultiplicative * GetMaxHealth() - points );
  7633.                
  7634.                 theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'BleedingEffect', 'duration', min, max );
  7635.                 damage *= min.valueAdditive * ( 1 - MinF( 1.f, resistance ) );
  7636.                
  7637.                 if( damage > 0.f )
  7638.                 {
  7639.                     npc.AddAbility( 'Mutation4BloodDebuff' );
  7640.                     ProcessActionMutation4ReturnedDamage( damage, npc, EAHA_ForceNo );                 
  7641.                     npc.AddTimer( 'RemoveMutation4BloodDebuff', 15.f, , , , , true );
  7642.                 }
  7643.             }
  7644.         }
  7645.     }
  7646.    
  7647.    
  7648.     public function ProcessActionMutation4ReturnedDamage( damageDealt : float, attacker : CActor, hitAnimationType : EActionHitAnim, optional action : W3DamageAction ) : bool
  7649.     {
  7650.         var customParams                : SCustomEffectParams;
  7651.         var currToxicity                : float;
  7652.         var min, max, customDamageValue : SAbilityAttributeValue;
  7653.         var dm                          : CDefinitionsManagerAccessor;
  7654.         var animAction                  : W3DamageAction;
  7655.  
  7656.         if( damageDealt <= 0 )
  7657.         {
  7658.             return false;
  7659.         }
  7660.        
  7661.         if( action )
  7662.         {
  7663.             action.SetMutation4Triggered();
  7664.         }
  7665.            
  7666.         dm = theGame.GetDefinitionsManager();
  7667.         currToxicity = GetStat( BCS_Toxicity );
  7668.        
  7669.         dm.GetAbilityAttributeValue( 'AcidEffect', 'DirectDamage', min, max );
  7670.         customDamageValue.valueAdditive = damageDealt * min.valueAdditive;
  7671.        
  7672.         if( currToxicity > 0 )
  7673.         {
  7674.             customDamageValue.valueAdditive *= currToxicity;
  7675.         }
  7676.        
  7677.         dm.GetAbilityAttributeValue( 'AcidEffect', 'duration', min, max );
  7678.         customDamageValue.valueAdditive /= min.valueAdditive;
  7679.        
  7680.         customParams.effectType = EET_Acid;
  7681.         customParams.effectValue = customDamageValue;
  7682.         customParams.duration = min.valueAdditive;
  7683.         customParams.creator = this;
  7684.         customParams.sourceName = 'Mutation4';
  7685.        
  7686.         attacker.AddEffectCustom( customParams );
  7687.        
  7688.        
  7689.         animAction = new W3DamageAction in theGame;
  7690.         animAction.Initialize( this, attacker, NULL, 'Mutation4', EHRT_Reflect, CPS_Undefined, true, false, false, false );
  7691.         animAction.SetCannotReturnDamage( true );
  7692.         animAction.SetCanPlayHitParticle( false );
  7693.         animAction.SetHitAnimationPlayType( hitAnimationType );
  7694.         theGame.damageMgr.ProcessAction( animAction );
  7695.         delete animAction;
  7696.        
  7697.         theGame.MutationHUDFeedback( MFT_PlayOnce );
  7698.        
  7699.         return true;
  7700.     }
  7701.    
  7702.     event OnPlayerActionEnd()
  7703.     {
  7704.         var l_i             : int;
  7705.         var l_bed           : W3WitcherBed;
  7706.        
  7707.         l_i = (int)GetBehaviorVariable( 'playerExplorationAction' );
  7708.        
  7709.         if( l_i == PEA_GoToSleep )
  7710.         {
  7711.             l_bed = (W3WitcherBed)theGame.GetEntityByTag( 'witcherBed' );
  7712.             BlockAllActions( 'WitcherBed', false );
  7713.             l_bed.ApplyAppearance( "collision" );
  7714.             l_bed.GotoState( 'WakeUp' );
  7715.             theGame.ReleaseNoSaveLock( l_bed.m_bedSaveLock );
  7716.            
  7717.            
  7718.             substateManager.m_MovementCorrectorO.disallowRotWhenGoingToSleep = false;
  7719.         }
  7720.        
  7721.         super.OnPlayerActionEnd();
  7722.     }
  7723.    
  7724.     event OnPlayerActionStartFinished()
  7725.     {
  7726.         var l_initData          : W3SingleMenuInitData;    
  7727.         var l_i                 : int;
  7728.        
  7729.         l_i = (int)GetBehaviorVariable( 'playerExplorationAction' );
  7730.        
  7731.         if( l_i == PEA_GoToSleep )
  7732.         {
  7733.             l_initData = new W3SingleMenuInitData in this;
  7734.             l_initData.SetBlockOtherPanels( true );
  7735.             l_initData.ignoreSaveSystem = true;
  7736.             l_initData.ignoreMeditationCheck = true;
  7737.             l_initData.setDefaultState( '' );
  7738.             l_initData.isBonusMeditationAvailable = true;
  7739.             l_initData.fixedMenuName = 'MeditationClockMenu';
  7740.            
  7741.             theGame.RequestMenuWithBackground( 'MeditationClockMenu', 'CommonMenu', l_initData );
  7742.         }
  7743.        
  7744.         super.OnPlayerActionStartFinished();
  7745.     }
  7746.    
  7747.     public function IsInCombatAction_SpecialAttack() : bool
  7748.     {
  7749.         if ( IsInCombatAction() && ( GetCombatAction() == EBAT_SpecialAttack_Light || GetCombatAction() == EBAT_SpecialAttack_Heavy ) )
  7750.             return true;
  7751.         else
  7752.             return false;
  7753.     }
  7754.    
  7755.     public function IsInCombatAction_SpecialAttackHeavy() : bool
  7756.     {
  7757.         if ( IsInCombatAction() && GetCombatAction() == EBAT_SpecialAttack_Heavy )
  7758.             return true;
  7759.         else
  7760.             return false;
  7761.     }
  7762.    
  7763.     protected function WhenCombatActionIsFinished()
  7764.     {
  7765.         super.WhenCombatActionIsFinished();
  7766.         RemoveTimer( 'ProcessAttackTimer' );
  7767.         RemoveTimer( 'AttackTimerEnd' );
  7768.         CastSignAbort();
  7769.         specialAttackCamera = false;
  7770.         this.OnPerformSpecialAttack( true, false );
  7771.     }
  7772.    
  7773.     event OnCombatActionEnd()
  7774.     {
  7775.         this.CleanCombatActionBuffer();    
  7776.         super.OnCombatActionEnd();
  7777.        
  7778.         RemoveTemporarySkills();
  7779.     }
  7780.    
  7781.     event OnCombatActionFriendlyEnd()
  7782.     {
  7783.         if ( IsCastingSign() )
  7784.         {
  7785.             SetBehaviorVariable( 'IsCastingSign', 0 );
  7786.             SetCurrentlyCastSign( ST_None, NULL );
  7787.             LogChannel( 'ST_None', "ST_None" );                
  7788.         }
  7789.  
  7790.         super.OnCombatActionFriendlyEnd();
  7791.     }
  7792.    
  7793.     public function GetPowerStatValue( stat : ECharacterPowerStats, optional ablName : name, optional ignoreDeath : bool ) : SAbilityAttributeValue
  7794.     {
  7795.         var result :  SAbilityAttributeValue;
  7796.        
  7797.        
  7798.         result = super.GetPowerStatValue( stat, ablName, ignoreDeath );
  7799.         ApplyMutation10StatBoost( result );
  7800.        
  7801.         return result;
  7802.     }
  7803.    
  7804.    
  7805.    
  7806.     timer function OpenRadialMenu( time: float, id : int )
  7807.     {
  7808.        
  7809.         if( GetBIsCombatActionAllowed() && !IsUITakeInput() )
  7810.         {
  7811.             bShowRadialMenu = true;
  7812.         }
  7813.        
  7814.         this.RemoveTimer('OpenRadialMenu');
  7815.     }
  7816.    
  7817.     public function OnAddRadialMenuOpenTimer(  )
  7818.     {
  7819.        
  7820.        
  7821.        
  7822.            
  7823.            
  7824.             this.AddTimer('OpenRadialMenu', _HoldBeforeOpenRadialMenuTime * theGame.GetTimeScale() );
  7825.        
  7826.     }
  7827.  
  7828.     public function SetShowRadialMenuOpenFlag( bSet : bool  )
  7829.     {
  7830.        
  7831.         bShowRadialMenu = bSet;
  7832.     }
  7833.    
  7834.     public function OnRemoveRadialMenuOpenTimer()
  7835.     {
  7836.        
  7837.         this.RemoveTimer('OpenRadialMenu');
  7838.     }
  7839.    
  7840.     public function ResetRadialMenuOpenTimer()
  7841.     {
  7842.        
  7843.         this.RemoveTimer('OpenRadialMenu');
  7844.         if( GetBIsCombatActionAllowed() )
  7845.         {
  7846.            
  7847.            
  7848.             AddTimer('OpenRadialMenu', _HoldBeforeOpenRadialMenuTime * theGame.GetTimeScale() );
  7849.         }
  7850.     }
  7851.  
  7852.    
  7853.    
  7854.     timer function ResendCompanionDisplayName(dt : float, id : int)
  7855.     {
  7856.         var hud : CR4ScriptedHud;
  7857.         var companionModule : CR4HudModuleCompanion;
  7858.        
  7859.         hud = (CR4ScriptedHud)theGame.GetHud();
  7860.         if( hud )
  7861.         {
  7862.             companionModule = (CR4HudModuleCompanion)hud.GetHudModule("CompanionModule");
  7863.             if( companionModule )
  7864.             {
  7865.                 companionModule.ResendDisplayName();
  7866.             }
  7867.         }
  7868.     }
  7869.  
  7870.     timer function ResendCompanionDisplayNameSecond(dt : float, id : int)
  7871.     {
  7872.         var hud : CR4ScriptedHud;
  7873.         var companionModule : CR4HudModuleCompanion;
  7874.        
  7875.         hud = (CR4ScriptedHud)theGame.GetHud();
  7876.         if( hud )
  7877.         {
  7878.             companionModule = (CR4HudModuleCompanion)hud.GetHudModule("CompanionModule");
  7879.             if( companionModule )
  7880.             {
  7881.                 companionModule.ResendDisplayNameSecond();
  7882.             }
  7883.         }
  7884.     }
  7885.    
  7886.     public function RemoveCompanionDisplayNameTimer()
  7887.     {
  7888.         this.RemoveTimer('ResendCompanionDisplayName');
  7889.     }
  7890.        
  7891.     public function RemoveCompanionDisplayNameTimerSecond()
  7892.     {
  7893.         this.RemoveTimer('ResendCompanionDisplayNameSecond');
  7894.     }
  7895.    
  7896.        
  7897.     public function GetCompanionNPCTag() : name
  7898.     {
  7899.         return companionNPCTag;
  7900.     }
  7901.  
  7902.     public function SetCompanionNPCTag( value : name )
  7903.     {
  7904.         companionNPCTag = value;
  7905.     }  
  7906.  
  7907.     public function GetCompanionNPCTag2() : name
  7908.     {
  7909.         return companionNPCTag2;
  7910.     }
  7911.  
  7912.     public function SetCompanionNPCTag2( value : name )
  7913.     {
  7914.         companionNPCTag2 = value;
  7915.     }
  7916.  
  7917.     public function GetCompanionNPCIconPath() : string
  7918.     {
  7919.         return companionNPCIconPath;
  7920.     }
  7921.  
  7922.     public function SetCompanionNPCIconPath( value : string )
  7923.     {
  7924.         companionNPCIconPath = value;
  7925.     }
  7926.  
  7927.     public function GetCompanionNPCIconPath2() : string
  7928.     {
  7929.         return companionNPCIconPath2;
  7930.     }
  7931.  
  7932.     public function SetCompanionNPCIconPath2( value : string )
  7933.     {
  7934.         companionNPCIconPath2 = value;
  7935.     }
  7936.    
  7937.    
  7938.  
  7939.     public function ReactToBeingHit(damageAction : W3DamageAction, optional buffNotApplied : bool) : bool
  7940.     {
  7941.         var chance : float;
  7942.         var procQuen : W3SignEntity;
  7943.        
  7944.         if(!damageAction.IsDoTDamage() && damageAction.DealsAnyDamage())
  7945.         {
  7946.             if(inv.IsItemBomb(selectedItemId))
  7947.             {
  7948.                 BombThrowAbort();
  7949.             }
  7950.             else
  7951.             {
  7952.                
  7953.                 ThrowingAbort();
  7954.             }          
  7955.         }      
  7956.        
  7957.        
  7958.         if(damageAction.IsActionRanged())
  7959.         {
  7960.             chance = CalculateAttributeValue(GetAttributeValue('quen_chance_on_projectile'));
  7961.             if(chance > 0)
  7962.             {
  7963.                 chance = ClampF(chance, 0, 1);
  7964.                
  7965.                 if(RandF() < chance)
  7966.                 {
  7967.                     procQuen = (W3SignEntity)theGame.CreateEntity(signs[ST_Quen].template, GetWorldPosition(), GetWorldRotation() );
  7968.                     procQuen.Init(signOwner, signs[ST_Quen].entity, true );
  7969.                     procQuen.OnStarted();
  7970.                     procQuen.OnThrowing();
  7971.                     procQuen.OnEnded();
  7972.                 }
  7973.             }
  7974.         }
  7975.        
  7976.        
  7977.         if( !((W3Effect_Toxicity)damageAction.causer) )
  7978.             MeditationForceAbort(true);
  7979.        
  7980.        
  7981.         if(IsDoingSpecialAttack(false))
  7982.             damageAction.SetHitAnimationPlayType(EAHA_ForceNo);
  7983.        
  7984.         return super.ReactToBeingHit(damageAction, buffNotApplied);
  7985.     }
  7986.    
  7987.     protected function ShouldPauseHealthRegenOnHit() : bool
  7988.     {
  7989.        
  7990.         if( ( HasBuff( EET_Swallow ) && GetPotionBuffLevel( EET_Swallow ) >= 3 ) || HasBuff( EET_Runeword8 ) || HasBuff( EET_Mutation11Buff ) )
  7991.         {
  7992.             return false;
  7993.         }
  7994.            
  7995.         return true;
  7996.     }
  7997.        
  7998.     public function SetMappinToHighlight( mappinName : name, mappinState : bool )
  7999.     {
  8000.         var mappinDef : SHighlightMappin;
  8001.         mappinDef.MappinName = mappinName;
  8002.         mappinDef.MappinState = mappinState;
  8003.         MappinToHighlight.PushBack(mappinDef);
  8004.     }  
  8005.  
  8006.     public function ClearMappinToHighlight()
  8007.     {
  8008.         MappinToHighlight.Clear();
  8009.     }
  8010.    
  8011.     public function CastSignAbort()
  8012.     {
  8013.         if( currentlyCastSign != ST_None && signs[currentlyCastSign].entity)
  8014.         {
  8015.             signs[currentlyCastSign].entity.OnSignAborted();
  8016.         }
  8017.        
  8018.        
  8019.     }
  8020.    
  8021.     event OnBlockingSceneStarted( scene: CStoryScene )
  8022.     {
  8023.         var med : W3PlayerWitcherStateMeditationWaiting;
  8024.                
  8025.        
  8026.         med = (W3PlayerWitcherStateMeditationWaiting)GetCurrentState();
  8027.         if(med)
  8028.         {
  8029.             med.StopRequested(true);
  8030.         }
  8031.        
  8032.        
  8033.         super.OnBlockingSceneStarted( scene );
  8034.     }
  8035.    
  8036.    
  8037.    
  8038.    
  8039.    
  8040.     public function GetHorseManager() : W3HorseManager
  8041.     {
  8042.         return (W3HorseManager)EntityHandleGet( horseManagerHandle );
  8043.     }
  8044.    
  8045.    
  8046.     public function HorseEquipItem(horsesItemId : SItemUniqueId) : bool
  8047.     {
  8048.         var man : W3HorseManager;
  8049.        
  8050.         man = GetHorseManager();
  8051.         if(man)
  8052.             return man.EquipItem(horsesItemId) != GetInvalidUniqueId();
  8053.            
  8054.         return false;
  8055.     }
  8056.    
  8057.    
  8058.     public function HorseUnequipItem(slot : EEquipmentSlots) : bool
  8059.     {
  8060.         var man : W3HorseManager;
  8061.        
  8062.         man = GetHorseManager();
  8063.         if(man)
  8064.             return man.UnequipItem(slot) != GetInvalidUniqueId();
  8065.            
  8066.         return false;
  8067.     }
  8068.    
  8069.    
  8070.     public final function HorseRemoveItemByName(itemName : name, quantity : int)
  8071.     {
  8072.         var man : W3HorseManager;
  8073.        
  8074.         man = GetHorseManager();
  8075.         if(man)
  8076.             man.HorseRemoveItemByName(itemName, quantity);
  8077.     }
  8078.    
  8079.    
  8080.     public final function HorseRemoveItemByCategory(itemCategory : name, quantity : int)
  8081.     {
  8082.         var man : W3HorseManager;
  8083.        
  8084.         man = GetHorseManager();
  8085.         if(man)
  8086.             man.HorseRemoveItemByCategory(itemCategory, quantity);
  8087.     }
  8088.    
  8089.    
  8090.     public final function HorseRemoveItemByTag(itemTag : name, quantity : int)
  8091.     {
  8092.         var man : W3HorseManager;
  8093.        
  8094.         man = GetHorseManager();
  8095.         if(man)
  8096.             man.HorseRemoveItemByTag(itemTag, quantity);
  8097.     }
  8098.    
  8099.     public function GetAssociatedInventory() : CInventoryComponent
  8100.     {
  8101.         var man : W3HorseManager;
  8102.        
  8103.         man = GetHorseManager();
  8104.         if(man)
  8105.             return man.GetInventoryComponent();
  8106.            
  8107.         return NULL;
  8108.     }
  8109.    
  8110.    
  8111.    
  8112.    
  8113.    
  8114.     public final function TutorialMutagensUnequipPlayerSkills() : array<STutorialSavedSkill>
  8115.     {
  8116.         var pam : W3PlayerAbilityManager;
  8117.        
  8118.         pam = (W3PlayerAbilityManager)abilityManager;
  8119.         return pam.TutorialMutagensUnequipPlayerSkills();
  8120.     }
  8121.    
  8122.     public final function TutorialMutagensEquipOneGoodSkill()
  8123.     {
  8124.         var pam : W3PlayerAbilityManager;
  8125.        
  8126.         pam = (W3PlayerAbilityManager)abilityManager;
  8127.         pam.TutorialMutagensEquipOneGoodSkill();
  8128.     }
  8129.    
  8130.     public final function TutorialMutagensEquipOneGoodOneBadSkill()
  8131.     {
  8132.         var pam : W3PlayerAbilityManager;
  8133.        
  8134.         pam = (W3PlayerAbilityManager)abilityManager;
  8135.         if(pam)
  8136.             pam.TutorialMutagensEquipOneGoodOneBadSkill();
  8137.     }
  8138.    
  8139.     public final function TutorialMutagensEquipThreeGoodSkills()
  8140.     {
  8141.         var pam : W3PlayerAbilityManager;
  8142.        
  8143.         pam = (W3PlayerAbilityManager)abilityManager;
  8144.         if(pam)
  8145.             pam.TutorialMutagensEquipThreeGoodSkills();
  8146.     }
  8147.    
  8148.     public final function TutorialMutagensCleanupTempSkills(savedEquippedSkills : array<STutorialSavedSkill>)
  8149.     {
  8150.         var pam : W3PlayerAbilityManager;
  8151.        
  8152.         pam = (W3PlayerAbilityManager)abilityManager;
  8153.         return pam.TutorialMutagensCleanupTempSkills(savedEquippedSkills);
  8154.     }
  8155.    
  8156.    
  8157.    
  8158.    
  8159.    
  8160.     public final function CalculatedArmorStaminaRegenBonus() : float
  8161.     {
  8162.         var armorEq, glovesEq, pantsEq, bootsEq : bool;
  8163.         var tempItem : SItemUniqueId;
  8164.         var staminaRegenVal : float;
  8165.         var armorRegenVal : SAbilityAttributeValue;
  8166.        
  8167.         if( HasAbility( 'Glyphword 2 _Stats', true ) )
  8168.         {
  8169.             armorEq = inv.GetItemEquippedOnSlot( EES_Armor, tempItem );
  8170.             glovesEq = inv.GetItemEquippedOnSlot( EES_Gloves, tempItem );
  8171.             pantsEq = inv.GetItemEquippedOnSlot( EES_Pants, tempItem );
  8172.             bootsEq = inv.GetItemEquippedOnSlot( EES_Boots, tempItem );
  8173.            
  8174.             if ( armorEq )
  8175.                 staminaRegenVal += 0.1;
  8176.             if ( glovesEq )
  8177.                 staminaRegenVal += 0.02;
  8178.             if ( pantsEq )
  8179.                 staminaRegenVal += 0.1;
  8180.             if ( bootsEq )
  8181.                 staminaRegenVal += 0.03;
  8182.            
  8183.         }
  8184.         else if( HasAbility( 'Glyphword 3 _Stats', true ) )
  8185.         {
  8186.             staminaRegenVal = 0;
  8187.         }
  8188.         else if( HasAbility( 'Glyphword 4 _Stats', true ) )
  8189.         {
  8190.             armorEq = inv.GetItemEquippedOnSlot( EES_Armor, tempItem );
  8191.             glovesEq = inv.GetItemEquippedOnSlot( EES_Gloves, tempItem );
  8192.             pantsEq = inv.GetItemEquippedOnSlot( EES_Pants, tempItem );
  8193.             bootsEq = inv.GetItemEquippedOnSlot( EES_Boots, tempItem );
  8194.            
  8195.             if ( armorEq )
  8196.                 staminaRegenVal -= 0.1;
  8197.             if ( glovesEq )
  8198.                 staminaRegenVal -= 0.02;
  8199.             if ( pantsEq )
  8200.                 staminaRegenVal -= 0.1;
  8201.             if ( bootsEq )
  8202.                 staminaRegenVal -= 0.03;
  8203.         }
  8204.         else
  8205.         {
  8206.             armorRegenVal = GetAttributeValue('staminaRegen_armor_mod');
  8207.             staminaRegenVal = armorRegenVal.valueMultiplicative;
  8208.         }
  8209.        
  8210.         return staminaRegenVal;
  8211.     }
  8212.    
  8213.     public function GetOffenseStatsList( optional hackMode : int ) : SPlayerOffenseStats
  8214.     {
  8215.         var playerOffenseStats:SPlayerOffenseStats;
  8216.         var steelDmg, silverDmg, elementalSteel, elementalSilver : float;
  8217.         var steelCritChance, steelCritDmg : float;
  8218.         var silverCritChance, silverCritDmg : float;
  8219.         var attackPower : SAbilityAttributeValue;
  8220.         var fastCritChance, fastCritDmg : float;
  8221.         var strongCritChance, strongCritDmg : float;
  8222.         var fastAP, strongAP, min, max : SAbilityAttributeValue;
  8223.         var item, crossbow : SItemUniqueId;
  8224.         var value : SAbilityAttributeValue;
  8225.         var mutagen : CBaseGameplayEffect;
  8226.         var thunder : W3Potion_Thunderbolt;
  8227.        
  8228.         if(!abilityManager || !abilityManager.IsInitialized())
  8229.             return playerOffenseStats;
  8230.        
  8231.         if (CanUseSkill(S_Sword_s21))
  8232.             fastAP += GetSkillAttributeValue(S_Sword_s21, PowerStatEnumToName(CPS_AttackPower), false, true) * GetSkillLevel(S_Sword_s21);
  8233.         if (CanUseSkill(S_Perk_05))
  8234.         {
  8235.             fastAP += GetAttributeValue('attack_power_fast_style');
  8236.             fastCritDmg += CalculateAttributeValue(GetAttributeValue('critical_hit_chance_fast_style'));
  8237.             strongCritDmg += CalculateAttributeValue(GetAttributeValue('critical_hit_chance_fast_style'));
  8238.         }
  8239.         if (CanUseSkill(S_Sword_s04))
  8240.             strongAP += GetSkillAttributeValue(S_Sword_s04, PowerStatEnumToName(CPS_AttackPower), false, true) * GetSkillLevel(S_Sword_s04);
  8241.         if (CanUseSkill(S_Perk_07))
  8242.             strongAP += GetAttributeValue('attack_power_heavy_style');
  8243.            
  8244.         if (CanUseSkill(S_Sword_s17))
  8245.         {
  8246.             fastCritChance += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s17, theGame.params.CRITICAL_HIT_CHANCE, false, true)) * GetSkillLevel(S_Sword_s17);
  8247.             fastCritDmg += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s17, theGame.params.CRITICAL_HIT_DAMAGE_BONUS, false, true)) * GetSkillLevel(S_Sword_s17);
  8248.         }
  8249.        
  8250.         if (CanUseSkill(S_Sword_s08))
  8251.         {
  8252.             strongCritChance += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s08, theGame.params.CRITICAL_HIT_CHANCE, false, true)) * GetSkillLevel(S_Sword_s08);
  8253.             strongCritDmg += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s08, theGame.params.CRITICAL_HIT_DAMAGE_BONUS, false, true)) * GetSkillLevel(S_Sword_s08);
  8254.         }
  8255.        
  8256.         if ( HasBuff(EET_Mutagen05) && (GetStat(BCS_Vitality) == GetStatMax(BCS_Vitality)) )
  8257.         {
  8258.             attackPower += GetAttributeValue('damageIncrease');
  8259.         }
  8260.        
  8261.         steelCritChance += CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_CHANCE));
  8262.         silverCritChance += CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_CHANCE));
  8263.         steelCritDmg += CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  8264.         silverCritDmg += CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  8265.         attackPower += GetPowerStatValue(CPS_AttackPower);
  8266.        
  8267.         if (GetItemEquippedOnSlot(EES_SteelSword, item))
  8268.         {
  8269.             steelDmg = GetTotalWeaponDamage(item, theGame.params.DAMAGE_NAME_SLASHING, GetInvalidUniqueId());
  8270.             steelDmg += GetTotalWeaponDamage(item, theGame.params.DAMAGE_NAME_PIERCING, GetInvalidUniqueId());
  8271.             steelDmg += GetTotalWeaponDamage(item, theGame.params.DAMAGE_NAME_BLUDGEONING, GetInvalidUniqueId());
  8272.             elementalSteel = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FIRE));
  8273.             elementalSteel += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FROST));
  8274.             if ( GetInventory().IsItemHeld(item) )
  8275.             {
  8276.                 steelCritChance -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  8277.                 silverCritChance -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  8278.                 steelCritDmg -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  8279.                 silverCritDmg -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  8280.             }
  8281.             steelCritChance += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  8282.             steelCritDmg += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  8283.            
  8284.             thunder = (W3Potion_Thunderbolt)GetBuff(EET_Thunderbolt);
  8285.             if(thunder && thunder.GetBuffLevel() == 3 && GetCurWeather() == EWE_Storm)
  8286.             {
  8287.                 steelCritChance += 1.0f;
  8288.             }
  8289.         }
  8290.         else
  8291.         {
  8292.             steelDmg += 0;
  8293.             steelCritChance += 0;
  8294.             steelCritDmg +=0;
  8295.         }
  8296.        
  8297.         if (GetItemEquippedOnSlot(EES_SilverSword, item))
  8298.         {
  8299.             silverDmg = GetTotalWeaponDamage(item, theGame.params.DAMAGE_NAME_SILVER, GetInvalidUniqueId());
  8300.             elementalSilver = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FIRE));
  8301.             elementalSilver += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FROST));
  8302.             if ( GetInventory().IsItemHeld(item) )
  8303.             {
  8304.                 steelCritChance -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  8305.                 silverCritChance -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  8306.                 steelCritDmg -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  8307.                 silverCritDmg -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  8308.             }
  8309.             silverCritChance += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  8310.             silverCritDmg += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  8311.            
  8312.             thunder = (W3Potion_Thunderbolt)GetBuff(EET_Thunderbolt);
  8313.             if(thunder && thunder.GetBuffLevel() == 3 && GetCurWeather() == EWE_Storm)
  8314.             {
  8315.                 silverCritChance += 1.0f;
  8316.             }
  8317.         }
  8318.         else
  8319.         {
  8320.             silverDmg += 0;
  8321.             silverCritChance += 0;
  8322.             silverCritDmg +=0;
  8323.         }
  8324.        
  8325.         if ( HasAbility('Runeword 4 _Stats', true) )
  8326.         {
  8327.             steelDmg += steelDmg * (abilityManager.GetOverhealBonus() / GetStatMax(BCS_Vitality));
  8328.             silverDmg += silverDmg * (abilityManager.GetOverhealBonus() / GetStatMax(BCS_Vitality));
  8329.         }
  8330.        
  8331.         fastAP += attackPower;
  8332.         strongAP += attackPower;
  8333.        
  8334.         playerOffenseStats.steelFastCritChance = (steelCritChance + fastCritChance) * 100;
  8335.         playerOffenseStats.steelFastCritDmg = steelCritDmg + fastCritDmg;
  8336.         if ( steelDmg != 0 )
  8337.         {
  8338.             playerOffenseStats.steelFastDmg = (steelDmg + fastAP.valueBase) * fastAP.valueMultiplicative + fastAP.valueAdditive + elementalSteel;
  8339.             playerOffenseStats.steelFastCritDmg = (steelDmg + fastAP.valueBase) * (fastAP.valueMultiplicative + playerOffenseStats.steelFastCritDmg) + fastAP.valueAdditive + elementalSteel;
  8340.         }
  8341.         else
  8342.         {
  8343.             playerOffenseStats.steelFastDmg = 0;
  8344.             playerOffenseStats.steelFastCritDmg = 0;
  8345.         }
  8346.         playerOffenseStats.steelFastDPS = (playerOffenseStats.steelFastDmg * (100 - playerOffenseStats.steelFastCritChance) + playerOffenseStats.steelFastCritDmg * playerOffenseStats.steelFastCritChance) / 100;
  8347.         playerOffenseStats.steelFastDPS = playerOffenseStats.steelFastDPS / 0.6;
  8348.        
  8349.        
  8350.         playerOffenseStats.steelStrongCritChance = (steelCritChance + strongCritChance) * 100;
  8351.         playerOffenseStats.steelStrongCritDmg = steelCritDmg + strongCritDmg;
  8352.         if ( steelDmg != 0 )
  8353.         {
  8354.             playerOffenseStats.steelStrongDmg = (steelDmg + strongAP.valueBase) * strongAP.valueMultiplicative + strongAP.valueAdditive + elementalSteel;
  8355.             playerOffenseStats.steelStrongDmg *= 1.833f;
  8356.             playerOffenseStats.steelStrongCritDmg = (steelDmg + strongAP.valueBase) * (strongAP.valueMultiplicative + playerOffenseStats.steelStrongCritDmg) + strongAP.valueAdditive + elementalSteel;
  8357.             playerOffenseStats.steelStrongCritDmg *= 1.833f;        }
  8358.         else
  8359.         {
  8360.             playerOffenseStats.steelStrongDmg = 0;
  8361.             playerOffenseStats.steelStrongCritDmg = 0;
  8362.         }
  8363.         playerOffenseStats.steelStrongDPS = (playerOffenseStats.steelStrongDmg * (100 - playerOffenseStats.steelStrongCritChance) + playerOffenseStats.steelStrongCritDmg * playerOffenseStats.steelStrongCritChance) / 100;
  8364.         playerOffenseStats.steelStrongDPS = playerOffenseStats.steelStrongDPS / 1.1;
  8365.        
  8366.    
  8367.        
  8368.         playerOffenseStats.silverFastCritChance = (silverCritChance + fastCritChance) * 100;
  8369.         playerOffenseStats.silverFastCritDmg = silverCritDmg + fastCritDmg;
  8370.         if ( silverDmg != 0 )
  8371.         {
  8372.             playerOffenseStats.silverFastDmg = (silverDmg + fastAP.valueBase) * fastAP.valueMultiplicative + fastAP.valueAdditive + elementalSilver;
  8373.             playerOffenseStats.silverFastCritDmg = (silverDmg + fastAP.valueBase) * (fastAP.valueMultiplicative + playerOffenseStats.silverFastCritDmg) + fastAP.valueAdditive + elementalSilver;  
  8374.         }
  8375.         else
  8376.         {
  8377.             playerOffenseStats.silverFastDmg = 0;
  8378.             playerOffenseStats.silverFastCritDmg = 0;  
  8379.         }
  8380.         playerOffenseStats.silverFastDPS = (playerOffenseStats.silverFastDmg * (100 - playerOffenseStats.silverFastCritChance) + playerOffenseStats.silverFastCritDmg * playerOffenseStats.silverFastCritChance) / 100;
  8381.         playerOffenseStats.silverFastDPS = playerOffenseStats.silverFastDPS / 0.6;
  8382.        
  8383.        
  8384.         playerOffenseStats.silverStrongCritChance = (silverCritChance + strongCritChance) * 100;
  8385.         playerOffenseStats.silverStrongCritDmg = silverCritDmg + strongCritDmg;    
  8386.         if ( silverDmg != 0 )
  8387.         {
  8388.             playerOffenseStats.silverStrongDmg = (silverDmg + strongAP.valueBase) * strongAP.valueMultiplicative + strongAP.valueAdditive + elementalSilver;
  8389.             playerOffenseStats.silverStrongDmg *= 1.833f;
  8390.             playerOffenseStats.silverStrongCritDmg = (silverDmg + strongAP.valueBase) * (strongAP.valueMultiplicative + playerOffenseStats.silverStrongCritDmg) + strongAP.valueAdditive + elementalSilver;
  8391.             playerOffenseStats.silverStrongCritDmg *= 1.833f;
  8392.         }
  8393.         else
  8394.         {
  8395.             playerOffenseStats.silverStrongDmg = 0;
  8396.             playerOffenseStats.silverStrongCritDmg = 0;
  8397.         }
  8398.         playerOffenseStats.silverStrongDPS = (playerOffenseStats.silverStrongDmg * (100 - playerOffenseStats.silverStrongCritChance) + playerOffenseStats.silverStrongCritDmg * playerOffenseStats.silverStrongCritChance) / 100;
  8399.         playerOffenseStats.silverStrongDPS = playerOffenseStats.silverStrongDPS / 1.1;
  8400.        
  8401.        
  8402.         playerOffenseStats.crossbowCritChance = GetCriticalHitChance( false, false, NULL, MC_NotSet, true );
  8403.    
  8404.        
  8405.         playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_PIERCING;
  8406.         if (GetItemEquippedOnSlot(EES_Bolt, item))
  8407.         {
  8408.            
  8409.            
  8410.             steelDmg = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FIRE));
  8411.             if(steelDmg > 0)
  8412.             {
  8413.                 playerOffenseStats.crossbowSteelDmg = steelDmg;
  8414.                
  8415.                 playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_FIRE;
  8416.                 playerOffenseStats.crossbowSilverDmg = steelDmg;
  8417.             }
  8418.             else
  8419.             {
  8420.                 playerOffenseStats.crossbowSilverDmg = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_SILVER));
  8421.                
  8422.                 steelDmg = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_PIERCING));
  8423.                 if(steelDmg > 0)
  8424.                 {
  8425.                     playerOffenseStats.crossbowSteelDmg = steelDmg;
  8426.                     playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_PIERCING;
  8427.                 }
  8428.                 else
  8429.                 {
  8430.                     playerOffenseStats.crossbowSteelDmg = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_BLUDGEONING));
  8431.                     playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_BLUDGEONING;
  8432.                 }
  8433.             }
  8434.         }
  8435.        
  8436.         if (GetItemEquippedOnSlot(EES_RangedWeapon, item))
  8437.         {
  8438.             attackPower += GetInventory().GetItemAttributeValue(item, PowerStatEnumToName(CPS_AttackPower));
  8439.             if(CanUseSkill(S_Perk_02))
  8440.             {              
  8441.                 attackPower += GetSkillAttributeValue(S_Perk_02, PowerStatEnumToName(CPS_AttackPower), false, true);
  8442.             }
  8443.  
  8444.            
  8445.             if( hackMode != 1 && ( IsMutationActive( EPMT_Mutation9 ) || hackMode == 2 ) )
  8446.             {
  8447.                 theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Mutation9', 'damage', min, max );
  8448.                 playerOffenseStats.crossbowSteelDmg += min.valueAdditive;
  8449.                 playerOffenseStats.crossbowSilverDmg += min.valueAdditive;
  8450.             }      
  8451.            
  8452.             playerOffenseStats.crossbowSteelDmg = (playerOffenseStats.crossbowSteelDmg + attackPower.valueBase) * attackPower.valueMultiplicative + attackPower.valueAdditive;
  8453.             playerOffenseStats.crossbowSilverDmg = (playerOffenseStats.crossbowSilverDmg + attackPower.valueBase) * attackPower.valueMultiplicative + attackPower.valueAdditive;
  8454.         }
  8455.         else
  8456.         {
  8457.             playerOffenseStats.crossbowSteelDmg = 0;
  8458.             playerOffenseStats.crossbowSilverDmg = 0;
  8459.             playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_PIERCING;
  8460.         }
  8461.        
  8462.         return playerOffenseStats;
  8463.     }
  8464.    
  8465.     public function GetTotalWeaponDamage(weaponId : SItemUniqueId, damageTypeName : name, crossbowId : SItemUniqueId) : float
  8466.     {
  8467.         var damage, durRatio, durMod, itemMod : float;
  8468.         var repairObjectBonus, min, max : SAbilityAttributeValue;
  8469.        
  8470.         durMod = 0;
  8471.         damage = super.GetTotalWeaponDamage(weaponId, damageTypeName, crossbowId);
  8472.        
  8473.        
  8474.         if( IsMutationActive( EPMT_Mutation9 ) && inv.IsItemBolt( weaponId ) && IsDamageTypeAnyPhysicalType( damageTypeName ) )
  8475.         {
  8476.             theGame.GetDefinitionsManager().GetAbilityAttributeValue('Mutation9', 'damage', min, max);
  8477.             damage += min.valueAdditive;
  8478.         }
  8479.        
  8480.        
  8481.         if(IsPhysicalResistStat(GetResistForDamage(damageTypeName, false)))
  8482.         {
  8483.             repairObjectBonus = inv.GetItemAttributeValue(weaponId, theGame.params.REPAIR_OBJECT_BONUS);
  8484.             durRatio = -1;
  8485.            
  8486.             if(inv.IsIdValid(crossbowId) && inv.HasItemDurability(crossbowId))
  8487.             {
  8488.                 durRatio = inv.GetItemDurabilityRatio(crossbowId);
  8489.             }
  8490.             else if(inv.IsIdValid(weaponId) && inv.HasItemDurability(weaponId))
  8491.             {
  8492.                 durRatio = inv.GetItemDurabilityRatio(weaponId);
  8493.             }
  8494.            
  8495.            
  8496.             if(durRatio >= 0)
  8497.                 durMod = theGame.params.GetDurabilityMultiplier(durRatio, true);
  8498.             else
  8499.                 durMod = 1;
  8500.         }
  8501.        
  8502.        
  8503.         if( damageTypeName == 'SilverDamage' && inv.ItemHasTag( weaponId, 'Aerondight' ) )
  8504.         {
  8505.             itemMod = inv.GetItemModifierFloat( weaponId, 'PermDamageBoost' );
  8506.             if( itemMod > 0.f )
  8507.             {
  8508.                 damage += itemMod;
  8509.             }
  8510.         }
  8511.        
  8512.         return damage * (durMod + repairObjectBonus.valueMultiplicative);
  8513.     }
  8514.    
  8515.    
  8516.    
  8517.    
  8518.    
  8519.     public final function GetSkillPathType(skill : ESkill) : ESkillPath
  8520.     {
  8521.         if(abilityManager && abilityManager.IsInitialized())
  8522.             return ((W3PlayerAbilityManager)abilityManager).GetSkillPathType(skill);
  8523.            
  8524.         return ESP_NotSet;
  8525.     }
  8526.    
  8527.     public function GetSkillLevel(s : ESkill) : int
  8528.     {
  8529.         if(abilityManager && abilityManager.IsInitialized())
  8530.             return ((W3PlayerAbilityManager)abilityManager).GetSkillLevel(s);
  8531.            
  8532.         return -1;
  8533.     }
  8534.    
  8535.     public function GetSkillMaxLevel(s : ESkill) : int
  8536.     {
  8537.         if(abilityManager && abilityManager.IsInitialized())
  8538.             return ((W3PlayerAbilityManager)abilityManager).GetSkillMaxLevel(s);
  8539.            
  8540.         return -1;
  8541.     }
  8542.    
  8543.     public function GetBoughtSkillLevel(s : ESkill) : int
  8544.     {
  8545.         if(abilityManager && abilityManager.IsInitialized())
  8546.             return ((W3PlayerAbilityManager)abilityManager).GetBoughtSkillLevel(s);
  8547.            
  8548.         return -1;
  8549.     }
  8550.    
  8551.    
  8552.     public function GetAxiiLevel() : int
  8553.     {
  8554.         var level : int;
  8555.        
  8556.         level = 1;
  8557.        
  8558.         if(CanUseSkill(S_Magic_s17)) level += GetSkillLevel(S_Magic_s17);
  8559.            
  8560.         return Clamp(level, 1, 4);
  8561.     }
  8562.    
  8563.     public function IsInFrenzy() : bool
  8564.     {
  8565.         return isInFrenzy;
  8566.     }
  8567.    
  8568.     public function HasRecentlyCountered() : bool
  8569.     {
  8570.         return hasRecentlyCountered;
  8571.     }
  8572.    
  8573.     public function SetRecentlyCountered(counter : bool)
  8574.     {
  8575.         hasRecentlyCountered = counter;
  8576.     }
  8577.    
  8578.     timer function CheckBlockedSkills(dt : float, id : int)
  8579.     {
  8580.         var nextCallTime : float;
  8581.        
  8582.         nextCallTime = ((W3PlayerAbilityManager)abilityManager).CheckBlockedSkills(dt);
  8583.         if(nextCallTime != -1)
  8584.             AddTimer('CheckBlockedSkills', nextCallTime, , , , true);
  8585.     }
  8586.        
  8587.    
  8588.     public function RemoveTemporarySkills()
  8589.     {
  8590.         var i : int;
  8591.         var pam : W3PlayerAbilityManager;
  8592.        
  8593.        
  8594.         if ( IsCastingSign() )
  8595.         {
  8596.             AddTimer( 'DelayedRemoveTemporarySkills', 0.1,,,, true );
  8597.             return;
  8598.         }
  8599.        
  8600.         AddTimer( 'SuperchargedSignCleanup', 0.1,,,, true );
  8601.        
  8602.    
  8603.         if(tempLearnedSignSkills.Size() > 0)
  8604.         {
  8605.             pam = (W3PlayerAbilityManager)abilityManager;
  8606.             for(i=0; i<tempLearnedSignSkills.Size(); i+=1)
  8607.             {
  8608.                 pam.RemoveTemporarySkill(tempLearnedSignSkills[i]);
  8609.             }
  8610.            
  8611.             tempLearnedSignSkills.Clear();                     
  8612.         }
  8613.         RemoveAbilityAll(SkillEnumToName(S_Sword_s19));
  8614.     }
  8615.    
  8616.    
  8617.    
  8618.     public timer function SuperchargedSignCleanup(dt : float, id : int)
  8619.     {
  8620.         superchargedSign = false;
  8621.     }
  8622.    
  8623.     public timer function DelayedRemoveTemporarySkills(dt : float, id : int)
  8624.     {
  8625.         var i : int;
  8626.         var pam : W3PlayerAbilityManager;
  8627.        
  8628.         if ( IsCastingSign() )
  8629.         {
  8630.             AddTimer( 'DelayedRemoveTemporarySkills', 0.1,,,, true );
  8631.             return;
  8632.         }
  8633.        
  8634.         AddTimer( 'SuperchargedSignCleanup', 0.1,,,, true );
  8635.        
  8636.         if(tempLearnedSignSkills.Size() > 0)
  8637.         {
  8638.             pam = (W3PlayerAbilityManager)abilityManager;
  8639.             for(i=0; i<tempLearnedSignSkills.Size(); i+=1)
  8640.             {
  8641.                 pam.RemoveTemporarySkill(tempLearnedSignSkills[i]);
  8642.             }
  8643.            
  8644.             tempLearnedSignSkills.Clear();
  8645.         }
  8646.         RemoveAbilityAll(SkillEnumToName(S_Sword_s19));
  8647.     }
  8648.    
  8649.    
  8650.    
  8651.     public function RemoveTemporarySkill(skill : SSimpleSkill) : bool
  8652.     {
  8653.         var pam : W3PlayerAbilityManager;
  8654.        
  8655.         pam = (W3PlayerAbilityManager)abilityManager;
  8656.         if(pam && pam.IsInitialized())
  8657.             return pam.RemoveTemporarySkill(skill);
  8658.            
  8659.         return false;
  8660.     }
  8661.    
  8662.    
  8663.    
  8664.     private var superchargedSign : bool;
  8665.     public function IsSuperchargedSign() : bool
  8666.     {
  8667.         return superchargedSign;
  8668.     }
  8669.    
  8670.    
  8671.    
  8672.    
  8673.     private function AddTemporarySkills()
  8674.     {
  8675.         if(CanUseSkill(S_Sword_s19) && GetStat(BCS_Focus) >= 3)
  8676.         {
  8677.             RemoveTemporarySkills();
  8678.             tempLearnedSignSkills = ((W3PlayerAbilityManager)abilityManager).AddTempNonAlchemySkills();                    
  8679.             DrainFocus(GetStat(BCS_Focus));
  8680.             if ( !this.HasAbility( SkillEnumToName(S_Sword_s19) ) )
  8681.                 AddAbilityMultiple(SkillEnumToName(S_Sword_s19), GetSkillLevel(S_Sword_s19));
  8682.            
  8683.             superchargedSign = true;
  8684.            
  8685.         }
  8686.     }
  8687.  
  8688.    
  8689.    
  8690.     public function HasAlternateQuen() : bool
  8691.     {
  8692.         var quenEntity : W3QuenEntity;
  8693.        
  8694.         quenEntity = (W3QuenEntity)GetCurrentSignEntity();
  8695.         if(quenEntity)
  8696.         {
  8697.             return quenEntity.IsAlternateCast();
  8698.         }
  8699.        
  8700.         return false;
  8701.     }
  8702.    
  8703.    
  8704.    
  8705.    
  8706.    
  8707.     public function AddPoints(type : ESpendablePointType, amount : int, show : bool)
  8708.     {
  8709.         levelManager.AddPoints(type, amount, show);
  8710.     }
  8711.    
  8712.     public function GetLevel() : int                                            {return levelManager.GetLevel();}
  8713.     public function GetMaxLevel() : int                                         {return levelManager.GetMaxLevel();}
  8714.     public function GetTotalExpForNextLevel() : int                             {return levelManager.GetTotalExpForNextLevel();}   
  8715.     public function GetPointsTotal(type : ESpendablePointType) : int            {return levelManager.GetPointsTotal(type);}
  8716.     public function IsAutoLeveling() : bool                                     {return autoLevel;}
  8717.     public function SetAutoLeveling( b : bool )                                 {autoLevel = b;}
  8718.    
  8719.     public function GetMissingExpForNextLevel() : int
  8720.     {
  8721.         return Max(0, GetTotalExpForNextLevel() - GetPointsTotal(EExperiencePoint));
  8722.     }
  8723.    
  8724.    
  8725.    
  8726.    
  8727.     private saved var runewordInfusionType : ESignType;
  8728.     default runewordInfusionType = ST_None;
  8729.    
  8730.     public final function GetRunewordInfusionType() : ESignType
  8731.     {
  8732.         return runewordInfusionType;
  8733.     }
  8734.    
  8735.    
  8736.     public function QuenImpulse( isAlternate : bool, signEntity : W3QuenEntity, source : string, optional forceSkillLevel : int )
  8737.     {
  8738.         var level, i, j : int;
  8739.         var atts, damages : array<name>;
  8740.         var ents : array<CGameplayEntity>;
  8741.         var action : W3DamageAction;
  8742.         var dm : CDefinitionsManagerAccessor;
  8743.         var skillAbilityName : name;
  8744.         var dmg : float;
  8745.         var min, max : SAbilityAttributeValue;
  8746.         var pos : Vector;
  8747.        
  8748.         if( forceSkillLevel > 0 )
  8749.         {
  8750.             level = forceSkillLevel;
  8751.         }
  8752.         else
  8753.         {
  8754.             level = GetSkillLevel(S_Magic_s13);
  8755.         }
  8756.        
  8757.         dm = theGame.GetDefinitionsManager();
  8758.         skillAbilityName = GetSkillAbilityName(S_Magic_s13);
  8759.        
  8760.         if(level >= 2)
  8761.         {
  8762.            
  8763.             dm.GetAbilityAttributes(skillAbilityName, atts);
  8764.             for(i=0; i<atts.Size(); i+=1)
  8765.             {
  8766.                 if(IsDamageTypeNameValid(atts[i]))
  8767.                 {
  8768.                     damages.PushBack(atts[i]);
  8769.                 }
  8770.             }
  8771.         }
  8772.        
  8773.        
  8774.         pos = signEntity.GetWorldPosition();
  8775.         FindGameplayEntitiesInSphere(ents, pos, 3, 1000, '', FLAG_OnlyAliveActors + FLAG_ExcludeTarget + FLAG_Attitude_Hostile + FLAG_Attitude_Neutral + FLAG_TestLineOfSight, this);
  8776.        
  8777.        
  8778.         for(i=0; i<ents.Size(); i+=1)
  8779.         {
  8780.             action = new W3DamageAction in theGame;
  8781.             action.Initialize(this, ents[i], signEntity, source, EHRT_Heavy, CPS_SpellPower, false, false, true, false);
  8782.             action.SetSignSkill(S_Magic_s13);
  8783.             action.SetCannotReturnDamage(true);
  8784.             action.SetProcessBuffsIfNoDamage(true);
  8785.            
  8786.            
  8787.             if(!isAlternate && level >= 2)
  8788.             {
  8789.                 action.SetHitEffect('hit_electric_quen');
  8790.                 action.SetHitEffect('hit_electric_quen', true);
  8791.                 action.SetHitEffect('hit_electric_quen', false, true);
  8792.                 action.SetHitEffect('hit_electric_quen', true, true);
  8793.             }
  8794.            
  8795.             if(level >= 1)
  8796.             {
  8797.                 action.AddEffectInfo(EET_Stagger);
  8798.             }
  8799.             if(level >= 2)
  8800.             {
  8801.                 for(j=0; j<damages.Size(); j+=1)
  8802.                 {
  8803.                     dm.GetAbilityAttributeValue(skillAbilityName, damages[j], min, max);
  8804.                     dmg = CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  8805.                     if( IsSetBonusActive( EISB_Bear_2 ) )
  8806.                     {
  8807.                         dm.GetAbilityAttributeValue( GetSetBonusAbility( EISB_Bear_2 ), 'quen_dmg_boost', min, max );
  8808.                         dmg *= 1 + min.valueMultiplicative;                    
  8809.                     }                  
  8810.                     action.AddDamage(damages[j], dmg);
  8811.                 }
  8812.             }
  8813.             if(level == 3)
  8814.             {
  8815.                 action.AddEffectInfo(EET_KnockdownTypeApplicator);
  8816.             }
  8817.            
  8818.             theGame.damageMgr.ProcessAction( action );
  8819.             delete action;
  8820.         }
  8821.        
  8822.        
  8823.         if(isAlternate)
  8824.         {
  8825.             signEntity.PlayHitEffect('quen_impulse_explode', signEntity.GetWorldRotation());
  8826.             signEntity.EraseFirstTimeStamp();
  8827.                        
  8828.            
  8829.             if(level >= 2)
  8830.             {
  8831.                 if( !IsSetBonusActive( EISB_Bear_2 ) )
  8832.                 {
  8833.                     signEntity.PlayHitEffect('quen_electric_explode', signEntity.GetWorldRotation());
  8834.                 }
  8835.                 else
  8836.                 {
  8837.                     signEntity.PlayHitEffect('quen_electric_explode_bear_abl2', signEntity.GetWorldRotation());
  8838.                 }
  8839.             }
  8840.         }
  8841.         else
  8842.         {
  8843.             signEntity.PlayEffect('lasting_shield_impulse');
  8844.         }      
  8845.     }
  8846.  
  8847.     public function OnSignCastPerformed(signType : ESignType, isAlternate : bool)
  8848.     {
  8849.         var items : array<SItemUniqueId>;
  8850.         var weaponEnt : CEntity;
  8851.         var fxName : name;
  8852.         var pos : Vector;
  8853.        
  8854.         super.OnSignCastPerformed(signType, isAlternate);
  8855.        
  8856.         if(HasAbility('Runeword 1 _Stats', true) && GetStat(BCS_Focus) >= 1.0f)
  8857.         {
  8858.             DrainFocus(1.0f);
  8859.             runewordInfusionType = signType;
  8860.             items = inv.GetHeldWeapons();
  8861.             weaponEnt = inv.GetItemEntityUnsafe(items[0]);
  8862.            
  8863.            
  8864.             weaponEnt.StopEffect('runeword_aard');
  8865.             weaponEnt.StopEffect('runeword_axii');
  8866.             weaponEnt.StopEffect('runeword_igni');
  8867.             weaponEnt.StopEffect('runeword_quen');
  8868.             weaponEnt.StopEffect('runeword_yrden');
  8869.                    
  8870.            
  8871.             if(signType == ST_Aard)
  8872.                 fxName = 'runeword_aard';
  8873.             else if(signType == ST_Axii)
  8874.                 fxName = 'runeword_axii';
  8875.             else if(signType == ST_Igni)
  8876.                 fxName = 'runeword_igni';
  8877.             else if(signType == ST_Quen)
  8878.                 fxName = 'runeword_quen';
  8879.             else if(signType == ST_Yrden)
  8880.                 fxName = 'runeword_yrden';
  8881.                
  8882.             weaponEnt.PlayEffect(fxName);
  8883.         }
  8884.        
  8885.        
  8886.         if( IsMutationActive( EPMT_Mutation6 ) && signType == ST_Aard && !isAlternate )
  8887.         {
  8888.             pos = GetWorldPosition() + GetWorldForward() * 2;
  8889.            
  8890.             theGame.GetSurfacePostFX().AddSurfacePostFXGroup( pos, 0.f, 3.f, 2.f, 5.f, 0 );
  8891.         }
  8892.     }
  8893.    
  8894.     public saved var savedQuenHealth, savedQuenDuration : float;
  8895.    
  8896.     timer function HACK_QuenSaveStatus(dt : float, id : int)
  8897.     {
  8898.         var quenEntity : W3QuenEntity;
  8899.        
  8900.         quenEntity = (W3QuenEntity)signs[ST_Quen].entity;
  8901.         savedQuenHealth = quenEntity.GetShieldHealth();
  8902.         savedQuenDuration = quenEntity.GetShieldRemainingDuration();
  8903.     }
  8904.    
  8905.     timer function DelayedRestoreQuen(dt : float, id : int)
  8906.     {
  8907.         RestoreQuen(savedQuenHealth, savedQuenDuration);
  8908.     }
  8909.    
  8910.     public final function OnBasicQuenFinishing()
  8911.     {
  8912.         RemoveTimer('HACK_QuenSaveStatus');
  8913.         savedQuenHealth = 0.f;
  8914.         savedQuenDuration = 0.f;
  8915.     }
  8916.    
  8917.     public final function IsAnyQuenActive() : bool
  8918.     {
  8919.         var quen : W3QuenEntity;
  8920.        
  8921.         quen = (W3QuenEntity)GetSignEntity(ST_Quen);
  8922.         if(quen)
  8923.             return quen.IsAnyQuenActive();
  8924.            
  8925.         return false;
  8926.     }
  8927.    
  8928.     public final function IsQuenActive(alternateMode : bool) : bool
  8929.     {
  8930.         if(IsAnyQuenActive() && GetSignEntity(ST_Quen).IsAlternateCast() == alternateMode)
  8931.             return true;
  8932.            
  8933.         return false;
  8934.     }
  8935.    
  8936.     public function FinishQuen( skipVisuals : bool, optional forceNoBearSetBonus : bool )
  8937.     {
  8938.         var quen : W3QuenEntity;
  8939.        
  8940.         quen = (W3QuenEntity)GetSignEntity(ST_Quen);
  8941.         if(quen)
  8942.             quen.ForceFinishQuen( skipVisuals, forceNoBearSetBonus );
  8943.     }
  8944.    
  8945.    
  8946.     public function GetTotalSignSpellPower(signSkill : ESkill) : SAbilityAttributeValue
  8947.     {
  8948.         var sp : SAbilityAttributeValue;
  8949.         var penalty : SAbilityAttributeValue;
  8950.         var penaltyReduction : float;
  8951.         var penaltyReductionLevel : int;
  8952.        
  8953.        
  8954.         sp = GetSkillAttributeValue(signSkill, PowerStatEnumToName(CPS_SpellPower), true, true);
  8955.        
  8956.        
  8957.         if ( signSkill == S_Magic_s01 )
  8958.         {
  8959.            
  8960.             penaltyReductionLevel = GetSkillLevel(S_Magic_s01) + 1;
  8961.             if(penaltyReductionLevel > 0)
  8962.             {
  8963.                 penaltyReduction = 1 - penaltyReductionLevel * CalculateAttributeValue(GetSkillAttributeValue(S_Magic_s01, 'spell_power_penalty_reduction', true, true));
  8964.                 penalty = GetSkillAttributeValue(S_Magic_s01, PowerStatEnumToName(CPS_SpellPower), false, false);
  8965.                 sp += penalty * penaltyReduction;  
  8966.             }
  8967.         }
  8968.        
  8969.        
  8970.         if(signSkill == S_Magic_1 || signSkill == S_Magic_s01)
  8971.         {
  8972.             sp += GetAttributeValue('spell_power_aard');
  8973.         }
  8974.         else if(signSkill == S_Magic_2 || signSkill == S_Magic_s02)
  8975.         {
  8976.             sp += GetAttributeValue('spell_power_igni');
  8977.         }
  8978.         else if(signSkill == S_Magic_3 || signSkill == S_Magic_s03)
  8979.         {
  8980.             sp += GetAttributeValue('spell_power_yrden');
  8981.         }
  8982.         else if(signSkill == S_Magic_4 || signSkill == S_Magic_s04)
  8983.         {
  8984.             sp += GetAttributeValue('spell_power_quen');
  8985.         }
  8986.         else if(signSkill == S_Magic_5 || signSkill == S_Magic_s05)
  8987.         {
  8988.             sp += GetAttributeValue('spell_power_axii');
  8989.         }
  8990.        
  8991.        
  8992.         ApplyMutation10StatBoost( sp );
  8993.    
  8994.         return sp;
  8995.     }
  8996.    
  8997.    
  8998.    
  8999.    
  9000.    
  9001.     public final function GetGwentCardIndex( cardName : name ) : int
  9002.     {
  9003.         var dm : CDefinitionsManagerAccessor;
  9004.        
  9005.         dm = theGame.GetDefinitionsManager();
  9006.        
  9007.         if(dm.ItemHasTag( cardName , 'GwintCardLeader' ))
  9008.         {
  9009.             return theGame.GetGwintManager().GwentLeadersNametoInt( cardName );
  9010.         }
  9011.         else if(dm.ItemHasTag( cardName , 'GwintCardNrkd' ))
  9012.         {
  9013.             return theGame.GetGwintManager().GwentNrkdNameToInt( cardName );
  9014.         }
  9015.         else if(dm.ItemHasTag( cardName , 'GwintCardNlfg' ))
  9016.         {
  9017.             return theGame.GetGwintManager().GwentNlfgNameToInt( cardName );
  9018.         }
  9019.         else if(dm.ItemHasTag( cardName , 'GwintCardSctl' ))
  9020.         {
  9021.             return theGame.GetGwintManager().GwentSctlNameToInt( cardName );
  9022.         }
  9023.         else if(dm.ItemHasTag( cardName , 'GwintCardMstr' ))
  9024.         {
  9025.             return theGame.GetGwintManager().GwentMstrNameToInt( cardName );
  9026.         }
  9027.         else if(dm.ItemHasTag( cardName , 'GwintCardSke' ))
  9028.         {
  9029.             return theGame.GetGwintManager().GwentSkeNameToInt( cardName );
  9030.         }  
  9031.         else if(dm.ItemHasTag( cardName , 'GwintCardNeutral' ))
  9032.         {
  9033.             return theGame.GetGwintManager().GwentNeutralNameToInt( cardName );
  9034.         }
  9035.         else if(dm.ItemHasTag( cardName , 'GwintCardSpcl' ))
  9036.         {
  9037.             return theGame.GetGwintManager().GwentSpecialNameToInt( cardName );
  9038.         }
  9039.        
  9040.         return -1;
  9041.     }
  9042.    
  9043.     public final function AddGwentCard(cardName : name, amount : int) : bool
  9044.     {
  9045.         var dm : CDefinitionsManagerAccessor;
  9046.         var cardIndex, i : int;
  9047.         var tut : STutorialMessage;
  9048.         var gwintManager : CR4GwintManager;
  9049.        
  9050.        
  9051.        
  9052.         if(FactsQuerySum("q001_nightmare_ended") > 0 && ShouldProcessTutorial('TutorialGwentDeckBuilder2'))
  9053.         {
  9054.             tut.type = ETMT_Hint;
  9055.             tut.tutorialScriptTag = 'TutorialGwentDeckBuilder2';
  9056.             tut.journalEntryName = 'TutorialGwentDeckBuilder2';
  9057.             tut.hintPositionType = ETHPT_DefaultGlobal;
  9058.             tut.markAsSeenOnShow = true;
  9059.             tut.hintDurationType = ETHDT_Long;
  9060.  
  9061.             theGame.GetTutorialSystem().DisplayTutorial(tut);
  9062.         }
  9063.        
  9064.         dm = theGame.GetDefinitionsManager();
  9065.        
  9066.         cardIndex = GetGwentCardIndex(cardName);
  9067.        
  9068.         if (cardIndex != -1)
  9069.         {
  9070.             FactsAdd("Gwint_Card_Looted");
  9071.            
  9072.             for(i = 0; i < amount; i += 1)
  9073.             {
  9074.                 theGame.GetGwintManager().AddCardToCollection( cardIndex );
  9075.             }
  9076.         }
  9077.        
  9078.         if( dm.ItemHasTag( cardName, 'GwentTournament' ) )
  9079.         {
  9080.             if ( dm.ItemHasTag( cardName, 'GT1' ) )
  9081.             {
  9082.                 FactsAdd( "GwentTournament", 1 );
  9083.             }
  9084.            
  9085.             else if ( dm.ItemHasTag( cardName, 'GT2' ) )
  9086.             {
  9087.                 FactsAdd( "GwentTournament", 2 );
  9088.             }
  9089.            
  9090.             else if ( dm.ItemHasTag( cardName, 'GT3' ) )
  9091.             {
  9092.                 FactsAdd( "GwentTournament", 3 );
  9093.             }
  9094.            
  9095.             else if ( dm.ItemHasTag( cardName, 'GT4' ) )
  9096.             {
  9097.                 FactsAdd( "GwentTournament", 4 );
  9098.             }
  9099.            
  9100.             else if ( dm.ItemHasTag( cardName, 'GT5' ) )
  9101.             {
  9102.                 FactsAdd( "GwentTournament", 5 );
  9103.             }
  9104.            
  9105.             else if ( dm.ItemHasTag( cardName, 'GT6' ) )
  9106.             {
  9107.                 FactsAdd( "GwentTournament", 6 );
  9108.             }
  9109.            
  9110.             else if ( dm.ItemHasTag( cardName, 'GT7' ) )
  9111.             {
  9112.                 FactsAdd( "GwentTournament", 7 );
  9113.             }
  9114.            
  9115.             CheckGwentTournamentDeck();
  9116.         }
  9117.        
  9118.         if( dm.ItemHasTag( cardName, 'EP2Tournament' ) )
  9119.         {
  9120.             if ( dm.ItemHasTag( cardName, 'GT1' ) )
  9121.             {
  9122.                 FactsAdd( "EP2Tournament", 1 );
  9123.             }
  9124.            
  9125.             else if ( dm.ItemHasTag( cardName, 'GT2' ) )
  9126.             {
  9127.                 FactsAdd( "EP2Tournament", 2 );
  9128.             }
  9129.            
  9130.             else if ( dm.ItemHasTag( cardName, 'GT3' ) )
  9131.             {
  9132.                 FactsAdd( "EP2Tournament", 3 );
  9133.             }
  9134.            
  9135.             else if ( dm.ItemHasTag( cardName, 'GT4' ) )
  9136.             {
  9137.                 FactsAdd( "EP2Tournament", 4 );
  9138.             }
  9139.            
  9140.             else if ( dm.ItemHasTag( cardName, 'GT5' ) )
  9141.             {
  9142.                 FactsAdd( "EP2Tournament", 5 );
  9143.             }
  9144.            
  9145.             else if ( dm.ItemHasTag( cardName, 'GT6' ) )
  9146.             {
  9147.                 FactsAdd( "EP2Tournament", 6 );
  9148.             }
  9149.            
  9150.             else if ( dm.ItemHasTag( cardName, 'GT7' ) )
  9151.             {
  9152.                 FactsAdd( "EP2Tournament", 7 );
  9153.             }
  9154.            
  9155.             CheckEP2TournamentDeck();
  9156.         }
  9157.        
  9158.         gwintManager = theGame.GetGwintManager();
  9159.         if( !gwintManager.IsDeckUnlocked( GwintFaction_Skellige ) &&
  9160.             gwintManager.HasCardsOfFactionInCollection( GwintFaction_Skellige, false ) )
  9161.         {
  9162.             gwintManager.UnlockDeck( GwintFaction_Skellige );
  9163.         }
  9164.        
  9165.         return true;
  9166.     }
  9167.    
  9168.    
  9169.     public final function RemoveGwentCard(cardName : name, amount : int) : bool
  9170.     {
  9171.         var dm : CDefinitionsManagerAccessor;
  9172.         var cardIndex, i : int;
  9173.        
  9174.         dm = theGame.GetDefinitionsManager();
  9175.        
  9176.         if(dm.ItemHasTag( cardName , 'GwintCardLeader' ))
  9177.         {
  9178.             cardIndex = theGame.GetGwintManager().GwentLeadersNametoInt( cardName );
  9179.             for(i=0; i<amount; i+=1)
  9180.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  9181.         }
  9182.         else if(dm.ItemHasTag( cardName , 'GwintCardNrkd' ))
  9183.         {
  9184.             cardIndex = theGame.GetGwintManager().GwentNrkdNameToInt( cardName );
  9185.             for(i=0; i<amount; i+=1)
  9186.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  9187.         }
  9188.         else if(dm.ItemHasTag( cardName , 'GwintCardNlfg' ))
  9189.         {
  9190.             cardIndex = theGame.GetGwintManager().GwentNlfgNameToInt( cardName );
  9191.             for(i=0; i<amount; i+=1)
  9192.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  9193.         }
  9194.         else if(dm.ItemHasTag( cardName , 'GwintCardSctl' ))
  9195.         {
  9196.             cardIndex = theGame.GetGwintManager().GwentSctlNameToInt( cardName );
  9197.             for(i=0; i<amount; i+=1)
  9198.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  9199.         }
  9200.         else if(dm.ItemHasTag( cardName , 'GwintCardMstr' ))
  9201.         {
  9202.             cardIndex = theGame.GetGwintManager().GwentMstrNameToInt( cardName );
  9203.             for(i=0; i<amount; i+=1)
  9204.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  9205.         }
  9206.         else if(dm.ItemHasTag( cardName , 'GwintCardNeutral' ))
  9207.         {
  9208.             cardIndex = theGame.GetGwintManager().GwentNeutralNameToInt( cardName );
  9209.             for(i=0; i<amount; i+=1)
  9210.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  9211.         }
  9212.         else if(dm.ItemHasTag( cardName , 'GwintCardSpcl' ))
  9213.         {
  9214.             cardIndex = theGame.GetGwintManager().GwentSpecialNameToInt( cardName );
  9215.             for(i=0; i<amount; i+=1)
  9216.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  9217.         }
  9218.        
  9219.         if( dm.ItemHasTag( cardName, 'GwentTournament' ) )
  9220.         {
  9221.             if ( dm.ItemHasTag( cardName, 'GT1' ) )
  9222.             {
  9223.                 FactsSubstract( "GwentTournament", 1 );
  9224.             }
  9225.            
  9226.             else if ( dm.ItemHasTag( cardName, 'GT2' ) )
  9227.             {
  9228.                 FactsSubstract( "GwentTournament", 2 );
  9229.             }
  9230.            
  9231.             else if ( dm.ItemHasTag( cardName, 'GT3' ) )
  9232.             {
  9233.                 FactsSubstract( "GwentTournament", 3 );
  9234.             }
  9235.            
  9236.             else if ( dm.ItemHasTag( cardName, 'GT4' ) )
  9237.             {
  9238.                 FactsSubstract( "GwentTournament", 4 );
  9239.             }
  9240.            
  9241.             else if ( dm.ItemHasTag( cardName, 'GT5' ) )
  9242.             {
  9243.                 FactsSubstract( "GwentTournament", 5 );
  9244.             }
  9245.            
  9246.             else if ( dm.ItemHasTag( cardName, 'GT6' ) )
  9247.             {
  9248.                 FactsSubstract( "GwentTournament", 6 );
  9249.             }
  9250.            
  9251.             else if ( dm.ItemHasTag( cardName, 'GT7' ) )
  9252.             {
  9253.                 FactsSubstract( "GwentTournament", 7 );
  9254.             }
  9255.            
  9256.             CheckGwentTournamentDeck();
  9257.         }
  9258.            
  9259.            
  9260.         if( dm.ItemHasTag( cardName, 'EP2Tournament' ) )
  9261.         {
  9262.             if ( dm.ItemHasTag( cardName, 'GT1' ) )
  9263.             {
  9264.                 FactsSubstract( "EP2Tournament", 1 );
  9265.             }
  9266.            
  9267.             else if ( dm.ItemHasTag( cardName, 'GT2' ) )
  9268.             {
  9269.                 FactsSubstract( "EP2Tournament", 2 );
  9270.             }
  9271.            
  9272.             else if ( dm.ItemHasTag( cardName, 'GT3' ) )
  9273.             {
  9274.                 FactsSubstract( "EP2Tournament", 3 );
  9275.             }
  9276.            
  9277.             else if ( dm.ItemHasTag( cardName, 'GT4' ) )
  9278.             {
  9279.                 FactsSubstract( "EP2Tournament", 4 );
  9280.             }
  9281.            
  9282.             else if ( dm.ItemHasTag( cardName, 'GT5' ) )
  9283.             {
  9284.                 FactsSubstract( "EP2Tournament", 5 );
  9285.             }
  9286.            
  9287.             else if ( dm.ItemHasTag( cardName, 'GT6' ) )
  9288.             {
  9289.                 FactsSubstract( "EP2Tournament", 6 );
  9290.             }
  9291.            
  9292.             else if ( dm.ItemHasTag( cardName, 'GT7' ) )
  9293.             {
  9294.                 FactsSubstract( "EP2Tournament", 7 );
  9295.             }
  9296.            
  9297.             CheckEP2TournamentDeck();
  9298.         }
  9299.        
  9300.         return true;
  9301.     }
  9302.    
  9303.     function CheckGwentTournamentDeck()
  9304.     {
  9305.         var gwentPower          : int;
  9306.         var neededGwentPower    : int;
  9307.         var checkBreakpoint     : int;
  9308.        
  9309.         neededGwentPower = 70;
  9310.        
  9311.         checkBreakpoint = neededGwentPower/5;
  9312.         gwentPower = FactsQuerySum( "GwentTournament" );
  9313.        
  9314.         if ( gwentPower >= neededGwentPower )
  9315.         {
  9316.             FactsAdd( "HasGwentTournamentDeck", 1 );
  9317.         }
  9318.         else
  9319.         {
  9320.             if( FactsDoesExist( "HasGwentTournamentDeck" ) )
  9321.             {
  9322.                 FactsRemove( "HasGwentTournamentDeck" );
  9323.             }
  9324.            
  9325.             if ( gwentPower >= checkBreakpoint )
  9326.             {
  9327.                 FactsAdd( "GwentTournamentObjective1", 1 );
  9328.             }
  9329.             else if ( FactsDoesExist( "GwentTournamentObjective1" ) )
  9330.             {
  9331.                 FactsRemove( "GwentTournamentObjective1" );
  9332.             }
  9333.            
  9334.             if ( gwentPower >= checkBreakpoint*2 )
  9335.             {
  9336.                 FactsAdd( "GwentTournamentObjective2", 1 );
  9337.             }
  9338.             else if ( FactsDoesExist( "GwentTournamentObjective2" ) )
  9339.             {
  9340.                 FactsRemove( "GwentTournamentObjective2" );
  9341.             }
  9342.            
  9343.             if ( gwentPower >= checkBreakpoint*3 )
  9344.             {
  9345.                 FactsAdd( "GwentTournamentObjective3", 1 );
  9346.             }
  9347.             else if ( FactsDoesExist( "GwentTournamentObjective3" ) )
  9348.             {
  9349.                 FactsRemove( "GwentTournamentObjective3" );
  9350.             }
  9351.            
  9352.             if ( gwentPower >= checkBreakpoint*4 )
  9353.             {
  9354.                 FactsAdd( "GwentTournamentObjective4", 1 );
  9355.             }
  9356.             else if ( FactsDoesExist( "GwentTournamentObjective4" ) )
  9357.             {
  9358.                 FactsRemove( "GwentTournamentObjective4" );
  9359.             }
  9360.         }
  9361.     }
  9362.    
  9363.     function CheckEP2TournamentDeck()
  9364.     {
  9365.         var gwentPower          : int;
  9366.         var neededGwentPower    : int;
  9367.         var checkBreakpoint     : int;
  9368.        
  9369.         neededGwentPower = 24;
  9370.        
  9371.         checkBreakpoint = neededGwentPower/5;
  9372.         gwentPower = FactsQuerySum( "EP2Tournament" );
  9373.        
  9374.         if ( gwentPower >= neededGwentPower )
  9375.         {
  9376.             if( FactsQuerySum( "HasEP2TournamentDeck") == 0 )
  9377.             {
  9378.                 FactsAdd( "HasEP2TournamentDeck", 1 );
  9379.             }
  9380.            
  9381.         }
  9382.         else
  9383.         {
  9384.             if( FactsDoesExist( "HasEP2TournamentDeck" ) )
  9385.             {
  9386.                 FactsRemove( "HasEP2TournamentDeck" );
  9387.             }
  9388.            
  9389.             if ( gwentPower >= checkBreakpoint )
  9390.             {
  9391.                 FactsAdd( "EP2TournamentObjective1", 1 );
  9392.             }
  9393.             else if ( FactsDoesExist( "EP2TournamentObjective1" ) )
  9394.             {
  9395.                 FactsRemove( "EP2TournamentObjective1" );
  9396.             }
  9397.            
  9398.             if ( gwentPower >= checkBreakpoint*2 )
  9399.             {
  9400.                 FactsAdd( "EP2TournamentObjective2", 1 );
  9401.             }
  9402.             else if ( FactsDoesExist( "EP2TournamentObjective2" ) )
  9403.             {
  9404.                 FactsRemove( "EP2TournamentObjective2" );
  9405.             }
  9406.            
  9407.             if ( gwentPower >= checkBreakpoint*3 )
  9408.             {
  9409.                 FactsAdd( "EP2TournamentObjective3", 1 );
  9410.             }
  9411.             else if ( FactsDoesExist( "EP2TournamentObjective3" ) )
  9412.             {
  9413.                 FactsRemove( "EP2TournamentObjective3" );
  9414.             }
  9415.            
  9416.             if ( gwentPower >= checkBreakpoint*4 )
  9417.             {
  9418.                 FactsAdd( "EP2TournamentObjective4", 1 );
  9419.             }
  9420.             else if ( FactsDoesExist( "EP2TournamentObjective4" ) )
  9421.             {
  9422.                 FactsRemove( "EP2TournamentObjective4" );
  9423.             }
  9424.         }
  9425.     }
  9426.    
  9427.    
  9428.    
  9429.    
  9430.    
  9431.    
  9432.     public function SimulateBuffTimePassing(simulatedTime : float)
  9433.     {
  9434.         super.SimulateBuffTimePassing(simulatedTime);
  9435.        
  9436.         FinishQuen(true);
  9437.     }
  9438.    
  9439.    
  9440.     public function CanMeditate() : bool
  9441.     {
  9442.         var currentStateName : name;
  9443.        
  9444.         currentStateName = GetCurrentStateName();
  9445.        
  9446.        
  9447.         if(currentStateName == 'Exploration' && !CanPerformPlayerAction())
  9448.             return false;
  9449.        
  9450.        
  9451.         if(GetCurrentStateName() != 'Exploration' && GetCurrentStateName() != 'Meditation' && GetCurrentStateName() != 'MeditationWaiting')
  9452.             return false;
  9453.            
  9454.        
  9455.         if(GetUsedVehicle())
  9456.             return false;
  9457.            
  9458.        
  9459.         return CanMeditateHere();
  9460.     }
  9461.    
  9462.    
  9463.     public final function CanMeditateWait(optional skipMeditationStateCheck : bool) : bool
  9464.     {
  9465.         var currState : name;
  9466.        
  9467.         currState = GetCurrentStateName();
  9468.        
  9469.        
  9470.        
  9471.         if(!skipMeditationStateCheck && currState != 'Meditation')
  9472.             return false;
  9473.            
  9474.        
  9475.         if(theGame.IsGameTimePaused())
  9476.             return false;
  9477.            
  9478.         if(!IsActionAllowed( EIAB_MeditationWaiting ))
  9479.             return false;
  9480.            
  9481.         return true;
  9482.     }
  9483.  
  9484.    
  9485.     public final function CanMeditateHere() : bool
  9486.     {
  9487.         var pos : Vector;
  9488.        
  9489.         pos = GetWorldPosition();
  9490.         if(pos.Z <= theGame.GetWorld().GetWaterLevel(pos, true) && IsInShallowWater())
  9491.             return false;
  9492.        
  9493.         if(IsThreatened())
  9494.             return false;
  9495.        
  9496.         return true;
  9497.     }
  9498.    
  9499.    
  9500.     public function Meditate() : bool
  9501.     {
  9502.         var medState            : W3PlayerWitcherStateMeditation;
  9503.         var stateName           : name;
  9504.    
  9505.         stateName = GetCurrentStateName();
  9506.    
  9507.        
  9508.         if (!CanMeditate()  || stateName == 'MeditationWaiting' )
  9509.             return false;
  9510.    
  9511.         GotoState('Meditation');
  9512.         medState = (W3PlayerWitcherStateMeditation)GetState('Meditation');     
  9513.         medState.SetMeditationPointHeading(GetHeading());
  9514.        
  9515.         return true;
  9516.     }
  9517.    
  9518.    
  9519.     public final function MeditationRestoring(simulatedTime : float)
  9520.     {          
  9521.        
  9522.         if ( theGame.GetDifficultyMode() != EDM_Hard && theGame.GetDifficultyMode() != EDM_Hardcore )
  9523.         {
  9524.             Heal(GetStatMax(BCS_Vitality));
  9525.         }
  9526.        
  9527.        
  9528.         abilityManager.DrainToxicity( abilityManager.GetStat( BCS_Toxicity ) );
  9529.         abilityManager.DrainFocus( abilityManager.GetStat( BCS_Focus ) );
  9530.        
  9531.        
  9532.         inv.SingletonItemsRefillAmmo();
  9533.        
  9534.        
  9535.         SimulateBuffTimePassing(simulatedTime);
  9536.        
  9537.        
  9538.         ApplyWitcherHouseBuffs();
  9539.     }
  9540.    
  9541.     var clockMenu : CR4MeditationClockMenu;
  9542.    
  9543.     public function MeditationClockStart(m : CR4MeditationClockMenu)
  9544.     {
  9545.         clockMenu = m;
  9546.         AddTimer('UpdateClockTime',0.1,true);
  9547.     }
  9548.    
  9549.     public function MeditationClockStop()
  9550.     {
  9551.         clockMenu = NULL;
  9552.         RemoveTimer('UpdateClockTime');
  9553.     }
  9554.    
  9555.     public timer function UpdateClockTime(dt : float, id : int)
  9556.     {
  9557.         if(clockMenu)
  9558.             clockMenu.UpdateCurrentHours();
  9559.         else
  9560.             RemoveTimer('UpdateClockTime');
  9561.     }
  9562.    
  9563.     private var waitTimeHour : int;
  9564.     public function SetWaitTargetHour(t : int)
  9565.     {
  9566.         waitTimeHour = t;
  9567.     }
  9568.     public function GetWaitTargetHour() : int
  9569.     {
  9570.         return waitTimeHour;
  9571.     }
  9572.    
  9573.     public function MeditationForceAbort(forceCloseUI : bool)
  9574.     {
  9575.         var waitt : W3PlayerWitcherStateMeditationWaiting;
  9576.         var medd : W3PlayerWitcherStateMeditation;
  9577.         var currentStateName : name;
  9578.        
  9579.         currentStateName = GetCurrentStateName();
  9580.        
  9581.         if(currentStateName == 'MeditationWaiting')
  9582.         {
  9583.             waitt = (W3PlayerWitcherStateMeditationWaiting)GetCurrentState();
  9584.             if(waitt)
  9585.             {
  9586.                 waitt.StopRequested(forceCloseUI);
  9587.             }
  9588.         }
  9589.         else if(currentStateName == 'Meditation')
  9590.         {
  9591.             medd = (W3PlayerWitcherStateMeditation)GetCurrentState();
  9592.             if(medd)
  9593.             {
  9594.                 medd.StopRequested(forceCloseUI);
  9595.             }
  9596.         }
  9597.        
  9598.        
  9599.        
  9600.         if( forceCloseUI && theGame.GetGuiManager().IsAnyMenu() && !theGame.GetPhotomodeEnabled() )
  9601.         {
  9602.             theGame.GetGuiManager().GetRootMenu().CloseMenu();
  9603.             DisplayActionDisallowedHudMessage(EIAB_MeditationWaiting, false, false, true, false);
  9604.         }
  9605.     }
  9606.    
  9607.     public function Runeword10Triggerred()
  9608.     {
  9609.         var min, max : SAbilityAttributeValue;
  9610.         var amount : float;
  9611.        
  9612.        
  9613.        
  9614.         theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Runeword 10 _Stats', 'stamina_runeword_gain', min, max );
  9615.        
  9616.        
  9617.         amount = min.valueMultiplicative * GetStatMax(BCS_Stamina);
  9618.         if ( GetStat(BCS_Stamina) + amount > GetStatMax(BCS_Stamina) )
  9619.         {
  9620.             amount = GetStatMax(BCS_Stamina) - GetStat(BCS_Stamina);
  9621.         }
  9622.         GainStat(BCS_Stamina, amount);
  9623.        
  9624.        
  9625.         PlayEffect('runeword_10_stamina');
  9626.     }
  9627.    
  9628.     public function Runeword12Triggerred()
  9629.     {
  9630.         var min, max : SAbilityAttributeValue;
  9631.         var amount : float;
  9632.        
  9633.        
  9634.        
  9635.         theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Runeword 12 _Stats', 'focus_runeword_gain', min, max );
  9636.        
  9637.        
  9638.         amount = RandRangeF(max.valueAdditive, min.valueAdditive);
  9639.         if ( GetStat(BCS_Focus) + amount > GetStatMax(BCS_Focus) )
  9640.         {
  9641.             amount = GetStatMax(BCS_Focus) - GetStat(BCS_Focus);
  9642.         }
  9643.         GainStat(BCS_Focus, amount);
  9644.        
  9645.        
  9646.         PlayEffect('runeword_20_adrenaline');  
  9647.     }
  9648.    
  9649.     var runeword10TriggerredOnFinisher, runeword12TriggerredOnFinisher : bool;
  9650.    
  9651.     event OnFinisherStart()
  9652.     {
  9653.         super.OnFinisherStart();
  9654.        
  9655.         runeword10TriggerredOnFinisher = false;
  9656.         runeword12TriggerredOnFinisher = false;
  9657.     }
  9658.    
  9659.     public function ApplyWitcherHouseBuffs()
  9660.     {
  9661.         var l_bed           : W3WitcherBed;
  9662.        
  9663.         if( FactsQuerySum( "PlayerInsideInnerWitcherHouse" ) > 0 )
  9664.         {
  9665.             l_bed = (W3WitcherBed)theGame.GetEntityByTag( 'witcherBed' );
  9666.            
  9667.             if( l_bed.GetWasUsed() )
  9668.             {
  9669.                 if( l_bed.GetBedLevel() != 0 )
  9670.                 {
  9671.                     AddEffectDefault( EET_WellRested, this, "Bed Buff" );
  9672.                 }
  9673.  
  9674.                 if( FactsQuerySum( "StablesExists" ) )
  9675.                 {
  9676.                     AddEffectDefault( EET_HorseStableBuff, this, "Stables" );
  9677.                 }
  9678.                
  9679.                 if( l_bed.GetWereItemsRefilled() )
  9680.                 {
  9681.                     theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt( "message_common_alchemy_table_buff_applied" ),, true );
  9682.                     l_bed.SetWereItemsRefilled( false );
  9683.                 }
  9684.                
  9685.                 AddEffectDefault( EET_BookshelfBuff, this, "Bookshelf" );
  9686.                
  9687.                 Heal( GetStatMax( BCS_Vitality ) );
  9688.             }
  9689.         }
  9690.     }
  9691.    
  9692.    
  9693.    
  9694.    
  9695.    
  9696.     public function CheatResurrect()
  9697.     {
  9698.         super.CheatResurrect();
  9699.         theGame.ReleaseNoSaveLock(theGame.deathSaveLockId);
  9700.         theInput.RestoreContext( 'Exploration', true );
  9701.     }
  9702.    
  9703.    
  9704.     public function Debug_EquipTestingSkills(equip : bool, force : bool)
  9705.     {
  9706.         var skills : array<ESkill>;
  9707.         var i, slot : int;
  9708.        
  9709.        
  9710.         ((W3PlayerAbilityManager)abilityManager).OnLevelGained(36);
  9711.        
  9712.         skills.PushBack(S_Magic_s01);
  9713.         skills.PushBack(S_Magic_s02);
  9714.         skills.PushBack(S_Magic_s03);
  9715.         skills.PushBack(S_Magic_s04);
  9716.         skills.PushBack(S_Magic_s05);
  9717.         skills.PushBack(S_Sword_s01);
  9718.         skills.PushBack(S_Sword_s02);
  9719.        
  9720.        
  9721.         if(equip)
  9722.         {
  9723.             for(i=0; i<skills.Size(); i+=1)
  9724.             {
  9725.                 if(!force && IsSkillEquipped(skills[i]))
  9726.                     continue;
  9727.                    
  9728.                
  9729.                 if(GetSkillLevel(skills[i]) == 0)
  9730.                     AddSkill(skills[i]);
  9731.                
  9732.                
  9733.                 if(force)
  9734.                     slot = i+1;    
  9735.                 else
  9736.                     slot = GetFreeSkillSlot();
  9737.                
  9738.                
  9739.                 EquipSkill(skills[i], slot);
  9740.             }
  9741.         }
  9742.         else
  9743.         {
  9744.             for(i=0; i<skills.Size(); i+=1)
  9745.             {
  9746.                 UnequipSkill(GetSkillSlotID(skills[i]));
  9747.             }
  9748.         }
  9749.     }
  9750.    
  9751.     public function Debug_ClearCharacterDevelopment(optional keepInv : bool)
  9752.     {
  9753.         var template : CEntityTemplate;
  9754.         var entity : CEntity;
  9755.         var invTesting : CInventoryComponent;
  9756.         var i : int;
  9757.         var items : array<SItemUniqueId>;
  9758.         var abs : array<name>;
  9759.    
  9760.         delete abilityManager;
  9761.         delete levelManager;
  9762.         delete effectManager;
  9763.        
  9764.        
  9765.         GetCharacterStats().GetAbilities(abs, false);
  9766.         for(i=0; i<abs.Size(); i+=1)
  9767.             RemoveAbility(abs[i]);
  9768.            
  9769.        
  9770.         abs.Clear();
  9771.         GetCharacterStatsParam(abs);       
  9772.         for(i=0; i<abs.Size(); i+=1)
  9773.             AddAbility(abs[i]);
  9774.                    
  9775.        
  9776.         levelManager = new W3LevelManager in this;         
  9777.         levelManager.Initialize();
  9778.         levelManager.PostInit(this, false, true);      
  9779.                        
  9780.        
  9781.         AddAbility('GeraltSkills_Testing');
  9782.         SetAbilityManager();       
  9783.         abilityManager.Init(this, GetCharacterStats(), false, theGame.GetDifficultyMode());
  9784.        
  9785.         SetEffectManager();
  9786.        
  9787.         abilityManager.PostInit();                     
  9788.        
  9789.        
  9790.        
  9791.        
  9792.        
  9793.         if(!keepInv)
  9794.         {
  9795.             inv.RemoveAllItems();
  9796.         }      
  9797.        
  9798.        
  9799.         template = (CEntityTemplate)LoadResource("geralt_inventory_release");
  9800.         entity = theGame.CreateEntity(template, Vector(0,0,0));
  9801.         invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  9802.         invTesting.GiveAllItemsTo(inv, true);
  9803.         entity.Destroy();
  9804.        
  9805.        
  9806.         inv.GetAllItems(items);
  9807.         for(i=0; i<items.Size(); i+=1)
  9808.         {
  9809.             if(!inv.ItemHasTag(items[i], 'NoDrop'))        
  9810.                 EquipItem(items[i]);
  9811.         }
  9812.            
  9813.        
  9814.         Debug_GiveTestingItems(0);
  9815.     }
  9816.    
  9817.     function Debug_BearSetBonusQuenSkills()
  9818.     {
  9819.         var skills  : array<ESkill>;
  9820.         var i, slot : int;
  9821.        
  9822.         skills.PushBack(S_Magic_s04);
  9823.         skills.PushBack(S_Magic_s14);
  9824.        
  9825.         for(i=0; i<skills.Size(); i+=1)
  9826.         {              
  9827.            
  9828.             if(GetSkillLevel(skills[i]) == 0)
  9829.             {
  9830.                 AddSkill(skills[i]);
  9831.             }
  9832.            
  9833.             slot = GetFreeSkillSlot();
  9834.            
  9835.            
  9836.             EquipSkill(skills[i], slot);
  9837.         }
  9838.     }
  9839.    
  9840.     final function Debug_HAX_UnlockSkillSlot(slotIndex : int) : bool
  9841.     {
  9842.         if(abilityManager && abilityManager.IsInitialized())
  9843.             return ((W3PlayerAbilityManager)abilityManager).Debug_HAX_UnlockSkillSlot(slotIndex);
  9844.            
  9845.         return false;
  9846.     }
  9847.    
  9848.    
  9849.     public function GetLevelupAbility( id : int) : name
  9850.     {
  9851.         switch(id)
  9852.         {
  9853.             case 1: return 'Lvl1';
  9854.             case 2: return 'Lvl2';
  9855.             case 3: return 'Lvl3';
  9856.             case 4: return 'Lvl4';
  9857.             case 5: return 'Lvl5';
  9858.             case 6: return 'Lvl6';
  9859.             case 7: return 'Lvl7';
  9860.             case 8: return 'Lvl8';
  9861.             case 9: return 'Lvl9';
  9862.             case 10: return 'Lvl10';
  9863.             case 11: return 'Lvl11';
  9864.             case 12: return 'Lvl12';
  9865.             case 13: return 'Lvl13';
  9866.             case 14: return 'Lvl14';
  9867.             case 15: return 'Lvl15';
  9868.             case 16: return 'Lvl16';
  9869.             case 17: return 'Lvl17';
  9870.             case 18: return 'Lvl18';
  9871.             case 19: return 'Lvl19';
  9872.             case 20: return 'Lvl20';
  9873.             case 21: return 'Lvl21';
  9874.             case 22: return 'Lvl22';
  9875.             case 23: return 'Lvl23';
  9876.             case 24: return 'Lvl24';
  9877.             case 25: return 'Lvl25';
  9878.             case 26: return 'Lvl26';
  9879.             case 27: return 'Lvl27';
  9880.             case 28: return 'Lvl28';
  9881.             case 29: return 'Lvl29';
  9882.             case 30: return 'Lvl30';
  9883.             case 31: return 'Lvl31';
  9884.             case 32: return 'Lvl32';
  9885.             case 33: return 'Lvl33';
  9886.             case 34: return 'Lvl34';
  9887.             case 35: return 'Lvl35';
  9888.             case 36: return 'Lvl36';
  9889.             case 37: return 'Lvl37';
  9890.             case 38: return 'Lvl38';
  9891.             case 39: return 'Lvl39';
  9892.             case 40: return 'Lvl40';
  9893.             case 41: return 'Lvl41';
  9894.             case 42: return 'Lvl42';
  9895.             case 43: return 'Lvl43';
  9896.             case 44: return 'Lvl44';
  9897.             case 45: return 'Lvl45';
  9898.             case 46: return 'Lvl46';
  9899.             case 47: return 'Lvl47';
  9900.             case 48: return 'Lvl48';
  9901.             case 49: return 'Lvl49';
  9902.             case 50: return 'Lvl50';
  9903.        
  9904.             default: return '';
  9905.         }
  9906.        
  9907.         return '';
  9908.     }  
  9909.    
  9910.     public function CanSprint( speed : float ) : bool
  9911.     {
  9912.         if( !super.CanSprint( speed ) )
  9913.         {
  9914.             return false;
  9915.         }      
  9916.         if( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  9917.         {
  9918.             if ( this.GetPlayerCombatStance() ==  PCS_AlertNear )
  9919.             {
  9920.                 if ( IsSprintActionPressed() )
  9921.                     OnRangedForceHolster( true, false );
  9922.             }
  9923.             else
  9924.                 return false;
  9925.         }
  9926.         if( GetCurrentStateName() != 'Swimming' && GetStat(BCS_Stamina) <= 0 )
  9927.         {
  9928.             SetSprintActionPressed(false,true);
  9929.             return false;
  9930.         }
  9931.        
  9932.         return true;
  9933.     }
  9934.    
  9935.     public function ManageSleeping()
  9936.     {
  9937.         thePlayer.RemoveBuffImmunity_AllCritical( 'Bed' );
  9938.         thePlayer.RemoveBuffImmunity_AllNegative( 'Bed' );
  9939.  
  9940.         thePlayer.PlayerStopAction( PEA_GoToSleep );
  9941.     }
  9942.    
  9943.    
  9944.    
  9945.     public function RestoreHorseManager() : bool
  9946.     {
  9947.         var horseTemplate   : CEntityTemplate;
  9948.         var horseManager    : W3HorseManager;  
  9949.        
  9950.         if ( GetHorseManager() )
  9951.         {
  9952.             return false;
  9953.         }
  9954.        
  9955.         horseTemplate = (CEntityTemplate)LoadResource("horse_manager");
  9956.         horseManager = (W3HorseManager)theGame.CreateEntity(horseTemplate, GetWorldPosition(),,,,,PM_Persist);
  9957.         horseManager.CreateAttachment(this);
  9958.         horseManager.OnCreated();
  9959.         EntityHandleSet( horseManagerHandle, horseManager );   
  9960.        
  9961.         return true;
  9962.     }
  9963.    
  9964.    
  9965.    
  9966.    
  9967.    
  9968.    
  9969.     final function PerformParryCheck( parryInfo : SParryInfo ) : bool
  9970.     {
  9971.         if( super.PerformParryCheck( parryInfo ) )
  9972.         {
  9973.             GainAdrenalineFromPerk21( 'parry' );
  9974.             return true;
  9975.         }
  9976.         return false;
  9977.     }  
  9978.    
  9979.     protected final function PerformCounterCheck( parryInfo: SParryInfo ) : bool
  9980.     {
  9981.         var fistFightCheck, isInFistFight       : bool;
  9982.        
  9983.         if( super.PerformCounterCheck( parryInfo ) )
  9984.         {
  9985.             GainAdrenalineFromPerk21( 'counter' );
  9986.            
  9987.             isInFistFight = FistFightCheck( parryInfo.target, parryInfo.attacker, fistFightCheck );
  9988.            
  9989.             if( isInFistFight && fistFightCheck )
  9990.             {
  9991.                 FactsAdd( "statistics_fist_fight_counter" );
  9992.                 AddTimer( 'FistFightCounterTimer', 0.5f, , , , true );
  9993.             }
  9994.            
  9995.             return true;
  9996.         }
  9997.         return false;
  9998.     }
  9999.    
  10000.     public function GainAdrenalineFromPerk21( n : name )
  10001.     {
  10002.         var perkStats, perkTime : SAbilityAttributeValue;
  10003.         var targets : array<CActor>;
  10004.        
  10005.         targets = GetHostileEnemies();
  10006.        
  10007.         if( !CanUseSkill( S_Perk_21 ) || targets.Size() == 0 )
  10008.         {
  10009.             return;
  10010.         }
  10011.        
  10012.         perkTime = GetSkillAttributeValue( S_Perk_21, 'perk21Time', false, false );
  10013.        
  10014.         if( theGame.GetEngineTimeAsSeconds() >= timeForPerk21 + perkTime.valueAdditive )
  10015.         {
  10016.             perkStats = GetSkillAttributeValue( S_Perk_21, n , false, false );
  10017.             GainStat( BCS_Focus, perkStats.valueAdditive );
  10018.             timeForPerk21 = theGame.GetEngineTimeAsSeconds();
  10019.            
  10020.             AddEffectDefault( EET_Perk21InternalCooldown, this, "Perk21", false );
  10021.         }  
  10022.     }
  10023.    
  10024.     timer function FistFightCounterTimer( dt : float, id : int )
  10025.     {
  10026.         FactsRemove( "statistics_fist_fight_counter" );
  10027.     }
  10028.    
  10029.     public final function IsSignBlocked(signType : ESignType) : bool
  10030.     {
  10031.         switch( signType )
  10032.         {
  10033.             case ST_Aard :
  10034.                 return IsRadialSlotBlocked ( 'Aard');
  10035.                 break;
  10036.             case ST_Axii :
  10037.                 return IsRadialSlotBlocked ( 'Axii');
  10038.                 break;
  10039.             case ST_Igni :
  10040.                 return IsRadialSlotBlocked ( 'Igni');
  10041.                 break;
  10042.             case ST_Quen :
  10043.                 return IsRadialSlotBlocked ( 'Quen');
  10044.                 break;
  10045.             case ST_Yrden :
  10046.                 return IsRadialSlotBlocked ( 'Yrden');
  10047.                 break;
  10048.             default:
  10049.                 break;
  10050.         }
  10051.         return false;
  10052.        
  10053.     }
  10054.    
  10055.     public final function AddAnItemWithAutogenLevelAndQuality(itemName : name, desiredLevel : int, minQuality : int, optional equipItem : bool)
  10056.     {
  10057.         var itemLevel, quality : int;
  10058.         var ids : array<SItemUniqueId>;
  10059.         var attemptCounter : int;
  10060.        
  10061.         itemLevel = 0;
  10062.         quality = 0;
  10063.         attemptCounter = 0;
  10064.         while(itemLevel != desiredLevel || quality < minQuality)
  10065.         {
  10066.             attemptCounter += 1;
  10067.             ids.Clear();
  10068.             ids = inv.AddAnItem(itemName, 1, true);
  10069.             itemLevel = inv.GetItemLevel(ids[0]);
  10070.             quality = RoundMath(CalculateAttributeValue(inv.GetItemAttributeValue(ids[0], 'quality')));
  10071.            
  10072.            
  10073.             if(attemptCounter >= 1000)
  10074.                 break;
  10075.            
  10076.             if(itemLevel != desiredLevel || quality < minQuality)
  10077.                 inv.RemoveItem(ids[0]);
  10078.         }
  10079.        
  10080.         if(equipItem)
  10081.             EquipItem(ids[0]);
  10082.     }
  10083.    
  10084.     public final function AddAnItemWithAutogenLevel(itemName : name, desiredLevel : int)
  10085.     {
  10086.         var itemLevel : int;
  10087.         var ids : array<SItemUniqueId>;
  10088.         var attemptCounter : int;
  10089.  
  10090.         itemLevel = 0;
  10091.         while(itemLevel != desiredLevel)
  10092.         {
  10093.             attemptCounter += 1;
  10094.             ids.Clear();
  10095.             ids = inv.AddAnItem(itemName, 1, true);
  10096.             itemLevel = inv.GetItemLevel(ids[0]);
  10097.            
  10098.            
  10099.             if(attemptCounter >= 1000)
  10100.                 break;
  10101.                
  10102.             if(itemLevel != desiredLevel)
  10103.                 inv.RemoveItem(ids[0]);
  10104.         }
  10105.     }
  10106.    
  10107.     public final function AddAnItemWithMinQuality(itemName : name, minQuality : int, optional equip : bool)
  10108.     {
  10109.         var quality : int;
  10110.         var ids : array<SItemUniqueId>;
  10111.         var attemptCounter : int;
  10112.  
  10113.         quality = 0;
  10114.         while(quality < minQuality)
  10115.         {
  10116.             attemptCounter += 1;
  10117.             ids.Clear();
  10118.             ids = inv.AddAnItem(itemName, 1, true);
  10119.             quality = RoundMath(CalculateAttributeValue(inv.GetItemAttributeValue(ids[0], 'quality')));
  10120.            
  10121.            
  10122.             if(attemptCounter >= 1000)
  10123.                 break;
  10124.                
  10125.             if(quality < minQuality)
  10126.                 inv.RemoveItem(ids[0]);
  10127.         }
  10128.        
  10129.         if(equip)
  10130.             EquipItem(ids[0]);
  10131.     }
  10132.    
  10133.    
  10134.    
  10135.    
  10136.    
  10137.    
  10138.     public function IsSetBonusActive( bonus : EItemSetBonus ) : bool
  10139.     {
  10140.         switch(bonus)
  10141.         {
  10142.             case EISB_Lynx_1:           return amountOfSetPiecesEquipped[ EIST_Lynx ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS;
  10143.             case EISB_Lynx_2:           return amountOfSetPiecesEquipped[ EIST_Lynx ] >= theGame.params.ITEMS_REQUIRED_FOR_MAJOR_SET_BONUS;
  10144.             case EISB_Gryphon_1:        return amountOfSetPiecesEquipped[ EIST_Gryphon ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS;
  10145.             case EISB_Gryphon_2:        return amountOfSetPiecesEquipped[ EIST_Gryphon ] >= theGame.params.ITEMS_REQUIRED_FOR_MAJOR_SET_BONUS;
  10146.             case EISB_Bear_1:           return amountOfSetPiecesEquipped[ EIST_Bear ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS;
  10147.             case EISB_Bear_2:           return amountOfSetPiecesEquipped[ EIST_Bear ] >= theGame.params.ITEMS_REQUIRED_FOR_MAJOR_SET_BONUS;
  10148.             case EISB_Wolf_1:           return amountOfSetPiecesEquipped[ EIST_Wolf ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS;
  10149.             case EISB_Wolf_2:           return amountOfSetPiecesEquipped[ EIST_Wolf ] >= theGame.params.ITEMS_REQUIRED_FOR_MAJOR_SET_BONUS;
  10150.             case EISB_RedWolf_1:        return amountOfSetPiecesEquipped[ EIST_RedWolf ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS;
  10151.             case EISB_RedWolf_2:        return amountOfSetPiecesEquipped[ EIST_RedWolf ] >= theGame.params.ITEMS_REQUIRED_FOR_MAJOR_SET_BONUS;
  10152.             case EISB_Vampire:          return amountOfSetPiecesEquipped[ EIST_Vampire ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS;
  10153.             case EISB_Netflix_1:        return amountOfSetPiecesEquipped[ EIST_Netflix ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS;
  10154.             case EISB_Netflix_2:        return amountOfSetPiecesEquipped[ EIST_Netflix ] >= theGame.params.ITEMS_REQUIRED_FOR_MAJOR_SET_BONUS;
  10155.             default:                    return false;
  10156.         }
  10157.     }
  10158.    
  10159.     public function GetSetPartsEquipped( setType : EItemSetType ) : int
  10160.     {
  10161.         return amountOfSetPiecesEquipped[ setType ];
  10162.     }
  10163.    
  10164.     protected function UpdateItemSetBonuses( item : SItemUniqueId, increment : bool )
  10165.     {
  10166.         var setType : EItemSetType;
  10167.         var tutorialStateSets : W3TutorialManagerUIHandlerStateSetItemsUnlocked;
  10168.         var id : SItemUniqueId;
  10169.                    
  10170.         if( !inv.IsIdValid( item ) || !inv.ItemHasTag(item, theGame.params.ITEM_SET_TAG_BONUS ) )  
  10171.         {
  10172.            
  10173.            
  10174.            
  10175.            
  10176.             return;
  10177.         }
  10178.        
  10179.         setType = CheckSetType( item );
  10180.        
  10181.         if( increment )
  10182.         {
  10183.             amountOfSetPiecesEquipped[ setType ] += 1;
  10184.            
  10185.             if( amountOfSetPiecesEquipped[ setType ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS && ShouldProcessTutorial( 'TutorialSetBonusesUnlocked' ) && theGame.GetTutorialSystem().uiHandler && theGame.GetTutorialSystem().uiHandler.GetCurrentStateName() == 'SetItemsUnlocked' )
  10186.             {
  10187.                 tutorialStateSets = ( W3TutorialManagerUIHandlerStateSetItemsUnlocked )theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  10188.                 tutorialStateSets.OnSetBonusCompleted();
  10189.             }
  10190.         }
  10191.         else if( amountOfSetPiecesEquipped[ setType ] > 0 )
  10192.         {
  10193.             amountOfSetPiecesEquipped[ setType ] -= 1;
  10194.         }
  10195.        
  10196.        
  10197.         if( setType != EIST_Vampire )
  10198.         {
  10199.             if(amountOfSetPiecesEquipped[ setType ] == theGame.params.ITEMS_REQUIRED_FOR_MAJOR_SET_BONUS)
  10200.             {
  10201.                 theGame.GetGamerProfile().AddAchievement( EA_ReadyToRoll );
  10202.             }
  10203.             else
  10204.             {
  10205.                 theGame.GetGamerProfile().NoticeAchievementProgress( EA_ReadyToRoll, amountOfSetPiecesEquipped[ setType ]);
  10206.             }
  10207.         }
  10208.        
  10209.        
  10210.        
  10211.        
  10212.        
  10213.        
  10214.         ManageActiveSetBonuses( setType );
  10215.        
  10216.        
  10217.         ManageSetBonusesSoundbanks( setType );
  10218.     }
  10219.    
  10220.     public function ManageActiveSetBonuses( setType : EItemSetType )
  10221.     {
  10222.         var l_i             : int;
  10223.        
  10224.        
  10225.         if( setType == EIST_Lynx )
  10226.         {
  10227.            
  10228.             if( HasBuff( EET_LynxSetBonus ) && !IsSetBonusActive( EISB_Lynx_1 ) )
  10229.             {
  10230.                 RemoveBuff( EET_LynxSetBonus );
  10231.             }
  10232.         }
  10233.        
  10234.         else if( setType == EIST_Gryphon )
  10235.         {
  10236.            
  10237.             if( !IsSetBonusActive( EISB_Gryphon_1 ) )
  10238.             {
  10239.                 RemoveBuff( EET_GryphonSetBonus );
  10240.             }
  10241.            
  10242.             if( IsSetBonusActive( EISB_Gryphon_2 ) && !HasBuff( EET_GryphonSetBonusYrden ) )
  10243.             {
  10244.                 for( l_i = 0 ; l_i < yrdenEntities.Size() ; l_i += 1 )
  10245.                 {
  10246.                     if( yrdenEntities[ l_i ].GetIsPlayerInside() && !yrdenEntities[ l_i ].IsAlternateCast() )
  10247.                     {
  10248.                         AddEffectDefault( EET_GryphonSetBonusYrden, this, "GryphonSetBonusYrden" );
  10249.                         break;
  10250.                     }
  10251.                 }
  10252.             }
  10253.             else
  10254.             {
  10255.                 RemoveBuff( EET_GryphonSetBonusYrden );
  10256.             }
  10257.         }
  10258.     }
  10259.    
  10260.     public function CheckSetTypeByName( itemName : name ) : EItemSetType
  10261.     {
  10262.         var dm : CDefinitionsManagerAccessor;
  10263.        
  10264.         dm = theGame.GetDefinitionsManager();
  10265.        
  10266.         if( dm.ItemHasTag( itemName, theGame.params.ITEM_SET_TAG_LYNX ) )
  10267.         {
  10268.             return EIST_Lynx;
  10269.         }
  10270.         else
  10271.         if( dm.ItemHasTag( itemName, theGame.params.ITEM_SET_TAG_GRYPHON ) )
  10272.         {
  10273.             return EIST_Gryphon;
  10274.         }
  10275.         else
  10276.         if( dm.ItemHasTag( itemName, theGame.params.ITEM_SET_TAG_BEAR ) )
  10277.         {
  10278.             return EIST_Bear;
  10279.         }
  10280.         else
  10281.         if( dm.ItemHasTag( itemName, theGame.params.ITEM_SET_TAG_WOLF ) )
  10282.         {
  10283.             return EIST_Wolf;
  10284.         }
  10285.         else
  10286.         if( dm.ItemHasTag( itemName, theGame.params.ITEM_SET_TAG_RED_WOLF ) )
  10287.         {
  10288.             return EIST_RedWolf;
  10289.         }
  10290.         else
  10291.         if( dm.ItemHasTag( itemName, theGame.params.ITEM_SET_TAG_VAMPIRE ) )
  10292.         {
  10293.             return EIST_Vampire;
  10294.         }
  10295.         else
  10296.         if( dm.ItemHasTag( itemName, theGame.params.ITEM_SET_TAG_VIPER ) )
  10297.         {
  10298.             return EIST_Viper;
  10299.         }
  10300.         else
  10301.         if( dm.ItemHasTag( itemName, theGame.params.ITEM_SET_TAG_NETFLIX ) )
  10302.         {
  10303.             return EIST_Netflix;
  10304.         }
  10305.         else
  10306.         {
  10307.             return EIST_Undefined;
  10308.         }
  10309.     }
  10310.    
  10311.     public function CheckSetType( item : SItemUniqueId ) : EItemSetType
  10312.     {
  10313.         var stopLoop    : bool;
  10314.         var tags        : array<name>;
  10315.         var i           : int;
  10316.         var setType     : EItemSetType;
  10317.        
  10318.         stopLoop = false;
  10319.        
  10320.         inv.GetItemTags( item, tags );
  10321.        
  10322.        
  10323.         for( i=0; i<tags.Size(); i+=1 )
  10324.         {
  10325.             switch( tags[i] )
  10326.             {
  10327.                 case theGame.params.ITEM_SET_TAG_LYNX:
  10328.                 case theGame.params.ITEM_SET_TAG_GRYPHON:
  10329.                 case theGame.params.ITEM_SET_TAG_BEAR:
  10330.                 case theGame.params.ITEM_SET_TAG_WOLF:
  10331.                 case theGame.params.ITEM_SET_TAG_RED_WOLF:
  10332.                 case theGame.params.ITEM_SET_TAG_VAMPIRE:
  10333.                 case theGame.params.ITEM_SET_TAG_VIPER:
  10334.                 case theGame.params.ITEM_SET_TAG_NETFLIX:
  10335.                     setType = SetItemNameToType( tags[i] );
  10336.                     stopLoop = true;
  10337.                     break;
  10338.             }      
  10339.             if ( stopLoop )
  10340.             {
  10341.                 break;
  10342.             }
  10343.         }
  10344.        
  10345.         return setType;
  10346.     }
  10347.    
  10348.     public function GetSetBonusStatusByName( itemName : name, out desc1, desc2 : string, out isActive1, isActive2 : bool ) : EItemSetType
  10349.     {
  10350.         var setType : EItemSetType;
  10351.        
  10352.         if( theGame.GetDLCManager().IsEP2Enabled() )
  10353.         {
  10354.             setType = CheckSetTypeByName( itemName );
  10355.             SetBonusStatusByType( setType, desc1, desc2, isActive1, isActive2 );
  10356.            
  10357.             return setType;    
  10358.         }
  10359.         else
  10360.         {
  10361.             return EIST_Undefined;
  10362.         }
  10363.     }
  10364.    
  10365.     public function GetSetBonusStatus( item : SItemUniqueId, out desc1, desc2 : string, out isActive1, isActive2 : bool ) : EItemSetType
  10366.     {
  10367.         var setType : EItemSetType;
  10368.        
  10369.         if( theGame.GetDLCManager().IsEP2Enabled() )
  10370.         {
  10371.             setType = CheckSetType( item );
  10372.             SetBonusStatusByType( setType, desc1, desc2, isActive1, isActive2 );
  10373.            
  10374.             return setType;
  10375.         }
  10376.         else
  10377.         {
  10378.             return EIST_Undefined;
  10379.         }
  10380.     }
  10381.    
  10382.     private function SetBonusStatusByType(setType : EItemSetType, out desc1, desc2 : string, out isActive1, isActive2 : bool):void
  10383.     {
  10384.         var setBonus : EItemSetBonus;
  10385.        
  10386.         if( amountOfSetPiecesEquipped[ setType ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS )
  10387.         {
  10388.             isActive1 = true;          
  10389.         }
  10390.        
  10391.         if( amountOfSetPiecesEquipped[ setType ] >= theGame.params.ITEMS_REQUIRED_FOR_MAJOR_SET_BONUS )
  10392.         {
  10393.             isActive2 = true;
  10394.         }
  10395.        
  10396.         setBonus = ItemSetTypeToItemSetBonus( setType, 1 );
  10397.         desc1 = GetSetBonusTooltipDescription( setBonus );
  10398.        
  10399.         setBonus = ItemSetTypeToItemSetBonus( setType, 2 );
  10400.         desc2 = GetSetBonusTooltipDescription( setBonus );
  10401.     }
  10402.    
  10403.     public function ItemSetTypeToItemSetBonus( setType : EItemSetType, nr : int ) : EItemSetBonus
  10404.     {
  10405.         var setBonus : EItemSetBonus;
  10406.    
  10407.         if( nr == 1 )
  10408.         {
  10409.             switch( setType )
  10410.             {
  10411.                 case EIST_Lynx:             setBonus = EISB_Lynx_1;     break;
  10412.                 case EIST_Gryphon:          setBonus = EISB_Gryphon_1;  break;
  10413.                 case EIST_Bear:             setBonus = EISB_Bear_1;     break;
  10414.                 case EIST_Wolf:             setBonus = EISB_Wolf_1;     break;
  10415.                 case EIST_RedWolf:          setBonus = EISB_RedWolf_1;  break;
  10416.                 case EIST_Vampire:          setBonus = EISB_Vampire;    break;
  10417.                 case EIST_Netflix:          setBonus = EISB_Netflix_1;  break;
  10418.             }
  10419.         }
  10420.         else
  10421.         {
  10422.             switch( setType )
  10423.             {
  10424.                 case EIST_Lynx:             setBonus = EISB_Lynx_2;     break;
  10425.                 case EIST_Gryphon:          setBonus = EISB_Gryphon_2;  break;
  10426.                 case EIST_Bear:             setBonus = EISB_Bear_2;     break;
  10427.                 case EIST_Wolf:             setBonus = EISB_Wolf_2;     break;
  10428.                 case EIST_RedWolf:          setBonus = EISB_RedWolf_2;  break;
  10429.                 case EIST_Vampire:          setBonus = EISB_Undefined;  break;
  10430.                 case EIST_Netflix:          setBonus = EISB_Netflix_2;  break;
  10431.             }
  10432.         }
  10433.    
  10434.         return setBonus;
  10435.     }
  10436.    
  10437.     public function GetSetBonusTooltipDescription( bonus : EItemSetBonus ) : string
  10438.     {
  10439.         var finalString : string;
  10440.         var arrString   : array<string>;
  10441.         var dm          : CDefinitionsManagerAccessor;
  10442.         var min, max    : SAbilityAttributeValue;
  10443.         var tempString  : string;
  10444.        
  10445.         switch( bonus )
  10446.         {
  10447.             case EISB_Lynx_1:           tempString = "skill_desc_lynx_set_ability1"; break;
  10448.             case EISB_Lynx_2:           tempString = "skill_desc_lynx_set_ability2"; break;
  10449.             case EISB_Gryphon_1:        tempString = "skill_desc_gryphon_set_ability1"; break;
  10450.             case EISB_Gryphon_2:        tempString = "skill_desc_gryphon_set_ability2"; break;
  10451.             case EISB_Bear_1:           tempString = "skill_desc_bear_set_ability1"; break;
  10452.             case EISB_Bear_2:           tempString = "skill_desc_bear_set_ability2"; break;
  10453.             case EISB_Wolf_1:           tempString = "skill_desc_wolf_set_ability2"; break;
  10454.             case EISB_Wolf_2:           tempString = "skill_desc_wolf_set_ability1"; break;
  10455.             case EISB_RedWolf_1:        tempString = "skill_desc_red_wolf_set_ability1"; break;
  10456.             case EISB_RedWolf_2:        tempString = "skill_desc_red_wolf_set_ability2"; break;
  10457.             case EISB_Vampire:          tempString = "skill_desc_vampire_set_ability1"; break;
  10458.             case EISB_Netflix_1:        tempString = "skill_desc_netflix_set_ability1"; break;
  10459.             case EISB_Netflix_2:        tempString = "skill_desc_netflix_set_ability2"; break;
  10460.             default:                    tempString = ""; break;
  10461.         }
  10462.        
  10463.         dm = theGame.GetDefinitionsManager();
  10464.        
  10465.         switch( bonus )
  10466.         {
  10467.         case EISB_Lynx_1:
  10468.             dm.GetAbilityAttributeValue( 'LynxSetBonusEffect', 'duration', min, max );
  10469.             arrString.PushBack( FloatToString( min.valueAdditive ) );
  10470.             dm.GetAbilityAttributeValue( 'LynxSetBonusEffect', 'lynx_dmg_boost', min, max );
  10471.             arrString.PushBack( FloatToString( min.valueAdditive * 100 ) );
  10472.             arrString.PushBack( FloatToString( min.valueAdditive * 100 * amountOfSetPiecesEquipped[ EIST_Lynx ] ) );
  10473.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10474.             break;
  10475.         case EISB_Lynx_2:
  10476.             dm.GetAbilityAttributeValue( GetSetBonusAbility( EISB_Lynx_2 ), 'lynx_2_dmg_boost', min, max );
  10477.             arrString.PushBack( FloatToString( min.valueAdditive * 100 ) );
  10478.            
  10479.             dm.GetAbilityAttributeValue( GetSetBonusAbility( EISB_Lynx_2 ), 'lynx_2_adrenaline_cost', min, max );
  10480.             arrString.PushBack( FloatToString( min.valueAdditive ) );
  10481.            
  10482.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10483.             break;
  10484.         case EISB_Gryphon_1:
  10485.             dm.GetAbilityAttributeValue( 'GryphonSetBonusEffect', 'duration', min, max );
  10486.             arrString.PushBack( FloatToString( min.valueAdditive ) );
  10487.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10488.             break;     
  10489.         case EISB_Gryphon_2:
  10490.             dm.GetAbilityAttributeValue( 'GryphonSetBonusYrdenEffect', 'trigger_scale', min, max );
  10491.             arrString.PushBack( FloatToString( ( min.valueAdditive - 1 )* 100) );
  10492.             dm.GetAbilityAttributeValue( 'GryphonSetBonusYrdenEffect', 'staminaRegen', min, max );
  10493.             arrString.PushBack( FloatToString( min.valueMultiplicative * 100) );
  10494.             dm.GetAbilityAttributeValue( 'GryphonSetBonusYrdenEffect', 'spell_power', min, max );
  10495.             arrString.PushBack( FloatToString( min.valueMultiplicative * 100) );
  10496.             dm.GetAbilityAttributeValue( 'GryphonSetBonusYrdenEffect', 'gryphon_set_bns_dmg_reduction', min, max );
  10497.             arrString.PushBack( FloatToString( min.valueAdditive * 100) );
  10498.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10499.             break;
  10500.         case EISB_Bear_1:
  10501.             dm.GetAbilityAttributeValue( 'setBonusAbilityBear_1', 'quen_reapply_chance', min, max );
  10502.             arrString.PushBack( FloatToString( min.valueMultiplicative * 100 ) );
  10503.            
  10504.             arrString.PushBack( FloatToString( min.valueMultiplicative * 100 * amountOfSetPiecesEquipped[ EIST_Bear ] ) );
  10505.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10506.             break;
  10507.         case EISB_Bear_2:
  10508.             dm.GetAbilityAttributeValue( 'setBonusAbilityBear_2', 'quen_dmg_boost', min, max );
  10509.             arrString.PushBack( FloatToString( min.valueMultiplicative * 100 ) );
  10510.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10511.             break;
  10512.         case EISB_RedWolf_2:
  10513.             dm.GetAbilityAttributeValue( 'setBonusAbilityRedWolf_2', 'amount', min, max );
  10514.             arrString.PushBack( FloatToString( min.valueAdditive ) );
  10515.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10516.             break;
  10517.         case EISB_Vampire:
  10518.             dm.GetAbilityAttributeValue( 'setBonusAbilityVampire', 'life_percent', min, max );
  10519.             arrString.PushBack( FloatToString( min.valueAdditive ) );
  10520.             arrString.PushBack( FloatToString( min.valueAdditive * amountOfSetPiecesEquipped[ EIST_Vampire ] ) );
  10521.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10522.             break;
  10523.        
  10524.         case EISB_Wolf_1:
  10525.             arrString.PushBack( FloatToString( 1 * amountOfSetPiecesEquipped[ EIST_Wolf ] ) );
  10526.             finalString = GetLocStringByKeyExtWithParams( tempString,,,arrString );
  10527.             break;
  10528.        
  10529.         default:
  10530.             finalString = GetLocStringByKeyExtWithParams( tempString );
  10531.         }
  10532.        
  10533.         return finalString;
  10534.     }
  10535.    
  10536.     public function ManageSetBonusesSoundbanks( setType : EItemSetType )
  10537.     {
  10538.         if( amountOfSetPiecesEquipped[ setType ] >= theGame.params.ITEMS_REQUIRED_FOR_MINOR_SET_BONUS )
  10539.         {
  10540.             switch( setType )
  10541.             {
  10542.                 case EIST_Lynx:
  10543.                     LoadSetBonusSoundBank( "ep2_setbonus_lynx.bnk" );
  10544.                     break;
  10545.                 case EIST_Gryphon:
  10546.                     LoadSetBonusSoundBank( "ep2_setbonus_gryphon.bnk" );
  10547.                     break;
  10548.                 case EIST_Bear:
  10549.                     LoadSetBonusSoundBank( "ep2_setbonus_bear.bnk" );
  10550.                     break;
  10551.             }
  10552.         }
  10553.         else
  10554.         {
  10555.             switch( setType )
  10556.             {
  10557.                 case EIST_Lynx:
  10558.                     UnloadSetBonusSoundBank( "ep2_setbonus_lynx.bnk" );
  10559.                     break;
  10560.                 case EIST_Gryphon:
  10561.                     UnloadSetBonusSoundBank( "ep2_setbonus_gryphon.bnk" );
  10562.                     break;
  10563.                 case EIST_Bear:
  10564.                     UnloadSetBonusSoundBank( "ep2_setbonus_bear.bnk" );
  10565.                     break;
  10566.             }
  10567.         }
  10568.     }
  10569.    
  10570.     public function VampiricSetAbilityRegeneration()
  10571.     {
  10572.         var healthMax       : float;
  10573.         var healthToReg     : float;
  10574.        
  10575.         healthMax = GetStatMax( BCS_Vitality );
  10576.        
  10577.         healthToReg = ( amountOfSetPiecesEquipped[ EIST_Vampire ] * healthMax ) / 100;
  10578.        
  10579.         PlayEffect('drain_energy_caretaker_shovel');
  10580.         GainStat( BCS_Vitality, healthToReg );
  10581.     }
  10582.    
  10583.     private function LoadSetBonusSoundBank( bankName : string )
  10584.     {
  10585.         if( !theSound.SoundIsBankLoaded( bankName ) )
  10586.         {
  10587.             theSound.SoundLoadBank( bankName, true );
  10588.         }
  10589.     }
  10590.    
  10591.     private function UnloadSetBonusSoundBank( bankName : string )
  10592.     {
  10593.         if( theSound.SoundIsBankLoaded( bankName ) )
  10594.         {
  10595.             theSound.SoundUnloadBank( bankName );
  10596.         }
  10597.     }
  10598.    
  10599.     timer function BearSetBonusQuenReapply( dt : float, id : int )
  10600.     {
  10601.         var newQuen     : W3QuenEntity;
  10602.        
  10603.         newQuen = (W3QuenEntity)theGame.CreateEntity( GetSignTemplate( ST_Quen ), GetWorldPosition(), GetWorldRotation() );
  10604.         newQuen.Init( signOwner, GetSignEntity( ST_Quen ), true );
  10605.         newQuen.freeFromBearSetBonus = true;
  10606.         newQuen.OnStarted();
  10607.         newQuen.OnThrowing();
  10608.         newQuen.OnEnded();
  10609.        
  10610.         m_quenReappliedCount += 1;
  10611.        
  10612.         RemoveTimer( 'BearSetBonusQuenReapply');
  10613.     }
  10614.    
  10615.     public final function StandaloneEp1_1()
  10616.     {
  10617.         var i, inc, quantityLow, randLow, quantityMedium, randMedium, quantityHigh, randHigh, startingMoney : int;
  10618.         var pam : W3PlayerAbilityManager;
  10619.         var ids : array<SItemUniqueId>;
  10620.         var STARTING_LEVEL : int;
  10621.        
  10622.         FactsAdd("StandAloneEP1", 1);
  10623.        
  10624.        
  10625.         inv.RemoveAllItems();
  10626.        
  10627.        
  10628.         inv.AddAnItem('Illusion Medallion', 1, true, true, false);
  10629.         inv.AddAnItem('q103_safe_conduct', 1, true, true, false);
  10630.        
  10631.        
  10632.         theGame.GetGamerProfile().ClearAllAchievementsForEP1();
  10633.        
  10634.        
  10635.         STARTING_LEVEL = 32;
  10636.         inc = STARTING_LEVEL - GetLevel();
  10637.         for(i=0; i<inc; i+=1)
  10638.         {
  10639.             levelManager.AddPoints(EExperiencePoint, levelManager.GetTotalExpForNextLevel() - levelManager.GetPointsTotal(EExperiencePoint), false);
  10640.         }
  10641.        
  10642.        
  10643.         levelManager.ResetCharacterDev();
  10644.         pam = (W3PlayerAbilityManager)abilityManager;
  10645.         if(pam)
  10646.         {
  10647.             pam.ResetCharacterDev();
  10648.         }
  10649.         levelManager.SetFreeSkillPoints(levelManager.GetLevel() - 1 + 11); 
  10650.        
  10651.        
  10652.         inv.AddAnItem('Mutagen red', 4);
  10653.         inv.AddAnItem('Mutagen green', 4);
  10654.         inv.AddAnItem('Mutagen blue', 4);
  10655.         inv.AddAnItem('Lesser mutagen red', 2);
  10656.         inv.AddAnItem('Lesser mutagen green', 2);
  10657.         inv.AddAnItem('Lesser mutagen blue', 2);
  10658.         inv.AddAnItem('Greater mutagen green', 1);
  10659.         inv.AddAnItem('Greater mutagen blue', 2);
  10660.        
  10661.        
  10662.         startingMoney = 40000;
  10663.         if(GetMoney() > startingMoney)
  10664.         {
  10665.             RemoveMoney(GetMoney() - startingMoney);
  10666.         }
  10667.         else
  10668.         {
  10669.             AddMoney( 40000 - GetMoney() );
  10670.         }
  10671.        
  10672.        
  10673.        
  10674.        
  10675.        
  10676.         ids.Clear();
  10677.         ids = inv.AddAnItem('EP1 Standalone Starting Armor');
  10678.         EquipItem(ids[0]);
  10679.         ids.Clear();
  10680.         ids = inv.AddAnItem('EP1 Standalone Starting Boots');
  10681.         EquipItem(ids[0]);
  10682.         ids.Clear();
  10683.         ids = inv.AddAnItem('EP1 Standalone Starting Gloves');
  10684.         EquipItem(ids[0]);
  10685.         ids.Clear();
  10686.         ids = inv.AddAnItem('EP1 Standalone Starting Pants');
  10687.         EquipItem(ids[0]);
  10688.        
  10689.        
  10690.         ids.Clear();
  10691.         ids = inv.AddAnItem('EP1 Standalone Starting Steel Sword');
  10692.         EquipItem(ids[0]);
  10693.         ids.Clear();
  10694.         ids = inv.AddAnItem('EP1 Standalone Starting Silver Sword');
  10695.         EquipItem(ids[0]);
  10696.        
  10697.        
  10698.         inv.AddAnItem('Torch', 1, true, true, false);
  10699.        
  10700.        
  10701.         quantityLow = 1;
  10702.         randLow = 3;
  10703.         quantityMedium = 4;
  10704.         randMedium = 4;
  10705.         quantityHigh = 8;
  10706.         randHigh = 6;
  10707.        
  10708.         inv.AddAnItem('Alghoul bone marrow',quantityMedium+RandRange(randMedium));
  10709.         inv.AddAnItem('Amethyst dust',quantityLow+RandRange(randLow));
  10710.         inv.AddAnItem('Arachas eyes',quantityLow+RandRange(randLow));
  10711.         inv.AddAnItem('Arachas venom',quantityLow+RandRange(randLow));
  10712.         inv.AddAnItem('Basilisk hide',quantityLow+RandRange(randLow));
  10713.         inv.AddAnItem('Basilisk venom',quantityLow+RandRange(randLow));
  10714.         inv.AddAnItem('Bear pelt',quantityHigh+RandRange(randHigh));
  10715.         inv.AddAnItem('Berserker pelt',quantityLow+RandRange(randLow));
  10716.         inv.AddAnItem('Coal',quantityHigh+RandRange(randHigh));
  10717.         inv.AddAnItem('Cotton',quantityHigh+RandRange(randHigh));
  10718.         inv.AddAnItem('Dark iron ingot',quantityLow+RandRange(randLow));
  10719.         inv.AddAnItem('Dark iron ore',quantityLow+RandRange(randLow));
  10720.         inv.AddAnItem('Deer hide',quantityHigh+RandRange(randHigh));
  10721.         inv.AddAnItem('Diamond dust',quantityLow+RandRange(randLow));
  10722.         inv.AddAnItem('Draconide leather',quantityLow+RandRange(randLow));
  10723.         inv.AddAnItem('Drowned dead tongue',quantityLow+RandRange(randLow));
  10724.         inv.AddAnItem('Drowner brain',quantityMedium+RandRange(randMedium));
  10725.         inv.AddAnItem('Dwimeryte ingot',quantityLow+RandRange(randLow));
  10726.         inv.AddAnItem('Dwimeryte ore',quantityLow+RandRange(randLow));
  10727.         inv.AddAnItem('Emerald dust',quantityLow+RandRange(randLow));
  10728.         inv.AddAnItem('Endriag chitin plates',quantityMedium+RandRange(randMedium));
  10729.         inv.AddAnItem('Endriag embryo',quantityLow+RandRange(randLow));
  10730.         inv.AddAnItem('Ghoul blood',quantityMedium+RandRange(randMedium));
  10731.         inv.AddAnItem('Goat hide',quantityMedium+RandRange(randMedium));
  10732.         inv.AddAnItem('Hag teeth',quantityMedium+RandRange(randMedium));
  10733.         inv.AddAnItem('Hardened leather',quantityMedium+RandRange(randMedium));
  10734.         inv.AddAnItem('Hardened timber',quantityMedium+RandRange(randMedium));
  10735.         inv.AddAnItem('Harpy feathers',quantityMedium+RandRange(randMedium));
  10736.         inv.AddAnItem('Horse hide',quantityLow+RandRange(randLow));
  10737.         inv.AddAnItem('Iron ore',quantityHigh+RandRange(randHigh));
  10738.         inv.AddAnItem('Leather straps',quantityHigh+RandRange(randHigh));
  10739.         inv.AddAnItem('Leather',quantityHigh+RandRange(randHigh));
  10740.         inv.AddAnItem('Linen',quantityMedium+RandRange(randMedium));
  10741.         inv.AddAnItem('Meteorite ingot',quantityLow+RandRange(randLow));
  10742.         inv.AddAnItem('Meteorite ore',quantityMedium+RandRange(randMedium));
  10743.         inv.AddAnItem('Necrophage skin',quantityLow+RandRange(randLow));
  10744.         inv.AddAnItem('Nekker blood',quantityHigh+RandRange(randHigh));
  10745.         inv.AddAnItem('Nekker heart',quantityMedium+RandRange(randMedium));
  10746.         inv.AddAnItem('Oil',quantityHigh+RandRange(randHigh));
  10747.         inv.AddAnItem('Phosphorescent crystal',quantityLow+RandRange(randLow));
  10748.         inv.AddAnItem('Pig hide',quantityMedium+RandRange(randMedium));
  10749.         inv.AddAnItem('Pure silver',quantityMedium+RandRange(randMedium));
  10750.         inv.AddAnItem('Rabbit pelt',quantityMedium+RandRange(randMedium));
  10751.         inv.AddAnItem('Rotfiend blood',quantityMedium+RandRange(randMedium));
  10752.         inv.AddAnItem('Sapphire dust',quantityLow+RandRange(randLow));
  10753.         inv.AddAnItem('Silk',quantityHigh+RandRange(randHigh));
  10754.         inv.AddAnItem('Silver ingot',quantityMedium+RandRange(randMedium));
  10755.         inv.AddAnItem('Silver ore',quantityHigh+RandRange(randHigh));
  10756.         inv.AddAnItem('Specter dust',quantityMedium+RandRange(randMedium));
  10757.         inv.AddAnItem('Steel ingot',quantityHigh+RandRange(randHigh));
  10758.         inv.AddAnItem('Steel plate',quantityHigh+RandRange(randHigh));
  10759.         inv.AddAnItem('String',quantityHigh+RandRange(randHigh));
  10760.         inv.AddAnItem('Thread',quantityHigh+RandRange(randHigh));
  10761.         inv.AddAnItem('Timber',quantityHigh+RandRange(randHigh));
  10762.         inv.AddAnItem('Twine',quantityMedium+RandRange(randMedium));
  10763.         inv.AddAnItem('Venom extract',quantityMedium+RandRange(randMedium));
  10764.         inv.AddAnItem('Water essence',quantityMedium+RandRange(randMedium));
  10765.         inv.AddAnItem('Wolf liver',quantityHigh+RandRange(randHigh));
  10766.         inv.AddAnItem('Wolf pelt',quantityMedium+RandRange(randMedium));
  10767.        
  10768.         inv.AddAnItem('Alcohest', 5);
  10769.         inv.AddAnItem('Dwarven spirit', 5);
  10770.    
  10771.        
  10772.         ids.Clear();
  10773.         ids = inv.AddAnItem('Crossbow 5');
  10774.         EquipItem(ids[0]);
  10775.         ids.Clear();
  10776.         ids = inv.AddAnItem('Blunt Bolt', 100);
  10777.         EquipItem(ids[0]);
  10778.         inv.AddAnItem('Broadhead Bolt', 100);
  10779.         inv.AddAnItem('Split Bolt', 100);
  10780.        
  10781.        
  10782.         RemoveAllAlchemyRecipes();
  10783.         RemoveAllCraftingSchematics();
  10784.        
  10785.        
  10786.        
  10787.        
  10788.         AddAlchemyRecipe('Recipe for Cat 1');
  10789.        
  10790.        
  10791.        
  10792.         AddAlchemyRecipe('Recipe for Maribor Forest 1');
  10793.         AddAlchemyRecipe('Recipe for Petris Philtre 1');
  10794.         AddAlchemyRecipe('Recipe for Swallow 1');
  10795.         AddAlchemyRecipe('Recipe for Tawny Owl 1');
  10796.        
  10797.         AddAlchemyRecipe('Recipe for White Gull 1');
  10798.         AddAlchemyRecipe('Recipe for White Honey 1');
  10799.         AddAlchemyRecipe('Recipe for White Raffards Decoction 1');
  10800.        
  10801.        
  10802.        
  10803.         AddAlchemyRecipe('Recipe for Beast Oil 1');
  10804.         AddAlchemyRecipe('Recipe for Cursed Oil 1');
  10805.         AddAlchemyRecipe('Recipe for Hanged Man Venom 1');
  10806.         AddAlchemyRecipe('Recipe for Hybrid Oil 1');
  10807.         AddAlchemyRecipe('Recipe for Insectoid Oil 1');
  10808.         AddAlchemyRecipe('Recipe for Magicals Oil 1');
  10809.         AddAlchemyRecipe('Recipe for Necrophage Oil 1');
  10810.         AddAlchemyRecipe('Recipe for Specter Oil 1');
  10811.         AddAlchemyRecipe('Recipe for Vampire Oil 1');
  10812.         AddAlchemyRecipe('Recipe for Draconide Oil 1');
  10813.         AddAlchemyRecipe('Recipe for Ogre Oil 1');
  10814.         AddAlchemyRecipe('Recipe for Relic Oil 1');
  10815.         AddAlchemyRecipe('Recipe for Beast Oil 2');
  10816.         AddAlchemyRecipe('Recipe for Cursed Oil 2');
  10817.         AddAlchemyRecipe('Recipe for Hanged Man Venom 2');
  10818.         AddAlchemyRecipe('Recipe for Hybrid Oil 2');
  10819.         AddAlchemyRecipe('Recipe for Insectoid Oil 2');
  10820.         AddAlchemyRecipe('Recipe for Magicals Oil 2');
  10821.         AddAlchemyRecipe('Recipe for Necrophage Oil 2');
  10822.         AddAlchemyRecipe('Recipe for Specter Oil 2');
  10823.         AddAlchemyRecipe('Recipe for Vampire Oil 2');
  10824.         AddAlchemyRecipe('Recipe for Draconide Oil 2');
  10825.         AddAlchemyRecipe('Recipe for Ogre Oil 2');
  10826.         AddAlchemyRecipe('Recipe for Relic Oil 2');
  10827.        
  10828.        
  10829.         AddAlchemyRecipe('Recipe for Dancing Star 1');
  10830.        
  10831.         AddAlchemyRecipe('Recipe for Dwimeritum Bomb 1');
  10832.        
  10833.         AddAlchemyRecipe('Recipe for Grapeshot 1');
  10834.         AddAlchemyRecipe('Recipe for Samum 1');
  10835.        
  10836.         AddAlchemyRecipe('Recipe for White Frost 1');
  10837.        
  10838.        
  10839.        
  10840.         AddAlchemyRecipe('Recipe for Dwarven spirit 1');
  10841.         AddAlchemyRecipe('Recipe for Alcohest 1');
  10842.         AddAlchemyRecipe('Recipe for White Gull 1');
  10843.        
  10844.        
  10845.         AddStartingSchematics();
  10846.        
  10847.        
  10848.         ids.Clear();
  10849.         ids = inv.AddAnItem('Swallow 2');
  10850.         EquipItem(ids[0]);
  10851.         ids.Clear();
  10852.         ids = inv.AddAnItem('Thunderbolt 2');
  10853.         EquipItem(ids[0]);
  10854.         ids.Clear();
  10855.         ids = inv.AddAnItem('Tawny Owl 2');
  10856.         EquipItem(ids[0]);
  10857.         ids.Clear();
  10858.        
  10859.         ids = inv.AddAnItem('Grapeshot 2');
  10860.         EquipItem(ids[0]);
  10861.         ids.Clear();
  10862.         ids = inv.AddAnItem('Samum 2');
  10863.         EquipItem(ids[0]);
  10864.        
  10865.         inv.AddAnItem('Dwimeritum Bomb 1');
  10866.         inv.AddAnItem('Dragons Dream 1');
  10867.         inv.AddAnItem('Silver Dust Bomb 1');
  10868.         inv.AddAnItem('White Frost 2');
  10869.         inv.AddAnItem('Devils Puffball 2');
  10870.         inv.AddAnItem('Dancing Star 2');
  10871.         inv.AddAnItem('Beast Oil 1');
  10872.         inv.AddAnItem('Cursed Oil 1');
  10873.         inv.AddAnItem('Hanged Man Venom 2');
  10874.         inv.AddAnItem('Hybrid Oil 1');
  10875.         inv.AddAnItem('Insectoid Oil 1');
  10876.         inv.AddAnItem('Magicals Oil 1');
  10877.         inv.AddAnItem('Necrophage Oil 2');
  10878.         inv.AddAnItem('Specter Oil 1');
  10879.         inv.AddAnItem('Vampire Oil 1');
  10880.         inv.AddAnItem('Draconide Oil 1');
  10881.         inv.AddAnItem('Relic Oil 1');
  10882.         inv.AddAnItem('Black Blood 1');
  10883.         inv.AddAnItem('Blizzard 1');
  10884.         inv.AddAnItem('Cat 2');
  10885.         inv.AddAnItem('Full Moon 1');
  10886.         inv.AddAnItem('Maribor Forest 1');
  10887.         inv.AddAnItem('Petris Philtre 1');
  10888.         inv.AddAnItem('White Gull 1', 3);
  10889.         inv.AddAnItem('White Honey 2');
  10890.         inv.AddAnItem('White Raffards Decoction 1');
  10891.        
  10892.        
  10893.         inv.AddAnItem('Mutagen 17');   
  10894.         inv.AddAnItem('Mutagen 19');   
  10895.         inv.AddAnItem('Mutagen 27');   
  10896.         inv.AddAnItem('Mutagen 26');   
  10897.        
  10898.        
  10899.         inv.AddAnItem('weapon_repair_kit_1', 5);
  10900.         inv.AddAnItem('weapon_repair_kit_2', 3);
  10901.         inv.AddAnItem('armor_repair_kit_1', 5);
  10902.         inv.AddAnItem('armor_repair_kit_2', 3);
  10903.        
  10904.        
  10905.         quantityMedium = 2;
  10906.         quantityLow = 1;
  10907.         inv.AddAnItem('Rune stribog lesser', quantityMedium);
  10908.         inv.AddAnItem('Rune stribog', quantityLow);
  10909.         inv.AddAnItem('Rune dazhbog lesser', quantityMedium);
  10910.         inv.AddAnItem('Rune dazhbog', quantityLow);
  10911.         inv.AddAnItem('Rune devana lesser', quantityMedium);
  10912.         inv.AddAnItem('Rune devana', quantityLow);
  10913.         inv.AddAnItem('Rune zoria lesser', quantityMedium);
  10914.         inv.AddAnItem('Rune zoria', quantityLow);
  10915.         inv.AddAnItem('Rune morana lesser', quantityMedium);
  10916.         inv.AddAnItem('Rune morana', quantityLow);
  10917.         inv.AddAnItem('Rune triglav lesser', quantityMedium);
  10918.         inv.AddAnItem('Rune triglav', quantityLow);
  10919.         inv.AddAnItem('Rune svarog lesser', quantityMedium);
  10920.         inv.AddAnItem('Rune svarog', quantityLow);
  10921.         inv.AddAnItem('Rune veles lesser', quantityMedium);
  10922.         inv.AddAnItem('Rune veles', quantityLow);
  10923.         inv.AddAnItem('Rune perun lesser', quantityMedium);
  10924.         inv.AddAnItem('Rune perun', quantityLow);
  10925.         inv.AddAnItem('Rune elemental lesser', quantityMedium);
  10926.         inv.AddAnItem('Rune elemental', quantityLow);
  10927.        
  10928.         inv.AddAnItem('Glyph aard lesser', quantityMedium);
  10929.         inv.AddAnItem('Glyph aard', quantityLow);
  10930.         inv.AddAnItem('Glyph axii lesser', quantityMedium);
  10931.         inv.AddAnItem('Glyph axii', quantityLow);
  10932.         inv.AddAnItem('Glyph igni lesser', quantityMedium);
  10933.         inv.AddAnItem('Glyph igni', quantityLow);
  10934.         inv.AddAnItem('Glyph quen lesser', quantityMedium);
  10935.         inv.AddAnItem('Glyph quen', quantityLow);
  10936.         inv.AddAnItem('Glyph yrden lesser', quantityMedium);
  10937.         inv.AddAnItem('Glyph yrden', quantityLow);
  10938.        
  10939.        
  10940.         StandaloneEp1_2();
  10941.     }
  10942.    
  10943.     public final function StandaloneEp1_2()
  10944.     {
  10945.         var horseId : SItemUniqueId;
  10946.         var ids : array<SItemUniqueId>;
  10947.         var ents : array< CJournalBase >;
  10948.         var i : int;
  10949.         var manager : CWitcherJournalManager;
  10950.        
  10951.        
  10952.         inv.AddAnItem( 'Cows milk', 20 );
  10953.         ids.Clear();
  10954.         ids = inv.AddAnItem( 'Dumpling', 44 );
  10955.         EquipItem(ids[0]);
  10956.        
  10957.        
  10958.         inv.AddAnItem('Clearing Potion', 2, true, false, false);
  10959.        
  10960.        
  10961.         GetHorseManager().RemoveAllItems();
  10962.        
  10963.         ids.Clear();
  10964.         ids = inv.AddAnItem('Horse Bag 2');
  10965.         horseId = GetHorseManager().MoveItemToHorse(ids[0]);
  10966.         GetHorseManager().EquipItem(horseId);
  10967.        
  10968.         ids.Clear();
  10969.         ids = inv.AddAnItem('Horse Blinder 2');
  10970.         horseId = GetHorseManager().MoveItemToHorse(ids[0]);
  10971.         GetHorseManager().EquipItem(horseId);
  10972.        
  10973.         ids.Clear();
  10974.         ids = inv.AddAnItem('Horse Saddle 2');
  10975.         horseId = GetHorseManager().MoveItemToHorse(ids[0]);
  10976.         GetHorseManager().EquipItem(horseId);
  10977.        
  10978.         manager = theGame.GetJournalManager();
  10979.  
  10980.        
  10981.         manager.GetActivatedOfType( 'CJournalCreature', ents );
  10982.         for(i=0; i<ents.Size(); i+=1)
  10983.         {
  10984.             manager.ActivateEntry(ents[i], JS_Inactive, false, true);
  10985.         }
  10986.        
  10987.        
  10988.         ents.Clear();
  10989.         manager.GetActivatedOfType( 'CJournalCharacter', ents );
  10990.         for(i=0; i<ents.Size(); i+=1)
  10991.         {
  10992.             manager.ActivateEntry(ents[i], JS_Inactive, false, true);
  10993.         }
  10994.        
  10995.        
  10996.         ents.Clear();
  10997.         manager.GetActivatedOfType( 'CJournalQuest', ents );
  10998.         for(i=0; i<ents.Size(); i+=1)
  10999.         {
  11000.            
  11001.             if( StrStartsWith(ents[i].baseName, "q60"))
  11002.                 continue;
  11003.                
  11004.             manager.ActivateEntry(ents[i], JS_Inactive, false, true);
  11005.         }
  11006.        
  11007.        
  11008.         manager.ActivateEntryByScriptTag('TutorialAard', JS_Active);
  11009.         manager.ActivateEntryByScriptTag('TutorialAdrenaline', JS_Active);
  11010.         manager.ActivateEntryByScriptTag('TutorialAxii', JS_Active);
  11011.         manager.ActivateEntryByScriptTag('TutorialAxiiDialog', JS_Active);
  11012.         manager.ActivateEntryByScriptTag('TutorialCamera', JS_Active);
  11013.         manager.ActivateEntryByScriptTag('TutorialCamera_pad', JS_Active);
  11014.         manager.ActivateEntryByScriptTag('TutorialCiriBlink', JS_Active);
  11015.         manager.ActivateEntryByScriptTag('TutorialCiriCharge', JS_Active);
  11016.         manager.ActivateEntryByScriptTag('TutorialCiriStamina', JS_Active);
  11017.         manager.ActivateEntryByScriptTag('TutorialCounter', JS_Active);
  11018.         manager.ActivateEntryByScriptTag('TutorialDialogClose', JS_Active);
  11019.         manager.ActivateEntryByScriptTag('TutorialFallingRoll', JS_Active);
  11020.         manager.ActivateEntryByScriptTag('TutorialFocus', JS_Active);
  11021.         manager.ActivateEntryByScriptTag('TutorialFocusClues', JS_Active);
  11022.         manager.ActivateEntryByScriptTag('TutorialFocusClues', JS_Active);
  11023.         manager.ActivateEntryByScriptTag('TutorialHorseRoad', JS_Active);
  11024.         manager.ActivateEntryByScriptTag('TutorialHorseSpeed0', JS_Active);
  11025.         manager.ActivateEntryByScriptTag('TutorialHorseSpeed0_pad', JS_Active);
  11026.         manager.ActivateEntryByScriptTag('TutorialHorseSpeed1', JS_Active);
  11027.         manager.ActivateEntryByScriptTag('TutorialHorseSpeed2', JS_Active);
  11028.         manager.ActivateEntryByScriptTag('TutorialHorseSummon', JS_Active);
  11029.         manager.ActivateEntryByScriptTag('TutorialHorseSummon_pad', JS_Active);
  11030.         manager.ActivateEntryByScriptTag('TutorialIgni', JS_Active);
  11031.         manager.ActivateEntryByScriptTag('TutorialJournalAlternateSings', JS_Active);
  11032.         manager.ActivateEntryByScriptTag('TutorialJournalBoatDamage', JS_Active);
  11033.         manager.ActivateEntryByScriptTag('TutorialJournalBoatMount', JS_Active);
  11034.         manager.ActivateEntryByScriptTag('TutorialJournalBuffs', JS_Active);
  11035.         manager.ActivateEntryByScriptTag('TutorialJournalCharDevLeveling', JS_Active);
  11036.         manager.ActivateEntryByScriptTag('TutorialJournalCharDevSkills', JS_Active);
  11037.         manager.ActivateEntryByScriptTag('TutorialJournalCrafting', JS_Active);
  11038.         manager.ActivateEntryByScriptTag('TutorialJournalCrossbow', JS_Active);
  11039.         manager.ActivateEntryByScriptTag('TutorialJournalDialogGwint', JS_Active);
  11040.         manager.ActivateEntryByScriptTag('TutorialJournalDialogShop', JS_Active);
  11041.         manager.ActivateEntryByScriptTag('TutorialJournalDive', JS_Active);
  11042.         manager.ActivateEntryByScriptTag('TutorialJournalDodge', JS_Active);
  11043.         manager.ActivateEntryByScriptTag('TutorialJournalDodge_pad', JS_Active);
  11044.         manager.ActivateEntryByScriptTag('TutorialJournalDrawWeapon', JS_Active);
  11045.         manager.ActivateEntryByScriptTag('TutorialJournalDrawWeapon_pad', JS_Active);
  11046.         manager.ActivateEntryByScriptTag('TutorialJournalDurability', JS_Active);
  11047.         manager.ActivateEntryByScriptTag('TutorialJournalExplorations', JS_Active);
  11048.         manager.ActivateEntryByScriptTag('TutorialJournalExplorations_pad', JS_Active);
  11049.         manager.ActivateEntryByScriptTag('TutorialJournalFastTravel', JS_Active);
  11050.         manager.ActivateEntryByScriptTag('TutorialJournalFocusRedObjects', JS_Active);
  11051.         manager.ActivateEntryByScriptTag('TutorialJournalGasClouds', JS_Active);
  11052.         manager.ActivateEntryByScriptTag('TutorialJournalHeavyAttacks', JS_Active);
  11053.         manager.ActivateEntryByScriptTag('TutorialJournalHorse', JS_Active);
  11054.         manager.ActivateEntryByScriptTag('TutorialJournalHorseStamina', JS_Active);
  11055.         manager.ActivateEntryByScriptTag('TutorialJournalJump', JS_Active);
  11056.         manager.ActivateEntryByScriptTag('TutorialJournalLightAttacks', JS_Active);
  11057.         manager.ActivateEntryByScriptTag('TutorialJournalLightAttacks_pad', JS_Active);
  11058.         manager.ActivateEntryByScriptTag('TutorialJournalMeditation', JS_Active);
  11059.         manager.ActivateEntryByScriptTag('TutorialJournalMeditation_pad', JS_Active);
  11060.         manager.ActivateEntryByScriptTag('TutorialJournalMonsterThreatLevels', JS_Active);
  11061.         manager.ActivateEntryByScriptTag('TutorialJournalMovement', JS_Active);
  11062.         manager.ActivateEntryByScriptTag('TutorialJournalMovement_pad', JS_Active);
  11063.         manager.ActivateEntryByScriptTag('TutorialJournalMutagenIngredient', JS_Active);
  11064.         manager.ActivateEntryByScriptTag('TutorialJournalMutagenPotion', JS_Active);
  11065.         manager.ActivateEntryByScriptTag('TutorialJournalOils', JS_Active);
  11066.         manager.ActivateEntryByScriptTag('TutorialJournalPetards', JS_Active);
  11067.         manager.ActivateEntryByScriptTag('TutorialJournalPotions', JS_Active);
  11068.         manager.ActivateEntryByScriptTag('TutorialJournalPotions_pad', JS_Active);
  11069.         manager.ActivateEntryByScriptTag('TutorialJournalQuestArea', JS_Active);
  11070.         manager.ActivateEntryByScriptTag('TutorialJournalRadial', JS_Active);
  11071.         manager.ActivateEntryByScriptTag('TutorialJournalRifts', JS_Active);
  11072.         manager.ActivateEntryByScriptTag('TutorialJournalRun', JS_Active);
  11073.         manager.ActivateEntryByScriptTag('TutorialJournalShopDescription', JS_Active);
  11074.         manager.ActivateEntryByScriptTag('TutorialJournalSignCast', JS_Active);
  11075.         manager.ActivateEntryByScriptTag('TutorialJournalSignCast_pad', JS_Active);
  11076.         manager.ActivateEntryByScriptTag('TutorialJournalSpecialAttacks', JS_Active);
  11077.         manager.ActivateEntryByScriptTag('TutorialJournalStaminaExploration', JS_Active);
  11078.         manager.ActivateEntryByScriptTag('TutorialJumpHang', JS_Active);
  11079.         manager.ActivateEntryByScriptTag('TutorialLadder', JS_Active);
  11080.         manager.ActivateEntryByScriptTag('TutorialLadderMove', JS_Active);
  11081.         manager.ActivateEntryByScriptTag('TutorialLadderMove_pad', JS_Active);
  11082.         manager.ActivateEntryByScriptTag('TutorialObjectiveSwitching', JS_Active);
  11083.         manager.ActivateEntryByScriptTag('TutorialOxygen', JS_Active);
  11084.         manager.ActivateEntryByScriptTag('TutorialParry', JS_Active);
  11085.         manager.ActivateEntryByScriptTag('TutorialPOIUncovered', JS_Active);
  11086.         manager.ActivateEntryByScriptTag('TutorialQuen', JS_Active);
  11087.         manager.ActivateEntryByScriptTag('TutorialRoll', JS_Active);
  11088.         manager.ActivateEntryByScriptTag('TutorialRoll_pad', JS_Active);
  11089.         manager.ActivateEntryByScriptTag('TutorialSpeedPairing', JS_Active);
  11090.         manager.ActivateEntryByScriptTag('TutorialSprint', JS_Active);
  11091.         manager.ActivateEntryByScriptTag('TutorialStaminaSigns', JS_Active);
  11092.         manager.ActivateEntryByScriptTag('TutorialStealing', JS_Active);
  11093.         manager.ActivateEntryByScriptTag('TutorialSwimmingSpeed', JS_Active);
  11094.         manager.ActivateEntryByScriptTag('TutorialTimedChoiceDialog', JS_Active);
  11095.         manager.ActivateEntryByScriptTag('TutorialYrden', JS_Active);
  11096.        
  11097.        
  11098.         FactsAdd('kill_base_tutorials');
  11099.        
  11100.        
  11101.         theGame.GetTutorialSystem().RemoveAllQueuedTutorials();
  11102.        
  11103.        
  11104.         FactsAdd('standalone_ep1');
  11105.         FactsRemove("StandAloneEP1");
  11106.        
  11107.         theGame.GetJournalManager().ForceUntrackingQuestForEP1Savegame();
  11108.     }
  11109.    
  11110.     final function Debug_FocusBoyFocusGain()
  11111.     {
  11112.         var focusGain : float;
  11113.        
  11114.         focusGain = FactsQuerySum( "debug_fact_focus_boy" ) ;
  11115.         GainStat( BCS_Focus, focusGain );
  11116.     }
  11117.    
  11118.     public final function StandaloneEp2_1()
  11119.     {
  11120.         var i, inc, quantityLow, randLow, quantityMedium, randMedium, quantityHigh, randHigh, startingMoney : int;
  11121.         var pam : W3PlayerAbilityManager;
  11122.         var ids : array<SItemUniqueId>;
  11123.         var STARTING_LEVEL : int;
  11124.        
  11125.         FactsAdd( "StandAloneEP2", 1 );
  11126.        
  11127.        
  11128.         inv.RemoveAllItems();
  11129.        
  11130.        
  11131.         inv.AddAnItem( 'Illusion Medallion', 1, true, true, false );
  11132.         inv.AddAnItem( 'q103_safe_conduct', 1, true, true, false );
  11133.        
  11134.        
  11135.         theGame.GetGamerProfile().ClearAllAchievementsForEP2();
  11136.        
  11137.        
  11138.         levelManager.Hack_EP2StandaloneLevelShrink( 35 );
  11139.        
  11140.        
  11141.         levelManager.ResetCharacterDev();
  11142.         pam = ( W3PlayerAbilityManager )abilityManager;
  11143.         if( pam )
  11144.         {
  11145.             pam.ResetCharacterDev();
  11146.         }
  11147.         levelManager.SetFreeSkillPoints( levelManager.GetLevel() - 1 + 11 );   
  11148.        
  11149.        
  11150.         inv.AddAnItem( 'Mutagen red', 4 );
  11151.         inv.AddAnItem( 'Mutagen green', 4 );
  11152.         inv.AddAnItem( 'Mutagen blue', 4 );
  11153.         inv.AddAnItem( 'Lesser mutagen red', 2 );
  11154.         inv.AddAnItem( 'Lesser mutagen green', 2 );
  11155.         inv.AddAnItem( 'Lesser mutagen blue', 2 );
  11156.         inv.AddAnItem( 'Greater mutagen red', 2 );
  11157.         inv.AddAnItem( 'Greater mutagen green', 2 );
  11158.         inv.AddAnItem( 'Greater mutagen blue', 2 );
  11159.        
  11160.        
  11161.         startingMoney = 20000;
  11162.         if( GetMoney() > startingMoney )
  11163.         {
  11164.             RemoveMoney( GetMoney() - startingMoney );
  11165.         }
  11166.         else
  11167.         {
  11168.             AddMoney( 20000 - GetMoney() );
  11169.         }
  11170.        
  11171.        
  11172.         ids.Clear();
  11173.         ids = inv.AddAnItem( 'EP2 Standalone Starting Armor' );
  11174.         EquipItem( ids[0] );
  11175.         ids.Clear();
  11176.         ids = inv.AddAnItem( 'EP2 Standalone Starting Boots' );
  11177.         EquipItem( ids[0] );
  11178.         ids.Clear();
  11179.         ids = inv.AddAnItem( 'EP2 Standalone Starting Gloves' );
  11180.         EquipItem( ids[0] );
  11181.         ids.Clear();
  11182.         ids = inv.AddAnItem( 'EP2 Standalone Starting Pants' );
  11183.         EquipItem( ids[0] );
  11184.        
  11185.        
  11186.         ids.Clear();
  11187.         ids = inv.AddAnItem( 'EP2 Standalone Starting Steel Sword' );
  11188.         EquipItem( ids[0] );
  11189.         ids.Clear();
  11190.         ids = inv.AddAnItem( 'EP2 Standalone Starting Silver Sword' );
  11191.         EquipItem( ids[0] );
  11192.        
  11193.        
  11194.         inv.AddAnItem( 'Torch', 1, true, true, false );
  11195.        
  11196.        
  11197.         quantityLow = 1;
  11198.         randLow = 3;
  11199.         quantityMedium = 4;
  11200.         randMedium = 4;
  11201.         quantityHigh = 8;
  11202.         randHigh = 6;
  11203.        
  11204.         inv.AddAnItem( 'Alghoul bone marrow',quantityMedium+RandRange( randMedium ) );
  11205.         inv.AddAnItem( 'Amethyst dust',quantityLow+RandRange( randLow ) );
  11206.         inv.AddAnItem( 'Arachas eyes',quantityLow+RandRange( randLow ) );
  11207.         inv.AddAnItem( 'Arachas venom',quantityLow+RandRange( randLow ) );
  11208.         inv.AddAnItem( 'Basilisk hide',quantityLow+RandRange( randLow ) );
  11209.         inv.AddAnItem( 'Basilisk venom',quantityLow+RandRange( randLow ) );
  11210.         inv.AddAnItem( 'Bear pelt',quantityHigh+RandRange( randHigh ) );
  11211.         inv.AddAnItem( 'Berserker pelt',quantityLow+RandRange( randLow ) );
  11212.         inv.AddAnItem( 'Coal',quantityHigh+RandRange( randHigh ) );
  11213.         inv.AddAnItem( 'Cotton',quantityHigh+RandRange( randHigh ) );
  11214.  
  11215.  
  11216.         inv.AddAnItem( 'Deer hide',quantityHigh+RandRange( randHigh ) );
  11217.         inv.AddAnItem( 'Diamond dust',quantityLow+RandRange( randLow ) );
  11218.  
  11219.         inv.AddAnItem( 'Drowned dead tongue',quantityLow+RandRange( randLow ) );
  11220.         inv.AddAnItem( 'Drowner brain',quantityMedium+RandRange( randMedium ) );
  11221.  
  11222.  
  11223.  
  11224.         inv.AddAnItem( 'Endriag chitin plates',quantityMedium+RandRange( randMedium ) );
  11225.         inv.AddAnItem( 'Endriag embryo',quantityLow+RandRange( randLow ) );
  11226.         inv.AddAnItem( 'Ghoul blood',quantityMedium+RandRange( randMedium ) );
  11227.         inv.AddAnItem( 'Goat hide',quantityMedium+RandRange( randMedium ) );
  11228.         inv.AddAnItem( 'Hag teeth',quantityMedium+RandRange( randMedium ) );
  11229.         inv.AddAnItem( 'Hardened leather',quantityMedium+RandRange( randMedium ) );
  11230.         inv.AddAnItem( 'Hardened timber',quantityMedium+RandRange( randMedium ) );
  11231.         inv.AddAnItem( 'Harpy feathers',quantityMedium+RandRange( randMedium ) );
  11232.         inv.AddAnItem( 'Horse hide',quantityLow+RandRange( randLow ) );
  11233.  
  11234.  
  11235.  
  11236.  
  11237.  
  11238.  
  11239.         inv.AddAnItem( 'Necrophage skin',quantityLow+RandRange( randLow ) );
  11240.         inv.AddAnItem( 'Nekker blood',quantityHigh+RandRange( randHigh ) );
  11241.         inv.AddAnItem( 'Nekker heart',quantityMedium+RandRange( randMedium ) );
  11242.  
  11243.         inv.AddAnItem( 'Phosphorescent crystal',quantityLow+RandRange( randLow ) );
  11244.         inv.AddAnItem( 'Pig hide',quantityMedium+RandRange( randMedium ) );
  11245.  
  11246.         inv.AddAnItem( 'Rabbit pelt',quantityMedium+RandRange( randMedium ) );
  11247.         inv.AddAnItem( 'Rotfiend blood',quantityMedium+RandRange( randMedium ) );
  11248.         inv.AddAnItem( 'Sapphire dust',quantityLow+RandRange( randLow ) );
  11249.  
  11250.  
  11251.  
  11252.         inv.AddAnItem( 'Specter dust',quantityMedium+RandRange( randMedium ) );
  11253.  
  11254.  
  11255.  
  11256.  
  11257.  
  11258.  
  11259.  
  11260.         inv.AddAnItem( 'Water essence',quantityMedium+RandRange( randMedium ) );
  11261.         inv.AddAnItem( 'Wolf liver',quantityHigh+RandRange( randHigh ) );
  11262.         inv.AddAnItem( 'Wolf pelt',quantityMedium+RandRange( randMedium ) );
  11263.        
  11264.         inv.AddAnItem( 'Alcohest', 5 );
  11265.         inv.AddAnItem( 'Dwarven spirit', 5 );
  11266.    
  11267.        
  11268.         ids.Clear();
  11269.         ids = inv.AddAnItem( 'Crossbow 5' );
  11270.         EquipItem( ids[0] );
  11271.         ids.Clear();
  11272.         ids = inv.AddAnItem( 'Blunt Bolt', 100 );
  11273.         EquipItem( ids[0] );
  11274.         inv.AddAnItem( 'Broadhead Bolt', 100 );
  11275.         inv.AddAnItem( 'Split Bolt', 100 );
  11276.        
  11277.        
  11278.         RemoveAllAlchemyRecipes();
  11279.         RemoveAllCraftingSchematics();
  11280.        
  11281.        
  11282.        
  11283.        
  11284.        
  11285.        
  11286.        
  11287.        
  11288.        
  11289.         AddAlchemyRecipe( 'Recipe for Petris Philtre 2' );
  11290.         AddAlchemyRecipe( 'Recipe for Swallow 1' );
  11291.         AddAlchemyRecipe( 'Recipe for Tawny Owl 1' );
  11292.        
  11293.         AddAlchemyRecipe( 'Recipe for White Gull 1' );
  11294.        
  11295.        
  11296.        
  11297.        
  11298.        
  11299.         AddAlchemyRecipe( 'Recipe for Beast Oil 1' );
  11300.         AddAlchemyRecipe( 'Recipe for Cursed Oil 1' );
  11301.         AddAlchemyRecipe( 'Recipe for Hanged Man Venom 1' );
  11302.         AddAlchemyRecipe( 'Recipe for Hybrid Oil 1' );
  11303.         AddAlchemyRecipe( 'Recipe for Insectoid Oil 2' );
  11304.         AddAlchemyRecipe( 'Recipe for Magicals Oil 1' );
  11305.         AddAlchemyRecipe( 'Recipe for Necrophage Oil 1' );
  11306.         AddAlchemyRecipe( 'Recipe for Specter Oil 1' );
  11307.         AddAlchemyRecipe( 'Recipe for Vampire Oil 2' );
  11308.         AddAlchemyRecipe( 'Recipe for Draconide Oil 2' );
  11309.         AddAlchemyRecipe( 'Recipe for Ogre Oil 1' );
  11310.         AddAlchemyRecipe( 'Recipe for Relic Oil 1' );
  11311.         AddAlchemyRecipe( 'Recipe for Beast Oil 2' );
  11312.         AddAlchemyRecipe( 'Recipe for Cursed Oil 2' );
  11313.         AddAlchemyRecipe( 'Recipe for Hanged Man Venom 2' );
  11314.         AddAlchemyRecipe( 'Recipe for Hybrid Oil 2' );
  11315.         AddAlchemyRecipe( 'Recipe for Insectoid Oil 2' );
  11316.         AddAlchemyRecipe( 'Recipe for Magicals Oil 2' );
  11317.         AddAlchemyRecipe( 'Recipe for Necrophage Oil 2' );
  11318.         AddAlchemyRecipe( 'Recipe for Specter Oil 2' );
  11319.         AddAlchemyRecipe( 'Recipe for Vampire Oil 2' );
  11320.         AddAlchemyRecipe( 'Recipe for Draconide Oil 2' );
  11321.         AddAlchemyRecipe( 'Recipe for Ogre Oil 2' );
  11322.         AddAlchemyRecipe( 'Recipe for Relic Oil 2' );
  11323.        
  11324.        
  11325.         AddAlchemyRecipe( 'Recipe for Dancing Star 1' );
  11326.        
  11327.         AddAlchemyRecipe( 'Recipe for Dwimeritum Bomb 1' );
  11328.        
  11329.         AddAlchemyRecipe( 'Recipe for Grapeshot 1' );
  11330.         AddAlchemyRecipe( 'Recipe for Samum 1' );
  11331.        
  11332.         AddAlchemyRecipe( 'Recipe for White Frost 1' );
  11333.        
  11334.        
  11335.        
  11336.         AddAlchemyRecipe( 'Recipe for Dwarven spirit 1' );
  11337.         AddAlchemyRecipe( 'Recipe for Alcohest 1' );
  11338.         AddAlchemyRecipe( 'Recipe for White Gull 1' );
  11339.        
  11340.        
  11341.         AddStartingSchematics();
  11342.        
  11343.        
  11344.         ids.Clear();
  11345.         ids = inv.AddAnItem( 'Swallow 2' );
  11346.         EquipItem( ids[0] );
  11347.         ids.Clear();
  11348.         ids = inv.AddAnItem( 'Thunderbolt 2' );
  11349.         EquipItem( ids[0] );
  11350.         ids.Clear();
  11351.         ids = inv.AddAnItem( 'Tawny Owl 2' );
  11352.         EquipItem( ids[0] );
  11353.         ids.Clear();
  11354.        
  11355.         ids = inv.AddAnItem( 'Grapeshot 2' );
  11356.         EquipItem( ids[0] );
  11357.         ids.Clear();
  11358.         ids = inv.AddAnItem( 'Samum 2' );
  11359.         EquipItem( ids[0] );
  11360.        
  11361.         inv.AddAnItem( 'Dwimeritum Bomb 1' );
  11362.         inv.AddAnItem( 'Dragons Dream 1' );
  11363.         inv.AddAnItem( 'Silver Dust Bomb 1' );
  11364.         inv.AddAnItem( 'White Frost 2' );
  11365.         inv.AddAnItem( 'Devils Puffball 2' );
  11366.         inv.AddAnItem( 'Dancing Star 2' );
  11367.         inv.AddAnItem( 'Beast Oil 1' );
  11368.         inv.AddAnItem( 'Cursed Oil 1' );
  11369.         inv.AddAnItem( 'Hanged Man Venom 2' );
  11370.         inv.AddAnItem( 'Hybrid Oil 2' );
  11371.         inv.AddAnItem( 'Insectoid Oil 2' );
  11372.         inv.AddAnItem( 'Magicals Oil 1' );
  11373.         inv.AddAnItem( 'Necrophage Oil 2' );
  11374.         inv.AddAnItem( 'Ogre Oil 1' );
  11375.         inv.AddAnItem( 'Specter Oil 1' );
  11376.         inv.AddAnItem( 'Vampire Oil 2' );
  11377.         inv.AddAnItem( 'Draconide Oil 2' );
  11378.         inv.AddAnItem( 'Relic Oil 1' );
  11379.         inv.AddAnItem( 'Black Blood 1' );
  11380.         inv.AddAnItem( 'Blizzard 1' );
  11381.         inv.AddAnItem( 'Cat 2' );
  11382.         inv.AddAnItem( 'Full Moon 1' );
  11383.         inv.AddAnItem( 'Golden Oriole 1' );
  11384.         inv.AddAnItem( 'Killer Whale 1' );
  11385.         inv.AddAnItem( 'Maribor Forest 1' );
  11386.         inv.AddAnItem( 'Petris Philtre 2' );
  11387.         inv.AddAnItem( 'White Gull 1', 3 );
  11388.         inv.AddAnItem( 'White Honey 2' );
  11389.         inv.AddAnItem( 'White Raffards Decoction 1' );
  11390.        
  11391.        
  11392.         inv.AddAnItem( 'Mutagen 17' ); 
  11393.         inv.AddAnItem( 'Mutagen 19' ); 
  11394.         inv.AddAnItem( 'Mutagen 27' ); 
  11395.         inv.AddAnItem( 'Mutagen 26' ); 
  11396.        
  11397.        
  11398.         inv.AddAnItem( 'weapon_repair_kit_1', 5 );
  11399.         inv.AddAnItem( 'weapon_repair_kit_2', 3 );
  11400.         inv.AddAnItem( 'armor_repair_kit_1', 5 );
  11401.         inv.AddAnItem( 'armor_repair_kit_2', 3 );
  11402.        
  11403.        
  11404.         quantityMedium = 2;
  11405.         quantityLow = 1;
  11406.         inv.AddAnItem( 'Rune stribog lesser', quantityMedium );
  11407.         inv.AddAnItem( 'Rune stribog', quantityLow );
  11408.         inv.AddAnItem( 'Rune dazhbog lesser', quantityMedium );
  11409.         inv.AddAnItem( 'Rune dazhbog', quantityLow );
  11410.         inv.AddAnItem( 'Rune devana lesser', quantityMedium );
  11411.         inv.AddAnItem( 'Rune devana', quantityLow );
  11412.         inv.AddAnItem( 'Rune zoria lesser', quantityMedium );
  11413.         inv.AddAnItem( 'Rune zoria', quantityLow );
  11414.         inv.AddAnItem( 'Rune morana lesser', quantityMedium );
  11415.         inv.AddAnItem( 'Rune morana', quantityLow );
  11416.         inv.AddAnItem( 'Rune triglav lesser', quantityMedium );
  11417.         inv.AddAnItem( 'Rune triglav', quantityLow );
  11418.         inv.AddAnItem( 'Rune svarog lesser', quantityMedium );
  11419.         inv.AddAnItem( 'Rune svarog', quantityLow );
  11420.         inv.AddAnItem( 'Rune veles lesser', quantityMedium );
  11421.         inv.AddAnItem( 'Rune veles', quantityLow );
  11422.         inv.AddAnItem( 'Rune perun lesser', quantityMedium );
  11423.         inv.AddAnItem( 'Rune perun', quantityLow );
  11424.         inv.AddAnItem( 'Rune elemental lesser', quantityMedium );
  11425.         inv.AddAnItem( 'Rune elemental', quantityLow );
  11426.        
  11427.         inv.AddAnItem( 'Glyph aard lesser', quantityMedium );
  11428.         inv.AddAnItem( 'Glyph aard', quantityLow );
  11429.         inv.AddAnItem( 'Glyph axii lesser', quantityMedium );
  11430.         inv.AddAnItem( 'Glyph axii', quantityLow );
  11431.         inv.AddAnItem( 'Glyph igni lesser', quantityMedium );
  11432.         inv.AddAnItem( 'Glyph igni', quantityLow );
  11433.         inv.AddAnItem( 'Glyph quen lesser', quantityMedium );
  11434.         inv.AddAnItem( 'Glyph quen', quantityLow );
  11435.         inv.AddAnItem( 'Glyph yrden lesser', quantityMedium );
  11436.         inv.AddAnItem( 'Glyph yrden', quantityLow );
  11437.        
  11438.        
  11439.         StandaloneEp2_2();
  11440.     }
  11441.    
  11442.     public final function StandaloneEp2_2()
  11443.     {
  11444.         var horseId : SItemUniqueId;
  11445.         var ids : array<SItemUniqueId>;
  11446.         var ents : array< CJournalBase >;
  11447.         var i : int;
  11448.         var manager : CWitcherJournalManager;
  11449.        
  11450.        
  11451.         inv.AddAnItem( 'Cows milk', 20 );
  11452.         ids.Clear();
  11453.         ids = inv.AddAnItem( 'Dumpling', 44 );
  11454.         EquipItem( ids[0] );
  11455.        
  11456.        
  11457.         inv.AddAnItem( 'Clearing Potion', 2, true, false, false );
  11458.        
  11459.        
  11460.         GetHorseManager().RemoveAllItems();
  11461.        
  11462.         ids.Clear();
  11463.         ids = inv.AddAnItem( 'Horse Bag 2' );
  11464.         horseId = GetHorseManager( ).MoveItemToHorse( ids[0] );
  11465.         GetHorseManager().EquipItem( horseId );
  11466.        
  11467.         ids.Clear();
  11468.         ids = inv.AddAnItem( 'Horse Blinder 2' );
  11469.         horseId = GetHorseManager().MoveItemToHorse( ids[0] );
  11470.         GetHorseManager().EquipItem( horseId );
  11471.        
  11472.         ids.Clear();
  11473.         ids = inv.AddAnItem( 'Horse Saddle 2' );
  11474.         horseId = GetHorseManager().MoveItemToHorse( ids[0] );
  11475.         GetHorseManager().EquipItem( horseId );
  11476.        
  11477.         manager = theGame.GetJournalManager();
  11478.  
  11479.        
  11480.         manager.GetActivatedOfType( 'CJournalCreature', ents );
  11481.         for(i=0; i<ents.Size(); i+=1)
  11482.         {
  11483.             manager.ActivateEntry( ents[i], JS_Inactive, false, true );
  11484.         }
  11485.        
  11486.        
  11487.         ents.Clear();
  11488.         manager.GetActivatedOfType( 'CJournalCharacter', ents );
  11489.         for(i=0; i<ents.Size(); i+=1)
  11490.         {
  11491.             manager.ActivateEntry( ents[i], JS_Inactive, false, true );
  11492.         }
  11493.        
  11494.        
  11495.         ents.Clear();
  11496.         manager.GetActivatedOfType( 'CJournalQuest', ents );
  11497.         for(i=0; i<ents.Size(); i+=1)
  11498.         {
  11499.            
  11500.             if( StrStartsWith( ents[i].baseName, "q60" ) )
  11501.                 continue;
  11502.                
  11503.             manager.ActivateEntry( ents[i], JS_Inactive, false, true );
  11504.         }
  11505.        
  11506.        
  11507.         manager.ActivateEntryByScriptTag( 'TutorialAard', JS_Active );
  11508.         manager.ActivateEntryByScriptTag( 'TutorialAdrenaline', JS_Active );
  11509.         manager.ActivateEntryByScriptTag( 'TutorialAxii', JS_Active );
  11510.         manager.ActivateEntryByScriptTag( 'TutorialAxiiDialog', JS_Active );
  11511.         manager.ActivateEntryByScriptTag( 'TutorialCamera', JS_Active );
  11512.         manager.ActivateEntryByScriptTag( 'TutorialCamera_pad', JS_Active );
  11513.         manager.ActivateEntryByScriptTag( 'TutorialCiriBlink', JS_Active );
  11514.         manager.ActivateEntryByScriptTag( 'TutorialCiriCharge', JS_Active );
  11515.         manager.ActivateEntryByScriptTag( 'TutorialCiriStamina', JS_Active );
  11516.         manager.ActivateEntryByScriptTag( 'TutorialCounter', JS_Active );
  11517.         manager.ActivateEntryByScriptTag( 'TutorialDialogClose', JS_Active );
  11518.         manager.ActivateEntryByScriptTag( 'TutorialFallingRoll', JS_Active );
  11519.         manager.ActivateEntryByScriptTag( 'TutorialFocus', JS_Active );
  11520.         manager.ActivateEntryByScriptTag( 'TutorialFocusClues', JS_Active );
  11521.         manager.ActivateEntryByScriptTag( 'TutorialFocusClues', JS_Active );
  11522.         manager.ActivateEntryByScriptTag( 'TutorialHorseRoad', JS_Active );
  11523.         manager.ActivateEntryByScriptTag( 'TutorialHorseSpeed0', JS_Active );
  11524.         manager.ActivateEntryByScriptTag( 'TutorialHorseSpeed0_pad', JS_Active );
  11525.         manager.ActivateEntryByScriptTag( 'TutorialHorseSpeed1', JS_Active );
  11526.         manager.ActivateEntryByScriptTag( 'TutorialHorseSpeed2', JS_Active );
  11527.         manager.ActivateEntryByScriptTag( 'TutorialHorseSummon', JS_Active );
  11528.         manager.ActivateEntryByScriptTag( 'TutorialHorseSummon_pad', JS_Active );
  11529.         manager.ActivateEntryByScriptTag( 'TutorialIgni', JS_Active );
  11530.         manager.ActivateEntryByScriptTag( 'TutorialJournalAlternateSings', JS_Active );
  11531.         manager.ActivateEntryByScriptTag( 'TutorialJournalBoatDamage', JS_Active );
  11532.         manager.ActivateEntryByScriptTag( 'TutorialJournalBoatMount', JS_Active );
  11533.         manager.ActivateEntryByScriptTag( 'TutorialJournalBuffs', JS_Active );
  11534.         manager.ActivateEntryByScriptTag( 'TutorialJournalCharDevLeveling', JS_Active );
  11535.         manager.ActivateEntryByScriptTag( 'TutorialJournalCharDevSkills', JS_Active );
  11536.         manager.ActivateEntryByScriptTag( 'TutorialJournalCrafting', JS_Active );
  11537.         manager.ActivateEntryByScriptTag( 'TutorialJournalCrossbow', JS_Active );
  11538.         manager.ActivateEntryByScriptTag( 'TutorialJournalDialogGwint', JS_Active );
  11539.         manager.ActivateEntryByScriptTag( 'TutorialJournalDialogShop', JS_Active );
  11540.         manager.ActivateEntryByScriptTag( 'TutorialJournalDive', JS_Active );
  11541.         manager.ActivateEntryByScriptTag( 'TutorialJournalDodge', JS_Active );
  11542.         manager.ActivateEntryByScriptTag( 'TutorialJournalDodge_pad', JS_Active );
  11543.         manager.ActivateEntryByScriptTag( 'TutorialJournalDrawWeapon', JS_Active );
  11544.         manager.ActivateEntryByScriptTag( 'TutorialJournalDrawWeapon_pad', JS_Active );
  11545.         manager.ActivateEntryByScriptTag( 'TutorialJournalDurability', JS_Active );
  11546.         manager.ActivateEntryByScriptTag( 'TutorialJournalExplorations', JS_Active );
  11547.         manager.ActivateEntryByScriptTag( 'TutorialJournalExplorations_pad', JS_Active );
  11548.         manager.ActivateEntryByScriptTag( 'TutorialJournalFastTravel', JS_Active );
  11549.         manager.ActivateEntryByScriptTag( 'TutorialJournalFocusRedObjects', JS_Active );
  11550.         manager.ActivateEntryByScriptTag( 'TutorialJournalGasClouds', JS_Active );
  11551.         manager.ActivateEntryByScriptTag( 'TutorialJournalHeavyAttacks', JS_Active );
  11552.         manager.ActivateEntryByScriptTag( 'TutorialJournalHorse', JS_Active );
  11553.         manager.ActivateEntryByScriptTag( 'TutorialJournalHorseStamina', JS_Active );
  11554.         manager.ActivateEntryByScriptTag( 'TutorialJournalJump', JS_Active );
  11555.         manager.ActivateEntryByScriptTag( 'TutorialJournalLightAttacks', JS_Active );
  11556.         manager.ActivateEntryByScriptTag( 'TutorialJournalLightAttacks_pad', JS_Active );
  11557.         manager.ActivateEntryByScriptTag( 'TutorialJournalMeditation', JS_Active );
  11558.         manager.ActivateEntryByScriptTag( 'TutorialJournalMeditation_pad', JS_Active );
  11559.         manager.ActivateEntryByScriptTag( 'TutorialJournalMonsterThreatLevels', JS_Active );
  11560.         manager.ActivateEntryByScriptTag( 'TutorialJournalMovement', JS_Active );
  11561.         manager.ActivateEntryByScriptTag( 'TutorialJournalMovement_pad', JS_Active );
  11562.         manager.ActivateEntryByScriptTag( 'TutorialJournalMutagenIngredient', JS_Active );
  11563.         manager.ActivateEntryByScriptTag( 'TutorialJournalMutagenPotion', JS_Active );
  11564.         manager.ActivateEntryByScriptTag( 'TutorialJournalOils', JS_Active );
  11565.         manager.ActivateEntryByScriptTag( 'TutorialJournalPetards', JS_Active );
  11566.         manager.ActivateEntryByScriptTag( 'TutorialJournalPotions', JS_Active );
  11567.         manager.ActivateEntryByScriptTag( 'TutorialJournalPotions_pad', JS_Active );
  11568.         manager.ActivateEntryByScriptTag( 'TutorialJournalQuestArea', JS_Active );
  11569.         manager.ActivateEntryByScriptTag( 'TutorialJournalRadial', JS_Active );
  11570.         manager.ActivateEntryByScriptTag( 'TutorialJournalRifts', JS_Active );
  11571.         manager.ActivateEntryByScriptTag( 'TutorialJournalRun', JS_Active );
  11572.         manager.ActivateEntryByScriptTag( 'TutorialJournalShopDescription', JS_Active );
  11573.         manager.ActivateEntryByScriptTag( 'TutorialJournalSignCast', JS_Active );
  11574.         manager.ActivateEntryByScriptTag( 'TutorialJournalSignCast_pad', JS_Active );
  11575.         manager.ActivateEntryByScriptTag( 'TutorialJournalSpecialAttacks', JS_Active );
  11576.         manager.ActivateEntryByScriptTag( 'TutorialJournalStaminaExploration', JS_Active );
  11577.         manager.ActivateEntryByScriptTag( 'TutorialJumpHang', JS_Active );
  11578.         manager.ActivateEntryByScriptTag( 'TutorialLadder', JS_Active );
  11579.         manager.ActivateEntryByScriptTag( 'TutorialLadderMove', JS_Active );
  11580.         manager.ActivateEntryByScriptTag( 'TutorialLadderMove_pad', JS_Active );
  11581.         manager.ActivateEntryByScriptTag( 'TutorialObjectiveSwitching', JS_Active );
  11582.         manager.ActivateEntryByScriptTag( 'TutorialOxygen', JS_Active );
  11583.         manager.ActivateEntryByScriptTag( 'TutorialParry', JS_Active );
  11584.         manager.ActivateEntryByScriptTag( 'TutorialPOIUncovered', JS_Active );
  11585.         manager.ActivateEntryByScriptTag( 'TutorialQuen', JS_Active );
  11586.         manager.ActivateEntryByScriptTag( 'TutorialRoll', JS_Active );
  11587.         manager.ActivateEntryByScriptTag( 'TutorialRoll_pad', JS_Active );
  11588.         manager.ActivateEntryByScriptTag( 'TutorialSpeedPairing', JS_Active );
  11589.         manager.ActivateEntryByScriptTag( 'TutorialSprint', JS_Active );
  11590.         manager.ActivateEntryByScriptTag( 'TutorialStaminaSigns', JS_Active );
  11591.         manager.ActivateEntryByScriptTag( 'TutorialStealing', JS_Active );
  11592.         manager.ActivateEntryByScriptTag( 'TutorialSwimmingSpeed', JS_Active );
  11593.         manager.ActivateEntryByScriptTag( 'TutorialTimedChoiceDialog', JS_Active );
  11594.         manager.ActivateEntryByScriptTag( 'TutorialYrden', JS_Active );
  11595.        
  11596.         inv.AddAnItem( 'Geralt Shirt', 1 );
  11597.         inv.AddAnItem( 'Thread', 13 );
  11598.         inv.AddAnItem( 'String', 9 );
  11599.         inv.AddAnItem( 'Linen', 4 );
  11600.         inv.AddAnItem( 'Silk', 6 );
  11601.         inv.AddAnItem( 'Nigredo', 3 );
  11602.         inv.AddAnItem( 'Albedo', 1 );
  11603.         inv.AddAnItem( 'Rubedo', 1 );
  11604.         inv.AddAnItem( 'Rebis', 1 );
  11605.         inv.AddAnItem( 'Dog tallow', 4 );
  11606.         inv.AddAnItem( 'Lunar shards', 3 );
  11607.         inv.AddAnItem( 'Quicksilver solution', 5 );
  11608.         inv.AddAnItem( 'Aether', 1 );
  11609.         inv.AddAnItem( 'Optima mater', 3 );
  11610.         inv.AddAnItem( 'Fifth essence', 2 );
  11611.         inv.AddAnItem( 'Hardened timber', 6 );
  11612.         inv.AddAnItem( 'Fur square', 1 );
  11613.         inv.AddAnItem( 'Leather straps', 11 );
  11614.         inv.AddAnItem( 'Leather squares', 6 );
  11615.         inv.AddAnItem( 'Leather', 3 );
  11616.         inv.AddAnItem( 'Hardened leather', 14 );
  11617.         inv.AddAnItem( 'Chitin scale', 8 );
  11618.         inv.AddAnItem( 'Draconide leather', 5 );
  11619.         inv.AddAnItem( 'Infused draconide leather', 0 );
  11620.         inv.AddAnItem( 'Steel ingot', 5 );
  11621.         inv.AddAnItem( 'Dark iron ore', 2 );
  11622.         inv.AddAnItem( 'Dark iron ingot', 3 );
  11623.         inv.AddAnItem( 'Dark iron plate', 1 );
  11624.         inv.AddAnItem( 'Dark steel ingot', 10 );
  11625.         inv.AddAnItem( 'Dark steel plate', 6 );
  11626.         inv.AddAnItem( 'Silver ore', 2 );
  11627.         inv.AddAnItem( 'Silver ingot', 6 );
  11628.         inv.AddAnItem( 'Meteorite ore', 3 );
  11629.         inv.AddAnItem( 'Meteorite ingot', 3 );
  11630.         inv.AddAnItem( 'Meteorite plate', 2 );
  11631.         inv.AddAnItem( 'Meteorite silver ingot', 6 );
  11632.         inv.AddAnItem( 'Meteorite silver plate', 5 );
  11633.         inv.AddAnItem( 'Orichalcum ingot', 0 );
  11634.         inv.AddAnItem( 'Orichalcum plate', 1 );
  11635.         inv.AddAnItem( 'Dwimeryte ingot', 6 );
  11636.         inv.AddAnItem( 'Dwimeryte plate', 5 );
  11637.         inv.AddAnItem( 'Dwimeryte enriched ingot', 0 );
  11638.         inv.AddAnItem( 'Dwimeryte enriched plate', 0 );
  11639.         inv.AddAnItem( 'Emerald dust', 0 );
  11640.         inv.AddAnItem( 'Ruby dust', 4 );
  11641.         inv.AddAnItem( 'Ruby', 2 );
  11642.         inv.AddAnItem( 'Ruby flawless', 1 );
  11643.         inv.AddAnItem( 'Sapphire dust', 0 );
  11644.         inv.AddAnItem( 'Sapphire', 0 );
  11645.         inv.AddAnItem( 'Monstrous brain', 8 );
  11646.         inv.AddAnItem( 'Monstrous blood', 14 );
  11647.         inv.AddAnItem( 'Monstrous bone', 9 );
  11648.         inv.AddAnItem( 'Monstrous claw', 14 );
  11649.         inv.AddAnItem( 'Monstrous dust', 9 );
  11650.         inv.AddAnItem( 'Monstrous ear', 5 );
  11651.         inv.AddAnItem( 'Monstrous egg', 1 );
  11652.         inv.AddAnItem( 'Monstrous eye', 10 );
  11653.         inv.AddAnItem( 'Monstrous essence', 7 );
  11654.         inv.AddAnItem( 'Monstrous feather', 8 );
  11655.         inv.AddAnItem( 'Monstrous hair', 12 );
  11656.         inv.AddAnItem( 'Monstrous heart', 7 );
  11657.         inv.AddAnItem( 'Monstrous hide', 4 );
  11658.         inv.AddAnItem( 'Monstrous liver', 5 );
  11659.         inv.AddAnItem( 'Monstrous plate', 1 );
  11660.         inv.AddAnItem( 'Monstrous saliva', 6 );
  11661.         inv.AddAnItem( 'Monstrous stomach', 3 );
  11662.         inv.AddAnItem( 'Monstrous tongue', 5 );
  11663.         inv.AddAnItem( 'Monstrous tooth', 9 );
  11664.         inv.AddAnItem( 'Venom extract', 0 );
  11665.         inv.AddAnItem( 'Siren vocal cords', 1 );
  11666.        
  11667.        
  11668.         SelectQuickslotItem( EES_RangedWeapon );
  11669.        
  11670.        
  11671.         FactsAdd( 'kill_base_tutorials' );
  11672.        
  11673.        
  11674.         theGame.GetTutorialSystem().RemoveAllQueuedTutorials();
  11675.        
  11676.        
  11677.         FactsAdd( 'standalone_ep2' );
  11678.         FactsRemove( "StandAloneEP2" );
  11679.        
  11680.         theGame.GetJournalManager().ForceUntrackingQuestForEP1Savegame();
  11681.     }
  11682. }
  11683.  
  11684. exec function fuqfep1()
  11685. {
  11686.     theGame.GetJournalManager().ForceUntrackingQuestForEP1Savegame();
  11687. }
  11688.  
  11689.  
  11690.  
  11691.  
  11692.  
  11693. function GetWitcherPlayer() : W3PlayerWitcher
  11694. {
  11695.     return (W3PlayerWitcher)thePlayer;
  11696. }
  11697.  
Add Comment
Please, Sign In to add comment