Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 214.96 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.    
  15.    
  16.     private saved var alchemyRecipes                    : array<name>;                 
  17.    
  18.    
  19.     private             var levelupAbilities    : array< name >;
  20.     private             var fastAttackCounter, heavyAttackCounter   : int;     
  21.     private             var isInFrenzy : bool;
  22.     private             var hasRecentlyCountered : bool;
  23.     private saved       var cannotUseUndyingSkill : bool;                      
  24.    
  25.    
  26.     public              var canSwitchFocusModeTarget    : bool;
  27.     protected           var switchFocusModeTargetAllowed : bool;
  28.         default canSwitchFocusModeTarget = true;
  29.         default switchFocusModeTargetAllowed = true;
  30.    
  31.    
  32.     private editable    var signs                       : array< SWitcherSign >;
  33.     private saved       var equippedSign                : ESignType;
  34.     private             var currentlyCastSign           : ESignType; default currentlyCastSign = ST_None;
  35.     private             var signOwner                   : W3SignOwnerPlayer;
  36.     private             var usedQuenInCombat            : bool;
  37.     public              var yrdenEntities               : array<W3YrdenEntity>;
  38.    
  39.     default             equippedSign    = ST_Aard;
  40.    
  41.    
  42.    
  43.     private             var bDispalyHeavyAttackIndicator        : bool;
  44.     private             var bDisplayHeavyAttackFirstLevelTimer  : bool;
  45.     public              var specialAttackHeavyAllowed           : bool;
  46.  
  47.     default bIsCombatActionAllowed = true
  48.     default bDispalyHeavyAttackIndicator = false;
  49.     default bDisplayHeavyAttackFirstLevelTimer = true;
  50.    
  51.    
  52.    
  53.         default explorationInputContext = 'Exploration';
  54.         default combatInputContext = 'Combat';
  55.         default combatFistsInputContext = 'Combat';
  56.        
  57.    
  58.     private saved var companionNPCTag       : name;
  59.     private saved var companionNPCTag2      : name;
  60.    
  61.     private saved var companionNPCIconPath  : string;
  62.     private saved var companionNPCIconPath2 : string;  
  63.        
  64.    
  65.     private       saved var itemSlots                   : array<SItemUniqueId>;
  66.     private             var remainingBombThrowDelaySlot1    : float;
  67.     private             var remainingBombThrowDelaySlot2    : float;
  68.     private             var previouslyUsedBolt : SItemUniqueId;            
  69.    
  70.     default isThrowingItem = false;
  71.     default remainingBombThrowDelaySlot1 = 0.f;
  72.     default remainingBombThrowDelaySlot2 = 0.f;
  73.    
  74.    
  75.    
  76.    
  77.    
  78.     private saved var tempLearnedSignSkills : array<SSimpleSkill>;     
  79.     public  saved var autoLevel             : bool;                    
  80.    
  81.    
  82.    
  83.    
  84.     protected var skillBonusPotionEffect            : CBaseGameplayEffect;         
  85.    
  86.    
  87.     public saved        var levelManager                : W3LevelManager;
  88.  
  89.    
  90.     saved var reputationManager : W3Reputation;
  91.    
  92.    
  93.     private editable    var medallionEntity         : CEntityTemplate;
  94.     private             var medallionController     : W3MedallionController;
  95.    
  96.    
  97.     public              var bShowRadialMenu : bool;
  98.  
  99.     private             var _HoldBeforeOpenRadialMenuTime : float;
  100.    
  101.     default _HoldBeforeOpenRadialMenuTime = 0.5f;
  102.    
  103.     public var MappinToHighlight : array<SHighlightMappin>;
  104.    
  105.    
  106.     protected saved var horseManagerHandle          : EntityHandle;    
  107.     private var isInitialized : bool;
  108.    
  109.         default isInitialized = false;
  110.        
  111.    
  112.     private var invUpdateTransaction : bool;
  113.         default invUpdateTransaction = false;
  114.    
  115.    
  116.    
  117.    
  118.    
  119.    
  120.    
  121.    
  122.    
  123.    
  124.    
  125.    
  126.     event OnSpawned( spawnData : SEntitySpawnData )
  127.     {
  128.         var i               : int;
  129.         var items           : array<SItemUniqueId>;
  130.         var items2          : array<SItemUniqueId>;
  131.         var horseTemplate   : CEntityTemplate;
  132.         var horseManager    : W3HorseManager;
  133.        
  134.         AddAnimEventCallback( 'ActionBlend',            'OnAnimEvent_ActionBlend' );
  135.         AddAnimEventCallback('cast_begin',              'OnAnimEvent_Sign');
  136.         AddAnimEventCallback('cast_throw',              'OnAnimEvent_Sign');
  137.         AddAnimEventCallback('cast_end',                'OnAnimEvent_Sign');
  138.         AddAnimEventCallback('cast_friendly_begin',     'OnAnimEvent_Sign');
  139.         AddAnimEventCallback('cast_friendly_throw',     'OnAnimEvent_Sign');
  140.         AddAnimEventCallback('axii_ready',              'OnAnimEvent_Sign');
  141.         AddAnimEventCallback('axii_alternate_ready',    'OnAnimEvent_Sign');
  142.         AddAnimEventCallback('yrden_draw_ready',        'OnAnimEvent_Sign');
  143.        
  144.         AddAnimEventCallback( 'ProjectileThrow',    'OnAnimEvent_Throwable' );
  145.         AddAnimEventCallback( 'OnWeaponReload',     'OnAnimEvent_Throwable' );
  146.         AddAnimEventCallback( 'ProjectileAttach',   'OnAnimEvent_Throwable' );         
  147.        
  148.         theTelemetry.LogWithName( TE_HERO_SPAWNED );
  149.        
  150.         runewordInfusionType = ST_None;
  151.                
  152.        
  153.         inv = GetInventory();          
  154.  
  155.        
  156.         signOwner = new W3SignOwnerPlayer in this;
  157.         signOwner.Init( this );
  158.        
  159.         itemSlots.Resize( EnumGetMax('EEquipmentSlots')+1 );
  160.  
  161.         if(!spawnData.restored)
  162.         {
  163.             levelManager = new W3LevelManager in this;         
  164.             levelManager.Initialize();
  165.            
  166.            
  167.             inv.GetAllItems(items);
  168.             for(i=0; i<items.Size(); i+=1)
  169.             {
  170.                 if(inv.IsItemMounted(items[i]) && ( !inv.IsItemBody(items[i]) || inv.GetItemCategory(items[i]) == 'hair' ) )
  171.                     EquipItem(items[i]);
  172.             }
  173.            
  174.            
  175.            
  176.            
  177.            
  178.             AddAlchemyRecipe('Recipe for Swallow 1',true,true);
  179.             AddAlchemyRecipe('Recipe for Cat 1',true,true);
  180.             AddAlchemyRecipe('Recipe for White Honey 1',true,true);
  181.            
  182.             AddAlchemyRecipe('Recipe for Samum 1',true,true);
  183.             AddAlchemyRecipe('Recipe for Grapeshot 1',true,true);
  184.            
  185.             AddAlchemyRecipe('Recipe for Specter Oil 1',true,true);
  186.             AddAlchemyRecipe('Recipe for Necrophage Oil 1',true,true);
  187.             AddAlchemyRecipe('Recipe for Alcohest 1',true,true);
  188.            
  189.            
  190.             AddStartingSchematics();           
  191.         }
  192.         else
  193.         {
  194.             AddTimer('DelayedOnItemMount', 0.1, true);
  195.            
  196.            
  197.             CheckHairItem();
  198.         }
  199.        
  200.         super.OnSpawned( spawnData );
  201.        
  202.        
  203.         AddAlchemyRecipe('Recipe for Mutagen red',true,true);
  204.         AddAlchemyRecipe('Recipe for Mutagen green',true,true);
  205.         AddAlchemyRecipe('Recipe for Mutagen blue',true,true);
  206.         AddAlchemyRecipe('Recipe for Greater mutagen red',true,true);
  207.         AddAlchemyRecipe('Recipe for Greater mutagen green',true,true);
  208.         AddAlchemyRecipe('Recipe for Greater mutagen blue',true,true);
  209.        
  210.         AddCraftingSchematic('Starting Armor Upgrade schematic 1',true,true);
  211.                
  212.         levelupAbilities.PushBack('Lvl1');
  213.         levelupAbilities.PushBack('Lvl1');
  214.         levelupAbilities.PushBack('Lvl2');
  215.         levelupAbilities.PushBack('Lvl3');
  216.         levelupAbilities.PushBack('Lvl4');
  217.         levelupAbilities.PushBack('Lvl5');
  218.         levelupAbilities.PushBack('Lvl6');
  219.         levelupAbilities.PushBack('Lvl7');
  220.         levelupAbilities.PushBack('Lvl8');
  221.         levelupAbilities.PushBack('Lvl9');
  222.         levelupAbilities.PushBack('Lvl10');
  223.         levelupAbilities.PushBack('Lvl11');
  224.         levelupAbilities.PushBack('Lvl12');
  225.         levelupAbilities.PushBack('Lvl13');
  226.         levelupAbilities.PushBack('Lvl14');
  227.         levelupAbilities.PushBack('Lvl15');
  228.         levelupAbilities.PushBack('Lvl16');
  229.         levelupAbilities.PushBack('Lvl17');
  230.         levelupAbilities.PushBack('Lvl18');
  231.         levelupAbilities.PushBack('Lvl19');
  232.         levelupAbilities.PushBack('Lvl20');
  233.         levelupAbilities.PushBack('Lvl21');
  234.         levelupAbilities.PushBack('Lvl22');
  235.         levelupAbilities.PushBack('Lvl23');
  236.         levelupAbilities.PushBack('Lvl24');
  237.         levelupAbilities.PushBack('Lvl25');
  238.         levelupAbilities.PushBack('Lvl26');
  239.         levelupAbilities.PushBack('Lvl27');
  240.         levelupAbilities.PushBack('Lvl28');
  241.         levelupAbilities.PushBack('Lvl29');
  242.         levelupAbilities.PushBack('Lvl30');
  243.         levelupAbilities.PushBack('Lvl31');
  244.         levelupAbilities.PushBack('Lvl32');
  245.         levelupAbilities.PushBack('Lvl33');
  246.         levelupAbilities.PushBack('Lvl34');
  247.         levelupAbilities.PushBack('Lvl35');
  248.         levelupAbilities.PushBack('Lvl36');
  249.         levelupAbilities.PushBack('Lvl37');
  250.         levelupAbilities.PushBack('Lvl38');
  251.         levelupAbilities.PushBack('Lvl39');
  252.         levelupAbilities.PushBack('Lvl40');
  253.         levelupAbilities.PushBack('Lvl41');
  254.         levelupAbilities.PushBack('Lvl42');
  255.         levelupAbilities.PushBack('Lvl43');
  256.         levelupAbilities.PushBack('Lvl44');
  257.         levelupAbilities.PushBack('Lvl45');
  258.         levelupAbilities.PushBack('Lvl46');
  259.         levelupAbilities.PushBack('Lvl47');
  260.         levelupAbilities.PushBack('Lvl48');
  261.         levelupAbilities.PushBack('Lvl49');
  262.         levelupAbilities.PushBack('Lvl50');
  263.         levelupAbilities.PushBack('Lvl51');
  264.         levelupAbilities.PushBack('Lvl52');
  265.         levelupAbilities.PushBack('Lvl53');
  266.         levelupAbilities.PushBack('Lvl54');
  267.         levelupAbilities.PushBack('Lvl55');
  268.         levelupAbilities.PushBack('Lvl56');
  269.         levelupAbilities.PushBack('Lvl57');
  270.         levelupAbilities.PushBack('Lvl58');
  271.         levelupAbilities.PushBack('Lvl59');
  272.         levelupAbilities.PushBack('Lvl60');
  273.         levelupAbilities.PushBack('Lvl61');
  274.         levelupAbilities.PushBack('Lvl62');
  275.         levelupAbilities.PushBack('Lvl63');
  276.         levelupAbilities.PushBack('Lvl64');
  277.         levelupAbilities.PushBack('Lvl65');
  278.         levelupAbilities.PushBack('Lvl66');
  279.         levelupAbilities.PushBack('Lvl67');
  280.         levelupAbilities.PushBack('Lvl68');
  281.         levelupAbilities.PushBack('Lvl69');
  282.         levelupAbilities.PushBack('Lvl70');
  283.         levelupAbilities.PushBack('Lvl71');
  284.         levelupAbilities.PushBack('Lvl72');
  285.         levelupAbilities.PushBack('Lvl73');
  286.         levelupAbilities.PushBack('Lvl74');
  287.         levelupAbilities.PushBack('Lvl75');
  288.         levelupAbilities.PushBack('Lvl76');
  289.         levelupAbilities.PushBack('Lvl77');
  290.         levelupAbilities.PushBack('Lvl78');
  291.         levelupAbilities.PushBack('Lvl79');
  292.         levelupAbilities.PushBack('Lvl80');
  293.         levelupAbilities.PushBack('Lvl81');
  294.         levelupAbilities.PushBack('Lvl82');
  295.         levelupAbilities.PushBack('Lvl83');
  296.         levelupAbilities.PushBack('Lvl84');
  297.         levelupAbilities.PushBack('Lvl85');
  298.         levelupAbilities.PushBack('Lvl86');
  299.         levelupAbilities.PushBack('Lvl87');
  300.         levelupAbilities.PushBack('Lvl88');
  301.         levelupAbilities.PushBack('Lvl89');
  302.         levelupAbilities.PushBack('Lvl90');
  303.         levelupAbilities.PushBack('Lvl91');
  304.         levelupAbilities.PushBack('Lvl92');
  305.         levelupAbilities.PushBack('Lvl93');
  306.         levelupAbilities.PushBack('Lvl94');
  307.         levelupAbilities.PushBack('Lvl95');
  308.         levelupAbilities.PushBack('Lvl96');
  309.         levelupAbilities.PushBack('Lvl97');
  310.         levelupAbilities.PushBack('Lvl98');
  311.         levelupAbilities.PushBack('Lvl99');
  312.         levelupAbilities.PushBack('Lvl100');
  313.        
  314.        
  315.         if( inputHandler )
  316.         {
  317.             inputHandler.BlockAllActions( 'being_ciri', false );
  318.         }
  319.         SetBehaviorVariable( 'test_ciri_replacer', 0.0f);
  320.        
  321.         if(!spawnData.restored)
  322.         {
  323.            
  324.             abilityManager.GainStat(BCS_Toxicity, 0);      
  325.         }      
  326.        
  327.         levelManager.PostInit(this, spawnData.restored);
  328.        
  329.         SetBIsCombatActionAllowed( true );     
  330.         SetBIsInputAllowed( true, 'OnSpawned' );               
  331.        
  332.        
  333.         if ( !reputationManager )
  334.         {
  335.             reputationManager = new W3Reputation in this;
  336.             reputationManager.Initialize();
  337.         }
  338.        
  339.         theSound.SoundParameter( "focus_aim", 1.0f, 1.0f );
  340.         theSound.SoundParameter( "focus_distance", 0.0f, 1.0f );
  341.        
  342.        
  343.        
  344.        
  345.            
  346.        
  347.         currentlyCastSign = ST_None;
  348.        
  349.        
  350.         if(!spawnData.restored)
  351.         {
  352.             horseTemplate = (CEntityTemplate)LoadResource("horse_manager");
  353.             horseManager = (W3HorseManager)theGame.CreateEntity(horseTemplate, GetWorldPosition(),,,,,PM_Persist);
  354.             horseManager.CreateAttachment(this);
  355.             horseManager.OnCreated();
  356.             EntityHandleSet( horseManagerHandle, horseManager );
  357.         }
  358.         else
  359.         {
  360.             AddTimer('DelayedHorseUpdate', 0.01, true);
  361.         }
  362.        
  363.        
  364.         RemoveAbility('Ciri_CombatRegen');
  365.         RemoveAbility('Ciri_Rage');
  366.         RemoveAbility('CiriBlink');
  367.         RemoveAbility('CiriCharge');
  368.         RemoveAbility('Ciri_Q205');
  369.         RemoveAbility('Ciri_Q305');
  370.         RemoveAbility('Ciri_Q403');
  371.         RemoveAbility('Ciri_Q111');
  372.         RemoveAbility('Ciri_Q501');
  373.         RemoveAbility('SkillCiri');
  374.        
  375.         if(spawnData.restored)
  376.         {
  377.             RestoreQuen(savedQuenHealth, savedQuenDuration);           
  378.         }
  379.         else
  380.         {
  381.             savedQuenHealth = 0.f;
  382.             savedQuenDuration = 0.f;
  383.         }
  384.        
  385.         if(spawnData.restored)
  386.             ApplyPatchFixes();
  387.        
  388.         if(!newGamePlusInitialized && FactsQuerySum("NewGamePlus") > 0)
  389.         {
  390.             NewGamePlusInitialize();
  391.         }
  392.        
  393.         if ( FactsQuerySum("NewGamePlus") > 0 )
  394.         {
  395.             NewGamePlusAdjustDLC1TemerianSet(inv);
  396.             NewGamePlusAdjustDLC5NilfgardianSet(inv);
  397.             NewGamePlusAdjustDLC10WolfSet(inv);
  398.             NewGamePlusAdjustDLC14SkelligeSet(inv);
  399.             if(horseManager)
  400.             {
  401.                 NewGamePlusAdjustDLC1TemerianSet(horseManager.GetInventoryComponent());
  402.                 NewGamePlusAdjustDLC5NilfgardianSet(horseManager.GetInventoryComponent());
  403.                 NewGamePlusAdjustDLC10WolfSet(horseManager.GetInventoryComponent());
  404.                 NewGamePlusAdjustDLC14SkelligeSet(horseManager.GetInventoryComponent());
  405.             }
  406.         }
  407.        
  408.        
  409.         ResumeStaminaRegen('WhirlSkill');
  410.        
  411.         if(HasAbility('Runeword 4 _Stats', true))
  412.             StartVitalityRegen();
  413.        
  414.        
  415.         if(HasAbility('sword_s19'))
  416.         {
  417.             RemoveTemporarySkills();
  418.         }
  419.        
  420.         HACK_UnequipWolfLiver();
  421.        
  422.         isInitialized = true;
  423.     }
  424.  
  425.    
  426.    
  427.    
  428.    
  429.     private function HACK_UnequipWolfLiver()
  430.     {
  431.         var itemName1, itemName2, itemName3, itemName4 : name;
  432.         var item1, item2, item3, item4 : SItemUniqueId;
  433.        
  434.         GetItemEquippedOnSlot( EES_Potion1, item1 );
  435.         GetItemEquippedOnSlot( EES_Potion2, item2 );
  436.         GetItemEquippedOnSlot( EES_Potion3, item3 );
  437.         GetItemEquippedOnSlot( EES_Potion4, item4 );
  438.  
  439.         if ( inv.IsIdValid( item1 ) )
  440.             itemName1 = inv.GetItemName( item1 );
  441.         if ( inv.IsIdValid( item2 ) )
  442.             itemName2 = inv.GetItemName( item2 );
  443.         if ( inv.IsIdValid( item3 ) )
  444.             itemName3 = inv.GetItemName( item3 );
  445.         if ( inv.IsIdValid( item4 ) )
  446.             itemName4 = inv.GetItemName( item4 );
  447.  
  448.         if ( itemName1 == 'Wolf liver' || itemName3 == 'Wolf liver' )
  449.         {
  450.             if ( inv.IsIdValid( item1 ) )
  451.                 UnequipItem( item1 );
  452.             if ( inv.IsIdValid( item3 ) )
  453.                 UnequipItem( item3 );
  454.         }
  455.         else if ( itemName2 == 'Wolf liver' || itemName4 == 'Wolf liver' )
  456.         {
  457.             if ( inv.IsIdValid( item2 ) )
  458.                 UnequipItem( item2 );
  459.             if ( inv.IsIdValid( item4 ) )
  460.                 UnequipItem( item4 );
  461.         }
  462.     }
  463.    
  464.    
  465.    
  466.    
  467.  
  468.     timer function DelayedHorseUpdate( dt : float, id : int )
  469.     {
  470.         var man : W3HorseManager;
  471.        
  472.         man = GetHorseManager();
  473.         if(man)
  474.         {
  475.             if ( man.ApplyHorseUpdateOnSpawn() )
  476.             {
  477.                 RemoveTimer( 'DelayedHorseUpdate' );
  478.             }
  479.         }
  480.     }  
  481.    
  482.     event OnAbilityAdded( abilityName : name)
  483.     {
  484.         super.OnAbilityAdded(abilityName);
  485.        
  486.         if(HasAbility('Runeword 4 _Stats', true))
  487.             StartVitalityRegen();
  488.            
  489.         if ( GetStat(BCS_Focus, true) >= GetStatMax(BCS_Focus) && abilityName == 'Runeword 8 _Stats' && !HasBuff(EET_Runeword8) )
  490.         {
  491.             AddEffectDefault(EET_Runeword8, this, "equipped item");
  492.         }
  493.  
  494.     }
  495.    
  496.     private final function AddStartingSchematics()
  497.     {
  498.         AddCraftingSchematic('Starting Armor Upgrade schematic 1',  true,true);
  499.         AddCraftingSchematic('Thread schematic',                    true, true);
  500.         AddCraftingSchematic('String schematic',                    true, true);
  501.         AddCraftingSchematic('Linen schematic',                     true, true);
  502.         AddCraftingSchematic('Silk schematic',                      true, true);
  503.         AddCraftingSchematic('Resin schematic',                     true, true);
  504.         AddCraftingSchematic('Blasting powder schematic',           true, true);
  505.         AddCraftingSchematic('Haft schematic',                      true, true);
  506.         AddCraftingSchematic('Hardened timber schematic',           true, true);
  507.         AddCraftingSchematic('Leather squares schematic',           true, true);
  508.         AddCraftingSchematic('Leather schematic',                   true, true);
  509.         AddCraftingSchematic('Hardened leather schematic',          true, true);
  510.         AddCraftingSchematic('Draconide leather schematic',         true, true);
  511.         AddCraftingSchematic('Iron ingot schematic',                true, true);
  512.         AddCraftingSchematic('Steel ingot schematic',               true, true);
  513.         AddCraftingSchematic('Steel ingot schematic 1',             true, true);
  514.         AddCraftingSchematic('Steel plate schematic',               true, true);
  515.         AddCraftingSchematic('Dark iron ingot schematic',           true, true);
  516.         AddCraftingSchematic('Dark steel ingot schematic',          true, true);
  517.         AddCraftingSchematic('Dark steel ingot schematic 1',        true, true);
  518.         AddCraftingSchematic('Dark steel plate schematic',          true, true);
  519.         AddCraftingSchematic('Silver ore schematic',                true, true);
  520.         AddCraftingSchematic('Silver ingot schematic',              true, true);
  521.         AddCraftingSchematic('Silver ingot schematic 1',            true, true);
  522.         AddCraftingSchematic('Silver plate schematic',              true, true);
  523.         AddCraftingSchematic('Meteorite ingot schematic',           true, true);
  524.         AddCraftingSchematic('Meteorite silver ingot schematic',    true, true);
  525.         AddCraftingSchematic('Meteorite silver plate schematic',    true, true);
  526.         AddCraftingSchematic('Glowing ingot schematic',             true, true);
  527.         AddCraftingSchematic('Dwimeryte ore schematic',             true, true);
  528.         AddCraftingSchematic('Dwimeryte ingot schematic',           true, true);
  529.         AddCraftingSchematic('Dwimeryte ingot schematic 1',         true, true);
  530.         AddCraftingSchematic('Dwimeryte plate schematic',           true, true);
  531.     }
  532.    
  533.     private final function ApplyPatchFixes()
  534.     {
  535.         var cnt, transmutationCount, mutagenCount, i : int;
  536.         var transmutationAbility : name;
  537.         var pam : W3PlayerAbilityManager;
  538.         var slotId : int;
  539.         var offset : float;
  540.         var buffs : array<CBaseGameplayEffect>;
  541.         var mutagen : W3Mutagen_Effect;
  542.         var skill : SSimpleSkill;
  543.         var spentSkillPoints, swordSkillPointsSpent, alchemySkillPointsSpent, perkSkillPointsSpent, pointsToAdd : int;
  544.        
  545.         if(FactsQuerySum("ClearingPotionPassiveBonusFix") < 1)
  546.         {
  547.             pam = (W3PlayerAbilityManager)abilityManager;
  548.  
  549.             cnt = GetAbilityCount('sword_adrenalinegain') - pam.GetPathPointsSpent(ESP_Sword);
  550.             if(cnt > 0)
  551.                 RemoveAbilityMultiple('sword_adrenalinegain', cnt);
  552.                
  553.             cnt = GetAbilityCount('magic_staminaregen') - pam.GetPathPointsSpent(ESP_Signs);
  554.             if(cnt > 0)
  555.                 RemoveAbilityMultiple('magic_staminaregen', cnt);
  556.                
  557.             cnt = GetAbilityCount('alchemy_potionduration') - pam.GetPathPointsSpent(ESP_Alchemy);
  558.             if(cnt > 0)
  559.                 RemoveAbilityMultiple('alchemy_potionduration', cnt);
  560.        
  561.             FactsAdd("ClearingPotionPassiveBonusFix");
  562.         }
  563.                
  564.        
  565.         if(FactsQuerySum("DimeritiumSynergyFix") < 1)
  566.         {
  567.             slotId = GetSkillSlotID(S_Alchemy_s19);
  568.             if(slotId != -1)
  569.                 UnequipSkill(S_Alchemy_s19);
  570.                
  571.             RemoveAbilityAll('greater_mutagen_color_green_synergy_bonus');
  572.             RemoveAbilityAll('mutagen_color_green_synergy_bonus');
  573.             RemoveAbilityAll('mutagen_color_lesser_green_synergy_bonus');
  574.            
  575.             RemoveAbilityAll('greater_mutagen_color_blue_synergy_bonus');
  576.             RemoveAbilityAll('mutagen_color_blue_synergy_bonus');
  577.             RemoveAbilityAll('mutagen_color_lesser_blue_synergy_bonus');
  578.            
  579.             RemoveAbilityAll('greater_mutagen_color_red_synergy_bonus');
  580.             RemoveAbilityAll('mutagen_color_red_synergy_bonus');
  581.             RemoveAbilityAll('mutagen_color_lesser_red_synergy_bonus');
  582.            
  583.             if(slotId != -1)
  584.                 EquipSkill(S_Alchemy_s19, slotId);
  585.        
  586.             FactsAdd("DimeritiumSynergyFix");
  587.         }
  588.        
  589.        
  590.         if(FactsQuerySum("DontShowRecipePinTut") < 1)
  591.         {
  592.             TutorialScript('alchemyRecipePin', '');
  593.             TutorialScript('craftingRecipePin', '');
  594.         }
  595.        
  596.        
  597.         if(FactsQuerySum("LevelReqPotGiven") < 1)
  598.         {
  599.             FactsAdd("LevelReqPotGiven");
  600.             inv.AddAnItem('Wolf Hour', 1, false, false, true);
  601.         }
  602.        
  603.        
  604.         if(!HasBuff(EET_AutoStaminaRegen))
  605.         {
  606.             AddEffectDefault(EET_AutoStaminaRegen, this, 'autobuff', false);
  607.         }
  608.        
  609.        
  610.        
  611.         buffs = GetBuffs();
  612.         offset = 0;
  613.         mutagenCount = 0;
  614.         for(i=0; i<buffs.Size(); i+=1)
  615.         {
  616.             mutagen = (W3Mutagen_Effect)buffs[i];
  617.             if(mutagen)
  618.             {
  619.                 offset += mutagen.GetToxicityOffset();
  620.                 mutagenCount += 1;
  621.             }
  622.         }
  623.        
  624.        
  625.         if(offset != (GetStat(BCS_Toxicity) - GetStat(BCS_Toxicity, true)))
  626.             SetToxicityOffset(offset);
  627.            
  628.        
  629.         mutagenCount *= GetSkillLevel(S_Alchemy_s13);
  630.         transmutationAbility = GetSkillAbilityName(S_Alchemy_s13);
  631.         transmutationCount = GetAbilityCount(transmutationAbility);
  632.         if(mutagenCount < transmutationCount)
  633.         {
  634.             RemoveAbilityMultiple(transmutationAbility, transmutationCount - mutagenCount);
  635.         }
  636.         else if(mutagenCount > transmutationCount)
  637.         {
  638.             AddAbilityMultiple(transmutationAbility, mutagenCount - transmutationCount);
  639.         }
  640.        
  641.        
  642.         if(theGame.GetDLCManager().IsEP1Available())
  643.         {
  644.             theGame.GetJournalManager().ActivateEntryByScriptTag('TutorialJournalEnchanting', JS_Active);
  645.         }
  646.        
  647.        
  648.         levelManager.FixMaxLevel();
  649.  
  650.        
  651.         if(HasAbility('sword_s19') && FactsQuerySum("Patch_Sword_s19") < 1)
  652.         {
  653.             pam = (W3PlayerAbilityManager)abilityManager;
  654.  
  655.            
  656.             skill.level = 0;
  657.             for(i = S_Magic_s01; i <= S_Magic_s20; i+=1)
  658.             {
  659.                 skill.skillType = i;               
  660.                 pam.RemoveTemporarySkill(skill);
  661.             }
  662.            
  663.            
  664.             spentSkillPoints = levelManager.GetPointsUsed(ESkillPoint);
  665.             swordSkillPointsSpent = pam.GetPathPointsSpent(ESP_Sword);
  666.             alchemySkillPointsSpent = pam.GetPathPointsSpent(ESP_Alchemy);
  667.             perkSkillPointsSpent = pam.GetPathPointsSpent(ESP_Perks);
  668.            
  669.             pointsToAdd = spentSkillPoints - swordSkillPointsSpent - alchemySkillPointsSpent - perkSkillPointsSpent;
  670.             if(pointsToAdd > 0)
  671.                 levelManager.UnspendPoints(ESkillPoint, pointsToAdd);
  672.            
  673.            
  674.             RemoveAbilityAll('sword_s19');
  675.            
  676.            
  677.             FactsAdd("Patch_Sword_s19");
  678.         }
  679.        
  680.        
  681.         if(FactsQuerySum("Patch_Armor_Type_Glyphwords") < 1)
  682.         {
  683.             pam = (W3PlayerAbilityManager)abilityManager;
  684.            
  685.             pam.SetPerkArmorBonus(S_Perk_05);
  686.             pam.SetPerkArmorBonus(S_Perk_06);
  687.             pam.SetPerkArmorBonus(S_Perk_07);              
  688.            
  689.             FactsAdd("Patch_Armor_Type_Glyphwords");
  690.         }
  691.     }
  692.    
  693.     public final function RestoreQuen(quenHealth : float, quenDuration : float) : bool
  694.         muts = SSS_Patch_MutagenStacking(muts); //zur13 modSSS mutTabs
  695.         } SSS_FixEquippedMutagens(); //zur13 modSSS mutTabs
  696.     {
  697.         var restoredQuen    : W3QuenEntity;
  698.        
  699.         if(quenHealth > 0.f && quenDuration >= 3.f)
  700.         {
  701.             restoredQuen = (W3QuenEntity)theGame.CreateEntity( signs[ST_Quen].template, GetWorldPosition(), GetWorldRotation() );
  702.             restoredQuen.Init( signOwner, signs[ST_Quen].entity, true );
  703.             restoredQuen.OnStarted();
  704.             restoredQuen.OnThrowing();
  705.             restoredQuen.OnEnded();
  706.             restoredQuen.SetDataFromRestore(quenHealth, quenDuration);
  707.            
  708.             return true;
  709.         }
  710.        
  711.         return false;
  712.     }
  713.    
  714.     public function IsInitialized() : bool
  715.     {
  716.         return isInitialized;
  717.     }
  718.    
  719.     private final function NewGamePlusInitialize()
  720.     {
  721.         var questItems : array<name>;
  722.         var horseManager : W3HorseManager;
  723.         var horseInventory : CInventoryComponent;
  724.         var i, missingLevels, expDiff : int;
  725.        
  726.        
  727.         horseManager = (W3HorseManager)EntityHandleGet(horseManagerHandle);
  728.         if(horseManager)
  729.             horseInventory = horseManager.GetInventoryComponent();
  730.        
  731.        
  732.         theGame.params.SetNewGamePlusLevel(GetLevel());
  733.        
  734.        
  735.         if (theGame.GetDLCManager().IsDLCAvailable('ep1'))
  736.             missingLevels = theGame.params.NEW_GAME_PLUS_EP1_MIN_LEVEL - GetLevel();
  737.         else
  738.             missingLevels = theGame.params.NEW_GAME_PLUS_MIN_LEVEL - GetLevel();
  739.            
  740.         for(i=0; i<missingLevels; i+=1)
  741.         {
  742.            
  743.             expDiff = levelManager.GetTotalExpForNextLevel() - levelManager.GetPointsTotal(EExperiencePoint);
  744.             expDiff = CeilF( ((float)expDiff) / 2 );
  745.             AddPoints(EExperiencePoint, expDiff, false);
  746.         }
  747.        
  748.        
  749.        
  750.        
  751.        
  752.         inv.RemoveItemByTag('Quest', -1);
  753.         horseInventory.RemoveItemByTag('Quest', -1);
  754.  
  755.        
  756.        
  757.         questItems = theGame.GetDefinitionsManager().GetItemsWithTag('Quest');
  758.         for(i=0; i<questItems.Size(); i+=1)
  759.         {
  760.             inv.RemoveItemByName(questItems[i], -1);
  761.             horseInventory.RemoveItemByName(questItems[i], -1);
  762.         }
  763.        
  764.        
  765.         inv.RemoveItemByName('mq1002_artifact_3', -1);
  766.         horseInventory.RemoveItemByName('mq1002_artifact_3', -1);
  767.        
  768.        
  769.         inv.RemoveItemByTag('NotTransferableToNGP', -1);
  770.         horseInventory.RemoveItemByTag('NotTransferableToNGP', -1);
  771.        
  772.        
  773.         inv.RemoveItemByTag('NoticeBoardNote', -1);
  774.         horseInventory.RemoveItemByTag('NoticeBoardNote', -1);
  775.        
  776.        
  777.         RemoveAllNonAutoBuffs();
  778.        
  779.        
  780.         RemoveAlchemyRecipe('Recipe for Trial Potion Kit');
  781.         RemoveAlchemyRecipe('Recipe for Pops Antidote');
  782.         RemoveAlchemyRecipe('Recipe for Czart Lure');
  783.         RemoveAlchemyRecipe('q603_diarrhea_potion_recipe');
  784.        
  785.        
  786.         inv.RemoveItemByTag('Trophy', -1);
  787.         horseInventory.RemoveItemByTag('Trophy', -1);
  788.        
  789.        
  790.         inv.RemoveItemByCategory('usable', -1);
  791.         horseInventory.RemoveItemByCategory('usable', -1);
  792.        
  793.        
  794.         RemoveAbility('StaminaTutorialProlog');
  795.         RemoveAbility('TutorialStaminaRegenHack');
  796.         RemoveAbility('area_novigrad');
  797.         RemoveAbility('NoRegenEffect');
  798.         RemoveAbility('HeavySwimmingStaminaDrain');
  799.         RemoveAbility('AirBoost');
  800.         RemoveAbility('area_nml');
  801.         RemoveAbility('area_skellige');
  802.        
  803.        
  804.         inv.RemoveItemByTag('GwintCard', -1);
  805.         horseInventory.RemoveItemByTag('GwintCard', -1);
  806.                
  807.        
  808.        
  809.         inv.RemoveItemByTag('ReadableItem', -1);
  810.         horseInventory.RemoveItemByTag('ReadableItem', -1);
  811.        
  812.        
  813.         abilityManager.RestoreStats();
  814.        
  815.        
  816.         ((W3PlayerAbilityManager)abilityManager).RemoveToxicityOffset(10000);
  817.        
  818.        
  819.         GetInventory().SingletonItemsRefillAmmo();
  820.        
  821.        
  822.         craftingSchematics.Clear();
  823.         AddStartingSchematics();
  824.  
  825.        
  826.         inv.AddAnItem('Clearing Potion', 1, true, false, false);
  827.        
  828.        
  829.         inv.RemoveItemByName('q203_broken_eyeofloki', -1);
  830.         horseInventory.RemoveItemByName('q203_broken_eyeofloki', -1);
  831.        
  832.         NewGamePlusReplaceViperSet(inv);
  833.         NewGamePlusReplaceViperSet(horseInventory);
  834.         NewGamePlusReplaceLynxSet(inv);
  835.         NewGamePlusReplaceLynxSet(horseInventory);
  836.         NewGamePlusReplaceGryphonSet(inv);
  837.         NewGamePlusReplaceGryphonSet(horseInventory);
  838.         NewGamePlusReplaceBearSet(inv);
  839.         NewGamePlusReplaceBearSet(horseInventory);
  840.         NewGamePlusReplaceEP1(inv);
  841.         NewGamePlusReplaceEP1(horseInventory);
  842.        
  843.        
  844.         inputHandler.ClearLocksForNGP();
  845.        
  846.        
  847.         buffImmunities.Clear();
  848.         buffRemovedImmunities.Clear();
  849.        
  850.         newGamePlusInitialized = true;
  851.     }
  852.        
  853.     private final function NewGamePlusReplaceItem( item : name, new_item : name, out inv : CInventoryComponent)
  854.     {
  855.         var i, j                    : int;
  856.         var ids, new_ids, enh_ids   : array<SItemUniqueId>;
  857.         var enh                     : array<name>;
  858.         var wasEquipped             : bool;
  859.         var wasEnchanted            : bool;
  860.         var enchantName             : name;
  861.        
  862.         if ( inv.HasItem( item ) )
  863.         {
  864.             ids = inv.GetItemsIds(item);
  865.             for (i = 0; i < ids.Size(); i += 1)
  866.             {
  867.                 inv.GetItemEnhancementItems(ids[i], enh);
  868.                 wasEnchanted = inv.IsItemEnchanted(ids[i]);
  869.                 if ( wasEnchanted )
  870.                     enchantName = inv.GetEnchantment(ids[i]);
  871.                 wasEquipped = IsItemEquipped( ids[i] );
  872.                 inv.RemoveItem(ids[i], 1);
  873.                 new_ids = inv.AddAnItem(new_item, 1, true, true, false);
  874.                 if ( wasEquipped )
  875.                 {
  876.                     EquipItem( new_ids[0] );
  877.                 }
  878.                 if ( wasEnchanted )
  879.                 {
  880.                     inv.EnchantItem(new_ids[0], enchantName, getEnchamtmentStatName(enchantName));
  881.                 }
  882.                 for (j = 0; j < enh.Size(); j += 1)
  883.                 {
  884.                     enh_ids = inv.AddAnItem(enh[j], 1, true, true, false);
  885.                     inv.EnhanceItemScript(new_ids[0], enh_ids[0]);
  886.                 }
  887.             }
  888.         }
  889.     }
  890.    
  891.     private final function NewGamePlusAdjustDLCItem(item : name, mod : name, inv : CInventoryComponent)
  892.     {
  893.         var ids     : array<SItemUniqueId>;
  894.         var i       : int;
  895.        
  896.         if( inv.HasItem(item) )
  897.         {
  898.             ids = inv.GetItemsIds(item);
  899.             for (i = 0; i < ids.Size(); i += 1)
  900.             {
  901.                 if ( inv.GetItemModifierInt(ids[i], 'DoNotAdjustNGPDLC') <= 0 )
  902.                 {
  903.                     inv.AddItemBaseAbility(ids[i], mod);
  904.                     inv.SetItemModifierInt(ids[i], 'DoNotAdjustNGPDLC', 1);
  905.                 }
  906.             }
  907.         }
  908.        
  909.     }
  910.    
  911.     private final function NewGamePlusAdjustDLC1TemerianSet(inv : CInventoryComponent)
  912.     {
  913.         NewGamePlusAdjustDLCItem('NGP DLC1 Temerian Armor', 'NGP DLC Compatibility Chest Armor Mod', inv);
  914.         NewGamePlusAdjustDLCItem('NGP DLC1 Temerian Gloves', 'NGP DLC Compatibility Armor Mod', inv);
  915.         NewGamePlusAdjustDLCItem('NGP DLC1 Temerian Pants', 'NGP DLC Compatibility Armor Mod', inv);
  916.         NewGamePlusAdjustDLCItem('NGP DLC1 Temerian Boots', 'NGP DLC Compatibility Armor Mod', inv);
  917.     }
  918.    
  919.     private final function NewGamePlusAdjustDLC5NilfgardianSet(inv : CInventoryComponent)
  920.     {
  921.         NewGamePlusAdjustDLCItem('NGP DLC5 Nilfgaardian Armor', 'NGP DLC Compatibility Chest Armor Mod', inv);
  922.         NewGamePlusAdjustDLCItem('NGP DLC5 Nilfgaardian Gloves', 'NGP DLC Compatibility Armor Mod', inv);
  923.         NewGamePlusAdjustDLCItem('NGP DLC5 Nilfgaardian Pants', 'NGP DLC Compatibility Armor Mod', inv);
  924.         NewGamePlusAdjustDLCItem('NGP DLC5 Nilfgaardian Boots', 'NGP DLC Compatibility Armor Mod', inv);
  925.     }
  926.    
  927.     private final function NewGamePlusAdjustDLC10WolfSet(inv : CInventoryComponent)
  928.     {
  929.         NewGamePlusAdjustDLCItem('NGP Wolf Armor',   'NGP DLC Compatibility Chest Armor Mod', inv);
  930.         NewGamePlusAdjustDLCItem('NGP Wolf Armor 1', 'NGP DLC Compatibility Chest Armor Mod', inv);
  931.         NewGamePlusAdjustDLCItem('NGP Wolf Armor 2', 'NGP DLC Compatibility Chest Armor Mod', inv);
  932.         NewGamePlusAdjustDLCItem('NGP Wolf Armor 3', 'NGP DLC Compatibility Chest Armor Mod', inv);
  933.        
  934.         NewGamePlusAdjustDLCItem('NGP Wolf Boots 1', 'NGP DLC Compatibility Armor Mod', inv);
  935.         NewGamePlusAdjustDLCItem('NGP Wolf Boots 2', 'NGP DLC Compatibility Armor Mod', inv);
  936.         NewGamePlusAdjustDLCItem('NGP Wolf Boots 3', 'NGP DLC Compatibility Armor Mod', inv);
  937.         NewGamePlusAdjustDLCItem('NGP Wolf Boots 4', 'NGP DLC Compatibility Armor Mod', inv);
  938.        
  939.         NewGamePlusAdjustDLCItem('NGP Wolf Gloves 1', 'NGP DLC Compatibility Armor Mod', inv);
  940.         NewGamePlusAdjustDLCItem('NGP Wolf Gloves 2', 'NGP DLC Compatibility Armor Mod', inv);
  941.         NewGamePlusAdjustDLCItem('NGP Wolf Gloves 3', 'NGP DLC Compatibility Armor Mod', inv);
  942.         NewGamePlusAdjustDLCItem('NGP Wolf Gloves 4', 'NGP DLC Compatibility Armor Mod', inv);
  943.        
  944.         NewGamePlusAdjustDLCItem('NGP Wolf Pants 1', 'NGP DLC Compatibility Armor Mod', inv);
  945.         NewGamePlusAdjustDLCItem('NGP Wolf Pants 2', 'NGP DLC Compatibility Armor Mod', inv);
  946.         NewGamePlusAdjustDLCItem('NGP Wolf Pants 3', 'NGP DLC Compatibility Armor Mod', inv);
  947.         NewGamePlusAdjustDLCItem('NGP Wolf Pants 4', 'NGP DLC Compatibility Armor Mod', inv);
  948.        
  949.         NewGamePlusAdjustDLCItem('NGP Wolf School steel sword',   'NGP Wolf Steel Sword Mod', inv);
  950.         NewGamePlusAdjustDLCItem('NGP Wolf School steel sword 1', 'NGP Wolf Steel Sword Mod', inv);
  951.         NewGamePlusAdjustDLCItem('NGP Wolf School steel sword 2', 'NGP Wolf Steel Sword Mod', inv);
  952.         NewGamePlusAdjustDLCItem('NGP Wolf School steel sword 3', 'NGP Wolf Steel Sword Mod', inv);
  953.        
  954.         NewGamePlusAdjustDLCItem('NGP Wolf School silver sword',   'NGP Wolf Silver Sword Mod', inv);
  955.         NewGamePlusAdjustDLCItem('NGP Wolf School silver sword 1', 'NGP Wolf Silver Sword Mod', inv);
  956.         NewGamePlusAdjustDLCItem('NGP Wolf School silver sword 2', 'NGP Wolf Silver Sword Mod', inv);
  957.         NewGamePlusAdjustDLCItem('NGP Wolf School silver sword 3', 'NGP Wolf Silver Sword Mod', inv);
  958.     }
  959.    
  960.     private final function NewGamePlusAdjustDLC14SkelligeSet(inv : CInventoryComponent)
  961.     {
  962.         NewGamePlusAdjustDLCItem('NGP DLC14 Skellige Armor', 'NGP DLC Compatibility Chest Armor Mod', inv);
  963.         NewGamePlusAdjustDLCItem('NGP DLC14 Skellige Gloves', 'NGP DLC Compatibility Armor Mod', inv);
  964.         NewGamePlusAdjustDLCItem('NGP DLC14 Skellige Pants', 'NGP DLC Compatibility Armor Mod', inv);
  965.         NewGamePlusAdjustDLCItem('NGP DLC14 Skellige Boots', 'NGP DLC Compatibility Armor Mod', inv);
  966.     }
  967.    
  968.     private final function NewGamePlusReplaceViperSet(out inv : CInventoryComponent)
  969.     {
  970.         NewGamePlusReplaceItem('Viper School steel sword', 'NGP Viper School steel sword', inv);
  971.        
  972.         NewGamePlusReplaceItem('Viper School silver sword', 'NGP Viper School silver sword', inv);
  973.     }
  974.    
  975.     private final function NewGamePlusReplaceLynxSet(out inv : CInventoryComponent)
  976.     {
  977.         NewGamePlusReplaceItem('Lynx Armor', 'NGP Lynx Armor', inv);
  978.         NewGamePlusReplaceItem('Lynx Armor 1', 'NGP Lynx Armor 1', inv);
  979.         NewGamePlusReplaceItem('Lynx Armor 2', 'NGP Lynx Armor 2', inv);
  980.         NewGamePlusReplaceItem('Lynx Armor 3', 'NGP Lynx Armor 3', inv);
  981.        
  982.         NewGamePlusReplaceItem('Lynx Gloves 1', 'NGP Lynx Gloves 1', inv);
  983.         NewGamePlusReplaceItem('Lynx Gloves 2', 'NGP Lynx Gloves 2', inv);
  984.         NewGamePlusReplaceItem('Lynx Gloves 3', 'NGP Lynx Gloves 3', inv);
  985.         NewGamePlusReplaceItem('Lynx Gloves 4', 'NGP Lynx Gloves 4', inv);
  986.        
  987.         NewGamePlusReplaceItem('Lynx Pants 1', 'NGP Lynx Pants 1', inv);
  988.         NewGamePlusReplaceItem('Lynx Pants 2', 'NGP Lynx Pants 2', inv);
  989.         NewGamePlusReplaceItem('Lynx Pants 3', 'NGP Lynx Pants 3', inv);
  990.         NewGamePlusReplaceItem('Lynx Pants 4', 'NGP Lynx Pants 4', inv);
  991.        
  992.         NewGamePlusReplaceItem('Lynx Boots 1', 'NGP Lynx Boots 1', inv);
  993.         NewGamePlusReplaceItem('Lynx Boots 2', 'NGP Lynx Boots 2', inv);
  994.         NewGamePlusReplaceItem('Lynx Boots 3', 'NGP Lynx Boots 3', inv);
  995.         NewGamePlusReplaceItem('Lynx Boots 4', 'NGP Lynx Boots 4', inv);
  996.        
  997.         NewGamePlusReplaceItem('Lynx School steel sword', 'NGP Lynx School steel sword', inv);
  998.         NewGamePlusReplaceItem('Lynx School steel sword 1', 'NGP Lynx School steel sword 1', inv);
  999.         NewGamePlusReplaceItem('Lynx School steel sword 2', 'NGP Lynx School steel sword 2', inv);
  1000.         NewGamePlusReplaceItem('Lynx School steel sword 3', 'NGP Lynx School steel sword 3', inv);
  1001.        
  1002.         NewGamePlusReplaceItem('Lynx School silver sword', 'NGP Lynx School silver sword', inv);
  1003.         NewGamePlusReplaceItem('Lynx School silver sword 1', 'NGP Lynx School silver sword 1', inv);
  1004.         NewGamePlusReplaceItem('Lynx School silver sword 2', 'NGP Lynx School silver sword 2', inv);
  1005.         NewGamePlusReplaceItem('Lynx School silver sword 3', 'NGP Lynx School silver sword 3', inv);
  1006.     }
  1007.    
  1008.     private final function NewGamePlusReplaceGryphonSet(out inv : CInventoryComponent)
  1009.     {
  1010.         NewGamePlusReplaceItem('Gryphon Armor', 'NGP Gryphon Armor', inv);
  1011.         NewGamePlusReplaceItem('Gryphon Armor 1', 'NGP Gryphon Armor 1', inv);
  1012.         NewGamePlusReplaceItem('Gryphon Armor 2', 'NGP Gryphon Armor 2', inv);
  1013.         NewGamePlusReplaceItem('Gryphon Armor 3', 'NGP Gryphon Armor 3', inv);
  1014.        
  1015.         NewGamePlusReplaceItem('Gryphon Gloves 1', 'NGP Gryphon Gloves 1', inv);
  1016.         NewGamePlusReplaceItem('Gryphon Gloves 2', 'NGP Gryphon Gloves 2', inv);
  1017.         NewGamePlusReplaceItem('Gryphon Gloves 3', 'NGP Gryphon Gloves 3', inv);
  1018.         NewGamePlusReplaceItem('Gryphon Gloves 4', 'NGP Gryphon Gloves 4', inv);
  1019.        
  1020.         NewGamePlusReplaceItem('Gryphon Pants 1', 'NGP Gryphon Pants 1', inv);
  1021.         NewGamePlusReplaceItem('Gryphon Pants 2', 'NGP Gryphon Pants 2', inv);
  1022.         NewGamePlusReplaceItem('Gryphon Pants 3', 'NGP Gryphon Pants 3', inv);
  1023.         NewGamePlusReplaceItem('Gryphon Pants 4', 'NGP Gryphon Pants 4', inv);
  1024.        
  1025.         NewGamePlusReplaceItem('Gryphon Boots 1', 'NGP Gryphon Boots 1', inv);
  1026.         NewGamePlusReplaceItem('Gryphon Boots 2', 'NGP Gryphon Boots 2', inv);
  1027.         NewGamePlusReplaceItem('Gryphon Boots 3', 'NGP Gryphon Boots 3', inv);
  1028.         NewGamePlusReplaceItem('Gryphon Boots 4', 'NGP Gryphon Boots 4', inv);
  1029.        
  1030.         NewGamePlusReplaceItem('Gryphon School steel sword', 'NGP Gryphon School steel sword', inv);
  1031.         NewGamePlusReplaceItem('Gryphon School steel sword 1', 'NGP Gryphon School steel sword 1', inv);
  1032.         NewGamePlusReplaceItem('Gryphon School steel sword 2', 'NGP Gryphon School steel sword 2', inv);
  1033.         NewGamePlusReplaceItem('Gryphon School steel sword 3', 'NGP Gryphon School steel sword 3', inv);
  1034.        
  1035.         NewGamePlusReplaceItem('Gryphon School silver sword', 'NGP Gryphon School silver sword', inv);
  1036.         NewGamePlusReplaceItem('Gryphon School silver sword 1', 'NGP Gryphon School silver sword 1', inv);
  1037.         NewGamePlusReplaceItem('Gryphon School silver sword 2', 'NGP Gryphon School silver sword 2', inv);
  1038.         NewGamePlusReplaceItem('Gryphon School silver sword 3', 'NGP Gryphon School silver sword 3', inv);
  1039.     }
  1040.    
  1041.     private final function NewGamePlusReplaceBearSet(out inv : CInventoryComponent)
  1042.     {
  1043.         NewGamePlusReplaceItem('Bear Armor', 'NGP Bear Armor', inv);
  1044.         NewGamePlusReplaceItem('Bear Armor 1', 'NGP Bear Armor 1', inv);
  1045.         NewGamePlusReplaceItem('Bear Armor 2', 'NGP Bear Armor 2', inv);
  1046.         NewGamePlusReplaceItem('Bear Armor 3', 'NGP Bear Armor 3', inv);
  1047.        
  1048.         NewGamePlusReplaceItem('Bear Gloves 1', 'NGP Bear Gloves 1', inv);
  1049.         NewGamePlusReplaceItem('Bear Gloves 2', 'NGP Bear Gloves 2', inv);
  1050.         NewGamePlusReplaceItem('Bear Gloves 3', 'NGP Bear Gloves 3', inv);
  1051.         NewGamePlusReplaceItem('Bear Gloves 4', 'NGP Bear Gloves 4', inv);
  1052.        
  1053.         NewGamePlusReplaceItem('Bear Pants 1', 'NGP Bear Pants 1', inv);
  1054.         NewGamePlusReplaceItem('Bear Pants 2', 'NGP Bear Pants 2', inv);
  1055.         NewGamePlusReplaceItem('Bear Pants 3', 'NGP Bear Pants 3', inv);
  1056.         NewGamePlusReplaceItem('Bear Pants 4', 'NGP Bear Pants 4', inv);
  1057.        
  1058.         NewGamePlusReplaceItem('Bear Boots 1', 'NGP Bear Boots 1', inv);
  1059.         NewGamePlusReplaceItem('Bear Boots 2', 'NGP Bear Boots 2', inv);
  1060.         NewGamePlusReplaceItem('Bear Boots 3', 'NGP Bear Boots 3', inv);
  1061.         NewGamePlusReplaceItem('Bear Boots 4', 'NGP Bear Boots 4', inv);
  1062.        
  1063.         NewGamePlusReplaceItem('Bear School steel sword', 'NGP Bear School steel sword', inv);
  1064.         NewGamePlusReplaceItem('Bear School steel sword 1', 'NGP Bear School steel sword 1', inv);
  1065.         NewGamePlusReplaceItem('Bear School steel sword 2', 'NGP Bear School steel sword 2', inv);
  1066.         NewGamePlusReplaceItem('Bear School steel sword 3', 'NGP Bear School steel sword 3', inv);
  1067.        
  1068.         NewGamePlusReplaceItem('Bear School silver sword', 'NGP Bear School silver sword', inv);
  1069.         NewGamePlusReplaceItem('Bear School silver sword 1', 'NGP Bear School silver sword 1', inv);
  1070.         NewGamePlusReplaceItem('Bear School silver sword 2', 'NGP Bear School silver sword 2', inv);
  1071.         NewGamePlusReplaceItem('Bear School silver sword 3', 'NGP Bear School silver sword 3', inv);
  1072.     }
  1073.        
  1074.     private final function NewGamePlusReplaceEP1(out inv : CInventoryComponent)
  1075.     {  
  1076.         NewGamePlusReplaceItem('Ofir Armor', 'NGP Ofir Armor', inv);
  1077.         NewGamePlusReplaceItem('Ofir Sabre 2', 'NGP Ofir Sabre 2', inv);
  1078.        
  1079.         NewGamePlusReplaceItem('Crafted Burning Rose Armor', 'NGP Crafted Burning Rose Armor', inv);
  1080.         NewGamePlusReplaceItem('Crafted Burning Rose Gloves', 'NGP Crafted Burning Rose Gloves', inv);
  1081.         NewGamePlusReplaceItem('Crafted Burning Rose Sword', 'NGP Crafted Burning Rose Sword', inv);
  1082.        
  1083.         NewGamePlusReplaceItem('Crafted Ofir Armor', 'NGP Crafted Ofir Armor', inv);
  1084.         NewGamePlusReplaceItem('Crafted Ofir Boots', 'NGP Crafted Ofir Boots', inv);
  1085.         NewGamePlusReplaceItem('Crafted Ofir Gloves', 'NGP Crafted Ofir Gloves', inv);
  1086.         NewGamePlusReplaceItem('Crafted Ofir Pants', 'NGP Crafted Ofir Pants', inv);
  1087.         NewGamePlusReplaceItem('Crafted Ofir Steel Sword', 'NGP Crafted Ofir Steel Sword', inv);
  1088.        
  1089.         NewGamePlusReplaceItem('EP1 Crafted Witcher Silver Sword', 'NGP EP1 Crafted Witcher Silver Sword', inv);
  1090.         NewGamePlusReplaceItem('Olgierd Sabre', 'NGP Olgierd Sabre', inv);
  1091.        
  1092.         NewGamePlusReplaceItem('EP1 Witcher Armor', 'NGP EP1 Witcher Armor', inv);
  1093.         NewGamePlusReplaceItem('EP1 Witcher Boots', 'NGP EP1 Witcher Boots', inv);
  1094.         NewGamePlusReplaceItem('EP1 Witcher Gloves', 'NGP EP1 Witcher Gloves', inv);
  1095.         NewGamePlusReplaceItem('EP1 Witcher Pants', 'NGP EP1 Witcher Pants', inv);
  1096.         NewGamePlusReplaceItem('EP1 Viper School steel sword', 'NGP EP1 Viper School steel sword', inv);
  1097.         NewGamePlusReplaceItem('EP1 Viper School silver sword', 'NGP EP1 Viper School silver sword', inv);
  1098.     }
  1099.    
  1100.     public function GetEquippedSword(steel : bool) : SItemUniqueId
  1101.     {
  1102.         var item : SItemUniqueId;
  1103.        
  1104.         if(steel)
  1105.             GetItemEquippedOnSlot(EES_SteelSword, item);
  1106.         else
  1107.             GetItemEquippedOnSlot(EES_SilverSword, item);
  1108.            
  1109.         return item;
  1110.     }
  1111.    
  1112.     timer function BroadcastRain( deltaTime : float, id : int )
  1113.     {
  1114.         var rainStrength : float = 0;
  1115.         rainStrength = GetRainStrength();
  1116.         if( rainStrength > 0.5 )
  1117.         {
  1118.             theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( thePlayer, 'RainAction', 2.0f , 50.0f, -1.f, -1, true);
  1119.             LogReactionSystem( "'RainAction' was sent by Player - single broadcast - distance: 50.0" );
  1120.         }
  1121.     }
  1122.    
  1123.     function InitializeParryType()
  1124.     {
  1125.         var i, j : int;
  1126.        
  1127.         parryTypeTable.Resize( EnumGetMax('EAttackSwingType')+1 );
  1128.         for( i = 0; i < EnumGetMax('EAttackSwingType')+1; i += 1 )
  1129.         {
  1130.             parryTypeTable[i].Resize( EnumGetMax('EAttackSwingDirection')+1 );
  1131.         }
  1132.         parryTypeTable[AST_Horizontal][ASD_UpDown] = PT_None;
  1133.         parryTypeTable[AST_Horizontal][ASD_DownUp] = PT_None;
  1134.         parryTypeTable[AST_Horizontal][ASD_LeftRight] = PT_Left;
  1135.         parryTypeTable[AST_Horizontal][ASD_RightLeft] = PT_Right;
  1136.         parryTypeTable[AST_Vertical][ASD_UpDown] = PT_Up;
  1137.         parryTypeTable[AST_Vertical][ASD_DownUp] = PT_Down;
  1138.         parryTypeTable[AST_Vertical][ASD_LeftRight] = PT_None;
  1139.         parryTypeTable[AST_Vertical][ASD_RightLeft] = PT_None;
  1140.         parryTypeTable[AST_DiagonalUp][ASD_UpDown] = PT_None;
  1141.         parryTypeTable[AST_DiagonalUp][ASD_DownUp] = PT_None;
  1142.         parryTypeTable[AST_DiagonalUp][ASD_LeftRight] = PT_UpLeft;
  1143.         parryTypeTable[AST_DiagonalUp][ASD_RightLeft] = PT_RightUp;
  1144.         parryTypeTable[AST_DiagonalDown][ASD_UpDown] = PT_None;
  1145.         parryTypeTable[AST_DiagonalDown][ASD_DownUp] = PT_None;
  1146.         parryTypeTable[AST_DiagonalDown][ASD_LeftRight] = PT_LeftDown;
  1147.         parryTypeTable[AST_DiagonalDown][ASD_RightLeft] = PT_DownRight;
  1148.         parryTypeTable[AST_Jab][ASD_UpDown] = PT_Jab;
  1149.         parryTypeTable[AST_Jab][ASD_DownUp] = PT_Jab;
  1150.         parryTypeTable[AST_Jab][ASD_LeftRight] = PT_Jab;
  1151.         parryTypeTable[AST_Jab][ASD_RightLeft] = PT_Jab;   
  1152.     }
  1153.    
  1154.    
  1155.    
  1156.    
  1157.    
  1158.    
  1159.     event OnDeath( damageAction : W3DamageAction )
  1160.     {
  1161.         var items       : array< SItemUniqueId >;
  1162.         var i, size     : int
  1163.         var slot        : EEquipmentSlots;
  1164.         var holdSlot    : name;
  1165.    
  1166.         super.OnDeath( damageAction );
  1167.    
  1168.         items = GetHeldItems();
  1169.                
  1170.         if( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait')
  1171.         {
  1172.             OnRangedForceHolster( true, true, true );      
  1173.             rangedWeapon.ClearDeployedEntity(true);
  1174.         }
  1175.        
  1176.         size = items.Size();
  1177.        
  1178.         if ( size > 0 )
  1179.         {
  1180.             for ( i = 0; i < size; i += 1 )
  1181.             {
  1182.                 if ( this.inv.IsIdValid( items[i] ) && !( this.inv.IsItemCrossbow( items[i] ) ) )
  1183.                 {
  1184.                     holdSlot = this.inv.GetItemHoldSlot( items[i] );               
  1185.                
  1186.                     if (  holdSlot == 'l_weapon' && this.IsHoldingItemInLHand() )
  1187.                     {
  1188.                         this.OnUseSelectedItem( true );
  1189.                     }          
  1190.            
  1191.                     DropItemFromSlot( holdSlot, false );
  1192.                    
  1193.                     if ( holdSlot == 'r_weapon' )
  1194.                     {
  1195.                         slot = this.GetItemSlot( items[i] );
  1196.                         if ( UnequipItemFromSlot( slot ) )
  1197.                             Log( "Unequip" );
  1198.                     }
  1199.                 }
  1200.             }
  1201.         }
  1202.     }
  1203.    
  1204.    
  1205.    
  1206.    
  1207.    
  1208.    
  1209.    
  1210.     function HandleMovement( deltaTime : float )
  1211.     {
  1212.         super.HandleMovement( deltaTime );
  1213.        
  1214.         rawCameraHeading = theCamera.GetCameraHeading();
  1215.     }
  1216.        
  1217.    
  1218.    
  1219.    
  1220.    
  1221.    
  1222.    
  1223.     function ToggleSpecialAttackHeavyAllowed( toggle : bool)
  1224.     {
  1225.         specialAttackHeavyAllowed = toggle;
  1226.     }
  1227.    
  1228.     function GetReputationManager() : W3Reputation
  1229.     {
  1230.         return reputationManager;
  1231.     }
  1232.            
  1233.     function OnRadialMenuItemChoose( selectedItem : string )
  1234.     {
  1235.         var iSlotId : int;
  1236.        
  1237.         if ( selectedItem != "Slot3" )
  1238.         {
  1239.             if ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  1240.                 OnRangedForceHolster( true, false );
  1241.         }
  1242.        
  1243.        
  1244.         switch(selectedItem)
  1245.         {
  1246.            
  1247.             case "Meditation":
  1248.                 theGame.RequestMenuWithBackground( 'MeditationClockMenu', 'CommonMenu' );
  1249.                 break;         
  1250.             case "Slot1":
  1251.                 SelectQuickslotItem(EES_Petard1);
  1252.                 break;         
  1253.             case "Slot2":
  1254.                 SelectQuickslotItem(EES_Petard2);
  1255.                 break;         
  1256.             case "Slot3":
  1257.                 SelectQuickslotItem(EES_RangedWeapon);
  1258.                 break;
  1259.             case "Slot4":
  1260.                 SelectQuickslotItem(EES_Quickslot1);
  1261.                 break;
  1262.             case "Slot5":
  1263.                 SelectQuickslotItem(EES_Quickslot2);
  1264.                 break;
  1265.             default:
  1266.                 SetEquippedSign(SignStringToEnum( selectedItem ));
  1267.                 FactsRemove("SignToggled");
  1268.                 break;
  1269.         }
  1270.     }
  1271.    
  1272.     function ToggleNextItem()
  1273.     {
  1274.         var quickSlotItems : array< EEquipmentSlots >;
  1275.         var currentSelectedItem : SItemUniqueId;
  1276.         var item : SItemUniqueId;
  1277.         var i : int;
  1278.        
  1279.         for( i = EES_Quickslot2; i > EES_Petard1 - 1; i -= 1 )
  1280.         {
  1281.             GetItemEquippedOnSlot( i, item );
  1282.             if( inv.IsIdValid( item ) )
  1283.             {
  1284.                 quickSlotItems.PushBack( i );
  1285.             }
  1286.         }
  1287.         if( !quickSlotItems.Size() )
  1288.         {
  1289.             return;
  1290.         }
  1291.        
  1292.         currentSelectedItem = GetSelectedItemId();
  1293.        
  1294.         if( inv.IsIdValid( currentSelectedItem ) )
  1295.         {
  1296.             for( i = 0; i < quickSlotItems.Size(); i += 1 )
  1297.             {
  1298.                 GetItemEquippedOnSlot( quickSlotItems[i], item );
  1299.                 if( currentSelectedItem == item )
  1300.                 {
  1301.                     if( i == quickSlotItems.Size() - 1 )
  1302.                     {
  1303.                         SelectQuickslotItem( quickSlotItems[ 0 ] );
  1304.                     }
  1305.                     else
  1306.                     {
  1307.                         SelectQuickslotItem( quickSlotItems[ i + 1 ] );
  1308.                     }
  1309.                     return;
  1310.                 }
  1311.             }
  1312.         }
  1313.         else
  1314.         {
  1315.             SelectQuickslotItem( quickSlotItems[ 0 ] );
  1316.         }
  1317.     }
  1318.        
  1319.    
  1320.     function SetEquippedSign( signType : ESignType )
  1321.     {
  1322.         if(!IsSignBlocked(signType))
  1323.         {
  1324.             equippedSign = signType;
  1325.             FactsSet("CurrentlySelectedSign", equippedSign);
  1326.         }
  1327.     }
  1328.    
  1329.     function GetEquippedSign() : ESignType
  1330.     {
  1331.         return equippedSign;
  1332.     }
  1333.    
  1334.     function GetCurrentlyCastSign() : ESignType
  1335.     {
  1336.         return currentlyCastSign;
  1337.     }
  1338.    
  1339.     function SetCurrentlyCastSign( type : ESignType, entity : W3SignEntity )
  1340.     {
  1341.         currentlyCastSign = type;
  1342.        
  1343.         if( type != ST_None )
  1344.         {
  1345.             signs[currentlyCastSign].entity = entity;
  1346.         }
  1347.     }
  1348.    
  1349.     function GetCurrentSignEntity() : W3SignEntity
  1350.     {
  1351.         if(currentlyCastSign == ST_None)
  1352.             return NULL;
  1353.            
  1354.         return signs[currentlyCastSign].entity;
  1355.     }
  1356.    
  1357.     public function GetSignEntity(type : ESignType) : W3SignEntity
  1358.     {
  1359.         if(type == ST_None)
  1360.             return NULL;
  1361.            
  1362.         return signs[type].entity;
  1363.     }
  1364.    
  1365.     public function GetSignTemplate(type : ESignType) : CEntityTemplate
  1366.     {
  1367.         if(type == ST_None)
  1368.             return NULL;
  1369.            
  1370.         return signs[type].template;
  1371.     }
  1372.    
  1373.     public function IsCurrentSignChanneled() : bool
  1374.     {
  1375.         if( currentlyCastSign != ST_None && signs[currentlyCastSign].entity)
  1376.             return signs[currentlyCastSign].entity.OnCheckChanneling();
  1377.        
  1378.         return false;
  1379.     }
  1380.    
  1381.     function IsCastingSign() : bool
  1382.     {
  1383.         return currentlyCastSign != ST_None;
  1384.     }
  1385.    
  1386.    
  1387.     protected function IsInCombatActionCameraRotationEnabled() : bool
  1388.     {
  1389.         if( IsInCombatAction() && ( GetCombatAction() == EBAT_EMPTY || GetCombatAction() == EBAT_Parry ) )
  1390.         {
  1391.             return true;
  1392.         }
  1393.        
  1394.         return !bIsInCombatAction;
  1395.     }
  1396.    
  1397.     function SetHoldBeforeOpenRadialMenuTime ( time : float )
  1398.     {
  1399.         _HoldBeforeOpenRadialMenuTime = time;
  1400.     }
  1401.    
  1402.    
  1403.    
  1404.    
  1405.    
  1406.    
  1407.    
  1408.     public function RepairItem (  rapairKitId : SItemUniqueId, usedOnItem : SItemUniqueId )
  1409.     {
  1410.         var itemMaxDurablity        : float;
  1411.         var itemCurrDurablity       : float;
  1412.         var baseRepairValue         : float;
  1413.         var reapirValue             : float;
  1414.         var itemAttribute           : SAbilityAttributeValue;
  1415.        
  1416.         itemMaxDurablity = inv.GetItemMaxDurability(usedOnItem);
  1417.         itemCurrDurablity = inv.GetItemDurability(usedOnItem);
  1418.         itemAttribute = inv.GetItemAttributeValue ( rapairKitId, 'repairValue' );
  1419.        
  1420.         if ( inv.IsItemAnyArmor ( usedOnItem )|| inv.IsItemWeapon( usedOnItem ) )
  1421.         {          
  1422.            
  1423.             baseRepairValue = itemMaxDurablity * itemAttribute.valueMultiplicative;                
  1424.             reapirValue = MinF( itemCurrDurablity + baseRepairValue, itemMaxDurablity );
  1425.            
  1426.             inv.SetItemDurabilityScript ( usedOnItem, MinF ( reapirValue, itemMaxDurablity ));
  1427.         }
  1428.        
  1429.         inv.RemoveItem ( rapairKitId, 1 );
  1430.        
  1431.     }
  1432.     public function HasRepairAbleGearEquiped ( ) : bool
  1433.     {
  1434.         var curEquipedItem : SItemUniqueId;
  1435.        
  1436.         return ( GetItemEquippedOnSlot(EES_Armor, curEquipedItem) || GetItemEquippedOnSlot(EES_Boots, curEquipedItem) || GetItemEquippedOnSlot(EES_Pants, curEquipedItem) || GetItemEquippedOnSlot(EES_Gloves, curEquipedItem)) == true;
  1437.     }
  1438.     public function HasRepairAbleWaponEquiped () : bool
  1439.     {
  1440.         var curEquipedItem : SItemUniqueId;
  1441.        
  1442.         return ( GetItemEquippedOnSlot(EES_SilverSword, curEquipedItem) || GetItemEquippedOnSlot(EES_SteelSword, curEquipedItem) ) == true;
  1443.     }
  1444.     public function IsItemRepairAble ( item : SItemUniqueId ) : bool
  1445.     {
  1446.         return inv.GetItemDurabilityRatio(item) <= 0.99999f;
  1447.     }
  1448.    
  1449.    
  1450.    
  1451.    
  1452.    
  1453.    
  1454.        
  1455.    
  1456.     public function GetOilAppliedOnSword(steel : bool) : name
  1457.     {
  1458.         var hasItem : bool;
  1459.         var sword   : SItemUniqueId;
  1460.        
  1461.         if(steel)
  1462.             hasItem = GetItemEquippedOnSlot(EES_SteelSword, sword);
  1463.         else
  1464.             hasItem = GetItemEquippedOnSlot(EES_SilverSword, sword);
  1465.            
  1466.         if(!hasItem)
  1467.             return ''
  1468.        
  1469.         return inv.GetSwordOil(sword);
  1470.     }
  1471.    
  1472.    
  1473.     public function IsEquippedSwordUpgradedWithOil(steel : bool, optional oilName : name) : bool
  1474.     {
  1475.         var sword : SItemUniqueId;
  1476.         var i, minAbs, maxAbs : int;
  1477.         var hasItem : bool;
  1478.         var abilities, swordAbilities : array<name>;
  1479.         var dm : CDefinitionsManagerAccessor;
  1480.         var weights : array<float>;
  1481.    
  1482.         if(steel)
  1483.             hasItem = GetItemEquippedOnSlot(EES_SteelSword, sword);
  1484.         else
  1485.             hasItem = GetItemEquippedOnSlot(EES_SilverSword, sword);
  1486.                
  1487.         if(hasItem)
  1488.         {
  1489.             inv.GetItemAbilities(sword, swordAbilities);
  1490.             dm = theGame.GetDefinitionsManager();
  1491.            
  1492.             if(IsNameValid(oilName))
  1493.             {              
  1494.                 dm.GetItemAbilitiesWithWeights(oilName, true, abilities, weights, minAbs, maxAbs);
  1495.                                
  1496.                 for(i=0; i<abilities.Size(); i+=1)
  1497.                 {
  1498.                     if(dm.AbilityHasTag(abilities[i], theGame.params.OIL_ABILITY_TAG))
  1499.                     {
  1500.                         if(swordAbilities.Contains(abilities[i]))
  1501.                         {
  1502.                            
  1503.                             return true;
  1504.                         }                  
  1505.                     }
  1506.                 }
  1507.             }
  1508.             else
  1509.             {
  1510.                
  1511.                 for(i=0; i<swordAbilities.Size(); i+=1)
  1512.                 {
  1513.                     if(dm.AbilityHasTag(swordAbilities[i], theGame.params.OIL_ABILITY_TAG))
  1514.                         return true;
  1515.                 }
  1516.             }
  1517.         }
  1518.        
  1519.        
  1520.         return false;
  1521.     }
  1522.    
  1523.    
  1524.     public function ApplyOil( oilId : SItemUniqueId, usedOnItem : SItemUniqueId )
  1525.     {
  1526.         var oilAbilities : array<name>;
  1527.         var i : int;
  1528.         var ammo, ammoBonus : float;
  1529.         var dm : CDefinitionsManagerAccessor;
  1530.         var swordEquipped, swordHeld, steel : bool;
  1531.         var tutStateOil : W3TutorialManagerUIHandlerStateOils;
  1532.         var sword : CWitcherSword;
  1533.                
  1534.         if(!CanApplyOilOnItem(oilId, usedOnItem))
  1535.             return;
  1536.                
  1537.         dm = theGame.GetDefinitionsManager();
  1538.         inv.GetItemAbilitiesWithTag(oilId, theGame.params.OIL_ABILITY_TAG, oilAbilities);
  1539.         swordEquipped = IsItemEquipped(usedOnItem);
  1540.         swordHeld     = IsItemHeld(usedOnItem);
  1541.         steel = inv.IsItemSteelSwordUsableByPlayer(usedOnItem);
  1542.        
  1543.        
  1544.         RemoveOilBuff(steel);
  1545.         RemoveItemOil(usedOnItem);
  1546.  
  1547.        
  1548.         for(i=0; i<oilAbilities.Size(); i+=1)
  1549.         {
  1550.             inv.AddItemCraftedAbility(usedOnItem, oilAbilities[i]);
  1551.                
  1552.            
  1553.             if(swordEquipped)
  1554.             {
  1555.                 AddAbility(oilAbilities[i]);
  1556.             }
  1557.         }
  1558.  
  1559.         if(swordEquipped)
  1560.         {
  1561.             sword = (CWitcherSword) inv.GetItemEntityUnsafe(usedOnItem);
  1562.             sword.ApplyOil( inv );
  1563.         }
  1564.                
  1565.        
  1566.        
  1567.         ammo = CalculateAttributeValue(inv.GetItemAttributeValue(oilId, 'ammo'));
  1568.         if(CanUseSkill(S_Alchemy_s06))
  1569.         {
  1570.             ammoBonus = CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s06, 'ammo_bonus', false, false));
  1571.             ammo *= 1 + ammoBonus * GetSkillLevel(S_Alchemy_s06);
  1572.         }
  1573.         inv.SetItemModifierInt(usedOnItem, 'oil_charges', RoundMath(ammo));
  1574.         inv.SetItemModifierInt(usedOnItem, 'oil_max_charges', RoundMath(ammo));
  1575.                
  1576.         LogOils("Added oil <<" + inv.GetItemName(oilId) + ">> to <<" + inv.GetItemName(usedOnItem) + ">>");
  1577.        
  1578.        
  1579.         SetFailedFundamentalsFirstAchievementCondition(true);
  1580.                
  1581.        
  1582.         if(ShouldProcessTutorial('TutorialOilCanEquip3'))
  1583.         {
  1584.             tutStateOil = (W3TutorialManagerUIHandlerStateOils)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  1585.             if(tutStateOil)
  1586.             {
  1587.                 tutStateOil.OnOilApplied();
  1588.             }
  1589.         }
  1590.        
  1591.         if ( swordHeld )
  1592.         {
  1593.            
  1594.             AddOilBuff(steel);
  1595.         }
  1596.        
  1597.         theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnOilApplied );
  1598.     }
  1599.    
  1600.    
  1601.    
  1602.    
  1603.    
  1604.    
  1605.    
  1606.    
  1607.     function ReduceDamage(out damageData : W3DamageAction)
  1608.     {
  1609.         var actorAttacker : CActor;
  1610.         var quen : W3QuenEntity;
  1611.         var attackRange : CAIAttackRange;
  1612.         var attackerMovementAdjustor : CMovementAdjustor;
  1613.         var dist, distToAttacker, actionHeading, attackerHeading : float;
  1614.         var attackName : name;
  1615.         var useQuenForBleeding : bool;
  1616.        
  1617.         super.ReduceDamage(damageData);
  1618.        
  1619.        
  1620.        
  1621.         quen = (W3QuenEntity)signs[ST_Quen].entity;
  1622.         useQuenForBleeding = false;
  1623.         if(quen && !damageData.DealsAnyDamage() && ((W3Effect_Bleeding)damageData.causer) && damageData.GetDamageValue(theGame.params.DAMAGE_NAME_DIRECT) > 0.f)
  1624.             useQuenForBleeding = true;
  1625.        
  1626.        
  1627.         if(!useQuenForBleeding && !damageData.DealsAnyDamage())
  1628.             return;
  1629.        
  1630.         actorAttacker = (CActor)damageData.attacker;
  1631.        
  1632.        
  1633.         if(actorAttacker && IsCurrentlyDodging() && damageData.CanBeDodged())
  1634.         {
  1635.            
  1636.            
  1637.             actionHeading = evadeHeading;
  1638.             attackerHeading = actorAttacker.GetHeading();
  1639.             dist = AngleDistance(actionHeading, attackerHeading);
  1640.             distToAttacker = VecDistance(this.GetWorldPosition(),damageData.attacker.GetWorldPosition());
  1641.             attackName = actorAttacker.GetLastAttackRangeName();
  1642.             attackRange = theGame.GetAttackRangeForEntity( actorAttacker, attackName );
  1643.             attackerMovementAdjustor = actorAttacker.GetMovingAgentComponent().GetMovementAdjustor();
  1644.             if( ( AbsF(dist) < 150 && attackName != 'stomp' && attackName != 'anchor_special_far' && attackName != 'anchor_far' )
  1645.                 || ( ( attackName == 'stomp' || attackName == 'anchor_special_far' || attackName == 'anchor_far' )
  1646.                     && distToAttacker > attackRange.rangeMax * 0.75 ) )
  1647.             {
  1648.                 if ( theGame.CanLog() )
  1649.                 {
  1650.                     LogDMHits("W3PlayerWitcher.ReduceDamage: Attack dodged by player - no damage done", damageData);
  1651.                 }
  1652.                 damageData.SetAllProcessedDamageAs(0);
  1653.                 damageData.SetWasDodged();
  1654.             }
  1655.            
  1656.             else if (!(damageData.IsActionEnvironment() || damageData.IsDoTDamage()) && CanUseSkill(S_Sword_s09))
  1657.             {
  1658.                 damageData.processedDmg.vitalityDamage *= 1 - ( CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s09, 'damage_reduction', false, true)) * GetSkillLevel(S_Sword_s09) );
  1659.                 if ( theGame.CanLog() )
  1660.                 {
  1661.                     LogDMHits("W3PlayerWitcher.ReduceDamage: skill S_Sword_s09 reduced damage while dodging", damageData );
  1662.                 }
  1663.             }
  1664.         }
  1665.        
  1666.        
  1667.         if(quen && damageData.GetBuffSourceName() != "FallingDamage")
  1668.         {
  1669.             if ( theGame.CanLog() )
  1670.             {      
  1671.                 LogDMHits("W3PlayerWitcher.ReduceDamage: Processing Quen sign damage reduction...", damageData);
  1672.             }
  1673.             quen.OnTargetHit( damageData );
  1674.         }  
  1675.     }
  1676.    
  1677.     timer function UndyingSkillCooldown(dt : float, id : int)
  1678.     {
  1679.         cannotUseUndyingSkill = false;
  1680.     }
  1681.    
  1682.     event OnTakeDamage( action : W3DamageAction)
  1683.     {
  1684.         var currVitality, hpTriggerTreshold : float;
  1685.         var healingFactor : float;
  1686.         var abilityName : name;
  1687.         var abilityCount, maxStack, itemDurability : float;
  1688.         var addAbility : bool;
  1689.         var min, max : SAbilityAttributeValue;
  1690.         var mutagenQuen : W3SignEntity;
  1691.         var equipped : array<SItemUniqueId>;
  1692.         var i : int;
  1693.    
  1694.         currVitality = GetStat(BCS_Vitality);
  1695.        
  1696.        
  1697.         if(action.processedDmg.vitalityDamage >= currVitality)
  1698.         {
  1699.            
  1700.             if(!cannotUseUndyingSkill && FloorF(GetStat(BCS_Focus)) >= 1 && CanUseSkill(S_Sword_s18) && HasBuff(EET_BattleTrance))
  1701.             {
  1702.                 healingFactor = CalculateAttributeValue( GetSkillAttributeValue(S_Sword_s18, 'healing_factor', false, true) );
  1703.                 healingFactor *= GetStatMax(BCS_Vitality);
  1704.                 healingFactor *= GetStat(BCS_Focus);
  1705.                 healingFactor *= 1 + CalculateAttributeValue( GetSkillAttributeValue(S_Sword_s18, 'healing_bonus', false, true) ) * (GetSkillLevel(S_Sword_s18) - 1);
  1706.                 ForceSetStat(BCS_Vitality, GetStatMax(BCS_Vitality));
  1707.                 action.processedDmg.vitalityDamage = GetStatMax(BCS_Vitality) - healingFactor;
  1708.                 DrainFocus(GetStat(BCS_Focus));
  1709.                 RemoveBuff(EET_BattleTrance);
  1710.                 cannotUseUndyingSkill = true;
  1711.                 AddTimer('UndyingSkillCooldown', CalculateAttributeValue( GetSkillAttributeValue(S_Sword_s18, 'trigger_delay', false, true) ), false, , , true);
  1712.             }
  1713.             else
  1714.             {
  1715.                
  1716.                 equipped = GetEquippedItems();
  1717.                
  1718.                 for(i=0; i<equipped.Size(); i+=1)
  1719.                 {
  1720.                     if ( !inv.IsIdValid( equipped[i] ) )
  1721.                     {
  1722.                         continue;
  1723.                     }
  1724.                     itemDurability = inv.GetItemDurability(equipped[i]);
  1725.                     if(inv.ItemHasAbility(equipped[i], 'MA_Reinforced') && itemDurability > 0)
  1726.                     {
  1727.                        
  1728.                         inv.SetItemDurabilityScript(equipped[i], MaxF(0, itemDurability - action.processedDmg.vitalityDamage) );
  1729.                        
  1730.                        
  1731.                         action.processedDmg.vitalityDamage = 0;
  1732.                         ForceSetStat(BCS_Vitality, 1);
  1733.                        
  1734.                         break;
  1735.                     }
  1736.                 }
  1737.             }
  1738.         }
  1739.        
  1740.        
  1741.         if(action.DealsAnyDamage() && !((W3Effect_Toxicity)action.causer) )
  1742.         {
  1743.             if(HasBuff(EET_Mutagen10))
  1744.                 RemoveAbilityAll( GetBuff(EET_Mutagen10).GetAbilityName() );
  1745.            
  1746.             if(HasBuff(EET_Mutagen15))
  1747.                 RemoveAbilityAll( GetBuff(EET_Mutagen15).GetAbilityName() );
  1748.         }
  1749.                
  1750.        
  1751.         if(HasBuff(EET_Mutagen19))
  1752.         {
  1753.             theGame.GetDefinitionsManager().GetAbilityAttributeValue(GetBuff(EET_Mutagen19).GetAbilityName(), 'max_hp_perc_trigger', min, max);
  1754.             hpTriggerTreshold = GetStatMax(BCS_Vitality) * CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  1755.            
  1756.             if(action.GetDamageDealt() >= hpTriggerTreshold)
  1757.             {
  1758.                 mutagenQuen = (W3SignEntity)theGame.CreateEntity( signs[ST_Quen].template, GetWorldPosition(), GetWorldRotation() );
  1759.                 mutagenQuen.Init( signOwner, signs[ST_Quen].entity, true );
  1760.                 mutagenQuen.OnStarted();
  1761.                 mutagenQuen.OnThrowing();
  1762.                 mutagenQuen.OnEnded();
  1763.             }
  1764.         }
  1765.        
  1766.        
  1767.         if(action.DealsAnyDamage() && !action.IsDoTDamage() && HasBuff(EET_Mutagen27))
  1768.         {
  1769.             abilityName = GetBuff(EET_Mutagen27).GetAbilityName();
  1770.             abilityCount = GetAbilityCount(abilityName);
  1771.            
  1772.             if(abilityCount == 0)
  1773.             {
  1774.                 addAbility = true;
  1775.             }
  1776.             else
  1777.             {
  1778.                 theGame.GetDefinitionsManager().GetAbilityAttributeValue(abilityName, 'mutagen27_max_stack', min, max);
  1779.                 maxStack = CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  1780.                
  1781.                 if(maxStack >= 0)
  1782.                 {
  1783.                     addAbility = (abilityCount < maxStack);
  1784.                 }
  1785.                 else
  1786.                 {
  1787.                     addAbility = true;
  1788.                 }
  1789.             }
  1790.            
  1791.             if(addAbility)
  1792.             {
  1793.                 AddAbility(abilityName, true);
  1794.             }
  1795.         }
  1796.  
  1797.         return super.OnTakeDamage(action);
  1798.     }
  1799.    
  1800.    
  1801.    
  1802.    
  1803.    
  1804.    
  1805.    
  1806.     event OnStartFistfightMinigame()
  1807.     {
  1808.         super.OnStartFistfightMinigame();
  1809.         effectManager.RemoveAllPotionEffects();
  1810.     }
  1811.    
  1812.     event OnEndFistfightMinigame()
  1813.     {
  1814.         super.OnEndFistfightMinigame();
  1815.     }
  1816.    
  1817.    
  1818.     public function GetCriticalHitChance(isHeavyAttack : bool, target : CActor, victimMonsterCategory : EMonsterCategory) : float
  1819.     {
  1820.         var ret : float;
  1821.         var thunder : W3Potion_Thunderbolt;
  1822.        
  1823.         ret = super.GetCriticalHitChance(isHeavyAttack, target, victimMonsterCategory);
  1824.        
  1825.        
  1826.        
  1827.        
  1828.        
  1829.        
  1830.        
  1831.         thunder = (W3Potion_Thunderbolt)GetBuff(EET_Thunderbolt);
  1832.         if(thunder && thunder.GetBuffLevel() == 3 && GetCurWeather() == EWE_Storm)
  1833.         {
  1834.             ret += 1.0f;
  1835.         }
  1836.            
  1837.         return ret;
  1838.     }
  1839.    
  1840.    
  1841.     public function GetCriticalHitDamageBonus(weaponId : SItemUniqueId, victimMonsterCategory : EMonsterCategory, isStrikeAtBack : bool) : SAbilityAttributeValue
  1842.     {
  1843.         var min, max, bonus, null, oilBonus : SAbilityAttributeValue;
  1844.         var mutagen : CBaseGameplayEffect;
  1845.         var monsterBonusType : name;
  1846.        
  1847.         bonus = super.GetCriticalHitDamageBonus(weaponId, victimMonsterCategory, isStrikeAtBack);
  1848.        
  1849.        
  1850.         if(inv.ItemHasOilApplied(weaponId) && GetStat(BCS_Focus) >= 3 && CanUseSkill(S_Alchemy_s07))
  1851.         {
  1852.             monsterBonusType = MonsterCategoryToAttackPowerBonus( victimMonsterCategory );
  1853.             oilBonus = inv.GetItemAttributeValue( weaponId, monsterBonusType );
  1854.             if(oilBonus != null)   
  1855.             {
  1856.                 bonus += GetSkillAttributeValue(S_Alchemy_s07, theGame.params.CRITICAL_HIT_DAMAGE_BONUS, false, true);
  1857.             }
  1858.         }
  1859.        
  1860.        
  1861.         if (isStrikeAtBack && HasBuff(EET_Mutagen11))
  1862.         {
  1863.             mutagen = GetBuff(EET_Mutagen11);
  1864.             theGame.GetDefinitionsManager().GetAbilityAttributeValue(mutagen.GetAbilityName(), 'damageIncrease', min, max);
  1865.             bonus += GetAttributeRandomizedValue(min, max);
  1866.         }
  1867.            
  1868.         return bonus;      
  1869.     }
  1870.    
  1871.     public function ProcessLockTarget( optional newLockTarget : CActor, optional checkLeftStickHeading : bool ) : bool
  1872.     {
  1873.         var newLockTargetFound  : bool;
  1874.    
  1875.         newLockTargetFound = super.ProcessLockTarget(newLockTarget, checkLeftStickHeading);
  1876.        
  1877.         if(GetCurrentlyCastSign() == ST_Axii)
  1878.         {
  1879.             ((W3AxiiEntity)GetCurrentSignEntity()).OnDisplayTargetChange(newLockTarget);
  1880.         }
  1881.        
  1882.         return newLockTargetFound;
  1883.     }
  1884.    
  1885.    
  1886.    
  1887.    
  1888.    
  1889.    
  1890.    
  1891.      event OnPocessActionPost(action : W3DamageAction)
  1892.     {
  1893.         var attackAction : W3Action_Attack;
  1894.         var rendLoad : float;
  1895.         var value : SAbilityAttributeValue;
  1896.         var actorVictim : CActor;
  1897.         var weaponId : SItemUniqueId;
  1898.         var usesSteel, usesSilver, usesVitality, usesEssence : bool;
  1899.         var abs : array<name>;
  1900.         var i : int;
  1901.         var dm : CDefinitionsManagerAccessor;
  1902.         var items : array<SItemUniqueId>;
  1903.         var weaponEnt : CEntity;
  1904.        
  1905.         super.OnPocessActionPost(action);
  1906.        
  1907.         attackAction = (W3Action_Attack)action;
  1908.         actorVictim = (CActor)action.victim;
  1909.         if(attackAction)
  1910.         {
  1911.             if(attackAction.IsActionMelee())
  1912.             {
  1913.                
  1914.                 if(SkillNameToEnum(attackAction.GetAttackTypeName()) == S_Sword_s02)
  1915.                 {
  1916.                     rendLoad = GetSpecialAttackTimeRatio();
  1917.                    
  1918.                    
  1919.                     rendLoad = MinF(rendLoad * GetStatMax(BCS_Focus), GetStat(BCS_Focus));
  1920.                    
  1921.                    
  1922.                     rendLoad = FloorF(rendLoad);                   
  1923.                     DrainFocus(rendLoad);
  1924.                    
  1925.                     OnSpecialAttackHeavyActionProcess();
  1926.                 }
  1927.                 else if(actorVictim && IsRequiredAttitudeBetween(this, actorVictim, true))
  1928.                 {
  1929.                    
  1930.                    
  1931.                     value = GetAttributeValue('focus_gain');
  1932.                    
  1933.                     if( FactsQuerySum("debug_fact_focus_boy") > 0 )
  1934.                     {
  1935.                         Debug_FocusBoyFocusGain();
  1936.                     }
  1937.                    
  1938.                    
  1939.                     if ( CanUseSkill(S_Sword_s20) )
  1940.                     {
  1941.                         value += GetSkillAttributeValue(S_Sword_s20, 'focus_gain', false, true) * GetSkillLevel(S_Sword_s20);
  1942.                     }
  1943.                    
  1944.                     GainStat(BCS_Focus, 0.1f * (1 + CalculateAttributeValue(value)) );
  1945.                 }
  1946.                
  1947.                
  1948.                 weaponId = attackAction.GetWeaponId();
  1949.                 if(actorVictim && (ShouldProcessTutorial('TutorialWrongSwordSteel') || ShouldProcessTutorial('TutorialWrongSwordSilver')) && GetAttitudeBetween(actorVictim, this) == AIA_Hostile)
  1950.                 {
  1951.                     usesSteel = inv.IsItemSteelSwordUsableByPlayer(weaponId);
  1952.                     usesSilver = inv.IsItemSilverSwordUsableByPlayer(weaponId);
  1953.                     usesVitality = actorVictim.UsesVitality();
  1954.                     usesEssence = actorVictim.UsesEssence();
  1955.                    
  1956.                     if(usesSilver && usesVitality)
  1957.                     {
  1958.                         FactsAdd('tut_wrong_sword_silver',1);
  1959.                     }
  1960.                     else if(usesSteel && usesEssence)
  1961.                     {
  1962.                         FactsAdd('tut_wrong_sword_steel',1);
  1963.                     }
  1964.                     else if(FactsQuerySum('tut_wrong_sword_steel') && usesSilver && usesEssence)
  1965.                     {
  1966.                         FactsAdd('tut_proper_sword_silver',1);
  1967.                         FactsRemove('tut_wrong_sword_steel');
  1968.                     }
  1969.                     else if(FactsQuerySum('tut_wrong_sword_silver') && usesSteel && usesVitality)
  1970.                     {
  1971.                         FactsAdd('tut_proper_sword_steel',1);
  1972.                         FactsRemove('tut_wrong_sword_silver');
  1973.                     }
  1974.                 }
  1975.                
  1976.                
  1977.                 if(!action.WasDodged() && HasAbility('Runeword 1 _Stats', true))
  1978.                 {
  1979.                     if(runewordInfusionType == ST_Axii)
  1980.                     {
  1981.                         actorVictim.SoundEvent('sign_axii_release');
  1982.                     }
  1983.                     else if(runewordInfusionType == ST_Igni)
  1984.                     {
  1985.                         actorVictim.SoundEvent('sign_igni_charge_begin');
  1986.                     }
  1987.                     else if(runewordInfusionType == ST_Quen)
  1988.                     {
  1989.                         value = GetAttributeValue('runeword1_quen_heal');
  1990.                         Heal( action.GetDamageDealt() * value.valueMultiplicative );
  1991.                         PlayEffectSingle('drain_energy_caretaker_shovel');
  1992.                     }
  1993.                     else if(runewordInfusionType == ST_Yrden)
  1994.                     {
  1995.                         actorVictim.SoundEvent('sign_yrden_shock_activate');
  1996.                     }
  1997.                     runewordInfusionType = ST_None;
  1998.                    
  1999.                    
  2000.                     items = inv.GetHeldWeapons();
  2001.                     weaponEnt = inv.GetItemEntityUnsafe(items[0]);
  2002.                     weaponEnt.StopEffect('runeword_aard');
  2003.                     weaponEnt.StopEffect('runeword_axii');
  2004.                     weaponEnt.StopEffect('runeword_igni');
  2005.                     weaponEnt.StopEffect('runeword_quen');
  2006.                     weaponEnt.StopEffect('runeword_yrden');
  2007.                 }
  2008.                
  2009.                
  2010.                 if(ShouldProcessTutorial('TutorialLightAttacks') || ShouldProcessTutorial('TutorialHeavyAttacks'))
  2011.                 {
  2012.                     if(IsLightAttack(attackAction.GetAttackName()))
  2013.                     {
  2014.                         theGame.GetTutorialSystem().IncreaseGeraltsLightAttacksCount(action.victim.GetTags());
  2015.                     }
  2016.                     else if(IsHeavyAttack(attackAction.GetAttackName()))
  2017.                     {
  2018.                         theGame.GetTutorialSystem().IncreaseGeraltsHeavyAttacksCount(action.victim.GetTags());
  2019.                     }
  2020.                 }
  2021.             }
  2022.             else if(attackAction.IsActionRanged())
  2023.             {
  2024.                
  2025.                 if(CanUseSkill(S_Sword_s15))
  2026.                 {              
  2027.                     value = GetSkillAttributeValue(S_Sword_s15, 'focus_gain', false, true) * GetSkillLevel(S_Sword_s15) ;
  2028.                     GainStat(BCS_Focus, CalculateAttributeValue(value) );
  2029.                 }
  2030.                
  2031.                
  2032.                 if(CanUseSkill(S_Sword_s12) && attackAction.IsCriticalHit() && actorVictim)
  2033.                 {
  2034.                    
  2035.                     abs = actorVictim.GetAbilities(false);
  2036.                     dm = theGame.GetDefinitionsManager();
  2037.                     for(i=abs.Size()-1; i>=0; i-=1)
  2038.                     {
  2039.                         if(!dm.AbilityHasTag(abs[i], theGame.params.TAG_MONSTER_SKILL) || actorVictim.IsAbilityBlocked(abs[i]))
  2040.                         {
  2041.                             abs.EraseFast(i);
  2042.                         }
  2043.                     }
  2044.                    
  2045.                    
  2046.                     if(abs.Size() > 0)
  2047.                     {
  2048.                         value = GetSkillAttributeValue(S_Sword_s12, 'duration', true, true) * GetSkillLevel(S_Sword_s12);
  2049.                         actorVictim.BlockAbility(abs[ RandRange(abs.Size()) ], true, CalculateAttributeValue(value));
  2050.                     }
  2051.                 }
  2052.             }
  2053.         }
  2054.        
  2055.        
  2056.         if(CanUseSkill(S_Perk_18) && ((W3Petard)action.causer) && action.DealsAnyDamage() && !action.IsDoTDamage())
  2057.         {
  2058.             value = GetSkillAttributeValue(S_Perk_18, 'focus_gain', false, true);
  2059.             GainStat(BCS_Focus, CalculateAttributeValue(value));
  2060.         }      
  2061.     }
  2062.    
  2063.    
  2064.     timer function Mutagen14Timer(dt : float, id : int)
  2065.     {
  2066.         var abilityName : name;
  2067.         var abilityCount, maxStack : float;
  2068.         var min, max : SAbilityAttributeValue;
  2069.         var addAbility : bool;
  2070.        
  2071.         abilityName = GetBuff(EET_Mutagen14).GetAbilityName();
  2072.         abilityCount = GetAbilityCount(abilityName);
  2073.        
  2074.         if(abilityCount == 0)
  2075.         {
  2076.             addAbility = true;
  2077.         }
  2078.         else
  2079.         {
  2080.             theGame.GetDefinitionsManager().GetAbilityAttributeValue(abilityName, 'mutagen14_max_stack', min, max);
  2081.             maxStack = CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  2082.            
  2083.             if(maxStack >= 0)
  2084.             {
  2085.                 addAbility = (abilityCount < maxStack);
  2086.             }
  2087.             else
  2088.             {
  2089.                 addAbility = true;
  2090.             }
  2091.         }
  2092.        
  2093.         if(addAbility)
  2094.         {
  2095.             AddAbility(abilityName, true);
  2096.         }
  2097.         else
  2098.         {
  2099.            
  2100.             RemoveTimer('Mutagen14Timer');
  2101.         }
  2102.     }
  2103.    
  2104.     public final function FailFundamentalsFirstAchievementCondition()
  2105.     {
  2106.         SetFailedFundamentalsFirstAchievementCondition(true);
  2107.     }
  2108.        
  2109.     public final function SetUsedQuenInCombat()
  2110.     {
  2111.         usedQuenInCombat = true;
  2112.     }
  2113.    
  2114.     public final function UsedQuenInCombat() : bool
  2115.     {
  2116.         return usedQuenInCombat;
  2117.     }
  2118.    
  2119.     event OnCombatStart()
  2120.     {
  2121.         var quenEntity, glyphQuen : W3QuenEntity;
  2122.         var focus, stamina : float;
  2123.        
  2124.         super.OnCombatStart();
  2125.        
  2126.         if ( IsInCombatActionFriendly() )
  2127.         {
  2128.             SetBIsCombatActionAllowed(true);
  2129.             SetBIsInputAllowed(true, 'OnCombatActionStart' );
  2130.         }
  2131.        
  2132.        
  2133.         if(HasBuff(EET_Mutagen14))
  2134.         {
  2135.             AddTimer('Mutagen14Timer', 2, true);
  2136.         }
  2137.        
  2138.        
  2139.         if(HasBuff(EET_Mutagen15))
  2140.         {
  2141.             AddAbility(GetBuff(EET_Mutagen15).GetAbilityName(), false);
  2142.         }
  2143.        
  2144.        
  2145.         quenEntity = (W3QuenEntity)signs[ST_Quen].entity;      
  2146.        
  2147.        
  2148.         if(quenEntity)
  2149.         {
  2150.             usedQuenInCombat = quenEntity.IsAnyQuenActive();
  2151.         }
  2152.         else
  2153.         {
  2154.             usedQuenInCombat = false;
  2155.         }
  2156.        
  2157.         if(usedQuenInCombat || HasPotionBuff() || IsEquippedSwordUpgradedWithOil(true) || IsEquippedSwordUpgradedWithOil(false))
  2158.         {
  2159.             SetFailedFundamentalsFirstAchievementCondition(true);
  2160.         }
  2161.         else
  2162.         {
  2163.             if(IsAnyItemEquippedOnSlot(EES_PotionMutagen1) || IsAnyItemEquippedOnSlot(EES_PotionMutagen2) || IsAnyItemEquippedOnSlot(EES_PotionMutagen3) || IsAnyItemEquippedOnSlot(EES_PotionMutagen4))
  2164.                 SetFailedFundamentalsFirstAchievementCondition(true);
  2165.             else
  2166.                 SetFailedFundamentalsFirstAchievementCondition(false);
  2167.         }
  2168.        
  2169.         if(CanUseSkill(S_Sword_s20) && IsThreatened())
  2170.         {
  2171.             focus = GetStat(BCS_Focus);
  2172.             if(focus < 1)
  2173.             {
  2174.                 GainStat(BCS_Focus, 1 - focus);
  2175.             }
  2176.         }
  2177.  
  2178.         if ( HasAbility('Glyphword 17 _Stats', true) && RandF() < CalculateAttributeValue(GetAttributeValue('quen_apply_chance')) )
  2179.         {
  2180.             stamina = GetStat(BCS_Stamina);
  2181.             glyphQuen = (W3QuenEntity)theGame.CreateEntity( signs[ST_Quen].template, GetWorldPosition(), GetWorldRotation() );
  2182.             glyphQuen.Init( signOwner, signs[ST_Quen].entity, true );
  2183.             glyphQuen.OnStarted();
  2184.             glyphQuen.OnThrowing();
  2185.             glyphQuen.OnEnded();
  2186.             ForceSetStat(BCS_Stamina, stamina);
  2187.         }
  2188.        
  2189.        
  2190.         MeditationForceAbort(true);
  2191.         if( IsMutationActive( EPMT_Mutation5 ) && GetStat( BCS_Focus ) >= 1.f ) //zur13 modSSS
  2192.         if( IsMutationActive( EPMT_Mutation7 ) ) //zur13 modSSS
  2193.         if( IsMutationActive( EPMT_Mutation8 ) ) //zur13 modSSS
  2194.         if( IsMutationActive( EPMT_Mutation10 ) ) //zur13 modSSS
  2195.     }
  2196.    
  2197.    
  2198.     event OnCombatFinished()
  2199.     {
  2200.         var mut17 : W3Mutagen17_Effect;
  2201.        
  2202.         super.OnCombatFinished();
  2203.        
  2204.        
  2205.         if(HasBuff(EET_Mutagen10))
  2206.         {
  2207.             RemoveAbilityAll( GetBuff(EET_Mutagen10).GetAbilityName() );
  2208.         }
  2209.        
  2210.        
  2211.         if(HasBuff(EET_Mutagen14))
  2212.         {
  2213.             RemoveAbilityAll( GetBuff(EET_Mutagen14).GetAbilityName() );
  2214.         }
  2215.        
  2216.        
  2217.         if(HasBuff(EET_Mutagen15))
  2218.         {
  2219.             RemoveAbilityAll( GetBuff(EET_Mutagen15).GetAbilityName() );
  2220.         }
  2221.        
  2222.        
  2223.         if(HasBuff(EET_Mutagen17))
  2224.         {
  2225.             mut17 = (W3Mutagen17_Effect)GetBuff(EET_Mutagen17);
  2226.             mut17.ClearBoost();
  2227.         }
  2228.        
  2229.        
  2230.         if(HasBuff(EET_Mutagen18))
  2231.         {
  2232.             RemoveAbilityAll( GetBuff(EET_Mutagen18).GetAbilityName() );
  2233.         }
  2234.        
  2235.        
  2236.         if(HasBuff(EET_Mutagen22))
  2237.         {
  2238.             RemoveAbilityAll( GetBuff(EET_Mutagen22).GetAbilityName() );
  2239.         }
  2240.        
  2241.        
  2242.         if(HasBuff(EET_Mutagen27))
  2243.         {
  2244.             RemoveAbilityAll( GetBuff(EET_Mutagen27).GetAbilityName() );
  2245.         }
  2246.        
  2247.        
  2248.         if( IsMutationActive( EPMT_Mutation8 ) ) //zur13 modSSS
  2249.         if(GetStat(BCS_Focus) > 0)
  2250.         {
  2251.             AddTimer('DelayedAdrenalineDrain', theGame.params.ADRENALINE_DRAIN_AFTER_COMBAT_DELAY, , , , true);
  2252.         }
  2253.        
  2254.        
  2255.         thePlayer.abilityManager.ResetOverhealBonus();
  2256.        
  2257.         usedQuenInCombat = false;      
  2258.        
  2259.         theGame.GetGamerProfile().ResetStat(ES_FinesseKills);
  2260.        
  2261.         LogChannel( 'OnCombatFinished', "OnCombatFinished: DelayedSheathSword timer added" );
  2262.         if ( ShouldAutoSheathSwordInstantly() )
  2263.             AddTimer( 'DelayedSheathSword', 0.5f );
  2264.         else
  2265.             AddTimer( 'DelayedSheathSword', 2.f );
  2266.            
  2267.         OnBlockAllCombatTickets( false );
  2268.        
  2269.        
  2270.         runewordInfusionType = ST_None;
  2271.        
  2272.        
  2273.     }
  2274.    
  2275.     timer function DelayedAdrenalineDrain(dt : float, id : int)
  2276.     {
  2277.         if ( !HasBuff(EET_Runeword8) )
  2278.             AddEffectDefault(EET_AdrenalineDrain, this, "after_combat_adrenaline_drain");
  2279.     }
  2280.    
  2281.    
  2282.     protected function Attack( hitTarget : CGameplayEntity, animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float, weaponEntity : CItemEntity)
  2283.     {
  2284.         var mutagen17 : W3Mutagen17_Effect;
  2285.        
  2286.         super.Attack(hitTarget, animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime, weaponEntity);
  2287.        
  2288.         if( (CActor)hitTarget && HasBuff(EET_Mutagen17) )
  2289.         {
  2290.             mutagen17 = (W3Mutagen17_Effect)GetBuff(EET_Mutagen17);
  2291.             if(mutagen17.HasBoost())
  2292.             {
  2293.                 mutagen17.ClearBoost();
  2294.             }
  2295.         }
  2296.     }
  2297.    
  2298.     public final timer function SpecialAttackLightSustainCost(dt : float, id : int)
  2299.     {
  2300.         var focusPerSec, cost, delay : float;
  2301.         var reduction : SAbilityAttributeValue;
  2302.         var skillLevel : int;
  2303.        
  2304.         if(abilityManager && abilityManager.IsInitialized() && IsAlive())
  2305.         {
  2306.             PauseStaminaRegen('WhirlSkill');
  2307.            
  2308.             if(GetStat(BCS_Stamina) > 0)
  2309.             {
  2310.                 cost = GetStaminaActionCost(ESAT_Ability, GetSkillAbilityName(S_Sword_s01), dt);
  2311.                 delay = GetStaminaActionDelay(ESAT_Ability, GetSkillAbilityName(S_Sword_s01), dt);
  2312.                 skillLevel = GetSkillLevel(S_Sword_s01);
  2313.                
  2314.                 if(skillLevel > 1)
  2315.                 {
  2316.                     reduction = GetSkillAttributeValue(S_Sword_s01, 'cost_reduction', false, true) * (skillLevel - 1);
  2317.                     cost = MaxF(0, cost * (1 - reduction.valueMultiplicative) - reduction.valueAdditive);
  2318.                 }
  2319.                
  2320.                 DrainStamina(ESAT_FixedValue, cost, delay, GetSkillAbilityName(S_Sword_s01));
  2321.             }
  2322.             else               
  2323.             {              
  2324.                 GetSkillAttributeValue(S_Sword_s01, 'focus_cost_per_sec', false, true);
  2325.                 focusPerSec = GetWhirlFocusCostPerSec();
  2326.                 DrainFocus(focusPerSec * dt);
  2327.             }
  2328.         }
  2329.        
  2330.         if(GetStat(BCS_Stamina) <= 0 && GetStat(BCS_Focus) <= 0)
  2331.         {
  2332.             OnPerformSpecialAttack(true, false);
  2333.         }
  2334.     }
  2335.    
  2336.     public final function GetWhirlFocusCostPerSec() : float
  2337.     {
  2338.         var ability : SAbilityAttributeValue;
  2339.         var val : float;
  2340.         var skillLevel : int;
  2341.        
  2342.         ability = GetSkillAttributeValue(S_Sword_s01, 'focus_cost_per_sec_initial', false, false);
  2343.         skillLevel = GetSkillLevel(S_Sword_s01);
  2344.        
  2345.         if(skillLevel > 1)
  2346.             ability -= GetSkillAttributeValue(S_Sword_s01, 'cost_reduction', false, false) * (skillLevel-1);
  2347.            
  2348.         val = CalculateAttributeValue(ability);
  2349.        
  2350.         return val;
  2351.     }
  2352.    
  2353.     public final timer function SpecialAttackHeavySustainCost(dt : float, id : int)
  2354.     {
  2355.         var focusHighlight, ratio : float;
  2356.         var hud : CR4ScriptedHud;
  2357.         var hudWolfHeadModule : CR4HudModuleWolfHead;      
  2358.  
  2359.        
  2360.         DrainStamina(ESAT_Ability, 0, 0, GetSkillAbilityName(S_Sword_s02), dt);
  2361.  
  2362.        
  2363.         if(GetStat(BCS_Stamina) <= 0)
  2364.             OnPerformSpecialAttack(false, false);
  2365.            
  2366.        
  2367.         ratio = EngineTimeToFloat(theGame.GetEngineTime() - specialHeavyStartEngineTime) / specialHeavyChargeDuration;
  2368.        
  2369.        
  2370.         if(ratio > 0.95)
  2371.             ratio = 1;
  2372.            
  2373.         SetSpecialAttackTimeRatio(ratio);
  2374.        
  2375.        
  2376.         focusHighlight = ratio * GetStatMax(BCS_Focus);
  2377.         focusHighlight = MinF(focusHighlight, GetStat(BCS_Focus));
  2378.         focusHighlight = FloorF(focusHighlight);
  2379.        
  2380.         hud = (CR4ScriptedHud)theGame.GetHud();
  2381.         if ( hud )
  2382.         {
  2383.             hudWolfHeadModule = (CR4HudModuleWolfHead)hud.GetHudModule( "WolfHeadModule" );
  2384.             if ( hudWolfHeadModule )
  2385.             {
  2386.                 hudWolfHeadModule.LockFocusPoints((int)focusHighlight);
  2387.             }      
  2388.         }
  2389.     }
  2390.    
  2391.     public function OnSpecialAttackHeavyActionProcess()
  2392.     {
  2393.         var hud : CR4ScriptedHud;
  2394.         var hudWolfHeadModule : CR4HudModuleWolfHead;
  2395.        
  2396.         super.OnSpecialAttackHeavyActionProcess();
  2397.  
  2398.         hud = (CR4ScriptedHud)theGame.GetHud();
  2399.         if ( hud )
  2400.         {
  2401.             hudWolfHeadModule = (CR4HudModuleWolfHead)hud.GetHudModule( "WolfHeadModule" );
  2402.             if ( hudWolfHeadModule )
  2403.             {
  2404.                 hudWolfHeadModule.ResetFocusPoints();
  2405.             }      
  2406.         }
  2407.     }
  2408.    
  2409.     timer function IsSpecialLightAttackInputHeld ( time : float, id : int )
  2410.     {
  2411.         var hasResource : bool;
  2412.        
  2413.         if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
  2414.         {
  2415.             if ( GetBIsCombatActionAllowed() && inputHandler.IsActionAllowed(EIAB_SwordAttack))
  2416.             {
  2417.                 if(GetStat(BCS_Stamina) > 0)
  2418.                 {
  2419.                     hasResource = true;
  2420.                 }
  2421.                 else
  2422.                 {
  2423.                     hasResource = (GetStat(BCS_Focus) >= GetWhirlFocusCostPerSec() * time);                
  2424.                 }
  2425.                
  2426.                 if(hasResource)
  2427.                 {
  2428.                     SetupCombatAction( EBAT_SpecialAttack_Light, BS_Pressed );
  2429.                     RemoveTimer('IsSpecialLightAttackInputHeld');
  2430.                 }
  2431.                 else if(!playedSpecialAttackMissingResourceSound)
  2432.                 {
  2433.                     IndicateTooLowAdrenaline();
  2434.                     playedSpecialAttackMissingResourceSound = true;
  2435.                 }
  2436.             }          
  2437.         }
  2438.         else
  2439.         {
  2440.             RemoveTimer('IsSpecialLightAttackInputHeld');
  2441.         }
  2442.     }  
  2443.    
  2444.     timer function IsSpecialHeavyAttackInputHeld ( time : float, id : int )
  2445.     {      
  2446.         var cost : float;
  2447.        
  2448.         if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
  2449.         {
  2450.             cost = CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s02, 'stamina_cost_per_sec', false, false));
  2451.            
  2452.             if( GetBIsCombatActionAllowed() && inputHandler.IsActionAllowed(EIAB_SwordAttack))
  2453.             {
  2454.                 if(GetStat(BCS_Stamina) >= cost)
  2455.                 {
  2456.                     SetupCombatAction( EBAT_SpecialAttack_Heavy, BS_Pressed );
  2457.                     RemoveTimer('IsSpecialHeavyAttackInputHeld');
  2458.                 }
  2459.                 else if(!playedSpecialAttackMissingResourceSound)
  2460.                 {
  2461.                     IndicateTooLowAdrenaline();
  2462.                     playedSpecialAttackMissingResourceSound = true;
  2463.                 }
  2464.             }
  2465.         }
  2466.         else
  2467.         {
  2468.             RemoveTimer('IsSpecialHeavyAttackInputHeld');
  2469.         }
  2470.     }
  2471.    
  2472.     public function EvadePressed( bufferAction : EBufferActionType )
  2473.     {
  2474.         var cat : float;
  2475.        
  2476.         if( (bufferAction == EBAT_Dodge && IsActionAllowed(EIAB_Dodge)) || (bufferAction == EBAT_Roll && IsActionAllowed(EIAB_Roll)) )
  2477.         {
  2478.            
  2479.             if(bufferAction != EBAT_Roll && ShouldProcessTutorial('TutorialDodge'))
  2480.             {
  2481.                 FactsAdd("tut_in_dodge", 1, 2);
  2482.                
  2483.                 if(FactsQuerySum("tut_fight_use_slomo") > 0)
  2484.                 {
  2485.                     theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
  2486.                     FactsRemove("tut_fight_slomo_ON");
  2487.                 }
  2488.             }              
  2489.             else if(bufferAction == EBAT_Roll && ShouldProcessTutorial('TutorialRoll'))
  2490.             {
  2491.                 FactsAdd("tut_in_roll", 1, 2);
  2492.                
  2493.                 if(FactsQuerySum("tut_fight_use_slomo") > 0)
  2494.                 {
  2495.                     theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
  2496.                     FactsRemove("tut_fight_slomo_ON");
  2497.                 }
  2498.             }
  2499.                
  2500.             if ( GetBIsInputAllowed() )
  2501.             {          
  2502.                 if ( GetBIsCombatActionAllowed() )
  2503.                 {
  2504.                     CriticalEffectAnimationInterrupted("Dodge 2");
  2505.                     PushCombatActionOnBuffer( bufferAction, BS_Released );
  2506.                     ProcessCombatActionBuffer();
  2507.                 }                  
  2508.                 else if ( IsInCombatAction() && GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
  2509.                 {
  2510.                     if ( CanPlayHitAnim() && IsThreatened() )
  2511.                     {
  2512.                         CriticalEffectAnimationInterrupted("Dodge 1");
  2513.                         PushCombatActionOnBuffer( bufferAction, BS_Released );
  2514.                         ProcessCombatActionBuffer();                           
  2515.                     }
  2516.                     else
  2517.                         PushCombatActionOnBuffer( bufferAction, BS_Released );
  2518.                 }
  2519.                
  2520.                 else if ( !( IsCurrentSignChanneled() ) )
  2521.                 {
  2522.                    
  2523.                     PushCombatActionOnBuffer( bufferAction, BS_Released );
  2524.                 }
  2525.             }
  2526.             else
  2527.             {
  2528.                 if ( IsInCombatAction() && GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
  2529.                 {
  2530.                     if ( CanPlayHitAnim() && IsThreatened() )
  2531.                     {
  2532.                         CriticalEffectAnimationInterrupted("Dodge 3");
  2533.                         PushCombatActionOnBuffer( bufferAction, BS_Released );
  2534.                         ProcessCombatActionBuffer();                           
  2535.                     }
  2536.                     else
  2537.                         PushCombatActionOnBuffer( bufferAction, BS_Released );
  2538.                 }
  2539.                 LogChannel( 'InputNotAllowed', "InputNotAllowed" );
  2540.             }
  2541.         }
  2542.         else
  2543.         {
  2544.             DisplayActionDisallowedHudMessage(EIAB_Dodge);
  2545.         }
  2546.     }
  2547.        
  2548.    
  2549.     public function ProcessCombatActionBuffer() : bool
  2550.     {
  2551.         var action              : EBufferActionType         = this.BufferCombatAction;
  2552.         var stage               : EButtonStage              = this.BufferButtonStage;      
  2553.         var throwStage          : EThrowStage;     
  2554.         var actionResult        : bool = true;
  2555.        
  2556.        
  2557.         if( isInFinisher )
  2558.         {
  2559.             return false;
  2560.         }
  2561.        
  2562.         if ( action != EBAT_SpecialAttack_Heavy )
  2563.             specialAttackCamera = false;           
  2564.        
  2565.        
  2566.         if(super.ProcessCombatActionBuffer())
  2567.             return true;       
  2568.            
  2569.         switch ( action )
  2570.         {          
  2571.             case EBAT_CastSign :
  2572.             {
  2573.                 switch ( stage )
  2574.                 {
  2575.                     case BS_Pressed :
  2576.                     {
  2577.  
  2578.  
  2579.  
  2580.  
  2581.    
  2582.    
  2583.                                 actionResult = this.CastSign();
  2584.                                 LogChannel('SignDebug', "CastSign()");
  2585.    
  2586.  
  2587.                     } break;
  2588.                    
  2589.                     default :
  2590.                     {
  2591.                         actionResult = false;
  2592.                     } break;
  2593.                 }
  2594.             } break;
  2595.            
  2596.             case EBAT_SpecialAttack_Light :
  2597.             {
  2598.                 switch ( stage )
  2599.                 {
  2600.                     case BS_Pressed :
  2601.                     {
  2602.                        
  2603.                         actionResult = this.OnPerformSpecialAttack( true, true );
  2604.                     } break;
  2605.                    
  2606.                     case BS_Released :
  2607.                     {                      
  2608.                         actionResult = this.OnPerformSpecialAttack( true, false );
  2609.                     } break;
  2610.                    
  2611.                     default :
  2612.                     {
  2613.                         actionResult = false;
  2614.                     } break;
  2615.                 }
  2616.             } break;
  2617.  
  2618.             case EBAT_SpecialAttack_Heavy :
  2619.             {
  2620.                 switch ( stage )
  2621.                 {
  2622.                     case BS_Pressed :
  2623.                     {
  2624.                        
  2625.                         actionResult = this.OnPerformSpecialAttack( false, true );
  2626.                     } break;
  2627.                    
  2628.                     case BS_Released :
  2629.                     {
  2630.                         actionResult = this.OnPerformSpecialAttack( false, false );
  2631.                     } break;
  2632.                    
  2633.                     default :
  2634.                     {
  2635.                         actionResult = false;
  2636.                     } break;
  2637.                 }
  2638.             } break;
  2639.            
  2640.             default:
  2641.                 return false;  
  2642.         }
  2643.        
  2644.        
  2645.         this.CleanCombatActionBuffer();
  2646.        
  2647.         if (actionResult)
  2648.         {
  2649.             SetCombatAction( action ) ;
  2650.         }
  2651.        
  2652.         return true;
  2653.     }
  2654.        
  2655.        
  2656.     event OnPerformSpecialAttack( isLightAttack : bool, enableAttack : bool ){}
  2657.    
  2658.     event OnPlayerTickTimer( deltaTime : float )
  2659.     {
  2660.         super.OnPlayerTickTimer( deltaTime );
  2661.        
  2662.         if ( !IsInCombat() )
  2663.         {
  2664.             fastAttackCounter = 0;
  2665.             heavyAttackCounter = 0;
  2666.         }      
  2667.     }
  2668.    
  2669.    
  2670.    
  2671.    
  2672.    
  2673.     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
  2674.     {
  2675.         var ret : bool;
  2676.         var skill : ESkill;
  2677.    
  2678.         ret = super.PrepareAttackAction(hitTarget, animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime, weaponEntity, attackAction);
  2679.        
  2680.         if(!ret)
  2681.             return false;
  2682.        
  2683.        
  2684.         if(attackAction.IsActionMelee())
  2685.         {          
  2686.             skill = SkillNameToEnum( attackAction.GetAttackTypeName() );
  2687.             if( skill != S_SUndefined && CanUseSkill(skill))
  2688.             {
  2689.                 if(IsLightAttack(animData.attackName))
  2690.                     fastAttackCounter += 1;
  2691.                 else
  2692.                     fastAttackCounter = 0;
  2693.                
  2694.                 if(IsHeavyAttack(animData.attackName))
  2695.                     heavyAttackCounter += 1;
  2696.                 else
  2697.                     heavyAttackCounter = 0;            
  2698.             }      
  2699.         }
  2700.        
  2701.         AddTimer('FastAttackCounterDecay',5.0);
  2702.         AddTimer('HeavyAttackCounterDecay',5.0);
  2703.        
  2704.         return true;
  2705.     }
  2706.    
  2707.     protected function TestParryAndCounter(data : CPreAttackEventData, weaponId : SItemUniqueId, out parried : bool, out countered : bool) : array<CActor>
  2708.     {
  2709.        
  2710.         if(SkillNameToEnum(attackActionName) == S_Sword_s02)
  2711.             data.Can_Parry_Attack = false;
  2712.            
  2713.         return super.TestParryAndCounter(data, weaponId, parried, countered);
  2714.     }
  2715.        
  2716.     private timer function FastAttackCounterDecay(delta : float, id : int)
  2717.     {
  2718.         fastAttackCounter = 0;
  2719.     }
  2720.    
  2721.     private timer function HeavyAttackCounterDecay(delta : float, id : int)
  2722.     {
  2723.         heavyAttackCounter = 0;
  2724.     }
  2725.        
  2726.    
  2727.     public function GetCraftingSchematicsNames() : array<name>      {return craftingSchematics;}
  2728.    
  2729.     public function RemoveAllCraftingSchematics()
  2730.     {
  2731.         craftingSchematics.Clear();
  2732.     }
  2733.    
  2734.    
  2735.     function AddCraftingSchematic( nam : name, optional isSilent : bool, optional skipTutorialUpdate : bool ) : bool
  2736.     {
  2737.         var i : int;
  2738.        
  2739.         if(!skipTutorialUpdate && ShouldProcessTutorial('TutorialCraftingGotRecipe'))
  2740.         {
  2741.             FactsAdd("tut_received_schematic");
  2742.         }
  2743.        
  2744.         for(i=0; i<craftingSchematics.Size(); i+=1)
  2745.         {
  2746.             if(craftingSchematics[i] == nam)
  2747.                 return false;
  2748.            
  2749.            
  2750.             if(StrCmp(craftingSchematics[i],nam) > 0)
  2751.             {
  2752.                 craftingSchematics.Insert(i,nam);
  2753.                 AddCraftingHudNotification( nam, isSilent );
  2754.                 theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_CraftingSchematics );
  2755.                 return true;
  2756.             }          
  2757.         }  
  2758.  
  2759.        
  2760.         craftingSchematics.PushBack(nam);
  2761.         AddCraftingHudNotification( nam, isSilent );
  2762.         theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_CraftingSchematics );
  2763.         return true;   
  2764.     }
  2765.    
  2766.     function AddCraftingHudNotification( nam : name, isSilent : bool )
  2767.     {
  2768.         var hud : CR4ScriptedHud;
  2769.         if( !isSilent )
  2770.         {
  2771.             hud = (CR4ScriptedHud)theGame.GetHud();
  2772.             if( hud )
  2773.             {
  2774.                 hud.OnCraftingSchematicUpdate( nam );
  2775.             }
  2776.         }
  2777.     }  
  2778.    
  2779.     function AddAlchemyHudNotification( nam : name, isSilent : bool )
  2780.     {
  2781.         var hud : CR4ScriptedHud;
  2782.         if( !isSilent )
  2783.         {
  2784.             hud = (CR4ScriptedHud)theGame.GetHud();
  2785.             if( hud )
  2786.             {
  2787.                 hud.OnAlchemySchematicUpdate( nam );
  2788.             }
  2789.         }
  2790.     }
  2791.    
  2792.         if( !SSS_IsMutationEquipped( mutationType, SSS_GetEquippedMutationType() ) ) //zur13 modSSS
  2793.    
  2794.    
  2795.    
  2796.    
  2797.    
  2798.    
  2799.     public function GetAlchemyRecipes() : array<name>
  2800.     {
  2801.         return alchemyRecipes;
  2802.     }
  2803.        
  2804.     public function CanLearnAlchemyRecipe(recipeName : name) : bool
  2805.     {
  2806.         var dm : CDefinitionsManagerAccessor;
  2807.         var recipeNode : SCustomNode;
  2808.         var i, tmpInt : int;
  2809.         var tmpName : name;
  2810.    
  2811.         dm = theGame.GetDefinitionsManager();
  2812.         if ( dm.GetSubNodeByAttributeValueAsCName( recipeNode, 'alchemy_recipes', 'name_name', recipeName ) )
  2813.         {
  2814.             return true;
  2815.            
  2816.         }
  2817.        
  2818.         return false;
  2819.     }
  2820.    
  2821.     private final function RemoveAlchemyRecipe(recipeName : name)
  2822.     {
  2823.         alchemyRecipes.Remove(recipeName);
  2824.     }
  2825.    
  2826.     private final function RemoveAllAlchemyRecipes()
  2827.     {
  2828.         alchemyRecipes.Clear();
  2829.     }
  2830.  
  2831.    
  2832.     function AddAlchemyRecipe(nam : name, optional isSilent : bool, optional skipTutorialUpdate : bool) : bool
  2833.     {
  2834.         var i, potions, bombs : int;
  2835.         var found : bool;
  2836.         var m_alchemyManager : W3AlchemyManager;
  2837.         var recipe : SAlchemyRecipe;
  2838.         var knownBombTypes : array<string>;
  2839.         var strRecipeName, recipeNameWithoutLevel : string;
  2840.        
  2841.         if(!IsAlchemyRecipe(nam))
  2842.             return false;
  2843.        
  2844.         found = false;
  2845.         for(i=0; i<alchemyRecipes.Size(); i+=1)
  2846.         {
  2847.             if(alchemyRecipes[i] == nam)
  2848.                 return false;
  2849.            
  2850.            
  2851.             if(StrCmp(alchemyRecipes[i],nam) > 0)
  2852.             {
  2853.                 alchemyRecipes.Insert(i,nam);
  2854.                 found = true;
  2855.                 AddAlchemyHudNotification(nam,isSilent);
  2856.                 break;
  2857.             }          
  2858.         }  
  2859.  
  2860.         if(!found)
  2861.         {
  2862.             alchemyRecipes.PushBack(nam);
  2863.             AddAlchemyHudNotification(nam,isSilent);
  2864.         }
  2865.        
  2866.         m_alchemyManager = new W3AlchemyManager in this;
  2867.         m_alchemyManager.Init(alchemyRecipes);
  2868.         m_alchemyManager.GetRecipe(nam, recipe);
  2869.            
  2870.        
  2871.         if(CanUseSkill(S_Alchemy_s18))
  2872.         {
  2873.             if ((recipe.cookedItemType != EACIT_Bolt) && (recipe.cookedItemType != EACIT_Undefined) && (recipe.level <= GetSkillLevel(S_Alchemy_s18)))
  2874.                 AddAbility(SkillEnumToName(S_Alchemy_s18), true);
  2875.            
  2876.         }
  2877.        
  2878.        
  2879.         potions = 0;
  2880.         bombs = 0;
  2881.         for(i=0; i<alchemyRecipes.Size(); i+=1)
  2882.         {
  2883.             m_alchemyManager.GetRecipe(alchemyRecipes[i], recipe);
  2884.            
  2885.            
  2886.             if(recipe.cookedItemType == EACIT_Potion || recipe.cookedItemType == EACIT_MutagenPotion || recipe.cookedItemType == EACIT_Alcohol || recipe.cookedItemType == EACIT_Quest)
  2887.             {
  2888.                 potions += 1;
  2889.             }
  2890.            
  2891.             else if(recipe.cookedItemType == EACIT_Bomb)
  2892.             {
  2893.                 strRecipeName = NameToString(alchemyRecipes[i]);
  2894.                 recipeNameWithoutLevel = StrLeft(strRecipeName, StrLen(strRecipeName)-2);
  2895.                 if(!knownBombTypes.Contains(recipeNameWithoutLevel))
  2896.                 {
  2897.                     bombs += 1;
  2898.                     knownBombTypes.PushBack(recipeNameWithoutLevel);
  2899.                 }
  2900.             }
  2901.         }      
  2902.         theGame.GetGamerProfile().SetStat(ES_KnownPotionRecipes, potions);
  2903.         theGame.GetGamerProfile().SetStat(ES_KnownBombRecipes, bombs);
  2904.         theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_AlchemyRecipe );
  2905.                
  2906.         return true;
  2907.     }
  2908.    
  2909.    
  2910.    
  2911.    
  2912.    
  2913.    
  2914.    
  2915.     public function GetDisplayHeavyAttackIndicator() : bool
  2916.     {
  2917.         return bDispalyHeavyAttackIndicator;
  2918.     }
  2919.  
  2920.     public function SetDisplayHeavyAttackIndicator( val : bool )
  2921.     {
  2922.         bDispalyHeavyAttackIndicator = val;
  2923.     }
  2924.  
  2925.     public function GetDisplayHeavyAttackFirstLevelTimer() : bool
  2926.     {
  2927.         return bDisplayHeavyAttackFirstLevelTimer;
  2928.     }
  2929.  
  2930.     public function SetDisplayHeavyAttackFirstLevelTimer( val : bool )
  2931.     {
  2932.         bDisplayHeavyAttackFirstLevelTimer = val;
  2933.     }
  2934.    
  2935.    
  2936.    
  2937.    
  2938.    
  2939.    
  2940.  
  2941.     public function SelectQuickslotItem( slot : EEquipmentSlots )
  2942.     {
  2943.         var item : SItemUniqueId;
  2944.    
  2945.         GetItemEquippedOnSlot(slot, item);
  2946.         selectedItemId = item;         
  2947.     }  
  2948.    
  2949.    
  2950.    
  2951.    
  2952.    
  2953.    
  2954.    
  2955.     public function GetMedallion() : W3MedallionController
  2956.     {
  2957.         if ( !medallionController )
  2958.         {
  2959.             medallionController = new W3MedallionController in this;
  2960.         }
  2961.         return medallionController;
  2962.     }
  2963.    
  2964.    
  2965.     public final function HighlightObjects(range : float, optional highlightTime : float )
  2966.     {
  2967.         var ents : array<CGameplayEntity>;
  2968.         var i : int;
  2969.  
  2970.         FindGameplayEntitiesInSphere(ents, GetWorldPosition(), range, 100, 'HighlightedByMedalionFX', FLAG_ExcludePlayer);
  2971.  
  2972.         if(highlightTime == 0)
  2973.             highlightTime = 30;
  2974.        
  2975.         for(i=0; i<ents.Size(); i+=1)
  2976.         {
  2977.             if(!ents[i].IsHighlighted())
  2978.             {
  2979.                 ents[i].SetHighlighted( true );
  2980.                 ents[i].PlayEffectSingle( 'medalion_detection_fx' );
  2981.                 ents[i].AddTimer( 'MedallionEffectOff', highlightTime );
  2982.             }
  2983.         }
  2984.     }
  2985.    
  2986.    
  2987.     public final function HighlightEnemies(range : float, optional highlightTime : float )
  2988.     {
  2989.         var ents : array<CGameplayEntity>;
  2990.         var i : int;
  2991.         var catComponent : CGameplayEffectsComponent;
  2992.  
  2993.         FindGameplayEntitiesInSphere(ents, GetWorldPosition(), range, 100, , FLAG_ExcludePlayer + FLAG_OnlyAliveActors);
  2994.  
  2995.         if(highlightTime == 0)
  2996.             highlightTime = 5;
  2997.        
  2998.         for(i=0; i<ents.Size(); i+=1)
  2999.         {
  3000.             if(IsRequiredAttitudeBetween(this, ents[i], true))
  3001.             {
  3002.                 catComponent = GetGameplayEffectsComponent(ents[i]);
  3003.                 if(catComponent)
  3004.                 {
  3005.                     catComponent.SetGameplayEffectFlag(EGEF_CatViewHiglight, true);
  3006.                     ents[i].AddTimer( 'EnemyHighlightOff', highlightTime );
  3007.                 }
  3008.             }
  3009.         }
  3010.     }  
  3011.    
  3012.     function SpawnMedallionEntity()
  3013.     {
  3014.         var rot                 : EulerAngles;
  3015.         var spawnedMedallion    : CEntity;
  3016.                
  3017.         spawnedMedallion = theGame.GetEntityByTag( 'new_Witcher_medallion_FX' );
  3018.        
  3019.         if ( !spawnedMedallion )
  3020.             theGame.CreateEntity( medallionEntity, GetWorldPosition(), rot, true, false );
  3021.     }
  3022.    
  3023.    
  3024.    
  3025.    
  3026.    
  3027.    
  3028.    
  3029.    
  3030.    
  3031.     public final function InterruptCombatFocusMode()
  3032.     {
  3033.         if( this.GetCurrentStateName() == 'CombatFocusMode_SelectSpot' )
  3034.         {  
  3035.             SetCanPlayHitAnim( true );
  3036.             PopState();
  3037.         }
  3038.     }
  3039.    
  3040.    
  3041.    
  3042.    
  3043.    
  3044.     private saved var selectedPotionSlotUpper, selectedPotionSlotLower : EEquipmentSlots;
  3045.     private var potionDoubleTapTimerRunning, potionDoubleTapSlotIsUpper : bool;
  3046.         default selectedPotionSlotUpper = EES_Potion1;
  3047.         default selectedPotionSlotLower = EES_Potion2;
  3048.         default potionDoubleTapTimerRunning = false;
  3049.    
  3050.     public final function SetPotionDoubleTapRunning(b : bool, optional isUpperSlot : bool)
  3051.     {
  3052.         if(b)
  3053.         {
  3054.             AddTimer('PotionDoubleTap', 0.3);
  3055.         }
  3056.         else
  3057.         {
  3058.             RemoveTimer('PotionDoubleTap');
  3059.         }
  3060.        
  3061.         potionDoubleTapTimerRunning = b;
  3062.         potionDoubleTapSlotIsUpper = isUpperSlot;
  3063.     }
  3064.    
  3065.     public final function IsPotionDoubleTapRunning() : bool
  3066.     {
  3067.         return potionDoubleTapTimerRunning;
  3068.     }
  3069.    
  3070.     timer function PotionDoubleTap(dt : float, id : int)
  3071.     {
  3072.         potionDoubleTapTimerRunning = false;
  3073.         OnPotionDrinkInput(potionDoubleTapSlotIsUpper);
  3074.     }
  3075.    
  3076.     public final function OnPotionDrinkInput(fromUpperSlot : bool)
  3077.     {
  3078.         var slot : EEquipmentSlots;
  3079.        
  3080.         if(fromUpperSlot)
  3081.             slot = GetSelectedPotionSlotUpper();
  3082.         else
  3083.             slot = GetSelectedPotionSlotLower();
  3084.            
  3085.         DrinkPotionFromSlot(slot);
  3086.     }
  3087.    
  3088.     public final function OnPotionDrinkKeyboardsInput(slot : EEquipmentSlots)
  3089.     {
  3090.         DrinkPotionFromSlot(slot);
  3091.     }
  3092.    
  3093.     private function DrinkPotionFromSlot(slot : EEquipmentSlots):void
  3094.     {
  3095.         var item : SItemUniqueId;      
  3096.         var hud : CR4ScriptedHud;
  3097.         var module : CR4HudModuleItemInfo;
  3098.        
  3099.         GetItemEquippedOnSlot(slot, item);
  3100.         if(inv.ItemHasTag(item, 'Edibles'))
  3101.         {
  3102.             ConsumeItem( item );
  3103.         }
  3104.         else
  3105.         {          
  3106.             if (ToxicityLowEnoughToDrinkPotion(slot))
  3107.             {
  3108.                 DrinkPreparedPotion(slot);
  3109.             }
  3110.             else
  3111.             {
  3112.                 SendToxicityTooHighMessage();
  3113.             }
  3114.         }
  3115.        
  3116.         hud = (CR4ScriptedHud)theGame.GetHud();
  3117.         if ( hud )
  3118.         {
  3119.             module = (CR4HudModuleItemInfo)hud.GetHudModule("ItemInfoModule");
  3120.             if( module )
  3121.             {
  3122.                 module.ForceShowElement();
  3123.             }
  3124.         }
  3125.     }
  3126.    
  3127.     private function SendToxicityTooHighMessage()
  3128.     {
  3129.         var messageText : string;
  3130.         var language : string;
  3131.         var audioLanguage : string;
  3132.        
  3133.         if (GetHudMessagesSize() < 2)
  3134.         {
  3135.             messageText = GetLocStringByKeyExt("menu_cannot_perform_action_now") + " " + GetLocStringByKeyExt("panel_common_statistics_tooltip_current_toxicity");
  3136.            
  3137.             theGame.GetGameLanguageName(audioLanguage,language);
  3138.             if (language == "AR")
  3139.             {
  3140.                 messageText += (int)(abilityManager.GetStat(BCS_Toxicity, false)) + " / " +  (int)(abilityManager.GetStatMax(BCS_Toxicity)) + " :";
  3141.             }
  3142.             else
  3143.             {
  3144.                 messageText += ": " + (int)(abilityManager.GetStat(BCS_Toxicity, false)) + " / " +  (int)(abilityManager.GetStatMax(BCS_Toxicity));
  3145.             }
  3146.            
  3147.             DisplayHudMessage(messageText);
  3148.         }
  3149.         theSound.SoundEvent("gui_global_denied");
  3150.     }
  3151.    
  3152.     public final function GetSelectedPotionSlotUpper() : EEquipmentSlots
  3153.     {
  3154.         return selectedPotionSlotUpper;
  3155.     }
  3156.    
  3157.     public final function GetSelectedPotionSlotLower() : EEquipmentSlots
  3158.     {
  3159.         return selectedPotionSlotLower;
  3160.     }
  3161.    
  3162.    
  3163.     public final function FlipSelectedPotion(isUpperSlot : bool) : bool
  3164.     {
  3165.         if(isUpperSlot)
  3166.         {
  3167.             if(selectedPotionSlotUpper == EES_Potion1 && IsAnyItemEquippedOnSlot(EES_Potion3))
  3168.             {
  3169.                 selectedPotionSlotUpper = EES_Potion3;
  3170.                 return true;
  3171.             }
  3172.             else if(selectedPotionSlotUpper == EES_Potion3 && IsAnyItemEquippedOnSlot(EES_Potion1))
  3173.             {
  3174.                 selectedPotionSlotUpper = EES_Potion1;
  3175.                 return true;
  3176.             }
  3177.         }
  3178.         else
  3179.         {
  3180.             if(selectedPotionSlotLower == EES_Potion2 && IsAnyItemEquippedOnSlot(EES_Potion4))
  3181.             {
  3182.                 selectedPotionSlotLower = EES_Potion4;
  3183.                 return true;
  3184.             }
  3185.             else if(selectedPotionSlotLower == EES_Potion4 && IsAnyItemEquippedOnSlot(EES_Potion2))
  3186.             {
  3187.                 selectedPotionSlotLower = EES_Potion2;
  3188.                 return true;
  3189.             }
  3190.         }
  3191.        
  3192.         return false;
  3193.     }
  3194.    
  3195.     public final function AddBombThrowDelay(bombId : SItemUniqueId)
  3196.     {
  3197.         var slot : EEquipmentSlots;
  3198.        
  3199.         slot = GetItemSlot(bombId);
  3200.        
  3201.         if(slot == EES_Unused)
  3202.             return;
  3203.            
  3204.         if(slot == EES_Petard1 || slot == EES_Quickslot1)
  3205.         {
  3206.             remainingBombThrowDelaySlot1 = theGame.params.BOMB_THROW_DELAY;
  3207.             AddTimer('BombDelay1', 0.1, true);
  3208.         }
  3209.         else if(slot == EES_Petard2 || slot == EES_Quickslot2)
  3210.         {
  3211.             remainingBombThrowDelaySlot2 = theGame.params.BOMB_THROW_DELAY;
  3212.             AddTimer('BombDelay2', 0.1, true);
  3213.         }
  3214.     }
  3215.    
  3216.     public final function GetBombDelay(slot : EEquipmentSlots) : float
  3217.     {
  3218.         if(slot == EES_Petard1 || slot == EES_Quickslot1)
  3219.             return remainingBombThrowDelaySlot1;
  3220.         else if(slot == EES_Petard2 || slot == EES_Quickslot2)
  3221.             return remainingBombThrowDelaySlot2;
  3222.            
  3223.         return 0;
  3224.     }
  3225.    
  3226.     timer function BombDelay1(dt : float, id : int)
  3227.     {
  3228.         remainingBombThrowDelaySlot1 -= dt;
  3229.        
  3230.         if(remainingBombThrowDelaySlot1 <= 0)
  3231.             RemoveTimer('BombDelay1');
  3232.     }
  3233.    
  3234.     timer function BombDelay2(dt : float, id : int)
  3235.     {
  3236.         remainingBombThrowDelaySlot2 -= dt;
  3237.        
  3238.         if(remainingBombThrowDelaySlot2 <= 0)
  3239.             RemoveTimer('BombDelay2');
  3240.     }
  3241.    
  3242.     public function ResetCharacterDev()
  3243.     {
  3244.        
  3245.         UnequipItemFromSlot(EES_SkillMutagen1);
  3246.         UnequipItemFromSlot(EES_SkillMutagen2);
  3247.         UnequipItemFromSlot(EES_SkillMutagen3);
  3248.         UnequipItemFromSlot(EES_SkillMutagen4);
  3249.         SSS_UnequipAllMutagens(); //zur13 modSSS mutTabs
  3250.         levelManager.ResetCharacterDev();
  3251.         ((W3PlayerAbilityManager)abilityManager).ResetCharacterDev();      
  3252.     }
  3253.    
  3254.     public function ConsumeItem( itemId : SItemUniqueId ) : bool
  3255.     {
  3256.         var itemName : name;
  3257.         var removedItem, willRemoveItem : bool;
  3258.         var edibles : array<SItemUniqueId>;
  3259.         var toSlot : EEquipmentSlots;
  3260.         var i : int;
  3261.         var equippedNewEdible : bool;
  3262.        
  3263.         itemName = inv.GetItemName( itemId );
  3264.        
  3265.         if (itemName == 'q111_imlerith_acorn' )
  3266.         {
  3267.             AddPoints(ESkillPoint, 2, true);
  3268.             removedItem = inv.RemoveItem( itemId, 1 );
  3269.             theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt("panel_character_popup_title_buy_skill") + "<br>" + GetLocStringByKeyExt("panel_character_availablepoints") + " +2");
  3270.             theSound.SoundEvent("gui_character_buy_skill");
  3271.         }
  3272.         else if ( itemName == 'Clearing Potion' )
  3273.         {
  3274.             ResetCharacterDev();
  3275.             removedItem = inv.RemoveItem( itemId, 1 );
  3276.             theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt("panel_character_popup_character_cleared") );
  3277.             theSound.SoundEvent("gui_character_synergy_effect");
  3278.         }
  3279.         else if(itemName == 'Wolf Hour')
  3280.         {
  3281.             removedItem = inv.RemoveItem( itemId, 1 );
  3282.             theSound.SoundEvent("gui_character_synergy_effect");
  3283.             AddEffectDefault(EET_WolfHour, thePlayer, 'wolf hour');
  3284.         }
  3285.         else
  3286.         {
  3287.             willRemoveItem = inv.GetItemQuantity(itemId) == 1 && !inv.ItemHasTag(itemId, 'InfiniteUse');
  3288.            
  3289.             if(willRemoveItem)
  3290.                 toSlot = GetItemSlot(itemId);
  3291.                
  3292.             removedItem = super.ConsumeItem(itemId);
  3293.            
  3294.             if(willRemoveItem && removedItem)
  3295.             {
  3296.                 edibles = inv.GetItemsByTag('Edibles');
  3297.                 equippedNewEdible = false;
  3298.                
  3299.                
  3300.                 for(i=0; i<edibles.Size(); i+=1)
  3301.                 {
  3302.                     if(!IsItemEquipped(edibles[i]) && !inv.ItemHasTag(edibles[i], 'Alcohol') && inv.GetItemName(edibles[i]) != 'Clearing Potion' && inv.GetItemName(edibles[i]) != 'Wolf Hour')
  3303.                     {
  3304.                         EquipItemInGivenSlot(edibles[i], toSlot, true, false);
  3305.                         equippedNewEdible = true;
  3306.                         break;
  3307.                     }
  3308.                 }
  3309.                
  3310.                
  3311.                 if(!equippedNewEdible)
  3312.                 {
  3313.                     for(i=0; i<edibles.Size(); i+=1)
  3314.                     {
  3315.                         if(!IsItemEquipped(edibles[i]) && inv.GetItemName(edibles[i]) != 'Clearing Potion' && inv.GetItemName(edibles[i]) != 'Wolf Hour')
  3316.                         {
  3317.                             EquipItemInGivenSlot(edibles[i], toSlot, true, false);
  3318.                             break;
  3319.                         }
  3320.                     }
  3321.                 }
  3322.             }
  3323.         }
  3324.        
  3325.         return removedItem;
  3326.     }
  3327.    
  3328.    
  3329.     public final function GetAlcoholForAlchemicalItemsRefill() : SItemUniqueId
  3330.     {
  3331.         var alcos : array<SItemUniqueId>;
  3332.         var id : SItemUniqueId;
  3333.         var i, price, minPrice : int;
  3334.        
  3335.         alcos = inv.GetItemsByTag(theGame.params.TAG_ALCHEMY_REFILL_ALCO);
  3336.        
  3337.         if(alcos.Size() > 0)
  3338.         {
  3339.             if(inv.ItemHasTag(alcos[0], theGame.params.TAG_INFINITE_USE))
  3340.                 return alcos[0];
  3341.                
  3342.             minPrice = inv.GetItemPrice(alcos[0]);
  3343.             price = minPrice;
  3344.             id = alcos[0];
  3345.            
  3346.             for(i=1; i<alcos.Size(); i+=1)
  3347.             {
  3348.                 if(inv.ItemHasTag(alcos[i], theGame.params.TAG_INFINITE_USE))
  3349.                     return alcos[i];
  3350.                
  3351.                 price = inv.GetItemPrice(alcos[i]);
  3352.                
  3353.                 if(price < minPrice)
  3354.                 {
  3355.                     minPrice = price;
  3356.                     id = alcos[i];
  3357.                 }
  3358.             }
  3359.            
  3360.             return id;
  3361.         }
  3362.        
  3363.         return GetInvalidUniqueId();
  3364.     }
  3365.    
  3366.     public final function ClearPreviouslyUsedBolt()
  3367.     {
  3368.         previouslyUsedBolt = GetInvalidUniqueId();
  3369.     }
  3370.    
  3371.    
  3372.     public final function AddAndEquipInfiniteBolt(optional forceBodkin : bool, optional forceHarpoon : bool)
  3373.     {
  3374.         var bolt, bodkins, harpoons : array<SItemUniqueId>;
  3375.         var boltItemName : name;
  3376.         var i : int;
  3377.        
  3378.        
  3379.         bodkins = inv.GetItemsByName('Bodkin Bolt');
  3380.         harpoons = inv.GetItemsByName('Harpoon Bolt');
  3381.        
  3382.         for(i=bodkins.Size()-1; i>=0; i-=1)
  3383.             inv.RemoveItem(bodkins[i], inv.GetItemQuantity(bodkins[i]) );
  3384.            
  3385.         for(i=harpoons.Size()-1; i>=0; i-=1)
  3386.             inv.RemoveItem(harpoons[i], inv.GetItemQuantity(harpoons[i]) );
  3387.            
  3388.        
  3389.        
  3390.         if(!forceBodkin && (forceHarpoon || GetCurrentStateName() == 'Swimming' || IsSwimming() || IsDiving()) )
  3391.         {
  3392.             boltItemName = 'Harpoon Bolt';
  3393.         }
  3394.         else
  3395.         {
  3396.             boltItemName = 'Bodkin Bolt';
  3397.         }
  3398.        
  3399.        
  3400.         if(boltItemName == 'Bodkin Bolt' && inv.IsIdValid(previouslyUsedBolt))
  3401.         {
  3402.             bolt.PushBack(previouslyUsedBolt);
  3403.         }
  3404.         else
  3405.         {
  3406.            
  3407.             bolt = inv.AddAnItem(boltItemName, 1, true, true);
  3408.            
  3409.            
  3410.             if(boltItemName == 'Harpoon Bolt')
  3411.             {
  3412.                 GetItemEquippedOnSlot(EES_Bolt, previouslyUsedBolt);
  3413.             }
  3414.         }
  3415.        
  3416.         EquipItem(bolt[0], EES_Bolt);
  3417.     }
  3418.    
  3419.    
  3420.     event OnItemGiven(data : SItemChangedData)
  3421.     {
  3422.         var m_guiManager    : CR4GuiManager;
  3423.        
  3424.         super.OnItemGiven(data);
  3425.        
  3426.        
  3427.         if(!inv)
  3428.             inv = GetInventory();
  3429.        
  3430.        
  3431.         if(inv.IsItemEncumbranceItem(data.ids[0]))
  3432.             UpdateEncumbrance();
  3433.        
  3434.         m_guiManager = theGame.GetGuiManager();
  3435.         if(m_guiManager)
  3436.             m_guiManager.RegisterNewItem(data.ids[0])
  3437.     }
  3438.        
  3439.    
  3440.     public final function CheckForFullyArmedAchievement()
  3441.     {
  3442.         if( HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_BEAR) || HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_GRYPHON) ||
  3443.             HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_LYNX) || HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_WOLF)
  3444.         )
  3445.         {
  3446.             theGame.GetGamerProfile().AddAchievement(EA_FullyArmed);
  3447.         }
  3448.     }
  3449.    
  3450.    
  3451.     public final function HasAllItemsFromSet(setItemTag : name) : bool
  3452.     {
  3453.         var item : SItemUniqueId;
  3454.        
  3455.         if(!GetItemEquippedOnSlot(EES_SteelSword, item) || !inv.ItemHasTag(item, setItemTag))
  3456.             return false;
  3457.        
  3458.         if(!GetItemEquippedOnSlot(EES_SilverSword, item) || !inv.ItemHasTag(item, setItemTag))
  3459.             return false;
  3460.            
  3461.         if(!GetItemEquippedOnSlot(EES_Boots, item) || !inv.ItemHasTag(item, setItemTag))
  3462.             return false;
  3463.            
  3464.         if(!GetItemEquippedOnSlot(EES_Pants, item) || !inv.ItemHasTag(item, setItemTag))
  3465.             return false;
  3466.            
  3467.         if(!GetItemEquippedOnSlot(EES_Gloves, item) || !inv.ItemHasTag(item, setItemTag))
  3468.             return false;
  3469.            
  3470.         if(!GetItemEquippedOnSlot(EES_Armor, item) || !inv.ItemHasTag(item, setItemTag))
  3471.             return false;
  3472.            
  3473.        
  3474.         if(setItemTag == theGame.params.ITEM_SET_TAG_BEAR || setItemTag == theGame.params.ITEM_SET_TAG_LYNX)
  3475.         {
  3476.             if(!GetItemEquippedOnSlot(EES_RangedWeapon, item) || !inv.ItemHasTag(item, setItemTag))
  3477.                 return false;
  3478.         }
  3479.  
  3480.         return true;
  3481.     }
  3482.    
  3483.    
  3484.    
  3485.    
  3486.     public function GetTotalArmor() : SAbilityAttributeValue
  3487.     {
  3488.         var armor : SAbilityAttributeValue;
  3489.         var armorItem : SItemUniqueId;
  3490.        
  3491.         armor = super.GetTotalArmor();
  3492.        
  3493.         if(GetItemEquippedOnSlot(EES_Armor, armorItem))
  3494.         {
  3495.            
  3496.             armor -= inv.GetItemAttributeValue(armorItem, theGame.params.ARMOR_VALUE_NAME);
  3497.            
  3498.            
  3499.             armor += inv.GetItemArmorTotal(armorItem);         
  3500.         }
  3501.        
  3502.         if(GetItemEquippedOnSlot(EES_Pants, armorItem))
  3503.         {
  3504.            
  3505.             armor -= inv.GetItemAttributeValue(armorItem, theGame.params.ARMOR_VALUE_NAME);
  3506.            
  3507.            
  3508.             armor += inv.GetItemArmorTotal(armorItem);         
  3509.         }
  3510.            
  3511.         if(GetItemEquippedOnSlot(EES_Boots, armorItem))
  3512.         {
  3513.            
  3514.             armor -= inv.GetItemAttributeValue(armorItem, theGame.params.ARMOR_VALUE_NAME);
  3515.            
  3516.            
  3517.             armor += inv.GetItemArmorTotal(armorItem);         
  3518.         }
  3519.            
  3520.         if(GetItemEquippedOnSlot(EES_Gloves, armorItem))
  3521.         {
  3522.            
  3523.             armor -= inv.GetItemAttributeValue(armorItem, theGame.params.ARMOR_VALUE_NAME);
  3524.            
  3525.            
  3526.             armor += inv.GetItemArmorTotal(armorItem);         
  3527.         }
  3528.            
  3529.         return armor;
  3530.     }
  3531.    
  3532.    
  3533.    
  3534.     public function ReduceArmorDurability() : EEquipmentSlots
  3535.     {
  3536.         var r, sum : int;
  3537.         var slot : EEquipmentSlots;
  3538.         var id : SItemUniqueId;
  3539.         var prevDurMult, currDurMult, ratio : float;
  3540.    
  3541.        
  3542.         sum = theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT;
  3543.         sum += theGame.params.DURABILITY_ARMOR_PANTS_WEIGHT;
  3544.         sum += theGame.params.DURABILITY_ARMOR_GLOVES_WEIGHT;
  3545.         sum += theGame.params.DURABILITY_ARMOR_BOOTS_WEIGHT;
  3546.         sum += theGame.params.DURABILITY_ARMOR_MISS_WEIGHT;
  3547.        
  3548.         r = RandRange(sum);
  3549.        
  3550.         if(r < theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT)
  3551.             slot = EES_Armor;
  3552.         else if (r < theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT + theGame.params.DURABILITY_ARMOR_PANTS_WEIGHT)
  3553.             slot = EES_Pants;
  3554.         else if (r < theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT + theGame.params.DURABILITY_ARMOR_PANTS_WEIGHT + theGame.params.DURABILITY_ARMOR_GLOVES_WEIGHT)
  3555.             slot = EES_Gloves;
  3556.         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)
  3557.             slot = EES_Boots;
  3558.         else
  3559.             return EES_InvalidSlot;                
  3560.        
  3561.         GetItemEquippedOnSlot(slot, id);               
  3562.         ratio = inv.GetItemDurabilityRatio(id);    
  3563.         if(inv.ReduceItemDurability(id))           
  3564.         {
  3565.             prevDurMult = theGame.params.GetDurabilityMultiplier(ratio, false);
  3566.            
  3567.             ratio = inv.GetItemDurabilityRatio(id);
  3568.             currDurMult = theGame.params.GetDurabilityMultiplier(ratio, false);
  3569.            
  3570.             if(currDurMult != prevDurMult)
  3571.             {
  3572.                
  3573.                
  3574.                
  3575.                
  3576.             }
  3577.                
  3578.             return slot;
  3579.         }
  3580.        
  3581.         return EES_InvalidSlot;
  3582.     }
  3583.    
  3584.    
  3585.     public function DismantleItem(dismantledItem : SItemUniqueId, toolItem : SItemUniqueId) : bool
  3586.     {
  3587.         var parts : array<SItemParts>;
  3588.         var i : int;
  3589.        
  3590.         if(!inv.IsItemDismantleKit(toolItem))
  3591.             return false;
  3592.        
  3593.         parts = inv.GetItemRecyclingParts(dismantledItem);
  3594.        
  3595.         if(parts.Size() <= 0)
  3596.             return false;
  3597.            
  3598.         for(i=0; i<parts.Size(); i+=1)
  3599.             inv.AddAnItem(parts[i].itemName, parts[i].quantity, true, false);
  3600.            
  3601.         inv.RemoveItem(toolItem);
  3602.         inv.RemoveItem(dismantledItem);
  3603.         return true;
  3604.     }
  3605.    
  3606.    
  3607.     public function GetItemEquippedOnSlot(slot : EEquipmentSlots, out item : SItemUniqueId) : bool
  3608.     {
  3609.         if(slot == EES_InvalidSlot || slot < 0 || slot > EnumGetMax('EEquipmentSlots'))
  3610.             return false;
  3611.        
  3612.         item = itemSlots[slot];
  3613.        
  3614.         return inv.IsIdValid(item);
  3615.     }
  3616.    
  3617.    
  3618.     public function GetItemSlotByItemName(itemName : name) : EEquipmentSlots
  3619.     {
  3620.         var ids : array<SItemUniqueId>;
  3621.         var i : int;
  3622.         var slot : EEquipmentSlots;
  3623.        
  3624.         ids = inv.GetItemsByName(itemName);
  3625.         for(i=0; i<ids.Size(); i+=1)
  3626.         {
  3627.             slot = GetItemSlot(ids[i]);
  3628.             if(slot != EES_InvalidSlot)
  3629.                 return slot;
  3630.         }
  3631.        
  3632.         return EES_InvalidSlot;
  3633.     }
  3634.    
  3635.    
  3636.     public function GetItemSlot(item : SItemUniqueId) : EEquipmentSlots
  3637.     {
  3638.         var i : int;
  3639.        
  3640.         if(!inv.IsIdValid(item))
  3641.             return EES_InvalidSlot;
  3642.            
  3643.         for(i=0; i<itemSlots.Size(); i+=1)
  3644.             if(itemSlots[i] == item)
  3645.                 return i;
  3646.        
  3647.         return EES_InvalidSlot;
  3648.     }
  3649.    
  3650.     public function GetEquippedItems() : array<SItemUniqueId>
  3651.     {
  3652.         return itemSlots;
  3653.     }
  3654.    
  3655.     public function IsItemEquipped(item : SItemUniqueId) : bool
  3656.     {
  3657.         if(!inv.IsIdValid(item))
  3658.             return false;
  3659.            
  3660.         return itemSlots.Contains(item);
  3661.     }
  3662.  
  3663.     public function IsItemHeld(item : SItemUniqueId) : bool
  3664.     {
  3665.         if(!inv.IsIdValid(item))
  3666.             return false;
  3667.            
  3668.         return inv.IsItemHeld(item);
  3669.     }
  3670.  
  3671.    
  3672.     public function IsAnyItemEquippedOnSlot(slot : EEquipmentSlots) : bool
  3673.     {
  3674.         if(slot == EES_InvalidSlot || slot < 0 || slot > EnumGetMax('EEquipmentSlots'))
  3675.             return false;
  3676.            
  3677.         return inv.IsIdValid(itemSlots[slot]);
  3678.     }
  3679.    
  3680.    
  3681.     public function GetFreeQuickslot() : EEquipmentSlots
  3682.     {
  3683.         if(!inv.IsIdValid(itemSlots[EES_Quickslot1]))       return EES_Quickslot1;
  3684.         if(!inv.IsIdValid(itemSlots[EES_Quickslot2]))       return EES_Quickslot2;
  3685.        
  3686.        
  3687.         return EES_InvalidSlot;
  3688.     }
  3689.    
  3690.    
  3691.     event OnEquipItemRequested(item : SItemUniqueId, ignoreMount : bool)
  3692.     {
  3693.         var slot : EEquipmentSlots;
  3694.        
  3695.         if(inv.IsIdValid(item))
  3696.         {
  3697.             slot = inv.GetSlotForItemId(item);
  3698.                
  3699.             if (slot != EES_InvalidSlot)
  3700.             {
  3701.                
  3702.                
  3703.                 EquipItemInGivenSlot(item, slot, ignoreMount);
  3704.             }
  3705.         }
  3706.     }
  3707.    
  3708.     event OnUnequipItemRequested(item : SItemUniqueId)
  3709.     {
  3710.         UnequipItem(item);
  3711.     }
  3712.    
  3713.    
  3714.     public function EquipItem(item : SItemUniqueId, optional slot : EEquipmentSlots, optional toHand : bool) : bool
  3715.     {
  3716.         if(!inv.IsIdValid(item))
  3717.             return false;
  3718.            
  3719.         if(slot == EES_InvalidSlot)
  3720.         {
  3721.             slot = inv.GetSlotForItemId(item);
  3722.            
  3723.             if(slot == EES_InvalidSlot)
  3724.                 return false;
  3725.         }
  3726.        
  3727.         return EquipItemInGivenSlot(item, slot, false, toHand);
  3728.     }
  3729.    
  3730.     protected function ShouldMount(slot : EEquipmentSlots, item : SItemUniqueId, category : name):bool
  3731.     {
  3732.        
  3733.        
  3734.         return !IsSlotPotionMutagen(slot) && category != 'usable' && category != 'potion' && category != 'petard' && !inv.ItemHasTag(item, 'PlayerUnwearable');
  3735.     }
  3736.        
  3737.     protected function ShouldMountItemWithName( itemName: name ): bool
  3738.     {
  3739.         var slot : EEquipmentSlots;
  3740.         var items : array<SItemUniqueId>;
  3741.         var category : name;
  3742.         var i : int;
  3743.        
  3744.         items = inv.GetItemsByName( itemName );
  3745.        
  3746.         category = inv.GetItemCategory( items[0] );
  3747.        
  3748.         slot = GetItemSlot( items[0] );
  3749.        
  3750.         return ShouldMount( slot, items[0], category );
  3751.     }  
  3752.    
  3753.     public function GetMountableItems( out items : array< SItemUniqueId > )
  3754.     {
  3755.         var i : int;
  3756.         var mountable : bool;
  3757.         var mountableItems : array< SItemUniqueId >;
  3758.         var slot : EEquipmentSlots;
  3759.         var category : name;
  3760.         var item: SItemUniqueId;
  3761.        
  3762.         for ( i = 0; i < items.Size(); i += 1 )
  3763.         {
  3764.             item = items[i];
  3765.        
  3766.             category = inv.GetItemCategory( item );
  3767.        
  3768.             slot = GetItemSlot( item );
  3769.        
  3770.             mountable = ShouldMount( slot, item, category );
  3771.        
  3772.             if ( mountable )
  3773.             {
  3774.                 mountableItems.PushBack( items[ i ] );
  3775.             }
  3776.         }
  3777.         items = mountableItems;
  3778.     }
  3779.    
  3780.     public final function SwapEquippedItems(slot1 : EEquipmentSlots, slot2 : EEquipmentSlots)
  3781.     {
  3782.         var temp : SItemUniqueId;
  3783.         var pam : W3PlayerAbilityManager;
  3784.        
  3785.         temp = itemSlots[slot1];
  3786.         itemSlots[slot1] = itemSlots[slot2];
  3787.         itemSlots[slot2] = temp;
  3788.        
  3789.         if(IsSlotSkillMutagen(slot1))
  3790.         {
  3791.             pam = (W3PlayerAbilityManager)abilityManager;
  3792.             if(pam)
  3793.                 pam.OnSwappedMutagensPost(itemSlots[slot1], itemSlots[slot2]);
  3794.         }
  3795.     }
  3796.    
  3797.     public function EquipItemInGivenSlot(item : SItemUniqueId, slot : EEquipmentSlots, ignoreMounting : bool, optional toHand : bool) : bool
  3798.     {          
  3799.         var i, groupID : int;
  3800.         var fistsID : array<SItemUniqueId>;
  3801.         var pam : W3PlayerAbilityManager;
  3802.         var isSkillMutagen : bool;     
  3803.         var armorEntity : CItemEntity;
  3804.         var armorMeshComponent : CComponent;
  3805.         var armorSoundIdentification : name;
  3806.         var category : name;
  3807.         var prevSkillColor : ESkillColor;
  3808.         var containedAbilities : array<name>;
  3809.         var dm : CDefinitionsManagerAccessor;
  3810.         var armorType : EArmorType;
  3811.         var otherMask, previousItemInSlot : SItemUniqueId;
  3812.         var tutStatePot : W3TutorialManagerUIHandlerStatePotions;
  3813.         var tutStateFood : W3TutorialManagerUIHandlerStateFood;
  3814.         var tutStateSecondPotionEquip : W3TutorialManagerUIHandlerStateSecondPotionEquip;
  3815.         var boltItem : SItemUniqueId;
  3816.        
  3817.         if(!inv.IsIdValid(item))
  3818.         {
  3819.             LogAssert(false, "W3PlayerWitcher.EquipItemInGivenSlot: invalid item");
  3820.             return false;
  3821.         }
  3822.         if(slot == EES_InvalidSlot || slot == EES_HorseBlinders || slot == EES_HorseSaddle || slot == EES_HorseBag || slot == EES_HorseTrophy)
  3823.         {
  3824.             LogAssert(false, "W3PlayerWitcher.EquipItem: Cannot equip item <<" + inv.GetItemName(item) + ">> - provided slot <<" + slot + ">> is invalid");
  3825.             return false;
  3826.         }
  3827.         if(itemSlots[slot] == item)
  3828.         {
  3829.             return true;
  3830.         }  
  3831.        
  3832.         if(!HasRequiredLevelToEquipItem(item))
  3833.         {
  3834.            
  3835.             return false;
  3836.         }
  3837.        
  3838.         if(inv.ItemHasTag(item, 'PhantomWeapon') && !GetPhantomWeaponMgr())
  3839.         {
  3840.             InitPhantomWeaponMgr();
  3841.         }
  3842.        
  3843.        
  3844.         previousItemInSlot = itemSlots[slot];
  3845.         if( IsItemEquipped(item))
  3846.         {
  3847.             SwapEquippedItems(slot, GetItemSlot(item));
  3848.             return true;
  3849.         }
  3850.        
  3851.        
  3852.         isSkillMutagen = IsSlotSkillMutagen(slot);
  3853.         if(isSkillMutagen)
  3854.         {
  3855.             pam = (W3PlayerAbilityManager)abilityManager;
  3856.             if(!pam.IsSkillMutagenSlotUnlocked(slot))
  3857.             {
  3858.                 return false;
  3859.             }
  3860.         }
  3861.        
  3862.        
  3863.         if(inv.IsIdValid(previousItemInSlot))
  3864.         {          
  3865.             if(!UnequipItemFromSlot(slot, true))
  3866.             {
  3867.                 LogAssert(false, "W3PlayerWitcher.EquipItem: Cannot equip item <<" + inv.GetItemName(item) + ">> !!");
  3868.                 return false;
  3869.             }
  3870.         }
  3871.        
  3872.        
  3873.         if(inv.IsItemMask(item))
  3874.         {
  3875.             if(slot == EES_Quickslot1)
  3876.                 GetItemEquippedOnSlot(EES_Quickslot2, otherMask);
  3877.             else
  3878.                 GetItemEquippedOnSlot(EES_Quickslot1, otherMask);
  3879.                
  3880.             if(inv.IsItemMask(otherMask))
  3881.                 UnequipItem(otherMask);
  3882.         }
  3883.        
  3884.         if(isSkillMutagen)
  3885.         {
  3886.             groupID = pam.GetSkillGroupIdOfMutagenSlot(slot);
  3887.             prevSkillColor = pam.GetSkillGroupColor(groupID);
  3888.         }
  3889.        
  3890.         itemSlots[slot] = item;
  3891.        
  3892.         category = inv.GetItemCategory( item );
  3893.    
  3894.        
  3895.         if( !ignoreMounting && ShouldMount(slot, item, category) )
  3896.         {
  3897.            
  3898.             inv.MountItem( item, toHand, IsSlotSkillMutagen( slot ) );
  3899.         }      
  3900.        
  3901.         theTelemetry.LogWithLabelAndValue( TE_INV_ITEM_EQUIPPED, inv.GetItemName(item), slot );
  3902.                
  3903.         if(slot == EES_RangedWeapon)
  3904.         {          
  3905.             rangedWeapon = ( Crossbow )( inv.GetItemEntityUnsafe(item) );
  3906.             if(!rangedWeapon)
  3907.                 AddTimer('DelayedOnItemMount', 0.1, true);
  3908.            
  3909.             if ( IsSwimming() || IsDiving() )
  3910.             {
  3911.                 GetItemEquippedOnSlot(EES_Bolt, boltItem);
  3912.                
  3913.                 if(inv.IsIdValid(boltItem))
  3914.                 {
  3915.                     if ( !inv.ItemHasTag(boltItem, 'UnderwaterAmmo' ))
  3916.                     {
  3917.                         AddAndEquipInfiniteBolt(false, true);
  3918.                     }
  3919.                 }
  3920.                 else if(!IsAnyItemEquippedOnSlot(EES_Bolt))
  3921.                 {
  3922.                     AddAndEquipInfiniteBolt(false, true);
  3923.                 }
  3924.             }
  3925.            
  3926.             else if(!IsAnyItemEquippedOnSlot(EES_Bolt))
  3927.                 AddAndEquipInfiniteBolt();
  3928.         }
  3929.         else if(slot == EES_Bolt)
  3930.         {
  3931.             if(rangedWeapon)
  3932.             {   if ( !IsSwimming() || !IsDiving() )
  3933.                 {
  3934.                     rangedWeapon.OnReplaceAmmo();
  3935.                     rangedWeapon.OnWeaponReload();
  3936.                 }
  3937.                 else
  3938.                 {
  3939.                     DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_now" ));
  3940.                 }
  3941.             }
  3942.         }      
  3943.        
  3944.         else if(isSkillMutagen)
  3945.         {          
  3946.             pam.OnSkillMutagenEquipped(item, slot, prevSkillColor);
  3947.             LogSkillColors("Mutagen <<" + inv.GetItemName(item) + ">> equipped to slot <<" + slot + ">>");
  3948.             LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
  3949.             LogSkillColors("");
  3950.         }
  3951.         else if(slot == EES_Gloves && HasWeaponDrawn(false))
  3952.         {
  3953.             PlayRuneword4FX(PW_Steel);
  3954.             PlayRuneword4FX(PW_Silver);
  3955.         }
  3956.  
  3957.        
  3958.         if(inv.ItemHasAbility(item, 'MA_HtH'))
  3959.         {
  3960.             inv.GetItemContainedAbilities(item, containedAbilities);
  3961.             fistsID = inv.GetItemsByName('fists');
  3962.             dm = theGame.GetDefinitionsManager();
  3963.             for(i=0; i<containedAbilities.Size(); i+=1)
  3964.             {
  3965.                 if(dm.AbilityHasTag(containedAbilities[i], 'MA_HtH'))
  3966.                 {                  
  3967.                     inv.AddItemCraftedAbility(fistsID[0], containedAbilities[i], true);
  3968.                 }
  3969.             }
  3970.         }      
  3971.        
  3972.        
  3973.         if(inv.IsItemAnyArmor(item))
  3974.         {
  3975.             armorType = inv.GetArmorType(item);
  3976.             pam = (W3PlayerAbilityManager)abilityManager;
  3977.            
  3978.             if(armorType == EAT_Light)
  3979.             {
  3980.                 if(CanUseSkill(S_Perk_05))
  3981.                     pam.SetPerkArmorBonus(S_Perk_05);
  3982.             }
  3983.             else if(armorType == EAT_Medium)
  3984.             {
  3985.                 if(CanUseSkill(S_Perk_06))
  3986.                     pam.SetPerkArmorBonus(S_Perk_06);
  3987.             }
  3988.             else if(armorType == EAT_Heavy)
  3989.             {
  3990.                 if(CanUseSkill(S_Perk_07))
  3991.                     pam.SetPerkArmorBonus(S_Perk_07);
  3992.             }
  3993.         }
  3994.        
  3995.        
  3996.         theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnItemEquipped );
  3997.    
  3998.        
  3999.         if(ShouldProcessTutorial('TutorialPotionCanEquip3'))
  4000.         {
  4001.             if(IsSlotPotionSlot(slot))
  4002.             {
  4003.                 tutStatePot = (W3TutorialManagerUIHandlerStatePotions)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  4004.                 if(tutStatePot)
  4005.                 {
  4006.                     tutStatePot.OnPotionEquipped(inv.GetItemName(item));
  4007.                 }
  4008.                
  4009.                 tutStateSecondPotionEquip = (W3TutorialManagerUIHandlerStateSecondPotionEquip)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  4010.                 if(tutStateSecondPotionEquip)
  4011.                 {
  4012.                     tutStateSecondPotionEquip.OnPotionEquipped(inv.GetItemName(item));
  4013.                 }
  4014.                
  4015.             }
  4016.         }
  4017.        
  4018.         if(ShouldProcessTutorial('TutorialFoodSelectTab'))
  4019.         {
  4020.             if( IsSlotPotionSlot(slot) && inv.IsItemFood(item))
  4021.             {
  4022.                 tutStateFood = (W3TutorialManagerUIHandlerStateFood)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
  4023.                 if(tutStateFood)
  4024.                 {
  4025.                     tutStateFood.OnFoodEquipped();
  4026.                 }
  4027.             }
  4028.         }
  4029.        
  4030.        
  4031.         if(inv.IsItemSetItem(item))
  4032.         {
  4033.             CheckForFullyArmedAchievement();   
  4034.         }
  4035.        
  4036.         return true;
  4037.     }
  4038.  
  4039.     private function CheckHairItem()
  4040.     {
  4041.         var ids : array<SItemUniqueId>;
  4042.         var i   : int;
  4043.         var itemName : name;
  4044.         var hairApplied : bool;
  4045.        
  4046.         ids = inv.GetItemsByCategory('hair');
  4047.        
  4048.         for(i=0; i<ids.Size(); i+= 1)
  4049.         {
  4050.             itemName = inv.GetItemName( ids[i] );
  4051.            
  4052.             if( itemName != 'Preview Hair' )
  4053.             {
  4054.                 if( hairApplied == false )
  4055.                 {
  4056.                     inv.MountItem( ids[i], false );
  4057.                     hairApplied = true;
  4058.                 }
  4059.                 else
  4060.                 {
  4061.                     inv.RemoveItem( ids[i], 1 );
  4062.                 }
  4063.                
  4064.             }
  4065.         }
  4066.        
  4067.         if( hairApplied == false )
  4068.         {
  4069.             ids = inv.AddAnItem('Half With Tail Hairstyle', 1, true, false);
  4070.             inv.MountItem( ids[0], false );
  4071.         }
  4072.        
  4073.     }
  4074.  
  4075.    
  4076.     timer function DelayedOnItemMount( dt : float, id : int )
  4077.     {
  4078.         var crossbowID : SItemUniqueId;
  4079.         var invent : CInventoryComponent;
  4080.        
  4081.         invent = GetInventory();
  4082.         if(!invent)
  4083.             return;
  4084.        
  4085.        
  4086.         GetItemEquippedOnSlot(EES_RangedWeapon, crossbowID);
  4087.                
  4088.         if(invent.IsIdValid(crossbowID))
  4089.         {
  4090.            
  4091.             rangedWeapon = ( Crossbow )(invent.GetItemEntityUnsafe(crossbowID) );
  4092.            
  4093.             if(rangedWeapon)
  4094.             {
  4095.                
  4096.                 RemoveTimer('DelayedOnItemMount');
  4097.             }
  4098.         }
  4099.         else
  4100.         {
  4101.            
  4102.             RemoveTimer('DelayedOnItemMount');
  4103.         }
  4104.     }
  4105.  
  4106.     public function GetHeldItems() : array<SItemUniqueId>
  4107.     {
  4108.         var items : array<SItemUniqueId>;
  4109.         var item : SItemUniqueId;
  4110.    
  4111.         if( inv.GetItemEquippedOnSlot(EES_SilverSword, item) && inv.IsItemHeld(item))
  4112.             items.PushBack(item);
  4113.            
  4114.         if( inv.GetItemEquippedOnSlot(EES_SteelSword, item) && inv.IsItemHeld(item))
  4115.             items.PushBack(item);
  4116.  
  4117.         if( inv.GetItemEquippedOnSlot(EES_RangedWeapon, item) && inv.IsItemHeld(item))
  4118.             items.PushBack(item);
  4119.  
  4120.         if( inv.GetItemEquippedOnSlot(EES_Quickslot1, item) && inv.IsItemHeld(item))
  4121.             items.PushBack(item);
  4122.  
  4123.         if( inv.GetItemEquippedOnSlot(EES_Quickslot2, item) && inv.IsItemHeld(item))
  4124.             items.PushBack(item);
  4125.  
  4126.         if( inv.GetItemEquippedOnSlot(EES_Petard1, item) && inv.IsItemHeld(item))
  4127.             items.PushBack(item);
  4128.  
  4129.         if( inv.GetItemEquippedOnSlot(EES_Petard2, item) && inv.IsItemHeld(item))
  4130.             items.PushBack(item);
  4131.  
  4132.         return items;          
  4133.     }
  4134.    
  4135.             pam = (W3PlayerAbilityManager)abilityManager; //zur13 modSSS fixed orig script error
  4136.    
  4137.     public function UnequipItemFromSlot(slot : EEquipmentSlots, optional reequipped : bool) : bool
  4138.     {
  4139.         var item, bolts : SItemUniqueId;
  4140.         var items : array<SItemUniqueId>;
  4141.         var retBool : bool;
  4142.         var fistsID, bolt : array<SItemUniqueId>;
  4143.         var i, groupID : int;
  4144.         var pam : W3PlayerAbilityManager;
  4145.         var prevSkillColor : ESkillColor;
  4146.         var containedAbilities : array<name>;
  4147.         var dm : CDefinitionsManagerAccessor;
  4148.         var armorType : EArmorType;
  4149.         var isSwimming : bool;
  4150.         var hud                 : CR4ScriptedHud;
  4151.         var damagedItemModule   : CR4HudModuleDamagedItems;
  4152.        
  4153.         if(slot == EES_InvalidSlot || slot < 0 || slot > EnumGetMax('EEquipmentSlots') || !inv.IsIdValid(itemSlots[slot]))
  4154.             return false;
  4155.            
  4156.        
  4157.         if(IsSlotSkillMutagen(slot))
  4158.         {
  4159.            
  4160.             pam = (W3PlayerAbilityManager)abilityManager;
  4161.             groupID = pam.GetSkillGroupIdOfMutagenSlot(slot);
  4162.             prevSkillColor = pam.GetSkillGroupColor(groupID);
  4163.         }
  4164.        
  4165.        
  4166.         if(slot == EES_SilverSword  || slot == EES_SteelSword)
  4167.         {
  4168.             RemoveOilBuff( slot == EES_SteelSword );
  4169.         }
  4170.            
  4171.         item = itemSlots[slot];
  4172.         itemSlots[slot] = GetInvalidUniqueId();
  4173.        
  4174.        
  4175.         if(inv.ItemHasTag( item, 'PhantomWeapon' ) && GetPhantomWeaponMgr())
  4176.         {
  4177.             DestroyPhantomWeaponMgr();
  4178.         }
  4179.        
  4180.        
  4181.        
  4182.        
  4183.         if(slot == EES_RangedWeapon)
  4184.         {
  4185.            
  4186.             this.OnRangedForceHolster( true, true );
  4187.             rangedWeapon.ClearDeployedEntity(true);
  4188.             rangedWeapon = NULL;
  4189.        
  4190.            
  4191.             if(GetItemEquippedOnSlot(EES_Bolt, bolts))
  4192.             {
  4193.                 if(inv.ItemHasTag(bolts, theGame.params.TAG_INFINITE_AMMO))
  4194.                 {
  4195.                     inv.RemoveItem(bolts, inv.GetItemQuantity(bolts) );
  4196.                 }
  4197.             }
  4198.         }
  4199.         else if(IsSlotSkillMutagen(slot))
  4200.         {          
  4201.             pam.OnSkillMutagenUnequipped(item, slot, prevSkillColor);
  4202.             LogSkillColors("Mutagen <<" + inv.GetItemName(item) + ">> unequipped from slot <<" + slot + ">>");
  4203.             LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
  4204.             LogSkillColors("");
  4205.         }
  4206.        
  4207.        
  4208.         if(currentlyEquipedItem == item)
  4209.         {
  4210.             currentlyEquipedItem = GetInvalidUniqueId();
  4211.             RaiseEvent('ForcedUsableItemUnequip');
  4212.         }
  4213.         if(currentlyEquipedItemL == item)
  4214.         {
  4215.             if ( currentlyUsedItemL )
  4216.             {
  4217.                 currentlyUsedItemL.OnHidden( this );
  4218.             }
  4219.             HideUsableItem ( true );
  4220.         }
  4221.                
  4222.        
  4223.         if( !IsSlotPotionMutagen(slot) )
  4224.         {
  4225.             GetInventory().UnmountItem(item, true);
  4226.         }
  4227.        
  4228.         retBool = true;
  4229.                
  4230.        
  4231.         if(IsAnyItemEquippedOnSlot(EES_RangedWeapon) && slot == EES_Bolt)
  4232.         {          
  4233.             if(inv.ItemHasTag(item, theGame.params.TAG_INFINITE_AMMO))
  4234.             {
  4235.                
  4236.                 inv.RemoveItem(item, inv.GetItemQuantityByName( inv.GetItemName(item) ) );
  4237.             }
  4238.             else if (!reequipped)
  4239.             {
  4240.                
  4241.                 AddAndEquipInfiniteBolt();
  4242.             }
  4243.         }
  4244.        
  4245.        
  4246.         if(slot == EES_SilverSword  || slot == EES_SteelSword)
  4247.         {
  4248.             OnEquipMeleeWeapon(PW_None, true);
  4249.         }
  4250.        
  4251.         if(  GetSelectedItemId() == item )
  4252.         {
  4253.             ClearSelectedItemId();
  4254.         }
  4255.        
  4256.         if(inv.IsItemBody(item))
  4257.         {
  4258.             retBool = true;
  4259.         }      
  4260.        
  4261.         if(retBool && !reequipped)
  4262.         {
  4263.             theTelemetry.LogWithLabelAndValue( TE_INV_ITEM_UNEQUIPPED, inv.GetItemName(item), slot );
  4264.            
  4265.            
  4266.             if(slot == EES_SteelSword && !IsAnyItemEquippedOnSlot(EES_SilverSword))
  4267.             {
  4268.                 RemoveBuff(EET_EnhancedWeapon);
  4269.             }
  4270.             else if(slot == EES_SilverSword && !IsAnyItemEquippedOnSlot(EES_SteelSword))
  4271.             {
  4272.                 RemoveBuff(EET_EnhancedWeapon);
  4273.             }
  4274.             else if(inv.IsItemAnyArmor(item))
  4275.             {
  4276.                 if( !IsAnyItemEquippedOnSlot(EES_Armor) && !IsAnyItemEquippedOnSlot(EES_Gloves) && !IsAnyItemEquippedOnSlot(EES_Boots) && !IsAnyItemEquippedOnSlot(EES_Pants))
  4277.                     RemoveBuff(EET_EnhancedArmor);
  4278.             }
  4279.         }
  4280.        
  4281.        
  4282.         if(inv.ItemHasAbility(item, 'MA_HtH'))
  4283.         {
  4284.             inv.GetItemContainedAbilities(item, containedAbilities);
  4285.             fistsID = inv.GetItemsByName('fists');
  4286.             dm = theGame.GetDefinitionsManager();
  4287.             for(i=0; i<containedAbilities.Size(); i+=1)
  4288.             {
  4289.                 if(dm.AbilityHasTag(containedAbilities[i], 'MA_HtH'))
  4290.                 {
  4291.                     inv.RemoveItemCraftedAbility(fistsID[0], containedAbilities[i]);
  4292.                 }
  4293.             }
  4294.         }
  4295.        
  4296.        
  4297.         if(inv.IsItemAnyArmor(item))
  4298.         {
  4299.             armorType = inv.GetArmorType(item);
  4300.             pam = (W3PlayerAbilityManager)abilityManager;
  4301.            
  4302.             if(CanUseSkill(S_Perk_05) && (armorType == EAT_Light || GetCharacterStats().HasAbility('Glyphword 2 _Stats', true) || inv.ItemHasAbility(item, 'Glyphword 2 _Stats')))
  4303.             {
  4304.                 pam.SetPerkArmorBonus(S_Perk_05);
  4305.             }
  4306.             if(CanUseSkill(S_Perk_06) && (armorType == EAT_Medium || GetCharacterStats().HasAbility('Glyphword 3 _Stats', true) || inv.ItemHasAbility(item, 'Glyphword 3 _Stats')) )
  4307.             {
  4308.                 pam.SetPerkArmorBonus(S_Perk_06);
  4309.             }
  4310.             if(CanUseSkill(S_Perk_07) && (armorType == EAT_Heavy || GetCharacterStats().HasAbility('Glyphword 4 _Stats', true) || inv.ItemHasAbility(item, 'Glyphword 4 _Stats')) )
  4311.             {
  4312.                 pam.SetPerkArmorBonus(S_Perk_07);
  4313.             }
  4314.         }
  4315.        
  4316.         if( slot == EES_Gloves )
  4317.         {
  4318.             thePlayer.DestroyEffect('runeword_4');
  4319.         }
  4320.        
  4321.        
  4322.         hud = (CR4ScriptedHud)theGame.GetHud();
  4323.         if ( hud )
  4324.         {
  4325.             damagedItemModule = hud.GetDamagedItemModule();
  4326.             if ( damagedItemModule )
  4327.             {
  4328.                 damagedItemModule.OnItemUnequippedFromSlot( slot );
  4329.             }
  4330.         }
  4331.        
  4332.        
  4333.         theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnItemEquipped );
  4334.        
  4335.         return retBool;
  4336.     }
  4337.        
  4338.     public function UnequipItem(item : SItemUniqueId) : bool
  4339.     {
  4340.         if(!inv.IsIdValid(item))
  4341.             return false;
  4342.        
  4343.         return UnequipItemFromSlot( itemSlots.FindFirst(item) );
  4344.     }
  4345.    
  4346.     public function DropItem( item : SItemUniqueId, quantity : int ) : bool
  4347.     {
  4348.         if(!inv.IsIdValid(item))
  4349.             return false;
  4350.         if(IsItemEquipped(item))
  4351.             return UnequipItem(item);
  4352.        
  4353.         return true;
  4354.     }  
  4355.    
  4356.    
  4357.     public function IsItemEquippedByName(itemName : name) : bool
  4358.     {
  4359.         var i : int;
  4360.    
  4361.         for(i=0; i<itemSlots.Size(); i+=1)
  4362.             if(inv.GetItemName(itemSlots[i]) == itemName)
  4363.                 return true;
  4364.  
  4365.         return false;
  4366.     }
  4367.  
  4368.    
  4369.     public function IsItemEquippedByCategoryName(categoryName : name) : bool
  4370.     {
  4371.         var i : int;
  4372.    
  4373.         for(i=0; i<itemSlots.Size(); i+=1)
  4374.             if(inv.GetItemCategory(itemSlots[i]) == categoryName)
  4375.                 return true;
  4376.                
  4377.         return false;
  4378.     }
  4379.    
  4380.     public function GetMaxRunEncumbrance(out usesHorseBonus : bool) : float
  4381.     {
  4382.         var value : float;
  4383.        
  4384.         value = CalculateAttributeValue(GetHorseManager().GetHorseAttributeValue('encumbrance', false));
  4385.         usesHorseBonus = (value > 0);
  4386.         value += CalculateAttributeValue( GetAttributeValue('encumbrance') );
  4387.        
  4388.         return value;
  4389.     }
  4390.        
  4391.     public function GetEncumbrance() : float
  4392.     {
  4393.         var i: int;
  4394.         var encumbrance : float;
  4395.         var items : array<SItemUniqueId>;
  4396.         var inve : CInventoryComponent;
  4397.    
  4398.         inve = GetInventory();         
  4399.         inve.GetAllItems(items);
  4400.  
  4401.         for(i=0; i<items.Size(); i+=1)
  4402.         {
  4403.             encumbrance += inve.GetItemEncumbrance( items[i] );
  4404.            
  4405.         }      
  4406.         return encumbrance;
  4407.     }
  4408.    
  4409.    
  4410.    
  4411.     public function StartInvUpdateTransaction():void
  4412.     {
  4413.         invUpdateTransaction = true;
  4414.     }
  4415.    
  4416.     public function FinishInvUpdateTransaction():void
  4417.     {
  4418.         invUpdateTransaction = false;
  4419.        
  4420.        
  4421.        
  4422.         UpdateEncumbrance();
  4423.     }
  4424.    
  4425.    
  4426.     public function UpdateEncumbrance()
  4427.     {
  4428.         var temp : bool;
  4429.        
  4430.         if (invUpdateTransaction)
  4431.         {
  4432.            
  4433.             return;
  4434.         }
  4435.        
  4436.        
  4437.        
  4438.         if ( GetEncumbrance() >= (GetMaxRunEncumbrance(temp) + 1) )
  4439.         {
  4440.             if( !HasBuff(EET_OverEncumbered) )
  4441.             {
  4442.                 AddEffectDefault(EET_OverEncumbered, NULL, "OverEncumbered");
  4443.             }
  4444.         }
  4445.         else if(HasBuff(EET_OverEncumbered))
  4446.         {
  4447.             RemoveAllBuffsOfType(EET_OverEncumbered);
  4448.         }
  4449.     }
  4450.    
  4451.     public final function GetSkillGroupIDFromIndex(idx : int) : int
  4452.     {
  4453.         var pam : W3PlayerAbilityManager;
  4454.        
  4455.         pam = (W3PlayerAbilityManager)abilityManager;
  4456.         if(pam && pam.IsInitialized())
  4457.             return pam.GetSkillGroupIDFromIndex(idx);
  4458.            
  4459.         return -1;
  4460.     }
  4461.    
  4462.     public final function GetSkillGroupColor(groupID : int) : ESkillColor
  4463.     {
  4464.         var pam : W3PlayerAbilityManager;
  4465.        
  4466.         pam = (W3PlayerAbilityManager)abilityManager;
  4467.         if(pam && pam.IsInitialized())
  4468.             return pam.GetSkillGroupColor(groupID);
  4469.            
  4470.         return SC_None;
  4471.     }
  4472.    
  4473.     public final function GetSkillGroupsCount() : int
  4474.     {
  4475.         var pam : W3PlayerAbilityManager;
  4476.        
  4477.         pam = (W3PlayerAbilityManager)abilityManager;
  4478.         if(pam && pam.IsInitialized())
  4479.             return pam.GetSkillGroupsCount();
  4480.            
  4481.         return 0;
  4482.     }
  4483.    
  4484.    
  4485.    
  4486.    
  4487.    
  4488.    
  4489.    
  4490.    
  4491.     function CycleSelectSign( bIsCyclingLeft : bool ) : ESignType
  4492.     {
  4493.         var signOrder : array<ESignType>;
  4494.         var i : int;
  4495.        
  4496.         signOrder.PushBack( ST_Yrden );
  4497.         signOrder.PushBack( ST_Quen );
  4498.         signOrder.PushBack( ST_Igni );
  4499.         signOrder.PushBack( ST_Axii );
  4500.         signOrder.PushBack( ST_Aard );
  4501.            
  4502.         for( i = 0; i < signOrder.Size(); i += 1 )
  4503.             if( signOrder[i] == equippedSign )
  4504.                 break;
  4505.        
  4506.         if(bIsCyclingLeft)
  4507.             return signOrder[ (4 + i) % 5 ];   
  4508.         else
  4509.             return signOrder[ (6 + i) % 5 ];
  4510.     }
  4511.    
  4512.     function ToggleNextSign()
  4513.     {
  4514.         SetEquippedSign(CycleSelectSign( false ));
  4515.         FactsAdd("SignToggled", 1, 1);
  4516.     }
  4517.    
  4518.     function TogglePreviousSign()
  4519.     {
  4520.         SetEquippedSign(CycleSelectSign( true ));
  4521.         FactsAdd("SignToggled", 1, 1);
  4522.     }
  4523.    
  4524.     function ProcessSignEvent( eventName : name ) : bool
  4525.     {
  4526.         if( currentlyCastSign != ST_None && signs[currentlyCastSign].entity)
  4527.         {
  4528.             return signs[currentlyCastSign].entity.OnProcessSignEvent( eventName );
  4529.         }
  4530.        
  4531.         return false;
  4532.     }
  4533.    
  4534.     var findActorTargetTimeStamp : float;
  4535.     var pcModeChanneledSignTimeStamp    : float;
  4536.     event OnProcessCastingOrientation( isContinueCasting : bool )
  4537.     {
  4538.         var customOrientationTarget : EOrientationTarget;
  4539.         var checkHeading            : float;
  4540.         var rotHeading              : float;
  4541.         var playerToHeadingDist     : float;
  4542.         var slideTargetActor        : CActor;
  4543.         var newLockTarget           : CActor;
  4544.        
  4545.         var enableNoTargetOrientation   : bool;
  4546.        
  4547.         var currTime : float;
  4548.        
  4549.         enableNoTargetOrientation = true;
  4550.         if ( GetDisplayTarget() && this.IsDisplayTargetTargetable() )
  4551.         {
  4552.             enableNoTargetOrientation = false;
  4553.             if ( theInput.GetActionValue( 'CastSignHold' ) > 0 || this.IsCurrentSignChanneled() )
  4554.             {
  4555.                 if ( IsPCModeEnabled() )
  4556.                 {
  4557.                     if ( EngineTimeToFloat( theGame.GetEngineTime() ) >  pcModeChanneledSignTimeStamp + 1.f )
  4558.                         enableNoTargetOrientation = true;
  4559.                 }
  4560.                 else
  4561.                 {
  4562.                     if ( GetCurrentlyCastSign() == ST_Igni || GetCurrentlyCastSign() == ST_Axii )
  4563.                     {
  4564.                         slideTargetActor = (CActor)GetDisplayTarget();
  4565.                         if ( slideTargetActor
  4566.                             && ( !slideTargetActor.GetGameplayVisibility() || !CanBeTargetedIfSwimming( slideTargetActor ) || !slideTargetActor.IsAlive() ) )
  4567.                         {
  4568.                             SetSlideTarget( NULL );
  4569.                             if ( ProcessLockTarget() )
  4570.                                 slideTargetActor = (CActor)slideTarget;
  4571.                         }              
  4572.                        
  4573.                         if ( !slideTargetActor )
  4574.                         {
  4575.                             LockToTarget( false );
  4576.                             enableNoTargetOrientation = true;
  4577.                         }
  4578.                         else if ( IsThreat( slideTargetActor ) || GetCurrentlyCastSign() == ST_Axii )
  4579.                             LockToTarget( true );
  4580.                         else
  4581.                         {
  4582.                             LockToTarget( false );
  4583.                             enableNoTargetOrientation = true;
  4584.                         }
  4585.                     }
  4586.                 }
  4587.             }
  4588.  
  4589.             if ( !enableNoTargetOrientation )
  4590.             {          
  4591.                 customOrientationTarget = OT_Actor;
  4592.             }
  4593.         }
  4594.        
  4595.         if ( enableNoTargetOrientation )
  4596.         {
  4597.             if ( GetPlayerCombatStance() == PCS_AlertNear && theInput.GetActionValue( 'CastSignHold' ) > 0 )
  4598.             {
  4599.                 if ( GetDisplayTarget() && !slideTargetActor )
  4600.                 {
  4601.                     currTime = EngineTimeToFloat( theGame.GetEngineTime() );
  4602.                     if ( currTime > findActorTargetTimeStamp + 1.5f )
  4603.                     {
  4604.                         findActorTargetTimeStamp = currTime;
  4605.                        
  4606.                         newLockTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, 0.f, true );
  4607.                        
  4608.                         if ( newLockTarget && IsThreat( newLockTarget ) && IsCombatMusicEnabled() )
  4609.                         {
  4610.                             SetTarget( newLockTarget, true );
  4611.                             SetMoveTargetChangeAllowed( true );
  4612.                             SetMoveTarget( newLockTarget );
  4613.                             SetMoveTargetChangeAllowed( false );
  4614.                             SetSlideTarget( newLockTarget );                           
  4615.                         }  
  4616.                     }
  4617.                 }
  4618.                 else
  4619.                     ProcessLockTarget();
  4620.             }
  4621.            
  4622.             if ( wasBRAxisPushed )
  4623.                 customOrientationTarget = OT_CameraOffset;
  4624.             else
  4625.             {
  4626.                 if ( !lastAxisInputIsMovement || theInput.LastUsedPCInput() )
  4627.                     customOrientationTarget = OT_CameraOffset;
  4628.                 else if ( theInput.GetActionValue( 'CastSignHold' ) > 0 )
  4629.                 {
  4630.                     if ( GetOrientationTarget() == OT_CameraOffset )
  4631.                         customOrientationTarget = OT_CameraOffset;
  4632.                     else if ( GetPlayerCombatStance() == PCS_AlertNear || GetPlayerCombatStance() == PCS_Guarded )
  4633.                         customOrientationTarget = OT_CameraOffset;
  4634.                     else
  4635.                         customOrientationTarget = OT_Player;   
  4636.                 }
  4637.                 else
  4638.                     customOrientationTarget = OT_CustomHeading;
  4639.             }          
  4640.         }      
  4641.        
  4642.         if ( GetCurrentlyCastSign() == ST_Quen )
  4643.         {
  4644.             if ( theInput.LastUsedPCInput() )
  4645.             {
  4646.                 customOrientationTarget = OT_Camera;
  4647.             }
  4648.             else if ( IsCurrentSignChanneled() )
  4649.             {
  4650.                 if ( bLAxisReleased )
  4651.                     customOrientationTarget = OT_Player;
  4652.                 else
  4653.                     customOrientationTarget = OT_Camera;
  4654.             }
  4655.             else
  4656.                 customOrientationTarget = OT_Player;
  4657.         }  
  4658.        
  4659.         if ( GetCurrentlyCastSign() == ST_Axii && IsCurrentSignChanneled() )
  4660.         {  
  4661.             if ( slideTarget && (CActor)slideTarget )
  4662.             {
  4663.                 checkHeading = VecHeading( slideTarget.GetWorldPosition() - this.GetWorldPosition() );
  4664.                 rotHeading = checkHeading;
  4665.                 playerToHeadingDist = AngleDistance( GetHeading(), checkHeading );
  4666.                
  4667.                 if ( playerToHeadingDist > 45 )
  4668.                     SetCustomRotation( 'ChanneledSignAxii', rotHeading, 0.0, 0.5, false );
  4669.                 else if ( playerToHeadingDist < -45 )
  4670.                     SetCustomRotation( 'ChanneledSignAxii', rotHeading, 0.0, 0.5, false );                 
  4671.             }
  4672.             else
  4673.             {
  4674.                 checkHeading = VecHeading( theCamera.GetCameraDirection() );
  4675.                 rotHeading = GetHeading();
  4676.                 playerToHeadingDist = AngleDistance( GetHeading(), checkHeading );
  4677.                
  4678.                 if ( playerToHeadingDist > 45 )
  4679.                     SetCustomRotation( 'ChanneledSignAxii', rotHeading - 22.5, 0.0, 0.5, false );
  4680.                 else if ( playerToHeadingDist < -45 )
  4681.                     SetCustomRotation( 'ChanneledSignAxii', rotHeading + 22.5, 0.0, 0.5, false );              
  4682.             }
  4683.         }      
  4684.            
  4685.         if ( IsActorLockedToTarget() )
  4686.             customOrientationTarget = OT_Actor;
  4687.        
  4688.         //modEnhancedTargeting BEGIN
  4689.         if ( theGame.GetInGameConfigWrapper().GetVarValue('EnhancedTargeting', 'ETSignsTowardsCamera') )
  4690.             customOrientationTarget = OT_CameraOffset; // shitty tweak, oh well
  4691.         //modEnhancedTargeting END
  4692.        
  4693.         AddCustomOrientationTarget( customOrientationTarget, 'Signs' );
  4694.        
  4695.         if ( customOrientationTarget == OT_CustomHeading )
  4696.             SetOrientationTargetCustomHeading( GetCombatActionHeading(), 'Signs' );        
  4697.     }
  4698.    
  4699.     event OnRaiseSignEvent()
  4700.     {
  4701.         var newTarget : CActor;
  4702.    
  4703.         if ( ( !IsCombatMusicEnabled() && !CanAttackWhenNotInCombat( EBAT_CastSign, false, newTarget ) ) || ( IsOnBoat() && !IsCombatMusicEnabled() ) )
  4704.         {      
  4705.             if ( CastSignFriendly() )
  4706.                 return true;
  4707.         }
  4708.         else
  4709.         {
  4710.             RaiseEvent('CombatActionFriendlyEnd');
  4711.             SetBehaviorVariable( 'SignNum', (int)equippedSign );
  4712.             SetBehaviorVariable( 'combatActionType', (int)CAT_CastSign );
  4713.  
  4714.             if ( IsPCModeEnabled() )
  4715.                 pcModeChanneledSignTimeStamp = EngineTimeToFloat( theGame.GetEngineTime() );
  4716.        
  4717.             if( RaiseForceEvent('CombatAction') )
  4718.             {
  4719.                 OnCombatActionStart();
  4720.                 findActorTargetTimeStamp = EngineTimeToFloat( theGame.GetEngineTime() );
  4721.                 theTelemetry.LogWithValueStr(TE_FIGHT_PLAYER_USE_SIGN, SignEnumToString( equippedSign ));
  4722.                 return true;
  4723.             }
  4724.         }
  4725.        
  4726.         return false;
  4727.     }
  4728.    
  4729.     function CastSignFriendly() : bool
  4730.     {
  4731.         var actor : CActor;
  4732.    
  4733.         SetBehaviorVariable( 'combatActionTypeForOverlay', (int)CAT_CastSign );        
  4734.         if ( RaiseCombatActionFriendlyEvent() )
  4735.         {
  4736.                        
  4737.             return true;
  4738.         }  
  4739.        
  4740.         return false;
  4741.     }
  4742.    
  4743.     function CastSign() : bool
  4744.     {
  4745.         var equippedSignStr : string;
  4746.         var newSignEnt : W3SignEntity;
  4747.         var spawnPos : Vector;
  4748.         var slotMatrix : Matrix;
  4749.         var target : CActor;
  4750.        
  4751.         if ( IsInAir() )
  4752.         {
  4753.             return false;
  4754.         }
  4755.        
  4756.         AddTemporarySkills();
  4757.        
  4758.        
  4759.        
  4760.         if(equippedSign == ST_Aard)
  4761.         {
  4762.             CalcEntitySlotMatrix('l_weapon', slotMatrix);
  4763.             spawnPos = MatrixGetTranslation(slotMatrix);
  4764.         }
  4765.         else
  4766.         {
  4767.             spawnPos = GetWorldPosition();
  4768.         }
  4769.        
  4770.         if( equippedSign == ST_Aard || equippedSign == ST_Igni )
  4771.         {
  4772.             target = GetTarget();
  4773.             if(target)
  4774.                 target.SignalGameplayEvent( 'DodgeSign' );
  4775.         }
  4776.        
  4777.         newSignEnt = (W3SignEntity)theGame.CreateEntity( signs[equippedSign].template, spawnPos, GetWorldRotation() );
  4778.         return newSignEnt.Init( signOwner, signs[equippedSign].entity );
  4779.     }
  4780.    
  4781.    
  4782.     private function HAX_SignToThrowItemRestore()
  4783.     {
  4784.         var action : SInputAction;
  4785.        
  4786.         action.value = theInput.GetActionValue('ThrowItemHold');
  4787.         action.lastFrameValue = 0;
  4788.        
  4789.         if(IsPressed(action) && CanSetupCombatAction_Throw())
  4790.         {
  4791.             if(inv.IsItemBomb(selectedItemId))
  4792.             {
  4793.                 BombThrowStart();
  4794.             }
  4795.             else
  4796.             {
  4797.                 UsableItemStart();
  4798.             }
  4799.            
  4800.             SetThrowHold( true );
  4801.         }
  4802.     }
  4803.    
  4804.     event OnCFMCameraZoomFail(){}
  4805.        
  4806.    
  4807.  
  4808.     public final function GetDrunkMutagens() : array<CBaseGameplayEffect>
  4809.     {
  4810.         return effectManager.GetDrunkMutagens();
  4811.     }
  4812.    
  4813.     public final function GetPotionBuffs() : array<CBaseGameplayEffect>
  4814.     {
  4815.         return effectManager.GetPotionBuffs();
  4816.     }
  4817.    
  4818.     public final function RecalcPotionsDurations()
  4819.     {
  4820.         var i : int;
  4821.         var buffs : array<CBaseGameplayEffect>;
  4822.        
  4823.         buffs = GetPotionBuffs();
  4824.         for(i=0; i<buffs.Size(); i+=1)
  4825.         {
  4826.             buffs[i].RecalcPotionDuration();
  4827.         }
  4828.     }
  4829.  
  4830.     public function StartFrenzy()
  4831.     {
  4832.         var ratio, duration : float;
  4833.         var skillLevel : int;
  4834.    
  4835.         isInFrenzy = true;
  4836.         skillLevel = GetSkillLevel(S_Alchemy_s16);
  4837.         ratio = 0.48f - skillLevel * CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s16, 'slowdown_ratio', false, true));
  4838.         duration = skillLevel * CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s16, 'slowdown_duration', false, true));
  4839.    
  4840.         theGame.SetTimeScale(ratio, theGame.GetTimescaleSource(ETS_SkillFrenzy), theGame.GetTimescalePriority(ETS_SkillFrenzy) );
  4841.         AddTimer('SkillFrenzyFinish', duration * ratio, , , , true);
  4842.     }
  4843.    
  4844.     timer function SkillFrenzyFinish(dt : float, optional id : int)
  4845.     {      
  4846.         theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_SkillFrenzy) );
  4847.         isInFrenzy = false;
  4848.     }
  4849.    
  4850.     public function GetToxicityDamageThreshold() : float
  4851.     {
  4852.         var ret : float;
  4853.        
  4854.         ret = theGame.params.TOXICITY_DAMAGE_THRESHOLD;
  4855.        
  4856.         if(CanUseSkill(S_Alchemy_s01))
  4857.             ret += CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s01, 'threshold', false, true)) * GetSkillLevel(S_Alchemy_s01);
  4858.        
  4859.         return ret;
  4860.     }
  4861.    
  4862.    
  4863.    
  4864.     public final function AddToxicityOffset( val : float)
  4865.     {
  4866.         ((W3PlayerAbilityManager)abilityManager).AddToxicityOffset(val);       
  4867.     }
  4868.    
  4869.     public final function SetToxicityOffset( val : float)
  4870.     {
  4871.         ((W3PlayerAbilityManager)abilityManager).SetToxicityOffset(val);
  4872.     }
  4873.    
  4874.     public final function RemoveToxicityOffset( val : float)
  4875.     {
  4876.         ((W3PlayerAbilityManager)abilityManager).RemoveToxicityOffset(val);    
  4877.     }
  4878.    
  4879.    
  4880.     public final function CalculatePotionDuration(item : SItemUniqueId, isMutagenPotion : bool, optional itemName : name) : float
  4881.     {
  4882.         var duration, skillPassiveMod, mutagenSkillMod : float;
  4883.         var val, min, max : SAbilityAttributeValue;
  4884.        
  4885.        
  4886.         if(inv.IsIdValid(item))
  4887.         {
  4888.             duration = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'duration'));           
  4889.         }
  4890.         else
  4891.         {
  4892.             theGame.GetDefinitionsManager().GetItemAttributeValueNoRandom(itemName, true, 'duration', min, max);
  4893.             duration = CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  4894.         }
  4895.            
  4896.         skillPassiveMod = CalculateAttributeValue(GetAttributeValue('potion_duration'));
  4897.        
  4898.         if(isMutagenPotion && CanUseSkill(S_Alchemy_s14))
  4899.         {
  4900.             val = GetSkillAttributeValue(S_Alchemy_s14, 'duration', false, true);
  4901.             mutagenSkillMod = val.valueMultiplicative * GetSkillLevel(S_Alchemy_s14);
  4902.         }
  4903.        
  4904.         duration = duration * (1 + skillPassiveMod + mutagenSkillMod);
  4905.        
  4906.         return duration;
  4907.     }
  4908.    
  4909.     public function ToxicityLowEnoughToDrinkPotion( slotid : EEquipmentSlots, optional itemId : SItemUniqueId ) : bool
  4910.     {
  4911.         var item : SItemUniqueId;
  4912.         var maxTox : float;
  4913.         var potionToxicity : float;
  4914.         var toxicityOffset : float;
  4915.         var effectType : EEffectType;
  4916.         var customAbilityName : name;
  4917.        
  4918.         if(itemId != GetInvalidUniqueId())
  4919.             item = itemId;
  4920.         else
  4921.             item = itemSlots[slotid];
  4922.        
  4923.         inv.GetPotionItemBuffData(item, effectType, customAbilityName);
  4924.         maxTox = abilityManager.GetStatMax(BCS_Toxicity);
  4925.         potionToxicity = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity'));
  4926.         toxicityOffset = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity_offset'));
  4927.        
  4928.         if(effectType != EET_WhiteHoney)
  4929.         {
  4930.             if(abilityManager.GetStat(BCS_Toxicity, false) + potionToxicity + toxicityOffset > maxTox )
  4931.             {
  4932.                 return false;
  4933.             }
  4934.         }
  4935.        
  4936.         return true;
  4937.     }
  4938.    
  4939.     public function DrinkPreparedPotion( slotid : EEquipmentSlots, optional itemId : SItemUniqueId )
  4940.     {  
  4941.         var i, ind : int;
  4942.         var toxicityOffset, adrenaline : float;
  4943.         var potionToxicity, duration, hpGainValue, maxTox : float;
  4944.         var randomPotions : array<EEffectType>;
  4945.         var effectType : EEffectType;
  4946.         var customAbilityName, factId : name;
  4947.         var ret : EEffectInteract;
  4948.         var atts : array<name>;
  4949.         var effectsOld, effectsNew : array<CBaseGameplayEffect>;
  4950.         var factPotionParams : W3Potion_Fact_Params;
  4951.         var potParams : W3PotionParams;
  4952.         var mutagenParams : W3MutagenBuffCustomParams;     
  4953.         var item : SItemUniqueId;
  4954.         var params, potionParams : SCustomEffectParams;
  4955.         var costReduction : SAbilityAttributeValue;
  4956.        
  4957.        
  4958.         if(itemId != GetInvalidUniqueId())
  4959.             item = itemId;
  4960.         else
  4961.             item = itemSlots[slotid];
  4962.        
  4963.        
  4964.         if(!inv.IsIdValid(item))
  4965.             return;
  4966.            
  4967.        
  4968.         if( inv.SingletonItemGetAmmo(item) == 0 )
  4969.             return;
  4970.        
  4971.        
  4972.         inv.GetPotionItemBuffData(item, effectType, customAbilityName);
  4973.         maxTox = abilityManager.GetStatMax(BCS_Toxicity);
  4974.         potionToxicity = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity'));
  4975.         toxicityOffset = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity_offset'));
  4976.        
  4977.        
  4978.         if(CanUseSkill(S_Perk_13))
  4979.         {
  4980.             costReduction = GetSkillAttributeValue(S_Perk_13, 'cost_reduction', false, true);
  4981.             adrenaline = FloorF(GetStat(BCS_Focus));
  4982.             costReduction = costReduction * adrenaline;
  4983.             potionToxicity = (potionToxicity - costReduction.valueBase) * (1 - costReduction.valueMultiplicative) - costReduction.valueAdditive;
  4984.             potionToxicity = MaxF(0.f, potionToxicity);
  4985.         }
  4986.        
  4987.        
  4988.         if(effectType != EET_WhiteHoney)
  4989.         {
  4990.             if(abilityManager.GetStat(BCS_Toxicity, false) + potionToxicity + toxicityOffset > maxTox )
  4991.                 return;
  4992.         }
  4993.        
  4994.        
  4995.         customAbilityName = '';
  4996.         inv.GetPotionItemBuffData(item, effectType, customAbilityName);
  4997.                
  4998.        
  4999.         if(effectType == EET_Fact)
  5000.         {
  5001.             inv.GetItemAttributes(item, atts);
  5002.            
  5003.             for(i=0; i<atts.Size(); i+=1)
  5004.             {
  5005.                 if(StrBeginsWith(NameToString(atts[i]), "fact_"))
  5006.                 {
  5007.                     factId = atts[i];
  5008.                     break;
  5009.                 }
  5010.             }
  5011.            
  5012.             factPotionParams = new W3Potion_Fact_Params in theGame;
  5013.             factPotionParams.factName = factId;
  5014.             factPotionParams.potionItemName = inv.GetItemName(item);
  5015.            
  5016.             potionParams.buffSpecificParams = factPotionParams;
  5017.         }
  5018.        
  5019.         else if(inv.ItemHasTag( item, 'Mutagen' ))
  5020.         {
  5021.             mutagenParams = new W3MutagenBuffCustomParams in theGame;
  5022.             mutagenParams.toxicityOffset = toxicityOffset;
  5023.             mutagenParams.potionItemName = inv.GetItemName(item);
  5024.            
  5025.             potionParams.buffSpecificParams = mutagenParams;
  5026.         }
  5027.        
  5028.         else
  5029.         {
  5030.             potParams = new W3PotionParams in theGame;
  5031.             potParams.potionItemName = inv.GetItemName(item);
  5032.            
  5033.             potionParams.buffSpecificParams = potParams;
  5034.         }
  5035.    
  5036.        
  5037.         duration = CalculatePotionDuration(item, inv.ItemHasTag( item, 'Mutagen' ));       
  5038.  
  5039.        
  5040.         potionParams.effectType = effectType;
  5041.         potionParams.creator = this;
  5042.         potionParams.sourceName = "drank_potion";
  5043.         potionParams.duration = duration;
  5044.         potionParams.customAbilityName = customAbilityName;
  5045.         ret = AddEffectCustom(potionParams);
  5046.  
  5047.        
  5048.         if(factPotionParams)
  5049.             delete factPotionParams;
  5050.            
  5051.         if(mutagenParams)
  5052.             delete mutagenParams;
  5053.            
  5054.        
  5055.         inv.SingletonItemRemoveAmmo(item);
  5056.        
  5057.        
  5058.         if(ret == EI_Pass || ret == EI_Override || ret == EI_Cumulate)
  5059.         {
  5060.             abilityManager.GainStat(BCS_Toxicity, potionToxicity );
  5061.            
  5062.            
  5063.             if(CanUseSkill(S_Perk_13))
  5064.             {
  5065.                 abilityManager.DrainFocus(adrenaline);
  5066.             }
  5067.            
  5068.             if (!IsEffectActive('invisible'))
  5069.             {
  5070.                 PlayEffect('use_potion');
  5071.             }
  5072.            
  5073.             if ( inv.ItemHasTag( item, 'Mutagen' ) )
  5074.             {
  5075.                
  5076.                 theGame.GetGamerProfile().CheckTrialOfGrasses();
  5077.                
  5078.                
  5079.                 SetFailedFundamentalsFirstAchievementCondition(true);
  5080.             }
  5081.            
  5082.            
  5083.             if(CanUseSkill(S_Alchemy_s02))
  5084.             {
  5085.                 hpGainValue = ClampF(GetStatMax(BCS_Vitality) * CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s02, 'vitality_gain_perc', false, true)) * GetSkillLevel(S_Alchemy_s02), 0, GetStatMax(BCS_Vitality));
  5086.                 GainStat(BCS_Vitality, hpGainValue);
  5087.             }
  5088.            
  5089.             if(CanUseSkill(S_Alchemy_s04) && !skillBonusPotionEffect && (RandF() < CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s04, 'apply_chance', false, true)) * GetSkillLevel(S_Alchemy_s04)))
  5090.             {
  5091.                
  5092.                 randomPotions.PushBack(EET_BlackBlood);
  5093.                 randomPotions.PushBack(EET_Blizzard);
  5094.                 randomPotions.PushBack(EET_Cat);
  5095.                 randomPotions.PushBack(EET_FullMoon);
  5096.                 randomPotions.PushBack(EET_GoldenOriole);
  5097.                 randomPotions.PushBack(EET_KillerWhale);
  5098.                 randomPotions.PushBack(EET_MariborForest);
  5099.                 randomPotions.PushBack(EET_PetriPhiltre);
  5100.                 randomPotions.PushBack(EET_Swallow);
  5101.                 randomPotions.PushBack(EET_TawnyOwl);
  5102.                 randomPotions.PushBack(EET_Thunderbolt);
  5103.                 randomPotions.PushBack(EET_WhiteRaffardDecoction);
  5104.                
  5105.                
  5106.                 randomPotions.Remove(effectType);
  5107.                 ind = RandRange(randomPotions.Size());
  5108.  
  5109.                 duration = BonusPotionGetDurationFromXML(randomPotions[ind]);
  5110.                
  5111.                 if(duration > 0)
  5112.                 {
  5113.                     effectsOld = GetCurrentEffects();
  5114.                                        
  5115.                     params.effectType = randomPotions[ind];
  5116.                     params.creator = this;
  5117.                     params.sourceName = SkillEnumToName(S_Alchemy_s04);
  5118.                     params.duration = duration;
  5119.                     ret = AddEffectCustom(params);
  5120.                    
  5121.                    
  5122.                     if(ret != EI_Undefined && ret != EI_Deny)
  5123.                     {
  5124.                         effectsNew = GetCurrentEffects();
  5125.                        
  5126.                         ind = -1;
  5127.                         for(i=0; i<effectsNew.Size(); i+=1)
  5128.                         {
  5129.                             if(!effectsOld.Contains(effectsNew[i]))
  5130.                             {
  5131.                                 ind = i;
  5132.                                 break;
  5133.                             }
  5134.                         }
  5135.                        
  5136.                         if(ind > -1)
  5137.                         {
  5138.                             skillBonusPotionEffect = effectsNew[ind];
  5139.                         }
  5140.                     }
  5141.                 }      
  5142.             }
  5143.            
  5144.             theGame.GetGamerProfile().SetStat(ES_ActivePotions, effectManager.GetPotionBuffsCount());
  5145.         }
  5146.        
  5147.         theTelemetry.LogWithLabel(TE_ELIXIR_USED, inv.GetItemName(item));
  5148.        
  5149.         if(ShouldProcessTutorial('TutorialPotionAmmo'))
  5150.         {
  5151.             FactsAdd("tut_used_potion");
  5152.         }
  5153.        
  5154.         SetFailedFundamentalsFirstAchievementCondition(true);
  5155.     }
  5156.    
  5157.    
  5158.     private function BonusPotionGetDurationFromXML(type : EEffectType) : float
  5159.     {
  5160.         var dm : CDefinitionsManagerAccessor;
  5161.         var main, ingredients : SCustomNode;
  5162.         var tmpName, typeName, itemName : name;
  5163.         var abs : array<name>;
  5164.         var min, max : SAbilityAttributeValue;
  5165.         var tmpInt : int;
  5166.         var temp                                : array<float>;
  5167.         var i, temp2, temp3 : int;
  5168.                        
  5169.         dm = theGame.GetDefinitionsManager();
  5170.         main = dm.GetCustomDefinition('alchemy_recipes');
  5171.         typeName = EffectTypeToName(type);
  5172.        
  5173.        
  5174.         for(i=0; i<main.subNodes.Size(); i+=1)
  5175.         {
  5176.             if(dm.GetCustomNodeAttributeValueName(main.subNodes[i], 'type_name', tmpName))
  5177.             {
  5178.                
  5179.                 if(tmpName == typeName)
  5180.                 {
  5181.                     if(dm.GetCustomNodeAttributeValueInt(main.subNodes[i], 'level', tmpInt))
  5182.                     {
  5183.                        
  5184.                         if(tmpInt == 1)
  5185.                         {
  5186.                             if(dm.GetCustomNodeAttributeValueName(main.subNodes[i], 'cookedItem_name', itemName))
  5187.                             {
  5188.                                
  5189.                                 if(IsNameValid(itemName))
  5190.                                 {
  5191.                                     break;
  5192.                                 }
  5193.                             }
  5194.                         }
  5195.                     }
  5196.                 }
  5197.             }
  5198.         }
  5199.        
  5200.         if(!IsNameValid(itemName))
  5201.             return 0;
  5202.        
  5203.        
  5204.         dm.GetItemAbilitiesWithWeights(itemName, true, abs, temp, temp2, temp3);
  5205.         dm.GetAbilitiesAttributeValue(abs, 'duration', min, max);                      
  5206.         return CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
  5207.     }
  5208.    
  5209.     public function ClearSkillBonusPotionEffect()
  5210.     {
  5211.         skillBonusPotionEffect = NULL;
  5212.     }
  5213.    
  5214.     public function GetSkillBonusPotionEffect() : CBaseGameplayEffect
  5215.     {
  5216.         return skillBonusPotionEffect;
  5217.     }
  5218.    
  5219.    
  5220.    
  5221.    
  5222.    
  5223.    
  5224.    
  5225.     public final function HasRunewordActive(abilityName : name) : bool
  5226.     {
  5227.         var item : SItemUniqueId;
  5228.         var hasRuneword : bool;
  5229.        
  5230.         if(GetItemEquippedOnSlot(EES_SteelSword, item))
  5231.         {
  5232.             hasRuneword = inv.ItemHasAbility(item, abilityName);               
  5233.         }
  5234.        
  5235.         if(!hasRuneword)
  5236.         {
  5237.             if(GetItemEquippedOnSlot(EES_SilverSword, item))
  5238.             {
  5239.                 hasRuneword = inv.ItemHasAbility(item, abilityName);
  5240.             }
  5241.         }
  5242.        
  5243.         return hasRuneword;
  5244.     }
  5245.    
  5246.     public final function GetShrineBuffs() : array<CBaseGameplayEffect>
  5247.     {
  5248.         var null : array<CBaseGameplayEffect>;
  5249.        
  5250.         if(effectManager && effectManager.IsReady())
  5251.             return effectManager.GetShrineBuffs();
  5252.            
  5253.         return null;
  5254.     }
  5255.    
  5256.     public final function AddRepairObjectBuff(armor : bool, weapon : bool) : bool
  5257.     {
  5258.         var added : bool;
  5259.        
  5260.         added = false;
  5261.        
  5262.         if(weapon && (IsAnyItemEquippedOnSlot(EES_SilverSword) || IsAnyItemEquippedOnSlot(EES_SteelSword)) )
  5263.         {
  5264.             AddEffectDefault(EET_EnhancedWeapon, this, "repair_object", false);
  5265.             added = true;
  5266.         }
  5267.        
  5268.         if(armor && (IsAnyItemEquippedOnSlot(EES_Armor) || IsAnyItemEquippedOnSlot(EES_Gloves) || IsAnyItemEquippedOnSlot(EES_Boots) || IsAnyItemEquippedOnSlot(EES_Pants)) )
  5269.         {
  5270.             AddEffectDefault(EET_EnhancedArmor, this, "repair_object", false);
  5271.             added = true;
  5272.         }
  5273.        
  5274.         return added;
  5275.     }
  5276.    
  5277.    
  5278.     public function StartCSAnim(buff : CBaseGameplayEffect) : bool
  5279.     {
  5280.        
  5281.         if(IsAnyQuenActive() && (W3CriticalDOTEffect)buff)
  5282.             return false;
  5283.            
  5284.         return super.StartCSAnim(buff);
  5285.     }
  5286.    
  5287.     public function GetPotionBuffLevel(effectType : EEffectType) : int
  5288.     {
  5289.         if(effectManager && effectManager.IsReady())
  5290.             return effectManager.GetPotionBuffLevel(effectType);
  5291.            
  5292.         return 0;
  5293.     }  
  5294.  
  5295.    
  5296.    
  5297.    
  5298.    
  5299.    
  5300.    
  5301.     event OnLevelGained(currentLevel : int, show : bool)
  5302.     {
  5303.         var hud : CR4ScriptedHud;
  5304.         hud = (CR4ScriptedHud)theGame.GetHud();
  5305.        
  5306.         if(abilityManager && abilityManager.IsInitialized())
  5307.         {
  5308.             ((W3PlayerAbilityManager)abilityManager).OnLevelGained(currentLevel);
  5309.         }
  5310.        
  5311.         if ( theGame.GetDifficultyMode() != EDM_Hardcore )
  5312.         {
  5313.             Heal(GetStatMax(BCS_Vitality));
  5314.         }
  5315.    
  5316.        
  5317.         if(currentLevel >= 35)
  5318.         {
  5319.             theGame.GetGamerProfile().AddAchievement(EA_Immortal);
  5320.         }
  5321.    
  5322.         if ( hud && currentLevel < 70 )
  5323.         {
  5324.             hud.OnLevelUpUpdate(currentLevel, show);
  5325.         }
  5326.        
  5327.         theGame.RequestAutoSave( "level gained", false );
  5328.     }
  5329.    
  5330.     public function GetSignStats(skill : ESkill, out damageType : name, out damageVal : float, out spellPower : SAbilityAttributeValue)
  5331.     {
  5332.         var i, size : int;
  5333.         var dm : CDefinitionsManagerAccessor;
  5334.         var attrs : array<name>;
  5335.    
  5336.         spellPower = GetPowerStatValue(CPS_SpellPower);
  5337.        
  5338.         dm = theGame.GetDefinitionsManager();
  5339.         dm.GetAbilityAttributes(GetSkillAbilityName(skill), attrs);
  5340.         size = attrs.Size();
  5341.        
  5342.         for( i = 0; i < size; i += 1 )
  5343.         {
  5344.             if( IsDamageTypeNameValid(attrs[i]) )
  5345.             {
  5346.                 damageVal = CalculateAttributeValue(GetSkillAttributeValue(skill, attrs[i], false, true));
  5347.                 damageType = attrs[i];
  5348.                 break;
  5349.             }
  5350.         }
  5351.     }
  5352.        
  5353.    
  5354.     public function SetIgnorePainMaxVitality(val : float)
  5355.     {
  5356.         if(abilityManager && abilityManager.IsInitialized())
  5357.             abilityManager.SetStatPointMax(BCS_Vitality, val);
  5358.     }
  5359.    
  5360.     event OnAnimEvent_ActionBlend( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  5361.     {
  5362.         if ( animEventType == AET_DurationStart && !disableActionBlend )
  5363.         {
  5364.             if ( this.IsCastingSign() )
  5365.                 ProcessSignEvent( 'cast_end' );
  5366.            
  5367.            
  5368.             FindMoveTarget();
  5369.             SetCanPlayHitAnim( true );
  5370.             this.SetBIsCombatActionAllowed( true );
  5371.            
  5372.             if ( this.GetFinisherVictim() && this.GetFinisherVictim().HasAbility( 'ForceFinisher' ) )
  5373.             {
  5374.                 this.GetFinisherVictim().SignalGameplayEvent( 'Finisher' );
  5375.             }
  5376.             else if (this.BufferCombatAction != EBAT_EMPTY )
  5377.             {
  5378.                
  5379.                
  5380.                    
  5381.                     if ( !IsCombatMusicEnabled() )
  5382.                     {
  5383.                         SetCombatActionHeading( ProcessCombatActionHeading( this.BufferCombatAction ) );
  5384.                         FindTarget();
  5385.                         UpdateDisplayTarget( true );
  5386.                     }
  5387.            
  5388.                     if ( AllowAttack( GetTarget(), this.BufferCombatAction ) )
  5389.                         this.ProcessCombatActionBuffer();
  5390.             }
  5391.             else
  5392.             {
  5393.                
  5394.                 ResumeEffects(EET_AutoStaminaRegen, 'InsideCombatAction');
  5395.                
  5396.                
  5397.                
  5398.             }
  5399.         }
  5400.         else if ( disableActionBlend )
  5401.         {
  5402.             disableActionBlend = false;
  5403.         }
  5404.     }
  5405.    
  5406.    
  5407.     event OnAnimEvent_Sign( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  5408.     {
  5409.         if( animEventType == AET_Tick )
  5410.         {
  5411.             ProcessSignEvent( animEventName );
  5412.         }
  5413.     }
  5414.    
  5415.     event OnAnimEvent_Throwable( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
  5416.     {
  5417.         var thrownEntity        : CThrowable;  
  5418.        
  5419.         thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
  5420.            
  5421.         if ( inv.IsItemCrossbow( inv.GetItemFromSlot('l_weapon') ) &&  rangedWeapon.OnProcessThrowEvent( animEventName ) )
  5422.         {      
  5423.             return true;
  5424.         }
  5425.         else if( thrownEntity && IsThrowingItem() && thrownEntity.OnProcessThrowEvent( animEventName ) )
  5426.         {
  5427.             return true;
  5428.         }  
  5429.     }  
  5430.    
  5431.     public function IsInCombatAction_SpecialAttack() : bool
  5432.     {
  5433.         if ( IsInCombatAction() && ( GetCombatAction() == EBAT_SpecialAttack_Light || GetCombatAction() == EBAT_SpecialAttack_Heavy ) )
  5434.             return true;
  5435.         else
  5436.             return false;
  5437.     }
  5438.    
  5439.     protected function WhenCombatActionIsFinished()
  5440.     {
  5441.         super.WhenCombatActionIsFinished();
  5442.         RemoveTimer( 'ProcessAttackTimer' );
  5443.         RemoveTimer( 'AttackTimerEnd' );
  5444.         CastSignAbort();
  5445.         specialAttackCamera = false;   
  5446.         this.OnPerformSpecialAttack( true, false );
  5447.     }
  5448.    
  5449.     event OnCombatActionEnd()
  5450.     {
  5451.         this.CleanCombatActionBuffer();    
  5452.         super.OnCombatActionEnd();
  5453.        
  5454.         RemoveTemporarySkills();
  5455.     }
  5456.    
  5457.     event OnCombatActionFriendlyEnd()
  5458.     {
  5459.         if ( IsCastingSign() )
  5460.         {
  5461.             SetBehaviorVariable( 'IsCastingSign', 0 );
  5462.             SetCurrentlyCastSign( ST_None, NULL );
  5463.             LogChannel( 'ST_None', "ST_None" );                
  5464.         }
  5465.  
  5466.         super.OnCombatActionFriendlyEnd();
  5467.     }
  5468.    
  5469.    
  5470.    
  5471.     timer function OpenRadialMenu( time: float, id : int )
  5472.     {
  5473.        
  5474.         if( GetBIsCombatActionAllowed() && !IsUITakeInput() )
  5475.         {
  5476.             bShowRadialMenu = true;
  5477.         }
  5478.        
  5479.         this.RemoveTimer('OpenRadialMenu');
  5480.     }
  5481.    
  5482.     public function OnAddRadialMenuOpenTimer(  )
  5483.     {
  5484.        
  5485.        
  5486.        
  5487.            
  5488.            
  5489.             this.AddTimer('OpenRadialMenu', _HoldBeforeOpenRadialMenuTime * theGame.GetTimeScale() );
  5490.        
  5491.     }
  5492.  
  5493.     public function SetShowRadialMenuOpenFlag( bSet : bool  )
  5494.     {
  5495.        
  5496.         bShowRadialMenu = bSet;
  5497.     }
  5498.    
  5499.     public function OnRemoveRadialMenuOpenTimer()
  5500.     {
  5501.        
  5502.         this.RemoveTimer('OpenRadialMenu');
  5503.     }
  5504.    
  5505.     public function ResetRadialMenuOpenTimer()
  5506.     {
  5507.        
  5508.         this.RemoveTimer('OpenRadialMenu');
  5509.         if( GetBIsCombatActionAllowed() )
  5510.         {
  5511.            
  5512.            
  5513.             AddTimer('OpenRadialMenu', _HoldBeforeOpenRadialMenuTime * theGame.GetTimeScale() );
  5514.         }
  5515.     }
  5516.  
  5517.    
  5518.    
  5519.     timer function ResendCompanionDisplayName(dt : float, id : int)
  5520.     {
  5521.         var hud : CR4ScriptedHud;
  5522.         var companionModule : CR4HudModuleCompanion;
  5523.        
  5524.         hud = (CR4ScriptedHud)theGame.GetHud();
  5525.         if( hud )
  5526.         {
  5527.             companionModule = (CR4HudModuleCompanion)hud.GetHudModule("CompanionModule");
  5528.             if( companionModule )
  5529.             {
  5530.                 companionModule.ResendDisplayName();
  5531.             }
  5532.         }
  5533.     }
  5534.  
  5535.     timer function ResendCompanionDisplayNameSecond(dt : float, id : int)
  5536.     {
  5537.         var hud : CR4ScriptedHud;
  5538.         var companionModule : CR4HudModuleCompanion;
  5539.        
  5540.         hud = (CR4ScriptedHud)theGame.GetHud();
  5541.         if( hud )
  5542.         {
  5543.             companionModule = (CR4HudModuleCompanion)hud.GetHudModule("CompanionModule");
  5544.             if( companionModule )
  5545.             {
  5546.                 companionModule.ResendDisplayNameSecond();
  5547.             }
  5548.         }
  5549.     }
  5550.    
  5551.     public function RemoveCompanionDisplayNameTimer()
  5552.     {
  5553.         this.RemoveTimer('ResendCompanionDisplayName');
  5554.     }
  5555.        
  5556.     public function RemoveCompanionDisplayNameTimerSecond()
  5557.     {
  5558.         this.RemoveTimer('ResendCompanionDisplayNameSecond');
  5559.     }
  5560.    
  5561.        
  5562.     public function GetCompanionNPCTag() : name
  5563.     {
  5564.         return companionNPCTag;
  5565.     }
  5566.  
  5567.     public function SetCompanionNPCTag( value : name )
  5568.     {
  5569.         companionNPCTag = value;
  5570.     }  
  5571.  
  5572.     public function GetCompanionNPCTag2() : name
  5573.     {
  5574.         return companionNPCTag2;
  5575.     }
  5576.  
  5577.     public function SetCompanionNPCTag2( value : name )
  5578.     {
  5579.         companionNPCTag2 = value;
  5580.     }
  5581.  
  5582.     public function GetCompanionNPCIconPath() : string
  5583.     {
  5584.         return companionNPCIconPath;
  5585.     }
  5586.  
  5587.     public function SetCompanionNPCIconPath( value : string )
  5588.     {
  5589.         companionNPCIconPath = value;
  5590.     }
  5591.  
  5592.     public function GetCompanionNPCIconPath2() : string
  5593.     {
  5594.         return companionNPCIconPath2;
  5595.     }
  5596.  
  5597.     public function SetCompanionNPCIconPath2( value : string )
  5598.     {
  5599.         companionNPCIconPath2 = value;
  5600.     }
  5601.    
  5602.    
  5603.  
  5604.     public function ReactToBeingHit(damageAction : W3DamageAction, optional buffNotApplied : bool) : bool
  5605.     {
  5606.         var chance : float;
  5607.         var procQuen : W3SignEntity;
  5608.        
  5609.         if(!damageAction.IsDoTDamage() && damageAction.DealsAnyDamage())
  5610.         {
  5611.             if(inv.IsItemBomb(selectedItemId))
  5612.             {
  5613.                 BombThrowAbort();
  5614.             }
  5615.             else
  5616.             {
  5617.                
  5618.                 ThrowingAbort();
  5619.             }          
  5620.         }      
  5621.        
  5622.        
  5623.         if(damageAction.IsActionRanged())
  5624.         {
  5625.             chance = CalculateAttributeValue(GetAttributeValue('quen_chance_on_projectile'));
  5626.             if(chance > 0)
  5627.             {
  5628.                 chance = ClampF(chance, 0, 1);
  5629.                
  5630.                 if(RandF() < chance)
  5631.                 {
  5632.                     procQuen = (W3SignEntity)theGame.CreateEntity(signs[ST_Quen].template, GetWorldPosition(), GetWorldRotation() );
  5633.                     procQuen.Init(signOwner, signs[ST_Quen].entity, true );
  5634.                     procQuen.OnStarted();
  5635.                     procQuen.OnThrowing();
  5636.                     procQuen.OnEnded();
  5637.                 }
  5638.             }
  5639.         }
  5640.        
  5641.        
  5642.         if( !((W3Effect_Toxicity)damageAction.causer) )
  5643.             MeditationForceAbort(true);
  5644.        
  5645.        
  5646.         if(IsDoingSpecialAttack(false))
  5647.             damageAction.SetHitAnimationPlayType(EAHA_ForceNo);
  5648.        
  5649.         return super.ReactToBeingHit(damageAction, buffNotApplied);
  5650.     }
  5651.    
  5652.     protected function ShouldPauseHealthRegenOnHit() : bool
  5653.     {
  5654.        
  5655.         if( (HasBuff(EET_Swallow) && GetPotionBuffLevel(EET_Swallow) >= 3) || HasBuff(EET_Runeword8) )
  5656.             return false;
  5657.            
  5658.         return true;
  5659.     }
  5660.        
  5661.     public function SetMappinToHighlight( mappinName : name, mappinState : bool )
  5662.     {
  5663.         var mappinDef : SHighlightMappin;
  5664.         mappinDef.MappinName = mappinName;
  5665.         mappinDef.MappinState = mappinState;
  5666.         MappinToHighlight.PushBack(mappinDef);
  5667.     }  
  5668.  
  5669.     public function ClearMappinToHighlight()
  5670.     {
  5671.         MappinToHighlight.Clear();
  5672.     }
  5673.    
  5674.     public function CastSignAbort()
  5675.     {
  5676.         if( currentlyCastSign != ST_None && signs[currentlyCastSign].entity)
  5677.         {
  5678.             signs[currentlyCastSign].entity.OnSignAborted();
  5679.         }
  5680.        
  5681.        
  5682.     }
  5683.    
  5684.     event OnBlockingSceneStarted( scene: CStoryScene )
  5685.     {
  5686.         var med : W3PlayerWitcherStateMeditationWaiting;
  5687.                
  5688.        
  5689.         med = (W3PlayerWitcherStateMeditationWaiting)GetCurrentState();
  5690.         if(med)
  5691.         {
  5692.             med.StopRequested(true);
  5693.         }
  5694.        
  5695.        
  5696.         super.OnBlockingSceneStarted( scene );
  5697.     }
  5698.    
  5699.    
  5700.    
  5701.    
  5702.    
  5703.     public function GetHorseManager() : W3HorseManager
  5704.     {
  5705.         return (W3HorseManager)EntityHandleGet( horseManagerHandle );
  5706.     }
  5707.    
  5708.    
  5709.     public function HorseEquipItem(horsesItemId : SItemUniqueId) : bool
  5710.     {
  5711.         var man : W3HorseManager;
  5712.        
  5713.         man = GetHorseManager();
  5714.         if(man)
  5715.             return man.EquipItem(horsesItemId) != GetInvalidUniqueId();
  5716.            
  5717.         return false;
  5718.     }
  5719.    
  5720.    
  5721.     public function HorseUnequipItem(slot : EEquipmentSlots) : bool
  5722.     {
  5723.         var man : W3HorseManager;
  5724.        
  5725.         man = GetHorseManager();
  5726.         if(man)
  5727.             return man.UnequipItem(slot) != GetInvalidUniqueId();
  5728.            
  5729.         return false;
  5730.     }
  5731.    
  5732.    
  5733.     public final function HorseRemoveItemByName(itemName : name, quantity : int)
  5734.     {
  5735.         var man : W3HorseManager;
  5736.        
  5737.         man = GetHorseManager();
  5738.         if(man)
  5739.             man.HorseRemoveItemByName(itemName, quantity);
  5740.     }
  5741.    
  5742.    
  5743.     public final function HorseRemoveItemByCategory(itemCategory : name, quantity : int)
  5744.     {
  5745.         var man : W3HorseManager;
  5746.        
  5747.         man = GetHorseManager();
  5748.         if(man)
  5749.             man.HorseRemoveItemByCategory(itemCategory, quantity);
  5750.     }
  5751.    
  5752.    
  5753.     public final function HorseRemoveItemByTag(itemTag : name, quantity : int)
  5754.     {
  5755.         var man : W3HorseManager;
  5756.        
  5757.         man = GetHorseManager();
  5758.         if(man)
  5759.             man.HorseRemoveItemByTag(itemTag, quantity);
  5760.     }
  5761.    
  5762.     public function GetAssociatedInventory() : CInventoryComponent
  5763.     {
  5764.         var man : W3HorseManager;
  5765.        
  5766.         man = GetHorseManager();
  5767.         if(man)
  5768.             return man.GetInventoryComponent();
  5769.            
  5770.         return NULL;
  5771.     }
  5772.    
  5773.    
  5774.    
  5775.    
  5776.    
  5777.     public final function TutorialMutagensUnequipPlayerSkills() : array<STutorialSavedSkill>
  5778.     {
  5779.         var pam : W3PlayerAbilityManager;
  5780.        
  5781.         pam = (W3PlayerAbilityManager)abilityManager;
  5782.         return pam.TutorialMutagensUnequipPlayerSkills();
  5783.     }
  5784.    
  5785.     public final function TutorialMutagensEquipOneGoodSkill()
  5786.     {
  5787.         var pam : W3PlayerAbilityManager;
  5788.        
  5789.         pam = (W3PlayerAbilityManager)abilityManager;
  5790.         pam.TutorialMutagensEquipOneGoodSkill();
  5791.     }
  5792.    
  5793.     public final function TutorialMutagensEquipOneGoodOneBadSkill()
  5794.     {
  5795.         var pam : W3PlayerAbilityManager;
  5796.        
  5797.         pam = (W3PlayerAbilityManager)abilityManager;
  5798.         if(pam)
  5799.             pam.TutorialMutagensEquipOneGoodOneBadSkill();
  5800.     }
  5801.    
  5802.     public final function TutorialMutagensEquipThreeGoodSkills()
  5803.     {
  5804.         var pam : W3PlayerAbilityManager;
  5805.        
  5806.         pam = (W3PlayerAbilityManager)abilityManager;
  5807.         if(pam)
  5808.             pam.TutorialMutagensEquipThreeGoodSkills();
  5809.     }
  5810.    
  5811.     public final function TutorialMutagensCleanupTempSkills(savedEquippedSkills : array<STutorialSavedSkill>)
  5812.     {
  5813.         var pam : W3PlayerAbilityManager;
  5814.        
  5815.         pam = (W3PlayerAbilityManager)abilityManager;
  5816.         return pam.TutorialMutagensCleanupTempSkills(savedEquippedSkills);
  5817.     }
  5818.    
  5819.    
  5820.    
  5821.    
  5822.    
  5823.     public function GetOffenseStatsList() : SPlayerOffenseStats
  5824.     {
  5825.         var playerOffenseStats:SPlayerOffenseStats;
  5826.         var steelDmg, silverDmg, elementalSteel, elementalSilver : float;
  5827.         var steelCritChance, steelCritDmg : float;
  5828.         var silverCritChance, silverCritDmg : float;
  5829.         var attackPower : SAbilityAttributeValue;
  5830.         var fastCritChance, fastCritDmg : float;
  5831.         var strongCritChance, strongCritDmg : float;
  5832.         var fastAP, strongAP : SAbilityAttributeValue;
  5833.         var item, crossbow : SItemUniqueId;
  5834.         var value : SAbilityAttributeValue;
  5835.         var mutagen : CBaseGameplayEffect;
  5836.         var thunder : W3Potion_Thunderbolt;
  5837.        
  5838.         if(!abilityManager || !abilityManager.IsInitialized())
  5839.             return playerOffenseStats;
  5840.        
  5841.         if (CanUseSkill(S_Sword_s21))
  5842.             fastAP += GetSkillAttributeValue(S_Sword_s21, PowerStatEnumToName(CPS_AttackPower), false, true) * GetSkillLevel(S_Sword_s21);
  5843.         if (CanUseSkill(S_Perk_05))
  5844.         {
  5845.             fastAP += GetAttributeValue('attack_power_fast_style');
  5846.             fastCritDmg += CalculateAttributeValue(GetAttributeValue('critical_hit_chance_fast_style'));
  5847.             strongCritDmg += CalculateAttributeValue(GetAttributeValue('critical_hit_chance_fast_style'));
  5848.         }
  5849.         if (CanUseSkill(S_Sword_s04))
  5850.             strongAP += GetSkillAttributeValue(S_Sword_s04, PowerStatEnumToName(CPS_AttackPower), false, true) * GetSkillLevel(S_Sword_s04);
  5851.         if (CanUseSkill(S_Perk_07))
  5852.             strongAP += GetAttributeValue('attack_power_heavy_style');
  5853.            
  5854.         if (CanUseSkill(S_Sword_s17))
  5855.         {
  5856.             fastCritChance += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s17, theGame.params.CRITICAL_HIT_CHANCE, false, true)) * GetSkillLevel(S_Sword_s17);
  5857.             fastCritDmg += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s17, theGame.params.CRITICAL_HIT_DAMAGE_BONUS, false, true)) * GetSkillLevel(S_Sword_s17);
  5858.         }
  5859.        
  5860.         if (CanUseSkill(S_Sword_s08))
  5861.         {
  5862.             strongCritChance += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s08, theGame.params.CRITICAL_HIT_CHANCE, false, true)) * GetSkillLevel(S_Sword_s08);
  5863.             strongCritDmg += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s08, theGame.params.CRITICAL_HIT_DAMAGE_BONUS, false, true)) * GetSkillLevel(S_Sword_s08);
  5864.         }
  5865.        
  5866.         if ( HasBuff(EET_Mutagen05) && (GetStat(BCS_Vitality) == GetStatMax(BCS_Vitality)) )
  5867.         {
  5868.             attackPower += GetAttributeValue('damageIncrease');
  5869.         }
  5870.        
  5871.         steelCritChance += CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_CHANCE));
  5872.         silverCritChance += CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_CHANCE));
  5873.         steelCritDmg += CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  5874.         silverCritDmg += CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  5875.         attackPower += GetPowerStatValue(CPS_AttackPower);
  5876.        
  5877.         if (GetItemEquippedOnSlot(EES_SteelSword, item))
  5878.         {
  5879.             steelDmg = GetTotalWeaponDamage(item, theGame.params.DAMAGE_NAME_SLASHING, GetInvalidUniqueId());
  5880.             steelDmg += GetTotalWeaponDamage(item, theGame.params.DAMAGE_NAME_PIERCING, GetInvalidUniqueId());
  5881.             steelDmg += GetTotalWeaponDamage(item, theGame.params.DAMAGE_NAME_BLUDGEONING, GetInvalidUniqueId());
  5882.             elementalSteel = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FIRE));
  5883.             elementalSteel += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FROST));
  5884.             if ( GetInventory().IsItemHeld(item) )
  5885.             {
  5886.                 steelCritChance -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  5887.                 silverCritChance -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  5888.                 steelCritDmg -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  5889.                 silverCritDmg -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  5890.             }
  5891.             steelCritChance += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  5892.             steelCritDmg += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  5893.            
  5894.             thunder = (W3Potion_Thunderbolt)GetBuff(EET_Thunderbolt);
  5895.             if(thunder && thunder.GetBuffLevel() == 3 && GetCurWeather() == EWE_Storm)
  5896.             {
  5897.                 steelCritChance += 1.0f;
  5898.             }
  5899.         }
  5900.         else
  5901.         {
  5902.             steelDmg += 0;
  5903.             steelCritChance += 0;
  5904.             steelCritDmg +=0;
  5905.         }
  5906.        
  5907.         if (GetItemEquippedOnSlot(EES_SilverSword, item))
  5908.         {
  5909.             silverDmg = GetTotalWeaponDamage(item, theGame.params.DAMAGE_NAME_SILVER, GetInvalidUniqueId());
  5910.             elementalSilver = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FIRE));
  5911.             elementalSilver += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FROST));
  5912.             if ( GetInventory().IsItemHeld(item) )
  5913.             {
  5914.                 steelCritChance -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  5915.                 silverCritChance -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  5916.                 steelCritDmg -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  5917.                 silverCritDmg -= CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  5918.             }
  5919.             silverCritChance += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
  5920.             silverCritDmg += CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
  5921.            
  5922.             thunder = (W3Potion_Thunderbolt)GetBuff(EET_Thunderbolt);
  5923.             if(thunder && thunder.GetBuffLevel() == 3 && GetCurWeather() == EWE_Storm)
  5924.             {
  5925.                 silverCritChance += 1.0f;
  5926.             }
  5927.         }
  5928.         else
  5929.         {
  5930.             silverDmg += 0;
  5931.             silverCritChance += 0;
  5932.             silverCritDmg +=0;
  5933.         }
  5934.        
  5935.         if ( HasAbility('Runeword 4 _Stats', true) )
  5936.         {
  5937.             steelDmg += steelDmg * (abilityManager.GetOverhealBonus() / GetStatMax(BCS_Vitality));
  5938.             silverDmg += silverDmg * (abilityManager.GetOverhealBonus() / GetStatMax(BCS_Vitality));
  5939.         }
  5940.        
  5941.         fastAP += attackPower;
  5942.         strongAP += attackPower;
  5943.        
  5944.         playerOffenseStats.steelFastCritChance = (steelCritChance + fastCritChance) * 100;
  5945.         playerOffenseStats.steelFastCritDmg = steelCritDmg + fastCritDmg;
  5946.         if ( steelDmg != 0 )
  5947.         {
  5948.             playerOffenseStats.steelFastDmg = (steelDmg + fastAP.valueBase) * fastAP.valueMultiplicative + fastAP.valueAdditive + elementalSteel;
  5949.             playerOffenseStats.steelFastCritDmg = (steelDmg + fastAP.valueBase) * (fastAP.valueMultiplicative + playerOffenseStats.steelFastCritDmg) + fastAP.valueAdditive + elementalSteel;
  5950.         }
  5951.         else
  5952.         {
  5953.             playerOffenseStats.steelFastDmg = 0;
  5954.             playerOffenseStats.steelFastCritDmg = 0;
  5955.         }
  5956.         playerOffenseStats.steelFastDPS = (playerOffenseStats.steelFastDmg * (100 - playerOffenseStats.steelFastCritChance) + playerOffenseStats.steelFastCritDmg * playerOffenseStats.steelFastCritChance) / 100;
  5957.         playerOffenseStats.steelFastDPS = playerOffenseStats.steelFastDPS / 0.6;
  5958.        
  5959.        
  5960.         playerOffenseStats.steelStrongCritChance = (steelCritChance + strongCritChance) * 100;
  5961.         playerOffenseStats.steelStrongCritDmg = steelCritDmg + strongCritDmg;
  5962.         if ( steelDmg != 0 )
  5963.         {
  5964.             playerOffenseStats.steelStrongDmg = (steelDmg + strongAP.valueBase) * strongAP.valueMultiplicative + strongAP.valueAdditive + elementalSteel;
  5965.             playerOffenseStats.steelStrongDmg *= 1.833f;
  5966.             playerOffenseStats.steelStrongCritDmg = (steelDmg + strongAP.valueBase) * (strongAP.valueMultiplicative + playerOffenseStats.steelStrongCritDmg) + strongAP.valueAdditive + elementalSteel;
  5967.             playerOffenseStats.steelStrongCritDmg *= 1.833f;        }
  5968.         else
  5969.         {
  5970.             playerOffenseStats.steelStrongDmg = 0;
  5971.             playerOffenseStats.steelStrongCritDmg = 0;
  5972.         }
  5973.         playerOffenseStats.steelStrongDPS = (playerOffenseStats.steelStrongDmg * (100 - playerOffenseStats.steelStrongCritChance) + playerOffenseStats.steelStrongCritDmg * playerOffenseStats.steelStrongCritChance) / 100;
  5974.         playerOffenseStats.steelStrongDPS = playerOffenseStats.steelStrongDPS / 1.1;
  5975.        
  5976.    
  5977.        
  5978.         playerOffenseStats.silverFastCritChance = (silverCritChance + fastCritChance) * 100;
  5979.         playerOffenseStats.silverFastCritDmg = silverCritDmg + fastCritDmg;
  5980.         if ( silverDmg != 0 )
  5981.         {
  5982.             playerOffenseStats.silverFastDmg = (silverDmg + fastAP.valueBase) * fastAP.valueMultiplicative + fastAP.valueAdditive + elementalSilver;
  5983.             playerOffenseStats.silverFastCritDmg = (silverDmg + fastAP.valueBase) * (fastAP.valueMultiplicative + playerOffenseStats.silverFastCritDmg) + fastAP.valueAdditive + elementalSilver;  
  5984.         }
  5985.         else
  5986.         {
  5987.             playerOffenseStats.silverFastDmg = 0;
  5988.             playerOffenseStats.silverFastCritDmg = 0;  
  5989.         }
  5990.         playerOffenseStats.silverFastDPS = (playerOffenseStats.silverFastDmg * (100 - playerOffenseStats.silverFastCritChance) + playerOffenseStats.silverFastCritDmg * playerOffenseStats.silverFastCritChance) / 100;
  5991.         playerOffenseStats.silverFastDPS = playerOffenseStats.silverFastDPS / 0.6;
  5992.        
  5993.        
  5994.         playerOffenseStats.silverStrongCritChance = (silverCritChance + strongCritChance) * 100;
  5995.         playerOffenseStats.silverStrongCritDmg = silverCritDmg + strongCritDmg;    
  5996.         if ( silverDmg != 0 )
  5997.         {
  5998.             playerOffenseStats.silverStrongDmg = (silverDmg + strongAP.valueBase) * strongAP.valueMultiplicative + strongAP.valueAdditive + elementalSilver;
  5999.             playerOffenseStats.silverStrongDmg *= 1.833f;
  6000.             playerOffenseStats.silverStrongCritDmg = (silverDmg + strongAP.valueBase) * (strongAP.valueMultiplicative + playerOffenseStats.silverStrongCritDmg) + strongAP.valueAdditive + elementalSilver;
  6001.             playerOffenseStats.silverStrongCritDmg *= 1.833f;
  6002.         }
  6003.         else
  6004.         {
  6005.             playerOffenseStats.silverStrongDmg = 0;
  6006.             playerOffenseStats.silverStrongCritDmg = 0;
  6007.         }
  6008.         playerOffenseStats.silverStrongDPS = (playerOffenseStats.silverStrongDmg * (100 - playerOffenseStats.silverStrongCritChance) + playerOffenseStats.silverStrongCritDmg * playerOffenseStats.silverStrongCritChance) / 100;
  6009.         playerOffenseStats.silverStrongDPS = playerOffenseStats.silverStrongDPS / 1.1;
  6010.        
  6011.        
  6012.         playerOffenseStats.crossbowCritChance = CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_CHANCE));
  6013.         if (CanUseSkill(S_Sword_s07))
  6014.             playerOffenseStats.crossbowCritChance += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s07, theGame.params.CRITICAL_HIT_CHANCE, false, true)) * GetSkillLevel(S_Sword_s07);
  6015.            
  6016.        
  6017.         playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_PIERCING;
  6018.         if (GetItemEquippedOnSlot(EES_Bolt, item))
  6019.         {
  6020.            
  6021.            
  6022.             steelDmg = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FIRE));
  6023.             if(steelDmg > 0)
  6024.             {
  6025.                 playerOffenseStats.crossbowSteelDmg = steelDmg;
  6026.                
  6027.                 playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_FIRE;
  6028.                 playerOffenseStats.crossbowSilverDmg = steelDmg;
  6029.             }
  6030.             else
  6031.             {
  6032.                 playerOffenseStats.crossbowSilverDmg = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_SILVER));
  6033.                
  6034.                 steelDmg = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_PIERCING));
  6035.                 if(steelDmg > 0)
  6036.                 {
  6037.                     playerOffenseStats.crossbowSteelDmg = steelDmg;
  6038.                     playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_PIERCING;
  6039.                 }
  6040.                 else
  6041.                 {
  6042.                     playerOffenseStats.crossbowSteelDmg = CalculateAttributeValue(GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_BLUDGEONING));
  6043.                     playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_BLUDGEONING;
  6044.                 }
  6045.             }
  6046.         }
  6047.        
  6048.         if (GetItemEquippedOnSlot(EES_RangedWeapon, item))
  6049.         {
  6050.             attackPower += GetInventory().GetItemAttributeValue(item, PowerStatEnumToName(CPS_AttackPower));
  6051.             if(CanUseSkill(S_Perk_02))
  6052.             {              
  6053.                 attackPower += GetSkillAttributeValue(S_Perk_02, PowerStatEnumToName(CPS_AttackPower), false, true);
  6054.             }
  6055.             playerOffenseStats.crossbowSteelDmg = (playerOffenseStats.crossbowSteelDmg + attackPower.valueBase) * attackPower.valueMultiplicative + attackPower.valueAdditive;
  6056.             playerOffenseStats.crossbowSilverDmg = (playerOffenseStats.crossbowSilverDmg + attackPower.valueBase) * attackPower.valueMultiplicative + attackPower.valueAdditive;
  6057.         }
  6058.         else
  6059.         {
  6060.             playerOffenseStats.crossbowSteelDmg = 0;
  6061.             playerOffenseStats.crossbowSilverDmg = 0;
  6062.             playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_PIERCING;
  6063.         }
  6064.        
  6065.         return playerOffenseStats;
  6066.     }
  6067.    
  6068.     public function GetTotalWeaponDamage(weaponId : SItemUniqueId, damageTypeName : name, crossbowId : SItemUniqueId) : float
  6069.     {
  6070.         var damage, durRatio, durMod : float;
  6071.         var repairObjectBonus : SAbilityAttributeValue;
  6072.        
  6073.         durMod = 0;
  6074.         damage = super.GetTotalWeaponDamage(weaponId, damageTypeName, crossbowId);
  6075.        
  6076.        
  6077.         if(IsPhysicalResistStat(GetResistForDamage(damageTypeName, false)))
  6078.         {
  6079.             repairObjectBonus = inv.GetItemAttributeValue(weaponId, theGame.params.REPAIR_OBJECT_BONUS);
  6080.             durRatio = -1;
  6081.            
  6082.             if(inv.IsIdValid(crossbowId) && inv.HasItemDurability(crossbowId))
  6083.             {
  6084.                 durRatio = inv.GetItemDurabilityRatio(crossbowId);
  6085.             }
  6086.             else if(inv.IsIdValid(weaponId) && inv.HasItemDurability(weaponId))
  6087.             {
  6088.                 durRatio = inv.GetItemDurabilityRatio(weaponId);
  6089.             }
  6090.            
  6091.            
  6092.             if(durRatio >= 0)
  6093.                 durMod = theGame.params.GetDurabilityMultiplier(durRatio, true);
  6094.             else
  6095.                 durMod = 1;
  6096.         }
  6097.        
  6098.         return damage * (durMod + repairObjectBonus.valueMultiplicative);
  6099.     }
  6100.    
  6101.    
  6102.    
  6103.    
  6104.    
  6105.     public final function GetSkillPathType(skill : ESkill) : ESkillPath
  6106.     {
  6107.         if(abilityManager && abilityManager.IsInitialized())
  6108.             return ((W3PlayerAbilityManager)abilityManager).GetSkillPathType(skill);
  6109.            
  6110.         return ESP_NotSet;
  6111.     }
  6112.    
  6113.     public function GetSkillLevel(s : ESkill) : int
  6114.     {
  6115.         if(abilityManager && abilityManager.IsInitialized())
  6116.             return ((W3PlayerAbilityManager)abilityManager).GetSkillLevel(s);
  6117.            
  6118.         return -1;
  6119.     }
  6120.    
  6121.     public function GetBoughtSkillLevel(s : ESkill) : int
  6122.     {
  6123.         if(abilityManager && abilityManager.IsInitialized())
  6124.             return ((W3PlayerAbilityManager)abilityManager).GetBoughtSkillLevel(s);
  6125.            
  6126.         return -1;
  6127.     }
  6128.    
  6129.    
  6130.     public function GetAxiiLevel() : int
  6131.     {
  6132.         var level : int;
  6133.        
  6134.         level = 1;
  6135.        
  6136.         if(CanUseSkill(S_Magic_s17)) level += GetSkillLevel(S_Magic_s17);
  6137.            
  6138.         return Clamp(level, 1, 4);
  6139.     }
  6140.    
  6141.     public function IsInFrenzy() : bool
  6142.     {
  6143.         return isInFrenzy;
  6144.     }
  6145.    
  6146.     public function HasRecentlyCountered() : bool
  6147.     {
  6148.         return hasRecentlyCountered;
  6149.     }
  6150.    
  6151.     public function SetRecentlyCountered(counter : bool)
  6152.     {
  6153.         hasRecentlyCountered = counter;
  6154.     }
  6155.    
  6156.     timer function CheckBlockedSkills(dt : float, id : int)
  6157.     {
  6158.         var nextCallTime : float;
  6159.        
  6160.         nextCallTime = ((W3PlayerAbilityManager)abilityManager).CheckBlockedSkills(dt);
  6161.         if(nextCallTime != -1)
  6162.             AddTimer('CheckBlockedSkills', nextCallTime, , , , true);
  6163.     }
  6164.        
  6165.    
  6166.     public function RemoveTemporarySkills()
  6167.     {
  6168.         var i : int;
  6169.         var pam : W3PlayerAbilityManager;
  6170.    
  6171.         if(tempLearnedSignSkills.Size() > 0)
  6172.         {
  6173.             pam = (W3PlayerAbilityManager)abilityManager;
  6174.             for(i=0; i<tempLearnedSignSkills.Size(); i+=1)
  6175.             {
  6176.                 pam.RemoveTemporarySkill(tempLearnedSignSkills[i]);
  6177.             }
  6178.            
  6179.             tempLearnedSignSkills.Clear();         
  6180.             RemoveAbilityAll(SkillEnumToName(S_Sword_s19));
  6181.         }      
  6182.     }
  6183.    
  6184.     public function RemoveTemporarySkill(skill : SSimpleSkill) : bool
  6185.     {
  6186.         var pam : W3PlayerAbilityManager;
  6187.        
  6188.         pam = (W3PlayerAbilityManager)abilityManager;
  6189.         if(pam && pam.IsInitialized())
  6190.             return pam.RemoveTemporarySkill(skill);
  6191.            
  6192.         return false;
  6193.     }
  6194.    
  6195.    
  6196.     private function AddTemporarySkills()
  6197.     {
  6198.         if(CanUseSkill(S_Sword_s19) && GetStat(BCS_Focus) >= 3)
  6199.         {
  6200.             tempLearnedSignSkills = ((W3PlayerAbilityManager)abilityManager).AddTempNonAlchemySkills();                    
  6201.             DrainFocus(GetStat(BCS_Focus));
  6202.             AddAbilityMultiple(SkillEnumToName(S_Sword_s19), GetSkillLevel(S_Sword_s19));          
  6203.         }
  6204.     }
  6205.  
  6206.    
  6207.    
  6208.     public function HasAlternateQuen() : bool
  6209.     {
  6210.         var quenEntity : W3QuenEntity;
  6211.        
  6212.         quenEntity = (W3QuenEntity)GetCurrentSignEntity();
  6213.         if(quenEntity)
  6214.         {
  6215.             return quenEntity.IsAlternateCast();
  6216.         }
  6217.        
  6218.         return false;
  6219.     }
  6220.    
  6221.    
  6222.    
  6223.    
  6224.    
  6225.     public function AddPoints(type : ESpendablePointType, amount : int, show : bool)
  6226.     {
  6227.         levelManager.AddPoints(type, amount, show);
  6228.     }
  6229.    
  6230.     public function GetLevel() : int                                            {return levelManager.GetLevel();}
  6231.     public function GetTotalExpForNextLevel() : int                             {return levelManager.GetTotalExpForNextLevel();}   
  6232.     public function GetPointsTotal(type : ESpendablePointType) : int            {return levelManager.GetPointsTotal(type);}
  6233.     public function IsAutoLeveling() : bool                                     {return autoLevel;}
  6234.     public function SetAutoLeveling( b : bool )                                 {autoLevel = b;}
  6235.    
  6236.     public function GetMissingExpForNextLevel() : int
  6237.     {
  6238.         return Max(0, GetTotalExpForNextLevel() - GetPointsTotal(EExperiencePoint));
  6239.     }
  6240.    
  6241.    
  6242.    
  6243.    
  6244.     private saved var runewordInfusionType : ESignType;
  6245.     default runewordInfusionType = ST_None;
  6246.    
  6247.     public final function GetRunewordInfusionType() : ESignType
  6248.     {
  6249.         return runewordInfusionType;
  6250.     }
  6251.  
  6252.     public function OnSignCastPerformed(signType : ESignType, isAlternate : bool)
  6253.     {
  6254.         var items : array<SItemUniqueId>;
  6255.         var weaponEnt : CEntity;
  6256.         var fxName : name;
  6257.        
  6258.         super.OnSignCastPerformed(signType, isAlternate);
  6259.        
  6260.         if(HasAbility('Runeword 1 _Stats', true) && GetStat(BCS_Focus) >= 1.0f)
  6261.         {
  6262.             DrainFocus(1.0f);
  6263.             runewordInfusionType = signType;
  6264.             items = inv.GetHeldWeapons();
  6265.             weaponEnt = inv.GetItemEntityUnsafe(items[0]);
  6266.            
  6267.            
  6268.             weaponEnt.StopEffect('runeword_aard');
  6269.             weaponEnt.StopEffect('runeword_axii');
  6270.             weaponEnt.StopEffect('runeword_igni');
  6271.             weaponEnt.StopEffect('runeword_quen');
  6272.             weaponEnt.StopEffect('runeword_yrden');
  6273.                    
  6274.            
  6275.             if(signType == ST_Aard)
  6276.                 fxName = 'runeword_aard';
  6277.             else if(signType == ST_Axii)
  6278.                 fxName = 'runeword_axii';
  6279.             else if(signType == ST_Igni)
  6280.                 fxName = 'runeword_igni';
  6281.             else if(signType == ST_Quen)
  6282.                 fxName = 'runeword_quen';
  6283.             else if(signType == ST_Yrden)
  6284.                 fxName = 'runeword_yrden';
  6285.                
  6286.             weaponEnt.PlayEffect(fxName);
  6287.         }
  6288.     }
  6289.    
  6290.     public saved var savedQuenHealth, savedQuenDuration : float;
  6291.    
  6292.     timer function HACK_QuenSaveStatus(dt : float, id : int)
  6293.     {
  6294.         var quenEntity : W3QuenEntity;
  6295.        
  6296.         quenEntity = (W3QuenEntity)signs[ST_Quen].entity;
  6297.         savedQuenHealth = quenEntity.GetShieldHealth();
  6298.         savedQuenDuration = quenEntity.GetShieldRemainingDuration();
  6299.     }
  6300.    
  6301.     timer function DelayedRestoreQuen(dt : float, id : int)
  6302.     {
  6303.         RestoreQuen(savedQuenHealth, savedQuenDuration);
  6304.     }
  6305.    
  6306.     public final function OnBasicQuenFinishing()
  6307.     {
  6308.         RemoveTimer('HACK_QuenSaveStatus');
  6309.         savedQuenHealth = 0.f;
  6310.         savedQuenDuration = 0.f;
  6311.     }
  6312.    
  6313.     public final function IsAnyQuenActive() : bool
  6314.     {
  6315.         var quen : W3QuenEntity;
  6316.        
  6317.         quen = (W3QuenEntity)GetSignEntity(ST_Quen);
  6318.         if(quen)
  6319.             return quen.IsAnyQuenActive();
  6320.            
  6321.         return false;
  6322.     }
  6323.    
  6324.     public final function IsQuenActive(alternateMode : bool) : bool
  6325.     {
  6326.         if(IsAnyQuenActive() && GetSignEntity(ST_Quen).IsAlternateCast() == alternateMode)
  6327.             return true;
  6328.            
  6329.         return false;
  6330.     }
  6331.    
  6332.     public function FinishQuen(skipVisuals : bool)
  6333.     {
  6334.         var quen : W3QuenEntity;
  6335.        
  6336.         quen = (W3QuenEntity)GetSignEntity(ST_Quen);
  6337.         if(quen)
  6338.             quen.ForceFinishQuen(skipVisuals);
  6339.     }
  6340.    
  6341.    
  6342.     public function GetTotalSignSpellPower(signSkill : ESkill) : SAbilityAttributeValue
  6343.     {
  6344.         var sp : SAbilityAttributeValue;
  6345.         var penalty : SAbilityAttributeValue;
  6346.         var penaltyReduction : float;
  6347.         var penaltyReductionLevel : int;
  6348.        
  6349.        
  6350.         sp = GetSkillAttributeValue(signSkill, PowerStatEnumToName(CPS_SpellPower), true, true);
  6351.        
  6352.        
  6353.         if ( signSkill == S_Magic_s01 )
  6354.         {
  6355.            
  6356.             penaltyReductionLevel = GetSkillLevel(S_Magic_s01) + 1;
  6357.             if(penaltyReductionLevel > 0)
  6358.             {
  6359.                 penaltyReduction = 1 - penaltyReductionLevel * CalculateAttributeValue(GetSkillAttributeValue(S_Magic_s01, 'spell_power_penalty_reduction', true, true));
  6360.                 penalty = GetSkillAttributeValue(S_Magic_s01, PowerStatEnumToName(CPS_SpellPower), false, false);
  6361.                 sp += penalty * penaltyReduction;  
  6362.             }
  6363.         }
  6364.        
  6365.        
  6366.         if(signSkill == S_Magic_1 || signSkill == S_Magic_s01)
  6367.         {
  6368.             sp += GetAttributeValue('spell_power_aard');
  6369.         }
  6370.         else if(signSkill == S_Magic_2 || signSkill == S_Magic_s02)
  6371.         {
  6372.             sp += GetAttributeValue('spell_power_igni');
  6373.         }
  6374.         else if(signSkill == S_Magic_3 || signSkill == S_Magic_s03)
  6375.         {
  6376.             sp += GetAttributeValue('spell_power_yrden');
  6377.         }
  6378.         else if(signSkill == S_Magic_4 || signSkill == S_Magic_s04)
  6379.         {
  6380.             sp += GetAttributeValue('spell_power_quen');
  6381.         }
  6382.         else if(signSkill == S_Magic_5 || signSkill == S_Magic_s05)
  6383.         {
  6384.             sp += GetAttributeValue('spell_power_axii');
  6385.         }
  6386.        
  6387.         return sp;
  6388.     }
  6389.    
  6390.    
  6391.    
  6392.    
  6393.    
  6394.     public final function GetGwentCardIndex( cardName : name ) : int
  6395.     {
  6396.         var dm : CDefinitionsManagerAccessor;
  6397.        
  6398.         dm = theGame.GetDefinitionsManager();
  6399.        
  6400.         if(dm.ItemHasTag( cardName , 'GwintCardLeader' ))
  6401.         {
  6402.             return theGame.GetGwintManager().GwentLeadersNametoInt( cardName );
  6403.         }
  6404.         else if(dm.ItemHasTag( cardName , 'GwintCardNrkd' ))
  6405.         {
  6406.             return theGame.GetGwintManager().GwentNrkdNameToInt( cardName );
  6407.         }
  6408.         else if(dm.ItemHasTag( cardName , 'GwintCardNlfg' ))
  6409.         {
  6410.             return theGame.GetGwintManager().GwentNlfgNameToInt( cardName );
  6411.         }
  6412.         else if(dm.ItemHasTag( cardName , 'GwintCardSctl' ))
  6413.         {
  6414.             return theGame.GetGwintManager().GwentSctlNameToInt( cardName );
  6415.         }
  6416.         else if(dm.ItemHasTag( cardName , 'GwintCardMstr' ))
  6417.         {
  6418.             return theGame.GetGwintManager().GwentMstrNameToInt( cardName );
  6419.         }
  6420.         else if(dm.ItemHasTag( cardName , 'GwintCardNeutral' ))
  6421.         {
  6422.             return theGame.GetGwintManager().GwentNeutralNameToInt( cardName );
  6423.         }
  6424.         else if(dm.ItemHasTag( cardName , 'GwintCardSpcl' ))
  6425.         {
  6426.             return theGame.GetGwintManager().GwentSpecialNameToInt( cardName );
  6427.         }
  6428.        
  6429.         return -1;
  6430.     }
  6431.    
  6432.     public final function AddGwentCard(cardName : name, amount : int) : bool
  6433.     {
  6434.         var dm : CDefinitionsManagerAccessor;
  6435.         var cardIndex, i : int;
  6436.         var tut : STutorialMessage;
  6437.        
  6438.        
  6439.        
  6440.         if(FactsQuerySum("q001_nightmare_ended") > 0 && ShouldProcessTutorial('TutorialGwentDeckBuilder2'))
  6441.         {
  6442.             tut.type = ETMT_Hint;
  6443.             tut.tutorialScriptTag = 'TutorialGwentDeckBuilder2';
  6444.             tut.journalEntryName = 'TutorialGwentDeckBuilder2';
  6445.             tut.hintPositionType = ETHPT_DefaultGlobal;
  6446.             tut.markAsSeenOnShow = true;
  6447.             tut.hintDurationType = ETHDT_Long;
  6448.  
  6449.             theGame.GetTutorialSystem().DisplayTutorial(tut);
  6450.         }
  6451.        
  6452.         dm = theGame.GetDefinitionsManager();
  6453.        
  6454.         cardIndex = GetGwentCardIndex(cardName);
  6455.        
  6456.         if (cardIndex != -1)
  6457.         {
  6458.             FactsAdd("Gwint_Card_Looted");
  6459.            
  6460.             for(i = 0; i < amount; i += 1)
  6461.             {
  6462.                 theGame.GetGwintManager().AddCardToCollection( cardIndex );
  6463.             }
  6464.         }
  6465.        
  6466.         if( dm.ItemHasTag( cardName, 'GwentTournament' ) )
  6467.         {
  6468.             if ( dm.ItemHasTag( cardName, 'GT1' ) )
  6469.             {
  6470.                 FactsAdd( "GwentTournament", 1 );
  6471.             }
  6472.            
  6473.             else if ( dm.ItemHasTag( cardName, 'GT2' ) )
  6474.             {
  6475.                 FactsAdd( "GwentTournament", 2 );
  6476.             }
  6477.            
  6478.             else if ( dm.ItemHasTag( cardName, 'GT3' ) )
  6479.             {
  6480.                 FactsAdd( "GwentTournament", 3 );
  6481.             }
  6482.            
  6483.             else if ( dm.ItemHasTag( cardName, 'GT4' ) )
  6484.             {
  6485.                 FactsAdd( "GwentTournament", 4 );
  6486.             }
  6487.            
  6488.             else if ( dm.ItemHasTag( cardName, 'GT5' ) )
  6489.             {
  6490.                 FactsAdd( "GwentTournament", 5 );
  6491.             }
  6492.            
  6493.             else if ( dm.ItemHasTag( cardName, 'GT6' ) )
  6494.             {
  6495.                 FactsAdd( "GwentTournament", 6 );
  6496.             }
  6497.            
  6498.             else if ( dm.ItemHasTag( cardName, 'GT7' ) )
  6499.             {
  6500.                 FactsAdd( "GwentTournament", 7 );
  6501.             }
  6502.            
  6503.             CheckGwentTournamentDeck();
  6504.         }
  6505.         else
  6506.         {
  6507.             return false;
  6508.         }
  6509.        
  6510.         return true;
  6511.     }
  6512.    
  6513.    
  6514.     public final function RemoveGwentCard(cardName : name, amount : int) : bool
  6515.     {
  6516.         var dm : CDefinitionsManagerAccessor;
  6517.         var cardIndex, i : int;
  6518.        
  6519.         dm = theGame.GetDefinitionsManager();
  6520.        
  6521.         if(dm.ItemHasTag( cardName , 'GwintCardLeader' ))
  6522.         {
  6523.             cardIndex = theGame.GetGwintManager().GwentLeadersNametoInt( cardName );
  6524.             for(i=0; i<amount; i+=1)
  6525.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  6526.         }
  6527.         else if(dm.ItemHasTag( cardName , 'GwintCardNrkd' ))
  6528.         {
  6529.             cardIndex = theGame.GetGwintManager().GwentNrkdNameToInt( cardName );
  6530.             for(i=0; i<amount; i+=1)
  6531.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  6532.         }
  6533.         else if(dm.ItemHasTag( cardName , 'GwintCardNlfg' ))
  6534.         {
  6535.             cardIndex = theGame.GetGwintManager().GwentNlfgNameToInt( cardName );
  6536.             for(i=0; i<amount; i+=1)
  6537.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  6538.         }
  6539.         else if(dm.ItemHasTag( cardName , 'GwintCardSctl' ))
  6540.         {
  6541.             cardIndex = theGame.GetGwintManager().GwentSctlNameToInt( cardName );
  6542.             for(i=0; i<amount; i+=1)
  6543.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  6544.         }
  6545.         else if(dm.ItemHasTag( cardName , 'GwintCardMstr' ))
  6546.         {
  6547.             cardIndex = theGame.GetGwintManager().GwentMstrNameToInt( cardName );
  6548.             for(i=0; i<amount; i+=1)
  6549.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  6550.         }
  6551.         else if(dm.ItemHasTag( cardName , 'GwintCardNeutral' ))
  6552.         {
  6553.             cardIndex = theGame.GetGwintManager().GwentNeutralNameToInt( cardName );
  6554.             for(i=0; i<amount; i+=1)
  6555.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  6556.         }
  6557.         else if(dm.ItemHasTag( cardName , 'GwintCardSpcl' ))
  6558.         {
  6559.             cardIndex = theGame.GetGwintManager().GwentSpecialNameToInt( cardName );
  6560.             for(i=0; i<amount; i+=1)
  6561.                 theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
  6562.         }
  6563.        
  6564.         if( dm.ItemHasTag( cardName, 'GwentTournament' ) )
  6565.         {
  6566.             if ( dm.ItemHasTag( cardName, 'GT1' ) )
  6567.             {
  6568.                 FactsSubstract( "GwentTournament", 1 );
  6569.             }
  6570.            
  6571.             else if ( dm.ItemHasTag( cardName, 'GT2' ) )
  6572.             {
  6573.                 FactsSubstract( "GwentTournament", 2 );
  6574.             }
  6575.            
  6576.             else if ( dm.ItemHasTag( cardName, 'GT3' ) )
  6577.             {
  6578.                 FactsSubstract( "GwentTournament", 3 );
  6579.             }
  6580.            
  6581.             else if ( dm.ItemHasTag( cardName, 'GT4' ) )
  6582.             {
  6583.                 FactsSubstract( "GwentTournament", 4 );
  6584.             }
  6585.            
  6586.             else if ( dm.ItemHasTag( cardName, 'GT5' ) )
  6587.             {
  6588.                 FactsSubstract( "GwentTournament", 5 );
  6589.             }
  6590.            
  6591.             else if ( dm.ItemHasTag( cardName, 'GT6' ) )
  6592.             {
  6593.                 FactsSubstract( "GwentTournament", 6 );
  6594.             }
  6595.            
  6596.             else if ( dm.ItemHasTag( cardName, 'GT7' ) )
  6597.             {
  6598.                 FactsSubstract( "GwentTournament", 7 );
  6599.             }
  6600.            
  6601.             CheckGwentTournamentDeck();
  6602.         }
  6603.        
  6604.         else
  6605.         {
  6606.             return false;
  6607.         }
  6608.        
  6609.         return true;
  6610.     }
  6611.    
  6612.     function CheckGwentTournamentDeck()
  6613.     {
  6614.         var gwentPower          : int;
  6615.         var neededGwentPower    : int;
  6616.         var checkBreakpoint     : int;
  6617.        
  6618.         neededGwentPower = 70;
  6619.        
  6620.         checkBreakpoint = neededGwentPower/5;
  6621.         gwentPower = FactsQuerySum( "GwentTournament" );
  6622.        
  6623.         if ( gwentPower >= neededGwentPower )
  6624.         {
  6625.             FactsAdd( "HasGwentTournamentDeck", 1 );
  6626.         }
  6627.         else
  6628.         {
  6629.             if( FactsDoesExist( "HasGwentTournamentDeck" ) )
  6630.             {
  6631.                 FactsRemove( "HasGwentTournamentDeck" );
  6632.             }
  6633.            
  6634.             if ( gwentPower >= checkBreakpoint )
  6635.             {
  6636.                 FactsAdd( "GwentTournamentObjective1", 1 );
  6637.             }
  6638.             else if ( FactsDoesExist( "GwentTournamentObjective1" ) )
  6639.             {
  6640.                 FactsRemove( "GwentTournamentObjective1" );
  6641.             }
  6642.            
  6643.             if ( gwentPower >= checkBreakpoint*2 )
  6644.             {
  6645.                 FactsAdd( "GwentTournamentObjective2", 1 );
  6646.             }
  6647.             else if ( FactsDoesExist( "GwentTournamentObjective2" ) )
  6648.             {
  6649.                 FactsRemove( "GwentTournamentObjective2" );
  6650.             }
  6651.            
  6652.             if ( gwentPower >= checkBreakpoint*3 )
  6653.             {
  6654.                 FactsAdd( "GwentTournamentObjective3", 1 );
  6655.             }
  6656.             else if ( FactsDoesExist( "GwentTournamentObjective3" ) )
  6657.             {
  6658.                 FactsRemove( "GwentTournamentObjective3" );
  6659.             }
  6660.            
  6661.             if ( gwentPower >= checkBreakpoint*4 )
  6662.             {
  6663.                 FactsAdd( "GwentTournamentObjective4", 1 );
  6664.             }
  6665.             else if ( FactsDoesExist( "GwentTournamentObjective4" ) )
  6666.             {
  6667.                 FactsRemove( "GwentTournamentObjective4" );
  6668.             }
  6669.         }
  6670.     }
  6671.    
  6672.    
  6673.    
  6674.    
  6675.    
  6676.    
  6677.     public function SimulateBuffTimePassing(simulatedTime : float)
  6678.     {
  6679.         super.SimulateBuffTimePassing(simulatedTime);
  6680.        
  6681.         FinishQuen(true);
  6682.     }
  6683.    
  6684.    
  6685.     public function CanMeditate() : bool
  6686.     {
  6687.         var currentStateName : name;
  6688.        
  6689.         currentStateName = GetCurrentStateName();
  6690.        
  6691.        
  6692.         if(currentStateName == 'Exploration' && !CanPerformPlayerAction())
  6693.             return false;
  6694.        
  6695.        
  6696.         if(GetCurrentStateName() != 'Exploration' && GetCurrentStateName() != 'Meditation' && GetCurrentStateName() != 'MeditationWaiting')
  6697.             return false;
  6698.            
  6699.        
  6700.         if(GetUsedVehicle())
  6701.             return false;
  6702.            
  6703.        
  6704.         return CanMeditateHere();
  6705.     }
  6706.    
  6707.    
  6708.     public final function CanMeditateWait(optional skipMeditationStateCheck : bool) : bool
  6709.     {
  6710.         var currState : name;
  6711.        
  6712.         currState = GetCurrentStateName();
  6713.        
  6714.        
  6715.        
  6716.         if(!skipMeditationStateCheck && currState != 'Meditation')
  6717.             return false;
  6718.            
  6719.        
  6720.         if(theGame.IsGameTimePaused())
  6721.             return false;
  6722.            
  6723.         if(!IsActionAllowed( EIAB_MeditationWaiting ))
  6724.             return false;
  6725.            
  6726.         return true;
  6727.     }
  6728.  
  6729.    
  6730.     public final function CanMeditateHere() : bool
  6731.     {
  6732.         var pos : Vector;
  6733.        
  6734.         pos = GetWorldPosition();
  6735.         if(pos.Z <= theGame.GetWorld().GetWaterLevel(pos, true) && IsInShallowWater())
  6736.             return false;
  6737.        
  6738.         if(IsThreatened())
  6739.             return false;
  6740.        
  6741.         return true;
  6742.     }
  6743.    
  6744.    
  6745.     public function Meditate()
  6746.     {
  6747.         var medState            : W3PlayerWitcherStateMeditation;
  6748.    
  6749.         if (!CanMeditate() || GetCurrentStateName() == 'Meditation' || GetCurrentStateName() == 'MeditationWaiting')
  6750.             return;
  6751.    
  6752.         GotoState('Meditation');
  6753.         medState = (W3PlayerWitcherStateMeditation)GetState('Meditation');     
  6754.         medState.SetMeditationPointHeading(GetHeading());
  6755.     }
  6756.    
  6757.    
  6758.     public final function MeditationRestoring(simulatedTime : float)
  6759.     {
  6760.        
  6761.         if ( theGame.GetDifficultyMode() != EDM_Hard && theGame.GetDifficultyMode() != EDM_Hardcore )
  6762.         {
  6763.             Heal(GetStatMax(BCS_Vitality));
  6764.         }
  6765.        
  6766.        
  6767.         abilityManager.DrainToxicity( abilityManager.GetStat( BCS_Toxicity ) );
  6768.         abilityManager.DrainFocus( abilityManager.GetStat( BCS_Focus ) );
  6769.        
  6770.        
  6771.         inv.SingletonItemsRefillAmmo();
  6772.        
  6773.        
  6774.         SimulateBuffTimePassing(simulatedTime);
  6775.     }
  6776.    
  6777.     var clockMenu : CR4MeditationClockMenu;
  6778.    
  6779.     public function MeditationClockStart(m : CR4MeditationClockMenu)
  6780.     {
  6781.         clockMenu = m;
  6782.         AddTimer('UpdateClockTime',0.1,true);
  6783.     }
  6784.    
  6785.     public function MeditationClockStop()
  6786.     {
  6787.         clockMenu = NULL;
  6788.         RemoveTimer('UpdateClockTime');
  6789.     }
  6790.    
  6791.     public timer function UpdateClockTime(dt : float, id : int)
  6792.     {
  6793.         if(clockMenu)
  6794.             clockMenu.UpdateCurrentHours();
  6795.         else
  6796.             RemoveTimer('UpdateClockTime');
  6797.     }
  6798.    
  6799.     private var waitTimeHour : int;
  6800.     public function SetWaitTargetHour(t : int)
  6801.     {
  6802.         waitTimeHour = t;
  6803.     }
  6804.     public function GetWaitTargetHour() : int
  6805.     {
  6806.         return waitTimeHour;
  6807.     }
  6808.    
  6809.     public function MeditationForceAbort(forceCloseUI : bool)
  6810.     {
  6811.         var waitt : W3PlayerWitcherStateMeditationWaiting;
  6812.         var medd : W3PlayerWitcherStateMeditation;
  6813.         var currentStateName : name;
  6814.        
  6815.         currentStateName = GetCurrentStateName();
  6816.        
  6817.         if(currentStateName == 'MeditationWaiting')
  6818.         {
  6819.             waitt = (W3PlayerWitcherStateMeditationWaiting)GetCurrentState();
  6820.             if(waitt)
  6821.             {
  6822.                 waitt.StopRequested(forceCloseUI);
  6823.             }
  6824.         }
  6825.         else if(currentStateName == 'Meditation')
  6826.         {
  6827.             medd = (W3PlayerWitcherStateMeditation)GetCurrentState();
  6828.             if(medd)
  6829.             {
  6830.                 medd.StopRequested(forceCloseUI);
  6831.             }
  6832.         }
  6833.        
  6834.        
  6835.        
  6836.         if(forceCloseUI && theGame.GetGuiManager().IsAnyMenu())
  6837.         {
  6838.             theGame.GetGuiManager().GetRootMenu().CloseMenu();
  6839.             DisplayActionDisallowedHudMessage(EIAB_MeditationWaiting, false, false, true, false);
  6840.         }
  6841.     }
  6842.    
  6843.     public function Runeword10Triggerred()
  6844.     {
  6845.         var min, max : SAbilityAttributeValue;
  6846.        
  6847.         theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Runeword 10 _Stats', 'stamina', min, max );
  6848.         GainStat(BCS_Stamina, min.valueMultiplicative * GetStatMax(BCS_Stamina));
  6849.         PlayEffect('runeword_10_stamina');
  6850.     }
  6851.    
  6852.     public function Runeword12Triggerred()
  6853.     {
  6854.         var min, max : SAbilityAttributeValue;
  6855.        
  6856.         theGame.GetDefinitionsManager().GetAbilityAttributeValue( 'Runeword 12 _Stats', 'focus', min, max );
  6857.         GainStat(BCS_Focus, RandRangeF(max.valueAdditive, min.valueAdditive));
  6858.         PlayEffect('runeword_20_adrenaline');  
  6859.     }
  6860.    
  6861.     var runeword10TriggerredOnFinisher, runeword12TriggerredOnFinisher : bool;
  6862.    
  6863.     event OnFinisherStart()
  6864.     {
  6865.         super.OnFinisherStart();
  6866.        
  6867.         runeword10TriggerredOnFinisher = false;
  6868.         runeword12TriggerredOnFinisher = false;
  6869.     }
  6870.    
  6871.    
  6872.    
  6873.    
  6874.    
  6875.     public function CheatResurrect()
  6876.     {
  6877.         super.CheatResurrect();
  6878.         theGame.ReleaseNoSaveLock(theGame.deathSaveLockId);
  6879.         theInput.RestoreContext( 'Exploration', true );
  6880.     }
  6881.    
  6882.    
  6883.     public function Debug_EquipTestingSkills(equip : bool, force : bool)
  6884.     {
  6885.         var skills : array<ESkill>;
  6886.         var i, slot : int;
  6887.        
  6888.        
  6889.         ((W3PlayerAbilityManager)abilityManager).OnLevelGained(36);
  6890.        
  6891.         skills.PushBack(S_Magic_s01);
  6892.         skills.PushBack(S_Magic_s02);
  6893.         skills.PushBack(S_Magic_s03);
  6894.         skills.PushBack(S_Magic_s04);
  6895.         skills.PushBack(S_Magic_s05);
  6896.         skills.PushBack(S_Sword_s01);
  6897.         skills.PushBack(S_Sword_s02);
  6898.        
  6899.        
  6900.         if(equip)
  6901.         {
  6902.             for(i=0; i<skills.Size(); i+=1)
  6903.             {
  6904.                 if(!force && IsSkillEquipped(skills[i]))
  6905.                     continue;
  6906.                    
  6907.                
  6908.                 if(GetSkillLevel(skills[i]) == 0)
  6909.                     AddSkill(skills[i]);
  6910.                
  6911.                
  6912.                 if(force)
  6913.                     slot = i+1;    
  6914.                 else
  6915.                     slot = GetFreeSkillSlot();
  6916.                
  6917.                
  6918.                 EquipSkill(skills[i], slot);
  6919.             }
  6920.         }
  6921.         else
  6922.         {
  6923.             for(i=0; i<skills.Size(); i+=1)
  6924.             {
  6925.                 UnequipSkill(GetSkillSlotID(skills[i]));
  6926.             }
  6927.         }
  6928.     }
  6929.    
  6930.     public function Debug_ClearCharacterDevelopment(optional keepInv : bool)
  6931.     {
  6932.         var template : CEntityTemplate;
  6933.         var entity : CEntity;
  6934.         var invTesting : CInventoryComponent;
  6935.         var i : int;
  6936.         var items : array<SItemUniqueId>;
  6937.         var abs : array<name>;
  6938.    
  6939.         delete abilityManager;
  6940.         delete levelManager;
  6941.         delete effectManager;
  6942.        
  6943.        
  6944.         abs = GetAbilities(false);
  6945.         for(i=0; i<abs.Size(); i+=1)
  6946.             RemoveAbility(abs[i]);
  6947.            
  6948.        
  6949.         abs.Clear();
  6950.         GetCharacterStatsParam(abs);       
  6951.         for(i=0; i<abs.Size(); i+=1)
  6952.             AddAbility(abs[i]);
  6953.                    
  6954.        
  6955.         levelManager = new W3LevelManager in this;         
  6956.         levelManager.Initialize();
  6957.         levelManager.PostInit(this, false);    
  6958.                        
  6959.        
  6960.         AddAbility('GeraltSkills_Testing');
  6961.         SetAbilityManager();       
  6962.         abilityManager.Init(this, GetCharacterStats(), false, theGame.GetDifficultyMode());
  6963.        
  6964.         SetEffectManager();
  6965.        
  6966.         abilityManager.PostInit();                     
  6967.        
  6968.        
  6969.        
  6970.        
  6971.        
  6972.         if(!keepInv)
  6973.         {
  6974.             inv.RemoveAllItems();
  6975.         }      
  6976.        
  6977.        
  6978.         template = (CEntityTemplate)LoadResource("geralt_inventory_release");
  6979.         entity = theGame.CreateEntity(template, Vector(0,0,0));
  6980.         invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
  6981.         invTesting.GiveAllItemsTo(inv, true);
  6982.         entity.Destroy();
  6983.        
  6984.        
  6985.         inv.GetAllItems(items);
  6986.         for(i=0; i<items.Size(); i+=1)
  6987.         {
  6988.             if(!inv.ItemHasTag(items[i], 'NoDrop'))        
  6989.                 EquipItem(items[i]);
  6990.         }
  6991.            
  6992.        
  6993.         Debug_GiveTestingItems(0);
  6994.     }
  6995.    
  6996.     final function Debug_HAX_UnlockSkillSlot(slotIndex : int) : bool
  6997.     {
  6998.         if(abilityManager && abilityManager.IsInitialized())
  6999.             return ((W3PlayerAbilityManager)abilityManager).Debug_HAX_UnlockSkillSlot(slotIndex);
  7000.            
  7001.         return false;
  7002.     }
  7003.    
  7004.    
  7005.     public function GetLevelupAbility( id : int) : name
  7006.     {
  7007.         return levelupAbilities[ id ];
  7008.     }
  7009.    
  7010.    
  7011.     public function CanSprint( speed : float ) : bool
  7012.     {
  7013.         if( !super.CanSprint( speed ) )
  7014.         {
  7015.             return false;
  7016.         }      
  7017.         if( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
  7018.         {
  7019.             if ( this.GetPlayerCombatStance() ==  PCS_AlertNear )
  7020.             {
  7021.                 if ( IsSprintActionPressed() )
  7022.                     OnRangedForceHolster( true, false );
  7023.             }
  7024.             else
  7025.                 return false;
  7026.         }
  7027.         if( GetCurrentStateName() != 'Swimming' && GetStat(BCS_Stamina) <= 0 )
  7028.         {
  7029.             SetSprintActionPressed(false,true);
  7030.             return false;
  7031.         }
  7032.        
  7033.         return true;
  7034.     }
  7035.    
  7036.    
  7037.    
  7038.     public function RestoreHorseManager() : bool
  7039.     {
  7040.         var horseTemplate   : CEntityTemplate;
  7041.         var horseManager    : W3HorseManager;  
  7042.        
  7043.         if ( GetHorseManager() )
  7044.         {
  7045.             return false;
  7046.         }
  7047.        
  7048.         horseTemplate = (CEntityTemplate)LoadResource("horse_manager");
  7049.         horseManager = (W3HorseManager)theGame.CreateEntity(horseTemplate, GetWorldPosition(),,,,,PM_Persist);
  7050.         horseManager.CreateAttachment(this);
  7051.         horseManager.OnCreated();
  7052.         EntityHandleSet( horseManagerHandle, horseManager );   
  7053.        
  7054.         return true;
  7055.     }
  7056.    
  7057.    
  7058.    
  7059.    
  7060.    
  7061.    
  7062.    
  7063.     public final function IsSignBlocked(signType : ESignType) : bool
  7064.     {
  7065.         switch( signType )
  7066.         {
  7067.             case ST_Aard :
  7068.                 return IsRadialSlotBlocked ( 'Aard');
  7069.                 break;
  7070.             case ST_Axii :
  7071.                 return IsRadialSlotBlocked ( 'Axii');
  7072.                 break;
  7073.             case ST_Igni :
  7074.                 return IsRadialSlotBlocked ( 'Igni');
  7075.                 break;
  7076.             case ST_Quen :
  7077.                 return IsRadialSlotBlocked ( 'Quen');
  7078.                 break;
  7079.             case ST_Yrden :
  7080.                 return IsRadialSlotBlocked ( 'Yrden');
  7081.                 break;
  7082.             default:
  7083.                 break;
  7084.         }
  7085.         return false;
  7086.        
  7087.     }
  7088.    
  7089.     public final function AddAnItemWithAutogenLevelAndQuality(itemName : name, desiredLevel : int, minQuality : int, optional equipItem : bool)
  7090.     {
  7091.         var itemLevel, quality : int;
  7092.         var ids : array<SItemUniqueId>;
  7093.         var attemptCounter : int;
  7094.        
  7095.         itemLevel = 0;
  7096.         quality = 0;
  7097.         attemptCounter = 0;
  7098.         while(itemLevel != desiredLevel || quality < minQuality)
  7099.         {
  7100.             attemptCounter += 1;
  7101.             ids.Clear();
  7102.             ids = inv.AddAnItem(itemName, 1, true);
  7103.             itemLevel = inv.GetItemLevel(ids[0]);
  7104.             quality = RoundMath(CalculateAttributeValue(inv.GetItemAttributeValue(ids[0], 'quality')));
  7105.            
  7106.            
  7107.             if(attemptCounter >= 1000)
  7108.                 break;
  7109.            
  7110.             if(itemLevel != desiredLevel || quality < minQuality)
  7111.                 inv.RemoveItem(ids[0]);
  7112.         }
  7113.        
  7114.         if(equipItem)
  7115.             EquipItem(ids[0]);
  7116.     }
  7117.    
  7118.     public final function AddAnItemWithAutogenLevel(itemName : name, desiredLevel : int)
  7119.     {
  7120.         var itemLevel : int;
  7121.         var ids : array<SItemUniqueId>;
  7122.         var attemptCounter : int;
  7123.  
  7124.         itemLevel = 0;
  7125.         while(itemLevel != desiredLevel)
  7126.         {
  7127.             attemptCounter += 1;
  7128.             ids.Clear();
  7129.             ids = inv.AddAnItem(itemName, 1, true);
  7130.             itemLevel = inv.GetItemLevel(ids[0]);
  7131.            
  7132.            
  7133.             if(attemptCounter >= 1000)
  7134.                 break;
  7135.                
  7136.             if(itemLevel != desiredLevel)
  7137.                 inv.RemoveItem(ids[0]);
  7138.         }
  7139.     }
  7140.    
  7141.     public final function AddAnItemWithMinQuality(itemName : name, minQuality : int, optional equip : bool)
  7142.     {
  7143.         var quality : int;
  7144.         var ids : array<SItemUniqueId>;
  7145.         var attemptCounter : int;
  7146.  
  7147.         quality = 0;
  7148.         while(quality < minQuality)
  7149.         {
  7150.             attemptCounter += 1;
  7151.             ids.Clear();
  7152.             ids = inv.AddAnItem(itemName, 1, true);
  7153.             quality = RoundMath(CalculateAttributeValue(inv.GetItemAttributeValue(ids[0], 'quality')));
  7154.            
  7155.            
  7156.             if(attemptCounter >= 1000)
  7157.                 break;
  7158.                
  7159.             if(quality < minQuality)
  7160.                 inv.RemoveItem(ids[0]);
  7161.         }
  7162.        
  7163.         if(equip)
  7164.             EquipItem(ids[0]);
  7165.     }
  7166.    
  7167.     public final function StandaloneEp1_1()
  7168.     {
  7169.         var i, inc, quantityLow, randLow, quantityMedium, randMedium, quantityHigh, randHigh, startingMoney : int;
  7170.         var pam : W3PlayerAbilityManager;
  7171.         var ids : array<SItemUniqueId>;
  7172.         var STARTING_LEVEL : int;
  7173.        
  7174.         FactsAdd("StandAloneEP1", 1);
  7175.        
  7176.        
  7177.         inv.RemoveAllItems();
  7178.        
  7179.        
  7180.         inv.AddAnItem('Illusion Medallion', 1, true, true, false);
  7181.         inv.AddAnItem('q103_safe_conduct', 1, true, true, false);
  7182.        
  7183.        
  7184.         theGame.GetGamerProfile().ClearAllAchievementsForEP1();
  7185.        
  7186.        
  7187.         STARTING_LEVEL = 32;
  7188.         inc = STARTING_LEVEL - GetLevel();
  7189.         for(i=0; i<inc; i+=1)
  7190.         {
  7191.             levelManager.AddPoints(EExperiencePoint, levelManager.GetTotalExpForNextLevel() - levelManager.GetPointsTotal(EExperiencePoint), false);
  7192.         }
  7193.        
  7194.        
  7195.         levelManager.ResetCharacterDev();
  7196.         pam = (W3PlayerAbilityManager)abilityManager;
  7197.         if(pam)
  7198.         {
  7199.             pam.ResetCharacterDev();
  7200.         }
  7201.         levelManager.SetFreeSkillPoints(levelManager.GetLevel() - 1 + 11)
  7202.        
  7203.        
  7204.         inv.AddAnItem('Mutagen red', 4);
  7205.         inv.AddAnItem('Mutagen green', 4);
  7206.         inv.AddAnItem('Mutagen blue', 4);
  7207.         inv.AddAnItem('Lesser mutagen red', 2);
  7208.         inv.AddAnItem('Lesser mutagen green', 2);
  7209.         inv.AddAnItem('Lesser mutagen blue', 2);
  7210.         inv.AddAnItem('Greater mutagen green', 1);
  7211.         inv.AddAnItem('Greater mutagen blue', 2);
  7212.        
  7213.        
  7214.         startingMoney = 20000;
  7215.         if(GetMoney() > startingMoney)
  7216.         {
  7217.             RemoveMoney(GetMoney() - startingMoney);
  7218.         }
  7219.         else
  7220.         {
  7221.             AddMoney( 20000 - GetMoney() );
  7222.         }
  7223.        
  7224.        
  7225.        
  7226.        
  7227.        
  7228.         ids.Clear();
  7229.         ids = inv.AddAnItem('EP1 Standalone Starting Armor');
  7230.         EquipItem(ids[0]);
  7231.         ids.Clear();
  7232.         ids = inv.AddAnItem('EP1 Standalone Starting Boots');
  7233.         EquipItem(ids[0]);
  7234.         ids.Clear();
  7235.         ids = inv.AddAnItem('EP1 Standalone Starting Gloves');
  7236.         EquipItem(ids[0]);
  7237.         ids.Clear();
  7238.         ids = inv.AddAnItem('EP1 Standalone Starting Pants');
  7239.         EquipItem(ids[0]);
  7240.        
  7241.        
  7242.         ids.Clear();
  7243.         ids = inv.AddAnItem('EP1 Standalone Starting Steel Sword');
  7244.         EquipItem(ids[0]);
  7245.         ids.Clear();
  7246.         ids = inv.AddAnItem('EP1 Standalone Starting Silver Sword');
  7247.         EquipItem(ids[0]);
  7248.        
  7249.        
  7250.         inv.AddAnItem('Torch', 1, true, true, false);
  7251.        
  7252.        
  7253.         quantityLow = 1;
  7254.         randLow = 3;
  7255.         quantityMedium = 4;
  7256.         randMedium = 4;
  7257.         quantityHigh = 8;
  7258.         randHigh = 6;
  7259.        
  7260.         inv.AddAnItem('Alghoul bone marrow',quantityMedium+RandRange(randMedium));
  7261.         inv.AddAnItem('Amethyst dust',quantityLow+RandRange(randLow));
  7262.         inv.AddAnItem('Arachas eyes',quantityLow+RandRange(randLow));
  7263.         inv.AddAnItem('Arachas venom',quantityLow+RandRange(randLow));
  7264.         inv.AddAnItem('Basilisk hide',quantityLow+RandRange(randLow));
  7265.         inv.AddAnItem('Basilisk venom',quantityLow+RandRange(randLow));
  7266.         inv.AddAnItem('Bear pelt',quantityHigh+RandRange(randHigh));
  7267.         inv.AddAnItem('Berserker pelt',quantityLow+RandRange(randLow));
  7268.         inv.AddAnItem('Coal',quantityHigh+RandRange(randHigh));
  7269.         inv.AddAnItem('Cotton',quantityHigh+RandRange(randHigh));
  7270.         inv.AddAnItem('Dark iron ingot',quantityLow+RandRange(randLow));
  7271.         inv.AddAnItem('Dark iron ore',quantityLow+RandRange(randLow));
  7272.         inv.AddAnItem('Deer hide',quantityHigh+RandRange(randHigh));
  7273.         inv.AddAnItem('Diamond dust',quantityLow+RandRange(randLow));
  7274.         inv.AddAnItem('Draconide leather',quantityLow+RandRange(randLow));
  7275.         inv.AddAnItem('Drowned dead tongue',quantityLow+RandRange(randLow));
  7276.         inv.AddAnItem('Drowner brain',quantityMedium+RandRange(randMedium));
  7277.         inv.AddAnItem('Dwimeryte ingot',quantityLow+RandRange(randLow));
  7278.         inv.AddAnItem('Dwimeryte ore',quantityLow+RandRange(randLow));
  7279.         inv.AddAnItem('Emerald dust',quantityLow+RandRange(randLow));
  7280.         inv.AddAnItem('Endriag chitin plates',quantityMedium+RandRange(randMedium));
  7281.         inv.AddAnItem('Endriag embryo',quantityLow+RandRange(randLow));
  7282.         inv.AddAnItem('Ghoul blood',quantityMedium+RandRange(randMedium));
  7283.         inv.AddAnItem('Goat hide',quantityMedium+RandRange(randMedium));
  7284.         inv.AddAnItem('Hag teeth',quantityMedium+RandRange(randMedium));
  7285.         inv.AddAnItem('Hardened leather',quantityMedium+RandRange(randMedium));
  7286.         inv.AddAnItem('Hardened timber',quantityMedium+RandRange(randMedium));
  7287.         inv.AddAnItem('Harpy feathers',quantityMedium+RandRange(randMedium));
  7288.         inv.AddAnItem('Horse hide',quantityLow+RandRange(randLow));
  7289.         inv.AddAnItem('Iron ore',quantityHigh+RandRange(randHigh));
  7290.         inv.AddAnItem('Leather straps',quantityHigh+RandRange(randHigh));
  7291.         inv.AddAnItem('Leather',quantityHigh+RandRange(randHigh));
  7292.         inv.AddAnItem('Linen',quantityMedium+RandRange(randMedium));
  7293.         inv.AddAnItem('Meteorite ingot',quantityLow+RandRange(randLow));
  7294.         inv.AddAnItem('Meteorite ore',quantityMedium+RandRange(randMedium));
  7295.         inv.AddAnItem('Necrophage skin',quantityLow+RandRange(randLow));
  7296.         inv.AddAnItem('Nekker blood',quantityHigh+RandRange(randHigh));
  7297.         inv.AddAnItem('Nekker heart',quantityMedium+RandRange(randMedium));
  7298.         inv.AddAnItem('Oil',quantityHigh+RandRange(randHigh));
  7299.         inv.AddAnItem('Phosphorescent crystal',quantityLow+RandRange(randLow));
  7300.         inv.AddAnItem('Pig hide',quantityMedium+RandRange(randMedium));
  7301.         inv.AddAnItem('Pure silver',quantityMedium+RandRange(randMedium));
  7302.         inv.AddAnItem('Rabbit pelt',quantityMedium+RandRange(randMedium));
  7303.         inv.AddAnItem('Rotfiend blood',quantityMedium+RandRange(randMedium));
  7304.         inv.AddAnItem('Sapphire dust',quantityLow+RandRange(randLow));
  7305.         inv.AddAnItem('Silk',quantityHigh+RandRange(randHigh));
  7306.         inv.AddAnItem('Silver ingot',quantityMedium+RandRange(randMedium));
  7307.         inv.AddAnItem('Silver ore',quantityHigh+RandRange(randHigh));
  7308.         inv.AddAnItem('Specter dust',quantityMedium+RandRange(randMedium));
  7309.         inv.AddAnItem('Steel ingot',quantityHigh+RandRange(randHigh));
  7310.         inv.AddAnItem('Steel plate',quantityHigh+RandRange(randHigh));
  7311.         inv.AddAnItem('String',quantityHigh+RandRange(randHigh));
  7312.         inv.AddAnItem('Thread',quantityHigh+RandRange(randHigh));
  7313.         inv.AddAnItem('Timber',quantityHigh+RandRange(randHigh));
  7314.         inv.AddAnItem('Twine',quantityMedium+RandRange(randMedium));
  7315.         inv.AddAnItem('Venom extract',quantityMedium+RandRange(randMedium));
  7316.         inv.AddAnItem('Water essence',quantityMedium+RandRange(randMedium));
  7317.         inv.AddAnItem('Wolf liver',quantityHigh+RandRange(randHigh));
  7318.         inv.AddAnItem('Wolf pelt',quantityMedium+RandRange(randMedium));
  7319.        
  7320.         inv.AddAnItem('Alcohest', 5);
  7321.         inv.AddAnItem('Dwarven spirit', 5);
  7322.    
  7323.        
  7324.         ids.Clear();
  7325.         ids = inv.AddAnItem('Crossbow 5');
  7326.         EquipItem(ids[0]);
  7327.         ids.Clear();
  7328.         ids = inv.AddAnItem('Blunt Bolt', 100);
  7329.         EquipItem(ids[0]);
  7330.         inv.AddAnItem('Broadhead Bolt', 100);
  7331.         inv.AddAnItem('Split Bolt', 100);
  7332.        
  7333.        
  7334.         RemoveAllAlchemyRecipes();
  7335.         RemoveAllCraftingSchematics();
  7336.        
  7337.        
  7338.        
  7339.        
  7340.         AddAlchemyRecipe('Recipe for Cat 1');
  7341.        
  7342.        
  7343.        
  7344.         AddAlchemyRecipe('Recipe for Maribor Forest 1');
  7345.         AddAlchemyRecipe('Recipe for Petris Philtre 1');
  7346.         AddAlchemyRecipe('Recipe for Swallow 1');
  7347.         AddAlchemyRecipe('Recipe for Tawny Owl 1');
  7348.        
  7349.         AddAlchemyRecipe('Recipe for White Gull 1');
  7350.         AddAlchemyRecipe('Recipe for White Honey 1');
  7351.         AddAlchemyRecipe('Recipe for White Raffards Decoction 1');
  7352.        
  7353.        
  7354.        
  7355.         AddAlchemyRecipe('Recipe for Beast Oil 1');
  7356.         AddAlchemyRecipe('Recipe for Cursed Oil 1');
  7357.         AddAlchemyRecipe('Recipe for Hanged Man Venom 1');
  7358.         AddAlchemyRecipe('Recipe for Hybrid Oil 1');
  7359.         AddAlchemyRecipe('Recipe for Insectoid Oil 1');
  7360.         AddAlchemyRecipe('Recipe for Magicals Oil 1');
  7361.         AddAlchemyRecipe('Recipe for Necrophage Oil 1');
  7362.         AddAlchemyRecipe('Recipe for Specter Oil 1');
  7363.         AddAlchemyRecipe('Recipe for Vampire Oil 1');
  7364.         AddAlchemyRecipe('Recipe for Draconide Oil 1');
  7365.         AddAlchemyRecipe('Recipe for Ogre Oil 1');
  7366.         AddAlchemyRecipe('Recipe for Relic Oil 1');
  7367.         AddAlchemyRecipe('Recipe for Beast Oil 2');
  7368.         AddAlchemyRecipe('Recipe for Cursed Oil 2');
  7369.         AddAlchemyRecipe('Recipe for Hanged Man Venom 2');
  7370.         AddAlchemyRecipe('Recipe for Hybrid Oil 2');
  7371.         AddAlchemyRecipe('Recipe for Insectoid Oil 2');
  7372.         AddAlchemyRecipe('Recipe for Magicals Oil 2');
  7373.         AddAlchemyRecipe('Recipe for Necrophage Oil 2');
  7374.         AddAlchemyRecipe('Recipe for Specter Oil 2');
  7375.         AddAlchemyRecipe('Recipe for Vampire Oil 2');
  7376.         AddAlchemyRecipe('Recipe for Draconide Oil 2');
  7377.         AddAlchemyRecipe('Recipe for Ogre Oil 2');
  7378.         AddAlchemyRecipe('Recipe for Relic Oil 2');
  7379.        
  7380.        
  7381.         AddAlchemyRecipe('Recipe for Dancing Star 1');
  7382.        
  7383.         AddAlchemyRecipe('Recipe for Dwimeritum Bomb 1');
  7384.        
  7385.         AddAlchemyRecipe('Recipe for Grapeshot 1');
  7386.         AddAlchemyRecipe('Recipe for Samum 1');
  7387.        
  7388.         AddAlchemyRecipe('Recipe for White Frost 1');
  7389.        
  7390.        
  7391.        
  7392.         AddAlchemyRecipe('Recipe for Dwarven spirit 1');
  7393.         AddAlchemyRecipe('Recipe for Alcohest 1');
  7394.         AddAlchemyRecipe('Recipe for White Gull 1');
  7395.        
  7396.        
  7397.         AddStartingSchematics();
  7398.        
  7399.        
  7400.         ids.Clear();
  7401.         ids = inv.AddAnItem('Swallow 2');
  7402.         EquipItem(ids[0]);
  7403.         ids.Clear();
  7404.         ids = inv.AddAnItem('Thunderbolt 2');
  7405.         EquipItem(ids[0]);
  7406.         ids.Clear();
  7407.         ids = inv.AddAnItem('Tawny Owl 2');
  7408.         EquipItem(ids[0]);
  7409.         ids.Clear();
  7410.        
  7411.         ids = inv.AddAnItem('Grapeshot 2');
  7412.         EquipItem(ids[0]);
  7413.         ids.Clear();
  7414.         ids = inv.AddAnItem('Samum 2');
  7415.         EquipItem(ids[0]);
  7416.        
  7417.         inv.AddAnItem('Dwimeritum Bomb 1');
  7418.         inv.AddAnItem('Dragons Dream 1');
  7419.         inv.AddAnItem('Silver Dust Bomb 1');
  7420.         inv.AddAnItem('White Frost 2');
  7421.         inv.AddAnItem('Devils Puffball 2');
  7422.         inv.AddAnItem('Dancing Star 2');
  7423.         inv.AddAnItem('Beast Oil 1');
  7424.         inv.AddAnItem('Cursed Oil 1');
  7425.         inv.AddAnItem('Hanged Man Venom 2');
  7426.         inv.AddAnItem('Hybrid Oil 1');
  7427.         inv.AddAnItem('Insectoid Oil 1');
  7428.         inv.AddAnItem('Magicals Oil 1');
  7429.         inv.AddAnItem('Necrophage Oil 2');
  7430.         inv.AddAnItem('Specter Oil 1');
  7431.         inv.AddAnItem('Vampire Oil 1');
  7432.         inv.AddAnItem('Draconide Oil 1');
  7433.         inv.AddAnItem('Relic Oil 1');
  7434.         inv.AddAnItem('Black Blood 1');
  7435.         inv.AddAnItem('Blizzard 1');
  7436.         inv.AddAnItem('Cat 2');
  7437.         inv.AddAnItem('Full Moon 1');
  7438.         inv.AddAnItem('Maribor Forest 1');
  7439.         inv.AddAnItem('Petris Philtre 1');
  7440.         inv.AddAnItem('White Gull 1', 3);
  7441.         inv.AddAnItem('White Honey 2');
  7442.         inv.AddAnItem('White Raffards Decoction 1');
  7443.        
  7444.        
  7445.         inv.AddAnItem('Mutagen 17');   
  7446.         inv.AddAnItem('Mutagen 19');   
  7447.         inv.AddAnItem('Mutagen 27');   
  7448.         inv.AddAnItem('Mutagen 26');   
  7449.        
  7450.        
  7451.         inv.AddAnItem('weapon_repair_kit_1', 5);
  7452.         inv.AddAnItem('weapon_repair_kit_2', 3);
  7453.         inv.AddAnItem('armor_repair_kit_1', 5);
  7454.         inv.AddAnItem('armor_repair_kit_2', 3);
  7455.        
  7456.        
  7457.         quantityMedium = 2;
  7458.         quantityLow = 1;
  7459.         inv.AddAnItem('Rune stribog lesser', quantityMedium);
  7460.         inv.AddAnItem('Rune stribog', quantityLow);
  7461.         inv.AddAnItem('Rune dazhbog lesser', quantityMedium);
  7462.         inv.AddAnItem('Rune dazhbog', quantityLow);
  7463.         inv.AddAnItem('Rune devana lesser', quantityMedium);
  7464.         inv.AddAnItem('Rune devana', quantityLow);
  7465.         inv.AddAnItem('Rune zoria lesser', quantityMedium);
  7466.         inv.AddAnItem('Rune zoria', quantityLow);
  7467.         inv.AddAnItem('Rune morana lesser', quantityMedium);
  7468.         inv.AddAnItem('Rune morana', quantityLow);
  7469.         inv.AddAnItem('Rune triglav lesser', quantityMedium);
  7470.         inv.AddAnItem('Rune triglav', quantityLow);
  7471.         inv.AddAnItem('Rune svarog lesser', quantityMedium);
  7472.         inv.AddAnItem('Rune svarog', quantityLow);
  7473.         inv.AddAnItem('Rune veles lesser', quantityMedium);
  7474.         inv.AddAnItem('Rune veles', quantityLow);
  7475.         inv.AddAnItem('Rune perun lesser', quantityMedium);
  7476.         inv.AddAnItem('Rune perun', quantityLow);
  7477.         inv.AddAnItem('Rune elemental lesser', quantityMedium);
  7478.         inv.AddAnItem('Rune elemental', quantityLow);
  7479.        
  7480.         inv.AddAnItem('Glyph aard lesser', quantityMedium);
  7481.         inv.AddAnItem('Glyph aard', quantityLow);
  7482.         inv.AddAnItem('Glyph axii lesser', quantityMedium);
  7483.         inv.AddAnItem('Glyph axii', quantityLow);
  7484.         inv.AddAnItem('Glyph igni lesser', quantityMedium);
  7485.         inv.AddAnItem('Glyph igni', quantityLow);
  7486.         inv.AddAnItem('Glyph quen lesser', quantityMedium);
  7487.         inv.AddAnItem('Glyph quen', quantityLow);
  7488.         inv.AddAnItem('Glyph yrden lesser', quantityMedium);
  7489.         inv.AddAnItem('Glyph yrden', quantityLow);
  7490.        
  7491.        
  7492.         StandaloneEp1_2();
  7493.     }
  7494.    
  7495.     public final function StandaloneEp1_2()
  7496.     {
  7497.         var horseId : SItemUniqueId;
  7498.         var ids : array<SItemUniqueId>;
  7499.         var ents : array< CJournalBase >;
  7500.         var i : int;
  7501.         var manager : CWitcherJournalManager;
  7502.        
  7503.        
  7504.         inv.AddAnItem( 'Cows milk', 20 );
  7505.         ids.Clear();
  7506.         ids = inv.AddAnItem( 'Dumpling', 44 );
  7507.         EquipItem(ids[0]);
  7508.        
  7509.        
  7510.         inv.AddAnItem('Clearing Potion', 2, true, false, false);
  7511.        
  7512.        
  7513.         GetHorseManager().RemoveAllItems();
  7514.        
  7515.         ids.Clear();
  7516.         ids = inv.AddAnItem('Horse Bag 2');
  7517.         horseId = GetHorseManager().MoveItemToHorse(ids[0]);
  7518.         GetHorseManager().EquipItem(horseId);
  7519.        
  7520.         ids.Clear();
  7521.         ids = inv.AddAnItem('Horse Blinder 2');
  7522.         horseId = GetHorseManager().MoveItemToHorse(ids[0]);
  7523.         GetHorseManager().EquipItem(horseId);
  7524.        
  7525.         ids.Clear();
  7526.         ids = inv.AddAnItem('Horse Saddle 2');
  7527.         horseId = GetHorseManager().MoveItemToHorse(ids[0]);
  7528.         GetHorseManager().EquipItem(horseId);
  7529.        
  7530.         manager = theGame.GetJournalManager();
  7531.  
  7532.        
  7533.         manager.GetActivatedOfType( 'CJournalCreature', ents );
  7534.         for(i=0; i<ents.Size(); i+=1)
  7535.         {
  7536.             manager.ActivateEntry(ents[i], JS_Inactive, false, true);
  7537.         }
  7538.        
  7539.        
  7540.         ents.Clear();
  7541.         manager.GetActivatedOfType( 'CJournalCharacter', ents );
  7542.         for(i=0; i<ents.Size(); i+=1)
  7543.         {
  7544.             manager.ActivateEntry(ents[i], JS_Inactive, false, true);
  7545.         }
  7546.        
  7547.        
  7548.         ents.Clear();
  7549.         manager.GetActivatedOfType( 'CJournalQuest', ents );
  7550.         for(i=0; i<ents.Size(); i+=1)
  7551.         {
  7552.            
  7553.             if( StrStartsWith(ents[i].baseName, "q60"))
  7554.                 continue;
  7555.                
  7556.             manager.ActivateEntry(ents[i], JS_Inactive, false, true);
  7557.         }
  7558.        
  7559.        
  7560.         manager.ActivateEntryByScriptTag('TutorialAard', JS_Active);
  7561.         manager.ActivateEntryByScriptTag('TutorialAdrenaline', JS_Active);
  7562.         manager.ActivateEntryByScriptTag('TutorialAxii', JS_Active);
  7563.         manager.ActivateEntryByScriptTag('TutorialAxiiDialog', JS_Active);
  7564.         manager.ActivateEntryByScriptTag('TutorialCamera', JS_Active);
  7565.         manager.ActivateEntryByScriptTag('TutorialCamera_pad', JS_Active);
  7566.         manager.ActivateEntryByScriptTag('TutorialCiriBlink', JS_Active);
  7567.         manager.ActivateEntryByScriptTag('TutorialCiriCharge', JS_Active);
  7568.         manager.ActivateEntryByScriptTag('TutorialCiriStamina', JS_Active);
  7569.         manager.ActivateEntryByScriptTag('TutorialCounter', JS_Active);
  7570.         manager.ActivateEntryByScriptTag('TutorialDialogClose', JS_Active);
  7571.         manager.ActivateEntryByScriptTag('TutorialFallingRoll', JS_Active);
  7572.         manager.ActivateEntryByScriptTag('TutorialFocus', JS_Active);
  7573.         manager.ActivateEntryByScriptTag('TutorialFocusClues', JS_Active);
  7574.         manager.ActivateEntryByScriptTag('TutorialFocusClues', JS_Active);
  7575.         manager.ActivateEntryByScriptTag('TutorialHorseRoad', JS_Active);
  7576.         manager.ActivateEntryByScriptTag('TutorialHorseSpeed0', JS_Active);
  7577.         manager.ActivateEntryByScriptTag('TutorialHorseSpeed0_pad', JS_Active);
  7578.         manager.ActivateEntryByScriptTag('TutorialHorseSpeed1', JS_Active);
  7579.         manager.ActivateEntryByScriptTag('TutorialHorseSpeed2', JS_Active);
  7580.         manager.ActivateEntryByScriptTag('TutorialHorseSummon', JS_Active);
  7581.         manager.ActivateEntryByScriptTag('TutorialHorseSummon_pad', JS_Active);
  7582.         manager.ActivateEntryByScriptTag('TutorialIgni', JS_Active);
  7583.         manager.ActivateEntryByScriptTag('TutorialJournalAlternateSings', JS_Active);
  7584.         manager.ActivateEntryByScriptTag('TutorialJournalBoatDamage', JS_Active);
  7585.         manager.ActivateEntryByScriptTag('TutorialJournalBoatMount', JS_Active);
  7586.         manager.ActivateEntryByScriptTag('TutorialJournalBuffs', JS_Active);
  7587.         manager.ActivateEntryByScriptTag('TutorialJournalCharDevLeveling', JS_Active);
  7588.         manager.ActivateEntryByScriptTag('TutorialJournalCharDevSkills', JS_Active);
  7589.         manager.ActivateEntryByScriptTag('TutorialJournalCrafting', JS_Active);
  7590.         manager.ActivateEntryByScriptTag('TutorialJournalCrossbow', JS_Active);
  7591.         manager.ActivateEntryByScriptTag('TutorialJournalDialogGwint', JS_Active);
  7592.         manager.ActivateEntryByScriptTag('TutorialJournalDialogShop', JS_Active);
  7593.         manager.ActivateEntryByScriptTag('TutorialJournalDive', JS_Active);
  7594.         manager.ActivateEntryByScriptTag('TutorialJournalDodge', JS_Active);
  7595.         manager.ActivateEntryByScriptTag('TutorialJournalDodge_pad', JS_Active);
  7596.         manager.ActivateEntryByScriptTag('TutorialJournalDrawWeapon', JS_Active);
  7597.         manager.ActivateEntryByScriptTag('TutorialJournalDrawWeapon_pad', JS_Active);
  7598.         manager.ActivateEntryByScriptTag('TutorialJournalDurability', JS_Active);
  7599.         manager.ActivateEntryByScriptTag('TutorialJournalExplorations', JS_Active);
  7600.         manager.ActivateEntryByScriptTag('TutorialJournalExplorations_pad', JS_Active);
  7601.         manager.ActivateEntryByScriptTag('TutorialJournalFastTravel', JS_Active);
  7602.         manager.ActivateEntryByScriptTag('TutorialJournalFocusRedObjects', JS_Active);
  7603.         manager.ActivateEntryByScriptTag('TutorialJournalGasClouds', JS_Active);
  7604.         manager.ActivateEntryByScriptTag('TutorialJournalHeavyAttacks', JS_Active);
  7605.         manager.ActivateEntryByScriptTag('TutorialJournalHorse', JS_Active);
  7606.         manager.ActivateEntryByScriptTag('TutorialJournalHorseStamina', JS_Active);
  7607.         manager.ActivateEntryByScriptTag('TutorialJournalJump', JS_Active);
  7608.         manager.ActivateEntryByScriptTag('TutorialJournalLightAttacks', JS_Active);
  7609.         manager.ActivateEntryByScriptTag('TutorialJournalLightAttacks_pad', JS_Active);
  7610.         manager.ActivateEntryByScriptTag('TutorialJournalMeditation', JS_Active);
  7611.         manager.ActivateEntryByScriptTag('TutorialJournalMeditation_pad', JS_Active);
  7612.         manager.ActivateEntryByScriptTag('TutorialJournalMonsterThreatLevels', JS_Active);
  7613.         manager.ActivateEntryByScriptTag('TutorialJournalMovement', JS_Active);
  7614.         manager.ActivateEntryByScriptTag('TutorialJournalMovement_pad', JS_Active);
  7615.         manager.ActivateEntryByScriptTag('TutorialJournalMutagenIngredient', JS_Active);
  7616.         manager.ActivateEntryByScriptTag('TutorialJournalMutagenPotion', JS_Active);
  7617.         manager.ActivateEntryByScriptTag('TutorialJournalOils', JS_Active);
  7618.         manager.ActivateEntryByScriptTag('TutorialJournalPetards', JS_Active);
  7619.         manager.ActivateEntryByScriptTag('TutorialJournalPotions', JS_Active);
  7620.         manager.ActivateEntryByScriptTag('TutorialJournalPotions_pad', JS_Active);
  7621.         manager.ActivateEntryByScriptTag('TutorialJournalQuestArea', JS_Active);
  7622.         manager.ActivateEntryByScriptTag('TutorialJournalRadial', JS_Active);
  7623.         manager.ActivateEntryByScriptTag('TutorialJournalRifts', JS_Active);
  7624.         manager.ActivateEntryByScriptTag('TutorialJournalRun', JS_Active);
  7625.         manager.ActivateEntryByScriptTag('TutorialJournalShopDescription', JS_Active);
  7626.         manager.ActivateEntryByScriptTag('TutorialJournalSignCast', JS_Active);
  7627.         manager.ActivateEntryByScriptTag('TutorialJournalSignCast_pad', JS_Active);
  7628.         manager.ActivateEntryByScriptTag('TutorialJournalSpecialAttacks', JS_Active);
  7629.         manager.ActivateEntryByScriptTag('TutorialJournalStaminaExploration', JS_Active);
  7630.         manager.ActivateEntryByScriptTag('TutorialJumpHang', JS_Active);
  7631.         manager.ActivateEntryByScriptTag('TutorialLadder', JS_Active);
  7632.         manager.ActivateEntryByScriptTag('TutorialLadderMove', JS_Active);
  7633.         manager.ActivateEntryByScriptTag('TutorialLadderMove_pad', JS_Active);
  7634.         manager.ActivateEntryByScriptTag('TutorialObjectiveSwitching', JS_Active);
  7635.         manager.ActivateEntryByScriptTag('TutorialOxygen', JS_Active);
  7636.         manager.ActivateEntryByScriptTag('TutorialParry', JS_Active);
  7637.         manager.ActivateEntryByScriptTag('TutorialPOIUncovered', JS_Active);
  7638.         manager.ActivateEntryByScriptTag('TutorialQuen', JS_Active);
  7639.         manager.ActivateEntryByScriptTag('TutorialRoll', JS_Active);
  7640.         manager.ActivateEntryByScriptTag('TutorialRoll_pad', JS_Active);
  7641.         manager.ActivateEntryByScriptTag('TutorialSpeedPairing', JS_Active);
  7642.         manager.ActivateEntryByScriptTag('TutorialSprint', JS_Active);
  7643.         manager.ActivateEntryByScriptTag('TutorialStaminaSigns', JS_Active);
  7644.         manager.ActivateEntryByScriptTag('TutorialStealing', JS_Active);
  7645.         manager.ActivateEntryByScriptTag('TutorialSwimmingSpeed', JS_Active);
  7646.         manager.ActivateEntryByScriptTag('TutorialTimedChoiceDialog', JS_Active);
  7647.         manager.ActivateEntryByScriptTag('TutorialYrden', JS_Active);
  7648.        
  7649.        
  7650.         FactsAdd('kill_base_tutorials');
  7651.        
  7652.        
  7653.         theGame.GetTutorialSystem().RemoveAllQueuedTutorials();
  7654.        
  7655.        
  7656.         FactsAdd('standalone_ep1');
  7657.         FactsRemove("StandAloneEP1");
  7658.        
  7659.         theGame.GetJournalManager().ForceUntrackingQuestForEP1Savegame();
  7660.     }
  7661.         function Debug_FocusBoyFocusGain()
  7662.     {
  7663.         var focusGain : float;
  7664.         focusGain = FactsQuerySum("debug_fact_focus_boy") ;
  7665.         GainStat(BCS_Focus, focusGain );
  7666.     }
  7667.     }
  7668.    
  7669.     //zur13 modSSS
  7670.     public function SSS_GetEquippedMutationType() : array< EPlayerMutationType >
  7671.     {
  7672.         return ( ( W3PlayerAbilityManager ) abilityManager ).SSS_GetEquippedMutationType();
  7673.     }
  7674.    
  7675.     //zur13 modSSS mutTabs
  7676.     public function SSS_FixEquippedMutagens()
  7677.     {
  7678.         var item : SItemUniqueId;
  7679.         var i : int;
  7680.         for( i = EES_SkillMutagen5 ; i < EES_SkillMutagen48; i=i+1 )
  7681.         {
  7682.             if( GetItemEquippedOnSlot( i, item ) )
  7683.             {
  7684.                 inv.SetItemStackable( item, false );
  7685.             }
  7686.         }
  7687.     }
  7688.    
  7689.     //zur13 modSSS mutTabs
  7690.     public function SSS_Patch_MutagenStacking(muts : array< SItemUniqueId >) : array< SItemUniqueId >
  7691.     {
  7692.         var i, j, quantity : int;
  7693.         var item : SItemUniqueId;
  7694.        
  7695.         for( i = EES_SkillMutagen5 ; i < EES_SkillMutagen48; i=i+1 )
  7696.         {
  7697.             if( GetItemEquippedOnSlot( i, item ) )
  7698.             {
  7699.                 muts.Remove( item );
  7700.                 inv.SetItemStackable( item, false );
  7701.             }
  7702.         }
  7703.         return muts;
  7704. }
  7705.    
  7706. exec function fuqfep1()
  7707. {
  7708.     theGame.GetJournalManager().ForceUntrackingQuestForEP1Savegame();
  7709. }
  7710.  
  7711.  
  7712.  
  7713.  
  7714.  
  7715. function GetWitcherPlayer() : W3PlayerWitcher
  7716. {
  7717.     return (W3PlayerWitcher)thePlayer;
  7718. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement