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