Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Copyright © CD Projekt RED 2015
- */
- statemachine class W3PlayerWitcher extends CR4Player
- {
- private saved var craftingSchematics : array<name>;
- private saved var alchemyRecipes : array<name>;
- private var levelupAbilities : array< name >;
- //---=== modFriendlyMeditation ===---
- public var fMeditationConfig : CModFMeditationConfig;
- //---=== modFriendlyMeditation ===---
- private var fastAttackCounter, heavyAttackCounter : int;
- private var isInFrenzy : bool;
- private var hasRecentlyCountered : bool;
- private saved var cannotUseUndyingSkill : bool;
- //---=== modFriendlyMeditation ===---
- var spawnedCampFire : W3Campfire;
- var fmedCanSpawnCampfire : bool;
- default fmedCanSpawnCampfire = true;
- var fmedAutorefillAlchemy : bool;
- default fmedAutorefillAlchemy = true;
- var fmedRefillIntervalSeconds : float;
- default fmedRefillIntervalSeconds = 3600.0;
- var fmedApplyWitcherHouseBuffs : bool;
- default fmedApplyWitcherHouseBuffs = true;
- var fmedWitcherHouseBuffsHours : int;
- default fmedWitcherHouseBuffsHours = 1;
- //---=== modFriendlyMeditation ===---
- public var canSwitchFocusModeTarget : bool;
- protected var switchFocusModeTargetAllowed : bool;
- default canSwitchFocusModeTarget = true;
- default switchFocusModeTargetAllowed = true;
- private editable var signs : array< SWitcherSign >;
- private saved var equippedSign : ESignType;
- private var currentlyCastSign : ESignType; default currentlyCastSign = ST_None;
- private var signOwner : W3SignOwnerPlayer;
- private var usedQuenInCombat : bool;
- public var yrdenEntities : array<W3YrdenEntity>;
- default equippedSign = ST_Aard;
- private var bDispalyHeavyAttackIndicator : bool;
- private var bDisplayHeavyAttackFirstLevelTimer : bool;
- public var specialAttackHeavyAllowed : bool;
- default bIsCombatActionAllowed = true;
- default bDispalyHeavyAttackIndicator = false;
- default bDisplayHeavyAttackFirstLevelTimer = true;
- default explorationInputContext = 'Exploration';
- default combatInputContext = 'Combat';
- default combatFistsInputContext = 'Combat';
- private saved var companionNPCTag : name;
- private saved var companionNPCTag2 : name;
- private saved var companionNPCIconPath : string;
- private saved var companionNPCIconPath2 : string;
- private saved var itemSlots : array<SItemUniqueId>;
- private var remainingBombThrowDelaySlot1 : float;
- private var remainingBombThrowDelaySlot2 : float;
- private var previouslyUsedBolt : SItemUniqueId;
- default isThrowingItem = false;
- default remainingBombThrowDelaySlot1 = 0.f;
- default remainingBombThrowDelaySlot2 = 0.f;
- private var tempLearnedSignSkills : array<SSimpleSkill>;
- public saved var autoLevel : bool;
- protected var skillBonusPotionEffect : CBaseGameplayEffect;
- public saved var levelManager : W3LevelManager;
- saved var reputationManager : W3Reputation;
- private editable var medallionEntity : CEntityTemplate;
- private var medallionController : W3MedallionController;
- public var bShowRadialMenu : bool;
- private var _HoldBeforeOpenRadialMenuTime : float;
- default _HoldBeforeOpenRadialMenuTime = 0.5f;
- public var MappinToHighlight : array<SHighlightMappin>;
- protected saved var horseManagerHandle : EntityHandle;
- private var isInitialized : bool;
- default isInitialized = false;
- //modSitting++
- public var modPlayerSitting : CPlayerSitting;
- //modSitting--
- event OnSpawned( spawnData : SEntitySpawnData )
- {
- var i : int;
- var items : array<SItemUniqueId>;
- var items2 : array<SItemUniqueId>;
- var horseTemplate : CEntityTemplate;
- var horseManager : W3HorseManager;
- AddAnimEventCallback( 'ActionBlend', 'OnAnimEvent_ActionBlend' );
- AddAnimEventCallback('cast_begin', 'OnAnimEvent_Sign');
- AddAnimEventCallback('cast_throw', 'OnAnimEvent_Sign');
- AddAnimEventCallback('cast_end', 'OnAnimEvent_Sign');
- AddAnimEventCallback('cast_friendly_begin', 'OnAnimEvent_Sign');
- AddAnimEventCallback('cast_friendly_throw', 'OnAnimEvent_Sign');
- AddAnimEventCallback('axii_ready', 'OnAnimEvent_Sign');
- AddAnimEventCallback('axii_alternate_ready', 'OnAnimEvent_Sign');
- AddAnimEventCallback('yrden_draw_ready', 'OnAnimEvent_Sign');
- AddAnimEventCallback( 'ProjectileThrow', 'OnAnimEvent_Throwable' );
- AddAnimEventCallback( 'OnWeaponReload', 'OnAnimEvent_Throwable' );
- AddAnimEventCallback( 'ProjectileAttach', 'OnAnimEvent_Throwable' );
- theTelemetry.Log( TE_HERO_SPAWNED );
- inv = GetInventory();
- signOwner = new W3SignOwnerPlayer in this;
- signOwner.Init( this );
- itemSlots.Resize( EnumGetMax('EEquipmentSlots')+1 );
- if(!spawnData.restored)
- {
- levelManager = new W3LevelManager in this;
- levelManager.Initialize();
- inv.GetAllItems(items);
- for(i=0; i<items.Size(); i+=1)
- {
- if(inv.IsItemMounted(items[i]) && ( !inv.IsItemBody(items[i]) || inv.GetItemCategory(items[i]) == 'hair' ) )
- EquipItem(items[i]);
- }
- AddAlchemyRecipe('Recipe for Swallow 1',true,true);
- AddAlchemyRecipe('Recipe for Cat 1',true,true);
- AddAlchemyRecipe('Recipe for White Honey 1',true,true);
- AddAlchemyRecipe('Recipe for Samum 1',true,true);
- AddAlchemyRecipe('Recipe for Grapeshot 1',true,true);
- AddAlchemyRecipe('Recipe for Specter Oil 1',true,true);
- AddAlchemyRecipe('Recipe for Necrophage Oil 1',true,true);
- AddAlchemyRecipe('Recipe for Alcohest 1',true,true);
- AddStartingSchematics();
- }
- else
- {
- AddTimer('DelayedOnItemMount', 0.1, true);
- CheckHairItem();
- }
- super.OnSpawned( spawnData );
- AddAlchemyRecipe('Recipe for Mutagen red',true,true);
- AddAlchemyRecipe('Recipe for Mutagen green',true,true);
- AddAlchemyRecipe('Recipe for Mutagen blue',true,true);
- AddAlchemyRecipe('Recipe for Greater mutagen red',true,true);
- AddAlchemyRecipe('Recipe for Greater mutagen green',true,true);
- AddAlchemyRecipe('Recipe for Greater mutagen blue',true,true);
- AddCraftingSchematic('Starting Armor Upgrade schematic 1',true,true);
- levelupAbilities.PushBack('Lvl1');
- levelupAbilities.PushBack('Lvl1');
- levelupAbilities.PushBack('Lvl2');
- levelupAbilities.PushBack('Lvl3');
- levelupAbilities.PushBack('Lvl4');
- levelupAbilities.PushBack('Lvl5');
- levelupAbilities.PushBack('Lvl6');
- levelupAbilities.PushBack('Lvl7');
- levelupAbilities.PushBack('Lvl8');
- levelupAbilities.PushBack('Lvl9');
- levelupAbilities.PushBack('Lvl10');
- levelupAbilities.PushBack('Lvl11');
- levelupAbilities.PushBack('Lvl12');
- levelupAbilities.PushBack('Lvl13');
- levelupAbilities.PushBack('Lvl14');
- levelupAbilities.PushBack('Lvl15');
- levelupAbilities.PushBack('Lvl16');
- levelupAbilities.PushBack('Lvl17');
- levelupAbilities.PushBack('Lvl18');
- levelupAbilities.PushBack('Lvl19');
- levelupAbilities.PushBack('Lvl20');
- levelupAbilities.PushBack('Lvl21');
- levelupAbilities.PushBack('Lvl22');
- levelupAbilities.PushBack('Lvl23');
- levelupAbilities.PushBack('Lvl24');
- levelupAbilities.PushBack('Lvl25');
- levelupAbilities.PushBack('Lvl26');
- levelupAbilities.PushBack('Lvl27');
- levelupAbilities.PushBack('Lvl28');
- levelupAbilities.PushBack('Lvl29');
- levelupAbilities.PushBack('Lvl30');
- levelupAbilities.PushBack('Lvl31');
- levelupAbilities.PushBack('Lvl32');
- levelupAbilities.PushBack('Lvl33');
- levelupAbilities.PushBack('Lvl34');
- levelupAbilities.PushBack('Lvl35');
- levelupAbilities.PushBack('Lvl36');
- levelupAbilities.PushBack('Lvl37');
- levelupAbilities.PushBack('Lvl38');
- levelupAbilities.PushBack('Lvl39');
- levelupAbilities.PushBack('Lvl40');
- levelupAbilities.PushBack('Lvl41');
- levelupAbilities.PushBack('Lvl42');
- levelupAbilities.PushBack('Lvl43');
- levelupAbilities.PushBack('Lvl44');
- levelupAbilities.PushBack('Lvl45');
- levelupAbilities.PushBack('Lvl46');
- levelupAbilities.PushBack('Lvl47');
- levelupAbilities.PushBack('Lvl48');
- levelupAbilities.PushBack('Lvl49');
- levelupAbilities.PushBack('Lvl50');
- levelupAbilities.PushBack('Lvl51');
- levelupAbilities.PushBack('Lvl52');
- levelupAbilities.PushBack('Lvl53');
- levelupAbilities.PushBack('Lvl54');
- levelupAbilities.PushBack('Lvl55');
- levelupAbilities.PushBack('Lvl56');
- levelupAbilities.PushBack('Lvl57');
- levelupAbilities.PushBack('Lvl58');
- levelupAbilities.PushBack('Lvl59');
- levelupAbilities.PushBack('Lvl60');
- levelupAbilities.PushBack('Lvl61');
- levelupAbilities.PushBack('Lvl62');
- levelupAbilities.PushBack('Lvl63');
- levelupAbilities.PushBack('Lvl64');
- levelupAbilities.PushBack('Lvl65');
- levelupAbilities.PushBack('Lvl66');
- levelupAbilities.PushBack('Lvl67');
- levelupAbilities.PushBack('Lvl68');
- levelupAbilities.PushBack('Lvl69');
- levelupAbilities.PushBack('Lvl70');
- levelupAbilities.PushBack('Lvl71');
- levelupAbilities.PushBack('Lvl72');
- levelupAbilities.PushBack('Lvl73');
- levelupAbilities.PushBack('Lvl74');
- levelupAbilities.PushBack('Lvl75');
- levelupAbilities.PushBack('Lvl76');
- levelupAbilities.PushBack('Lvl77');
- levelupAbilities.PushBack('Lvl78');
- levelupAbilities.PushBack('Lvl79');
- levelupAbilities.PushBack('Lvl80');
- levelupAbilities.PushBack('Lvl81');
- levelupAbilities.PushBack('Lvl82');
- levelupAbilities.PushBack('Lvl83');
- levelupAbilities.PushBack('Lvl84');
- levelupAbilities.PushBack('Lvl85');
- levelupAbilities.PushBack('Lvl86');
- levelupAbilities.PushBack('Lvl87');
- levelupAbilities.PushBack('Lvl88');
- levelupAbilities.PushBack('Lvl89');
- levelupAbilities.PushBack('Lvl90');
- levelupAbilities.PushBack('Lvl91');
- levelupAbilities.PushBack('Lvl92');
- levelupAbilities.PushBack('Lvl93');
- levelupAbilities.PushBack('Lvl94');
- levelupAbilities.PushBack('Lvl95');
- levelupAbilities.PushBack('Lvl96');
- levelupAbilities.PushBack('Lvl97');
- levelupAbilities.PushBack('Lvl98');
- levelupAbilities.PushBack('Lvl99');
- levelupAbilities.PushBack('Lvl100');
- if( inputHandler )
- {
- inputHandler.BlockAllActions( 'being_ciri', false );
- }
- SetBehaviorVariable( 'test_ciri_replacer', 0.0f);
- if(!spawnData.restored)
- {
- abilityManager.GainStat(BCS_Toxicity, 0);
- }
- levelManager.PostInit(this, spawnData.restored);
- SetBIsCombatActionAllowed( true );
- SetBIsInputAllowed( true, 'OnSpawned' );
- if ( !reputationManager )
- {
- reputationManager = new W3Reputation in this;
- reputationManager.Initialize();
- }
- theSound.SoundParameter( "focus_aim", 1.0f, 1.0f );
- theSound.SoundParameter( "focus_distance", 0.0f, 1.0f );
- currentlyCastSign = ST_None;
- if(!spawnData.restored)
- {
- horseTemplate = (CEntityTemplate)LoadResource("horse_manager");
- horseManager = (W3HorseManager)theGame.CreateEntity(horseTemplate, GetWorldPosition(),,,,,PM_Persist);
- horseManager.CreateAttachment(this);
- horseManager.OnCreated();
- EntityHandleSet( horseManagerHandle, horseManager );
- }
- //---=== modFriendlyMeditation ===---
- fMeditationConfig = new CModFMeditationConfig in this;
- fMeditationConfig.Init();
- //---=== modFriendlyMeditation ===---
- RemoveAbility('Ciri_CombatRegen');
- RemoveAbility('Ciri_Rage');
- RemoveAbility('CiriBlink');
- RemoveAbility('CiriCharge');
- RemoveAbility('Ciri_Q205');
- RemoveAbility('Ciri_Q305');
- RemoveAbility('Ciri_Q403');
- RemoveAbility('Ciri_Q111');
- RemoveAbility('Ciri_Q501');
- RemoveAbility('SkillCiri');
- if(spawnData.restored)
- {
- RestoreQuen(savedQuenHealth, savedQuenDuration);
- }
- else
- {
- savedQuenHealth = 0.f;
- savedQuenDuration = 0.f;
- }
- if(spawnData.restored)
- ApplyPatchFixes();
- if(!newGamePlusInitialized && FactsQuerySum("NewGamePlus") > 0)
- {
- NewGamePlusInitialize();
- }
- ResumeStaminaRegen('WhirlSkill');
- isInitialized = true;
- //modSitting++
- modPlayerSitting = new CPlayerSitting in this;
- modPlayerSitting.initAction();
- //modSitting--
- }
- private final function AddStartingSchematics()
- {
- AddCraftingSchematic('Starting Armor Upgrade schematic 1', true,true);
- AddCraftingSchematic('Thread schematic', true, true);
- AddCraftingSchematic('String schematic', true, true);
- AddCraftingSchematic('Linen schematic', true, true);
- AddCraftingSchematic('Silk schematic', true, true);
- AddCraftingSchematic('Resin schematic', true, true);
- AddCraftingSchematic('Blasting powder schematic', true, true);
- AddCraftingSchematic('Haft schematic', true, true);
- AddCraftingSchematic('Hardened timber schematic', true, true);
- AddCraftingSchematic('Leather squares schematic', true, true);
- AddCraftingSchematic('Leather schematic', true, true);
- AddCraftingSchematic('Hardened leather schematic', true, true);
- AddCraftingSchematic('Draconide leather schematic', true, true);
- AddCraftingSchematic('Iron ingot schematic', true, true);
- AddCraftingSchematic('Steel ingot schematic', true, true);
- AddCraftingSchematic('Steel ingot schematic 1', true, true);
- AddCraftingSchematic('Steel plate schematic', true, true);
- AddCraftingSchematic('Dark iron ingot schematic', true, true);
- AddCraftingSchematic('Dark steel ingot schematic', true, true);
- AddCraftingSchematic('Dark steel ingot schematic 1', true, true);
- AddCraftingSchematic('Dark steel plate schematic', true, true);
- AddCraftingSchematic('Silver ore schematic', true, true);
- AddCraftingSchematic('Silver ingot schematic', true, true);
- AddCraftingSchematic('Silver ingot schematic 1', true, true);
- AddCraftingSchematic('Silver plate schematic', true, true);
- AddCraftingSchematic('Meteorite ingot schematic', true, true);
- AddCraftingSchematic('Meteorite silver ingot schematic', true, true);
- AddCraftingSchematic('Meteorite silver plate schematic', true, true);
- AddCraftingSchematic('Glowing ingot schematic', true, true);
- AddCraftingSchematic('Dwimeryte ore schematic', true, true);
- AddCraftingSchematic('Dwimeryte ingot schematic', true, true);
- AddCraftingSchematic('Dwimeryte ingot schematic 1', true, true);
- AddCraftingSchematic('Dwimeryte plate schematic', true, true);
- }
- private final function ApplyPatchFixes()
- {
- var cnt : int;
- var pam : W3PlayerAbilityManager;
- var slotId : int;
- if(FactsQuerySum("ClearingPotionPassiveBonusFix") < 1)
- {
- pam = (W3PlayerAbilityManager)abilityManager;
- cnt = GetAbilityCount('sword_adrenalinegain') - pam.GetPathPointsSpent(ESP_Sword);
- if(cnt > 0)
- RemoveAbilityMultiple('sword_adrenalinegain', cnt);
- cnt = GetAbilityCount('magic_staminaregen') - pam.GetPathPointsSpent(ESP_Signs);
- if(cnt > 0)
- RemoveAbilityMultiple('magic_staminaregen', cnt);
- cnt = GetAbilityCount('alchemy_potionduration') - pam.GetPathPointsSpent(ESP_Alchemy);
- if(cnt > 0)
- RemoveAbilityMultiple('alchemy_potionduration', cnt);
- FactsAdd("ClearingPotionPassiveBonusFix");
- }
- if(FactsQuerySum("DimeritiumSynergyFix") < 1)
- {
- slotId = GetSkillSlotID(S_Alchemy_s19);
- if(slotId != -1)
- UnequipSkill(S_Alchemy_s19);
- RemoveAbilityAll('greater_mutagen_color_green_synergy_bonus');
- RemoveAbilityAll('mutagen_color_green_synergy_bonus');
- RemoveAbilityAll('mutagen_color_lesser_green_synergy_bonus');
- RemoveAbilityAll('greater_mutagen_color_blue_synergy_bonus');
- RemoveAbilityAll('mutagen_color_blue_synergy_bonus');
- RemoveAbilityAll('mutagen_color_lesser_blue_synergy_bonus');
- RemoveAbilityAll('greater_mutagen_color_red_synergy_bonus');
- RemoveAbilityAll('mutagen_color_red_synergy_bonus');
- RemoveAbilityAll('mutagen_color_lesser_red_synergy_bonus');
- if(slotId != -1)
- EquipSkill(S_Alchemy_s19, slotId);
- FactsAdd("DimeritiumSynergyFix");
- }
- if(FactsQuerySum("DontShowRecipePinTut") < 1)
- {
- TutorialScript('alchemyRecipePin', '');
- TutorialScript('craftingRecipePin', '');
- }
- if(FactsQuerySum("LevelReqPotGiven") < 1)
- {
- FactsAdd("LevelReqPotGiven");
- inv.AddAnItem('Wolf Hour', 1, false, false, true);
- }
- }
- public final function RestoreQuen(quenHealth : float, quenDuration : float) : bool
- {
- var restoredQuen : W3QuenEntity;
- if(quenHealth > 0.f && quenDuration >= 3.f)
- {
- restoredQuen = (W3QuenEntity)theGame.CreateEntity( signs[ST_Quen].template, GetWorldPosition(), GetWorldRotation() );
- restoredQuen.Init( signOwner, signs[ST_Quen].entity, true );
- restoredQuen.OnStarted();
- restoredQuen.OnThrowing();
- restoredQuen.OnEnded();
- restoredQuen.SetDataFromRestore(quenHealth, quenDuration);
- return true;
- }
- return false;
- }
- public function IsInitialized() : bool
- {
- return isInitialized;
- }
- private final function NewGamePlusInitialize()
- {
- var questItems : array<name>;
- var horseManager : W3HorseManager;
- var horseInventory : CInventoryComponent;
- var i, missingLevels : int;
- horseManager = (W3HorseManager)EntityHandleGet(horseManagerHandle);
- if(horseManager)
- horseInventory = horseManager.GetInventoryComponent();
- theGame.params.SetNewGamePlusLevel(GetLevel());
- missingLevels = 30 - GetLevel();
- for(i=0; i<missingLevels; i+=1)
- {
- AddPoints(EExperiencePoint, levelManager.GetTotalExpForNextLevel() - levelManager.GetPointsTotal(EExperiencePoint), false);
- }
- inv.RemoveItemByTag('Quest', -1);
- horseInventory.RemoveItemByTag('Quest', -1);
- questItems = theGame.GetDefinitionsManager().GetItemsWithTag('Quest');
- for(i=0; i<questItems.Size(); i+=1)
- {
- inv.RemoveItemByName(questItems[i], -1);
- horseInventory.RemoveItemByName(questItems[i], -1);
- }
- inv.RemoveItemByName('mq1002_artifact_3', -1);
- horseInventory.RemoveItemByName('mq1002_artifact_3', -1);
- inv.RemoveItemByTag('NoticeBoardNote', -1);
- horseInventory.RemoveItemByTag('NoticeBoardNote', -1);
- RemoveAllNonAutoBuffs();
- RemoveAlchemyRecipe('Recipe for Trial Potion Kit');
- RemoveAlchemyRecipe('Recipe for Pops Antidote');
- RemoveAlchemyRecipe('Recipe for Czart Lure');
- inv.RemoveItemByTag('Trophy', -1);
- horseInventory.RemoveItemByTag('Trophy', -1);
- inv.RemoveItemByCategory('usable', -1);
- horseInventory.RemoveItemByCategory('usable', -1);
- RemoveAbility('StaminaTutorialProlog');
- RemoveAbility('TutorialStaminaRegenHack');
- RemoveAbility('area_novigrad');
- RemoveAbility('NoRegenEffect');
- RemoveAbility('HeavySwimmingStaminaDrain');
- RemoveAbility('AirBoost');
- RemoveAbility('area_nml');
- RemoveAbility('area_skellige');
- inv.RemoveItemByTag('GwintCard', -1);
- horseInventory.RemoveItemByTag('GwintCard', -1);
- inv.RemoveItemByTag('ReadableItem', -1);
- horseInventory.RemoveItemByTag('ReadableItem', -1);
- abilityManager.RestoreStats();
- ((W3PlayerAbilityManager)abilityManager).RemoveToxicityOffset(10000);
- GetInventory().SingletonItemsRefillAmmo();
- craftingSchematics.Clear();
- AddStartingSchematics();
- inv.AddAnItem('Clearing Potion', 1, true, false, false);
- inv.RemoveItemByName('q203_broken_eyeofloki', -1);
- horseInventory.RemoveItemByName('q203_broken_eyeofloki', -1);
- NewGamePlusReplaceViperSet(inv);
- NewGamePlusReplaceViperSet(horseInventory);
- NewGamePlusReplaceLynxSet(inv);
- NewGamePlusReplaceLynxSet(horseInventory);
- NewGamePlusReplaceGryphonSet(inv);
- NewGamePlusReplaceGryphonSet(horseInventory);
- NewGamePlusReplaceBearSet(inv);
- NewGamePlusReplaceBearSet(horseInventory);
- newGamePlusInitialized = true;
- }
- private final function NewGamePlusReplaceItem( item : name, new_item : name, out inv : CInventoryComponent)
- {
- var i, j : int;
- var ids, new_ids, enh_ids : array<SItemUniqueId>;
- var enh : array<name>;
- var wasEquipped : bool;
- if ( inv.HasItem( item ) )
- {
- ids = inv.GetItemsIds(item);
- for (i = 0; i < ids.Size(); i += 1)
- {
- inv.GetItemEnhancementItems(ids[i], enh);
- wasEquipped = IsItemEquipped( ids[i] );
- inv.RemoveItem(ids[i], 1);
- new_ids = inv.AddAnItem(new_item, 1, true, true, false);
- if ( wasEquipped )
- {
- EquipItem( new_ids[0] );
- }
- for (j = 0; j < enh.Size(); j += 1)
- {
- enh_ids = inv.AddAnItem(enh[j], 1, true, true, false);
- inv.EnhanceItemScript(new_ids[0], enh_ids[0]);
- }
- }
- }
- }
- private final function NewGamePlusReplaceViperSet(out inv : CInventoryComponent)
- {
- NewGamePlusReplaceItem('Viper School steel sword', 'NGP Viper School steel sword', inv);
- NewGamePlusReplaceItem('Viper School silver sword', 'NGP Viper School silver sword', inv);
- }
- private final function NewGamePlusReplaceLynxSet(out inv : CInventoryComponent)
- {
- NewGamePlusReplaceItem('Lynx Armor', 'NGP Lynx Armor', inv);
- NewGamePlusReplaceItem('Lynx Armor 1', 'NGP Lynx Armor 1', inv);
- NewGamePlusReplaceItem('Lynx Armor 2', 'NGP Lynx Armor 2', inv);
- NewGamePlusReplaceItem('Lynx Armor 3', 'NGP Lynx Armor 3', inv);
- NewGamePlusReplaceItem('Lynx Gloves 1', 'NGP Lynx Gloves 1', inv);
- NewGamePlusReplaceItem('Lynx Gloves 2', 'NGP Lynx Gloves 2', inv);
- NewGamePlusReplaceItem('Lynx Gloves 3', 'NGP Lynx Gloves 3', inv);
- NewGamePlusReplaceItem('Lynx Gloves 4', 'NGP Lynx Gloves 4', inv);
- NewGamePlusReplaceItem('Lynx Pants 1', 'NGP Lynx Pants 1', inv);
- NewGamePlusReplaceItem('Lynx Pants 2', 'NGP Lynx Pants 2', inv);
- NewGamePlusReplaceItem('Lynx Pants 3', 'NGP Lynx Pants 3', inv);
- NewGamePlusReplaceItem('Lynx Pants 4', 'NGP Lynx Pants 4', inv);
- NewGamePlusReplaceItem('Lynx Boots 1', 'NGP Lynx Boots 1', inv);
- NewGamePlusReplaceItem('Lynx Boots 2', 'NGP Lynx Boots 2', inv);
- NewGamePlusReplaceItem('Lynx Boots 3', 'NGP Lynx Boots 3', inv);
- NewGamePlusReplaceItem('Lynx Boots 4', 'NGP Lynx Boots 4', inv);
- NewGamePlusReplaceItem('Lynx School steel sword', 'NGP Lynx School steel sword', inv);
- NewGamePlusReplaceItem('Lynx School steel sword 1', 'NGP Lynx School steel sword 1', inv);
- NewGamePlusReplaceItem('Lynx School steel sword 2', 'NGP Lynx School steel sword 2', inv);
- NewGamePlusReplaceItem('Lynx School steel sword 3', 'NGP Lynx School steel sword 3', inv);
- NewGamePlusReplaceItem('Lynx School silver sword', 'NGP Lynx School silver sword', inv);
- NewGamePlusReplaceItem('Lynx School silver sword 1', 'NGP Lynx School silver sword 1', inv);
- NewGamePlusReplaceItem('Lynx School silver sword 2', 'NGP Lynx School silver sword 2', inv);
- NewGamePlusReplaceItem('Lynx School silver sword 3', 'NGP Lynx School silver sword 3', inv);
- }
- private final function NewGamePlusReplaceGryphonSet(out inv : CInventoryComponent)
- {
- NewGamePlusReplaceItem('Gryphon Armor', 'NGP Gryphon Armor', inv);
- NewGamePlusReplaceItem('Gryphon Armor 1', 'NGP Gryphon Armor 1', inv);
- NewGamePlusReplaceItem('Gryphon Armor 2', 'NGP Gryphon Armor 2', inv);
- NewGamePlusReplaceItem('Gryphon Armor 3', 'NGP Gryphon Armor 3', inv);
- NewGamePlusReplaceItem('Gryphon Gloves 1', 'NGP Gryphon Gloves 1', inv);
- NewGamePlusReplaceItem('Gryphon Gloves 2', 'NGP Gryphon Gloves 2', inv);
- NewGamePlusReplaceItem('Gryphon Gloves 3', 'NGP Gryphon Gloves 3', inv);
- NewGamePlusReplaceItem('Gryphon Gloves 4', 'NGP Gryphon Gloves 4', inv);
- NewGamePlusReplaceItem('Gryphon Pants 1', 'NGP Gryphon Pants 1', inv);
- NewGamePlusReplaceItem('Gryphon Pants 2', 'NGP Gryphon Pants 2', inv);
- NewGamePlusReplaceItem('Gryphon Pants 3', 'NGP Gryphon Pants 3', inv);
- NewGamePlusReplaceItem('Gryphon Pants 4', 'NGP Gryphon Pants 4', inv);
- NewGamePlusReplaceItem('Gryphon Boots 1', 'NGP Gryphon Boots 1', inv);
- NewGamePlusReplaceItem('Gryphon Boots 2', 'NGP Gryphon Boots 2', inv);
- NewGamePlusReplaceItem('Gryphon Boots 3', 'NGP Gryphon Boots 3', inv);
- NewGamePlusReplaceItem('Gryphon Boots 4', 'NGP Gryphon Boots 4', inv);
- NewGamePlusReplaceItem('Gryphon School steel sword', 'NGP Gryphon School steel sword', inv);
- NewGamePlusReplaceItem('Gryphon School steel sword 1', 'NGP Gryphon School steel sword 1', inv);
- NewGamePlusReplaceItem('Gryphon School steel sword 2', 'NGP Gryphon School steel sword 2', inv);
- NewGamePlusReplaceItem('Gryphon School steel sword 3', 'NGP Gryphon School steel sword 3', inv);
- NewGamePlusReplaceItem('Gryphon School silver sword', 'NGP Gryphon School silver sword', inv);
- NewGamePlusReplaceItem('Gryphon School silver sword 1', 'NGP Gryphon School silver sword 1', inv);
- NewGamePlusReplaceItem('Gryphon School silver sword 2', 'NGP Gryphon School silver sword 2', inv);
- NewGamePlusReplaceItem('Gryphon School silver sword 3', 'NGP Gryphon School silver sword 3', inv);
- }
- private final function NewGamePlusReplaceBearSet(out inv : CInventoryComponent)
- {
- NewGamePlusReplaceItem('Bear Armor', 'NGP Bear Armor', inv);
- NewGamePlusReplaceItem('Bear Armor 1', 'NGP Bear Armor 1', inv);
- NewGamePlusReplaceItem('Bear Armor 2', 'NGP Bear Armor 2', inv);
- NewGamePlusReplaceItem('Bear Armor 3', 'NGP Bear Armor 3', inv);
- NewGamePlusReplaceItem('Bear Gloves 1', 'NGP Bear Gloves 1', inv);
- NewGamePlusReplaceItem('Bear Gloves 2', 'NGP Bear Gloves 2', inv);
- NewGamePlusReplaceItem('Bear Gloves 3', 'NGP Bear Gloves 3', inv);
- NewGamePlusReplaceItem('Bear Gloves 4', 'NGP Bear Gloves 4', inv);
- NewGamePlusReplaceItem('Bear Pants 1', 'NGP Bear Pants 1', inv);
- NewGamePlusReplaceItem('Bear Pants 2', 'NGP Bear Pants 2', inv);
- NewGamePlusReplaceItem('Bear Pants 3', 'NGP Bear Pants 3', inv);
- NewGamePlusReplaceItem('Bear Pants 4', 'NGP Bear Pants 4', inv);
- NewGamePlusReplaceItem('Bear Boots 1', 'NGP Bear Boots 1', inv);
- NewGamePlusReplaceItem('Bear Boots 2', 'NGP Bear Boots 2', inv);
- NewGamePlusReplaceItem('Bear Boots 3', 'NGP Bear Boots 3', inv);
- NewGamePlusReplaceItem('Bear Boots 4', 'NGP Bear Boots 4', inv);
- NewGamePlusReplaceItem('Bear School steel sword', 'NGP Bear School steel sword', inv);
- NewGamePlusReplaceItem('Bear School steel sword 1', 'NGP Bear School steel sword 1', inv);
- NewGamePlusReplaceItem('Bear School steel sword 2', 'NGP Bear School steel sword 2', inv);
- NewGamePlusReplaceItem('Bear School steel sword 3', 'NGP Bear School steel sword 3', inv);
- NewGamePlusReplaceItem('Bear School silver sword', 'NGP Bear School silver sword', inv);
- NewGamePlusReplaceItem('Bear School silver sword 1', 'NGP Bear School silver sword 1', inv);
- NewGamePlusReplaceItem('Bear School silver sword 2', 'NGP Bear School silver sword 2', inv);
- NewGamePlusReplaceItem('Bear School silver sword 3', 'NGP Bear School silver sword 3', inv);
- }
- timer function BroadcastRain( deltaTime : float, id : int )
- {
- var rainStrength : float = 0;
- rainStrength = GetRainStrength();
- if( rainStrength > 0.5 )
- {
- theGame.GetBehTreeReactionManager().CreateReactionEventIfPossible( thePlayer, 'RainAction', 2.0f , 50.0f, -1.f, -1, true);
- LogReactionSystem( "'RainAction' was sent by Player - single broadcast - distance: 50.0" );
- }
- }
- function InitializeParryType()
- {
- var i, j : int;
- parryTypeTable.Resize( EnumGetMax('EAttackSwingType')+1 );
- for( i = 0; i < EnumGetMax('EAttackSwingType')+1; i += 1 )
- {
- parryTypeTable[i].Resize( EnumGetMax('EAttackSwingDirection')+1 );
- }
- parryTypeTable[AST_Horizontal][ASD_UpDown] = PT_None;
- parryTypeTable[AST_Horizontal][ASD_DownUp] = PT_None;
- parryTypeTable[AST_Horizontal][ASD_LeftRight] = PT_Left;
- parryTypeTable[AST_Horizontal][ASD_RightLeft] = PT_Right;
- parryTypeTable[AST_Vertical][ASD_UpDown] = PT_Up;
- parryTypeTable[AST_Vertical][ASD_DownUp] = PT_Down;
- parryTypeTable[AST_Vertical][ASD_LeftRight] = PT_None;
- parryTypeTable[AST_Vertical][ASD_RightLeft] = PT_None;
- parryTypeTable[AST_DiagonalUp][ASD_UpDown] = PT_None;
- parryTypeTable[AST_DiagonalUp][ASD_DownUp] = PT_None;
- parryTypeTable[AST_DiagonalUp][ASD_LeftRight] = PT_UpLeft;
- parryTypeTable[AST_DiagonalUp][ASD_RightLeft] = PT_RightUp;
- parryTypeTable[AST_DiagonalDown][ASD_UpDown] = PT_None;
- parryTypeTable[AST_DiagonalDown][ASD_DownUp] = PT_None;
- parryTypeTable[AST_DiagonalDown][ASD_LeftRight] = PT_LeftDown;
- parryTypeTable[AST_DiagonalDown][ASD_RightLeft] = PT_DownRight;
- parryTypeTable[AST_Jab][ASD_UpDown] = PT_Jab;
- parryTypeTable[AST_Jab][ASD_DownUp] = PT_Jab;
- parryTypeTable[AST_Jab][ASD_LeftRight] = PT_Jab;
- parryTypeTable[AST_Jab][ASD_RightLeft] = PT_Jab;
- }
- event OnDeath( damageAction : W3DamageAction )
- {
- var items : array< SItemUniqueId >;
- var i, size : int;
- var slot : EEquipmentSlots;
- var holdSlot : name;
- super.OnDeath( damageAction );
- items = GetHeldItems();
- if( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait')
- {
- OnRangedForceHolster( true, true, true );
- rangedWeapon.ClearDeployedEntity(true);
- }
- size = items.Size();
- if ( size > 0 )
- {
- for ( i = 0; i < size; i += 1 )
- {
- if ( this.inv.IsIdValid( items[i] ) && !( this.inv.IsItemCrossbow( items[i] ) ) )
- {
- holdSlot = this.inv.GetItemHoldSlot( items[i] );
- if ( holdSlot == 'l_weapon' && this.IsHoldingItemInLHand() )
- {
- this.OnUseSelectedItem( true );
- }
- DropItemFromSlot( holdSlot, false );
- if ( holdSlot == 'r_weapon' )
- {
- slot = this.GetItemSlot( items[i] );
- if ( UnequipItemFromSlot( slot ) )
- Log( "Unequip" );
- }
- }
- }
- }
- }
- function HandleMovement( deltaTime : float )
- {
- super.HandleMovement( deltaTime );
- rawCameraHeading = theCamera.GetCameraHeading();
- }
- function ToggleSpecialAttackHeavyAllowed( toggle : bool)
- {
- specialAttackHeavyAllowed = toggle;
- }
- function GetReputationManager() : W3Reputation
- {
- return reputationManager;
- }
- function OnRadialMenuItemChoose( selectedItem : string )
- {
- var iSlotId : int;
- if ( selectedItem != "Slot3" )
- {
- if ( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
- OnRangedForceHolster( true, false );
- }
- switch(selectedItem)
- {
- case "Meditation":
- theGame.RequestMenuWithBackground( 'MeditationClockMenu', 'CommonMenu' );
- break;
- case "Slot1":
- SelectQuickslotItem(EES_Petard1);
- break;
- case "Slot2":
- SelectQuickslotItem(EES_Petard2);
- break;
- case "Slot3":
- SelectQuickslotItem(EES_RangedWeapon);
- break;
- case "Slot4":
- SelectQuickslotItem(EES_Quickslot1);
- break;
- case "Slot5":
- SelectQuickslotItem(EES_Quickslot2);
- break;
- default:
- SetEquippedSign(SignStringToEnum( selectedItem ));
- FactsRemove("SignToggled");
- break;
- }
- }
- function ToggleNextItem()
- {
- var quickSlotItems : array< EEquipmentSlots >;
- var currentSelectedItem : SItemUniqueId;
- var item : SItemUniqueId;
- var i : int;
- for( i = EES_Quickslot2; i > EES_Petard1 - 1; i -= 1 )
- {
- GetItemEquippedOnSlot( i, item );
- if( inv.IsIdValid( item ) )
- {
- quickSlotItems.PushBack( i );
- }
- }
- if( !quickSlotItems.Size() )
- {
- return;
- }
- currentSelectedItem = GetSelectedItemId();
- if( inv.IsIdValid( currentSelectedItem ) )
- {
- for( i = 0; i < quickSlotItems.Size(); i += 1 )
- {
- GetItemEquippedOnSlot( quickSlotItems[i], item );
- if( currentSelectedItem == item )
- {
- if( i == quickSlotItems.Size() - 1 )
- {
- SelectQuickslotItem( quickSlotItems[ 0 ] );
- }
- else
- {
- SelectQuickslotItem( quickSlotItems[ i + 1 ] );
- }
- return;
- }
- }
- }
- else
- {
- SelectQuickslotItem( quickSlotItems[ 0 ] );
- }
- }
- function SetEquippedSign( signType : ESignType )
- {
- if(!IsSignBlocked(signType))
- {
- equippedSign = signType;
- FactsSet("CurrentlySelectedSign", equippedSign);
- }
- }
- function GetEquippedSign() : ESignType
- {
- return equippedSign;
- }
- function GetCurrentlyCastSign() : ESignType
- {
- return currentlyCastSign;
- }
- function SetCurrentlyCastSign( type : ESignType, entity : W3SignEntity )
- {
- currentlyCastSign = type;
- if( type != ST_None )
- {
- signs[currentlyCastSign].entity = entity;
- }
- }
- function GetCurrentSignEntity() : W3SignEntity
- {
- if(currentlyCastSign == ST_None)
- return NULL;
- return signs[currentlyCastSign].entity;
- }
- public function GetSignEntity(type : ESignType) : W3SignEntity
- {
- if(type == ST_None)
- return NULL;
- return signs[type].entity;
- }
- public function IsCurrentSignChanneled() : bool
- {
- if( currentlyCastSign != ST_None && signs[currentlyCastSign].entity)
- return signs[currentlyCastSign].entity.OnCheckChanneling();
- return false;
- }
- function IsCastingSign() : bool
- {
- return currentlyCastSign != ST_None;
- }
- protected function IsInCombatActionCameraRotationEnabled() : bool
- {
- if( IsInCombatAction() && ( GetCombatAction() == EBAT_EMPTY || GetCombatAction() == EBAT_Parry ) )
- {
- return true;
- }
- return !bIsInCombatAction;
- }
- function SetHoldBeforeOpenRadialMenuTime ( time : float )
- {
- _HoldBeforeOpenRadialMenuTime = time;
- }
- public function RepairItem ( rapairKitId : SItemUniqueId, usedOnItem : SItemUniqueId )
- {
- var itemMaxDurablity : float;
- var itemCurrDurablity : float;
- var baseRepairValue : float;
- var reapirValue : float;
- var itemAttribute : SAbilityAttributeValue;
- itemMaxDurablity = inv.GetItemMaxDurability(usedOnItem);
- itemCurrDurablity = inv.GetItemDurability(usedOnItem);
- itemAttribute = inv.GetItemAttributeValue ( rapairKitId, 'repairValue' );
- if ( inv.IsItemAnyArmor ( usedOnItem )|| inv.IsItemWeapon( usedOnItem ) )
- {
- baseRepairValue = itemMaxDurablity * itemAttribute.valueMultiplicative;
- reapirValue = MinF( itemCurrDurablity + baseRepairValue, itemMaxDurablity );
- inv.SetItemDurabilityScript ( usedOnItem, MinF ( reapirValue, itemMaxDurablity ));
- }
- inv.RemoveItem ( rapairKitId, 1 );
- }
- public function HasRepairAbleGearEquiped ( ) : bool
- {
- var curEquipedItem : SItemUniqueId;
- return ( GetWitcherPlayer().GetItemEquippedOnSlot(EES_Armor, curEquipedItem) || GetWitcherPlayer().GetItemEquippedOnSlot(EES_Boots, curEquipedItem) || GetWitcherPlayer().GetItemEquippedOnSlot(EES_Pants, curEquipedItem) || GetWitcherPlayer().GetItemEquippedOnSlot(EES_Gloves, curEquipedItem)) == true;
- }
- public function HasRepairAbleWaponEquiped () : bool
- {
- var curEquipedItem : SItemUniqueId;
- return ( GetWitcherPlayer().GetItemEquippedOnSlot(EES_SilverSword, curEquipedItem) || GetWitcherPlayer().GetItemEquippedOnSlot(EES_SteelSword, curEquipedItem) ) == true;
- }
- public function IsItemRepairAble ( item : SItemUniqueId ) : bool
- {
- return inv.GetItemDurabilityRatio(item) <= 0.99999f;
- }
- public function GetOilAppliedOnSword(steel : bool) : name
- {
- //modAnimations++
- var weps : EPlayerWeapon;
- var hasItem : bool;
- var sword : SItemUniqueId;
- //modAnimations--
- if( !super.ApplyOil( oilId, usedOnItem ))
- if(steel)
- hasItem = GetItemEquippedOnSlot(EES_SteelSword, sword);
- else
- // CA
- if( !super.CanApplyOilOnItem( oilId, usedOnItem ) )
- {
- hasItem = GetItemEquippedOnSlot(EES_SilverSword, sword);
- }
- if(!hasItem)
- return '';
- if (CAOilAnimOn() && ((thePlayer.IsInCombat() && CAOilCombat() ) || thePlayer.GetCurrentStateName() == 'Exploration')) {
- completeAnims.SetOil( oilId );
- completeAnims.SetOilOnItem( usedOnItem );
- completeAnims.OilAnim(inv.GetItemCategory(usedOnItem));
- } else {
- super.ApplyOil( oilId, usedOnItem );
- }
- // CA
- return inv.GetSwordOil(sword);
- }
- public function IsEquippedSwordUpgradedWithOil(steel : bool, optional oilName : name) : bool
- {
- var sword : SItemUniqueId;
- var i, minAbs, maxAbs : int;
- var hasItem : bool;
- var abilities, swordAbilities : array<name>;
- var dm : CDefinitionsManagerAccessor;
- var weights : array<float>;
- if(steel)
- hasItem = GetItemEquippedOnSlot(EES_SteelSword, sword);
- else
- hasItem = GetItemEquippedOnSlot(EES_SilverSword, sword);
- if(hasItem)
- {
- inv.GetItemAbilities(sword, swordAbilities);
- dm = theGame.GetDefinitionsManager();
- if(IsNameValid(oilName))
- {
- dm.GetItemAbilitiesWithWeights(oilName, true, abilities, weights, minAbs, maxAbs);
- for(i=0; i<abilities.Size(); i+=1)
- {
- if(dm.AbilityHasTag(abilities[i], theGame.params.OIL_ABILITY_TAG))
- {
- if(swordAbilities.Contains(abilities[i]))
- {
- return true;
- }
- }
- }
- }
- else
- {
- //modAnimations++
- weps = thePlayer.weaponHolster.GetCurrentMeleeWeapon();
- if ( weps == PW_Silver || weps == PW_Steel)
- for(i=0; i<swordAbilities.Size(); i+=1)
- {
- if(dm.AbilityHasTag(swordAbilities[i], theGame.params.OIL_ABILITY_TAG))
- {
- thePlayer.PlayerStartAction( 1, 'man_work_sword_sharpening_02' );
- }
- //modAnimations--
- return true;
- }
- }
- }
- return false;
- }
- public function ApplyOil( oilId : SItemUniqueId, usedOnItem : SItemUniqueId )
- {
- var oilAbilities : array<name>;
- var i : int;
- var ammo, ammoBonus : float;
- var dm : CDefinitionsManagerAccessor;
- var swordEquipped : bool;
- var tutStateOil : W3TutorialManagerUIHandlerStateOils;
- var sword : CWitcherSword;
- if(!CanApplyOilOnItem(oilId, usedOnItem))
- return;
- dm = theGame.GetDefinitionsManager();
- inv.GetItemAbilitiesWithTag(oilId, theGame.params.OIL_ABILITY_TAG, oilAbilities);
- swordEquipped = IsItemEquipped(usedOnItem);
- RemoveItemOil(usedOnItem);
- for(i=0; i<oilAbilities.Size(); i+=1)
- {
- inv.AddItemCraftedAbility(usedOnItem, oilAbilities[i]);
- if(swordEquipped)
- {
- AddAbility(oilAbilities[i]);
- }
- }
- if(swordEquipped)
- {
- sword = (CWitcherSword) inv.GetItemEntityUnsafe(usedOnItem);
- sword.ApplyOil(oilAbilities);
- }
- ammo = CalculateAttributeValue(inv.GetItemAttributeValue(oilId, 'ammo'));
- if(thePlayer.CanUseSkill(S_Alchemy_s06))
- {
- ammoBonus = CalculateAttributeValue(thePlayer.GetSkillAttributeValue(S_Alchemy_s06, 'ammo_bonus', false, false));
- ammo *= 1 + ammoBonus * thePlayer.GetSkillLevel(S_Alchemy_s06);
- }
- inv.SetItemModifierInt(usedOnItem, 'oil_charges', RoundMath(ammo));
- inv.SetItemModifierInt(usedOnItem, 'oil_max_charges', RoundMath(ammo));
- LogOils("Added oil <<" + inv.GetItemName(oilId) + ">> to <<" + inv.GetItemName(usedOnItem) + ">>");
- SetFailedFundamentalsFirstAchievementCondition(true);
- if(ShouldProcessTutorial('TutorialOilCanEquip3'))
- {
- tutStateOil = (W3TutorialManagerUIHandlerStateOils)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
- if(tutStateOil)
- {
- tutStateOil.OnOilApplied();
- }
- }
- theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnOilApplied );
- }
- function ReduceDamage(out damageData : W3DamageAction)
- {
- var actorAttacker : CActor;
- var quen : W3QuenEntity;
- var attackRange : CAIAttackRange;
- var attackerMovementAdjustor : CMovementAdjustor;
- var dist, distToAttacker, actionHeading, attackerHeading : float;
- var attackName : name;
- var useQuenForBleeding : bool;
- super.ReduceDamage(damageData);
- quen = (W3QuenEntity)signs[ST_Quen].entity;
- useQuenForBleeding = false;
- if(quen && !damageData.DealsAnyDamage() && ((W3Effect_Bleeding)damageData.causer) && damageData.GetDamageValue(theGame.params.DAMAGE_NAME_DIRECT) > 0.f)
- useQuenForBleeding = true;
- if(!useQuenForBleeding && !damageData.DealsAnyDamage())
- return;
- actorAttacker = (CActor)damageData.attacker;
- if(actorAttacker && IsCurrentlyDodging() && damageData.CanBeDodged())
- {
- actionHeading = evadeHeading;
- attackerHeading = actorAttacker.GetHeading();
- dist = AngleDistance(actionHeading, attackerHeading);
- distToAttacker = VecDistance(this.GetWorldPosition(),damageData.attacker.GetWorldPosition());
- attackName = actorAttacker.GetLastAttackRangeName();
- attackRange = theGame.GetAttackRangeForEntity( actorAttacker, attackName );
- attackerMovementAdjustor = actorAttacker.GetMovingAgentComponent().GetMovementAdjustor();
- if( ( AbsF(dist) < 150 && attackName != 'stomp' && attackName != 'anchor_special_far' && attackName != 'anchor_far' )
- || ( ( attackName == 'stomp' || attackName == 'anchor_special_far' || attackName == 'anchor_far' )
- && distToAttacker > attackRange.rangeMax * 0.75 ) )
- {
- if ( theGame.CanLog() )
- {
- LogDMHits("W3PlayerWitcher.ReduceDamage: Attack dodged by player - no damage done", damageData);
- }
- damageData.SetAllProcessedDamageAs(0);
- damageData.SetWasDodged();
- }
- else if (!(damageData.IsActionEnvironment() || damageData.IsDoTDamage()) && CanUseSkill(S_Sword_s09))
- {
- damageData.processedDmg.vitalityDamage *= 1 - ( CalculateAttributeValue(thePlayer.GetSkillAttributeValue(S_Sword_s09, 'damage_reduction', false, true)) * thePlayer.GetSkillLevel(S_Sword_s09) );
- if ( theGame.CanLog() )
- {
- LogDMHits("W3PlayerWitcher.ReduceDamage: skill S_Sword_s09 reduced damage while dodging", damageData );
- }
- }
- }
- if(quen && damageData.GetBuffSourceName() != "FallingDamage")
- {
- if ( theGame.CanLog() )
- {
- LogDMHits("W3PlayerWitcher.ReduceDamage: Processing Quen sign damage reduction...", damageData);
- }
- quen.OnTargetHit( damageData );
- }
- }
- timer function UndyingSkillCooldown(dt : float, id : int)
- {
- cannotUseUndyingSkill = false;
- }
- event OnTakeDamage( action : W3DamageAction)
- {
- var currVitality, hpTriggerTreshold : float;
- var healingFactor : float;
- var abilityName : name;
- var abilityCount, maxStack, itemDurability : float;
- var addAbility : bool;
- var min, max : SAbilityAttributeValue;
- var mutagenQuen : W3SignEntity;
- var equipped : array<SItemUniqueId>;
- var i : int;
- currVitality = GetStat(BCS_Vitality);
- if(action.processedDmg.vitalityDamage >= currVitality)
- {
- if(!cannotUseUndyingSkill && FloorF(GetStat(BCS_Focus)) >= 1 && CanUseSkill(S_Sword_s18) && HasBuff(EET_BattleTrance))
- {
- healingFactor = CalculateAttributeValue( GetSkillAttributeValue(S_Sword_s18, 'healing_factor', false, true) );
- healingFactor *= GetStatMax(BCS_Vitality);
- healingFactor *= GetStat(BCS_Focus);
- healingFactor *= 1 + CalculateAttributeValue( GetSkillAttributeValue(S_Sword_s18, 'healing_bonus', false, true) ) * (GetSkillLevel(S_Sword_s18) - 1);
- ForceSetStat(BCS_Vitality, GetStatMax(BCS_Vitality));
- action.processedDmg.vitalityDamage = GetStatMax(BCS_Vitality) - healingFactor;
- DrainFocus(GetStat(BCS_Focus));
- RemoveBuff(EET_BattleTrance);
- cannotUseUndyingSkill = true;
- AddTimer('UndyingSkillCooldown', CalculateAttributeValue( GetSkillAttributeValue(S_Sword_s18, 'trigger_delay', false, true) ), false, , , true);
- }
- else
- {
- equipped = GetEquippedItems();
- for(i=0; i<equipped.Size(); i+=1)
- {
- if ( !inv.IsIdValid( equipped[i] ) )
- {
- continue;
- }
- itemDurability = inv.GetItemDurability(equipped[i]);
- if(inv.ItemHasAbility(equipped[i], 'MA_Reinforced') && itemDurability > 0)
- {
- inv.SetItemDurabilityScript(equipped[i], MaxF(0, itemDurability - action.processedDmg.vitalityDamage) );
- action.processedDmg.vitalityDamage = 0;
- ForceSetStat(BCS_Vitality, 1);
- break;
- }
- }
- }
- }
- if(action.DealsAnyDamage() && !((W3Effect_Toxicity)action.causer) )
- {
- if(HasBuff(EET_Mutagen10))
- RemoveAbilityAll( GetBuff(EET_Mutagen10).GetAbilityName() );
- if(HasBuff(EET_Mutagen15))
- RemoveAbilityAll( GetBuff(EET_Mutagen15).GetAbilityName() );
- }
- if(HasBuff(EET_Mutagen19))
- {
- theGame.GetDefinitionsManager().GetAbilityAttributeValue(GetBuff(EET_Mutagen19).GetAbilityName(), 'max_hp_perc_trigger', min, max);
- hpTriggerTreshold = GetStatMax(BCS_Vitality) * CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
- if(action.GetDamageDealt() >= hpTriggerTreshold)
- {
- mutagenQuen = (W3SignEntity)theGame.CreateEntity( signs[ST_Quen].template, GetWorldPosition(), GetWorldRotation() );
- mutagenQuen.Init( signOwner, signs[ST_Quen].entity, true );
- mutagenQuen.OnStarted();
- mutagenQuen.OnThrowing();
- mutagenQuen.OnEnded();
- }
- }
- if(action.DealsAnyDamage() && !action.IsDoTDamage() && HasBuff(EET_Mutagen27))
- {
- abilityName = GetBuff(EET_Mutagen27).GetAbilityName();
- abilityCount = GetAbilityCount(abilityName);
- if(abilityCount == 0)
- {
- addAbility = true;
- }
- else
- {
- theGame.GetDefinitionsManager().GetAbilityAttributeValue(abilityName, 'mutagen27_max_stack', min, max);
- maxStack = CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
- if(maxStack >= 0)
- {
- addAbility = (abilityCount < maxStack);
- }
- else
- {
- addAbility = true;
- }
- }
- if(addAbility)
- {
- AddAbility(abilityName, true);
- }
- }
- return super.OnTakeDamage(action);
- }
- event OnStartFistfightMinigame()
- {
- super.OnStartFistfightMinigame();
- BlockAction(EIAB_OpenInventory, 'FistFightMinigame', , true);
- BlockAction(EIAB_QuickSlots, 'FistFightMinigame', , true);
- effectManager.RemoveAllPotionEffects();
- }
- event OnEndFistfightMinigame()
- {
- UnblockAction(EIAB_OpenInventory, 'FistFightMinigame');
- UnblockAction(EIAB_QuickSlots, 'FistFightMinigame');
- super.OnEndFistfightMinigame();
- }
- public function GetCriticalHitChance(isHeavyAttack : bool, target : CActor, victimMonsterCategory : EMonsterCategory) : float
- {
- var ret : float;
- ret = super.GetCriticalHitChance(isHeavyAttack, target, victimMonsterCategory);
- return ret;
- }
- public function GetCriticalHitDamageBonus(weaponId : SItemUniqueId, victimMonsterCategory : EMonsterCategory, isStrikeAtBack : bool) : SAbilityAttributeValue
- {
- var min, max, bonus, null, oilBonus : SAbilityAttributeValue;
- var mutagen : CBaseGameplayEffect;
- var vsAttributeName : name;
- bonus = super.GetCriticalHitDamageBonus(weaponId, victimMonsterCategory, isStrikeAtBack);
- if(inv.ItemHasOilApplied(weaponId) && GetStat(BCS_Focus) >= 3 && CanUseSkill(S_Alchemy_s07))
- {
- vsAttributeName = MonsterCategoryToCriticalDamageBonus(victimMonsterCategory);
- oilBonus = inv.GetItemAttributeValue(weaponId, vsAttributeName);
- if(oilBonus != null)
- {
- bonus += GetSkillAttributeValue(S_Alchemy_s07, theGame.params.CRITICAL_HIT_DAMAGE_BONUS, false, true);
- }
- }
- if (isStrikeAtBack && HasBuff(EET_Mutagen11))
- {
- mutagen = GetBuff(EET_Mutagen11);
- theGame.GetDefinitionsManager().GetAbilityAttributeValue(mutagen.GetAbilityName(), 'damageIncrease', min, max);
- bonus += GetAttributeRandomizedValue(min, max);
- }
- return bonus;
- }
- public function ProcessLockTarget( optional newLockTarget : CActor, optional checkLeftStickHeading : bool ) : bool
- {
- var newLockTargetFound : bool;
- newLockTargetFound = super.ProcessLockTarget(newLockTarget, checkLeftStickHeading);
- if(GetCurrentlyCastSign() == ST_Axii)
- {
- ((W3AxiiEntity)GetCurrentSignEntity()).OnDisplayTargetChange(newLockTarget);
- }
- return newLockTargetFound;
- }
- timer function Mutagen14Timer(dt : float, id : int)
- {
- var abilityName : name;
- var abilityCount, maxStack : float;
- var min, max : SAbilityAttributeValue;
- var addAbility : bool;
- abilityName = thePlayer.GetBuff(EET_Mutagen14).GetAbilityName();
- abilityCount = thePlayer.GetAbilityCount(abilityName);
- if(abilityCount == 0)
- {
- addAbility = true;
- }
- else
- {
- theGame.GetDefinitionsManager().GetAbilityAttributeValue(abilityName, 'mutagen14_max_stack', min, max);
- maxStack = CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
- if(maxStack >= 0)
- {
- addAbility = (abilityCount < maxStack);
- }
- else
- {
- addAbility = true;
- }
- }
- if(addAbility)
- {
- thePlayer.AddAbility(abilityName, true);
- }
- else
- {
- RemoveTimer('Mutagen14Timer');
- }
- }
- public final function FailFundamentalsFirstAchievementCondition()
- {
- SetFailedFundamentalsFirstAchievementCondition(true);
- }
- public final function SetUsedQuenInCombat()
- {
- usedQuenInCombat = true;
- }
- public final function UsedQuenInCombat() : bool
- {
- return usedQuenInCombat;
- }
- event OnCombatStart()
- {
- var quenEntity : W3QuenEntity;
- var focus : float;
- super.OnCombatStart();
- if ( IsInCombatActionFriendly() )
- {
- SetBIsCombatActionAllowed(true);
- SetBIsInputAllowed(true, 'OnCombatActionStart' );
- }
- if(HasBuff(EET_Mutagen14))
- {
- AddTimer('Mutagen14Timer', 2, true);
- }
- if(HasBuff(EET_Mutagen15))
- {
- AddAbility(GetBuff(EET_Mutagen15).GetAbilityName(), false);
- }
- quenEntity = (W3QuenEntity)signs[ST_Quen].entity;
- if(quenEntity)
- {
- usedQuenInCombat = quenEntity.IsAnyQuenActive();
- }
- else
- {
- usedQuenInCombat = false;
- }
- if(usedQuenInCombat || HasPotionBuff() || IsEquippedSwordUpgradedWithOil(true) || IsEquippedSwordUpgradedWithOil(false))
- {
- SetFailedFundamentalsFirstAchievementCondition(true);
- }
- else
- {
- if(IsAnyItemEquippedOnSlot(EES_PotionMutagen1) || IsAnyItemEquippedOnSlot(EES_PotionMutagen2) || IsAnyItemEquippedOnSlot(EES_PotionMutagen3) || IsAnyItemEquippedOnSlot(EES_PotionMutagen4))
- SetFailedFundamentalsFirstAchievementCondition(true);
- else
- SetFailedFundamentalsFirstAchievementCondition(false);
- }
- if(GetWitcherPlayer().CanUseSkill(S_Sword_s20) && GetWitcherPlayer().IsThreatened())
- {
- focus = thePlayer.GetStat(BCS_Focus);
- if(focus < 1)
- {
- thePlayer.GainStat(BCS_Focus, 1 - focus);
- }
- }
- MeditationForceAbort(true);
- }
- event OnCombatFinished()
- {
- var mut17 : W3Mutagen17_Effect;
- super.OnCombatFinished();
- if(HasBuff(EET_Mutagen10))
- {
- RemoveAbilityAll( GetBuff(EET_Mutagen10).GetAbilityName() );
- }
- if(HasBuff(EET_Mutagen14))
- {
- RemoveAbilityAll( GetBuff(EET_Mutagen14).GetAbilityName() );
- }
- if(HasBuff(EET_Mutagen15))
- {
- RemoveAbilityAll( GetBuff(EET_Mutagen15).GetAbilityName() );
- }
- if(HasBuff(EET_Mutagen17))
- {
- mut17 = (W3Mutagen17_Effect)GetBuff(EET_Mutagen17);
- mut17.ClearBoost();
- }
- if(HasBuff(EET_Mutagen18))
- {
- RemoveAbilityAll( GetBuff(EET_Mutagen18).GetAbilityName() );
- }
- if(HasBuff(EET_Mutagen22))
- {
- RemoveAbilityAll( GetBuff(EET_Mutagen22).GetAbilityName() );
- }
- if(HasBuff(EET_Mutagen27))
- {
- RemoveAbilityAll( GetBuff(EET_Mutagen27).GetAbilityName() );
- }
- if(GetStat(BCS_Focus) > 0)
- {
- AddTimer('DelayedAdrenalineDrain', theGame.params.ADRENALINE_DRAIN_AFTER_COMBAT_DELAY, , , , true);
- }
- usedQuenInCombat = false;
- theGame.GetGamerProfile().ResetStat(ES_FinesseKills);
- LogChannel( 'OnCombatFinished', "OnCombatFinished: DelayedSheathSword timer added" );
- if ( ShouldAutoSheathSwordInstantly() )
- AddTimer( 'DelayedSheathSword', 0.5f );
- else
- AddTimer( 'DelayedSheathSword', 2.f );
- OnBlockAllCombatTickets( false );
- }
- timer function DelayedAdrenalineDrain(dt : float, id : int)
- {
- AddEffectDefault(EET_AdrenalineDrain, this, "after_combat_adrenaline_drain");
- }
- protected function Attack( hitTarget : CGameplayEntity, animData : CPreAttackEventData, weaponId : SItemUniqueId, parried : bool, countered : bool, parriedBy : array<CActor>, attackAnimationName : name, hitTime : float, weaponEntity : CItemEntity)
- {
- var mutagen17 : W3Mutagen17_Effect;
- super.Attack(hitTarget, animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime, weaponEntity);
- if( (CActor)hitTarget && HasBuff(EET_Mutagen17) )
- {
- mutagen17 = (W3Mutagen17_Effect)GetBuff(EET_Mutagen17);
- if(mutagen17.HasBoost())
- {
- mutagen17.ClearBoost();
- }
- }
- }
- public final timer function SpecialAttackLightSustainCost(dt : float, id : int)
- {
- var focusPerSec, cost, delay : float;
- var reduction : SAbilityAttributeValue;
- var skillLevel : int;
- if(abilityManager && abilityManager.IsInitialized() && IsAlive())
- {
- PauseStaminaRegen('WhirlSkill');
- if(GetStat(BCS_Stamina) > 0)
- {
- cost = GetStaminaActionCost(ESAT_Ability, GetSkillAbilityName(S_Sword_s01), dt);
- delay = GetStaminaActionDelay(ESAT_Ability, GetSkillAbilityName(S_Sword_s01), dt);
- skillLevel = GetSkillLevel(S_Sword_s01);
- if(skillLevel > 1)
- {
- reduction = GetSkillAttributeValue(S_Sword_s01, 'cost_reduction', false, true) * (skillLevel - 1);
- cost = MaxF(0, cost * (1 - reduction.valueMultiplicative) - reduction.valueAdditive);
- }
- DrainStamina(ESAT_FixedValue, cost, delay, GetSkillAbilityName(S_Sword_s01));
- }
- else
- {
- GetSkillAttributeValue(S_Sword_s01, 'focus_cost_per_sec', false, true);
- focusPerSec = GetWhirlFocusCostPerSec();
- DrainFocus(focusPerSec * dt);
- }
- }
- if(GetStat(BCS_Stamina) <= 0 && GetStat(BCS_Focus) <= 0)
- {
- OnPerformSpecialAttack(true, false);
- }
- }
- public final function GetWhirlFocusCostPerSec() : float
- {
- var ability : SAbilityAttributeValue;
- var val : float;
- var skillLevel : int;
- ability = GetSkillAttributeValue(S_Sword_s01, 'focus_cost_per_sec_initial', false, false);
- skillLevel = GetSkillLevel(S_Sword_s01);
- if(skillLevel > 1)
- ability -= GetSkillAttributeValue(S_Sword_s01, 'cost_reduction', false, false) * (skillLevel-1);
- val = CalculateAttributeValue(ability);
- return val;
- }
- public final timer function SpecialAttackHeavySustainCost(dt : float, id : int)
- {
- var focusHighlight, ratio : float;
- var hud : CR4ScriptedHud;
- var hudWolfHeadModule : CR4HudModuleWolfHead;
- DrainStamina(ESAT_Ability, 0, 0, GetSkillAbilityName(S_Sword_s02), dt);
- if(GetStat(BCS_Stamina) <= 0)
- OnPerformSpecialAttack(false, false);
- ratio = EngineTimeToFloat(theGame.GetEngineTime() - specialHeavyStartEngineTime) / specialHeavyChargeDuration;
- if(ratio > 0.95)
- ratio = 1;
- SetSpecialAttackTimeRatio(ratio);
- focusHighlight = ratio * GetStatMax(BCS_Focus);
- focusHighlight = MinF(focusHighlight, GetStat(BCS_Focus));
- focusHighlight = FloorF(focusHighlight);
- hud = (CR4ScriptedHud)theGame.GetHud();
- if ( hud )
- {
- hudWolfHeadModule = (CR4HudModuleWolfHead)hud.GetHudModule( "WolfHeadModule" );
- if ( hudWolfHeadModule )
- {
- hudWolfHeadModule.LockFocusPoints((int)focusHighlight);
- }
- }
- }
- public function OnSpecialAttackHeavyActionProcess()
- {
- var hud : CR4ScriptedHud;
- var hudWolfHeadModule : CR4HudModuleWolfHead;
- super.OnSpecialAttackHeavyActionProcess();
- hud = (CR4ScriptedHud)theGame.GetHud();
- if ( hud )
- {
- hudWolfHeadModule = (CR4HudModuleWolfHead)hud.GetHudModule( "WolfHeadModule" );
- if ( hudWolfHeadModule )
- {
- hudWolfHeadModule.ResetFocusPoints();
- }
- }
- }
- timer function IsSpecialLightAttackInputHeld ( time : float, id : int )
- {
- var hasResource : bool;
- if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
- {
- if ( GetBIsCombatActionAllowed() && inputHandler.IsActionAllowed(EIAB_SwordAttack))
- {
- if(GetStat(BCS_Stamina) > 0)
- {
- hasResource = true;
- }
- else
- {
- hasResource = (GetStat(BCS_Focus) >= GetWhirlFocusCostPerSec() * time);
- }
- if(hasResource)
- {
- SetupCombatAction( EBAT_SpecialAttack_Light, BS_Pressed );
- RemoveTimer('IsSpecialLightAttackInputHeld');
- }
- else if(!playedSpecialAttackMissingResourceSound)
- {
- thePlayer.IndicateTooLowAdrenaline();
- playedSpecialAttackMissingResourceSound = true;
- }
- }
- }
- else
- {
- RemoveTimer('IsSpecialLightAttackInputHeld');
- }
- }
- timer function IsSpecialHeavyAttackInputHeld ( time : float, id : int )
- {
- var cost : float;
- if ( GetCurrentStateName() == 'CombatSteel' || GetCurrentStateName() == 'CombatSilver' )
- {
- cost = CalculateAttributeValue(GetWitcherPlayer().GetSkillAttributeValue(S_Sword_s02, 'stamina_cost_per_sec', false, false));
- if( GetBIsCombatActionAllowed() && inputHandler.IsActionAllowed(EIAB_SwordAttack))
- {
- if(GetStat(BCS_Stamina) >= cost)
- {
- SetupCombatAction( EBAT_SpecialAttack_Heavy, BS_Pressed );
- RemoveTimer('IsSpecialHeavyAttackInputHeld');
- }
- else if(!playedSpecialAttackMissingResourceSound)
- {
- thePlayer.IndicateTooLowAdrenaline();
- playedSpecialAttackMissingResourceSound = true;
- }
- }
- }
- else
- {
- RemoveTimer('IsSpecialHeavyAttackInputHeld');
- }
- }
- public function EvadePressed( bufferAction : EBufferActionType )
- {
- var cat : float;
- if( (bufferAction == EBAT_Dodge && IsActionAllowed(EIAB_Dodge)) || (bufferAction == EBAT_Roll && IsActionAllowed(EIAB_Roll)) )
- {
- if(bufferAction != EBAT_Roll && ShouldProcessTutorial('TutorialDodge'))
- {
- FactsAdd("tut_in_dodge", 1, 2);
- if(FactsQuerySum("tut_fight_use_slomo") > 0)
- {
- theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
- FactsRemove("tut_fight_slomo_ON");
- }
- }
- else if(bufferAction == EBAT_Roll && ShouldProcessTutorial('TutorialRoll'))
- {
- FactsAdd("tut_in_roll", 1, 2);
- if(FactsQuerySum("tut_fight_use_slomo") > 0)
- {
- theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_TutorialFight) );
- FactsRemove("tut_fight_slomo_ON");
- }
- }
- if ( thePlayer.GetBIsInputAllowed() )
- {
- if ( thePlayer.GetBIsCombatActionAllowed() )
- {
- thePlayer.CriticalEffectAnimationInterrupted("Dodge 2");
- thePlayer.PushCombatActionOnBuffer( bufferAction, BS_Released );
- thePlayer.ProcessCombatActionBuffer();
- }
- else if ( thePlayer.IsInCombatAction() && thePlayer.GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
- {
- if ( thePlayer.CanPlayHitAnim() && thePlayer.IsThreatened() )
- {
- thePlayer.CriticalEffectAnimationInterrupted("Dodge 1");
- thePlayer.PushCombatActionOnBuffer( bufferAction, BS_Released );
- thePlayer.ProcessCombatActionBuffer();
- }
- else
- thePlayer.PushCombatActionOnBuffer( bufferAction, BS_Released );
- }
- else if ( !( thePlayer.IsCurrentSignChanneled() ) )
- {
- thePlayer.PushCombatActionOnBuffer( bufferAction, BS_Released );
- }
- }
- else
- {
- if ( thePlayer.IsInCombatAction() && thePlayer.GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack )
- {
- if ( thePlayer.CanPlayHitAnim() && thePlayer.IsThreatened() )
- {
- thePlayer.CriticalEffectAnimationInterrupted("Dodge 3");
- thePlayer.PushCombatActionOnBuffer( bufferAction, BS_Released );
- thePlayer.ProcessCombatActionBuffer();
- }
- else
- thePlayer.PushCombatActionOnBuffer( bufferAction, BS_Released );
- }
- LogChannel( 'InputNotAllowed', "InputNotAllowed" );
- }
- }
- else
- {
- thePlayer.DisplayActionDisallowedHudMessage(EIAB_Dodge);
- }
- }
- public function ProcessCombatActionBuffer() : bool
- {
- var action : EBufferActionType = this.BufferCombatAction;
- var stage : EButtonStage = this.BufferButtonStage;
- var throwStage : EThrowStage;
- var actionResult : bool = true;
- if( isInFinisher )
- {
- return false;
- }
- if ( action != EBAT_SpecialAttack_Heavy )
- specialAttackCamera = false;
- if(super.ProcessCombatActionBuffer())
- return true;
- switch ( action )
- {
- case EBAT_CastSign :
- {
- switch ( stage )
- {
- case BS_Pressed :
- {
- actionResult = this.CastSign();
- LogChannel('SignDebug', "CastSign()");
- } break;
- default :
- {
- actionResult = false;
- } break;
- }
- } break;
- case EBAT_SpecialAttack_Light :
- {
- switch ( stage )
- {
- case BS_Pressed :
- {
- actionResult = this.OnPerformSpecialAttack( true, true );
- } break;
- case BS_Released :
- {
- actionResult = this.OnPerformSpecialAttack( true, false );
- } break;
- default :
- {
- actionResult = false;
- } break;
- }
- } break;
- case EBAT_SpecialAttack_Heavy :
- {
- switch ( stage )
- {
- case BS_Pressed :
- {
- actionResult = this.OnPerformSpecialAttack( false, true );
- } break;
- case BS_Released :
- {
- actionResult = this.OnPerformSpecialAttack( false, false );
- } break;
- default :
- {
- actionResult = false;
- } break;
- }
- } break;
- default:
- return false;
- }
- this.CleanCombatActionBuffer();
- if (actionResult)
- {
- SetCombatAction( action ) ;
- }
- return true;
- }
- event OnPerformSpecialAttack( isLightAttack : bool, enableAttack : bool ){}
- event OnPlayerTickTimer( deltaTime : float )
- {
- super.OnPlayerTickTimer( deltaTime );
- if ( !IsInCombat() )
- {
- fastAttackCounter = 0;
- heavyAttackCounter = 0;
- }
- }
- 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
- {
- var ret : bool;
- var skill : ESkill;
- ret = super.PrepareAttackAction(hitTarget, animData, weaponId, parried, countered, parriedBy, attackAnimationName, hitTime, weaponEntity, attackAction);
- if(!ret)
- return false;
- if(attackAction.IsActionMelee())
- {
- skill = SkillNameToEnum( attackAction.GetAttackTypeName() );
- if( skill != S_SUndefined && CanUseSkill(skill))
- {
- if(IsLightAttack(animData.attackName))
- fastAttackCounter += 1;
- else
- fastAttackCounter = 0;
- if(IsHeavyAttack(animData.attackName))
- heavyAttackCounter += 1;
- else
- heavyAttackCounter = 0;
- }
- }
- AddTimer('FastAttackCounterDecay',5.0);
- AddTimer('HeavyAttackCounterDecay',5.0);
- return true;
- }
- protected function TestParryAndCounter(data : CPreAttackEventData, weaponId : SItemUniqueId, out parried : bool, out countered : bool) : array<CActor>
- {
- if(SkillNameToEnum(attackActionName) == S_Sword_s02)
- data.Can_Parry_Attack = false;
- return super.TestParryAndCounter(data, weaponId, parried, countered);
- }
- private timer function FastAttackCounterDecay(delta : float, id : int)
- {
- fastAttackCounter = 0;
- }
- private timer function HeavyAttackCounterDecay(delta : float, id : int)
- {
- heavyAttackCounter = 0;
- }
- public function GetCraftingSchematicsNames() : array<name> {return craftingSchematics;}
- function AddCraftingSchematic( nam : name, optional isSilent : bool, optional skipTutorialUpdate : bool ) : bool
- {
- var i : int;
- if(!skipTutorialUpdate && ShouldProcessTutorial('TutorialCraftingGotRecipe'))
- {
- FactsAdd("tut_received_schematic");
- }
- for(i=0; i<craftingSchematics.Size(); i+=1)
- {
- if(craftingSchematics[i] == nam)
- return false;
- if(StrCmp(craftingSchematics[i],nam) > 0)
- {
- craftingSchematics.Insert(i,nam);
- AddCraftingHudNotification( nam, isSilent );
- theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_CraftingSchematics );
- return true;
- }
- }
- craftingSchematics.PushBack(nam);
- AddCraftingHudNotification( nam, isSilent );
- theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_CraftingSchematics );
- return true;
- }
- function AddCraftingHudNotification( nam : name, isSilent : bool )
- {
- var hud : CR4ScriptedHud;
- if( !isSilent )
- {
- hud = (CR4ScriptedHud)theGame.GetHud();
- if( hud )
- {
- hud.OnCraftingSchematicUpdate( nam );
- }
- }
- }
- function AddAlchemyHudNotification( nam : name, isSilent : bool )
- {
- var hud : CR4ScriptedHud;
- if( !isSilent )
- {
- hud = (CR4ScriptedHud)theGame.GetHud();
- if( hud )
- {
- hud.OnAlchemySchematicUpdate( nam );
- }
- }
- }
- // CA
- timer function CAApplyOil( dt : float, id : int ) { super.ApplyOil( completeAnims.oilId, completeAnims.usedOnItem ); }
- timer function CAContainerProcessLoot( dt : float, id : int ) { var lootData : W3LootPopupData; lootData = new W3LootPopupData in completeAnims.container; lootData.targetContainer = completeAnims.container; theGame.RequestPopup('LootPopup', lootData); }
- timer function CAConsume( time : float, id : int ) { ConsumeItem( completeAnims.ItemToConsume ); }
- timer function CADrinkPotion( time : float, id : int ) { DrinkPreparedPotion(completeAnims.SlotToConsume); }
- timer function CADrinkPotionInv( time : float, id : int ) { DrinkPreparedPotion(completeAnims.SlotToConsume, completeAnims.ItemToConsume ); }
- timer function CARepairBuffWeapon( dt : float, id : int ) {
- AddEffectDefault(EET_EnhancedWeapon, this, "repair_object", false);
- DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_repair_done"));
- SoundEvent("gui_inventory_silversword_attach");
- }
- timer function CARepairBuffArmor( dt : float, id : int ) {
- AddEffectDefault(EET_EnhancedArmor, this, "repair_object", false);
- DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_repair_done"));
- SoundEvent("gui_inventory_armor_attach");
- }
- // CA
- public function GetAlchemyRecipes() : array<name>
- {
- return alchemyRecipes;
- }
- public function CanLearnAlchemyRecipe(recipeName : name) : bool
- {
- var dm : CDefinitionsManagerAccessor;
- var recipeNode : SCustomNode;
- var i, tmpInt : int;
- var tmpName : name;
- dm = theGame.GetDefinitionsManager();
- if ( dm.GetSubNodeByAttributeValueAsCName( recipeNode, 'alchemy_recipes', 'name_name', recipeName ) )
- {
- return true;
- }
- return false;
- }
- private final function RemoveAlchemyRecipe(recipeName : name)
- {
- alchemyRecipes.Remove(recipeName);
- }
- function AddAlchemyRecipe(nam : name, optional isSilent : bool, optional skipTutorialUpdate : bool) : bool
- {
- var i, potions, bombs : int;
- var found : bool;
- var m_alchemyManager : W3AlchemyManager;
- var recipe : SAlchemyRecipe;
- var knownBombTypes : array<string>;
- var strRecipeName, recipeNameWithoutLevel : string;
- if(!IsAlchemyRecipe(nam))
- return false;
- found = false;
- for(i=0; i<alchemyRecipes.Size(); i+=1)
- {
- if(alchemyRecipes[i] == nam)
- return false;
- if(StrCmp(alchemyRecipes[i],nam) > 0)
- {
- alchemyRecipes.Insert(i,nam);
- found = true;
- AddAlchemyHudNotification(nam,isSilent);
- break;
- }
- }
- if(!found)
- {
- alchemyRecipes.PushBack(nam);
- AddAlchemyHudNotification(nam,isSilent);
- }
- m_alchemyManager = new W3AlchemyManager in this;
- m_alchemyManager.Init(alchemyRecipes);
- m_alchemyManager.GetRecipe(nam, recipe);
- if(CanUseSkill(S_Alchemy_s18))
- {
- if ((recipe.cookedItemType != EACIT_Bolt) && (recipe.cookedItemType != EACIT_Undefined) && (recipe.level <= GetSkillLevel(S_Alchemy_s18)))
- AddAbility(SkillEnumToName(S_Alchemy_s18), true);
- }
- potions = 0;
- bombs = 0;
- for(i=0; i<alchemyRecipes.Size(); i+=1)
- {
- m_alchemyManager.GetRecipe(alchemyRecipes[i], recipe);
- if(recipe.cookedItemType == EACIT_Potion || recipe.cookedItemType == EACIT_MutagenPotion || recipe.cookedItemType == EACIT_Alcohol || recipe.cookedItemType == EACIT_Quest)
- {
- potions += 1;
- }
- else if(recipe.cookedItemType == EACIT_Bomb)
- {
- strRecipeName = NameToString(alchemyRecipes[i]);
- recipeNameWithoutLevel = StrLeft(strRecipeName, StrLen(strRecipeName)-2);
- if(!knownBombTypes.Contains(recipeNameWithoutLevel))
- {
- bombs += 1;
- knownBombTypes.PushBack(recipeNameWithoutLevel);
- }
- }
- }
- theGame.GetGamerProfile().SetStat(ES_KnownPotionRecipes, potions);
- theGame.GetGamerProfile().SetStat(ES_KnownBombRecipes, bombs);
- theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_AlchemyRecipe );
- return true;
- }
- public function GetDisplayHeavyAttackIndicator() : bool
- {
- return bDispalyHeavyAttackIndicator;
- }
- public function SetDisplayHeavyAttackIndicator( val : bool )
- {
- bDispalyHeavyAttackIndicator = val;
- }
- public function GetDisplayHeavyAttackFirstLevelTimer() : bool
- {
- return bDisplayHeavyAttackFirstLevelTimer;
- }
- public function SetDisplayHeavyAttackFirstLevelTimer( val : bool )
- {
- bDisplayHeavyAttackFirstLevelTimer = val;
- }
- public function SelectQuickslotItem( slot : EEquipmentSlots )
- {
- var item : SItemUniqueId;
- GetItemEquippedOnSlot(slot, item);
- selectedItemId = item;
- }
- public function GetMedallion() : W3MedallionController
- {
- if ( !medallionController )
- {
- medallionController = new W3MedallionController in this;
- }
- return medallionController;
- }
- public final function HighlightObjects(range : float, optional highlightTime : float )
- {
- var ents : array<CGameplayEntity>;
- var i : int;
- FindGameplayEntitiesInSphere(ents, GetWorldPosition(), range, 100, 'HighlightedByMedalionFX', FLAG_ExcludePlayer);
- if(highlightTime == 0)
- highlightTime = 30;
- for(i=0; i<ents.Size(); i+=1)
- {
- if(!ents[i].IsHighlighted())
- {
- ents[i].SetHighlighted( true );
- ents[i].PlayEffectSingle( 'medalion_detection_fx' );
- ents[i].AddTimer( 'MedallionEffectOff', highlightTime );
- }
- }
- }
- public final function HighlightEnemies(range : float, optional highlightTime : float )
- {
- var ents : array<CGameplayEntity>;
- var i : int;
- var catComponent : CGameplayEffectsComponent;
- FindGameplayEntitiesInSphere(ents, GetWorldPosition(), range, 100, , FLAG_ExcludePlayer + FLAG_OnlyAliveActors);
- if(highlightTime == 0)
- highlightTime = 5;
- for(i=0; i<ents.Size(); i+=1)
- {
- if(IsRequiredAttitudeBetween(this, ents[i], true))
- {
- catComponent = GetGameplayEffectsComponent(ents[i]);
- if(catComponent)
- {
- catComponent.SetGameplayEffectFlag(EGEF_CatViewHiglight, true);
- ents[i].AddTimer( 'EnemyHighlightOff', highlightTime );
- }
- }
- }
- }
- function SpawnMedallionEntity()
- {
- var rot : EulerAngles;
- var spawnedMedallion : CEntity;
- spawnedMedallion = theGame.GetEntityByTag( 'new_Witcher_medallion_FX' );
- if ( !spawnedMedallion )
- theGame.CreateEntity( medallionEntity, GetWorldPosition(), rot, true, false );
- }
- public final function InterruptCombatFocusMode()
- {
- if( this.GetCurrentStateName() == 'CombatFocusMode_SelectSpot' )
- {
- SetCanPlayHitAnim( true );
- PopState();
- }
- }
- //modAnimations++
- timer function DrinkThePotion(dt : float, id : int)
- {
- var slot : EEquipmentSlots;
- var anim : CComponent;
- var wep : EPlayerWeapon;
- if (!thePlayer.GetWasHit())
- {
- slot = GetPotSlot();
- DrinkPreparedPotion(slot);
- thePlayer.SetIsDrinking(false);
- thePlayer.UnblockAction(EIAB_DrawWeapon, 'InCombat' );
- thePlayer.UnblockAction(EIAB_CallHorse, 'InCombat');
- thePlayer.UnblockAction(EIAB_Signs, 'InCombat');
- thePlayer.UnblockAction(EIAB_Crossbow, 'InCombat');
- thePlayer.UnblockAction(EIAB_UsableItem, 'InCombat');
- thePlayer.UnblockAction(EIAB_ThrowBomb, 'InCombat');
- thePlayer.UnblockAction(EIAB_SwordAttack, 'InCombat');
- thePlayer.UnblockAction(EIAB_Jump, 'InCombat');
- thePlayer.UnblockAction(EIAB_Roll, 'InCombat');
- thePlayer.UnblockAction(EIAB_Dodge, 'InCombat');
- thePlayer.UnblockAction(EIAB_LightAttacks, 'InCombat');
- thePlayer.UnblockAction(EIAB_HeavyAttacks, 'InCombat');
- thePlayer.UnblockAction(EIAB_SpecialAttackLight, 'InCombat');
- thePlayer.UnblockAction(EIAB_SpecialAttackHeavy, 'InCombat');
- //thePlayer.weaponHolster.GetMostConvenientMeleeWeapon(thePlayer.GetTarget());
- wep = thePlayer.GetWep();
- thePlayer.weaponHolster.OnEquipMeleeWeapon( wep, false);
- thePlayer.SetIsDrinking(false);
- }
- else
- {
- wep = thePlayer.GetWep();
- thePlayer.weaponHolster.OnEquipMeleeWeapon( wep, false);
- thePlayer.SetIsDrinking(false);
- }
- }
- private var slotss : EEquipmentSlots;
- private function GetPotSlot() : EEquipmentSlots
- {
- return this.slotss;
- }
- private function SetPotSlot(slot : EEquipmentSlots)
- {
- this.slotss = slot;
- }
- timer function EatTheFood(dt : float, id : int)
- {
- var item : SItemUniqueId;
- var wep : EPlayerWeapon;
- if (!thePlayer.GetWasHit())
- // CA
- if (GetCurrentStateName() == 'Swimming') {
- CAHudNotify(GetLocStringByKeyExt( "menu_cannot_perform_action_here" ));
- return;
- }
- // CA
- {
- item = GetFudSlot();
- // CA
- if (!CAAllowAnimsInCombat() && thePlayer.IsInCombat()) {
- ConsumeItem(item);
- return;
- }
- completeAnims.SetItemToConsume( item );
- if ( inv.ItemHasTag(item, 'Drinks')) {
- if (CADrinkAnimOn()) {
- completeAnims.DrinkAnim('CAConsume');
- } else {
- ConsumeItem(item);
- }
- } else {
- if (CAEatAnimOn()) {
- completeAnims.EatAnim();
- } else {
- ConsumeItem(item);
- thePlayer.SetIsDrinking(false);
- thePlayer.UnblockAction(EIAB_DrawWeapon, 'InCombat' );
- thePlayer.UnblockAction(EIAB_CallHorse, 'InCombat');
- thePlayer.UnblockAction(EIAB_Signs, 'InCombat');
- thePlayer.UnblockAction(EIAB_Crossbow, 'InCombat');
- thePlayer.UnblockAction(EIAB_UsableItem, 'InCombat');
- thePlayer.UnblockAction(EIAB_ThrowBomb, 'InCombat');
- thePlayer.UnblockAction(EIAB_SwordAttack, 'InCombat');
- thePlayer.UnblockAction(EIAB_Jump, 'InCombat');
- thePlayer.UnblockAction(EIAB_Dodge, 'InCombat');
- thePlayer.UnblockAction(EIAB_Roll, 'InCombat');
- thePlayer.UnblockAction(EIAB_LightAttacks, 'InCombat');
- thePlayer.UnblockAction(EIAB_HeavyAttacks, 'InCombat');
- thePlayer.UnblockAction(EIAB_SpecialAttackLight, 'InCombat');
- thePlayer.UnblockAction(EIAB_SpecialAttackHeavy, 'InCombat');
- wep = thePlayer.GetWep();
- thePlayer.weaponHolster.OnEquipMeleeWeapon( wep, false);
- thePlayer.SetIsDrinking(false);
- }
- }
- // CA
- }
- else
- {
- wep = thePlayer.GetWep();
- thePlayer.weaponHolster.OnEquipMeleeWeapon( wep, false);
- // CA
- if (!CAAllowAnimsInCombat() && thePlayer.IsInCombat()) {
- DrinkPreparedPotion(slot);
- thePlayer.SetIsDrinking(false);
- DrinkPreparedPotion(slot);
- return;
- }
- if (CADrinkAnimOn()) {
- completeAnims.SetSlotToConsumeOne( slot );
- completeAnims.DrinkAnim('CADrinkPotion', slot);
- } else {
- DrinkPreparedPotion(slot);
- }
- // CA
- }
- }
- private var itemss : SItemUniqueId;
- private function GetFudSlot() : SItemUniqueId
- {
- return this.itemss;
- }
- private function SetFudSlot(item : SItemUniqueId)
- {
- this.itemss = item;
- }
- timer function Drink(dt : float, id : int)
- {
- if (!thePlayer.GetWasHit())
- {
- thePlayer.PlayerStartAction( 1, 'geralt_determined_gesture_drink' );
- }
- }
- private function SendToxicityTooHighMessage()
- timer function Eat(dt : float, id : int)
- // CA
- public function SendToxicityTooHighMessage()
- {
- var wep : EPlayerWeapon;
- if (!thePlayer.GetWasHit())
- {
- thePlayer.PlayerStartAction( 1, 'work_stand_eat_02' );
- }
- }
- timer function Potion(dt : float, id : int)
- {
- if (!thePlayer.GetWasHit())
- {
- OnUsePotion();
- }
- }
- //modAnimations--
- //modAnimations++
- var anim : CComponent;
- var weps : EPlayerWeapon;
- weps = thePlayer.weaponHolster.GetCurrentMeleeWeapon();
- thePlayer.SetWep(weps);
- thePlayer.SetWasHit(false);
- //modAnimations--
- //modAnimations++
- if ( !thePlayer.isDrinking() && !thePlayer.IsInAir() && !thePlayer.IsCurrentlyDodging() && !thePlayer.wasHeHit())
- {
- if(inv.ItemHasTag(item, 'Drinks'))
- {
- thePlayer.SetIsDrinking(true);
- if (weps == PW_Fists || weps == PW_None)
- {
- SetFudSlot(item);
- //thePlayer.PlayerStartAction( 1, 'work_stand_drink_02' );
- if(!thePlayer.IsInCombat())
- {
- RaiseEvent('ForcedUsableItemUnequip');
- //thePlayer.PlayerStartAction( 1, 'geralt_determined_gesture_drink' );
- AddTimer('Drink',0.2,false);
- AddTimer('EatTheFood',2.7f, false);
- }
- else AddTimer('EatTheFood',0.1f, false);
- }
- else
- {
- if(!thePlayer.IsInCombat())
- {
- RaiseEvent('ForcedUsableItemUnequip');
- thePlayer.OnMeleeForceHolster( true );
- thePlayer.OnRangedForceHolster( true );
- AddTimer('Drink',1.5,false);
- SetFudSlot(item);
- AddTimer('EatTheFood',10.5f, false);
- } else AddTimer('EatTheFood',0.1f, false);
- }
- }
- else if(inv.ItemHasTag(item, 'Edibles'))
- {
- thePlayer.SetIsDrinking(true);
- if (weps == PW_Fists || weps == PW_None)
- {
- SetFudSlot(item);
- if(!thePlayer.IsInCombat())
- {
- thePlayer.PlayerStartAction( 1, 'work_stand_eat_02' );
- AddTimer('EatTheFood',2.1f, false);
- }
- else AddTimer('EatTheFood',0.1f, false);
- }
- else
- {
- if(!thePlayer.IsInCombat())
- {
- thePlayer.OnMeleeForceHolster( true );
- thePlayer.OnRangedForceHolster( true );
- AddTimer('Eat',1.5,false);
- SetFudSlot(item);
- AddTimer('EatTheFood',14.0f, false);
- } else AddTimer('EatTheFood',0.1f, false);
- }
- }
- else
- {
- if (ToxicityLowEnoughToDrinkPotion(slot))
- {
- thePlayer.SetIsDrinking(true);
- // if Geralt is holding something in left hand remove it
- if (IsCurrentlyUsingItemL())
- {
- RaiseEvent('ForcedUsableItemUnequip');
- AddTimer('Potion',0.5f,false);
- AddTimer('DrinkThePotion',2.5f, false);
- }
- else
- {
- OnUsePotion();
- AddTimer('DrinkThePotion',2.0f, false);
- }
- SetPotSlot(slot);
- //DrinkPreparedPotion(slot);
- }
- else
- {
- SendToxicityTooHighMessage();
- }
- }
- }
- //modAnimations--
- public final function AddBombThrowDelay(bombId : SItemUniqueId)
- {
- var slot : EEquipmentSlots;
- slot = GetItemSlot(bombId);
- if(slot == EES_Unused)
- return;
- if(slot == EES_Petard1 || slot == EES_Quickslot1)
- {
- remainingBombThrowDelaySlot1 = theGame.params.BOMB_THROW_DELAY;
- AddTimer('BombDelay1', 0.1, true);
- }
- else if(slot == EES_Petard2 || slot == EES_Quickslot2)
- {
- remainingBombThrowDelaySlot2 = theGame.params.BOMB_THROW_DELAY;
- AddTimer('BombDelay2', 0.1, true);
- }
- }
- public final function GetBombDelay(slot : EEquipmentSlots) : float
- {
- if(slot == EES_Petard1 || slot == EES_Quickslot1)
- return remainingBombThrowDelaySlot1;
- else if(slot == EES_Petard2 || slot == EES_Quickslot2)
- return remainingBombThrowDelaySlot2;
- return 0;
- }
- timer function BombDelay1(dt : float, id : int)
- {
- remainingBombThrowDelaySlot1 -= dt;
- if(remainingBombThrowDelaySlot1 <= 0)
- RemoveTimer('BombDelay1');
- }
- timer function BombDelay2(dt : float, id : int)
- {
- remainingBombThrowDelaySlot2 -= dt;
- if(remainingBombThrowDelaySlot2 <= 0)
- RemoveTimer('BombDelay2');
- }
- public function ResetCharacterDev()
- {
- UnequipItemFromSlot(EES_SkillMutagen1);
- UnequipItemFromSlot(EES_SkillMutagen2);
- UnequipItemFromSlot(EES_SkillMutagen3);
- UnequipItemFromSlot(EES_SkillMutagen4);
- levelManager.ResetCharacterDev();
- ((W3PlayerAbilityManager)abilityManager).ResetCharacterDev();
- }
- public function ConsumeItem( itemId : SItemUniqueId ) : bool
- {
- var itemName : name;
- var removedItem, willRemoveItem : bool;
- var edibles : array<SItemUniqueId>;
- var toSlot : EEquipmentSlots;
- var i : int;
- var equippedNewEdible : bool;
- itemName = inv.GetItemName( itemId );
- if (itemName == 'q111_imlerith_acorn' )
- {
- AddPoints(ESkillPoint, 2, true);
- removedItem = inv.RemoveItem( itemId, 1 );
- theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt("panel_character_popup_title_buy_skill") + "<br>" + GetLocStringByKeyExt("panel_character_availablepoints") + " +2");
- theSound.SoundEvent("gui_character_buy_skill");
- }
- else if ( itemName == 'Clearing Potion' )
- {
- ResetCharacterDev();
- removedItem = inv.RemoveItem( itemId, 1 );
- theGame.GetGuiManager().ShowNotification( GetLocStringByKeyExt("panel_character_popup_character_cleared") );
- theSound.SoundEvent("gui_character_synergy_effect");
- }
- else if(itemName == 'Wolf Hour')
- {
- removedItem = inv.RemoveItem( itemId, 1 );
- theSound.SoundEvent("gui_character_synergy_effect");
- AddEffectDefault(EET_WolfHour, thePlayer, 'wolf hour');
- }
- else
- {
- willRemoveItem = (inv.GetItemQuantity(itemId) == 1);
- if(willRemoveItem)
- toSlot = GetItemSlot(itemId);
- removedItem = super.ConsumeItem(itemId);
- if(willRemoveItem && removedItem)
- {
- edibles = inv.GetItemsByTag('Edibles');
- equippedNewEdible = false;
- for(i=0; i<edibles.Size(); i+=1)
- {
- if(!IsItemEquipped(edibles[i]) && !inv.ItemHasTag(edibles[i], 'Alcohol') && inv.GetItemName(edibles[i]) != 'Clearing Potion' && inv.GetItemName(edibles[i]) != 'Wolf Hour')
- {
- EquipItemInGivenSlot(edibles[i], toSlot, true, false);
- equippedNewEdible = true;
- break;
- }
- }
- if(!equippedNewEdible)
- {
- for(i=0; i<edibles.Size(); i+=1)
- {
- if(!IsItemEquipped(edibles[i]) && inv.GetItemName(edibles[i]) != 'Clearing Potion' && inv.GetItemName(edibles[i]) != 'Wolf Hour')
- {
- EquipItemInGivenSlot(edibles[i], toSlot, true, false);
- break;
- }
- }
- }
- }
- }
- return removedItem;
- }
- public final function GetAlcoholForAlchemicalItemsRefill() : SItemUniqueId
- {
- var alcos : array<SItemUniqueId>;
- var id : SItemUniqueId;
- var i, price, minPrice : int;
- alcos = inv.GetItemsByTag(theGame.params.TAG_ALCHEMY_REFILL_ALCO);
- if(alcos.Size() > 0)
- {
- minPrice = inv.GetItemPrice(alcos[0]);
- price = minPrice;
- id = alcos[0];
- for(i=1; i<alcos.Size(); i+=1)
- {
- price = inv.GetItemPrice(alcos[i]);
- if(price < minPrice)
- {
- minPrice = price;
- id = alcos[i];
- }
- }
- return id;
- }
- return GetInvalidUniqueId();
- }
- public final function ClearPreviouslyUsedBolt()
- {
- previouslyUsedBolt = GetInvalidUniqueId();
- }
- public final function AddAndEquipInfiniteBolt(optional forceBodkin : bool, optional forceHarpoon : bool)
- {
- var bolt, bodkins, harpoons : array<SItemUniqueId>;
- var boltItemName : name;
- var i : int;
- bodkins = inv.GetItemsByName('Bodkin Bolt');
- harpoons = inv.GetItemsByName('Harpoon Bolt');
- for(i=bodkins.Size()-1; i>=0; i-=1)
- inv.RemoveItem(bodkins[i], inv.GetItemQuantity(bodkins[i]) );
- for(i=harpoons.Size()-1; i>=0; i-=1)
- inv.RemoveItem(harpoons[i], inv.GetItemQuantity(harpoons[i]) );
- if(!forceBodkin && (forceHarpoon || GetCurrentStateName() == 'Swimming' || IsSwimming() || IsDiving()) )
- {
- boltItemName = 'Harpoon Bolt';
- }
- else
- {
- boltItemName = 'Bodkin Bolt';
- }
- if(boltItemName == 'Bodkin Bolt' && inv.IsIdValid(previouslyUsedBolt))
- {
- bolt.PushBack(previouslyUsedBolt);
- }
- else
- {
- bolt = inv.AddAnItem(boltItemName, 1, true, true);
- if(boltItemName == 'Harpoon Bolt')
- {
- GetItemEquippedOnSlot(EES_Bolt, previouslyUsedBolt);
- }
- }
- EquipItem(bolt[0], EES_Bolt);
- }
- event OnItemGiven(data : SItemChangedData)
- {
- var m_guiManager : CR4GuiManager;
- super.OnItemGiven(data);
- if(!inv)
- inv = GetInventory();
- if(inv.IsItemEncumbranceItem(data.ids[0]))
- UpdateEncumbrance();
- m_guiManager = theGame.GetGuiManager();
- if(m_guiManager)
- m_guiManager.RegisterNewItem(data.ids[0]);
- }
- public final function CheckForFullyArmedAchievement()
- {
- if( HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_BEAR) || HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_GRYPHON) ||
- HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_LYNX) || HasAllItemsFromSet(theGame.params.ITEM_SET_TAG_WOLF)
- )
- {
- theGame.GetGamerProfile().AddAchievement(EA_FullyArmed);
- }
- }
- public final function HasAllItemsFromSet(setItemTag : name) : bool
- {
- var item : SItemUniqueId;
- if(!GetItemEquippedOnSlot(EES_SteelSword, item) || !inv.ItemHasTag(item, setItemTag))
- return false;
- if(!GetItemEquippedOnSlot(EES_SilverSword, item) || !inv.ItemHasTag(item, setItemTag))
- return false;
- if(!GetItemEquippedOnSlot(EES_Boots, item) || !inv.ItemHasTag(item, setItemTag))
- return false;
- if(!GetItemEquippedOnSlot(EES_Pants, item) || !inv.ItemHasTag(item, setItemTag))
- return false;
- if(!GetItemEquippedOnSlot(EES_Gloves, item) || !inv.ItemHasTag(item, setItemTag))
- return false;
- if(!GetItemEquippedOnSlot(EES_Armor, item) || !inv.ItemHasTag(item, setItemTag))
- return false;
- if(setItemTag == theGame.params.ITEM_SET_TAG_BEAR || setItemTag == theGame.params.ITEM_SET_TAG_LYNX)
- {
- if(!GetItemEquippedOnSlot(EES_RangedWeapon, item) || !inv.ItemHasTag(item, setItemTag))
- return false;
- }
- return true;
- }
- public function GetTotalArmor() : SAbilityAttributeValue
- {
- var armor : SAbilityAttributeValue;
- var armorItem : SItemUniqueId;
- armor = super.GetTotalArmor();
- if(GetItemEquippedOnSlot(EES_Armor, armorItem))
- {
- armor -= inv.GetItemAttributeValue(armorItem, theGame.params.ARMOR_VALUE_NAME);
- armor += inv.GetItemArmorTotal(armorItem);
- }
- if(GetItemEquippedOnSlot(EES_Pants, armorItem))
- {
- armor -= inv.GetItemAttributeValue(armorItem, theGame.params.ARMOR_VALUE_NAME);
- armor += inv.GetItemArmorTotal(armorItem);
- }
- if(GetItemEquippedOnSlot(EES_Boots, armorItem))
- {
- armor -= inv.GetItemAttributeValue(armorItem, theGame.params.ARMOR_VALUE_NAME);
- armor += inv.GetItemArmorTotal(armorItem);
- }
- if(GetItemEquippedOnSlot(EES_Gloves, armorItem))
- {
- armor -= inv.GetItemAttributeValue(armorItem, theGame.params.ARMOR_VALUE_NAME);
- armor += inv.GetItemArmorTotal(armorItem);
- }
- return armor;
- }
- public function ReduceArmorDurability() : EEquipmentSlots
- {
- var r, sum : int;
- var slot : EEquipmentSlots;
- var id : SItemUniqueId;
- var prevDurMult, currDurMult, ratio : float;
- sum = theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT;
- sum += theGame.params.DURABILITY_ARMOR_PANTS_WEIGHT;
- sum += theGame.params.DURABILITY_ARMOR_GLOVES_WEIGHT;
- sum += theGame.params.DURABILITY_ARMOR_BOOTS_WEIGHT;
- sum += theGame.params.DURABILITY_ARMOR_MISS_WEIGHT;
- r = RandRange(sum);
- if(r < theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT)
- slot = EES_Armor;
- else if (r < theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT + theGame.params.DURABILITY_ARMOR_PANTS_WEIGHT)
- slot = EES_Pants;
- else if (r < theGame.params.DURABILITY_ARMOR_CHEST_WEIGHT + theGame.params.DURABILITY_ARMOR_PANTS_WEIGHT + theGame.params.DURABILITY_ARMOR_GLOVES_WEIGHT)
- slot = EES_Gloves;
- 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)
- slot = EES_Boots;
- else
- return EES_InvalidSlot;
- GetItemEquippedOnSlot(slot, id);
- ratio = inv.GetItemDurabilityRatio(id);
- if(inv.ReduceItemDurability(id))
- {
- prevDurMult = theGame.params.GetDurabilityMultiplier(ratio, false);
- ratio = inv.GetItemDurabilityRatio(id);
- currDurMult = theGame.params.GetDurabilityMultiplier(ratio, false);
- if(currDurMult != prevDurMult)
- {
- }
- return slot;
- }
- return EES_InvalidSlot;
- }
- public function DismantleItem(dismantledItem : SItemUniqueId, toolItem : SItemUniqueId) : bool
- {
- var parts : array<SItemParts>;
- var i : int;
- if(!inv.IsItemDismantleKit(toolItem))
- return false;
- parts = inv.GetItemRecyclingParts(dismantledItem);
- if(parts.Size() <= 0)
- return false;
- for(i=0; i<parts.Size(); i+=1)
- inv.AddAnItem(parts[i].itemName, parts[i].quantity, true, false);
- inv.RemoveItem(toolItem);
- inv.RemoveItem(dismantledItem);
- return true;
- }
- public function GetItemEquippedOnSlot(slot : EEquipmentSlots, out item : SItemUniqueId) : bool
- {
- if(slot == EES_InvalidSlot || slot < 0 || slot > EnumGetMax('EEquipmentSlots'))
- return false;
- item = itemSlots[slot];
- return inv.IsIdValid(item);
- }
- public function GetItemSlotByItemName(itemName : name) : EEquipmentSlots
- {
- var ids : array<SItemUniqueId>;
- var i : int;
- var slot : EEquipmentSlots;
- ids = inv.GetItemsByName(itemName);
- for(i=0; i<ids.Size(); i+=1)
- {
- slot = GetItemSlot(ids[i]);
- if(slot != EES_InvalidSlot)
- return slot;
- }
- return EES_InvalidSlot;
- }
- public function GetItemSlot(item : SItemUniqueId) : EEquipmentSlots
- {
- var i : int;
- if(!inv.IsIdValid(item))
- return EES_InvalidSlot;
- for(i=0; i<itemSlots.Size(); i+=1)
- if(itemSlots[i] == item)
- return i;
- return EES_InvalidSlot;
- }
- public function GetEquippedItems() : array<SItemUniqueId>
- {
- return itemSlots;
- }
- public function IsItemEquipped(item : SItemUniqueId) : bool
- {
- if(!inv.IsIdValid(item))
- return false;
- return itemSlots.Contains(item);
- }
- public function IsAnyItemEquippedOnSlot(slot : EEquipmentSlots) : bool
- {
- if(slot == EES_InvalidSlot || slot < 0 || slot > EnumGetMax('EEquipmentSlots'))
- return false;
- return inv.IsIdValid(itemSlots[slot]);
- }
- public function GetFreeQuickslot() : EEquipmentSlots
- {
- if(!inv.IsIdValid(itemSlots[EES_Quickslot1])) return EES_Quickslot1;
- if(!inv.IsIdValid(itemSlots[EES_Quickslot2])) return EES_Quickslot2;
- return EES_InvalidSlot;
- }
- event OnEquipItemRequested(item : SItemUniqueId, ignoreMount : bool)
- {
- var slot : EEquipmentSlots;
- if(inv.IsIdValid(item))
- {
- slot = inv.GetSlotForItemId(item);
- if (slot != EES_InvalidSlot)
- {
- EquipItemInGivenSlot(item, slot, ignoreMount);
- }
- }
- }
- event OnUnequipItemRequested(item : SItemUniqueId)
- {
- UnequipItem(item);
- }
- public function EquipItem(item : SItemUniqueId, optional slot : EEquipmentSlots, optional toHand : bool) : bool
- {
- if(!inv.IsIdValid(item))
- return false;
- if(slot == EES_InvalidSlot)
- {
- slot = inv.GetSlotForItemId(item);
- if(slot == EES_InvalidSlot)
- return false;
- }
- return EquipItemInGivenSlot(item, slot, false, toHand);
- }
- protected function ShouldMount(slot : EEquipmentSlots, item : SItemUniqueId, category : name):bool
- {
- return !IsSlotPotionMutagen(slot) && category != 'usable' && category != 'potion' && category != 'petard' && !inv.ItemHasTag(item, 'PlayerUnwearable');
- }
- protected function ShouldMountItemWithName( itemName: name ): bool
- {
- var slot : EEquipmentSlots;
- var items : array<SItemUniqueId>;
- var category : name;
- var i : int;
- items = inv.GetItemsByName( itemName );
- category = inv.GetItemCategory( items[0] );
- slot = GetItemSlot( items[0] );
- return ShouldMount( slot, items[0], category );
- }
- public function GetMountableItems( out items : array< name > )
- {
- var i : int;
- var mountable : bool;
- var mountableItems : array< name >;
- for ( i = 0; i < items.Size(); i += 1 )
- {
- mountable = ShouldMountItemWithName( items[ i ] );
- if ( mountable )
- {
- mountableItems.PushBack( items[ i ] );
- }
- }
- items = mountableItems;
- }
- public final function SwapEquippedItems(slot1 : EEquipmentSlots, slot2 : EEquipmentSlots)
- {
- var temp : SItemUniqueId;
- var pam : W3PlayerAbilityManager;
- temp = itemSlots[slot1];
- itemSlots[slot1] = itemSlots[slot2];
- itemSlots[slot2] = temp;
- if(IsSlotSkillMutagen(slot1))
- {
- pam = (W3PlayerAbilityManager)abilityManager;
- if(pam)
- pam.OnSwappedMutagensPost(itemSlots[slot1], itemSlots[slot2]);
- }
- }
- public function EquipItemInGivenSlot(item : SItemUniqueId, slot : EEquipmentSlots, ignoreMounting : bool, optional toHand : bool) : bool
- {
- var i, groupID : int;
- var fistsID : array<SItemUniqueId>;
- var pam : W3PlayerAbilityManager;
- var isSkillMutagen : bool;
- var armorEntity : CItemEntity;
- var armorMeshComponent : CComponent;
- var armorSoundIdentification : name;
- var category : name;
- var prevSkillColor : ESkillColor;
- var containedAbilities : array<name>;
- var dm : CDefinitionsManagerAccessor;
- var armorType : EArmorType;
- var otherMask, previousItemInSlot : SItemUniqueId;
- var tutStatePot : W3TutorialManagerUIHandlerStatePotions;
- var tutStateFood : W3TutorialManagerUIHandlerStateFood;
- var tutStateSecondPotionEquip : W3TutorialManagerUIHandlerStateSecondPotionEquip;
- var boltItem : SItemUniqueId;
- if(!inv.IsIdValid(item))
- {
- LogAssert(false, "W3PlayerWitcher.EquipItemInGivenSlot: invalid item");
- return false;
- }
- if(slot == EES_InvalidSlot || slot == EES_HorseBlinders || slot == EES_HorseSaddle || slot == EES_HorseBag || slot == EES_HorseTrophy)
- {
- LogAssert(false, "W3PlayerWitcher.EquipItem: Cannot equip item <<" + inv.GetItemName(item) + ">> - provided slot <<" + slot + ">> is invalid");
- return false;
- }
- if(itemSlots[slot] == item)
- {
- return true;
- }
- if(!HasRequiredLevelToEquipItem(item))
- {
- return false;
- }
- previousItemInSlot = itemSlots[slot];
- if( IsItemEquipped(item))
- {
- SwapEquippedItems(slot, GetItemSlot(item));
- return true;
- }
- isSkillMutagen = IsSlotSkillMutagen(slot);
- if(isSkillMutagen)
- {
- pam = (W3PlayerAbilityManager)abilityManager;
- if(!pam.IsSkillMutagenSlotUnlocked(slot))
- {
- return false;
- }
- }
- if(inv.IsIdValid(previousItemInSlot))
- {
- if(!UnequipItemFromSlot(slot, true))
- {
- LogAssert(false, "W3PlayerWitcher.EquipItem: Cannot equip item <<" + inv.GetItemName(item) + ">> !!");
- return false;
- }
- }
- if(inv.IsItemMask(item))
- {
- if(slot == EES_Quickslot1)
- GetItemEquippedOnSlot(EES_Quickslot2, otherMask);
- else
- GetItemEquippedOnSlot(EES_Quickslot1, otherMask);
- if(inv.IsItemMask(otherMask))
- UnequipItem(otherMask);
- }
- if(isSkillMutagen)
- {
- groupID = pam.GetSkillGroupIdOfMutagenSlot(slot);
- prevSkillColor = pam.GetSkillGroupColor(groupID);
- }
- itemSlots[slot] = item;
- category = inv.GetItemCategory( item );
- if( !ignoreMounting && ShouldMount(slot, item, category) )
- {
- inv.MountItem( item, toHand, IsSlotSkillMutagen( slot ) );
- }
- theTelemetry.LogWithLabelAndValue( TE_INV_ITEM_EQUIPPED, inv.GetItemName(item), slot );
- if(slot == EES_RangedWeapon)
- {
- rangedWeapon = ( Crossbow )( inv.GetItemEntityUnsafe(item) );
- if(!rangedWeapon)
- AddTimer('DelayedOnItemMount', 0.1, true);
- if ( IsSwimming() || IsDiving() )
- {
- GetItemEquippedOnSlot(EES_Bolt, boltItem);
- if(inv.IsIdValid(boltItem))
- {
- if ( !inv.ItemHasTag(boltItem, 'UnderwaterAmmo' ))
- {
- AddAndEquipInfiniteBolt(false, true);
- }
- }
- else if(!IsAnyItemEquippedOnSlot(EES_Bolt))
- {
- AddAndEquipInfiniteBolt(false, true);
- }
- }
- else if(!IsAnyItemEquippedOnSlot(EES_Bolt))
- AddAndEquipInfiniteBolt();
- }
- else if(slot == EES_Bolt)
- {
- if(rangedWeapon)
- { if ( !IsSwimming() || !IsDiving() )
- {
- rangedWeapon.OnReplaceAmmo();
- rangedWeapon.OnWeaponReload();
- }
- else
- {
- DisplayHudMessage(GetLocStringByKeyExt( "menu_cannot_perform_action_now" ));
- }
- }
- }
- else if(isSkillMutagen)
- {
- pam.OnSkillMutagenEquipped(item, slot, prevSkillColor);
- LogSkillColors("Mutagen <<" + inv.GetItemName(item) + ">> equipped to slot <<" + slot + ">>");
- LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
- LogSkillColors("");
- }
- if(inv.ItemHasAbility(item, 'MA_HtH'))
- {
- inv.GetItemContainedAbilities(item, containedAbilities);
- fistsID = inv.GetItemsByName('fists');
- dm = theGame.GetDefinitionsManager();
- for(i=0; i<containedAbilities.Size(); i+=1)
- {
- if(dm.AbilityHasTag(containedAbilities[i], 'MA_HtH'))
- {
- inv.AddItemCraftedAbility(fistsID[0], containedAbilities[i], true);
- }
- }
- }
- if(inv.IsItemAnyArmor(item))
- {
- armorType = inv.GetArmorType(item);
- pam = (W3PlayerAbilityManager)abilityManager;
- if(armorType == EAT_Light)
- {
- if(CanUseSkill(S_Perk_05))
- pam.UpdatePerkArmorBonus(S_Perk_05, true);
- }
- else if(armorType == EAT_Medium)
- {
- if(CanUseSkill(S_Perk_06))
- pam.UpdatePerkArmorBonus(S_Perk_06, true);
- }
- else if(armorType == EAT_Heavy)
- {
- if(CanUseSkill(S_Perk_07))
- pam.UpdatePerkArmorBonus(S_Perk_07, true);
- }
- }
- theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnItemEquipped );
- if(ShouldProcessTutorial('TutorialPotionCanEquip3'))
- {
- if(slot == EES_Potion1 || slot == EES_Potion2)
- {
- tutStatePot = (W3TutorialManagerUIHandlerStatePotions)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
- if(tutStatePot)
- {
- tutStatePot.OnPotionEquipped(inv.GetItemName(item));
- }
- tutStateSecondPotionEquip = (W3TutorialManagerUIHandlerStateSecondPotionEquip)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
- if(tutStateSecondPotionEquip)
- {
- tutStateSecondPotionEquip.OnPotionEquipped(inv.GetItemName(item));
- }
- }
- }
- if(ShouldProcessTutorial('TutorialFoodSelectTab'))
- {
- if( (slot == EES_Potion1 || slot == EES_Potion2) && inv.IsItemFood(item))
- {
- tutStateFood = (W3TutorialManagerUIHandlerStateFood)theGame.GetTutorialSystem().uiHandler.GetCurrentState();
- if(tutStateFood)
- {
- tutStateFood.OnFoodEquipped();
- }
- }
- }
- if(inv.IsItemSetItem(item))
- {
- CheckForFullyArmedAchievement();
- }
- return true;
- }
- private function CheckHairItem()
- {
- var ids : array<SItemUniqueId>;
- var i : int;
- var itemName : name;
- var hairApplied : bool;
- ids = inv.GetItemsByCategory('hair');
- for(i=0; i<ids.Size(); i+= 1)
- {
- itemName = inv.GetItemName( ids[i] );
- if( itemName != 'Preview Hair' )
- {
- if( hairApplied == false )
- {
- inv.MountItem( ids[i], false );
- hairApplied = true;
- }
- else
- {
- inv.RemoveItem( ids[i], 1 );
- }
- }
- }
- if( hairApplied == false )
- {
- ids = inv.AddAnItem('Half With Tail Hairstyle', 1, true, false);
- inv.MountItem( ids[0], false );
- }
- }
- timer function DelayedOnItemMount( dt : float, id : int )
- {
- var crossbowID : SItemUniqueId;
- var invent : CInventoryComponent;
- invent = GetInventory();
- if(!invent)
- return;
- GetItemEquippedOnSlot(EES_RangedWeapon, crossbowID);
- if(invent.IsIdValid(crossbowID))
- {
- rangedWeapon = ( Crossbow )(invent.GetItemEntityUnsafe(crossbowID) );
- if(rangedWeapon)
- {
- RemoveTimer('DelayedOnItemMount');
- }
- }
- else
- {
- RemoveTimer('DelayedOnItemMount');
- }
- }
- public function GetHeldItems() : array<SItemUniqueId>
- {
- var items : array<SItemUniqueId>;
- var item : SItemUniqueId;
- if( inv.GetItemEquippedOnSlot(EES_SilverSword, item) && inv.IsItemHeld(item))
- items.PushBack(item);
- if( inv.GetItemEquippedOnSlot(EES_SteelSword, item) && inv.IsItemHeld(item))
- items.PushBack(item);
- if( inv.GetItemEquippedOnSlot(EES_RangedWeapon, item) && inv.IsItemHeld(item))
- items.PushBack(item);
- if( inv.GetItemEquippedOnSlot(EES_Quickslot1, item) && inv.IsItemHeld(item))
- items.PushBack(item);
- if( inv.GetItemEquippedOnSlot(EES_Quickslot2, item) && inv.IsItemHeld(item))
- items.PushBack(item);
- if( inv.GetItemEquippedOnSlot(EES_Petard1, item) && inv.IsItemHeld(item))
- items.PushBack(item);
- if( inv.GetItemEquippedOnSlot(EES_Petard2, item) && inv.IsItemHeld(item))
- items.PushBack(item);
- return items;
- }
- public function UnequipItemFromSlot(slot : EEquipmentSlots, optional reequipped : bool) : bool
- {
- var item, bolts : SItemUniqueId;
- var items : array<SItemUniqueId>;
- var retBool : bool;
- var fistsID, bolt : array<SItemUniqueId>;
- var i, groupID : int;
- var pam : W3PlayerAbilityManager;
- var prevSkillColor : ESkillColor;
- var containedAbilities : array<name>;
- var dm : CDefinitionsManagerAccessor;
- var armorType : EArmorType;
- var isSwimming : bool;
- var hud : CR4ScriptedHud;
- var damagedItemModule : CR4HudModuleDamagedItems;
- if(slot == EES_InvalidSlot || slot < 0 || slot > EnumGetMax('EEquipmentSlots') || !inv.IsIdValid(itemSlots[slot]))
- return false;
- if(IsSlotSkillMutagen(slot))
- {
- pam = (W3PlayerAbilityManager)abilityManager;
- groupID = pam.GetSkillGroupIdOfMutagenSlot(slot);
- prevSkillColor = pam.GetSkillGroupColor(groupID);
- }
- item = itemSlots[slot];
- itemSlots[slot] = GetInvalidUniqueId();
- if(slot == EES_RangedWeapon)
- {
- this.OnRangedForceHolster( true, true );
- rangedWeapon.ClearDeployedEntity(true);
- rangedWeapon = NULL;
- if(GetItemEquippedOnSlot(EES_Bolt, bolts))
- {
- if(inv.ItemHasTag(bolts, theGame.params.TAG_INFINITE_AMMO))
- {
- inv.RemoveItem(bolts, inv.GetItemQuantity(bolts) );
- }
- }
- }
- else if(IsSlotSkillMutagen(slot))
- {
- pam.OnSkillMutagenUnequipped(item, slot, prevSkillColor);
- LogSkillColors("Mutagen <<" + inv.GetItemName(item) + ">> unequipped from slot <<" + slot + ">>");
- LogSkillColors("Group bonus color is now <<" + pam.GetSkillGroupColor(groupID) + ">>");
- LogSkillColors("");
- }
- if(currentlyEquipedItem == item)
- {
- currentlyEquipedItem = GetInvalidUniqueId();
- RaiseEvent('ForcedUsableItemUnequip');
- }
- if(currentlyEquipedItemL == item)
- {
- if ( currentlyUsedItemL )
- {
- currentlyUsedItemL.OnHidden( this );
- }
- HideUsableItem ( true );
- }
- if( !IsSlotPotionMutagen(slot) )
- {
- GetInventory().UnmountItem(item, true);
- }
- retBool = true;
- if(IsAnyItemEquippedOnSlot(EES_RangedWeapon) && slot == EES_Bolt)
- {
- if(inv.ItemHasTag(item, theGame.params.TAG_INFINITE_AMMO))
- {
- inv.RemoveItem(item, inv.GetItemQuantityByName( inv.GetItemName(item) ) );
- }
- else if (!reequipped)
- {
- AddAndEquipInfiniteBolt();
- }
- }
- if(slot == EES_SilverSword || slot == EES_SteelSword)
- {
- OnEquipMeleeWeapon(PW_None, true);
- }
- if( GetSelectedItemId() == item )
- {
- ClearSelectedItemId();
- }
- if(inv.IsItemBody(item))
- {
- retBool = true;
- }
- if(retBool && !reequipped)
- {
- theTelemetry.LogWithLabelAndValue( TE_INV_ITEM_UNEQUIPPED, inv.GetItemName(item), slot );
- if(slot == EES_SteelSword && !IsAnyItemEquippedOnSlot(EES_SilverSword))
- {
- RemoveBuff(EET_EnhancedWeapon);
- }
- else if(slot == EES_SilverSword && !IsAnyItemEquippedOnSlot(EES_SteelSword))
- {
- RemoveBuff(EET_EnhancedWeapon);
- }
- else if(inv.IsItemAnyArmor(item))
- {
- if( !IsAnyItemEquippedOnSlot(EES_Armor) && !IsAnyItemEquippedOnSlot(EES_Gloves) && !IsAnyItemEquippedOnSlot(EES_Boots) && !IsAnyItemEquippedOnSlot(EES_Pants))
- RemoveBuff(EET_EnhancedArmor);
- }
- }
- if(inv.ItemHasAbility(item, 'MA_HtH'))
- {
- inv.GetItemContainedAbilities(item, containedAbilities);
- fistsID = inv.GetItemsByName('fists');
- dm = theGame.GetDefinitionsManager();
- for(i=0; i<containedAbilities.Size(); i+=1)
- {
- if(dm.AbilityHasTag(containedAbilities[i], 'MA_HtH'))
- {
- inv.RemoveItemCraftedAbility(fistsID[0], containedAbilities[i]);
- }
- }
- }
- if(inv.IsItemAnyArmor(item))
- {
- armorType = inv.GetArmorType(item);
- pam = (W3PlayerAbilityManager)abilityManager;
- if(armorType == EAT_Light)
- {
- if(CanUseSkill(S_Perk_05))
- pam.UpdatePerkArmorBonus(S_Perk_05, false);
- }
- else if(armorType == EAT_Medium)
- {
- if(CanUseSkill(S_Perk_06))
- pam.UpdatePerkArmorBonus(S_Perk_06, false);
- }
- else if(armorType == EAT_Heavy)
- {
- if(CanUseSkill(S_Perk_07))
- pam.UpdatePerkArmorBonus(S_Perk_07, false);
- }
- }
- hud = (CR4ScriptedHud)theGame.GetHud();
- damagedItemModule = hud.GetDamagedItemModule();
- damagedItemModule.OnItemUnequippedFromSlot( slot );
- theGame.GetGlobalEventsManager().OnScriptedEvent( SEC_OnItemEquipped );
- return retBool;
- }
- public function UnequipItem(item : SItemUniqueId) : bool
- {
- if(!inv.IsIdValid(item))
- return false;
- return UnequipItemFromSlot( itemSlots.FindFirst(item) );
- }
- public function DropItem( item : SItemUniqueId, quantity : int ) : bool
- {
- if(!inv.IsIdValid(item))
- return false;
- if(IsItemEquipped(item))
- return UnequipItem(item);
- return true;
- }
- public function IsItemEquippedByName(itemName : name) : bool
- {
- var i : int;
- for(i=0; i<itemSlots.Size(); i+=1)
- if(inv.GetItemName(itemSlots[i]) == itemName)
- return true;
- return false;
- }
- public function IsItemEquippedByCategoryName(categoryName : name) : bool
- {
- var i : int;
- for(i=0; i<itemSlots.Size(); i+=1)
- if(inv.GetItemCategory(itemSlots[i]) == categoryName)
- return true;
- return false;
- }
- public function GetMaxRunEncumbrance(out usesHorseBonus : bool) : float
- {
- var value : float;
- value = CalculateAttributeValue(GetHorseManager().GetHorseAttributeValue('encumbrance', false));
- usesHorseBonus = (value > 0);
- value += CalculateAttributeValue( GetAttributeValue('encumbrance') );
- return value;
- }
- public function GetEncumbrance() : float
- {
- var i: int;
- var encumbrance : float;
- var items : array<SItemUniqueId>;
- var inve : CInventoryComponent;
- inve = GetInventory();
- inve.GetAllItems(items);
- for(i=0; i<items.Size(); i+=1)
- {
- if( inv.IsItemEncumbranceItem( items[i] ) )
- {
- encumbrance += inve.GetItemEncumbrance( items[i] );
- }
- }
- return encumbrance;
- }
- public function UpdateEncumbrance()
- {
- var temp : bool;
- if ( GetEncumbrance() >= (GetMaxRunEncumbrance(temp) + 1) )
- {
- if( !HasBuff(EET_OverEncumbered) )
- {
- AddEffectDefault(EET_OverEncumbered, NULL, "OverEncumbered");
- }
- }
- else if(HasBuff(EET_OverEncumbered))
- {
- RemoveAllBuffsOfType(EET_OverEncumbered);
- }
- }
- public final function GetSkillGroupIDFromIndex(idx : int) : int
- {
- var pam : W3PlayerAbilityManager;
- pam = (W3PlayerAbilityManager)abilityManager;
- if(pam && pam.IsInitialized())
- return pam.GetSkillGroupIDFromIndex(idx);
- return -1;
- }
- public final function GetSkillGroupColor(groupID : int) : ESkillColor
- {
- var pam : W3PlayerAbilityManager;
- pam = (W3PlayerAbilityManager)abilityManager;
- if(pam && pam.IsInitialized())
- return pam.GetSkillGroupColor(groupID);
- return SC_None;
- }
- public final function GetSkillGroupsCount() : int
- {
- var pam : W3PlayerAbilityManager;
- pam = (W3PlayerAbilityManager)abilityManager;
- if(pam && pam.IsInitialized())
- return pam.GetSkillGroupsCount();
- return 0;
- }
- function CycleSelectSign( bIsCyclingLeft : bool ) : ESignType
- {
- var signOrder : array<ESignType>;
- var i : int;
- signOrder.PushBack( ST_Yrden );
- signOrder.PushBack( ST_Quen );
- signOrder.PushBack( ST_Igni );
- signOrder.PushBack( ST_Axii );
- signOrder.PushBack( ST_Aard );
- for( i = 0; i < signOrder.Size(); i += 1 )
- if( signOrder[i] == equippedSign )
- break;
- if(bIsCyclingLeft)
- return signOrder[ (4 + i) % 5 ];
- else
- return signOrder[ (6 + i) % 5 ];
- }
- function ToggleNextSign()
- {
- SetEquippedSign(CycleSelectSign( false ));
- FactsAdd("SignToggled", 1, 1);
- }
- function TogglePreviousSign()
- {
- SetEquippedSign(CycleSelectSign( true ));
- FactsAdd("SignToggled", 1, 1);
- }
- function ProcessSignEvent( eventName : name ) : bool
- {
- if( currentlyCastSign != ST_None && signs[currentlyCastSign].entity)
- {
- return signs[currentlyCastSign].entity.OnProcessSignEvent( eventName );
- }
- return false;
- }
- var findActorTargetTimeStamp : float;
- var pcModeChanneledSignTimeStamp : float;
- event OnProcessCastingOrientation( isContinueCasting : bool )
- {
- var customOrientationTarget : EOrientationTarget;
- var checkHeading : float;
- var rotHeading : float;
- var playerToHeadingDist : float;
- var slideTargetActor : CActor;
- var newLockTarget : CActor;
- var enableNoTargetOrientation : bool;
- var currTime : float;
- enableNoTargetOrientation = true;
- if ( GetDisplayTarget() && this.IsDisplayTargetTargetable() )
- {
- enableNoTargetOrientation = false;
- if ( theInput.GetActionValue( 'CastSignHold' ) > 0 || this.IsCurrentSignChanneled() )
- {
- if ( IsPCModeEnabled() )
- {
- if ( EngineTimeToFloat( theGame.GetEngineTime() ) > pcModeChanneledSignTimeStamp + 1.f )
- enableNoTargetOrientation = true;
- }
- else
- {
- if ( GetCurrentlyCastSign() == ST_Igni || GetCurrentlyCastSign() == ST_Axii )
- {
- slideTargetActor = (CActor)GetDisplayTarget();
- if ( slideTargetActor
- && ( !slideTargetActor.GetGameplayVisibility() || !CanBeTargetedIfSwimming( slideTargetActor ) || !slideTargetActor.IsAlive() ) )
- {
- SetSlideTarget( NULL );
- if ( ProcessLockTarget() )
- slideTargetActor = (CActor)slideTarget;
- }
- if ( !slideTargetActor )
- {
- LockToTarget( false );
- enableNoTargetOrientation = true;
- }
- else if ( IsThreat( slideTargetActor ) || GetCurrentlyCastSign() == ST_Axii )
- LockToTarget( true );
- else
- {
- LockToTarget( false );
- enableNoTargetOrientation = true;
- }
- }
- }
- }
- if ( !enableNoTargetOrientation )
- {
- customOrientationTarget = OT_Actor;
- }
- }
- if ( enableNoTargetOrientation )
- {
- if ( GetPlayerCombatStance() == PCS_AlertNear && theInput.GetActionValue( 'CastSignHold' ) > 0 )
- {
- if ( GetDisplayTarget() && !slideTargetActor )
- {
- currTime = EngineTimeToFloat( theGame.GetEngineTime() );
- if ( currTime > findActorTargetTimeStamp + 1.5f )
- {
- findActorTargetTimeStamp = currTime;
- newLockTarget = GetScreenSpaceLockTarget( GetDisplayTarget(), 180.f, 1.f, 0.f, true );
- if ( newLockTarget && IsThreat( newLockTarget ) && IsCombatMusicEnabled() )
- {
- SetTarget( newLockTarget, true );
- SetMoveTargetChangeAllowed( true );
- SetMoveTarget( newLockTarget );
- SetMoveTargetChangeAllowed( false );
- SetSlideTarget( newLockTarget );
- }
- }
- }
- else
- ProcessLockTarget();
- }
- if ( wasBRAxisPushed )
- customOrientationTarget = OT_CameraOffset;
- else
- {
- if ( !lastAxisInputIsMovement || theInput.LastUsedPCInput() )
- customOrientationTarget = OT_CameraOffset;
- else if ( theInput.GetActionValue( 'CastSignHold' ) > 0 )
- {
- if ( GetOrientationTarget() == OT_CameraOffset )
- customOrientationTarget = OT_CameraOffset;
- else if ( GetPlayerCombatStance() == PCS_AlertNear || GetPlayerCombatStance() == PCS_Guarded )
- customOrientationTarget = OT_CameraOffset;
- else
- customOrientationTarget = OT_Player;
- }
- else
- customOrientationTarget = OT_CustomHeading;
- }
- }
- if ( GetCurrentlyCastSign() == ST_Quen )
- {
- if ( theInput.LastUsedPCInput() )
- {
- customOrientationTarget = OT_Camera;
- }
- else if ( IsCurrentSignChanneled() )
- {
- if ( bLAxisReleased )
- customOrientationTarget = OT_Player;
- else
- customOrientationTarget = OT_Camera;
- }
- else
- customOrientationTarget = OT_Player;
- }
- if ( GetCurrentlyCastSign() == ST_Axii && IsCurrentSignChanneled() )
- {
- if ( slideTarget && (CActor)slideTarget )
- {
- checkHeading = VecHeading( slideTarget.GetWorldPosition() - this.GetWorldPosition() );
- rotHeading = checkHeading;
- playerToHeadingDist = AngleDistance( GetHeading(), checkHeading );
- if ( playerToHeadingDist > 45 )
- SetCustomRotation( 'ChanneledSignAxii', rotHeading, 0.0, 0.5, false );
- else if ( playerToHeadingDist < -45 )
- SetCustomRotation( 'ChanneledSignAxii', rotHeading, 0.0, 0.5, false );
- }
- else
- {
- checkHeading = VecHeading( theCamera.GetCameraDirection() );
- rotHeading = GetHeading();
- playerToHeadingDist = AngleDistance( GetHeading(), checkHeading );
- if ( playerToHeadingDist > 45 )
- SetCustomRotation( 'ChanneledSignAxii', rotHeading - 22.5, 0.0, 0.5, false );
- else if ( playerToHeadingDist < -45 )
- SetCustomRotation( 'ChanneledSignAxii', rotHeading + 22.5, 0.0, 0.5, false );
- }
- }
- if ( IsActorLockedToTarget() )
- customOrientationTarget = OT_Actor;
- AddCustomOrientationTarget( customOrientationTarget, 'Signs' );
- if ( customOrientationTarget == OT_CustomHeading )
- SetOrientationTargetCustomHeading( GetCombatActionHeading(), 'Signs' );
- }
- event OnRaiseSignEvent()
- {
- var newTarget : CActor;
- if ( ( !thePlayer.IsCombatMusicEnabled() && !thePlayer.CanAttackWhenNotInCombat( EBAT_CastSign, false, newTarget ) ) || ( thePlayer.IsOnBoat() && !thePlayer.IsCombatMusicEnabled() ) )
- {
- if ( CastSignFriendly() )
- return true;
- }
- else
- {
- RaiseEvent('CombatActionFriendlyEnd');
- SetBehaviorVariable( 'SignNum', (int)equippedSign );
- SetBehaviorVariable( 'combatActionType', (int)CAT_CastSign );
- if ( IsPCModeEnabled() )
- pcModeChanneledSignTimeStamp = EngineTimeToFloat( theGame.GetEngineTime() );
- if( RaiseForceEvent('CombatAction') )
- {
- OnCombatActionStart();
- findActorTargetTimeStamp = EngineTimeToFloat( theGame.GetEngineTime() );
- theTelemetry.LogWithValueStr(TE_FIGHT_PLAYER_USE_SIGN, SignEnumToString( equippedSign ));
- return true;
- }
- }
- return false;
- }
- function CastSignFriendly() : bool
- {
- var actor : CActor;
- SetBehaviorVariable( 'combatActionTypeForOverlay', (int)CAT_CastSign );
- if ( RaiseCombatActionFriendlyEvent() )
- {
- return true;
- }
- return false;
- }
- function CastSign() : bool
- {
- var equippedSignStr : string;
- var newSignEnt : W3SignEntity;
- var spawnPos : Vector;
- var slotMatrix : Matrix;
- if ( IsInAir() )
- {
- return false;
- }
- AddTemporarySkills();
- if(equippedSign == ST_Aard)
- {
- CalcEntitySlotMatrix('l_weapon', slotMatrix);
- spawnPos = MatrixGetTranslation(slotMatrix);
- }
- else
- {
- spawnPos = GetWorldPosition();
- }
- newSignEnt = (W3SignEntity)theGame.CreateEntity( signs[equippedSign].template, spawnPos, GetWorldRotation() );
- return newSignEnt.Init( signOwner, signs[equippedSign].entity );
- }
- event OnCFMCameraZoomFail(){}
- public final function GetDrunkMutagens() : array<CBaseGameplayEffect>
- {
- return effectManager.GetDrunkMutagens();
- }
- public final function GetPotionBuffs() : array<CBaseGameplayEffect>
- {
- return effectManager.GetPotionBuffs();
- }
- public final function RecalcPotionsDurations()
- {
- var i : int;
- var buffs : array<CBaseGameplayEffect>;
- buffs = GetPotionBuffs();
- for(i=0; i<buffs.Size(); i+=1)
- {
- buffs[i].RecalcPotionDuration();
- }
- }
- public function StartFrenzy()
- {
- var ratio, duration : float;
- var skillLevel : int;
- isInFrenzy = true;
- skillLevel = GetSkillLevel(S_Alchemy_s16);
- ratio = 0.48f - skillLevel * CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s16, 'slowdown_ratio', false, true));
- duration = skillLevel * CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s16, 'slowdown_duration', false, true));
- theGame.SetTimeScale(ratio, theGame.GetTimescaleSource(ETS_SkillFrenzy), theGame.GetTimescalePriority(ETS_SkillFrenzy) );
- AddTimer('SkillFrenzyFinish', duration * ratio, , , , true);
- }
- timer function SkillFrenzyFinish(dt : float, optional id : int)
- {
- theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_SkillFrenzy) );
- isInFrenzy = false;
- }
- public function GetToxicityDamageThreshold() : float
- {
- var ret : float;
- ret = theGame.params.TOXICITY_DAMAGE_THRESHOLD;
- if(CanUseSkill(S_Alchemy_s01))
- ret += CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s01, 'threshold', false, true)) * GetSkillLevel(S_Alchemy_s01);
- return ret;
- }
- public final function AddToxicityOffset( val : float)
- {
- ((W3PlayerAbilityManager)abilityManager).AddToxicityOffset(val);
- if(CanUseSkill(S_Alchemy_s13))
- {
- AddAbilityMultiple(GetSkillAbilityName(S_Alchemy_s13), GetSkillLevel(S_Alchemy_s13));
- }
- }
- public final function RemoveToxicityOffset( val : float)
- {
- ((W3PlayerAbilityManager)abilityManager).RemoveToxicityOffset(val);
- if(CanUseSkill(S_Alchemy_s13))
- {
- RemoveAbilityMultiple(GetSkillAbilityName(S_Alchemy_s13), GetSkillLevel(S_Alchemy_s13));
- }
- }
- public final function CalculatePotionDuration(item : SItemUniqueId, isMutagenPotion : bool, optional itemName : name) : float
- {
- var duration, skillPassiveMod, mutagenSkillMod : float;
- var val, min, max : SAbilityAttributeValue;
- if(inv.IsIdValid(item))
- {
- duration = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'duration'));
- }
- else
- {
- theGame.GetDefinitionsManager().GetItemAttributeValueNoRandom(itemName, true, 'duration', min, max);
- duration = CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
- }
- skillPassiveMod = CalculateAttributeValue(GetAttributeValue('potion_duration'));
- if(isMutagenPotion && CanUseSkill(S_Alchemy_s14))
- {
- val = GetSkillAttributeValue(S_Alchemy_s14, 'duration', false, true);
- mutagenSkillMod = val.valueMultiplicative * GetSkillLevel(S_Alchemy_s14);
- }
- duration = duration * (1 + skillPassiveMod + mutagenSkillMod);
- return duration;
- }
- public function ToxicityLowEnoughToDrinkPotion( slotid : EEquipmentSlots, optional itemId : SItemUniqueId ) : bool
- {
- var item : SItemUniqueId;
- var maxTox : float;
- var potionToxicity : float;
- var toxicityOffset : float;
- var effectType : EEffectType;
- var customAbilityName : name;
- if(itemId != GetInvalidUniqueId())
- item = itemId;
- else
- item = itemSlots[slotid];
- inv.GetPotionItemBuffData(item, effectType, customAbilityName);
- maxTox = abilityManager.GetStatMax(BCS_Toxicity);
- potionToxicity = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity'));
- toxicityOffset = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity_offset'));
- if(effectType != EET_WhiteHoney)
- {
- if(abilityManager.GetStat(BCS_Toxicity, false) + potionToxicity + toxicityOffset > maxTox )
- {
- return false;
- }
- }
- return true;
- }
- public function DrinkPreparedPotion( slotid : EEquipmentSlots, optional itemId : SItemUniqueId )
- {
- var i, ind : int;
- var toxicityOffset : float;
- var potionToxicity, duration, hpGainValue, maxTox : float;
- var randomPotions : array<EEffectType>;
- var effectType : EEffectType;
- var customAbilityName, factId : name;
- var ret : EEffectInteract;
- var atts : array<name>;
- var effectsOld, effectsNew : array<CBaseGameplayEffect>;
- var factPotionParams : W3Potion_Fact_Params;
- var potParams : W3PotionParams;
- var mutagenParams : W3MutagenBuffCustomParams;
- var item : SItemUniqueId;
- var params, potionParams : SCustomEffectParams;
- if(itemId != GetInvalidUniqueId())
- item = itemId;
- else
- item = itemSlots[slotid];
- if(!inv.IsIdValid(item))
- return;
- if( inv.SingletonItemGetAmmo(item) == 0 )
- return;
- inv.GetPotionItemBuffData(item, effectType, customAbilityName);
- maxTox = abilityManager.GetStatMax(BCS_Toxicity);
- potionToxicity = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity'));
- toxicityOffset = CalculateAttributeValue(inv.GetItemAttributeValue(item, 'toxicity_offset'));
- if(effectType != EET_WhiteHoney)
- {
- if(abilityManager.GetStat(BCS_Toxicity, false) + potionToxicity + toxicityOffset > maxTox )
- return;
- }
- customAbilityName = '';
- inv.GetPotionItemBuffData(item, effectType, customAbilityName);
- if(effectType == EET_Fact)
- {
- inv.GetItemAttributes(item, atts);
- for(i=0; i<atts.Size(); i+=1)
- {
- if(StrBeginsWith(NameToString(atts[i]), "fact_"))
- {
- factId = atts[i];
- break;
- }
- }
- factPotionParams = new W3Potion_Fact_Params in theGame;
- factPotionParams.factName = factId;
- factPotionParams.potionItemName = inv.GetItemName(item);
- potionParams.buffSpecificParams = factPotionParams;
- }
- else if(inv.ItemHasTag( item, 'Mutagen' ))
- {
- mutagenParams = new W3MutagenBuffCustomParams in theGame;
- mutagenParams.toxicityOffset = toxicityOffset;
- mutagenParams.potionItemName = inv.GetItemName(item);
- potionParams.buffSpecificParams = mutagenParams;
- }
- else
- {
- potParams = new W3PotionParams in theGame;
- potParams.potionItemName = inv.GetItemName(item);
- potionParams.buffSpecificParams = potParams;
- }
- duration = CalculatePotionDuration(item, inv.ItemHasTag( item, 'Mutagen' ));
- potionParams.effectType = effectType;
- potionParams.creator = this;
- potionParams.sourceName = "drank_potion";
- potionParams.duration = duration;
- potionParams.customAbilityName = customAbilityName;
- ret = AddEffectCustom(potionParams);
- if(factPotionParams)
- delete factPotionParams;
- if(mutagenParams)
- delete mutagenParams;
- inv.SingletonItemRemoveAmmo(item);
- if(ret == EI_Pass || ret == EI_Override || ret == EI_Cumulate)
- {
- abilityManager.GainStat(BCS_Toxicity, potionToxicity );
- if (!IsEffectActive('invisible'))
- {
- PlayEffect('use_potion');
- }
- if ( inv.ItemHasTag( item, 'Mutagen' ) )
- {
- theGame.GetGamerProfile().CheckTrialOfGrasses();
- SetFailedFundamentalsFirstAchievementCondition(true);
- }
- if(CanUseSkill(S_Alchemy_s02))
- {
- hpGainValue = ClampF(GetStatMax(BCS_Vitality) * CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s02, 'vitality_gain_perc', false, true)) * GetSkillLevel(S_Alchemy_s02), 0, GetStatMax(BCS_Vitality));
- GainStat(BCS_Vitality, hpGainValue);
- }
- if(CanUseSkill(S_Alchemy_s04) && !skillBonusPotionEffect && (RandF() < CalculateAttributeValue(GetSkillAttributeValue(S_Alchemy_s04, 'apply_chance', false, true)) * GetSkillLevel(S_Alchemy_s04)))
- {
- randomPotions.PushBack(EET_BlackBlood);
- randomPotions.PushBack(EET_Blizzard);
- randomPotions.PushBack(EET_Cat);
- randomPotions.PushBack(EET_FullMoon);
- randomPotions.PushBack(EET_GoldenOriole);
- randomPotions.PushBack(EET_KillerWhale);
- randomPotions.PushBack(EET_MariborForest);
- randomPotions.PushBack(EET_PetriPhiltre);
- randomPotions.PushBack(EET_Swallow);
- randomPotions.PushBack(EET_TawnyOwl);
- randomPotions.PushBack(EET_Thunderbolt);
- randomPotions.PushBack(EET_WhiteRaffardDecoction);
- randomPotions.Remove(effectType);
- ind = RandRange(randomPotions.Size());
- duration = BonusPotionGetDurationFromXML(randomPotions[ind]);
- if(duration > 0)
- {
- effectsOld = GetCurrentEffects();
- params.effectType = randomPotions[ind];
- params.creator = this;
- params.sourceName = SkillEnumToName(S_Alchemy_s04);
- params.duration = duration;
- ret = AddEffectCustom(params);
- if(ret != EI_Undefined && ret != EI_Deny)
- {
- effectsNew = GetCurrentEffects();
- ind = -1;
- for(i=0; i<effectsNew.Size(); i+=1)
- {
- if(!effectsOld.Contains(effectsNew[i]))
- {
- ind = i;
- break;
- }
- }
- if(ind > -1)
- {
- skillBonusPotionEffect = effectsNew[ind];
- }
- }
- }
- }
- }
- theTelemetry.LogWithLabel(TE_ELIXIR_USED, inv.GetItemName(item));
- if(ShouldProcessTutorial('TutorialPotionAmmo'))
- {
- FactsAdd("tut_used_potion");
- }
- SetFailedFundamentalsFirstAchievementCondition(true);
- }
- private function BonusPotionGetDurationFromXML(type : EEffectType) : float
- {
- var dm : CDefinitionsManagerAccessor;
- var main, ingredients : SCustomNode;
- var tmpName, typeName, itemName : name;
- var abs : array<name>;
- var min, max : SAbilityAttributeValue;
- var tmpInt : int;
- var temp : array<float>;
- var i, temp2, temp3 : int;
- dm = theGame.GetDefinitionsManager();
- main = dm.GetCustomDefinition('alchemy_recipes');
- typeName = EffectTypeToName(type);
- for(i=0; i<main.subNodes.Size(); i+=1)
- {
- if(dm.GetCustomNodeAttributeValueName(main.subNodes[i], 'type_name', tmpName))
- {
- if(tmpName == typeName)
- {
- if(dm.GetCustomNodeAttributeValueInt(main.subNodes[i], 'level', tmpInt))
- {
- if(tmpInt == 1)
- {
- if(dm.GetCustomNodeAttributeValueName(main.subNodes[i], 'cookedItem_name', itemName))
- {
- if(IsNameValid(itemName))
- {
- break;
- }
- }
- }
- }
- }
- }
- }
- if(!IsNameValid(itemName))
- return 0;
- dm.GetItemAbilitiesWithWeights(itemName, true, abs, temp, temp2, temp3);
- dm.GetAbilitiesAttributeValue(abs, 'duration', min, max);
- return CalculateAttributeValue(GetAttributeRandomizedValue(min, max));
- }
- public function ClearSkillBonusPotionEffect()
- {
- skillBonusPotionEffect = NULL;
- }
- public function GetSkillBonusPotionEffect() : CBaseGameplayEffect
- {
- return skillBonusPotionEffect;
- }
- public final function AddRepairObjectBuff(armor : bool, weapon : bool) : bool
- {
- var added : bool;
- //modAnimations++
- var weps : EPlayerWeapon;
- //modAnimations--
- // CA
- var wpn : EPlayerWeapon;
- // CA
- added = false;
- if(weapon && (IsAnyItemEquippedOnSlot(EES_SilverSword) || IsAnyItemEquippedOnSlot(EES_SteelSword)) )
- {
- //modAnimations++
- weps = thePlayer.weaponHolster.GetCurrentMeleeWeapon();
- if ( weps == PW_Silver || weps == PW_Steel)
- {
- // CA
- if (CAGrindstoneAnimOn()) {
- completeAnims.GrindstoneAnim();
- } else {
- thePlayer.PlayerStartAction( PEA_SlotAnimation, 'man_work_sword_sharpening_06' );
- AddEffectDefault(EET_EnhancedWeapon, this, "repair_object", false);
- DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_repair_done"));
- SoundEvent("gui_inventory_silversword_attach");
- }
- // CA
- added = true;
- }
- //modAnimations--
- }
- if(armor && (IsAnyItemEquippedOnSlot(EES_Armor) || IsAnyItemEquippedOnSlot(EES_Gloves) || IsAnyItemEquippedOnSlot(EES_Boots) || IsAnyItemEquippedOnSlot(EES_Pants)) )
- {
- //modAnimations++
- thePlayer.OnMeleeForceHolster( true );
- thePlayer.PlayerStartAction(PEA_SlotAnimation, 'man_standing_adjusting_and_cleaning_clothes_loop_2');
- //modAnimations--
- // CA
- if (CAWorkbenchAnimOn()) {
- completeAnims.WorkbenchAnim();
- } else {
- AddEffectDefault(EET_EnhancedArmor, this, "repair_object", false);
- DisplayHudMessage(GetLocStringByKeyExt("panel_hud_message_repair_done"));
- SoundEvent("gui_inventory_armor_attach");
- }
- // CA
- added = true;
- }
- return added;
- }
- public function StartCSAnim(buff : CBaseGameplayEffect) : bool
- {
- if(IsAnyQuenActive() && (W3CriticalDOTEffect)buff)
- return false;
- return super.StartCSAnim(buff);
- }
- public function GetPotionBuffLevel(effectType : EEffectType) : int
- {
- if(effectManager && effectManager.IsReady())
- return effectManager.GetPotionBuffLevel(effectType);
- return 0;
- }
- event OnLevelGained(currentLevel : int, show : bool)
- {
- var hud : CR4ScriptedHud;
- hud = (CR4ScriptedHud)theGame.GetHud();
- if(abilityManager && abilityManager.IsInitialized())
- {
- ((W3PlayerAbilityManager)abilityManager).OnLevelGained(currentLevel);
- }
- if ( theGame.GetDifficultyMode() != EDM_Hardcore )
- {
- Heal(GetStatMax(BCS_Vitality));
- }
- if(currentLevel >= 35)
- {
- theGame.GetGamerProfile().AddAchievement(EA_Immortal);
- }
- if ( hud && currentLevel < 70 )
- {
- hud.OnLevelUpUpdate(currentLevel, show);
- }
- theGame.RequestAutoSave( "level gained", false );
- }
- public function GetSignStats(skill : ESkill, out damageType : name, out damageVal : float, out spellPower : SAbilityAttributeValue)
- {
- var i, size : int;
- var dm : CDefinitionsManagerAccessor;
- var attrs : array<name>;
- spellPower = GetPowerStatValue(CPS_SpellPower);
- dm = theGame.GetDefinitionsManager();
- dm.GetAbilityAttributes(GetSkillAbilityName(skill), attrs);
- size = attrs.Size();
- for( i = 0; i < size; i += 1 )
- {
- if( IsDamageTypeNameValid(attrs[i]) )
- {
- damageVal = CalculateAttributeValue(GetSkillAttributeValue(skill, attrs[i], false, true));
- damageType = attrs[i];
- break;
- }
- }
- }
- public function SetIgnorePainMaxVitality(val : float)
- {
- if(abilityManager && abilityManager.IsInitialized())
- abilityManager.SetStatPointMax(BCS_Vitality, val);
- }
- event OnAnimEvent_ActionBlend( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
- {
- if ( animEventType == AET_DurationStart && !disableActionBlend )
- {
- if ( this.IsCastingSign() )
- ProcessSignEvent( 'cast_end' );
- FindMoveTarget();
- SetCanPlayHitAnim( true );
- this.SetBIsCombatActionAllowed( true );
- if ( this.GetFinisherVictim() && this.GetFinisherVictim().HasAbility( 'ForceFinisher' ) )
- {
- this.GetFinisherVictim().SignalGameplayEvent( 'Finisher' );
- }
- else if (this.BufferCombatAction != EBAT_EMPTY )
- {
- if ( !IsCombatMusicEnabled() )
- {
- SetCombatActionHeading( ProcessCombatActionHeading( this.BufferCombatAction ) );
- FindTarget();
- UpdateDisplayTarget( true );
- }
- if ( AllowAttack( GetTarget(), this.BufferCombatAction ) )
- this.ProcessCombatActionBuffer();
- }
- else
- {
- ResumeEffects(EET_AutoStaminaRegen, 'InsideCombatAction');
- }
- }
- else if ( disableActionBlend )
- {
- disableActionBlend = false;
- }
- }
- event OnAnimEvent_Sign( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
- {
- if( animEventType == AET_Tick )
- {
- ProcessSignEvent( animEventName );
- }
- }
- event OnAnimEvent_Throwable( animEventName : name, animEventType : EAnimationEventType, animInfo : SAnimationEventAnimInfo )
- {
- var thrownEntity : CThrowable;
- thrownEntity = (CThrowable)EntityHandleGet( thrownEntityHandle );
- if ( inv.IsItemCrossbow( inv.GetItemFromSlot('l_weapon') ) && rangedWeapon.OnProcessThrowEvent( animEventName ) )
- {
- return true;
- }
- else if( thrownEntity && IsThrowingItem() && thrownEntity.OnProcessThrowEvent( animEventName ) )
- {
- return true;
- }
- }
- //modFriendlyMeditation begin
- UnblockAction( EIAB_OpenMeditation, 'WitcherBed' );
- UnblockAction( EIAB_MeditationWaiting, 'WitcherBed' );
- //modFriendlyMeditation end
- public function IsInCombatAction_SpecialAttack() : bool
- {
- if ( IsInCombatAction() && ( GetCombatAction() == EBAT_SpecialAttack_Light || GetCombatAction() == EBAT_SpecialAttack_Heavy ) )
- return true;
- else
- return false;
- }
- protected function WhenCombatActionIsFinished()
- {
- super.WhenCombatActionIsFinished();
- RemoveTimer( 'ProcessAttackTimer' );
- RemoveTimer( 'AttackTimerEnd' );
- CastSignAbort();
- specialAttackCamera = false;
- this.OnPerformSpecialAttack( true, false );
- }
- event OnCombatActionEnd()
- {
- this.CleanCombatActionBuffer();
- super.OnCombatActionEnd();
- RemoveTemporarySkills();
- }
- event OnCombatActionFriendlyEnd()
- {
- if ( IsCastingSign() )
- {
- SetBehaviorVariable( 'IsCastingSign', 0 );
- SetCurrentlyCastSign( ST_None, NULL );
- LogChannel( 'ST_None', "ST_None" );
- }
- super.OnCombatActionFriendlyEnd();
- }
- timer function OpenRadialMenu( time: float, id : int )
- {
- if( GetBIsCombatActionAllowed() && !IsUITakeInput() )
- {
- bShowRadialMenu = true;
- }
- this.RemoveTimer('OpenRadialMenu');
- }
- public function OnAddRadialMenuOpenTimer( )
- {
- this.AddTimer('OpenRadialMenu', _HoldBeforeOpenRadialMenuTime * theGame.GetTimeScale() );
- }
- public function SetShowRadialMenuOpenFlag( bSet : bool )
- {
- bShowRadialMenu = bSet;
- }
- public function OnRemoveRadialMenuOpenTimer()
- {
- this.RemoveTimer('OpenRadialMenu');
- }
- public function ResetRadialMenuOpenTimer()
- {
- this.RemoveTimer('OpenRadialMenu');
- if( GetBIsCombatActionAllowed() )
- {
- AddTimer('OpenRadialMenu', _HoldBeforeOpenRadialMenuTime * theGame.GetTimeScale() );
- }
- }
- timer function ResendCompanionDisplayName(dt : float, id : int)
- {
- var hud : CR4ScriptedHud;
- var companionModule : CR4HudModuleCompanion;
- hud = (CR4ScriptedHud)theGame.GetHud();
- if( hud )
- {
- companionModule = (CR4HudModuleCompanion)hud.GetHudModule("CompanionModule");
- if( companionModule )
- {
- companionModule.ResendDisplayName();
- }
- }
- }
- timer function ResendCompanionDisplayNameSecond(dt : float, id : int)
- {
- var hud : CR4ScriptedHud;
- var companionModule : CR4HudModuleCompanion;
- hud = (CR4ScriptedHud)theGame.GetHud();
- if( hud )
- {
- companionModule = (CR4HudModuleCompanion)hud.GetHudModule("CompanionModule");
- if( companionModule )
- {
- companionModule.ResendDisplayNameSecond();
- }
- }
- }
- public function RemoveCompanionDisplayNameTimer()
- {
- this.RemoveTimer('ResendCompanionDisplayName');
- }
- public function RemoveCompanionDisplayNameTimerSecond()
- {
- this.RemoveTimer('ResendCompanionDisplayNameSecond');
- }
- public function GetCompanionNPCTag() : name
- {
- return companionNPCTag;
- }
- public function SetCompanionNPCTag( value : name )
- {
- companionNPCTag = value;
- }
- public function GetCompanionNPCTag2() : name
- {
- return companionNPCTag2;
- }
- public function SetCompanionNPCTag2( value : name )
- {
- companionNPCTag2 = value;
- }
- public function GetCompanionNPCIconPath() : string
- {
- return companionNPCIconPath;
- }
- public function SetCompanionNPCIconPath( value : string )
- {
- companionNPCIconPath = value;
- }
- public function GetCompanionNPCIconPath2() : string
- {
- return companionNPCIconPath2;
- }
- public function SetCompanionNPCIconPath2( value : string )
- {
- companionNPCIconPath2 = value;
- }
- public function ReactToBeingHit(damageAction : W3DamageAction, optional buffNotApplied : bool) : bool
- {
- var chance : float;
- var procQuen : W3SignEntity;
- if(!damageAction.IsDoTDamage() && damageAction.DealsAnyDamage())
- {
- if(inv.IsItemBomb(selectedItemId))
- {
- BombThrowAbort();
- }
- else
- {
- ThrowingAbort();
- }
- }
- if(damageAction.IsActionRanged())
- {
- chance = CalculateAttributeValue(GetAttributeValue('quen_chance_on_projectile'));
- if(chance > 0)
- {
- chance = ClampF(chance, 0, 1);
- if(RandF() < chance)
- {
- procQuen = (W3SignEntity)theGame.CreateEntity(signs[ST_Quen].template, GetWorldPosition(), GetWorldRotation() );
- procQuen.Init(signOwner, signs[ST_Quen].entity, true );
- procQuen.OnStarted();
- procQuen.OnThrowing();
- procQuen.OnEnded();
- }
- }
- }
- if( !((W3Effect_Toxicity)damageAction.causer) )
- MeditationForceAbort(true);
- if(IsDoingSpecialAttack(false))
- damageAction.SetHitAnimationPlayType(EAHA_ForceNo);
- return super.ReactToBeingHit(damageAction, buffNotApplied);
- }
- protected function ShouldPauseHealthRegenOnHit() : bool
- {
- if(HasBuff(EET_Swallow) && GetPotionBuffLevel(EET_Swallow) >= 3)
- return false;
- return true;
- }
- public function SetMappinToHighlight( mappinName : name, mappinState : bool )
- {
- var mappinDef : SHighlightMappin;
- mappinDef.MappinName = mappinName;
- mappinDef.MappinState = mappinState;
- MappinToHighlight.PushBack(mappinDef);
- }
- public function ClearMappinToHighlight()
- {
- MappinToHighlight.Clear();
- }
- public function CastSignAbort()
- {
- if( currentlyCastSign != ST_None && signs[currentlyCastSign].entity)
- {
- signs[currentlyCastSign].entity.OnSignAborted();
- }
- }
- event OnBlockingSceneStarted( scene: CStoryScene )
- {
- //---=== modFriendlyMeditation ===---
- //var med : W3PlayerWitcherStateMeditationWaiting;
- //
- //
- //med = (W3PlayerWitcherStateMeditationWaiting)GetCurrentState();
- //if(med)
- //{
- // med.StopRequested(true);
- //}
- ModEndMeditation();
- //---=== modFriendlyMeditation ===---
- super.OnBlockingSceneStarted( scene );
- }
- public function GetHorseManager() : W3HorseManager
- {
- return (W3HorseManager)EntityHandleGet( horseManagerHandle );
- }
- public function HorseEquipItem(horsesItemId : SItemUniqueId) : bool
- {
- var man : W3HorseManager;
- man = GetHorseManager();
- if(man)
- return man.EquipItem(horsesItemId) != GetInvalidUniqueId();
- return false;
- }
- public function HorseUnequipItem(slot : EEquipmentSlots) : bool
- {
- var man : W3HorseManager;
- man = GetHorseManager();
- if(man)
- return man.UnequipItem(slot) != GetInvalidUniqueId();
- return false;
- }
- public final function HorseRemoveItemByName(itemName : name, quantity : int)
- {
- var man : W3HorseManager;
- man = GetHorseManager();
- if(man)
- man.HorseRemoveItemByName(itemName, quantity);
- }
- public final function HorseRemoveItemByCategory(itemCategory : name, quantity : int)
- {
- var man : W3HorseManager;
- man = GetHorseManager();
- if(man)
- man.HorseRemoveItemByCategory(itemCategory, quantity);
- }
- public final function HorseRemoveItemByTag(itemTag : name, quantity : int)
- {
- var man : W3HorseManager;
- man = GetHorseManager();
- if(man)
- man.HorseRemoveItemByTag(itemTag, quantity);
- }
- event OnPlayerHorseSpawned( horse : CActor )
- {
- var man : W3HorseManager;
- man = GetHorseManager();
- if(man)
- man.ApplyHorseUpdateOnSpawn();
- }
- public function GetAssociatedInventory() : CInventoryComponent
- {
- var man : W3HorseManager;
- man = GetHorseManager();
- if(man)
- return man.GetInventoryComponent();
- return NULL;
- }
- public final function TutorialMutagensUnequipPlayerSkills() : array<STutorialSavedSkill>
- {
- var pam : W3PlayerAbilityManager;
- pam = (W3PlayerAbilityManager)abilityManager;
- return pam.TutorialMutagensUnequipPlayerSkills();
- }
- public final function TutorialMutagensEquipOneGoodSkill()
- {
- var pam : W3PlayerAbilityManager;
- pam = (W3PlayerAbilityManager)abilityManager;
- pam.TutorialMutagensEquipOneGoodSkill();
- }
- public final function TutorialMutagensEquipOneGoodOneBadSkill()
- {
- var pam : W3PlayerAbilityManager;
- pam = (W3PlayerAbilityManager)abilityManager;
- if(pam)
- pam.TutorialMutagensEquipOneGoodOneBadSkill();
- }
- public final function TutorialMutagensEquipThreeGoodSkills()
- {
- var pam : W3PlayerAbilityManager;
- pam = (W3PlayerAbilityManager)abilityManager;
- if(pam)
- pam.TutorialMutagensEquipThreeGoodSkills();
- }
- public final function TutorialMutagensCleanupTempSkills(savedEquippedSkills : array<STutorialSavedSkill>)
- {
- var pam : W3PlayerAbilityManager;
- pam = (W3PlayerAbilityManager)abilityManager;
- return pam.TutorialMutagensCleanupTempSkills(savedEquippedSkills);
- }
- public function GetOffenseStatsList() : SPlayerOffenseStats
- {
- var playerOffenseStats:SPlayerOffenseStats;
- var steelDmg, silverDmg, elementalSteel, elementalSilver : float;
- var steelCritChance, steelCritDmg : float;
- var silverCritChance, silverCritDmg : float;
- var attackPower : SAbilityAttributeValue;
- var fastCritChance, fastCritDmg : float;
- var strongCritChance, strongCritDmg : float;
- var fastAP, strongAP : SAbilityAttributeValue;
- var item, crossbow : SItemUniqueId;
- var value : SAbilityAttributeValue;
- var mutagen : CBaseGameplayEffect;
- if(!abilityManager || !abilityManager.IsInitialized())
- return playerOffenseStats;
- if (CanUseSkill(S_Sword_s21))
- fastAP += GetSkillAttributeValue(S_Sword_s21, PowerStatEnumToName(CPS_AttackPower), false, true) * GetSkillLevel(S_Sword_s21);
- if (CanUseSkill(S_Perk_05))
- {
- fastAP += GetAttributeValue('attack_power_fast_style');
- fastCritDmg += CalculateAttributeValue(GetAttributeValue('critical_hit_chance_fast_style'));
- strongCritDmg += CalculateAttributeValue(GetAttributeValue('critical_hit_chance_fast_style'));
- }
- if (CanUseSkill(S_Sword_s04))
- strongAP += GetSkillAttributeValue(S_Sword_s04, PowerStatEnumToName(CPS_AttackPower), false, true) * GetSkillLevel(S_Sword_s04);
- if (CanUseSkill(S_Perk_07))
- strongAP += GetAttributeValue('attack_power_heavy_style');
- if (CanUseSkill(S_Sword_s17))
- {
- fastCritChance += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s17, theGame.params.CRITICAL_HIT_CHANCE, false, true)) * GetSkillLevel(S_Sword_s17);
- fastCritDmg += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s17, theGame.params.CRITICAL_HIT_DAMAGE_BONUS, false, true)) * GetSkillLevel(S_Sword_s17);
- }
- if (CanUseSkill(S_Sword_s08))
- {
- strongCritChance += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s08, theGame.params.CRITICAL_HIT_CHANCE, false, true)) * GetSkillLevel(S_Sword_s08);
- strongCritDmg += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s08, theGame.params.CRITICAL_HIT_DAMAGE_BONUS, false, true)) * GetSkillLevel(S_Sword_s08);
- }
- if ( HasBuff(EET_Mutagen05) && (GetStat(BCS_Vitality) == GetStatMax(BCS_Vitality)) )
- {
- attackPower += GetAttributeValue('damageIncrease');
- }
- steelCritChance += CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_CHANCE));
- silverCritChance += CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_CHANCE));
- steelCritDmg += CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
- silverCritDmg += CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
- attackPower += GetPowerStatValue(CPS_AttackPower);
- if (GetItemEquippedOnSlot(EES_SteelSword, item))
- {
- steelDmg = GetTotalWeaponDamage(item, theGame.params.DAMAGE_NAME_SLASHING, GetInvalidUniqueId());
- steelDmg += GetTotalWeaponDamage(item, theGame.params.DAMAGE_NAME_PIERCING, GetInvalidUniqueId());
- steelDmg += GetTotalWeaponDamage(item, theGame.params.DAMAGE_NAME_BLUDGEONING, GetInvalidUniqueId());
- elementalSteel = CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FIRE));
- elementalSteel += CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FROST));
- if ( GetInventory().IsItemHeld(item) )
- {
- steelCritChance -= CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
- silverCritChance -= CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
- steelCritDmg -= CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
- silverCritDmg -= CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
- }
- steelCritChance += CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
- steelCritDmg += CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
- }
- else
- {
- steelDmg += 0;
- steelCritChance += 0;
- steelCritDmg +=0;
- }
- if (GetItemEquippedOnSlot(EES_SilverSword, item))
- {
- silverDmg = GetTotalWeaponDamage(item, theGame.params.DAMAGE_NAME_SILVER, GetInvalidUniqueId());
- elementalSilver = CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FIRE));
- elementalSilver += CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FROST));
- if ( GetInventory().IsItemHeld(item) )
- {
- steelCritChance -= CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
- silverCritChance -= CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
- steelCritDmg -= CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
- silverCritDmg -= CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
- }
- silverCritChance += CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_CHANCE));
- silverCritDmg += CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.CRITICAL_HIT_DAMAGE_BONUS));
- }
- else
- {
- silverDmg += 0;
- silverCritChance += 0;
- silverCritDmg +=0;
- }
- fastAP += attackPower;
- strongAP += attackPower;
- playerOffenseStats.steelFastCritChance = (steelCritChance + fastCritChance) * 100;
- playerOffenseStats.steelFastCritDmg = steelCritDmg + fastCritDmg;
- if ( steelDmg != 0 )
- {
- playerOffenseStats.steelFastDmg = (steelDmg + fastAP.valueBase) * fastAP.valueMultiplicative + fastAP.valueAdditive + elementalSteel;
- playerOffenseStats.steelFastCritDmg = (steelDmg + fastAP.valueBase) * (fastAP.valueMultiplicative + playerOffenseStats.steelFastCritDmg) + fastAP.valueAdditive + elementalSteel;
- }
- else
- {
- playerOffenseStats.steelFastDmg = 0;
- playerOffenseStats.steelFastCritDmg = 0;
- }
- playerOffenseStats.steelFastDPS = (playerOffenseStats.steelFastDmg * (100 - playerOffenseStats.steelFastCritChance) + playerOffenseStats.steelFastCritDmg * playerOffenseStats.steelFastCritChance) / 100;
- playerOffenseStats.steelFastDPS = playerOffenseStats.steelFastDPS / 0.6;
- playerOffenseStats.steelStrongCritChance = (steelCritChance + strongCritChance) * 100;
- playerOffenseStats.steelStrongCritDmg = steelCritDmg + strongCritDmg;
- if ( steelDmg != 0 )
- {
- playerOffenseStats.steelStrongDmg = (steelDmg + strongAP.valueBase) * strongAP.valueMultiplicative + strongAP.valueAdditive + elementalSteel;
- playerOffenseStats.steelStrongDmg *= 1.833f;
- playerOffenseStats.steelStrongCritDmg = (steelDmg + strongAP.valueBase) * (strongAP.valueMultiplicative + playerOffenseStats.steelStrongCritDmg) + strongAP.valueAdditive + elementalSteel;
- playerOffenseStats.steelStrongCritDmg *= 1.833f; }
- else
- {
- playerOffenseStats.steelStrongDmg = 0;
- playerOffenseStats.steelStrongCritDmg = 0;
- }
- playerOffenseStats.steelStrongDPS = (playerOffenseStats.steelStrongDmg * (100 - playerOffenseStats.steelStrongCritChance) + playerOffenseStats.steelStrongCritDmg * playerOffenseStats.steelStrongCritChance) / 100;
- playerOffenseStats.steelStrongDPS = playerOffenseStats.steelStrongDPS / 1.1;
- playerOffenseStats.silverFastCritChance = (silverCritChance + fastCritChance) * 100;
- playerOffenseStats.silverFastCritDmg = silverCritDmg + fastCritDmg;
- if ( silverDmg != 0 )
- {
- playerOffenseStats.silverFastDmg = (silverDmg + fastAP.valueBase) * fastAP.valueMultiplicative + fastAP.valueAdditive + elementalSilver;
- playerOffenseStats.silverFastCritDmg = (silverDmg + fastAP.valueBase) * (fastAP.valueMultiplicative + playerOffenseStats.silverFastCritDmg) + fastAP.valueAdditive + elementalSilver;
- }
- else
- {
- playerOffenseStats.silverFastDmg = 0;
- playerOffenseStats.silverFastCritDmg = 0;
- }
- playerOffenseStats.silverFastDPS = (playerOffenseStats.silverFastDmg * (100 - playerOffenseStats.silverFastCritChance) + playerOffenseStats.silverFastCritDmg * playerOffenseStats.silverFastCritChance) / 100;
- playerOffenseStats.silverFastDPS = playerOffenseStats.silverFastDPS / 0.6;
- playerOffenseStats.silverStrongCritChance = (silverCritChance + strongCritChance) * 100;
- playerOffenseStats.silverStrongCritDmg = silverCritDmg + strongCritDmg;
- if ( silverDmg != 0 )
- {
- playerOffenseStats.silverStrongDmg = (silverDmg + strongAP.valueBase) * strongAP.valueMultiplicative + strongAP.valueAdditive + elementalSilver;
- playerOffenseStats.silverStrongDmg *= 1.833f;
- playerOffenseStats.silverStrongCritDmg = (silverDmg + strongAP.valueBase) * (strongAP.valueMultiplicative + playerOffenseStats.silverStrongCritDmg) + strongAP.valueAdditive + elementalSilver;
- playerOffenseStats.silverStrongCritDmg *= 1.833f;
- }
- else
- {
- playerOffenseStats.silverStrongDmg = 0;
- playerOffenseStats.silverStrongCritDmg = 0;
- }
- playerOffenseStats.silverStrongDPS = (playerOffenseStats.silverStrongDmg * (100 - playerOffenseStats.silverStrongCritChance) + playerOffenseStats.silverStrongCritDmg * playerOffenseStats.silverStrongCritChance) / 100;
- playerOffenseStats.silverStrongDPS = playerOffenseStats.silverStrongDPS / 1.1;
- playerOffenseStats.crossbowCritChance = CalculateAttributeValue(GetAttributeValue(theGame.params.CRITICAL_HIT_CHANCE));
- if (CanUseSkill(S_Sword_s07))
- playerOffenseStats.crossbowCritChance += CalculateAttributeValue(GetSkillAttributeValue(S_Sword_s07, theGame.params.CRITICAL_HIT_CHANCE, false, true)) * GetSkillLevel(S_Sword_s07);
- playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_PIERCING;
- if (GetItemEquippedOnSlot(EES_Bolt, item))
- {
- steelDmg = CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_FIRE));
- if(steelDmg > 0)
- {
- playerOffenseStats.crossbowSteelDmg = steelDmg;
- playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_FIRE;
- playerOffenseStats.crossbowSilverDmg = steelDmg;
- }
- else
- {
- playerOffenseStats.crossbowSilverDmg = CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_SILVER));
- steelDmg = CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_PIERCING));
- if(steelDmg > 0)
- {
- playerOffenseStats.crossbowSteelDmg = steelDmg;
- playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_PIERCING;
- }
- else
- {
- playerOffenseStats.crossbowSteelDmg = CalculateAttributeValue(thePlayer.GetInventory().GetItemAttributeValue(item, theGame.params.DAMAGE_NAME_BLUDGEONING));
- playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_BLUDGEONING;
- }
- }
- }
- if (GetItemEquippedOnSlot(EES_RangedWeapon, item))
- {
- attackPower += thePlayer.GetInventory().GetItemAttributeValue(item, PowerStatEnumToName(CPS_AttackPower));
- if(CanUseSkill(S_Perk_02))
- {
- attackPower += GetSkillAttributeValue(S_Perk_02, PowerStatEnumToName(CPS_AttackPower), false, true);
- }
- playerOffenseStats.crossbowSteelDmg = (playerOffenseStats.crossbowSteelDmg + attackPower.valueBase) * attackPower.valueMultiplicative + attackPower.valueAdditive;
- playerOffenseStats.crossbowSilverDmg = (playerOffenseStats.crossbowSilverDmg + attackPower.valueBase) * attackPower.valueMultiplicative + attackPower.valueAdditive;
- }
- else
- {
- playerOffenseStats.crossbowSteelDmg = 0;
- playerOffenseStats.crossbowSilverDmg = 0;
- playerOffenseStats.crossbowSteelDmgType = theGame.params.DAMAGE_NAME_PIERCING;
- }
- return playerOffenseStats;
- }
- public function GetTotalWeaponDamage(weaponId : SItemUniqueId, damageTypeName : name, crossbowId : SItemUniqueId) : float
- {
- var damage, durRatio, durMod : float;
- var repairObjectBonus : SAbilityAttributeValue;
- durMod = 0;
- damage = super.GetTotalWeaponDamage(weaponId, damageTypeName, crossbowId);
- if(IsPhysicalResistStat(GetResistForDamage(damageTypeName, false)))
- {
- repairObjectBonus = inv.GetItemAttributeValue(weaponId, theGame.params.REPAIR_OBJECT_BONUS);
- durRatio = -1;
- if(inv.IsIdValid(crossbowId) && inv.HasItemDurability(crossbowId))
- {
- durRatio = inv.GetItemDurabilityRatio(crossbowId);
- }
- else if(inv.IsIdValid(weaponId) && inv.HasItemDurability(weaponId))
- {
- durRatio = inv.GetItemDurabilityRatio(weaponId);
- }
- if(durRatio >= 0)
- durMod = theGame.params.GetDurabilityMultiplier(durRatio, true);
- else
- durMod = 1;
- }
- return damage * (durMod + repairObjectBonus.valueMultiplicative);
- }
- public final function GetSkillPathType(skill : ESkill) : ESkillPath
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillPathType(skill);
- return ESP_NotSet;
- }
- public function GetSkillLevel(s : ESkill) : int
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).GetSkillLevel(s);
- return -1;
- }
- public function GetAxiiLevel() : int
- {
- var level : int;
- level = 1;
- if(CanUseSkill(S_Magic_s17)) level += GetSkillLevel(S_Magic_s17);
- return Clamp(level, 1, 4);
- }
- public function IsInFrenzy() : bool
- {
- return isInFrenzy;
- }
- public function HasRecentlyCountered() : bool
- {
- return hasRecentlyCountered;
- }
- public function SetRecentlyCountered(counter : bool)
- {
- hasRecentlyCountered = counter;
- }
- timer function CheckBlockedSkills(dt : float, id : int)
- {
- var nextCallTime : float;
- nextCallTime = ((W3PlayerAbilityManager)abilityManager).CheckBlockedSkills(dt);
- if(nextCallTime != -1)
- AddTimer('CheckBlockedSkills', nextCallTime, , , , true);
- }
- public function RemoveTemporarySkills()
- {
- var i : int;
- var pam : W3PlayerAbilityManager;
- if(tempLearnedSignSkills.Size() > 0)
- {
- pam = (W3PlayerAbilityManager)abilityManager;
- for(i=0; i<tempLearnedSignSkills.Size(); i+=1)
- {
- pam.RemoveTemporarySkill(tempLearnedSignSkills[i]);
- }
- tempLearnedSignSkills.Clear();
- RemoveAbilityAll(SkillEnumToName(S_Sword_s19));
- }
- }
- public function RemoveTemporarySkill(skill : SSimpleSkill) : bool
- {
- var pam : W3PlayerAbilityManager;
- pam = (W3PlayerAbilityManager)abilityManager;
- if(pam && pam.IsInitialized())
- return pam.RemoveTemporarySkill(skill);
- return false;
- }
- private function AddTemporarySkills()
- {
- if(CanUseSkill(S_Sword_s19) && GetStat(BCS_Focus) >= 3)
- {
- tempLearnedSignSkills = ((W3PlayerAbilityManager)abilityManager).AddTempNonAlchemySkills();
- DrainFocus(GetStat(BCS_Focus));
- AddAbilityMultiple(SkillEnumToName(S_Sword_s19), GetSkillLevel(S_Sword_s19));
- }
- }
- public function HasAlternateQuen() : bool
- {
- var quenEntity : W3QuenEntity;
- quenEntity = (W3QuenEntity)GetCurrentSignEntity();
- if(quenEntity)
- {
- return quenEntity.IsAlternateCast();
- }
- return false;
- }
- public function AddPoints(type : ESpendablePointType, amount : int, show : bool)
- {
- levelManager.AddPoints(type, amount, show);
- }
- public function GetLevel() : int {return levelManager.GetLevel();}
- public function GetTotalExpForNextLevel() : int {return levelManager.GetTotalExpForNextLevel();}
- public function GetPointsTotal(type : ESpendablePointType) : int {return levelManager.GetPointsTotal(type);}
- public function IsAutoLeveling() : bool {return autoLevel;}
- public function SetAutoLeveling( b : bool ) {autoLevel = b;}
- public function GetMissingExpForNextLevel() : int
- {
- return Max(0, GetTotalExpForNextLevel() - GetPointsTotal(EExperiencePoint));
- }
- public saved var savedQuenHealth, savedQuenDuration : float;
- timer function MonitorQuenSaveStatus(dt : float, id : int)
- {
- var quenEntity : W3QuenEntity;
- quenEntity = (W3QuenEntity)signs[ST_Quen].entity;
- savedQuenHealth = quenEntity.GetShieldHealth();
- savedQuenDuration = quenEntity.GetShieldRemainingDuration();
- }
- timer function DelayedRestoreQuen(dt : float, id : int)
- {
- RestoreQuen(savedQuenHealth, savedQuenDuration);
- }
- public final function OnBasicQuenFinishing()
- {
- RemoveTimer('MonitorQuenSaveStatus');
- savedQuenHealth = 0.f;
- savedQuenDuration = 0.f;
- }
- public final function IsAnyQuenActive() : bool
- {
- var quen : W3QuenEntity;
- quen = (W3QuenEntity)GetSignEntity(ST_Quen);
- if(quen)
- return quen.IsAnyQuenActive();
- return false;
- }
- public final function IsQuenActive(alternateMode : bool) : bool
- {
- if(IsAnyQuenActive() && GetSignEntity(ST_Quen).IsAlternateCast() == alternateMode)
- return true;
- return false;
- }
- public function FinishQuen(skipVisuals : bool)
- {
- var quen : W3QuenEntity;
- quen = (W3QuenEntity)GetSignEntity(ST_Quen);
- if(quen)
- quen.ForceFinishQuen(skipVisuals);
- }
- public function GetTotalSignSpellPower(signSkill : ESkill) : SAbilityAttributeValue
- {
- var sp : SAbilityAttributeValue;
- var penalty : SAbilityAttributeValue;
- var penaltyReduction : float;
- var penaltyReductionLevel : int;
- sp = GetSkillAttributeValue(signSkill, PowerStatEnumToName(CPS_SpellPower), true, true);
- if ( signSkill == S_Magic_s01 )
- {
- penaltyReductionLevel = GetSkillLevel(S_Magic_s01) + 1;
- if(penaltyReductionLevel > 0)
- {
- penaltyReduction = 1 - penaltyReductionLevel * CalculateAttributeValue(GetSkillAttributeValue(S_Magic_s01, 'spell_power_penalty_reduction', true, true));
- penalty = GetSkillAttributeValue(S_Magic_s01, PowerStatEnumToName(CPS_SpellPower), false, false);
- sp += penalty * penaltyReduction;
- }
- }
- if(signSkill == S_Magic_1 || signSkill == S_Magic_s01)
- {
- sp += GetAttributeValue('spell_power_aard');
- }
- else if(signSkill == S_Magic_2 || signSkill == S_Magic_s02)
- {
- sp += GetAttributeValue('spell_power_igni');
- }
- else if(signSkill == S_Magic_3 || signSkill == S_Magic_s03)
- {
- sp += GetAttributeValue('spell_power_yrden');
- }
- else if(signSkill == S_Magic_4 || signSkill == S_Magic_s04)
- {
- sp += GetAttributeValue('spell_power_quen');
- }
- else if(signSkill == S_Magic_5 || signSkill == S_Magic_s05)
- {
- sp += GetAttributeValue('spell_power_axii');
- }
- return sp;
- }
- public final function GetGwentCardIndex( cardName : name ) : int
- {
- var dm : CDefinitionsManagerAccessor;
- dm = theGame.GetDefinitionsManager();
- if(dm.ItemHasTag( cardName , 'GwintCardLeader' ))
- {
- return theGame.GetGwintManager().GwentLeadersNametoInt( cardName );
- }
- else if(dm.ItemHasTag( cardName , 'GwintCardNrkd' ))
- {
- return theGame.GetGwintManager().GwentNrkdNameToInt( cardName );
- }
- else if(dm.ItemHasTag( cardName , 'GwintCardNlfg' ))
- {
- return theGame.GetGwintManager().GwentNlfgNameToInt( cardName );
- }
- else if(dm.ItemHasTag( cardName , 'GwintCardSctl' ))
- {
- return theGame.GetGwintManager().GwentSctlNameToInt( cardName );
- }
- else if(dm.ItemHasTag( cardName , 'GwintCardMstr' ))
- {
- return theGame.GetGwintManager().GwentMstrNameToInt( cardName );
- }
- else if(dm.ItemHasTag( cardName , 'GwintCardNeutral' ))
- {
- return theGame.GetGwintManager().GwentNeutralNameToInt( cardName );
- }
- else if(dm.ItemHasTag( cardName , 'GwintCardSpcl' ))
- {
- return theGame.GetGwintManager().GwentSpecialNameToInt( cardName );
- }
- return -1;
- }
- public final function AddGwentCard(cardName : name, amount : int) : bool
- {
- var dm : CDefinitionsManagerAccessor;
- var cardIndex, i : int;
- var tut : STutorialMessage;
- if(FactsQuerySum("q001_nightmare_ended") > 0 && ShouldProcessTutorial('TutorialGwentDeckBuilder2'))
- {
- tut.type = ETMT_Hint;
- tut.tutorialScriptTag = 'TutorialGwentDeckBuilder2';
- tut.journalEntryName = 'TutorialGwentDeckBuilder2';
- tut.hintPositionType = ETHPT_DefaultGlobal;
- tut.markAsSeenOnShow = true;
- tut.hintDurationType = ETHDT_Long;
- theGame.GetTutorialSystem().DisplayTutorial(tut);
- }
- dm = theGame.GetDefinitionsManager();
- cardIndex = GetGwentCardIndex(cardName);
- if (cardIndex != -1)
- {
- FactsAdd("Gwint_Card_Looted");
- for(i = 0; i < amount; i += 1)
- {
- theGame.GetGwintManager().AddCardToCollection( cardIndex );
- }
- }
- if( dm.ItemHasTag( cardName, 'GwentTournament' ) )
- {
- if ( dm.ItemHasTag( cardName, 'GT1' ) )
- {
- FactsAdd( "GwentTournament", 1 );
- }
- else if ( dm.ItemHasTag( cardName, 'GT2' ) )
- {
- FactsAdd( "GwentTournament", 2 );
- }
- else if ( dm.ItemHasTag( cardName, 'GT3' ) )
- {
- FactsAdd( "GwentTournament", 3 );
- }
- else if ( dm.ItemHasTag( cardName, 'GT4' ) )
- {
- FactsAdd( "GwentTournament", 4 );
- }
- else if ( dm.ItemHasTag( cardName, 'GT5' ) )
- {
- FactsAdd( "GwentTournament", 5 );
- }
- else if ( dm.ItemHasTag( cardName, 'GT6' ) )
- {
- FactsAdd( "GwentTournament", 6 );
- }
- else if ( dm.ItemHasTag( cardName, 'GT7' ) )
- {
- FactsAdd( "GwentTournament", 7 );
- }
- CheckGwentTournamentDeck();
- }
- else
- {
- return false;
- }
- return true;
- }
- public final function RemoveGwentCard(cardName : name, amount : int) : bool
- {
- var dm : CDefinitionsManagerAccessor;
- var cardIndex, i : int;
- dm = theGame.GetDefinitionsManager();
- if(dm.ItemHasTag( cardName , 'GwintCardLeader' ))
- {
- cardIndex = theGame.GetGwintManager().GwentLeadersNametoInt( cardName );
- for(i=0; i<amount; i+=1)
- theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
- }
- else if(dm.ItemHasTag( cardName , 'GwintCardNrkd' ))
- {
- cardIndex = theGame.GetGwintManager().GwentNrkdNameToInt( cardName );
- for(i=0; i<amount; i+=1)
- theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
- }
- else if(dm.ItemHasTag( cardName , 'GwintCardNlfg' ))
- {
- cardIndex = theGame.GetGwintManager().GwentNlfgNameToInt( cardName );
- for(i=0; i<amount; i+=1)
- theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
- }
- else if(dm.ItemHasTag( cardName , 'GwintCardSctl' ))
- {
- cardIndex = theGame.GetGwintManager().GwentSctlNameToInt( cardName );
- for(i=0; i<amount; i+=1)
- theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
- }
- else if(dm.ItemHasTag( cardName , 'GwintCardMstr' ))
- {
- cardIndex = theGame.GetGwintManager().GwentMstrNameToInt( cardName );
- for(i=0; i<amount; i+=1)
- theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
- }
- else if(dm.ItemHasTag( cardName , 'GwintCardNeutral' ))
- {
- cardIndex = theGame.GetGwintManager().GwentNeutralNameToInt( cardName );
- for(i=0; i<amount; i+=1)
- theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
- }
- else if(dm.ItemHasTag( cardName , 'GwintCardSpcl' ))
- {
- cardIndex = theGame.GetGwintManager().GwentSpecialNameToInt( cardName );
- for(i=0; i<amount; i+=1)
- theGame.GetGwintManager().RemoveCardFromCollection( cardIndex );
- }
- if( dm.ItemHasTag( cardName, 'GwentTournament' ) )
- {
- if ( dm.ItemHasTag( cardName, 'GT1' ) )
- {
- FactsSubstract( "GwentTournament", 1 );
- }
- else if ( dm.ItemHasTag( cardName, 'GT2' ) )
- {
- FactsSubstract( "GwentTournament", 2 );
- }
- else if ( dm.ItemHasTag( cardName, 'GT3' ) )
- {
- FactsSubstract( "GwentTournament", 3 );
- }
- else if ( dm.ItemHasTag( cardName, 'GT4' ) )
- {
- FactsSubstract( "GwentTournament", 4 );
- }
- else if ( dm.ItemHasTag( cardName, 'GT5' ) )
- {
- FactsSubstract( "GwentTournament", 5 );
- }
- else if ( dm.ItemHasTag( cardName, 'GT6' ) )
- {
- FactsSubstract( "GwentTournament", 6 );
- }
- else if ( dm.ItemHasTag( cardName, 'GT7' ) )
- {
- FactsSubstract( "GwentTournament", 7 );
- }
- CheckGwentTournamentDeck();
- }
- else
- {
- return false;
- }
- return true;
- }
- function CheckGwentTournamentDeck()
- {
- var gwentPower : int;
- var neededGwentPower : int;
- var checkBreakpoint : int;
- neededGwentPower = 70;
- checkBreakpoint = neededGwentPower/5;
- gwentPower = FactsQuerySum( "GwentTournament" );
- if ( gwentPower >= neededGwentPower )
- {
- FactsAdd( "HasGwentTournamentDeck", 1 );
- }
- else
- {
- if( FactsDoesExist( "HasGwentTournamentDeck" ) )
- {
- FactsRemove( "HasGwentTournamentDeck" );
- }
- if ( gwentPower >= checkBreakpoint )
- {
- FactsAdd( "GwentTournamentObjective1", 1 );
- }
- else if ( FactsDoesExist( "GwentTournamentObjective1" ) )
- {
- FactsRemove( "GwentTournamentObjective1" );
- }
- if ( gwentPower >= checkBreakpoint*2 )
- {
- FactsAdd( "GwentTournamentObjective2", 1 );
- }
- else if ( FactsDoesExist( "GwentTournamentObjective2" ) )
- {
- FactsRemove( "GwentTournamentObjective2" );
- }
- if ( gwentPower >= checkBreakpoint*3 )
- {
- FactsAdd( "GwentTournamentObjective3", 1 );
- }
- else if ( FactsDoesExist( "GwentTournamentObjective3" ) )
- {
- FactsRemove( "GwentTournamentObjective3" );
- }
- if ( gwentPower >= checkBreakpoint*4 )
- {
- FactsAdd( "GwentTournamentObjective4", 1 );
- }
- else if ( FactsDoesExist( "GwentTournamentObjective4" ) )
- {
- FactsRemove( "GwentTournamentObjective4" );
- }
- }
- }
- //---=== modFriendlyMeditation ===---
- public function IsMeditating() : bool
- {
- return ( GetCurrentStateName() == 'Meditation' );
- }
- public function IsSkippingTime() : bool
- {
- return ( GetCurrentStateName() == 'MeditationWaiting' );
- }
- public function UpdateEffectsAccelerated( realTimeSecs, acceleration : float )
- {
- effectManager.PerformUpdate( realTimeSecs * acceleration );
- }
- //---=== modFriendlyMeditation ===---
- public function SimulateBuffTimePassing(simulatedTime : float)
- {
- super.SimulateBuffTimePassing(simulatedTime);
- FinishQuen(true);
- }
- public function CanMeditate() : bool
- {
- var currentStateName : name;
- currentStateName = GetCurrentStateName();
- if(currentStateName == 'Exploration' && !CanPerformPlayerAction())
- return false;
- if(GetCurrentStateName() != 'Exploration' && GetCurrentStateName() != 'Meditation' && GetCurrentStateName() != 'MeditationWaiting')
- return false;
- if(GetUsedVehicle())
- return false;
- return CanMeditateHere();
- }
- public final function CanMeditateWait(optional skipMeditationStateCheck : bool) : bool
- {
- var currState : name;
- currState = GetCurrentStateName();
- if(!skipMeditationStateCheck && currState != 'Meditation')
- return false;
- if(theGame.IsGameTimePaused())
- return false;
- if(!thePlayer.IsActionAllowed( EIAB_MeditationWaiting ))
- return false;
- return true;
- }
- public final function CanMeditateHere() : bool
- {
- var pos : Vector;
- pos = GetWorldPosition();
- if(pos.Z <= theGame.GetWorld().GetWaterLevel(pos, true) && IsInShallowWater())
- return false;
- if(IsThreatened())
- return false;
- return true;
- }
- public function Meditate()
- {
- //---=== modFriendlyMeditation ===---
- var stateName : name;
- stateName = GetCurrentStateName();
- //var medState : W3PlayerWitcherStateMeditation;
- //var stateName : name;
- //
- //stateName = GetCurrentStateName();
- //
- //
- //if (!CanMeditate() || stateName == 'MeditationWaiting' )
- // return false;
- //
- //GotoState('Meditation');
- //medState = (W3PlayerWitcherStateMeditation)GetState('Meditation');
- //medState.SetMeditationPointHeading(GetHeading());
- //
- //return true;
- if (!CanMeditate() || stateName == 'MeditationWaiting' )
- if (!CanMeditate() || GetCurrentStateName() == 'Meditation' || GetCurrentStateName() == 'MeditationWaiting')
- if ( !ModCanMeditate() )
- return;
- theGame.RequestMenuWithBackground( 'MeditationClockMenu', 'CommonMenu' );
- //---=== modFriendlyMeditation ===---
- }
- public final function MeditationRestoring(simulatedTime : float)
- {
- if ( theGame.GetDifficultyMode() != EDM_Hard && theGame.GetDifficultyMode() != EDM_Hardcore )
- {
- Heal(GetStatMax(BCS_Vitality));
- }
- abilityManager.DrainToxicity( abilityManager.GetStat( BCS_Toxicity ) );
- abilityManager.DrainFocus( abilityManager.GetStat( BCS_Focus ) );
- inv.SingletonItemsRefillAmmo();
- SimulateBuffTimePassing(simulatedTime);
- }
- var clockMenu : CR4MeditationClockMenu;
- public function MeditationClockStart(m : CR4MeditationClockMenu)
- {
- clockMenu = m;
- AddTimer('UpdateClockTime',0.1,true);
- }
- public function MeditationClockStop()
- {
- clockMenu = NULL;
- RemoveTimer('UpdateClockTime');
- }
- public timer function UpdateClockTime(dt : float, id : int)
- {
- if(clockMenu)
- clockMenu.UpdateCurrentHours();
- else
- RemoveTimer('UpdateClockTime');
- }
- private var waitTimeHour : int;
- public function SetWaitTargetHour(t : int)
- {
- waitTimeHour = t;
- }
- public function GetWaitTargetHour() : int
- {
- return waitTimeHour;
- }
- public function MeditationForceAbort(forceCloseUI : bool)
- {
- //---=== modFriendlyMeditation ===---
- //var waitt : W3PlayerWitcherStateMeditationWaiting;
- //var medd : W3PlayerWitcherStateMeditation;
- //var currentStateName : name;
- //
- //currentStateName = GetCurrentStateName();
- //
- //if(currentStateName == 'MeditationWaiting')
- //{
- // waitt = (W3PlayerWitcherStateMeditationWaiting)GetCurrentState();
- // if(waitt)
- // {
- // waitt.StopRequested(forceCloseUI);
- // }
- //}
- //else if(currentStateName == 'Meditation')
- //{
- // medd = (W3PlayerWitcherStateMeditation)GetCurrentState();
- // if(medd)
- // {
- // medd.StopRequested(forceCloseUI);
- // }
- //}
- ModEndMeditation();
- //---=== modFriendlyMeditation ===---
- if(forceCloseUI && theGame.GetGuiManager().IsAnyMenu())
- {
- theGame.GetGuiManager().GetRootMenu().CloseMenu();
- DisplayActionDisallowedHudMessage(EIAB_MeditationWaiting, false, false, true, false);
- }
- }
- //---=== modFriendlyMeditation ===---
- public function ModCanMeditate(optional isPlayerMeditatingInBed : bool) : bool
- {
- if( isPlayerMeditatingInBed )
- return true;
- //checking everything for Preparations compatibility
- if( !CanMeditate() )
- return false;
- if( !CanMeditateWait(true) )
- return false;
- if( !CanMeditateHere() )
- return false;
- if( !ModCanMeditateHereExt() )
- return false;
- return true;
- }
- public function ModCanMeditateHereExt() : bool
- {
- if( ((CMovingPhysicalAgentComponent)GetMovingAgentComponent()).GetSubmergeDepth() < 0 )
- return false;
- return true;
- }
- public function ModStartMeditation(optional isPlayerMeditatingInBed : bool, optional isFromClock : bool, optional endTime : float) : bool
- {
- if( !ModCanMeditate(isPlayerMeditatingInBed) )
- return false;
- if( theGame.GetGuiManager().IsAnyMenu() )
- theGame.GetGuiManager().GetRootMenu().CloseMenu();
- if( !IsMeditating() && !IsSkippingTime() )
- {
- medIsPlayerMeditatingInBed = isPlayerMeditatingInBed;
- medIsFromClock = isFromClock;
- medEndTime = endTime;
- SetBehaviorVariable('MeditateAbort', 0);
- PushState('Meditation');
- return true;
- }
- else
- {
- if( IsSkippingTime() )
- {
- MeditationEndFastforward();
- }
- if( IsMeditating() )
- {
- medIsPlayerMeditatingInBed = isPlayerMeditatingInBed;
- medIsFromClock = isFromClock;
- medEndTime = endTime;
- SetBehaviorVariable('MeditateAbort', 0);
- if( isFromClock )
- ((W3PlayerWitcherStateMeditation)GetState( 'Meditation' )).StartFastforward();
- return true;
- }
- }
- return false;
- }
- public function ModEndMeditation()
- {
- if( IsMeditating() || IsSkippingTime() )
- {
- SetBehaviorVariable('MeditateAbort', 1);
- PopState();
- medIsPlayerMeditatingInBed = false;
- medIsFromClock = false;
- medEndTime = -1;
- if( theGame.GetGuiManager().IsAnyMenu() )
- theGame.GetGuiManager().GetRootMenu().CloseMenu();
- }
- }
- private var medIsPlayerMeditatingInBed : bool;
- default medIsPlayerMeditatingInBed = false;
- public function GetIsPlayerMeditatingInBed() : bool
- {
- return medIsPlayerMeditatingInBed;
- }
- private var medEndTime : float;
- default medEndTime = -1;
- public function GetMeditationTargetTime() : float
- {
- return medEndTime;
- }
- private var medIsFromClock : bool;
- default medIsFromClock = false;
- public function GetMeditationStartedByClock() : bool
- {
- return medIsFromClock;
- }
- public function MeditationRefill( gameTimeSecs : float ) : bool
- {
- if ( fmedAutorefillAlchemy && gameTimeSecs >= fmedRefillIntervalSeconds )
- {
- inv.SingletonItemsRefillAmmo();
- return true;
- }
- return false;
- }
- public function CheckWitcherHouseBuffs( gameTimeSecs : float ) : bool
- {
- if ( fmedApplyWitcherHouseBuffs && GetIsPlayerMeditatingInBed() && CeilF(gameTimeSecs/3600.0) >= fmedWitcherHouseBuffsHours )
- {
- ApplyWitcherHouseBuffs();
- return true;
- }
- return false;
- }
- timer function DeSpawnCampFireTimer(dt : float, id : int)
- {
- spawnedCampFire.ToggleFire( false );
- spawnedCampFire.Destroy();
- spawnedCampFire = NULL;
- }
- public function MeditationStartFastforward()
- {
- if( IsMeditating() )
- {
- medIsFromClock = false;
- ((W3PlayerWitcherStateMeditation)GetState( 'Meditation' )).StartFastforward();
- }
- }
- public function MeditationEndFastforward()
- {
- if( IsSkippingTime() )
- {
- ((W3PlayerWitcherStateMeditation)GetState( 'Meditation' )).EndFastforward();
- medIsFromClock = false;
- }
- }
- //---=== modFriendlyMeditation ===---
- public function CheatResurrect()
- {
- super.CheatResurrect();
- theGame.ReleaseNoSaveLock(theGame.deathSaveLockId);
- theInput.RestoreContext( 'Exploration', true );
- }
- public function Debug_EquipTestingSkills(equip : bool)
- {
- ((W3PlayerAbilityManager)abilityManager).OnLevelGained(36);
- if(equip)
- {
- if(GetSkillLevel(S_Magic_s01) == 0) AddSkill(S_Magic_s01);
- if(GetSkillLevel(S_Magic_s02) == 0) AddSkill(S_Magic_s02);
- if(GetSkillLevel(S_Magic_s03) == 0) AddSkill(S_Magic_s03);
- if(GetSkillLevel(S_Magic_s04) == 0) AddSkill(S_Magic_s04);
- if(GetSkillLevel(S_Magic_s05) == 0) AddSkill(S_Magic_s05);
- if(GetSkillLevel(S_Sword_s01) == 0) AddSkill(S_Sword_s01);
- if(GetSkillLevel(S_Sword_s02) == 0) AddSkill(S_Sword_s02);
- EquipSkill(S_Magic_s01, GetFreeSkillSlot());
- EquipSkill(S_Magic_s02, GetFreeSkillSlot());
- EquipSkill(S_Magic_s03, GetFreeSkillSlot());
- EquipSkill(S_Magic_s04, GetFreeSkillSlot());
- EquipSkill(S_Magic_s05, GetFreeSkillSlot());
- EquipSkill(S_Sword_s01, GetFreeSkillSlot());
- EquipSkill(S_Sword_s02, GetFreeSkillSlot());
- }
- else
- {
- UnequipSkill(GetSkillSlotID(S_Magic_s01));
- UnequipSkill(GetSkillSlotID(S_Magic_s02));
- UnequipSkill(GetSkillSlotID(S_Magic_s03));
- UnequipSkill(GetSkillSlotID(S_Magic_s04));
- UnequipSkill(GetSkillSlotID(S_Magic_s05));
- UnequipSkill(GetSkillSlotID(S_Sword_s01));
- UnequipSkill(GetSkillSlotID(S_Sword_s02));
- }
- }
- public function Debug_ClearCharacterDevelopment()
- {
- var template : CEntityTemplate;
- var entity : CEntity;
- var invTesting : CInventoryComponent;
- var i : int;
- var items : array<SItemUniqueId>;
- var abs : array<name>;
- delete abilityManager;
- delete levelManager;
- delete effectManager;
- abs = GetAbilities(false);
- for(i=0; i<abs.Size(); i+=1)
- RemoveAbility(abs[i]);
- abs.Clear();
- GetCharacterStatsParam(abs);
- for(i=0; i<abs.Size(); i+=1)
- AddAbility(abs[i]);
- levelManager = new W3LevelManager in this;
- levelManager.Initialize();
- levelManager.PostInit(this, false);
- AddAbility('GeraltSkills_Testing');
- SetAbilityManager();
- abilityManager.Init(this, GetCharacterStats(), false, theGame.GetDifficultyMode());
- SetEffectManager();
- abilityManager.PostInit();
- inv.RemoveAllItems();
- template = (CEntityTemplate)LoadResource("geralt_inventory_release");
- entity = theGame.CreateEntity(template, Vector(0,0,0));
- invTesting = (CInventoryComponent)entity.GetComponentByClassName('CInventoryComponent');
- invTesting.GiveAllItemsTo(inv, true);
- entity.Destroy();
- inv.GetAllItems(items);
- for(i=0; i<items.Size(); i+=1)
- {
- if(!inv.ItemHasTag(items[i], 'NoDrop'))
- GetWitcherPlayer().EquipItem(items[i]);
- }
- Debug_GiveTestingItems(0);
- }
- final function Debug_UnlockSkillSlot(slotIndex : int) : bool
- {
- if(abilityManager && abilityManager.IsInitialized())
- return ((W3PlayerAbilityManager)abilityManager).Debug_UnlockSkillSlot(slotIndex);
- return false;
- }
- public function GetLevelupAbility( id : int) : name
- {
- return levelupAbilities[ id ];
- }
- public function CanSprint( speed : float ) : bool
- {
- if( !super.CanSprint( speed ) )
- {
- return false;
- }
- if( rangedWeapon && rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' )
- {
- if ( this.GetPlayerCombatStance() == PCS_AlertNear )
- {
- if ( IsSprintActionPressed() )
- OnRangedForceHolster( true, false );
- }
- else
- return false;
- }
- if( thePlayer.GetCurrentStateName() != 'Swimming' && thePlayer.GetStat(BCS_Stamina) <= 0 )
- {
- thePlayer.SetSprintActionPressed(false,true);
- return false;
- }
- return true;
- }
- public function RestoreHorseManager() : bool
- {
- var horseTemplate : CEntityTemplate;
- var horseManager : W3HorseManager;
- if ( GetHorseManager() )
- {
- return false;
- }
- horseTemplate = (CEntityTemplate)LoadResource("horse_manager");
- horseManager = (W3HorseManager)theGame.CreateEntity(horseTemplate, GetWorldPosition(),,,,,PM_Persist);
- horseManager.CreateAttachment(this);
- horseManager.OnCreated();
- EntityHandleSet( horseManagerHandle, horseManager );
- return true;
- }
- public final function IsSignBlocked(signType : ESignType) : bool
- {
- switch( signType )
- {
- case ST_Aard :
- return IsRadialSlotBlocked ( 'Aard');
- break;
- case ST_Axii :
- return IsRadialSlotBlocked ( 'Axii');
- break;
- case ST_Igni :
- return IsRadialSlotBlocked ( 'Igni');
- break;
- case ST_Quen :
- return IsRadialSlotBlocked ( 'Quen');
- break;
- case ST_Yrden :
- return IsRadialSlotBlocked ( 'Yrden');
- break;
- default:
- break;
- }
- return false;
- }
- }
- function GetWitcherPlayer() : W3PlayerWitcher
- {
- return (W3PlayerWitcher)thePlayer;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement