Deleted46552037User Posted July 27, 2017 Share Posted July 27, 2017 (edited) I fixed some issues that had a unexpected "}" however I am left with these. Please help Error [mod0000_mergedfiles]game\gameplay\containers\container.ws(800): syntax error, unexpected TOKEN_IF, expecting TOKEN_FUNCTION, near 'if'Error [mod0000_mergedfiles]game\gameplay\items\swords\witchersword.ws(138): syntax error, unexpected TOKEN_IF, expecting TOKEN_FUNCTION, near 'if'Error [mod0000_mergedfiles]game\gui\hud\hud.ws(347): syntax error, unexpected TOKEN_IDENT, expecting TOKEN_FUNCTION, near 'currentlyVisibleHud'Error [mod0000_mergedfiles]game\player\playerinput.ws(614): syntax error, unexpected TOKEN_VAR, expecting TOKEN_FUNCTION, near 'var' Each .ws file below is in the same order as above /* /** Witcher Script file - Container controll class /***********************************************************************/ /** Copyright © 2012 CDProjektRed /** Author : Malgorzata Napiontek /** Bartosz Bigaj /** Tomasz Kozera import class W3Container extends W3LockableEntity //@FIXME Bidon - apply loot window mechanics { editable var isDynamic : bool; //set to true if container is dynamically created (e.g. loot bag) //obsolete parameter --- > should be always false //if false then once container is emptied you cannot use it anymore editable var skipInventoryPanel : bool; //if true then no inventory panel will be shown upon looting (forces auto loot) editable var focusModeHighlight : EFocusModeVisibility; editable var factOnContainerOpened : string; var usedByCiri : bool; editable var allowToInjectBalanceItems : bool; default allowToInjectBalanceItems = false; editable var disableLooting : bool; editable var disableStealing : bool; default disableStealing = true; protected saved var checkedForBonusMoney : bool; //set when container was tested for dropping bonus money private saved var usedByClueStash : EntityHandle; private var disableFocusHighlightControl : bool; //Disables highlight control from container, setting from gameplay entity will always be applied protected optional autobind inv : CInventoryComponent = single; protected optional autobind lootInteractionComponent : CInteractionComponent = "Loot"; protected var isPlayingInteractionAnim : bool; default isPlayingInteractionAnim = false; private const var QUEST_HIGHLIGHT_FX : name; //fx marking that container has a quest item hint skipInventoryPanel = "If set then the inventory panel will not be shown upon looting"; hint isDynamic = "set to true if you want to destroy container when empty"; hint focusModeHighlight = "FMV_Interactive: White, FMV_Clue: Red"; default skipInventoryPanel = false; default usedByCiri = false; default focusModeHighlight = FMV_Interactive; default QUEST_HIGHLIGHT_FX = 'quest_highlight_fx'; default disableLooting = false; import function SetIsQuestContainer( isQuest : bool ); private const var SKIP_NO_DROP_NO_SHOW : bool; default SKIP_NO_DROP_NO_SHOW = true; event OnSpawned( spawnData : SEntitySpawnData ) { EnableVisualDebug( SHOW_Containers, true ); super.OnSpawned(spawnData); //container cannot ever be looted - treat as decoration if(disableLooting) { SetFocusModeVisibility( FMV_None ); StopQuestItemFx(); if( lootInteractionComponent ) { lootInteractionComponent.SetEnabled(false); } CheckLock(); } else { UpdateContainer(); } } event OnStreamIn() { super.OnStreamIn(); UpdateContainer(); } event OnSpawnedEditor( spawnData : SEntitySpawnData ) { EnableVisualDebug( SHOW_Containers, true ); super.OnSpawned( spawnData ); } event OnVisualDebug( frame : CScriptedRenderFrame, flag : EShowFlags ) { frame.DrawText( GetName(), GetWorldPosition() + Vector( 0, 0, 1.0f ), Color( 255, 0, 255 ) ); frame.DrawSphere( GetWorldPosition(), 1.0f, Color( 255, 0, 255 ) ); return true; } function UpdateFactItems() { var i,j : int; var items : array<SItemUniqueId>; var tags : array<name>; var factName : string; //check for fact hidden items (not visible unless fact exists) if( inv && !disableLooting) { inv.GetAllItems( items ); } for(i=0; i<items.Size(); i+=1) { tags.Clear(); inv.GetItemTags(items[i], tags); // inv exists here, cause if it wouldn't, we would iterate over empty array for(j=0; j<tags.Size(); j+=1) { factName = StrAfterLast(NameToString(tags[j]), "fact_hidden_"); if(StrLen(factName) > 0) { if(FactsQuerySum(factName) > 0) { inv.RemoveItemTag(items[i], theGame.params.TAG_DONT_SHOW); } else { inv.AddItemTag(items[i], theGame.params.TAG_DONT_SHOW); } break; } } } } function InjectItemsOnLevels() { /*var playerLevel : int = thePlayer.GetLevel() - 1; var itemName : name = thePlayer.itemsPerLevel[playerLevel]; if ( !inv.HasItem( itemName ) && !thePlayer.inv.HasItem( itemName ) && !thePlayer.itemsPerLevelGiven[playerLevel] && !( playerLevel > thePlayer.itemsPerLevel.Size() ) && allowToInjectBalanceItems ) { thePlayer.SetItemsPerLevelGiven(playerLevel); inv.AddAnItem( itemName, 1, true, true ); }*/ // Called when entity gets within interaction range event OnInteractionActivated( interactionComponentName : string, activator : CEntity ) { UpdateContainer(); RebalanceItems(); RemoveUnwantedItems(); DisableIfEmpty(); // was destroyed inside DisableIfEmpty() super.OnInteractionActivated(interactionComponentName, activator); if(activator == thePlayer) { if ( inv && !disableLooting) { inv.UpdateLoot(); if(!checkedForBonusMoney) { checkedForBonusMoney = true; CheckForBonusMoney(0); } } if(!disableLooting && (!thePlayer.IsInCombat() || IsEnabledInCombat()) ) HighlightEntity(); if ( interactionComponentName == "Medallion" && isMagicalObject ) SenseMagic(); if( (!IsEmpty() && !disableLooting) || lockedByKey) //if empty and not reusable but locked then we still need to process it { ShowInteractionComponent(); } } } // Called when entity leaves interaction range event OnInteractionDeactivated( interactionComponentName : string, activator : CEntity ) { super.OnInteractionDeactivated(interactionComponentName, activator); if(activator == thePlayer) { UnhighlightEntity(); } } // Returns true if container can be used during combat public final function IsEnabledInCombat() : bool { if( !lootInteractionComponent || disableLooting) { return false; } return lootInteractionComponent.IsEnabledInCombat(); } public function InformClueStash() { var clueStash : W3ClueStash; clueStash = ( W3ClueStash )EntityHandleGet( usedByClueStash ); if( clueStash ) { clueStash.OnContainerEvent(); } } event OnItemGiven(data : SItemChangedData) { super.OnItemGiven(data); if(isEnabled) UpdateContainer(); InformClueStash(); } function ReadSchematicsAndRecipes() { } event OnItemTaken(itemId : SItemUniqueId, quantity : int) { super.OnItemTaken(itemId, quantity); if(!HasQuestItem()) { StopQuestItemFx(); } InformClueStash(); } event OnUpdateContainer() { } protected final function UpdateContainer() { var medalion : CComponent; var foliageComponent : CSwitchableFoliageComponent; var itemCategory : name; foliageComponent = ( CSwitchableFoliageComponent ) GetComponentByClassName( 'CSwitchableFoliageComponent' ); if(!disableLooting) UpdateFactItems(); if( inv && !disableLooting) { inv.UpdateLoot(); } // container is always visible (full) when game is not active if ( !theGame.IsActive() || ( inv && !disableLooting && isEnabled && !inv.IsEmpty( SKIP_NO_DROP_NO_SHOW ) ) ) { SetFocusModeVisibility( focusModeHighlight ); AddTag('HighlightedByMedalionFX'); if ( foliageComponent ) foliageComponent.SetAndSaveEntry( 'full' ); else ApplyAppearance("1_full"); if( HasQuestItem() ) { SetIsQuestContainer( true ); PlayQuestItemFx(); } } else { SetFocusModeVisibility( FMV_None ); // even for disabled but non-empty container we still want to use "full" appearance if ( foliageComponent && !disableLooting) foliageComponent.SetAndSaveEntry( 'empty' ); else ApplyAppearance("2_empty"); StopQuestItemFx(); } if ( !isMagicalObject ) // @FIXME Bidon - move to better place { medalion = GetComponent("Medallion"); if(medalion) { medalion.SetEnabled( false ); } } if(lootInteractionComponent) { if(disableLooting) { lootInteractionComponent.SetEnabled(false); } else { lootInteractionComponent.SetEnabled( inv && !inv.IsEmpty( SKIP_NO_DROP_NO_SHOW ) ) ; //Only enable "Loot" when there is content inside. } } if(!disableLooting) OnUpdateContainer(); CheckForDimeritium(); CheckLock(); } function RebalanceItems() { var i : int; var items : array<SItemUniqueId>; if( inv && !disableLooting) { inv.AutoBalanaceItemsWithPlayerLevel(); inv.GetAllItems( items ); } for(i=0; i<items.Size(); i+=1) { // Adding abilities to masterwork / magical items if ( inv.GetItemModifierInt(items[i], 'ItemQualityModified') > 0 ) continue; inv.AddRandomEnhancementToItem(items[i]); } } protected final function HighlightEntity() { isHighlightedByMedallion = true; } protected final function UnhighlightEntity() { StopEffect('medalion_detection_fx'); StopEffect('medalion_fx'); isHighlightedByMedallion = false; } public final function HasQuestItem() : bool { if( !inv || disableLooting) { return false; } return inv.HasQuestItem(); } public function CheckForDimeritium() { if (inv && !disableLooting) { if ( inv.HasItemByTag('Dimeritium')) { if (!this.HasTag('Potestaquisitor')) this.AddTag('Potestaquisitor'); } else { if (this.HasTag('Potestaquisitor')) this.RemoveTag('Potestaquisitor'); } } else { if (this.HasTag('Potestaquisitor')) this.RemoveTag('Potestaquisitor'); } } // #B when returns false item is not transfered, so for example if we want container that gives only one item (or one item type) it should be checked in this function public final function OnTryToGiveItem( itemId : SItemUniqueId ) : bool { return true; } //Transfers all items from container to player's inventory public function TakeAllItems() { var targetInv : CInventoryComponent; var allItems : array< SItemUniqueId >; var ciriEntity : W3ReplacerCiri; var i : int; var itemsCategories : array< name >; var category : name; // Transfer items targetInv = thePlayer.inv; if( !inv || !targetInv ) { return; } inv.GetAllItems( allItems ); LogChannel( 'ITEMS___', ">>>>>>>>>>>>>> TakeAllItems " + allItems.Size() ); for(i=0; i<allItems.Size(); i+=1) { if( inv.ItemHasTag(allItems[i], 'Lootable' ) || !inv.ItemHasTag(allItems[i], 'NoDrop') && !inv.ItemHasTag(allItems[i], theGame.params.TAG_DONT_SHOW)) { inv.NotifyItemLooted( allItems[ i ] ); if( inv.ItemHasTag(allItems[i], 'HerbGameplay') ) { category = 'herb'; } else { category = inv.GetItemCategory(allItems[i]); } if( itemsCategories.FindFirst( category ) == -1 ) { itemsCategories.PushBack( category ); } inv.GiveItemTo(targetInv, allItems[i], inv.GetItemQuantity(allItems[i]), true, false, true ); } } if( itemsCategories.Size() == 1 ) { PlayItemEquipSound(itemsCategories[0]); } else { PlayItemEquipSound('generic'); } LogChannel( 'ITEMS___', "<<<<<<<<<<<<<< TakeAllItems"); InformClueStash(); } // save state of this container // Called when some interaction occurs with this container event OnInteraction( actionName : string, activator : CEntity ) { var processed : bool; var i,j : int; var m_schematicList, m_recipeList : array< name >; var itemCategory : name; var attr : SAbilityAttributeValue; if ( activator != thePlayer || isInteractionBlocked || IsEmpty() ) return false; if ( activator == (W3ReplacerCiri)thePlayer ) { skipInventoryPanel = true; usedByCiri = true; } if ( StrLen( factOnContainerOpened ) > 0 && !FactsDoesExist ( factOnContainerOpened ) && ( actionName == "Container" || actionName == "Unlock" ) ) { FactsAdd ( factOnContainerOpened, 1, -1 ); } //don't add recipes that you already have and items with to high level m_recipeList = GetWitcherPlayer().GetAlchemyRecipes(); m_schematicList = GetWitcherPlayer().GetCraftingSchematicsNames(); // Process New Game+ Witcher sets schematics if ( FactsQuerySum("NewGamePlus") > 0 ) { AddWolfNewGamePlusSchematics(); KeepWolfWitcherSetSchematics(m_schematicList); } //spoon collector randomly makes us find spoons InjectItemsOnLevels(); processed = super.OnInteraction(actionName, activator); if(processed) return true; //handled by super if(actionName != "Container" && actionName != "GatherHerbs") return false; ProcessLoot (); return true; } function RemoveUnwantedItems() { var allItems : array< SItemUniqueId >; var i,j : int; var m_schematicList, m_recipeList : array< name >; var itemName : name; if ( !HasTag('lootbag') ) { m_recipeList = GetWitcherPlayer().GetAlchemyRecipes(); m_schematicList = GetWitcherPlayer().GetCraftingSchematicsNames(); inv.GetAllItems( allItems ); for ( i=0; i<allItems.Size(); i+=1 ) { itemName = inv.GetItemName( allItems[i] ); // recipes for( j = 0; j < m_recipeList.Size(); j+= 1 ) { if ( itemName == m_recipeList[j] ) { inv.RemoveItem( allItems[i], inv.GetItemQuantity( allItems[i] ) ); inv.NotifyItemLooted( allItems[i] ); //inv.AddAnItem( 'Crowns', RoundF(RandRangeF(4, 2)), true, true); } } // schematics for( j = 0; j < m_schematicList.Size(); j+= 1 ) { if ( itemName == m_schematicList[j] ) { inv.RemoveItem( allItems[i], inv.GetItemQuantity( allItems[i] ) ); inv.NotifyItemLooted( allItems[i] ); //inv.AddAnItem( 'Crowns', RoundF(RandRangeF(4, 2)), true, true); } } if ( GetWitcherPlayer().GetLevel() - 1 > 1 && inv.GetItemLevel( allItems[i] ) == 1 && inv.ItemHasTag(allItems[i], 'Autogen') ) { // failsafe - when item is spawned in container and there is no player level yet - reset item and regenerate inv.RemoveItemCraftedAbility(allItems[i], 'autogen_steel_base'); inv.RemoveItemCraftedAbility(allItems[i], 'autogen_silver_base'); inv.RemoveItemCraftedAbility(allItems[i], 'autogen_armor_base'); inv.RemoveItemCraftedAbility(allItems[i], 'autogen_pants_base'); inv.RemoveItemCraftedAbility(allItems[i], 'autogen_gloves_base'); inv.GenerateItemLevel(allItems[i]); } // too many the same gwint cards collected already if ( inv.GetItemCategory(allItems[i]) == 'gwint' ) { inv.ClearGwintCards(); } if ( ( thePlayer.GetLevel() < 10 ) && ( GetInventory().GetItemLevel( allItems[i] ) > thePlayer.GetLevel() + 5 ) ) { inv.RemoveItem( allItems[i], inv.GetItemQuantity( allItems[i] ) ); inv.NotifyItemLooted( allItems[i] ); } } } } function ProcessLoot() { if(disableLooting) return; if(skipInventoryPanel || usedByCiri) { TakeAllItems(); OnContainerClosed(); } else { ShowLoot(); } } private function KeepWolfWitcherSetSchematics(out m_schematicList : array< name >) { var index : int; // Wolf index = m_schematicList.FindFirst('Wolf Armor schematic'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Witcher Wolf Jacket Upgrade schematic 1'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Witcher Wolf Jacket Upgrade schematic 2'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Witcher Wolf Jacket Upgrade schematic 3'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Wolf Gloves schematic'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Witcher Wolf Gloves Upgrade schematic 1'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Witcher Wolf Gloves Upgrade schematic 2'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Witcher Wolf Gloves Upgrade schematic 3'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Wolf Pants schematic'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Witcher Wolf Pants Upgrade schematic 1'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Witcher Wolf Pants Upgrade schematic 2'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Witcher Wolf Pants Upgrade schematic 3'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Wolf Boots schematic'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Witcher Wolf Boots Upgrade schematic 1'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Witcher Wolf Boots Upgrade schematic 2'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Witcher Wolf Boots Upgrade schematic 3'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Wolf School steel sword schematic'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Wolf School steel sword Upgrade schematic 1'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Wolf School steel sword Upgrade schematic 2'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Wolf School steel sword Upgrade schematic 3'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Wolf School silver sword schematic'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Wolf School silver sword Upgrade schematic 1'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Wolf School silver sword Upgrade schematic 2'); if ( index > -1 ) m_schematicList.Erase( index ); index = m_schematicList.FindFirst('Wolf School silver sword Upgrade schematic 3'); if ( index > -1 ) m_schematicList.Erase( index ); } private function AddWolfNewGamePlusSchematics() { var allItems : array< SItemUniqueId >; var i : int; var itemName : name; inv.GetAllItems( allItems ); for ( i=0; i<allItems.Size(); i+=1 ) { itemName = inv.GetItemName( allItems[i] ); // Wolf Armors if ( itemName == 'Wolf Armor schematic' && !inv.HasItem('NGP Wolf Armor schematic') ) inv.AddAnItem( 'NGP Wolf Armor schematic', 1, true, true); if ( itemName == 'Witcher Wolf Jacket Upgrade schematic 1' && !inv.HasItem('NGP Witcher Wolf Jacket Upgrade schematic 1') ) inv.AddAnItem( 'NGP Witcher Wolf Jacket Upgrade schematic 1', 1, true, true); if ( itemName == 'Witcher Wolf Jacket Upgrade schematic 2' && !inv.HasItem('NGP Witcher Wolf Jacket Upgrade schematic 2') ) inv.AddAnItem( 'NGP Witcher Wolf Jacket Upgrade schematic 2', 1, true, true); if ( itemName == 'Witcher Wolf Jacket Upgrade schematic 3' && !inv.HasItem('NGP Witcher Wolf Jacket Upgrade schematic 3') ) inv.AddAnItem( 'NGP Witcher Wolf Jacket Upgrade schematic 3', 1, true, true); if ( itemName == 'Wolf Gloves schematic' && !inv.HasItem('NGP Wolf Gloves schematic') ) inv.AddAnItem( 'NGP Wolf Gloves schematic', 1, true, true); if ( itemName == 'Witcher Wolf Gloves Upgrade schematic 1' && !inv.HasItem('NGP Witcher Wolf Gloves Upgrade schematic 1') ) inv.AddAnItem( 'NGP Witcher Wolf Gloves Upgrade schematic 1', 1, true, true); if ( itemName == 'Witcher Wolf Gloves Upgrade schematic 2' && !inv.HasItem('NGP Witcher Wolf Gloves Upgrade schematic 2') ) inv.AddAnItem( 'NGP Witcher Wolf Gloves Upgrade schematic 2', 1, true, true); if ( itemName == 'Witcher Wolf Gloves Upgrade schematic 3' && !inv.HasItem('NGP Witcher Wolf Gloves Upgrade schematic 3') ) inv.AddAnItem( 'NGP Witcher Wolf Gloves Upgrade schematic 3', 1, true, true); if ( itemName == 'Wolf Pants schematic' && !inv.HasItem('NGP Wolf Pants schematic') ) inv.AddAnItem( 'NGP Wolf Pants schematic', 1, true, true); if ( itemName == 'Witcher Wolf Pants Upgrade schematic 1' && !inv.HasItem('NGP Witcher Wolf Pants Upgrade schematic 1') ) inv.AddAnItem( 'NGP Witcher Wolf Pants Upgrade schematic 1', 1, true, true); if ( itemName == 'Witcher Wolf Pants Upgrade schematic 2' && !inv.HasItem('NGP Witcher Wolf Pants Upgrade schematic 2') ) inv.AddAnItem( 'NGP Witcher Wolf Pants Upgrade schematic 2', 1, true, true); if ( itemName == 'Witcher Wolf Pants Upgrade schematic 3' && !inv.HasItem('NGP Witcher Wolf Pants Upgrade schematic 3') ) inv.AddAnItem( 'NGP Witcher Wolf Pants Upgrade schematic 3', 1, true, true); if ( itemName == 'Wolf Boots schematic' && !inv.HasItem('NGP Wolf Boots schematic') ) inv.AddAnItem( 'NGP Wolf Boots schematic', 1, true, true); if ( itemName == 'Witcher Wolf Boots Upgrade schematic 1' && !inv.HasItem('NGP Witcher Wolf Boots Upgrade schematic 1') ) inv.AddAnItem( 'NGP Witcher Wolf Boots Upgrade schematic 1', 1, true, true); if ( itemName == 'Witcher Wolf Boots Upgrade schematic 2' && !inv.HasItem('NGP Witcher Wolf Boots Upgrade schematic 2') ) inv.AddAnItem( 'NGP Witcher Wolf Boots Upgrade schematic 2', 1, true, true); if ( itemName == 'Witcher Wolf Boots Upgrade schematic 3' && !inv.HasItem('NGP Witcher Wolf Boots Upgrade schematic 3') ) inv.AddAnItem( 'NGP Witcher Wolf Boots Upgrade schematic 3', 1, true, true); if ( itemName == 'Wolf School steel sword schematic' && !inv.HasItem('NGP Wolf School steel sword schematic') ) inv.AddAnItem( 'NGP Wolf School steel sword schematic', 1, true, true); if ( itemName == 'Wolf School steel sword Upgrade schematic 1' && !inv.HasItem('NGP Wolf School steel sword Upgrade schematic 1') ) inv.AddAnItem( 'NGP Wolf School steel sword Upgrade schematic 1', 1, true, true); if ( itemName == 'Wolf School steel sword Upgrade schematic 2' && !inv.HasItem('NGP Wolf School steel sword Upgrade schematic 2') ) inv.AddAnItem( 'NGP Wolf School steel sword Upgrade schematic 2', 1, true, true); if ( itemName == 'Wolf School steel sword Upgrade schematic 3' && !inv.HasItem('NGP Wolf School steel sword Upgrade schematic 3') ) inv.AddAnItem( 'NGP Wolf School steel sword Upgrade schematic 3', 1, true, true); if ( itemName == 'Wolf School silver sword schematic' && !inv.HasItem('NGP Wolf School silver sword schematic') ) inv.AddAnItem( 'NGP Wolf School silver sword schematic', 1, true, true); if ( itemName == 'Wolf School silver sword Upgrade schematic 1' && !inv.HasItem('NGP Wolf School silver sword Upgrade schematic 1') ) inv.AddAnItem( 'NGP Wolf School silver sword Upgrade schematic 1', 1, true, true); if ( itemName == 'Wolf School silver sword Upgrade schematic 2' && !inv.HasItem('NGP Wolf School silver sword Upgrade schematic 2') ) inv.AddAnItem( 'NGP Wolf School silver sword Upgrade schematic 2', 1, true, true); if ( itemName == 'Wolf School silver sword Upgrade schematic 3' && !inv.HasItem('NGP Wolf School silver sword Upgrade schematic 3') ) inv.AddAnItem( 'NGP Wolf School silver sword Upgrade schematic 3', 1, true, true); //spoon collector's trophy randomly grants bonus junk spoons //var itemNames : array< name >; 4debug //already made a test for this container //if player doesn't have trophy //don't add if container has quest items //if randomization chancefailed //don't add if it's a container with items dropped by player //don't add if animal remains //container needs to have proper loot e.g. don't add spoons to herbs or baskets with apples //4 debug /* for( i=0; i<items.Size(); i+=1 ) { itemNames.PushBack( inv.GetItemName( items[i] ) ); }*/ //10% to get 2 spoons instead of one } } event OnStateChange( newState : bool ) { if( lootInteractionComponent ) { lootInteractionComponent.SetEnabled( newState ); } super.OnStateChange( newState ); } // AutoLoot added public function AutoLootCleanup() : void { if( (W3treasureHuntContainer)this ) ((W3treasureHuntContainer)this).OnContainerClosed(); this.OnContainerClosed(); this.InformClueStash(); this.DisableIfEmpty(); this.UpdateContainer(); } // Function showing the loot panel public final function ShowLoot() { var lootData : W3LootPopupData; // AutoLoot hook // If there are items left to loot if(AL_LootContainer(this)) { lootData = new W3LootPopupData in this; lootData.targetContainer = this; theGame.RequestPopup('LootPopup', lootData); } /*var hud : CR4ScriptedHud; var lootPopupModule : CR4HudModuleLootPopup; hud = (CR4ScriptedHud)theGame.GetHud(); if( hud ) { lootPopupModule = (CR4HudModuleLootPopup)hud.GetHudModule("LootPopupModule"); lootPopupModule.Open( this ); }*/ } public function IsEmpty() : bool { return !inv || inv.IsEmpty( SKIP_NO_DROP_NO_SHOW ); } public function Enable(e : bool, optional skipInteractionUpdate : bool, optional questForcedEnable : bool) { if( !(e && questForcedEnable) ) { //don't enable if container is empty and is not reusable if(e && IsEmpty() ) { return; } else { UpdateContainer(); } } super.Enable(e, skipInteractionUpdate); } // Called when the container is closed public function OnContainerClosed() { if(!HasQuestItem()) StopQuestItemFx(); DisableIfEmpty(); } // returns true if container was destroyed if(IsEmpty()) { SetFocusModeVisibility( FMV_None ); RemoveTag('HighlightedByMedalionFX'); //disable highlights UnhighlightEntity(); //disable container Enable(false); //change model if empty ApplyAppearance("2_empty"); if(isDynamic) { Destroy(); return; } } //adds additional money based on player bonuses protected final function CheckForBonusMoney(oldMoney : int) { var money, bonusMoney : int; if( !inv ) { return; } money = inv.GetMoney() - oldMoney; if(money <= 0) { return; } bonusMoney = RoundMath(money * CalculateAttributeValue(thePlayer.GetAttributeValue('bonus_money'))); if(bonusMoney > 0) { inv.AddMoney(bonusMoney); } } public final function PlayQuestItemFx() { PlayEffectSingle(QUEST_HIGHLIGHT_FX); } public final function StopQuestItemFx() { StopEffect(QUEST_HIGHLIGHT_FX); } public function GetSkipInventoryPanel():bool { return skipInventoryPanel; } public function CanShowFocusInteractionIcon() : bool { return inv && !disableLooting && isEnabled && !inv.IsEmpty( SKIP_NO_DROP_NO_SHOW ); } public function RegisterClueStash( clueStash : W3ClueStash ) { EntityHandleSet( usedByClueStash, clueStash ); } /* Copyright © CD Projekt RED 2015 */ import class CWitcherSword extends CItemEntity { editable var padBacklightColor : Vector; var oilLevel : int; var runeCount : int; hint padBacklightColor = "PS4 backlight color. R,G,B [0-1]"; import public function GetSwordType() : EWitcherSwordType; // modSEC -- Begin public function GetRuneEffectSilver() : int { return StringToInt( theGame.GetInGameConfigWrapper().GetVarValue('SwordEffects', 'SEC_RESilver') ); } public function GetRuneEffectSteel() : int { return StringToInt( theGame.GetInGameConfigWrapper().GetVarValue('SwordEffects', 'SEC_RESteel') ); } public function DisableOilEffectSilver() : bool { return theGame.GetInGameConfigWrapper().GetVarValue('SwordEffects', 'SEC_OESilver'); } public function DisableOilEffectSteel() : bool { return theGame.GetInGameConfigWrapper().GetVarValue('SwordEffects', 'SEC_OESteel'); } public function GetSECRuneLevelSilver() : int { return StringToInt( theGame.GetInGameConfigWrapper().GetVarValue('SwordEffects', 'SEC_RLSilver') ); } public function GetSECRuneLevelSteel() : int { return StringToInt( theGame.GetInGameConfigWrapper().GetVarValue('SwordEffects', 'SEC_RLSteel') ); } public function GetRuneColorSilver() : int { return StringToInt( theGame.GetInGameConfigWrapper().GetVarValue('SwordEffects', 'SEC_RCSilver') ); } public function GetRuneColorSteel() : int { return StringToInt( theGame.GetInGameConfigWrapper().GetVarValue('SwordEffects', 'SEC_RCSteel') ); } // modSEC -- End public function Initialize( actor : CActor ) { var inv : CInventoryComponent; var swordCategory : name; var myItemId : SItemUniqueId; var stateName : name; var swordType : EWitcherSwordType; var abilities : array<name>; inv = (CInventoryComponent)( actor.GetComponentByClassName( 'CInventoryComponent' ) ); var runeEffect : int; // modSEC swordType = GetSwordType(); switch ( swordType ) { case WST_Silver: swordCategory = 'silversword'; break; case WST_Steel: swordCategory = 'steelsword'; break; } myItemId = inv.GetItemByItemEntity( this ); inv.GetItemAbilitiesWithTag( myItemId, theGame.params.OIL_ABILITY_TAG, abilities ); ApplyOil( abilities ); runeCount = inv.GetItemEnhancementCount( myItemId ); UpdateEnhancements( runeCount ); stateName = actor.GetCurrentStateName(); // modSEC -- Begin if ( swordType == WST_Silver ) runeEffect = GetRuneEffectSilver(); else if ( swordType == WST_Steel ) runeEffect = GetRuneEffectSteel(); { switch ( runeEffect ) { case 0: case 1: { PlayEffect('rune_blast_loop'); break; } case 2: { StopEffect( 'rune_blast_loop' ); break; } } } else { switch ( runeEffect ) { case 0: { PlayEffect('rune_blast_long'); break; } case 1: { PlayEffect( 'rune_blast_loop' ); break; } case 2: { StopEffect( 'rune_blast_loop' ); break; } } } // modSEC -- End } var runeEffect : int; // modSEC // modSEC -- Begin if ( GetSwordType() == WST_Silver ) runeEffect = GetRuneEffectSilver(); else if ( GetSwordType() == WST_Steel ) runeEffect = GetRuneEffectSteel(); switch ( runeEffect ) { case 0: case 1: { PlayEffect( 'rune_blast_loop' ); break; } case 2: { StopEffect( 'rune_blast_loop' ); break; } } // modSEC -- End event OnGrab() { super.OnGrab(); Initialize( (CActor)GetParentEntity() ); GetWitcherPlayer().ResetPadBacklightColor(); } event OnPut() { super.OnPut(); StopAllEffects(); GetWitcherPlayer().ResetPadBacklightColor(true); } public function ApplyOil( oilAbilities : array<name> ) { // modSEC -- Begin var oilEffect : bool; if ( GetSwordType() == WST_Silver ) oilEffect = DisableOilEffectSilver(); else if ( GetSwordType() == WST_Steel ) oilEffect = DisableOilEffectSteel(); if ( oilEffect ) StopEffect( GetOilFxName( oilAbilityName ) ); else PlayEffect( GetOilFxName( oilAbilityName ) ); // modSEC -- End dm = theGame.GetDefinitionsManager(); dm.GetAbilitiesAttributeValue(oilAbilities, 'level', min, max); oilLevel = (int) CalculateAttributeValue(min); oilFx = GetOilFxName(); PlayEffect(oilFx); } public function RemoveOil() { var oilFx : name; oilFx = GetOilFxName(); StopEffect(oilFx); oilLevel = 0; } public function GetOilFxName() : name { var oilFx : name; // modSEC -- Begin var color : int; if ( GetSwordType() == WST_Silver ) color = GetRuneColorSilver(); if ( GetSwordType() == WST_Steel ) color = GetRuneColorSteel(); if ( color == 0 ) { switch ( runeName ) { case 'Rune stribog lesser': case 'Rune stribog': case 'Rune stribog greater': { runeFx = 'rune_stribog'; break; } case 'Rune dazhbog lesser': case 'Rune dazhbog': case 'Rune dazhbog greater': { runeFx = 'rune_dazhbog'; break; } case 'Rune devana lesser': case 'Rune devana': case 'Rune devana greater': { runeFx = 'rune_devana'; break; } case 'Rune zoria lesser': case 'Rune zoria': case 'Rune zoria greater': { runeFx = 'rune_zoria'; break; } case 'Rune morana lesser': case 'Rune morana': case 'Rune morana greater': { runeFx = 'rune_morana'; break; } case 'Rune triglav lesser': case 'Rune triglav': case 'Rune triglav greater': { runeFx = 'rune_triglav'; break; } case 'Rune svarog lesser': case 'Rune svarog': case 'Rune svarog greater': { runeFx = 'rune_svarog'; break; } case 'Rune veles lesser': case 'Rune veles': case 'Rune veles greater': { runeFx = 'rune_veles'; break; } case 'Rune perun lesser': case 'Rune perun': case 'Rune perun greater': { runeFx = 'rune_perun'; oilFx = 'oil_lvl0'; break; } case 'Rune elemental lesser': case 'Rune elemental': case 'Rune elemental greater': { runeFx = 'rune_elemental'; break; } case 'Rune pierog lesser': case 'Rune pierog': case 'Rune pierog greater': { runeFx = 'rune_pierog'; break; } case 'Rune tvarog lesser': case 'Rune tvarog': case 'Rune tvarog greater': { runeFx = 'rune_tvarog'; break; } } } else { switch ( color ) { // red case 1: { runeFx = 'rune_devana'; break; } // blue case 2: { runeFx = 'rune_triglav'; break; } // light blue case 3: { runeFx = 'rune_zoria'; break; } // green case 4: { runeFx = 'rune_morana'; break; } // cyan case 5: { runeFx = 'rune_veles'; break; } // orange or yellow case 6: { runeFx = 'rune_dazhbog'; break; } // pink 1 case 7: { runeFx = 'rune_stribog'; break; } // pink 2 case 8: { runeFx = 'rune_perun'; break; } // pink 3 case 9: { runeFx = 'rune_elemental'; break; } } } // modSEC -- End } public function GetRuneFxName() : name { var runeFx : name; // modSEC -- Begin if ( GetSECRuneLevelSilver() > 0 && GetSwordType() == WST_Silver ) count = GetSECRuneLevelSilver(); else if ( GetSECRuneLevelSteel() > 0 && GetSwordType() == WST_Steel ) count = GetSECRuneLevelSteel(); // modSEC -- End { case 0: runeFx = 'rune_lvl0'; break; case 1: runeFx = 'rune_lvl1'; break; case 2: runeFx = 'rune_lvl2'; break; case 3: runeFx = 'rune_lvl3'; break; } } return runeFx; } public function UpdateEnhancements( newRuneCount : int ) { var fx : name; // modSEC -- Begin var player : W3PlayerWitcher; player = GetWitcherPlayer(); // modSEC -- End fx = GetRuneFxName(); StopEffect( fx ); runeCount = newRuneCount; fx = GetRuneFxName(); PlayEffect( fx ); // modSEC -- Begin else if ( GetSECRuneLevelSilver() > 0 && GetSwordType() == WST_Silver && player.IsItemEquipped(itemId) ) { PlayEffect( GetRuneLevel( GetSECRuneLevelSilver() ) ); // Rune here doesn't matter, just need the function to run and pull the color from menu setting PlayEffect( GetRuneFxName( 'Rune stribog' ) ); } else if ( GetSECRuneLevelSteel() > 0 && GetSwordType() == WST_Steel && player.IsItemEquipped(itemId) ) { PlayEffect( GetRuneLevel( GetSECRuneLevelSteel() ) ); // Rune here doesn't matter, just need the function to run and pull the color from menu setting PlayEffect( GetRuneFxName( 'Rune stribog' ) ); } // modSEC -- End } /* Copyright © CD Projekt RED 2015 */ import class CR4Hud extends CHud { //import final function GetActorHeadIconScreenPosition( actor : CActor, allowOffScreen : bool, screenPos : Vector ) : bool; import final function ShowOneliner( text : string, entity : CEntity ); import final function HideOneliner( entity : CEntity ); } class CR4ScriptedHud extends CR4Hud { private var m_hudSize : int; default m_hudSize = 0; private var m_minimapRotationEnabled : bool; default m_minimapRotationEnabled = true; private var m_minimapZoom : float; default m_minimapZoom = 0.55; /* WMK */ private var m_enabledEnemyFocus : bool; default m_enabledEnemyFocus = true; private var m_enabledNPCNames : bool; default m_enabledNPCNames = true; private var m_enemyHitEffects : bool; default m_enemyHitEffects = true; private var m_dlcMessagePending : bool; default m_dlcMessagePending = false; private var m_HudFlashSFS : CScriptedFlashSprite; private var m_fxShowModulesSFF : CScriptedFlashFunction; private var m_fxPrintInfoSFF : CScriptedFlashFunction; private var m_fxSetInputContextSFF : CScriptedFlashFunction; private var m_fxSetIsDynamicSFF : CScriptedFlashFunction; private var m_fxSetControllerType : CScriptedFlashFunction; private var m_fxSwapAcceptCancel : CScriptedFlashFunction; protected var m_fxSetGamepadType : CScriptedFlashFunction; protected var m_fxLockControlScheme : CScriptedFlashFunction; private var hudModules : array<CR4HudModuleBase>; public var hudModulesNames : array<name>; public var currentInputContext : name; public var previousInputContext : name; private var m_isDynamic : bool; default m_isDynamic = true; private var m_guiManager : CR4GuiManager; private var m_deathTimerActive : bool; default m_deathTimerActive = false; private var m_deathTimer : float; private var m_scaleformWidth : int; default m_scaleformWidth = 1920; private var m_scaleformHeight : int; default m_scaleformHeight = 1080; private var m_scaleformOffsetX : int; default m_scaleformOffsetX = 0; private var m_scaleformOffsetY : int; default m_scaleformOffsetY = 0; event OnTick( timeDelta : float ) { ///////////////////////////////////////////////////////////////////////////// // // !!! HACK !!! // ClearCachedPositionForEntity(); // // !!! END OF HACK !!! // ///////////////////////////////////////////////////////////////////////////// UpdateLootPopupContext(); if( currentInputContext != theInput.GetContext() ) { previousInputContext = currentInputContext; currentInputContext = theInput.GetContext(); // #Y OMG! We can't switch context during RadialMenu, it's very not intuitive and may cause a lot of bugs if( IsRadialMenuOpened() && currentInputContext != 'RadialMenu' && !IsRadialMenuOverwritenByContext(currentInputContext) ) { theInput.RestoreContext( 'RadialMenu', true ); theInput.StoreContext( 'RadialMenu' ); currentInputContext = 'RadialMenu'; LogChannel('HUD_TICK',"INPUT CONTEXT CHANGED !!! if( IsRadialMenuOpened() !!! "+currentInputContext+" previousInputContext "+previousInputContext); } else { m_fxSetInputContextSFF.InvokeSelfOneArg(FlashArgString(currentInputContext)); } // I will just leave this line commented for future generations, it's too precious to be deleted and forgotten // | // | // V //if( previousInputContext != 'RadialMenu' && !( currentInputContext == 'Exploration' && previousInputContext == 'JumpClimb' || currentInputContext == 'Exploration' && previousInputContext == 'JumpClimb' ) ) { GetHudEventController().RunEvent_ControlsFeedbackModule_Update( currentInputContext ); } OnInputContextChanged(); //LogChannel('HUD_TICK',""); LogChannel('HUD_TICK',"INPUT CONTEXT CHANGED "+currentInputContext+" previousInputContext "+previousInputContext); LogChannel('HUD_TICK',""); } UpdateDLCPendingMessage(); UpdateDeathTimer(timeDelta); GetHudEventController().RunDelayedEvents(); } protected function CheckDLCMessagePending():void { var dlcManager : CDLCManager; var hasSeen : bool; var dlcNames : array<name>; var i : int; hasSeen = theGame.GetInGameConfigWrapper().GetVarValue('Hidden', 'HasSeenDLCMessage'); if (!hasSeen) { dlcManager = theGame.GetDLCManager(); dlcManager.GetDLCs(dlcNames); for (i = 0; i < dlcNames.Size(); i += 1) { if (dlcManager.IsDLCAvailable(dlcNames[i])) { m_dlcMessagePending = true; break; } } } } protected function UpdateDLCPendingMessage():void { if (m_dlcMessagePending && !theGame.IsDialogOrCutscenePlaying() && !theGame.IsBlackscreenOrFading()) { m_dlcMessagePending = false; theGame.GetInGameConfigWrapper().SetVarValue('Hidden', 'HasSeenDLCMessage', "true"); theGame.SaveUserSettings(); theGame.GetGuiManager().ShowUserDialog(0, "", "dlc_pop_up", UDB_Ok); } } protected function UpdateLootPopupContext():void { var lootPopup : CR4LootPopup; lootPopup = (CR4LootPopup)theGame.GetGuiManager().GetPopup('LootPopup'); if (lootPopup) { lootPopup.UpdateInputContext(); } } public function StartDeathTimer(duration : float) { m_deathTimer = duration; m_deathTimerActive = true; } private function UpdateDeathTimer(timeDelta : float) { var currentMenu : CR4Menu; // #J SUPER lame way to bypass fact that current timers are paused when game is paused, even if it needs not to be // Best way to fix TTP#100217 that I could think of without new timer system. If theres a better way that I know nothing about // feel free, nay, encouraged to do it that way. if ( m_deathTimerActive ) { m_deathTimer -= timeDelta; if (m_deathTimer <= 0.0) { m_deathTimerActive = false; currentMenu = theGame.GetGuiManager().GetRootMenu(); // In case pause menu popped in when it should not have. if (currentMenu) { currentMenu.CloseMenu(); } theGame.RequestMenu( 'DeathScreenMenu' ); theInput.StoreContext('Death'); } } } private function GetHudEventController() : CR4HudEventController { return theGame.GetGuiManager().GetHudEventController(); } private function OnInputContextChanged() { var module : CR4HudModuleInteractions; module = (CR4HudModuleInteractions)GetHudModule( "InteractionsModule" ); if ( module ) { module.OnInputContextChanged(); } } public function RefreshHudConfiguration() : void { UpdateScaleformStageSize(); UpdateHudScale(); UpdateHudConfigs(); } public function UpdateScaleformStageSize() { var currentWidth, currentHeight : int; var ratio : float; theGame.GetCurrentViewportResolution( currentWidth, currentHeight ); ratio = ( (float)currentWidth ) / currentHeight; // this should be the same as in UpdateAnchorsAspectRatio in HudModuleAnchors.as if ( AbsF( ratio - 4.0 / 3.0 ) < 0.01 ) { m_scaleformWidth = 1920; m_scaleformHeight = 1440; m_scaleformOffsetX = 0; m_scaleformOffsetY = -180; } else if ( AbsF( ratio - 21.0 / 9.0 ) < 0.01 ) { m_scaleformWidth = 2520; m_scaleformHeight = 1080; m_scaleformOffsetX = -300; m_scaleformOffsetY = 0; } else { m_scaleformWidth = 1920; m_scaleformHeight = 1080; m_scaleformOffsetX = 0; m_scaleformOffsetY = 0; } } public function GetScaleformPoint( x : float, y : float ) : Vector { var normalizedPoint : Vector; normalizedPoint.X = x * m_scaleformWidth + m_scaleformOffsetX; normalizedPoint.Y = y * m_scaleformHeight + m_scaleformOffsetY; return normalizedPoint; } public function UpdateHudScale() { var l_hudModuleAnchors : CR4HudModuleAnchors; l_hudModuleAnchors = (CR4HudModuleAnchors) GetHudModule( "AnchorsModule" ); if (l_hudModuleAnchors) { l_hudModuleAnchors.UpdateAnchorsAspectRatio(); } if( ( m_hudSize == 1 ) ) { theGame.SetUIGamepadScaleGain(0.25); } else { theGame.SetUIGamepadScaleGain(0.0); } theGame.SetUIOpacity(1); RescaleModules(); } // INIT #B // ------------------------------------------------------------------------------- event /*flash*/ OnConfigUI() { var i : int; m_HudFlashSFS = GetHudFlash(); m_guiManager = theGame.GetGuiManager(); UpdateScaleformStageSize(); UpdateHudScale(); m_fxShowModulesSFF = m_HudFlashSFS.GetMemberFlashFunction( "ShowModules"); m_fxPrintInfoSFF = m_HudFlashSFS.GetMemberFlashFunction( "PrintInfo"); m_fxSetInputContextSFF = m_HudFlashSFS.GetMemberFlashFunction( "SetInputContext"); m_fxSetIsDynamicSFF = m_HudFlashSFS.GetMemberFlashFunction( "SetDynamic"); m_fxSetControllerType = m_HudFlashSFS.GetMemberFlashFunction( "setControllerType" ); m_fxSwapAcceptCancel = m_HudFlashSFS.GetMemberFlashFunction( "swapAcceptCancel" ); m_fxSetGamepadType = m_HudFlashSFS.GetMemberFlashFunction( "setGamepadType" ); m_fxLockControlScheme = m_HudFlashSFS.GetMemberFlashFunction( "lockControlScheme" ); CreateHudModule("AnchorsModule"); hudModulesNames.PushBack('ControlsFeedbackModule'); hudModulesNames.PushBack('HorseStaminaBarModule'); // OK // #B Anchors OK hudModulesNames.PushBack('HorsePanicBarModule'); // OK // #B Anchors OK hudModulesNames.PushBack('InteractionsModule'); // OK hudModulesNames.PushBack('MessageModule'); // OK hudModulesNames.PushBack('RadialMenuModule'); // OK hudModulesNames.PushBack('QuestsModule'); // OK // #B Anchors OK //hudModulesNames.PushBack('SignInfoModule'); // OK // #B Anchors OK hudModulesNames.PushBack('SubtitlesModule'); // OK //hudModulesNames.PushBack('DebugFastMenuModule'); // OK //hudModulesNames.PushBack('LootPopupModule'); // OK // #B Anchors OK hudModulesNames.PushBack('BuffsModule'); // OK // #B Anchors OK hudModulesNames.PushBack('WolfHeadModule'); // OK // #B Anchors OK hudModulesNames.PushBack('ItemInfoModule'); // <-------------------- some scaleform error!!! // #B Anchors OK hudModulesNames.PushBack('OxygenBarModule'); // #B Anchors OK hudModulesNames.PushBack('EnemyFocusModule'); hudModulesNames.PushBack('BossFocusModule'); hudModulesNames.PushBack('DialogModule'); //hudModulesNames.PushBack('DebugTextModule'); hudModulesNames.PushBack('BoatHealthModule'); //hudModulesNames.PushBack('DeathScreenModule'); hudModulesNames.PushBack('ConsoleModule'); // #B Anchors OK hudModulesNames.PushBack('JournalUpdateModule'); // #B Anchors OK hudModulesNames.PushBack('AreaInfoModule'); // #B Anchors OK hudModulesNames.PushBack('CrosshairModule'); // #B Anchors OK hudModulesNames.PushBack('OnelinersModule'); // #B Anchors OK hudModulesNames.PushBack('Minimap2Module'); hudModulesNames.PushBack('CompanionModule'); hudModulesNames.PushBack('DamagedItemsModule'); hudModulesNames.PushBack('TimeLapseModule'); for( i = 0; i < hudModulesNames.Size(); i += 1 ) { CreateHudModule(NameToString(hudModulesNames[i])); } m_fxSetIsDynamicSFF.InvokeSelfOneArg(FlashArgBool(m_isDynamic)); UpdateHudConfigs(); UpdateAcceptCancelSwaping(); UpdateControlSchemeLock(); CheckDLCMessagePending(); if ( !show && source == HVS_User ) { if ( IsRadialMenuOpened() ) { // restriction - don't allow to hide hud by user when radial is opened return; } } previouslyVisibleHud = ( m_visibleHudBySystem && m_visibleHudByUser ); } currentlyVisibleHud = ( m_visibleHudBySystem && m_visibleHudByUser ); ForceShow( !m_visibleHudByUser, HVS_User ); public function ForceShow( show : bool ) { m_HudFlashSFS.SetVisible( show ); } public function UpdateAcceptCancelSwaping():void { var inGameConfigWrapper : CInGameConfigWrapper; var configValue : bool; var radialMenuModule : CR4HudModuleRadialMenu; if (m_fxSwapAcceptCancel) { inGameConfigWrapper = (CInGameConfigWrapper)theGame.GetInGameConfigWrapper(); configValue = inGameConfigWrapper.GetVarValue('Controls', 'SwapAcceptCancel'); m_fxSwapAcceptCancel.InvokeSelfOneArg( FlashArgBool(configValue) ); } radialMenuModule = (CR4HudModuleRadialMenu)GetHudModule( "RadialMenuModule" ); if (radialMenuModule) { radialMenuModule.UpdateSwapAcceptCancel(); } } protected function UpdateControlSchemeLock():void { if (m_fxLockControlScheme && m_guiManager) { m_fxLockControlScheme.InvokeSelfOneArg( FlashArgUInt(m_guiManager.GetLockedControlScheme()) ); } } public function UpdateInputDevice():void { if (m_fxSetControllerType) { m_fxSetControllerType.InvokeSelfOneArg( FlashArgBool(theInput.LastUsedGamepad()) ); } } public function UpdateHudConfigs():void { UpdateHudConfig('Subtitles', false); // Note: When game is intializing, all modules need to update on these values themselves properly. UpdateHudConfig('HudSize', false); UpdateHudConfig('TimeLapseModule', false); UpdateHudConfig('BoatHealthModule', false); UpdateHudConfig('BossFocusModule', false); UpdateHudConfig('BuffsModule', false); UpdateHudConfig('CompanionModule', false); UpdateHudConfig('ConsoleModule', false); UpdateHudConfig('DamagedItemsModule', false); UpdateHudConfig('EnemyFocusModule', false); UpdateHudConfig('NPCNames', false); UpdateHudConfig('EnemyHitEffects', false); UpdateHudConfig('HorsePanicBarModule', false); UpdateHudConfig('HorseStaminaBarModule', false); UpdateHudConfig('ItemInfoModule', false); //UpdateHudConfig('JournalUpdateModule', false); UpdateHudConfig('Minimap2Module', false); UpdateHudConfig('DayWeatherIndicator',false); UpdateHudConfig('TrackedMonster',false); UpdateHudConfig('OnelinersModule', false); UpdateHudConfig('OxygenBarModule', false); UpdateHudConfig('QuestsModule', false); UpdateHudConfig('WolfMedalion',false); UpdateHudConfig('MessageModule', false); UpdateHudConfig('MinimapRotation', false); UpdateHudConfig('MinimapFocusClues', false); UpdateHudConfig('MinimapTracksWaypoints', false); UpdateHudConfig('MiminapPoiQuestionMarks', false); UpdateHudConfig('ControlsFeedbackModule', false); UpdateHUD(); } public function UpdateHudConfig(configName : name, updateHud : bool):void { var configValue : string; var inGameConfigWrapper : CInGameConfigWrapper; var module : CR4HudModuleBase; inGameConfigWrapper = (CInGameConfigWrapper)theGame.GetInGameConfigWrapper(); switch (configName) { case 'HudSize': configValue = inGameConfigWrapper.GetVarValue('Hud', configName); SetHudSize( StringToInt( configValue ), true ); break; case 'Subtitles': { configValue = inGameConfigWrapper.GetVarValue('Localization', configName); module = (CR4HudModuleBase)(GetHudModule(NameToString('SubtitlesModule'))); if (module) { module.SetEnabled(configValue == "true"); } theGame.setDialogDisplayDisabled(configValue == "false"); } break; case 'WolfMedalion': case 'TimeLapseModule': case 'BoatHealthModule': case 'BossFocusModule': case 'CompanionModule': case 'ConsoleModule': case 'DamagedItemsModule': case 'HorsePanicBarModule': case 'HorseStaminaBarModule': case 'ItemInfoModule': //case 'JournalUpdateModule': case 'Minimap2Module': case 'OnelinersModule': case 'OxygenBarModule': case 'QuestsModule': case 'MessageModule': case 'BuffsModule': case 'ControlsFeedbackModule': { configValue = inGameConfigWrapper.GetVarValue('Hud', configName); if( configName == 'WolfMedalion' ) { configName = 'WolfHeadModule'; } module = (CR4HudModuleBase)(GetHudModule(NameToString(configName))); if (module) { module.SetEnabled(configValue == "true"); } } break; case 'EnemyFocusModule': { configValue = inGameConfigWrapper.GetVarValue( 'Hud', configName ); m_enabledEnemyFocus = ( configValue == "true" ); UpdateEnemyFocusVisiblity( m_enabledEnemyFocus, m_enabledNPCNames ); } break; case 'NPCNames': { configValue = inGameConfigWrapper.GetVarValue( 'Hud', configName ); m_enabledNPCNames = ( configValue == "true" ); UpdateEnemyFocusVisiblity( m_enabledEnemyFocus, m_enabledNPCNames ); } break; case 'EnemyHitEffects': { configValue = inGameConfigWrapper.GetVarValue('Hud', configName); m_enemyHitEffects = configValue == "true"; } break; case 'DayWeatherIndicator': /*{ configValue = inGameConfigWrapper.GetVarValue('Hud', configName); EnableDayTimeDisplay(configValue == "true"); }*/ break; case 'TrackedMonster': /*{ configValue = inGameConfigWrapper.GetVarValue('Hud', configName); EnableBuffedMonsterDisplay(configValue == "true"); }*/ break; case 'MinimapRotation': { configValue = inGameConfigWrapper.GetVarValue('Hud', configName); EnableMinimapRotation(configValue == "true"); } break; case 'MinimapFocusClues': { configValue = inGameConfigWrapper.GetVarValue('Hud', configName); theGame.GetCommonMapManager().ShowFocusClues( configValue == "true" ); } break; case 'MiminapPoiQuestionMarks': { configValue = inGameConfigWrapper.GetVarValue('Hud', configName); theGame.GetCommonMapManager().ShowKnownEntities( configValue == "true" ); } break; case 'MinimapTracksWaypoints': { configValue = inGameConfigWrapper.GetVarValue('Hud', configName); theGame.GetCommonMapManager().ShowHintWaypoints( configValue == "true" ); } break; } if (updateHud) { UpdateHUD(); } } function EnableBuffedMonsterDisplay( value : bool ) { var minimapModule : CR4HudModuleMinimap2; minimapModule = (CR4HudModuleMinimap2)GetHudModule("Minimap2Module"); minimapModule.bDisplayBuffedMoster = value; } function Toggle24HRFormat( value : bool ) { var minimapModule : CR4HudModuleMinimap2; minimapModule = (CR4HudModuleMinimap2)GetHudModule("Minimap2Module"); minimapModule.b24HRFormat = value; minimapModule.RefreshTimeDisplay(); } public function AddHudModuleReference( hudModule : CR4HudModuleBase ) { if( hudModules.FindFirst( hudModule ) < 0 ) { hudModules.PushBack( hudModule ); } } public function HandleDialogClosed( messageId : int ) { var hudModuleDialog : CR4HudModuleDialog; if (messageId == UMID_MissingContentOnDialogError) { hudModuleDialog = GetDialogModule(); if (hudModuleDialog) { hudModuleDialog.OnMissingContentDialogClosed(); } } } function GetDialogModule() : CR4HudModuleDialog { return (CR4HudModuleDialog)GetHudModule( "DialogModule" ); } function GetDamagedItemModule() : CR4HudModuleDamagedItems { return (CR4HudModuleDamagedItems)GetHudModule( "DamagedItemsModule" ); } function RescaleModules() { var i : int; for( i = 0; i < hudModules.Size(); i += 1) { hudModules[i].SnapToAnchorPosition(); } } function IsRadialMenuOpened() : bool { var radialMenuModule : CR4HudModuleRadialMenu; radialMenuModule = (CR4HudModuleRadialMenu)GetHudModule( "RadialMenuModule" ); if(radialMenuModule) return radialMenuModule.IsRadialMenuOpened(); return false; } function IsRadialMenuOverwritenByContext( context : name ) : bool { switch(context) { case 'Scene': case 'FastMenu': case 'EMPTY_CONTEXT': return true; default: return false; } return false; } // DIALOGS & SUBTITLES // ------------------------------------------------------------------------------- event /*C++*/ OnDialogHudShow() { theInput.StoreContext( 'Scene' ); //#B should be Scene } event /*C++*/ OnDialogHudHide() { theInput.RestoreContext( 'Scene', true ); // note : MS - we don't really know at this point what context we are going back to } event /*C++*/ OnDialogSentenceSet( text : string, alternativeUI : bool ) { var dialogModule : CR4HudModuleDialog; dialogModule = GetDialogModule(); if ( dialogModule ) { dialogModule.OnDialogSentenceSet( text ); } else { LogChannel( 'MissingHudModule', "CR4HudModuleDialog not found (OnDialogSentenceSet)" ); } } event /*C++*/ OnDialogPreviousSentenceSet( text : string ) { var dialogModule : CR4HudModuleDialog; dialogModule = GetDialogModule(); if ( dialogModule ) { dialogModule.OnDialogPreviousSentenceSet( text ); } else { LogChannel( 'MissingHudModule', "CR4HudModuleDialog not found (OnDialogPreviousSentenceSet)" ); } } event /*C++*/ OnDialogPreviousSentenceHide() { var dialogModule : CR4HudModuleDialog; dialogModule = GetDialogModule(); if ( dialogModule ) { dialogModule.OnDialogPreviousSentenceHide(); } else { LogChannel( 'MissingHudModule', "CR4HudModuleDialog not found (OnDialogPreviousSentenceHide)" ); } } event /*C++*/ OnDialogSentenceHide() { var dialogModule : CR4HudModuleDialog; dialogModule = GetDialogModule(); if ( dialogModule ) { dialogModule.OnDialogSentenceHide(); } else { LogChannel( 'MissingHudModule', "CR4HudModuleDialog not found (OnDialogSentenceHide)" ); } } event /*C++*/ OnDialogChoicesSet( choices : array< SSceneChoice >, alternativeUI : bool ) { var dialogModule : CR4HudModuleDialog; dialogModule = GetDialogModule(); if ( dialogModule ) { dialogModule.OnDialogChoicesSet( choices ); } else { LogChannel( 'MissingHudModule', "CR4HudModuleDialog not found (OnDialogChoicesSet)" ); } } event /*C++*/ OnDialogChoiceTimeoutSet( timeOutPercent : float ) { var dialogModule : CR4HudModuleDialog; dialogModule = GetDialogModule(); if ( dialogModule ) { dialogModule.OnDialogChoiceTimeoutSet(timeOutPercent); } else { LogChannel( 'MissingHudModule', "CR4HudModuleDialog not found (OnDialogChoiceTimeoutSet)" ); } } event /*C++*/ OnDialogChoiceTimeoutHide() { var dialogModule : CR4HudModuleDialog; dialogModule = GetDialogModule(); if ( dialogModule ) { dialogModule.OnDialogChoiceTimeoutHide(); } else { LogChannel( 'MissingHudModule', "CR4HudModuleDialog not found (OnDialogChoiceTimeoutHide)" ); } } event /*C++*/ OnDialogSkipConfirmShow() { var dialogModule : CR4HudModuleDialog; dialogModule = GetDialogModule(); if ( dialogModule ) { dialogModule.OnDialogSkipConfirmShow(); } else { LogChannel( 'MissingHudModule', "CR4HudModuleDialog not found (OnDialogSkipConfirmShow)" ); } } event /*C++*/ OnDialogSkipConfirmHide() { var dialogModule : CR4HudModuleDialog; dialogModule = GetDialogModule(); if ( dialogModule ) { dialogModule.OnDialogSkipConfirmHide(); } else { LogChannel( 'MissingHudModule', "CR4HudModuleDialog not found (OnDialogSkipConfirmHide)" ); } } event /*C++*/ OnSubtitleAdded( id : int, speakerNameDisplayText : string, htmlString : string, alternativeUI : bool ) { var subtitlesModule : CR4HudModuleSubtitles; subtitlesModule = (CR4HudModuleSubtitles)GetHudModule( "SubtitlesModule" ); if ( subtitlesModule ) { subtitlesModule.OnSubtitleAdded( id, speakerNameDisplayText, htmlString ); } else { LogChannel( 'MissingHudModule', "CR4HudModuleSubtitles not found (OnSubtitleAdded)" ); } } event /*C++*/ OnSubtitleRemoved( id : int ) { var subtitlesModule : CR4HudModuleSubtitles; subtitlesModule = (CR4HudModuleSubtitles)GetHudModule( "SubtitlesModule" ); if ( subtitlesModule ) { subtitlesModule.OnSubtitleRemoved( id ); } else { LogChannel( 'MissingHudModule', "CR4HudModuleSubtitles not found (OnSubtitleRemoved)" ); } } // VIDEO // ------------------------------------------------------------------------------- event OnVideoSubtitles( subtitles : string ) { LogChannel('Video', "[" + subtitles + "]"); if ( subtitles != "" ) { OnDialogSentenceSet( subtitles ); } else { OnDialogSentenceHide(); } } // ONELINERS // ------------------------------------------------------------------------------- event /* C++ */ OnCreateOneliner( target : CEntity, value : string, ID : int ) { var onelinersModule : CR4HudModuleOneliners; onelinersModule = (CR4HudModuleOneliners)GetHudModule( "OnelinersModule" ); if ( onelinersModule ) { onelinersModule.OnCreateOneliner( target, value, ID ); } else { LogChannel( 'MissingHudModule', "CR4HudModuleOneliners not found (OnCreateOneliner)" ); } } event /* C++ */ OnRemoveOneliner( ID : int ) { var onelinersModule : CR4HudModuleOneliners; onelinersModule = (CR4HudModuleOneliners)GetHudModule( "OnelinersModule" ); if ( onelinersModule ) { onelinersModule.OnRemoveOneliner( ID ); } else { LogChannel( 'MissingHudModule', "CR4HudModuleOneliners not found (OnRemoveOneliner)" ); } } // INTERACTIONS #B // ------------------------------------------------------------------------------- event /*C++*/ OnInteractionsUpdated( component : CInteractionComponent ) { var interactionsModule : CR4HudModuleInteractions; interactionsModule = (CR4HudModuleInteractions)GetHudModule( "InteractionsModule" ); if ( interactionsModule ) { interactionsModule.OnInteractionsUpdated( component ); } else { LogChannel( 'MissingHudModule', "CR4HudModuleInteractions not found (OnInteractionsUpdated)" ); } } public function IsInteractionInCameraView( interaction : CInteractionComponent ) : bool { var interactionsModule : CR4HudModuleInteractions; interactionsModule = (CR4HudModuleInteractions)GetHudModule( "InteractionsModule" ); if ( interactionsModule ) { return interactionsModule.IsInteractionInCameraView( interaction ); } return false; } // DEBUG TEXT #B // ------------------------------------------------------------------------------- event /*C++*/ OnDebugTextShown( text : string ) { /* var debugTextModule : CR4HudModuleDebugText; debugTextModule = (CR4HudModuleDebugText)GetHudModule( "DebugTextModule" ); if ( debugTextModule ) { debugTextModule.ShowDebugText( text ); } else { LogChannel( 'MissingHudModule', "CR4HudModuleDebugText not found (OnDebugTextShown)" ); } */ } event /*C++*/ OnDebugTextHidden() { /* var debugTextModule : CR4HudModuleDebugText; debugTextModule = (CR4HudModuleDebugText)GetHudModule( "DebugTextModule" ); if ( debugTextModule ) { debugTextModule.HideDebugText(); } else { LogChannel( 'MissingHudModule', "CR4HudModuleDebugText not found (OnDebugTextHidden)" ); } */ } // JOURNAL UPDATE MODULE // ------------------------------------------------------------------------------- event /*C++*/ OnCharacterEvent( journalCharacter : CJournalCharacter ) { LogChannel( 'Journal', "OnCharacterEvent" ); OnJournalUpdate(journalCharacter,false); m_guiManager.RegisterNewGlossaryEntry( journalCharacter, 'panel_title_glossary_dictionary' ); // panel_title_glossary_characters } event /*C++*/ OnCharacterDescriptionEvent( journalCharacterDescription : CJournalCharacterDescription ) { var journalCharacter : CJournalCharacter; LogChannel( 'Journal', "OnCharacterDescriptionEvent" ); journalCharacter = (CJournalCharacter)journalCharacterDescription.GetParent(); if( journalCharacter ) { OnJournalUpdate(journalCharacter,true); } } event /*C++*/ OnCreatureEvent( journalCreature : CJournalCreature ) { LogChannel( 'Journal', "OnCreatureEvent" ); OnJournalUpdate(journalCreature,false); m_guiManager.RegisterNewGlossaryEntry( journalCreature, 'panel_title_glossary_bestiary' ); } event /*C++*/ OnCreatureDescriptionEvent( journalCreatureDescription : CJournalCreatureDescriptionEntry ) { var journalCreature : CJournalCreature; LogChannel( 'Journal', "OnCreatureDescriptionEvent" ); // this will never work, CJournalCreatureDescriptionEntry has parent CJournalCreatureDescriptionGroup, not CJournalCreature // but at this point I waouldn't rather want to fix it // | // V journalCreature = (CJournalCreature)journalCreatureDescription.GetParent(); if( journalCreature ) { OnJournalUpdate(journalCreature,true); } } event /*C++*/ OnGlossaryEvent( journalGlossary : CJournalGlossary ) { /* LogChannel( 'Journal', "OnGlossaryEvent" ); OnJournalUpdate(journalGlossary,false); m_guiManager.RegisterNewGlossaryEntry( journalGlossary, 'panel_title_glossary_dictionary' ); */ } event /*C++*/ OnGlossaryDescriptionEvent( journalGlossaryDescription : CJournalGlossaryDescription ) { /* var journalGlossary : CJournalGlossary; LogChannel( 'Journal', "OnGlossaryDescriptionEvent" ); journalGlossary = (CJournalGlossary)journalGlossaryDescription.GetParent(); if( journalGlossary ) { OnJournalUpdate(journalGlossary,true); } */ } event /*C++*/ OnStoryBookPageEvent( journalStoryBookPage : CJournalStoryBookPage ) { LogChannel( 'Journal', "OnStoryBookPageEvent" ); } event /*C++*/ OnTutorialEvent( journalTutorial : CJournalTutorial ) { LogChannel( 'Journal', "OnTutorialEvent" ); } event /*C++*/ OnPlaceEvent( journalPlace : CJournalPlace ) { LogChannel( 'Journal', "OnPlaceEvent" ); } event /*C++*/ OnPlaceDescriptionEvent( journalPlaceDescription : CJournalPlaceDescription ) { LogChannel( 'Journal', "OnPlaceDescriptionEvent" ); } event /*C++*/ OnQuestEvent( journalQuest : CJournalQuest ) { LogChannel( 'Journal', "OnQuestEvent "+journalQuest.baseName ); OnQuestUpdate( journalQuest, true ); } event /*C++*/ OnQuestObjectiveEvent( journalQuest : CJournalQuest, journalObjective : CJournalQuestObjective ) { LogChannel( 'Journal', "OnQuestObjectiveEvent " + journalQuest.baseName + " : " + journalObjective.baseName ); OnQuestUpdate( journalQuest, false ); // #B disable when we want to display only quest updates (not objectives) } function OnQuestUpdate( journalQuest : CJournalQuest, isQuestUpdate : bool ) { var hudJournalUpdateModule : CR4HudModuleJournalUpdate; var manager : CWitcherJournalManager; var status : int; var id : int; var itemIds : array<SItemUniqueId>; hudJournalUpdateModule = (CR4HudModuleJournalUpdate)GetHudModule( "JournalUpdateModule" ); if ( hudJournalUpdateModule ) { hudJournalUpdateModule.AddQuestUpdate( journalQuest, isQuestUpdate ); } manager = theGame.GetJournalManager(); status = manager.GetEntryStatus( journalQuest ); if ( status == JS_Success ) { thePlayer.inv.GetAllItems( itemIds ); theTelemetry.LogWithLabel( TE_INV_QUEST_COMPLETED, "QUEST COMPLETED - ECONOMY REPORT" ); theTelemetry.LogWithLabelAndValue( TE_INV_QUEST_COMPLETED, "Crowns", thePlayer.GetMoney() ); for ( id = itemIds.Size() - 1; id >= 0; id -= 1 ) { theTelemetry.LogWithLabelAndValue( TE_INV_QUEST_COMPLETED, thePlayer.inv.GetItemName(itemIds[ id ] ), thePlayer.inv.GetItemQuantity( itemIds[ id ] ) ); } } } function OnLevelUpUpdate( level : int, show : bool) { var hudJournalUpdateModule : CR4HudModuleJournalUpdate; var hudQuestsModule : CR4HudModuleQuests; hudJournalUpdateModule = (CR4HudModuleJournalUpdate)GetHudModule( "JournalUpdateModule" ); if ( hudJournalUpdateModule ) { if ( show ) hudJournalUpdateModule.AddLevelUpUpdate(level); if ( thePlayer.IsCiri() ) show = false; OnShowLevelUpIndicator( show ); } hudQuestsModule = (CR4HudModuleQuests)GetHudModule( "QuestsModule" ); if (hudQuestsModule) { hudQuestsModule.OnLevelUp(); } } function OnShowLevelUpIndicator( show : bool ) { var hudWolfHeadModule : CR4HudModuleWolfHead; hudWolfHeadModule = (CR4HudModuleWolfHead)GetHudModule( "WolfHeadModule" ); if ( hudWolfHeadModule ) { hudWolfHeadModule.ShowLevelUpIndicator(show); } } function OnExperienceUpdate( exp : int, show : bool ) { var hudJournalUpdateModule : CR4HudModuleJournalUpdate; hudJournalUpdateModule = (CR4HudModuleJournalUpdate)GetHudModule( "JournalUpdateModule" ); if ( hudJournalUpdateModule && show ) { if ( show ) hudJournalUpdateModule.AddExperienceUpdate(exp); } } function OnMapPinUpdate( mapPinTag : name ) { var hudJournalUpdateModule : CR4HudModuleJournalUpdate; hudJournalUpdateModule = (CR4HudModuleJournalUpdate)GetHudModule( "JournalUpdateModule" ); if ( hudJournalUpdateModule ) { hudJournalUpdateModule.AddMapPinUpdate(mapPinTag); } } function OnItemRecivedDuringScene( itemName : name, optional quantity : int ) { var hudJournalUpdateModule : CR4HudModuleJournalUpdate; hudJournalUpdateModule = (CR4HudModuleJournalUpdate)GetHudModule( "JournalUpdateModule" ); if ( hudJournalUpdateModule ) { hudJournalUpdateModule.AddItemRecivedDuringSceneUpdate(itemName, quantity); } } function OnJournalUpdate( journalEntry : CJournalBase, isDescription : bool ) { var hudJournalUpdateModule : CR4HudModuleJournalUpdate; hudJournalUpdateModule = (CR4HudModuleJournalUpdate)GetHudModule( "JournalUpdateModule" ); if ( hudJournalUpdateModule ) { hudJournalUpdateModule.AddJournalUpdate( journalEntry, isDescription ); } } function OnCraftingSchematicUpdate( schematicName : name ) { var hudJournalUpdateModule : CR4HudModuleJournalUpdate; hudJournalUpdateModule = (CR4HudModuleJournalUpdate)GetHudModule( "JournalUpdateModule" ); if ( hudJournalUpdateModule ) { hudJournalUpdateModule.AddCraftingSchematicUpdate( schematicName ); } m_guiManager.RegisterNewGlossaryEntry( NULL, 'panel_title_crafting', schematicName ); } function OnAlchemySchematicUpdate( schematicName : name ) { var hudJournalUpdateModule : CR4HudModuleJournalUpdate; hudJournalUpdateModule = (CR4HudModuleJournalUpdate)GetHudModule( "JournalUpdateModule" ); if ( hudJournalUpdateModule ) { hudJournalUpdateModule.AddAlchemySchematicUpdate( schematicName ); } m_guiManager.RegisterNewAlchemyEntry( schematicName ); } // Quest Tracker Events #B // ------------------------------------------------------------------------------- event /*C++*/ OnQuestTrackingStarted( journalQuest : CJournalQuest ) { GetHudEventController().RunEvent_QuestsModule_OnQuestTrackingStarted( journalQuest ); LogChannel( 'Journal', "OnQuestTrackingStarted " + journalQuest.baseName ); } event /*C++*/ OnTrackedQuestUpdated( journalQuest : CJournalQuest ) { var hudQuestTrackerModule : CR4HudModuleQuests; hudQuestTrackerModule = (CR4HudModuleQuests)GetHudModule( "QuestsModule" ); if ( hudQuestTrackerModule ) { hudQuestTrackerModule.OnTrackedQuestUpdated( journalQuest ); } else { LogChannel( 'MissingHudModule', "CR4HudModuleQuests not found (OnTrackedQuestUpdated)" ); } LogChannel( 'Journal', "OnTrackedQuestUpdated " + journalQuest.baseName ); } event /*C++*/ OnTrackedQuestObjectivesUpdated( journalObjective : CJournalQuestObjective ) { var hudQuestTrackerModule : CR4HudModuleQuests; hudQuestTrackerModule = (CR4HudModuleQuests)GetHudModule( "QuestsModule" ); if ( hudQuestTrackerModule ) { hudQuestTrackerModule.OnTrackedQuestObjectivesUpdated( journalObjective ); } else { LogChannel( 'MissingHudModule', "CR4HudModuleQuests not found (OnTrackedQuestObjectivesUpdated)" ); } LogChannel( 'Journal', "OnTrackedQuestObjectivesUpdated " + journalObjective.baseName ); } event /*C++*/ OnTrackedQuestObjectiveCounterUpdated( journalObjective : CJournalQuestObjective ) { var hudQuestTrackerModule : CR4HudModuleQuests; hudQuestTrackerModule = (CR4HudModuleQuests)GetHudModule( "QuestsModule" ); if ( hudQuestTrackerModule ) { hudQuestTrackerModule.OnTrackedQuestObjectiveCounterUpdated( journalObjective ); } else { LogChannel( 'MissingHudModule', "CR4HudModuleQuests not found (OnTrackedQuestObjectiveCounterUpdated)" ); } LogChannel( 'Journal', "OnTrackedQuestObjectiveCounterUpdated " + journalObjective.baseName ); } event /*C++*/ OnTrackedQuestObjectiveHighlighted( journalObjective : CJournalQuestObjective, journalObjectiveIndex : int ) { GetHudEventController().RunEvent_QuestsModule_OnTrackedQuestObjectiveHighlighted( journalObjective, journalObjectiveIndex ); LogChannel( 'Journal', "OnTrackedQuestObjectiveHighlighted " + journalObjective.baseName ); } function __PrintInfo() { m_fxPrintInfoSFF.InvokeSelf(); } private function SetHudSize( size : int, update : bool ) { m_hudSize = size; if ( update ) { UpdateHudScale(); } } private function UpdateEnemyFocusVisiblity( enableEnemyFocus : bool, enabledNPCNames : bool ) { var enemyFocusModule : CR4HudModuleEnemyFocus; enemyFocusModule = (CR4HudModuleEnemyFocus)( GetHudModule( "EnemyFocusModule" ) ); if ( enemyFocusModule ) { enemyFocusModule.SetGeneralVisibility( enableEnemyFocus, enabledNPCNames ); } } public function AreEnabledEnemyHitEffects(): bool { return m_enemyHitEffects; } public function IsEnabledMinimapRotation() : bool { return m_minimapRotationEnabled; } private function EnableMinimapRotation( enable : bool ) { var module : CR4HudModuleMinimap2; m_minimapRotationEnabled = enable; module = (CR4HudModuleMinimap2)GetHudModule("Minimap2Module"); if ( module ) { module.EnableRotation( enable ); } } public function SetMinimapZoom( zoom : float ) { m_minimapZoom = zoom; } public function GetMinimapZoom() : float { return m_minimapZoom; } public function HudConsoleMsg( msgText : string ) { var module : CR4HudModuleConsole; module = (CR4HudModuleConsole)GetHudModule("ConsoleModule"); if ( module ) { module.ConsoleMsg( msgText ); } } public function HudConsoleTest() { var module : CR4HudModuleConsole; module = (CR4HudModuleConsole)GetHudModule("ConsoleModule"); if ( module ) { module.ConsoleTest(); } } public function HudConsoleCleanup() { var module : CR4HudModuleConsole; module = (CR4HudModuleConsole)GetHudModule("ConsoleModule"); if ( module ) { module.ConsoleCleanup(); } } public function SetDynamic( value : bool ) { m_isDynamic = value; m_fxSetIsDynamicSFF.InvokeSelfOneArg(FlashArgBool(m_isDynamic)); UpdateHUD(); } public function GetDynamic( ) : bool { return m_isDynamic; } public function UpdateHUD() { m_fxSetInputContextSFF.InvokeSelfOneArg(FlashArgString(currentInputContext)); } public function DisplayTutorialHighlight( tutorialName : name ,bShow : bool ) { var hudModule : CR4HudModuleBase; LogChannel('TUTHUGH',"tutorialName "+tutorialName+" bShow "+bShow); switch(tutorialName) { case 'TutorialHorseStamina' : hudModule = (CR4HudModuleBase)GetHudModule("HorseStaminaBarModule"); hudModule.ShowTutorialHighlight(bShow,NameToString(tutorialName)); break; case 'TutorialOxygen' : hudModule = (CR4HudModuleBase)GetHudModule("OxygenBarModule"); hudModule.ShowTutorialHighlight(bShow,NameToString(tutorialName)); break; case 'TutorialMinimap' : case 'TutorialActiveGoalHighlight' : case 'TutorialMinimapAndQuestLog' : hudModule = (CR4HudModuleBase)GetHudModule("Minimap2Module"); hudModule.ShowTutorialHighlight(bShow,NameToString(tutorialName)); if( tutorialName != 'TutorialMinimapAndQuestLog' ) // #B because it should be called also for Quest Tracker { break; } case 'TutorialMinimapAndQuestLog' : case 'TutorialQuestTodo' : hudModule = (CR4HudModuleBase)GetHudModule("QuestsModule"); hudModule.ShowTutorialHighlight(bShow,NameToString(tutorialName)); break; case 'TutorialFallingDamage' : case 'TutorialStaminaSigns' : case 'TutorialStaminaExploration' : case 'TutorialAdrenaline' : hudModule = (CR4HudModuleBase)GetHudModule("WolfHeadModule"); hudModule.ShowTutorialHighlight(bShow,NameToString(tutorialName)); break; case 'TutorialBuffs' : hudModule = (CR4HudModuleBase)GetHudModule("BuffsModule"); hudModule.ShowTutorialHighlight(bShow,NameToString(tutorialName)); break; case 'TutorialSelectQuen' : case 'TutorialSelectIgni' : case 'TutorialSelectAard' : case 'TutorialSelectAxii' : case 'TutorialSelectYrden' : case 'TutorialSelectPetard' : case 'TutorialSelectCrossbow' : hudModule = (CR4HudModuleBase)GetHudModule("RadialMenuModule"); hudModule.ShowTutorialHighlight(bShow,NameToString(tutorialName)); break; case 'TutorialLootWindow' : hudModule = (CR4HudModuleBase)GetHudModule("LootPopupModule"); hudModule.ShowTutorialHighlight(bShow,NameToString(tutorialName)); break; case 'TutorialBoatDamage' : hudModule = (CR4HudModuleBase)GetHudModule("BoatHealthModule"); hudModule.ShowTutorialHighlight(bShow,NameToString(tutorialName)); break; default: break; } } ///////////////////////////////////////////////////////////////////////////// // // !!! HACK !!! // private var _cachedEntity : CEntity; private var _cachedEntityPosition : Vector; function IsCachedPositionForEntity( entity : CEntity ) : bool { return _cachedEntity == entity; } function GetCachedPositionForEntity( entity : CEntity ) : Vector { return _cachedEntityPosition; } function SetCachedPositionForEntity( entity : CEntity, pos : Vector ) { _cachedEntity = entity; _cachedEntityPosition = pos; } function ClearCachedPositionForEntity() { _cachedEntity = NULL; } // // !!! END OF HACK !!! // ///////////////////////////////////////////////////////////////////////////// } exec function showCrossbowTut() { var hud : CR4ScriptedHud; hud = (CR4ScriptedHud)theGame.GetHud(); hud.DisplayTutorialHighlight('TutorialSelectCrossbow', true); } function GetBaseScreenPosition( out screenPos : Vector, entity : CEntity, optional comp : CInteractionComponent, optional extraZ : float, optional noOppositeCamera : bool, optional normalized : bool ) : bool { var hud : CR4ScriptedHud; var targetActor : CActor; var targetEntity : CGameplayEntity; var headBoneIdx : int; var targetPos : Vector; var box : Box; var drawableComponent : CDrawableComponent; var drawableComponentCount : int; var useDrawableComponent : bool; var compMat : Matrix; var actorExtraZ : float = 0.5; if ( !entity ) { return false; } hud = (CR4ScriptedHud)theGame.GetHud(); // if you're going to change something here, you need to know that this function is used by *three* hud modules // proceed with caution // keep it simple targetActor = (CActor)entity; if ( targetActor ) { ///////////////////////////////////////////////////////////////////////////// // // !!! HACK !!! // if ( hud.IsCachedPositionForEntity( targetActor ) ) { targetPos = hud.GetCachedPositionForEntity( targetActor ); } else { // // ///////////////////////////////////////////////////////////////////////////// headBoneIdx = targetActor.GetHeadBoneIndex(); if ( headBoneIdx >= 0 ) { targetPos = MatrixGetTranslation( targetActor.GetBoneWorldMatrixByIndex( headBoneIdx ) ); } else { targetPos = targetActor.GetWorldPosition(); } ///////////////////////////////////////////////////////////////////////////// // // hud.SetCachedPositionForEntity( targetActor, targetPos ); // // !!! END OF HACK !!! // ///////////////////////////////////////////////////////////////////////////// } targetPos += targetActor.iconOffset; targetPos.Z += actorExtraZ; } else { targetEntity = (CGameplayEntity)entity; if ( targetEntity ) { if ( comp ) { targetPos = comp.GetWorldPosition(); if ( comp.iconOffset.X != 0.f || comp.iconOffset.Y != 0.f || comp.iconOffset.Z != 0.f ) { compMat = comp.GetLocalToWorld(); targetPos = VecTransform( compMat, comp.iconOffset ); } else { useDrawableComponent = true; } } else { targetPos = targetEntity.GetWorldPosition(); if ( targetEntity.iconOffset.X != 0.f || targetEntity.iconOffset.Y != 0.f || targetEntity.iconOffset.Z != 0.f ) { compMat = targetEntity.GetLocalToWorld(); targetPos = VecTransform( compMat, targetEntity.iconOffset ); } else { useDrawableComponent = true; } } if ( useDrawableComponent ) { drawableComponentCount = targetEntity.GetComponentsCountByClassName( 'CDrawableComponent' ); if ( drawableComponentCount == 1 ) { // get drawable component only if there is only one drawableComponent = (CDrawableComponent)( targetEntity.GetComponentByClassName( 'CDrawableComponent' ) ); if( drawableComponent ) { drawableComponent.GetObjectBoundingVolume( box ); if ( box.Max.Z > 0 ) { targetPos.Z = box.Max.Z; } else { targetPos.Z += 0.25f; } } } } } else { targetPos = entity.GetWorldPosition(); } } targetPos.Z += extraZ; if ( !theCamera.WorldVectorToViewRatio( targetPos, screenPos.X, screenPos.Y ) ) { if ( noOppositeCamera ) { return false; } GetOppositeCameraScreenPos( targetPos, screenPos.X, screenPos.Y ); } screenPos.X = ( screenPos.X + 1 ) / 2; screenPos.Y = ( screenPos.Y + 1 ) / 2; if ( !normalized ) { screenPos = hud.GetScaleformPoint( screenPos.X, screenPos.Y ); } return true; } function GetOppositeCameraScreenPos( worldPos : Vector, out x : float, out y : float ) { var camera : CCustomCamera; var oppositeCamHeading : float; var playerToTargetHeading : float; var angleDiff : float; camera = (CCustomCamera)theCamera.GetTopmostCameraObject(); oppositeCamHeading = camera.GetHeading() + 180.f; playerToTargetHeading = VecHeading( worldPos - thePlayer.GetWorldPosition() ); angleDiff = AngleDistance( oppositeCamHeading, playerToTargetHeading ); x = -angleDiff/90; y = 1.f; } function IsPointOnScreen( screenPos : Vector ) : bool { return screenPos.X >= 0 && screenPos.X < 1920 && screenPos.Y >= 0 && screenPos.Y < 1080; } //#B DEBUG FUNCTIONS TO REMOVE SOMEDAY exec function showoneliner1( plainText : string ) { var hud : CR4ScriptedHud; if ( thePlayer.moveTarget ) { hud = (CR4ScriptedHud)theGame.GetHud(); hud.ShowOneliner( plainText, thePlayer.moveTarget ); } } exec function hideoneliner1() { var hud : CR4ScriptedHud; if ( thePlayer.moveTarget ) { hud = (CR4ScriptedHud)theGame.GetHud(); hud.HideOneliner( thePlayer.moveTarget ); } } exec function dlgshow() { var hud : CR4ScriptedHud; hud = (CR4ScriptedHud)theGame.GetHud(); hud.OnDialogHudShow(); } exec function dlghide() { var hud : CR4ScriptedHud; hud = (CR4ScriptedHud)theGame.GetHud(); hud.OnDialogHudHide(); } exec function hudinfo() { var hud : CR4ScriptedHud; hud = (CR4ScriptedHud)theGame.GetHud(); hud.__PrintInfo(); } exec function HudConsoleMsg( msgText : string ) { var hud : CR4ScriptedHud; hud = (CR4ScriptedHud)theGame.GetHud(); hud.HudConsoleMsg(msgText); } exec function HudConsoleTest() { var hud : CR4ScriptedHud; hud = (CR4ScriptedHud)theGame.GetHud(); hud.HudConsoleTest(); } exec function HudConsoleCleanup() { var hud : CR4ScriptedHud; hud = (CR4ScriptedHud)theGame.GetHud(); hud.HudConsoleCleanup(); } exec function HudSetDynamic( value : bool ) { var hud : CR4ScriptedHud; hud = (CR4ScriptedHud)theGame.GetHud(); hud.SetDynamic( value ); } exec function HudSetModuleEnabled( moduleName : string,value : bool ) { var hud : CR4ScriptedHud; var module : CR4HudModuleBase; hud = (CR4ScriptedHud)theGame.GetHud(); module = (CR4HudModuleBase)hud.GetHudModule(moduleName); module.SetEnabled(value); hud.UpdateHUD(); } exec function ForceHudScaleRefresh() { var hud : CR4ScriptedHud; hud = (CR4ScriptedHud)theGame.GetHud(); if (hud) { hud.UpdateScaleformStageSize(); hud.UpdateHudScale(); } } /* /** Copyright © 2013-2014 /** Author : Tomasz Czarny /** Tomek Kozera /** Marwin So class CPlayerInput { private saved var actionLocks : array<array<SInputActionLock>>; //locks for actions private var totalCameraPresetChange : float; default totalCameraPresetChange = 0.0f; private var potAction : SInputAction; private var potPress : bool; private var debugBlockSourceName : name; default debugBlockSourceName = 'PLAYER'; private var holdFastMenuInvoked : bool; default holdFastMenuInvoked = false; //to handle touchpad press/hold releases private var potionUpperHeld, potionLowerHeld : bool; //set when potion switch button is being held private var potionModeHold : bool; //set when potion switching mode is set to Hold public function Initialize(isFromLoad : bool, optional previousInput : CPlayerInput) { if(previousInput) { actionLocks = previousInput.actionLocks; } else { if(!isFromLoad) { actionLocks.Grow(EnumGetMax('EInputActionBlock')+1); } } theInput.RegisterListener( this, 'OnCommSprint', 'Sprint' ); theInput.RegisterListener( this, 'OnCommSprintToggle', 'SprintToggle' ); theInput.RegisterListener( this, 'OnCommWalkToggle', 'WalkToggle' ); theInput.RegisterListener( this, 'OnCommGuard', 'Guard' ); // horse theInput.RegisterListener( this, 'OnCommSpawnHorse', 'SpawnHorse' ); //potions //theInput.RegisterListener( this, 'OnCommDrinkPot', 'DrinkPotion' ); -not used anymore, handles one on tap and second on double tap theInput.RegisterListener( this, 'OnCommDrinkPotion1', 'DrinkPotion1' ); theInput.RegisterListener( this, 'OnCommDrinkPotion2', 'DrinkPotion2' ); //weapon draw/sheathe theInput.RegisterListener( this, 'OnCommSteelSword', 'SteelSword' ); theInput.RegisterListener( this, 'OnCommSilverSword', 'SilverSword' ); theInput.RegisterListener( this, 'OnCommSheatheAny', 'SwordSheathe' ); theInput.RegisterListener( this, 'OnCommSheatheSilver', 'SwordSheatheSilver' ); theInput.RegisterListener( this, 'OnCommSheatheSteel', 'SwordSheatheSteel' ); theInput.RegisterListener( this, 'OnToggleSigns', 'ToggleSigns' ); theInput.RegisterListener( this, 'OnSelectSign', 'SelectAard' ); theInput.RegisterListener( this, 'OnSelectSign', 'SelectYrden' ); theInput.RegisterListener( this, 'OnSelectSign', 'SelectIgni' ); theInput.RegisterListener( this, 'OnSelectSign', 'SelectQuen' ); theInput.RegisterListener( this, 'OnSelectSign', 'SelectAxii' ); //character panels theInput.RegisterListener( this, 'OnCommDeckEditor', 'PanelGwintDeckEditor' ); theInput.RegisterListener( this, 'OnCommMenuHub', 'HubMenu' ); theInput.RegisterListener( this, 'OnCommPanelInv', 'PanelInv' ); theInput.RegisterListener( this, 'OnCommHoldFastMenu', 'HoldFastMenu' ); theInput.RegisterListener( this, 'OnCommPanelChar', 'PanelChar' ); theInput.RegisterListener( this, 'OnCommPanelMed', 'PanelMed' ); theInput.RegisterListener( this, 'OnCommPanelMap', 'PanelMap' ); theInput.RegisterListener( this, 'OnCommPanelMapPC', 'PanelMapPC' ); theInput.RegisterListener( this, 'OnCommPanelJour', 'PanelJour' ); theInput.RegisterListener( this, 'OnCommPanelAlch', 'PanelAlch' ); theInput.RegisterListener( this, 'OnCommPanelGlossary', 'PanelGlossary' ); theInput.RegisterListener( this, 'OnCommPanelBestiary', 'PanelBestiary' ); theInput.RegisterListener( this, 'OnCommPanelMeditation', 'PanelMeditation' ); theInput.RegisterListener( this, 'OnCommPanelCrafting', 'PanelCrafting' ); theInput.RegisterListener( this, 'OnShowControlsHelp', 'ControlsHelp' ); theInput.RegisterListener( this, 'OnCommPanelUIResize', 'PanelUIResize' ); theInput.RegisterListener( this, 'OnCastSign', 'CastSign' ); theInput.RegisterListener( this, 'OnExpFocus', 'Focus' ); theInput.RegisterListener( this, 'OnExpMedallion', 'Medallion' ); //boat theInput.RegisterListener( this, 'OnBoatDismount', 'BoatDismount' ); theInput.RegisterListener( this, 'OnDiving', 'DiveDown' ); theInput.RegisterListener( this, 'OnDiving', 'DiveUp' ); theInput.RegisterListener( this, 'OnDivingDodge', 'DiveDodge' ); // PC only theInput.RegisterListener( this, 'OnCbtSpecialAttackWithAlternateLight', 'SpecialAttackWithAlternateLight' ); theInput.RegisterListener( this, 'OnCbtSpecialAttackWithAlternateHeavy', 'SpecialAttackWithAlternateHeavy' ); theInput.RegisterListener( this, 'OnCbtAttackWithAlternateLight', 'AttackWithAlternateLight' ); theInput.RegisterListener( this, 'OnCbtAttackWithAlternateHeavy', 'AttackWithAlternateHeavy' ); theInput.RegisterListener( this, 'OnCbtAttackLight', 'AttackLight' ); theInput.RegisterListener( this, 'OnCbtAttackHeavy', 'AttackHeavy' ); theInput.RegisterListener( this, 'OnCbtSpecialAttackLight', 'SpecialAttackLight' ); theInput.RegisterListener( this, 'OnCbtSpecialAttackHeavy', 'SpecialAttackHeavy' ); theInput.RegisterListener( this, 'OnCbtDodge', 'Dodge' ); theInput.RegisterListener( this, 'OnCbtRoll', 'CbtRoll' ); theInput.RegisterListener( this, 'OnMovementDoubleTap', 'MovementDoubleTapW' ); theInput.RegisterListener( this, 'OnMovementDoubleTap', 'MovementDoubleTapS' ); theInput.RegisterListener( this, 'OnMovementDoubleTap', 'MovementDoubleTapA' ); theInput.RegisterListener( this, 'OnMovementDoubleTap', 'MovementDoubleTapD' ); theInput.RegisterListener( this, 'OnCbtLockAndGuard', 'LockAndGuard' ); theInput.RegisterListener( this, 'OnCbtCameraLockOrSpawnHorse', 'CameraLockOrSpawnHorse' ); theInput.RegisterListener( this, 'OnCbtCameraLock', 'CameraLock' ); theInput.RegisterListener( this, 'OnCbtComboDigitLeft', 'ComboDigitLeft' ); theInput.RegisterListener( this, 'OnCbtComboDigitRight', 'ComboDigitRight' ); // Ciri theInput.RegisterListener( this, 'OnCbtCiriSpecialAttack', 'CiriSpecialAttack' ); theInput.RegisterListener( this, 'OnCbtCiriAttackHeavy', 'CiriAttackHeavy' ); theInput.RegisterListener( this, 'OnCbtCiriSpecialAttackHeavy', 'CiriSpecialAttackHeavy' ); theInput.RegisterListener( this, 'OnCbtCiriDodge', 'CiriDodge' ); theInput.RegisterListener( this, 'OnCbtCiriDash', 'CiriDash' ); //throwing items, casting signs theInput.RegisterListener( this, 'OnCbtThrowItem', 'ThrowItem' ); theInput.RegisterListener( this, 'OnCbtThrowItemHold', 'ThrowItemHold' ); theInput.RegisterListener( this, 'OnCbtThrowCastAbort', 'ThrowCastAbort' ); //replacer only theInput.RegisterListener( this, 'OnCiriDrawWeapon', 'CiriDrawWeapon' ); theInput.RegisterListener( this, 'OnCiriDrawWeapon', 'CiriDrawWeaponAlternative' ); theInput.RegisterListener( this, 'OnCiriHolsterWeapon', 'CiriHolsterWeapon' ); //debug if( !theGame.IsFinalBuild() ) { theInput.RegisterListener( this, 'OnDbgSpeedUp', 'Debug_SpeedUp' ); theInput.RegisterListener( this, 'OnDbgHit', 'Debug_Hit' ); theInput.RegisterListener( this, 'OnDbgKillTarget', 'Debug_KillTarget' ); theInput.RegisterListener( this, 'OnDbgKillAll', 'Debug_KillAllEnemies' ); theInput.RegisterListener( this, 'OnDbgKillAllTargetingPlayer', 'Debug_KillAllTargetingPlayer' ); theInput.RegisterListener( this, 'OnDbgResurrectPlayer', 'Debug_Resurrect' ); theInput.RegisterListener( this, 'OnCommPanelFakeHud', 'PanelFakeHud' ); } // other theInput.RegisterListener( this, 'OnChangeCameraPreset', 'CameraPreset' ); theInput.RegisterListener( this, 'OnChangeCameraPresetByMouseWheel', 'CameraPresetByMouseWheel' ); theInput.RegisterListener( this, 'OnMeditationAbort', 'MeditationAbort'); theInput.RegisterListener( this, 'OnFastMenu', 'FastMenu' ); theInput.RegisterListener( this, 'OnIngameMenu', 'IngameMenu' ); // AutoLoot mod added theInput.RegisterListener( this, 'OnAutoLootRadiusLoot', 'AutoLootRadius' ); } // curently unused function Destroy() { } /////////////////////////// // Action blocking /////////////////////////// public function FindActionLockIndex(action : EInputActionBlock, sourceName : name) : int { var i : int; for(i=0; i<actionLocks[action].Size(); i+=1) if(actionLocks[action][i].sourceName == sourceName) return i; return -1; } // function to (un)block given input actions public function BlockAction(action : EInputActionBlock, sourceName : name, lock : bool, optional keepOnSpawn : bool, optional playerPointer : CPlayer, optional isFromQuest : bool, optional isFromPlace : bool) { var index : int; var isLocked, wasLocked : bool; var actionLock : SInputActionLock; if (action == EIAB_HighlightObjective) { index = FindActionLockIndex(action, sourceName); } index = FindActionLockIndex(action, sourceName); wasLocked = (actionLocks[action].Size() > 0); if(lock) { if(index != -1) return; actionLock.sourceName = sourceName; actionLock.removedOnSpawn = !keepOnSpawn; actionLock.isFromQuest = isFromQuest; actionLock.isFromPlace = isFromPlace; actionLocks[action].PushBack(actionLock); } else { if(index == -1) return; actionLocks[action].Erase(index); } isLocked = (actionLocks[action].Size() > 0); if(isLocked != wasLocked) OnActionLockChanged(action, isLocked, sourceName, playerPointer); } //For toxic gas tutorial - we MUST open radial then so ALL locks are released public final function TutorialForceUnblockRadial() : array<SInputActionLock> { var ret : array<SInputActionLock>; ret = actionLocks[EIAB_RadialMenu]; actionLocks[EIAB_RadialMenu].Clear(); thePlayer.SetBIsInputAllowed(true, ''); BlockAction( EIAB_Signs, 'ToxicGasTutorial', true, true, NULL, false); return ret; } //Toxic tutorial restoring of radial open locks public final function TutorialForceRestoreRadialLocks(radialLocks : array<SInputActionLock>) { actionLocks[EIAB_RadialMenu] = radialLocks; thePlayer.UnblockAction(EIAB_Signs, 'ToxicGasTutorial' ); } private function OnActionLockChanged(action : EInputActionBlock, locked : bool, optional sourceName : name, optional playerPointer : CPlayer) { var player : CPlayer; var lockType : EPlayerInteractionLock; var hud : CR4ScriptedHud; var guiManager : CR4GuiManager; var rootMenu : CR4MenuBase; // ED: Submited this to catch unknown blocking sources if( sourceName == debugBlockSourceName ) { // Put a breakpoint here: sourceName = sourceName; } //custom stuff if(action == EIAB_FastTravel) { theGame.GetCommonMapManager().EnableFastTravelling(!locked); } else if(action == EIAB_Interactions) { //set lock flag if(sourceName == 'InsideCombatAction') lockType = PIL_CombatAction; else lockType = PIL_Default; if(!thePlayer) player = playerPointer; else player = thePlayer; if(player) { if(locked) player.LockButtonInteractions(lockType); else player.UnlockButtonInteractions(lockType); } //update interactions after flag change hud = (CR4ScriptedHud)theGame.GetHud(); if ( hud ) { hud.ForceInteractionUpdate(); } } else if(action == EIAB_Movement && locked && thePlayer) //no thePlayer on session start { //if we block movement then force Idle state, unless you are in air (jumping) - in that case wait for touch down and then force it if(thePlayer.IsUsingVehicle() && thePlayer.GetCurrentStateName() == 'HorseRiding') { ((CActor)thePlayer.GetUsedVehicle()).GetMovingAgentComponent().ResetMoveRequests(); thePlayer.GetUsedVehicle().SetBehaviorVariable( '2idle', 1); thePlayer.SetBehaviorVariable( 'speed', 0); thePlayer.SetBehaviorVariable( '2idle', 1); } else if(!thePlayer.IsInAir()) { thePlayer.RaiseForceEvent( 'Idle' ); } } else if (action == EIAB_DismountVehicle) { guiManager = theGame.GetGuiManager(); if (guiManager) { guiManager.UpdateDismountAvailable(locked); } } else if (action == EIAB_OpenPreparation || action == EIAB_OpenMap || action == EIAB_OpenInventory || action == EIAB_OpenJournal || action == EIAB_OpenCharacterPanel || action == EIAB_OpenGlossary || action == EIAB_OpenAlchemy || action == EIAB_MeditationWaiting || action == EIAB_OpenMeditation) { guiManager = theGame.GetGuiManager(); if (guiManager && guiManager.IsAnyMenu()) { rootMenu = (CR4MenuBase)guiManager.GetRootMenu(); if (rootMenu) { rootMenu.ActionBlockStateChange(action, locked); } } } } public function BlockAllActions(sourceName : name, lock : bool, optional exceptions : array<EInputActionBlock>, optional saveLock : bool, optional playerPointer : CPlayer, optional isFromQuest : bool, optional isFromPlace : bool) { var i, size : int; size = EnumGetMax('EInputActionBlock')+1; for(i=0; i<size; i+=1) { if ( exceptions.Contains(i) ) continue; BlockAction(i, sourceName, lock, saveLock, playerPointer, isFromQuest, isFromPlace); } } //blocking all actions from all quest sources regardless of source public final function BlockAllQuestActions(sourceName : name, lock : bool) { var action, j, size : int; var isLocked, wasLocked : bool; if(lock) { //block works as regular block BlockAllActions(sourceName, lock, , true, , true); } else { //release all quest locks, regardless of sourceName size = EnumGetMax('EInputActionBlock')+1; for(action=0; action<size; action+=1) { wasLocked = (actionLocks[action].Size() > 0); for(j=0; j<actionLocks[action].Size();) { if(actionLocks[action][j].isFromQuest) { actionLocks[action].EraseFast(j); } else { j += 1; } } isLocked = (actionLocks[action].Size() > 0); if(wasLocked != isLocked) OnActionLockChanged(action, isLocked); } } } //blocking all UI actions from all quest sources regardless of source public function BlockAllUIQuestActions(sourceName : name, lock : bool) { var i, j, action, size : int; var uiActions : array<int>; var wasLocked, isLocked : bool; if( lock ) { BlockAction(EIAB_OpenInventory, sourceName, true, true, NULL, false); BlockAction(EIAB_MeditationWaiting, sourceName, true, true, NULL, false); BlockAction(EIAB_OpenMeditation, sourceName, true, true, NULL, false); BlockAction(EIAB_FastTravel, sourceName, true, true, NULL, false); BlockAction(EIAB_OpenMap, sourceName, true, true, NULL, false); BlockAction(EIAB_OpenCharacterPanel, sourceName, true, true, NULL, false); BlockAction(EIAB_OpenJournal, sourceName, true, true, NULL, false); BlockAction(EIAB_OpenAlchemy, sourceName, true, true, NULL, false); } else { //release all quest locks, regardless of sourceName uiActions.Resize(8); uiActions[0] = EIAB_OpenInventory; uiActions[1] = EIAB_MeditationWaiting; uiActions[2] = EIAB_OpenMeditation; uiActions[3] = EIAB_FastTravel; uiActions[4] = EIAB_OpenMap; uiActions[5] = EIAB_OpenCharacterPanel; uiActions[6] = EIAB_OpenJournal; uiActions[7] = EIAB_OpenAlchemy; size = uiActions.Size(); for(i=0; i<size; i+=1) { action = uiActions[i]; wasLocked = (actionLocks[action].Size() > 0); for(j=0; j<actionLocks[action].Size();) { if(actionLocks[action][j].isFromQuest) { actionLocks[action].EraseFast(j); } else { j += 1; } } isLocked = (actionLocks[action].Size() > 0); if(wasLocked != isLocked) OnActionLockChanged(action, isLocked); } } } //forces releas of all action blocks public function ForceUnlockAllInputActions(alsoQuestLocks : bool) { var i, j : int; for(i=0; i<=EnumGetMax('EInputActionBlock'); i+=1) { if(alsoQuestLocks) { actionLocks[i].Clear(); OnActionLockChanged(i, false); } else { for(j=actionLocks[i].Size()-1; j>=0; j-=1) { if(actionLocks[i][j].removedOnSpawn) actionLocks[i].Erase(j); } if(actionLocks[i].Size() == 0) OnActionLockChanged(i, false); } } } public function RemoveLocksOnSpawn() { var i, j : int; for(i=0; i<actionLocks.Size(); i+=1) { for(j=actionLocks[i].Size()-1; j>=0; j-=1) { if(actionLocks[i][j].removedOnSpawn) { actionLocks[i].Erase(j); } } } } public function GetActionLocks(action : EInputActionBlock) : array< SInputActionLock > { return actionLocks[action]; } public function GetAllActionLocks() : array< array< SInputActionLock > > { return actionLocks; } public function IsActionAllowed(action : EInputActionBlock) : bool { var actionAllowed : bool; actionAllowed = (actionLocks[action].Size() == 0); return actionAllowed; } public function IsActionBlockedBy( action : EInputActionBlock, sourceName : name ) : bool { return FindActionLockIndex( action, sourceName ) != -1; } public final function GetActionBlockedHudLockType(action : EInputActionBlock) : name { var i : int; if(action == EIAB_Undefined) return ''; for(i=0; i<actionLocks[action].Size(); i+=1) { if(actionLocks[action][i].isFromPlace) return 'place'; } if(actionLocks[action].Size() > 0) return 'time'; return ''; } /////////////////////////// // Common Inputs /////////////////////////// event OnCommSprint( action : SInputAction ) { if( IsPressed( action ) ) { thePlayer.SetSprintActionPressed(true); if ( thePlayer.rangedWeapon ) thePlayer.rangedWeapon.OnSprintHolster(); } /*if( thePlayer.CanFollowNpc() ) { if( IsPressed( action ) ) { if( VecDistanceSquared( thePlayer.GetWorldPosition(), thePlayer.GetActorToFollow().GetWorldPosition() ) < 25.0 ) { thePlayer.FollowActor( thePlayer.GetActorToFollow() ); } else { thePlayer.SignalGameplayEvent( 'StopPlayerAction' ); thePlayer.SetCanFollowNpc( false, NULL ); } } else if( IsReleased( action ) ) { thePlayer.SignalGameplayEvent( 'StopPlayerAction' ); thePlayer.SetCanFollowNpc( false, NULL ); } }*/ event OnCommSprintToggle( action : SInputAction ) { if( IsPressed(action) ) { if ( thePlayer.GetIsSprintToggled() ) thePlayer.SetSprintToggle( false ); else thePlayer.SetSprintToggle( true ); } } event OnCommWalkToggle( action : SInputAction ) { if( IsPressed(action) && !thePlayer.GetIsSprinting() && !thePlayer.modifyPlayerSpeed ) { if ( thePlayer.GetIsWalkToggled() ) thePlayer.SetWalkToggle( false ); else thePlayer.SetWalkToggle( true ); } } event OnCommGuard( action : SInputAction ) { if(thePlayer.IsCiri() && !GetCiriPlayer().HasSword()) return false; if ( !thePlayer.IsInsideInteraction() ) { if ( IsActionAllowed(EIAB_Parry) ) { if( IsReleased(action) && thePlayer.GetCurrentStateName() == 'CombatFists' ) thePlayer.OnGuardedReleased(); if( IsPressed(action) ) { thePlayer.AddCounterTimeStamp(theGame.GetEngineTime()); //cache counter button press to further check counter button spamming by the thePlayer thePlayer.SetGuarded(true); thePlayer.OnPerformGuard(); } else if( IsReleased(action) ) { thePlayer.SetGuarded(false); } } else { thePlayer.DisplayActionDisallowedHudMessage(EIAB_Parry); } } } /////////////////////////// // Horse /////////////////////////// private var pressTimestamp : float; private const var DOUBLE_TAP_WINDOW : float; default DOUBLE_TAP_WINDOW = 0.4; event OnCommSpawnHorse( action : SInputAction ) { var doubleTap : bool; if( IsPressed( action ) ) { if( pressTimestamp + DOUBLE_TAP_WINDOW >= theGame.GetEngineTimeAsSeconds() ) { doubleTap = true; } else { doubleTap = false; } if( IsActionAllowed( EIAB_CallHorse ) && !thePlayer.IsInInterior() && !thePlayer.IsInAir() ) { if( doubleTap || theInput.LastUsedPCInput() ) { if ( thePlayer.IsHoldingItemInLHand () ) { thePlayer.OnUseSelectedItem(true); thePlayer.SetPlayerActionToRestore ( PATR_CallHorse ); } else { theGame.OnSpawnPlayerHorse(); } } } else { if( thePlayer.IsInInterior() ) thePlayer.DisplayActionDisallowedHudMessage( EIAB_Undefined, false, true ); else thePlayer.DisplayActionDisallowedHudMessage( EIAB_CallHorse ); } pressTimestamp = theGame.GetEngineTimeAsSeconds(); return true; } return false; } /////////////////////////// // Opening UI Panels /////////////////////////// // MenuHub (aka commonmenu.ws) event OnCommMenuHub( action : SInputAction ) { if(IsReleased(action)) { PushMenuHub(); } } final function PushMenuHub() { if ( theGame.IsBlackscreenOrFading() ) { return; } theGame.RequestMenu('CommonMenu'); } //Character screen event OnCommPanelChar( action : SInputAction ) { if(IsReleased(action)) { PushCharacterScreen(); } } final function PushCharacterScreen() { if ( theGame.IsBlackscreenOrFading() ) { return; } theGame.RequestMenuWithBackground( 'CharacterMenu', 'CommonMenu' ); } //Inventory screen event OnCommPanelInv( action : SInputAction ) { if (IsReleased(action)) { PushInventoryScreen(); } } final function PushInventoryScreen() { if ( theGame.IsBlackscreenOrFading() ) { return; } if( IsActionAllowed(EIAB_OpenInventory) ) { theGame.RequestMenuWithBackground( 'InventoryMenu', 'CommonMenu' ); } else { thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenInventory); } } //Gwint screen event OnCommDeckEditor( action : SInputAction ) { if( IsReleased(action) ) { if ( theGame.IsBlackscreenOrFading() ) { return false; } if (theGame.GetGwintManager().GetHasDoneTutorial() || theGame.GetGwintManager().HasLootedCard()) { if( IsActionAllowed(EIAB_OpenGwint) ) { theGame.RequestMenu( 'DeckBuilder' ); } else { thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenGwint); } } } } //Meditation screen event OnCommPanelMed( action : SInputAction ) { if( IsReleased(action) ) { if( IsActionAllowed(EIAB_MeditationWaiting) ) { GetWitcherPlayer().Meditate(); } else { thePlayer.DisplayActionDisallowedHudMessage(EIAB_MeditationWaiting); } } } event OnCommPanelMapPC( action : SInputAction ) { if( IsReleased(action) ) { PushMapScreen(); } } //Map screen event OnCommPanelMap( action : SInputAction ) { if( IsPressed(action) ) { PushMapScreen(); } } final function PushMapScreen() { if ( theGame.IsBlackscreenOrFading() ) { return; } if( IsActionAllowed(EIAB_OpenMap) ) { theGame.RequestMenuWithBackground( 'MapMenu', 'CommonMenu' ); } else { thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenMap); } } //Journal screen event OnCommPanelJour( action : SInputAction ) { if( IsReleased(action) ) { PushJournalScreen(); } } final function PushJournalScreen() { if ( theGame.IsBlackscreenOrFading() ) { return; } if( IsActionAllowed(EIAB_OpenJournal) ) { //theGame.RequestMenu( 'QuestListMenu' ); theGame.RequestMenuWithBackground( 'JournalQuestMenu', 'CommonMenu' ); } else { thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenJournal); } } event OnCommPanelMeditation( action : SInputAction ) { if( IsReleased(action) ) { PushMeditationScreen(); } } final function PushMeditationScreen() { if ( theGame.IsBlackscreenOrFading() ) { return; } if( IsActionAllowed(EIAB_OpenMeditation) ) { theGame.RequestMenuWithBackground( 'MeditationClockMenu', 'CommonMenu' ); } else { thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenMeditation); } } event OnCommPanelCrafting( action : SInputAction ) { if( IsReleased(action) ) { PushCraftingScreen(); } } final function PushCraftingScreen() { if ( theGame.IsBlackscreenOrFading() ) { return; } theGame.RequestMenuWithBackground( 'CraftingMenu', 'CommonMenu' ); } //Bestiary screen event OnCommPanelBestiary( action : SInputAction ) { if( IsReleased(action) ) { PushBestiaryScreen(); } } final function PushBestiaryScreen() { if ( theGame.IsBlackscreenOrFading() ) { return; } if( IsActionAllowed(EIAB_OpenGlossary) ) { theGame.RequestMenuWithBackground( 'GlossaryBestiaryMenu', 'CommonMenu' ); } else { thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenGlossary); } } //Alchemy screen event OnCommPanelAlch( action : SInputAction ) { if( IsReleased(action) ) { PushAlchemyScreen(); } } final function PushAlchemyScreen() { if ( theGame.IsBlackscreenOrFading() ) { return; } if( IsActionAllowed(EIAB_OpenAlchemy) ) { theGame.RequestMenuWithBackground( 'AlchemyMenu', 'CommonMenu' ); } else { thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenAlchemy); } } //Alchemy screen event OnCommPanelGlossary( action : SInputAction ) { if( IsReleased(action) ) { PushGlossaryScreen(); } } final function PushGlossaryScreen() { if ( theGame.IsBlackscreenOrFading() ) { return; } if( IsActionAllowed(EIAB_OpenGlossary) ) { theGame.RequestMenuWithBackground( 'GlossaryEncyclopediaMenu', 'CommonMenu' ); } else { thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenGlossary); } } event OnShowControlsHelp( action : SInputAction ) { if( IsReleased(action) ) { if ( theGame.IsBlackscreenOrFading() ) { return false; } //theGame.RequestMenu( 'ControlsHelp' ); //theGame.RequestMenu( 'JournalQuestMenu' ); } } event OnCommPanelUIResize( action : SInputAction ) { if( IsReleased(action) ) { if ( theGame.IsBlackscreenOrFading() ) { return false; } theGame.RequestMenu( 'RescaleMenu' ); } } event OnCommPanelFakeHud( action : SInputAction ) { if( IsReleased(action) ) { if ( theGame.IsBlackscreenOrFading() ) { return false; } //theGame.RequestMenu( 'FakeHudMenu' ); } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////// WEAPON DRAW /////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private var processedSwordHold : bool; event OnCommSteelSword( action : SInputAction ) { var duringCastSign : bool; if(IsPressed(action)) processedSwordHold = false; if ( theInput.LastUsedGamepad() && theInput.IsActionPressed('Alternate') ) { return false; } if ( IsReleased(action) || ( IsPressed(action) && (thePlayer.GetCurrentMeleeWeaponType() == PW_None || thePlayer.GetCurrentMeleeWeaponType() == PW_Fists) ) ) { if( !processedSwordHold ) { if ( IsActionAllowed(EIAB_DrawWeapon) && thePlayer.GetBIsInputAllowed() && thePlayer.GetWeaponHolster().IsMeleeWeaponReady() ) { thePlayer.PushCombatActionOnBuffer( EBAT_Draw_Steel, BS_Pressed ); if ( thePlayer.GetBIsCombatActionAllowed() ) thePlayer.ProcessCombatActionBuffer(); } processedSwordHold = true; } } } event OnCommSilverSword( action : SInputAction ) { var duringCastSign : bool; if( IsPressed(action) ) processedSwordHold = false; if ( theInput.LastUsedGamepad() && theInput.IsActionPressed('Alternate') ) { return false; } if ( IsReleased(action) || ( IsPressed(action) && (thePlayer.GetCurrentMeleeWeaponType() == PW_None || thePlayer.GetCurrentMeleeWeaponType() == PW_Fists) ) ) { if( !processedSwordHold ) { if ( IsActionAllowed(EIAB_DrawWeapon) && thePlayer.GetBIsInputAllowed() && thePlayer.GetWeaponHolster().IsMeleeWeaponReady() ) { thePlayer.PushCombatActionOnBuffer( EBAT_Draw_Silver, BS_Pressed ); if ( thePlayer.GetBIsCombatActionAllowed() || duringCastSign ) thePlayer.ProcessCombatActionBuffer(); } processedSwordHold = true; } } } event OnCommSheatheAny( action : SInputAction ) { var duringCastSign : bool; if( IsPressed( action ) ) { if ( thePlayer.GetBIsInputAllowed() && thePlayer.GetWeaponHolster().IsMeleeWeaponReady() ) { thePlayer.PushCombatActionOnBuffer( EBAT_Sheathe_Sword, BS_Pressed ); if ( thePlayer.GetBIsCombatActionAllowed() || duringCastSign ) { thePlayer.ProcessCombatActionBuffer(); } } processedSwordHold = true; } } event OnCommSheatheSteel( action : SInputAction ) { if( IsPressed( action ) && thePlayer.IsWeaponHeld( 'steelsword' ) && !processedSwordHold) { OnCommSheatheAny(action); } } event OnCommSheatheSilver( action : SInputAction ) { if( IsPressed( action ) && thePlayer.IsWeaponHeld( 'silversword' ) && !processedSwordHold) { OnCommSheatheAny(action); } } event OnCommDrinkPot( action : SInputAction ) { if(IsPressed(action)) { if(!potPress) { potPress = true; potAction = action; thePlayer.AddTimer('PotDrinkTimer', 0.3); } else { PotDrinkTimer(true); thePlayer.RemoveTimer('PotDrinkTimer'); } } } public function PotDrinkTimer(isDoubleTapped : bool) { thePlayer.RemoveTimer('PotDrinkTimer'); potPress = false; if(isDoubleTapped) OnCommDrinkPotion2(potAction); else OnCommDrinkPotion1(potAction); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// event OnCbtComboDigitLeft( action : SInputAction ) { if ( theInput.IsActionPressed('Alternate') ) { OnTogglePreviousSign(action); } } event OnCbtComboDigitRight( action : SInputAction ) { if ( theInput.IsActionPressed('Alternate') ) { OnToggleNextSign(action); } } event OnSelectSign(action : SInputAction) { if( IsPressed( action ) ) { switch( action.aName ) { case 'SelectAard' : GetWitcherPlayer().SetEquippedSign(ST_Aard); break; case 'SelectYrden' : GetWitcherPlayer().SetEquippedSign(ST_Yrden); break; case 'SelectIgni' : GetWitcherPlayer().SetEquippedSign(ST_Igni); break; case 'SelectQuen' : GetWitcherPlayer().SetEquippedSign(ST_Quen); break; case 'SelectAxii' : GetWitcherPlayer().SetEquippedSign(ST_Axii); break; default : break; } } } event OnToggleSigns( action : SInputAction ) { var tolerance : float; tolerance = 2.5f; if( action.value < -tolerance ) { GetWitcherPlayer().TogglePreviousSign(); } else if( action.value > tolerance ) { GetWitcherPlayer().ToggleNextSign(); } } event OnToggleNextSign( action : SInputAction ) { if( IsPressed( action ) ) { GetWitcherPlayer().ToggleNextSign(); } } event OnTogglePreviousSign( action : SInputAction ) { if( IsPressed( action ) ) { GetWitcherPlayer().TogglePreviousSign(); } } event OnToggleItem( action : SInputAction ) { if( !IsActionAllowed( EIAB_QuickSlots ) ) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_QuickSlots); return false; } if( IsReleased( action ) ) { if( theInput.GetLastActivationTime( action.aName ) < 0.3 ) GetWitcherPlayer().ToggleNextItem(); } } /////////////////////////// // Potions /////////////////////////// { var witcher : W3PlayerWitcher; var item : SItemUniqueId; //requested hack for Ciri using Geralt's input context if(thePlayer.IsCiri()) return false; if( !IsActionAllowed( EIAB_QuickSlots ) ) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_QuickSlots); return false; //requested hack for Ciri using Geralt's input context } if ( IsPressed(action) ) { witcher = GetWitcherPlayer(); witcher.GetItemEquippedOnSlot(EES_Potion1, item); if(witcher.inv.ItemHasTag(item, 'Edibles')) { witcher.ConsumeItem( item ); } else { if (witcher.ToxicityLowEnoughToDrinkPotion( EES_Potion1 )) { witcher.DrinkPreparedPotion( EES_Potion1 ); } else { SendToxicityTooHighMessage(); } } ShowItemInfo(); } //upper left slot //requested hack for Ciri using Geralt's input context } //lower left slot event OnCommDrinkPotion2( action : SInputAction ) { var witcher : W3PlayerWitcher; var item : SItemUniqueId; //requested hack for Ciri using Geralt's input context if(thePlayer.IsCiri()) return false; if( !IsActionAllowed( EIAB_QuickSlots ) ) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_QuickSlots); return false; } if ( IsPressed(action) ) { witcher = GetWitcherPlayer(); witcher.GetItemEquippedOnSlot(EES_Potion2, item); if(witcher.inv.ItemHasTag(item, 'Edibles')) { witcher.ConsumeItem( item ); } else { if (witcher.ToxicityLowEnoughToDrinkPotion( EES_Potion2 )) { witcher.DrinkPreparedPotion( EES_Potion2 ); } else { SendToxicityTooHighMessage(); } } ShowItemInfo(); } //upper right slot private function SendToxicityTooHighMessage() { //requested hack for Ciri using Geralt's input context var language : string; var audioLanguage : string; if (thePlayer.GetHudMessagesSize() < 2) { messageText = GetLocStringByKeyExt("menu_cannot_perform_action_now") + " " + GetLocStringByKeyExt("panel_common_statistics_tooltip_current_toxicity"); theGame.GetGameLanguageName(audioLanguage,language); if (language == "AR") { messageText += (int)(thePlayer.abilityManager.GetStat(BCS_Toxicity, false)) + " / " + (int)(thePlayer.abilityManager.GetStatMax(BCS_Toxicity)) + " :"; } else { messageText += ": " + (int)(thePlayer.abilityManager.GetStat(BCS_Toxicity, false)) + " / " + (int)(thePlayer.abilityManager.GetStatMax(BCS_Toxicity)); } thePlayer.DisplayHudMessage(messageText); } theSound.SoundEvent("gui_global_denied"); } //lower right slot { var hud : CR4ScriptedHud; var module : CR4HudModuleItemInfo; //requested hack for Ciri using Geralt's input context if ( hud ) { module = (CR4HudModuleItemInfo)hud.GetHudModule("ItemInfoModule"); if( module ) { module.ForceShowElement(); } } } /////////////////////////// // Exploration Inputs /////////////////////////// event OnDiving( action : SInputAction ) { if ( IsPressed(action) && IsActionAllowed(EIAB_Dive) ) { if ( action.aName == 'DiveDown' ) { if ( thePlayer.OnAllowedDiveDown() ) { if ( !thePlayer.OnCheckDiving() ) thePlayer.OnDive(); if ( thePlayer.bLAxisReleased ) thePlayer.SetBehaviorVariable( 'divePitch',-1.0); else thePlayer.SetBehaviorVariable( 'divePitch', -0.9); thePlayer.OnDiveInput(-1.f); if ( thePlayer.rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' ) { thePlayer.OnRangedForceHolster( true, false ); thePlayer.OnFullyBlendedIdle(); } } } else if ( action.aName == 'DiveUp' ) { if ( thePlayer.bLAxisReleased ) thePlayer.SetBehaviorVariable( 'divePitch',1.0); else thePlayer.SetBehaviorVariable( 'divePitch', 0.9); if ( thePlayer.rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' ) { thePlayer.OnRangedForceHolster( true, false ); thePlayer.OnFullyBlendedIdle(); } thePlayer.OnDiveInput(1.f); } } else if ( IsReleased(action) ) { thePlayer.SetBehaviorVariable( 'divePitch',0.0); thePlayer.OnDiveInput(0.f); } else if ( IsPressed(action) && !IsActionAllowed(EIAB_Dive) ) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_Dive); } } event OnDivingDodge( action : SInputAction ) { var isDodgeAllowed : bool; if( IsPressed(action) ) { isDodgeAllowed = IsActionAllowed(EIAB_Dodge); if( isDodgeAllowed && IsActionAllowed(EIAB_Dive) ) { if ( thePlayer.OnCheckDiving() && thePlayer.GetBIsInputAllowed() ) { thePlayer.PushCombatActionOnBuffer( EBAT_Dodge, BS_Pressed ); if ( thePlayer.GetBIsCombatActionAllowed() ) thePlayer.ProcessCombatActionBuffer(); } } else { if(!isDodgeAllowed) thePlayer.DisplayActionDisallowedHudMessage(EIAB_Dodge); else thePlayer.DisplayActionDisallowedHudMessage(EIAB_Dive); } } } /* Redundant with OnCbtCameraLockOrSpawnHorse event OnExpSpawnHorse( action : SInputAction ) { var test : bool = false; if( IsPressed(action) && IsActionAllowed(EIAB_CallHorse)) { test = false; //thePlayer.OnSpawnHorse(); } } */ /*event OnMountHorse( action : SInputAction ) { if( IsPressed( action ) ) { if( thePlayer.IsMountingHorseAllowed() ) { thePlayer.OnVehicleInteraction( (CVehicleComponent)thePlayer.horseInteractionSource.GetComponentByClassName( 'CVehicleComponent' ) ); } } }*/ event OnExpFistFightLight( action : SInputAction ) { var fistsAllowed : bool; if( IsPressed(action) ) { fistsAllowed = IsActionAllowed(EIAB_Fists); if( fistsAllowed && IsActionAllowed(EIAB_LightAttacks) ) { //thePlayer.PrepareToAttack( ); thePlayer.SetupCombatAction( EBAT_LightAttack, BS_Pressed ); } else { if(!fistsAllowed) thePlayer.DisplayActionDisallowedHudMessage(EIAB_Fists); else thePlayer.DisplayActionDisallowedHudMessage(EIAB_LightAttacks); } } } event OnExpFistFightHeavy( action : SInputAction ) { var fistsAllowed : bool; if( IsPressed(action) ) { fistsAllowed = IsActionAllowed(EIAB_Fists); if( fistsAllowed && IsActionAllowed(EIAB_HeavyAttacks) ) { //thePlayer.PrepareToAttack( ); thePlayer.SetupCombatAction( EBAT_HeavyAttack, BS_Pressed ); } else { if(!fistsAllowed) thePlayer.DisplayActionDisallowedHudMessage(EIAB_Fists); else thePlayer.DisplayActionDisallowedHudMessage(EIAB_HeavyAttacks); } } } /* event OnExpMedallion( action : SInputAction ) { if(IsActionAllowed(EIAB_ExplorationFocus)) { if( IsPressed( action ) ) { thePlayer.MedallionPing(); } } } */ event OnExpFocus( action : SInputAction ) { if(IsActionAllowed(EIAB_ExplorationFocus)) { if( IsPressed( action ) ) { // Let's turn focus into guard if the player should fight if( thePlayer.GoToCombatIfNeeded() ) { OnCommGuard( action ); return false; } theGame.GetFocusModeController().Activate(); //thePlayer.MedallionPing(); } else if( IsReleased( action ) ) { theGame.GetFocusModeController().Deactivate(); } } else { thePlayer.DisplayActionDisallowedHudMessage(EIAB_ExplorationFocus); theGame.GetFocusModeController().Deactivate(); } } /////////////////////////// // Combat Inputs /////////////////////////// private function ShouldSwitchAttackType():bool { var outKeys : array<EInputKey>; if ( theInput.LastUsedPCInput() ) { theInput.GetPCKeysForAction('PCAlternate',outKeys); if ( outKeys.Size() > 0 ) { if ( theInput.IsActionPressed('PCAlternate') ) { return true; } } } return false; } event OnCbtAttackWithAlternateLight( action : SInputAction ) { CbtAttackPC( action, false); } event OnCbtAttackWithAlternateHeavy( action : SInputAction ) { CbtAttackPC( action, true); } function CbtAttackPC( action : SInputAction, isHeavy : bool ) { var switchAttackType : bool; switchAttackType = ShouldSwitchAttackType(); if ( !theInput.LastUsedPCInput() ) { return; } if ( thePlayer.IsCiri() ) { if ( switchAttackType != isHeavy) // XOR { OnCbtCiriAttackHeavy(action); } else { OnCbtAttackLight(action); } } else { if ( switchAttackType != isHeavy) // XOR { OnCbtAttackHeavy(action); } else { OnCbtAttackLight(action); } } } event OnCbtAttackLight( action : SInputAction ) { var allowed, checkedFists : bool; if( IsPressed(action) ) { if( IsActionAllowed(EIAB_LightAttacks) ) { if (thePlayer.GetBIsInputAllowed()) { allowed = false; if( thePlayer.GetCurrentMeleeWeaponType() == PW_Fists || thePlayer.GetCurrentMeleeWeaponType() == PW_None ) { checkedFists = true; if(IsActionAllowed(EIAB_Fists)) allowed = true; } else if(IsActionAllowed(EIAB_SwordAttack)) { checkedFists = false; allowed = true; } if(allowed) { thePlayer.SetupCombatAction( EBAT_LightAttack, BS_Pressed ); } else { if(checkedFists) thePlayer.DisplayActionDisallowedHudMessage(EIAB_Fists); else thePlayer.DisplayActionDisallowedHudMessage(EIAB_SwordAttack); } } } else if ( !IsActionBlockedBy(EIAB_LightAttacks,'interaction') ) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_LightAttacks); } } } event OnCbtAttackHeavy( action : SInputAction ) { var allowed, checkedSword : bool; var outKeys : array<EInputKey>; if ( thePlayer.GetBIsInputAllowed() ) { if( IsActionAllowed(EIAB_HeavyAttacks) ) { allowed = false; if( thePlayer.GetCurrentMeleeWeaponType() == PW_Fists || thePlayer.GetCurrentMeleeWeaponType() == PW_None ) { checkedSword = false; if(IsActionAllowed(EIAB_Fists)) allowed = true; } else if(IsActionAllowed(EIAB_SwordAttack)) { checkedSword = true; allowed = true; } if(allowed) { if ( ( thePlayer.GetCurrentMeleeWeaponType() == PW_Fists || thePlayer.GetCurrentMeleeWeaponType() == PW_None ) && IsPressed(action) ) { thePlayer.SetupCombatAction( EBAT_HeavyAttack, BS_Released ); } else { if( IsReleased(action) && theInput.GetLastActivationTime( action.aName ) < 0.2 ) { thePlayer.SetupCombatAction( EBAT_HeavyAttack, BS_Released ); } } } else { if(checkedSword) thePlayer.DisplayActionDisallowedHudMessage(EIAB_SwordAttack); else thePlayer.DisplayActionDisallowedHudMessage(EIAB_Fists); } } else if ( !IsActionBlockedBy(EIAB_HeavyAttacks,'interaction') ) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_HeavyAttacks); } } } private function CheckFinisherInput() : bool { var enemyInCone : CActor; var npc : CNewNPC; var interactionTarget : CInteractionComponent; var isDeadlySwordHeld : bool; interactionTarget = theGame.GetInteractionsManager().GetActiveInteraction(); if ( interactionTarget && interactionTarget.GetName() == "Finish" )//|| thePlayer.GetFinisherVictim() ) { npc = (CNewNPC)( interactionTarget.GetEntity() ); isDeadlySwordHeld = thePlayer.IsDeadlySwordHeld(); if( ( theInput.GetActionValue( 'AttackHeavy' ) == 1.f || theInput.GetActionValue( 'AttackLight' ) == 1.f ) && isDeadlySwordHeld )// { theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_FinisherInput) ); npc.SignalGameplayEvent('Finisher'); } else if ( !isDeadlySwordHeld ) { if ( thePlayer.IsWeaponHeld( 'fist' )) thePlayer.SetBehaviorVariable( 'combatTauntType', 1.f ); else thePlayer.SetBehaviorVariable( 'combatTauntType', 0.f ); thePlayer.RaiseEvent( 'CombatTaunt' ); } return true; } return false; } private function IsPlayerAbleToPerformSpecialAttack() : bool { if( ( thePlayer.GetCurrentStateName() == 'Exploration' ) && !( thePlayer.IsWeaponHeld( 'silversword' ) || thePlayer.IsWeaponHeld( 'steelsword' ) ) ) { return false; } return true; } event OnCbtSpecialAttackWithAlternateLight( action : SInputAction ) { CbSpecialAttackPC( action, false); } event OnCbtSpecialAttackWithAlternateHeavy( action : SInputAction ) { CbSpecialAttackPC( action, true); } function CbSpecialAttackPC( action : SInputAction, isHeavy : bool ) // special attack for PC { var switchAttackType : bool; switchAttackType = ShouldSwitchAttackType(); if ( !theInput.LastUsedPCInput() ) { return; } if ( IsPressed(action) ) { if ( thePlayer.IsCiri() ) { // always heavy for Ciri OnCbtCiriSpecialAttackHeavy(action); } else { if (switchAttackType != isHeavy) // XOR { OnCbtSpecialAttackHeavy(action); } else { OnCbtSpecialAttackLight(action); } } } else if ( IsReleased( action ) ) { if ( thePlayer.IsCiri() ) { OnCbtCiriSpecialAttackHeavy(action); } else { // to release hold actions OnCbtSpecialAttackHeavy(action); OnCbtSpecialAttackLight(action); } } } event OnCbtSpecialAttackLight( action : SInputAction ) { if ( IsReleased( action ) ) { CancelHoldAttacks(); return true; } if ( !IsPlayerAbleToPerformSpecialAttack() ) return false; if( !IsActionAllowed(EIAB_LightAttacks) ) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_LightAttacks); return false; } if(!IsActionAllowed(EIAB_SpecialAttackLight) ) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_SpecialAttackLight); return false; } if( IsPressed(action) && thePlayer.CanUseSkill(S_Sword_s01) ) { thePlayer.PrepareToAttack(); thePlayer.SetPlayedSpecialAttackMissingResourceSound(false); thePlayer.AddTimer( 'IsSpecialLightAttackInputHeld', 0.00001, true ); } } event OnCbtSpecialAttackHeavy( action : SInputAction ) { if ( IsReleased( action ) ) { CancelHoldAttacks(); return true; } if ( !IsPlayerAbleToPerformSpecialAttack() ) return false; if( !IsActionAllowed(EIAB_HeavyAttacks)) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_HeavyAttacks); return false; } if(!IsActionAllowed(EIAB_SpecialAttackHeavy)) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_SpecialAttackHeavy); return false; } if( IsPressed(action) && thePlayer.CanUseSkill(S_Sword_s02) ) { thePlayer.PrepareToAttack(); thePlayer.SetPlayedSpecialAttackMissingResourceSound(false); thePlayer.AddTimer( 'IsSpecialHeavyAttackInputHeld', 0.00001, true ); } else if ( IsPressed(action) ) { if ( theInput.IsActionPressed('AttackHeavy') ) theInput.ForceDeactivateAction('AttackHeavy'); else if ( theInput.IsActionPressed('AttackWithAlternateHeavy') ) theInput.ForceDeactivateAction('AttackWithAlternateHeavy'); } } // CiriSpecialAttack { thePlayer.RemoveTimer( 'IsSpecialLightAttackInputHeld' ); thePlayer.RemoveTimer( 'IsSpecialHeavyAttackInputHeld' ); thePlayer.RemoveTimer( 'SpecialAttackLightSustainCost' ); thePlayer.RemoveTimer( 'SpecialAttackHeavySustainCost' ); thePlayer.RemoveTimer( 'UpdateSpecialAttackLightHeading' ); thePlayer.UnblockAction( EIAB_Crossbow, 'SpecialAttack' ); if ( thePlayer.GetBehaviorVariable( 'combatActionType' ) == (int)CAT_SpecialAttack ) { if( thePlayer.GetBehaviorVariable( 'playerAttackType' ) == (int)PAT_Light && thePlayer.GetBehaviorVariable( 'isPerformingSpecialAttack' ) == 1.f ) { thePlayer.SetAttackActionName(SkillEnumToName(S_Sword_s01)); thePlayer.PushCombatActionOnBuffer( EBAT_SpecialAttack_Light, BS_Released ); thePlayer.ProcessCombatActionBuffer(); ((W3PlayerWitcherStateCombatFists) GetState('Combat')).ResetTimeToEndCombat(); } else if( thePlayer.GetBehaviorVariable( 'playerAttackType' ) == (int)PAT_Heavy && thePlayer.GetBehaviorVariable( 'isPerformingSpecialAttack' ) == 1.f ) { thePlayer.SetAttackActionName(SkillEnumToName(S_Sword_s02)); thePlayer.PushCombatActionOnBuffer( EBAT_SpecialAttack_Heavy, BS_Released ); thePlayer.ProcessCombatActionBuffer(); } } } event OnCbtCiriSpecialAttack( action : SInputAction ) { if( !GetCiriPlayer().HasSword() ) return false; if( thePlayer.GetBIsInputAllowed() && thePlayer.GetBIsCombatActionAllowed() && IsPressed(action) ) { if ( thePlayer.HasAbility('CiriBlink') && ((W3ReplacerCiri)thePlayer).HasStaminaForSpecialAction(true) ) thePlayer.PrepareToAttack(); thePlayer.PushCombatActionOnBuffer( EBAT_Ciri_SpecialAttack, BS_Pressed ); thePlayer.ProcessCombatActionBuffer(); } else if ( IsReleased( action ) && thePlayer.GetCombatAction() == EBAT_Ciri_SpecialAttack && thePlayer.GetBehaviorVariable( 'isPerformingSpecialAttack' ) != 0 ) { thePlayer.PushCombatActionOnBuffer( EBAT_Ciri_SpecialAttack, BS_Released ); thePlayer.ProcessCombatActionBuffer(); } } // CiriSpecialAttackHeavy event OnCbtCiriAttackHeavy( action : SInputAction ) { var specialAttackAction : SInputAction; if( !GetCiriPlayer().HasSword() ) return false; specialAttackAction = theInput.GetAction('CiriSpecialAttackHeavy'); if( thePlayer.GetBIsInputAllowed() && IsReleased(action) && thePlayer.GetBehaviorVariable( 'isPerformingSpecialAttack' ) == 0 ) { if( IsActionAllowed(EIAB_HeavyAttacks) && IsActionAllowed(EIAB_SwordAttack) ) { if ( thePlayer.GetCurrentMeleeWeaponType() == PW_Steel ) { thePlayer.PrepareToAttack(); thePlayer.SetupCombatAction( EBAT_HeavyAttack, BS_Released ); if ( thePlayer.GetBIsCombatActionAllowed() ) thePlayer.ProcessCombatActionBuffer(); } } else if ( !IsActionBlockedBy(EIAB_HeavyAttacks,'interaction') ) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_LightAttacks); } } } // CiriSpecialAttackHeavy event OnCbtCiriSpecialAttackHeavy( action : SInputAction ) { if( !GetCiriPlayer().HasSword() ) return false; if( thePlayer.GetBIsInputAllowed() && thePlayer.GetBIsCombatActionAllowed() && IsPressed(action) ) { theInput.ForceDeactivateAction('AttackWithAlternateHeavy'); thePlayer.PushCombatActionOnBuffer( EBAT_Ciri_SpecialAttack_Heavy, BS_Pressed ); thePlayer.ProcessCombatActionBuffer(); } else if ( IsReleased( action ) && thePlayer.GetCombatAction() == EBAT_Ciri_SpecialAttack_Heavy && thePlayer.GetBehaviorVariable( 'isPerformingSpecialAttack' ) != 0 ) { theInput.ForceDeactivateAction('CiriAttackHeavy'); theInput.ForceDeactivateAction('AttackWithAlternateHeavy'); thePlayer.PushCombatActionOnBuffer( EBAT_Ciri_SpecialAttack_Heavy, BS_Released ); thePlayer.ProcessCombatActionBuffer(); } } event OnCbtCiriDodge( action : SInputAction ) { if( IsActionAllowed(EIAB_Dodge) && IsPressed(action) && thePlayer.IsAlive() ) { if ( thePlayer.IsInCombatAction() && thePlayer.GetCombatAction() == EBAT_Ciri_SpecialAttack && thePlayer.GetBehaviorVariable( 'isCompletingSpecialAttack' ) <= 0 ) { thePlayer.PushCombatActionOnBuffer( EBAT_Ciri_Dodge, BS_Pressed ); thePlayer.ProcessCombatActionBuffer(); } else if ( thePlayer.GetBIsInputAllowed() ) { thePlayer.PushCombatActionOnBuffer( EBAT_Ciri_Dodge, BS_Pressed ); if ( thePlayer.GetBIsCombatActionAllowed() ) thePlayer.ProcessCombatActionBuffer(); } else { if ( thePlayer.IsInCombatAction() && thePlayer.GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack ) { if ( thePlayer.CanPlayHitAnim() && thePlayer.IsThreatened() ) { thePlayer.CriticalEffectAnimationInterrupted("CiriDodge"); thePlayer.PushCombatActionOnBuffer( EBAT_Ciri_Dodge, BS_Pressed ); thePlayer.ProcessCombatActionBuffer(); } else thePlayer.PushCombatActionOnBuffer( EBAT_Ciri_Dodge, BS_Pressed ); } } } else if ( !IsActionAllowed(EIAB_Dodge) ) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_Dodge); } } event OnCbtCiriDash( action : SInputAction ) { if ( theInput.LastUsedGamepad() && IsPressed( action ) ) { thePlayer.StartDodgeTimer(); } else if( IsActionAllowed(EIAB_Dodge) && thePlayer.IsAlive() ) { if ( theInput.LastUsedGamepad() ) { if ( !(thePlayer.IsDodgeTimerRunning() && !thePlayer.IsInsideInteraction() && IsReleased(action)) ) return false; } if ( thePlayer.IsInCombatAction() && thePlayer.GetCombatAction() == EBAT_Ciri_SpecialAttack && thePlayer.GetBehaviorVariable( 'isCompletingSpecialAttack' ) <= 0 ) { thePlayer.PushCombatActionOnBuffer( EBAT_Roll, BS_Released ); thePlayer.ProcessCombatActionBuffer(); } else if ( thePlayer.GetBIsInputAllowed() ) { thePlayer.PushCombatActionOnBuffer( EBAT_Roll, BS_Released ); if ( thePlayer.GetBIsCombatActionAllowed() ) thePlayer.ProcessCombatActionBuffer(); } else { if ( thePlayer.IsInCombatAction() && thePlayer.GetBehaviorVariable( 'combatActionType' ) == (int)CAT_Attack ) { if ( thePlayer.CanPlayHitAnim() && thePlayer.IsThreatened() ) { thePlayer.CriticalEffectAnimationInterrupted("CiriDodge"); thePlayer.PushCombatActionOnBuffer( EBAT_Roll, BS_Released ); thePlayer.ProcessCombatActionBuffer(); } else thePlayer.PushCombatActionOnBuffer( EBAT_Roll, BS_Released ); } } } else if ( !IsActionAllowed(EIAB_Dodge) ) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_Dodge); } } event OnCbtDodge( action : SInputAction ) { if ( IsPressed(action) ) thePlayer.EvadePressed(EBAT_Dodge); } event OnCbtRoll( action : SInputAction ) { if ( theInput.LastUsedPCInput() ) { if ( IsPressed( action ) ) { thePlayer.EvadePressed(EBAT_Roll); } } else { if ( IsPressed( action ) ) { thePlayer.StartDodgeTimer(); } else if ( IsReleased( action ) ) { if ( thePlayer.IsDodgeTimerRunning() ) { thePlayer.StopDodgeTimer(); if ( !thePlayer.IsInsideInteraction() ) thePlayer.EvadePressed(EBAT_Roll); } } } } var lastMovementDoubleTapName : name; event OnMovementDoubleTap( action : SInputAction ) { if ( IsPressed( action ) ) { if ( !thePlayer.IsDodgeTimerRunning() || action.aName != lastMovementDoubleTapName ) { thePlayer.StartDodgeTimer(); lastMovementDoubleTapName = action.aName; } else { thePlayer.StopDodgeTimer(); thePlayer.EvadePressed(EBAT_Dodge); } } } event OnCastSign( action : SInputAction ) { var signSkill : ESkill; if( !thePlayer.GetBIsInputAllowed() ) { return false; } if( IsPressed(action) ) { if( !IsActionAllowed(EIAB_Signs) ) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_Signs); return false; } /* if ( thePlayer.IsHoldingItemInLHand() && !thePlayer.IsUsableItemLBlocked() ) { thePlayer.SetPlayerActionToRestore ( PATR_CastSign ); thePlayer.OnUseSelectedItem( true ); return true; } else*/ if ( thePlayer.IsHoldingItemInLHand() && thePlayer.IsUsableItemLBlocked() ) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_Undefined, false, false, true); return false; } signSkill = SignEnumToSkillEnum( thePlayer.GetEquippedSign() ); if( signSkill != S_SUndefined ) { if(!thePlayer.CanUseSkill(signSkill)) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_Undefined, false, false, true); return false; } if( thePlayer.HasStaminaToUseSkill( signSkill, false ) ) { if( GetInvalidUniqueId() != thePlayer.inv.GetItemFromSlot( 'l_weapon' ) && !thePlayer.IsUsableItemLBlocked()) { // thePlayer.OnUseSelectedItem( true); //thePlayer.DropItemFromSlot( 'l_weapon', false ); //thePlayer.RaiseEvent( 'ItemEndL' ); } thePlayer.SetupCombatAction( EBAT_CastSign, BS_Pressed ); } else { thePlayer.SoundEvent("gui_no_stamina"); } } } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// @BOMBS //////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// event OnThrowBomb(action : SInputAction) { var selectedItemId : SItemUniqueId; selectedItemId = thePlayer.GetSelectedItemId(); if(!thePlayer.inv.IsItemBomb(selectedItemId)) return false; if( thePlayer.inv.SingletonItemGetAmmo(selectedItemId) == 0 ) { //sound to indicate you have no ammo if(IsPressed(action)) { thePlayer.SoundEvent( "gui_ingame_low_stamina_warning" ); } return false; } if ( IsReleased(action) ) { if ( thePlayer.IsThrowHold() ) { if ( thePlayer.playerAiming.GetAimedTarget() ) { if ( thePlayer.AllowAttack( thePlayer.playerAiming.GetAimedTarget(), EBAT_ItemUse ) ) { thePlayer.PushCombatActionOnBuffer( EBAT_ItemUse, BS_Released ); thePlayer.ProcessCombatActionBuffer(); } else thePlayer.BombThrowAbort(); } else { thePlayer.PushCombatActionOnBuffer( EBAT_ItemUse, BS_Released ); thePlayer.ProcessCombatActionBuffer(); } thePlayer.SetThrowHold( false ); return true; } else { if(!IsActionAllowed(EIAB_ThrowBomb)) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_ThrowBomb); return false; } else if(GetWitcherPlayer().GetBombDelay(GetWitcherPlayer().GetItemSlot(selectedItemId)) > 0 ) { return false; } if ( thePlayer.IsHoldingItemInLHand() && !thePlayer.IsUsableItemLBlocked() ) { thePlayer.SetPlayerActionToRestore ( PATR_ThrowBomb ); thePlayer.OnUseSelectedItem( true ); return true; } if(thePlayer.CanSetupCombatAction_Throw() && theInput.GetLastActivationTime( action.aName ) < 0.3f ) //why last activation time? { //thePlayer.PrepareToAttack(); thePlayer.SetupCombatAction( EBAT_ItemUse, BS_Pressed ); return true; } thePlayer.SetupCombatAction( EBAT_ItemUse, BS_Released ); return true; } } return false; } event OnThrowBombHold(action : SInputAction) { var locks : array<SInputActionLock>; var ind : int; var selectedItemId : SItemUniqueId; selectedItemId = thePlayer.GetSelectedItemId(); if(!thePlayer.inv.IsItemBomb(selectedItemId)) return false; if( thePlayer.inv.SingletonItemGetAmmo(selectedItemId) == 0 ) { //sound to indicate you have no ammo if(IsPressed(action)) { thePlayer.SoundEvent( "gui_ingame_low_stamina_warning" ); } return false; } if( IsPressed(action) ) { if(!IsActionAllowed(EIAB_ThrowBomb)) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_ThrowBomb); return false; } else if(GetWitcherPlayer().GetBombDelay(GetWitcherPlayer().GetItemSlot(selectedItemId)) > 0 ) { //thePlayer.DisplayActionDisallowedHudMessage(EIAB_Undefined, , , true); return false; } if ( thePlayer.IsHoldingItemInLHand() && !thePlayer.IsUsableItemLBlocked() ) { thePlayer.SetPlayerActionToRestore ( PATR_ThrowBomb ); thePlayer.OnUseSelectedItem( true ); return true; } if(thePlayer.CanSetupCombatAction_Throw() && theInput.GetLastActivationTime( action.aName ) < 0.3f ) //why last activation time? { if( thePlayer.GetBIsCombatActionAllowed() ) { thePlayer.PushCombatActionOnBuffer( EBAT_ItemUse, BS_Pressed ); thePlayer.ProcessCombatActionBuffer(); } } //get action locks, remove bomb throw lock and check if there any other more //the reason is that ThrowItem always sets the lock not knowing if we'll do a hold later or not, so we have to skip this one lock instance locks = GetActionLocks(EIAB_ThrowBomb); ind = FindActionLockIndex(EIAB_ThrowBomb, 'BombThrow'); if(ind >= 0) locks.Erase(ind); if(locks.Size() != 0) return false; thePlayer.SetThrowHold( true ); return true; } return false; } event OnThrowBombAbort(action : SInputAction) { if( IsPressed(action) ) { thePlayer.BombThrowAbort(); } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// END OF BOMBS ////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// event OnCbtThrowItem( action : SInputAction ) { var isUsableItem, isCrossbow, isBomb, ret : bool; var itemId : SItemUniqueId; //disabled while in air if(thePlayer.IsInAir() || thePlayer.GetWeaponHolster().IsOnTheMiddleOfHolstering()) return false; if( thePlayer.IsSwimming() && !thePlayer.OnCheckDiving() && thePlayer.GetCurrentStateName() != 'AimThrow' ) return false; itemId = thePlayer.GetSelectedItemId(); if(!thePlayer.inv.IsIdValid(itemId)) return false; isCrossbow = thePlayer.inv.IsItemCrossbow(itemId); if(!isCrossbow) { isBomb = thePlayer.inv.IsItemBomb(itemId); if(!isBomb) { isUsableItem = true; } } //if ( ( isBomb || isUsableItem ) && thePlayer.rangedWeapon && thePlayer.rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' ) // thePlayer.OnRangedForceHolster( true, false ); if( isCrossbow ) { if ( IsActionAllowed(EIAB_Crossbow) ) { if( IsPressed(action)) { if ( thePlayer.IsHoldingItemInLHand() && !thePlayer.IsUsableItemLBlocked() ) { /* thePlayer.SetPlayerActionToRestore ( PATR_None ); thePlayer.OnUseSelectedItem( true ); if ( thePlayer.GetBIsInputAllowed() ) { thePlayer.SetIsAimingCrossbow( true ); thePlayer.SetupCombatAction( EBAT_ItemUse, BS_Pressed ); } ret = true;*/ thePlayer.SetPlayerActionToRestore ( PATR_Crossbow ); thePlayer.OnUseSelectedItem( true ); ret = true; } else if ( thePlayer.GetBIsInputAllowed() && !thePlayer.IsCurrentlyUsingItemL() )//&& thePlayer.GetBIsCombatActionAllowed() ) { thePlayer.SetIsAimingCrossbow( true ); thePlayer.SetupCombatAction( EBAT_ItemUse, BS_Pressed ); //thePlayer.PushCombatActionOnBuffer( EBAT_ItemUse, BS_Pressed ); //thePlayer.ProcessCombatActionBuffer(); ret = true; } } else { // if ( thePlayer.GetIsAimingCrossbow() ) if ( thePlayer.GetIsAimingCrossbow() && !thePlayer.IsCurrentlyUsingItemL() ) { thePlayer.SetupCombatAction( EBAT_ItemUse, BS_Released ); //thePlayer.PushCombatActionOnBuffer( EBAT_ItemUse, BS_Released ); //thePlayer.ProcessCombatActionBuffer(); thePlayer.SetIsAimingCrossbow( false ); ret = true; } } } else { if ( !thePlayer.IsInShallowWater() ) thePlayer.DisplayActionDisallowedHudMessage(EIAB_Crossbow); } if ( IsPressed(action) ) thePlayer.AddTimer( 'IsItemUseInputHeld', 0.00001, true ); else thePlayer.RemoveTimer('IsItemUseInputHeld'); return ret; } else if(isBomb) { return OnThrowBomb(action); } else if(isUsableItem && !thePlayer.IsSwimming() && !thePlayer.IsFistFighting() ) { if( IsActionAllowed(EIAB_UsableItem) ) { if(IsPressed(action) && thePlayer.HasStaminaToUseAction(ESAT_UsableItem)) { thePlayer.SetPlayerActionToRestore ( PATR_Default ); thePlayer.OnUseSelectedItem(); return true; } /* else if ( IsReleased(action) ) { thePlayer.SetupCombatAction( EBAT_ItemUse, BS_Released ); return true; }*/ } else { thePlayer.DisplayActionDisallowedHudMessage(EIAB_UsableItem); } } return false; } event OnCbtThrowItemHold( action : SInputAction ) { var isBomb, isCrossbow, isUsableItem : bool; var itemId : SItemUniqueId; //disabled while in air if(thePlayer.IsInAir() || thePlayer.GetWeaponHolster().IsOnTheMiddleOfHolstering() ) return false; if( thePlayer.IsSwimming() && !thePlayer.OnCheckDiving() && thePlayer.GetCurrentStateName() != 'AimThrow' ) return false; itemId = thePlayer.GetSelectedItemId(); if(!thePlayer.inv.IsIdValid(itemId)) return false; isCrossbow = thePlayer.inv.IsItemCrossbow(itemId); if(!isCrossbow) { isBomb = thePlayer.inv.IsItemBomb(itemId); if(isBomb) { return OnThrowBombHold(action); } else { isUsableItem = true; } } //quit if action is blocked - for bomb we already checked actionLocks.Size() so there is no check here if(IsPressed(action)) { if( isCrossbow && !IsActionAllowed(EIAB_Crossbow) ) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_Crossbow); return false; } if( isUsableItem) { if(!IsActionAllowed(EIAB_UsableItem)) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_UsableItem); return false; } else if(thePlayer.IsSwimming()) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_Undefined, false, false, true); return false; } } } if( IsPressed(action) ) { thePlayer.SetThrowHold( true ); return true; } else if( IsReleased(action) && thePlayer.IsThrowHold()) { //thePlayer.PushCombatActionOnBuffer( EBAT_ItemUse, BS_Released ); //thePlayer.ProcessCombatActionBuffer(); thePlayer.SetupCombatAction( EBAT_ItemUse, BS_Released ); thePlayer.SetThrowHold( false ); return true; } return false; } event OnCbtThrowCastAbort( action : SInputAction ) { var player : W3PlayerWitcher; var throwStage : EThrowStage; if(thePlayer.inv.IsItemBomb(thePlayer.GetSelectedItemId())) { return OnThrowBombAbort(action); } if( IsPressed(action) ) { player = GetWitcherPlayer(); if(player) { if( player.IsCastingSign() ) { player.CastSignAbort(); } else { if ( thePlayer.inv.IsItemCrossbow( thePlayer.inv.GetItemFromSlot( 'l_weapon' ) ) ) { thePlayer.OnRangedForceHolster(); } else { throwStage = (int)thePlayer.GetBehaviorVariable( 'throwStage', (int)TS_Stop); if(throwStage == TS_Start || throwStage == TS_Loop) player.ThrowingAbort(); } } } } } event OnCbtSelectLockTarget( inputVector : Vector ) { var newLockTarget : CActor; var inputHeading : float; var target : CActor; inputVector.Y = inputVector.Y * -1.f; inputHeading = VecHeading( inputVector ); newLockTarget = thePlayer.GetScreenSpaceLockTarget( thePlayer.GetDisplayTarget(), 180.f, 1.f, inputHeading ); if ( newLockTarget ) thePlayer.ProcessLockTarget( newLockTarget ); target = thePlayer.GetTarget(); if ( target ) { thePlayer.SetSlideTarget( target ); //thePlayer.LockToTarget( true ); } } event OnCbtLockAndGuard( action : SInputAction ) { if(thePlayer.IsCiri() && !GetCiriPlayer().HasSword()) return false; // moved released to front due to bug where geralt would stay in guard stance if though the button is released if( IsReleased(action) ) { thePlayer.SetGuarded(false); thePlayer.OnGuardedReleased(); } if( (thePlayer.IsWeaponHeld('fists') || thePlayer.GetCurrentStateName() == 'CombatFists') && !IsActionAllowed(EIAB_Fists)) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_Fists); return false; } if( IsPressed(action) ) { if( !IsActionAllowed(EIAB_Parry) ) { if ( IsActionBlockedBy(EIAB_Parry,'UsableItem') ) { thePlayer.DisplayActionDisallowedHudMessage(EIAB_Parry); } return true; } if ( thePlayer.GetCurrentStateName() == 'Exploration' ) thePlayer.GoToCombatIfNeeded(); if ( thePlayer.bLAxisReleased ) thePlayer.ResetRawPlayerHeading(); if ( thePlayer.rangedWeapon && thePlayer.rangedWeapon.GetCurrentStateName() != 'State_WeaponWait' ) thePlayer.OnRangedForceHolster( true, true ); thePlayer.AddCounterTimeStamp(theGame.GetEngineTime()); //cache counter button press to further check counter button spamming by the thePlayer thePlayer.SetGuarded(true); thePlayer.OnPerformGuard(); } } event OnCbtCameraLockOrSpawnHorse( action : SInputAction ) { if ( OnCbtCameraLock(action) ) return true; if ( OnCommSpawnHorse(action) ) return true; return false; } event OnCbtCameraLock( action : SInputAction ) { if( IsPressed(action) ) { if ( thePlayer.IsThreatened() || thePlayer.IsActorLockedToTarget() ) { if ( !thePlayer.IsHardLockEnabled() && thePlayer.GetDisplayTarget() && (CActor)( thePlayer.GetDisplayTarget() ) && IsActionAllowed(EIAB_HardLock)) { if ( thePlayer.bLAxisReleased ) thePlayer.ResetRawPlayerHeading(); thePlayer.HardLockToTarget( true ); } else { thePlayer.HardLockToTarget( false ); } return true; } } return false; } event OnChangeCameraPreset( action : SInputAction ) { if( IsPressed(action) ) { ((CCustomCamera)theCamera.GetTopmostCameraObject()).NextPreset(); } } event OnChangeCameraPresetByMouseWheel( action : SInputAction ) { var tolerance : float; tolerance = 10.0f; if( ( action.value * totalCameraPresetChange ) < 0.0f ) { totalCameraPresetChange = 0.0f; } totalCameraPresetChange += action.value; if( totalCameraPresetChange < -tolerance ) { ((CCustomCamera)theCamera.GetTopmostCameraObject()).PrevPreset(); totalCameraPresetChange = 0.0f; } else if( totalCameraPresetChange > tolerance ) { ((CCustomCamera)theCamera.GetTopmostCameraObject()).NextPreset(); totalCameraPresetChange = 0.0f; } } event OnMeditationAbort(action : SInputAction) { var med : W3PlayerWitcherStateMeditation; if (!theGame.GetGuiManager().IsAnyMenu()) { med = (W3PlayerWitcherStateMeditation)GetWitcherPlayer().GetCurrentState(); if(med) { // If meditation is stopped with b button (as of writing this, only plugged into player input and not gameplay systems) // the menu's should not be closed automatically. med.StopRequested(false); } } } /////////////////////////// // Debug /////////////////////////// public function Dbg_UnlockAllActions() { var i : int; if( theGame.IsFinalBuild() ) { return; } for(i=actionLocks.Size()-1; i>=0; i-=1) { OnActionLockChanged(i, false); } actionLocks.Clear(); } event OnDbgSpeedUp( action : SInputAction ) { if( theGame.IsFinalBuild() ) { return false; } if(IsPressed(action)) { theGame.SetTimeScale(4, theGame.GetTimescaleSource(ETS_DebugInput), theGame.GetTimescalePriority(ETS_DebugInput)); } else if(IsReleased(action)) { theGame.RemoveTimeScale( theGame.GetTimescaleSource(ETS_DebugInput) ); } } event OnDbgHit( action : SInputAction ) { if( theGame.IsFinalBuild() ) { return false; } if(IsReleased(action)) { thePlayer.SetBehaviorVariable( 'HitReactionDirection',(int)EHRD_Back); thePlayer.SetBehaviorVariable( 'isAttackReflected', 0 ); thePlayer.SetBehaviorVariable( 'HitReactionType', (int)EHRT_Heavy); thePlayer.SetBehaviorVariable( 'HitReactionWeapon', 0); thePlayer.SetBehaviorVariable( 'HitSwingDirection',(int)ASD_LeftRight); thePlayer.SetBehaviorVariable( 'HitSwingType',(int)AST_Horizontal); thePlayer.RaiseForceEvent( 'Hit' ); thePlayer.OnRangedForceHolster( true ); GetWitcherPlayer().SetCustomRotation( 'Hit', thePlayer.GetHeading()+180, 1080.f, 0.1f, false ); thePlayer.CriticalEffectAnimationInterrupted("OnDbgHit"); } } event OnDbgKillTarget( action : SInputAction ) { var target : CActor; if( theGame.IsFinalBuild() ) { return false; } target = thePlayer.GetTarget(); if( target && IsReleased(action) ) { target.Kill(); } } event OnDbgKillAll( action : SInputAction ) { if( theGame.IsFinalBuild() ) { return false; } if(IsReleased(action)) thePlayer.DebugKillAll(); } //Nuke - kills all actors targeting thePlayer on the entire level { if( theGame.IsFinalBuild() ) { return false; } if(IsReleased(action)) { thePlayer.CheatResurrect(); } } event OnDbgKillAllTargetingPlayer( action : SInputAction ) { var i : int; var all : array<CActor>; if( theGame.IsFinalBuild() ) { return false; } if(IsPressed(action)) { all = GetActorsInRange(thePlayer, 10000, 10000, '', true); for(i=0; i<all.Size(); i+=1) { if(all[i] != thePlayer && all[i].GetTarget() == thePlayer) all[i].Kill(); } } } /////////////////////////// // @Boat /////////////////////////// event OnBoatDismount( action : SInputAction ) { var boatComp : CBoatComponent; var stopAction : SInputAction; stopAction = theInput.GetAction('GI_Decelerate'); if( IsReleased(action) && ( theInput.LastUsedPCInput() || ( stopAction.value < 0.7 && stopAction.lastFrameValue < 0.7 ) ) ) { if( thePlayer.IsActionAllowed( EIAB_DismountVehicle ) ) { boatComp = (CBoatComponent)thePlayer.GetUsedVehicle().GetComponentByClassName( 'CBoatComponent' ); boatComp.IssueCommandToDismount( DT_normal ); } else { thePlayer.DisplayActionDisallowedHudMessage(EIAB_DismountVehicle); } } } /////////////////////////// // @Replacers /////////////////////////// event OnCiriDrawWeapon( action : SInputAction ) { var duringCastSign : bool; //draw weapon if ( IsReleased(action) || ( IsPressed(action) && (thePlayer.GetCurrentMeleeWeaponType() == PW_None || thePlayer.GetCurrentMeleeWeaponType() == PW_Fists) ) ) { if ( thePlayer.GetBIsInputAllowed() && thePlayer.GetBIsCombatActionAllowed() ) { if (thePlayer.GetCurrentMeleeWeaponType() == PW_Steel && !thePlayer.IsThreatened() ) thePlayer.OnEquipMeleeWeapon( PW_None, false ); else thePlayer.OnEquipMeleeWeapon( PW_Steel, false ); } } else if(IsReleased(action) || ( IsPressed(action) && (thePlayer.GetCurrentMeleeWeaponType() == PW_Steel || thePlayer.GetCurrentMeleeWeaponType() == PW_Silver) ) ) { CiriSheatheWeapon(); } } event OnCiriHolsterWeapon( action : SInputAction ) { var currWeaponType : EPlayerWeapon; if(IsPressed( action )) { currWeaponType = thePlayer.GetCurrentMeleeWeaponType(); if(currWeaponType == PW_Steel || currWeaponType == PW_Silver) { CiriSheatheWeapon(); } } } private final function CiriSheatheWeapon() { if ( thePlayer.GetBIsInputAllowed() && thePlayer.GetBIsCombatActionAllowed() && !thePlayer.IsThreatened() ) { thePlayer.OnEquipMeleeWeapon( PW_None, false ); } } /////////////////////////// // @Replacers /////////////////////////// event OnCommHoldFastMenu( action : SInputAction ) { if(IsPressed(action)) { holdFastMenuInvoked = true; PushInventoryScreen(); } } event OnFastMenu( action : SInputAction ) { if( IsReleased(action) ) { if(holdFastMenuInvoked) { holdFastMenuInvoked = false; return false; } if ( theGame.IsBlackscreenOrFading() ) { return false; } if (theGame.GetGuiManager().IsAnyMenu()) { return false; } if( IsActionAllowed( EIAB_OpenFastMenu ) ) { theGame.SetMenuToOpen( '' ); theGame.RequestMenu('CommonMenu' ); } else { thePlayer.DisplayActionDisallowedHudMessage(EIAB_OpenFastMenu); } } } event OnIngameMenu( action : SInputAction ) { var openedPanel : name; openedPanel = theGame.GetMenuToOpen(); // #Y avoid opening menu on release after opening TutorialsMenu on hold if( IsReleased(action) && openedPanel != 'GlossaryTutorialsMenu' && !theGame.GetGuiManager().IsAnyMenu() ) // #B very ugly :P { if ( theGame.IsBlackscreenOrFading() ) { return false; } theGame.SetMenuToOpen( '' ); theGame.RequestMenu('CommonIngameMenu' ); } } public final function Debug_ClearAllActionLocks(optional action : EInputActionBlock, optional all : bool) { var i : int; if(all) { Dbg_UnlockAllActions(); } else { OnActionLockChanged(action, false); actionLocks[action].Clear(); } } public final function OnAutoLootRadiusLoot(action : SInputAction) { if(IsPressed(action)) { AL_LootInRadius(); } } } Edited July 27, 2017 by Guest Link to comment Share on other sites More sharing options...
Recommended Posts