Advertisement
Guest User

Error [mod0000_mergedfiles]game\player\r4player.ws(14772): U

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