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