diff --git a/X2WOTCCommunityHighlander/Src/XComGame/Classes/CHHelpers.uc b/X2WOTCCommunityHighlander/Src/XComGame/Classes/CHHelpers.uc index d50e3b77e..c28d1dd1c 100644 --- a/X2WOTCCommunityHighlander/Src/XComGame/Classes/CHHelpers.uc +++ b/X2WOTCCommunityHighlander/Src/XComGame/Classes/CHHelpers.uc @@ -1,14 +1,24 @@ class CHHelpers extends Object config(Game); -//issue #188 - creating a struct and usable array for modders +//issue #188 - creating a struct for modders struct TeamRequest { var ETeam Team; //eTeam_One and eTeam_Two should be the only ones here. }; - -var config array ModAddedTeams; //end issue #188 +// Start Issue #93 +struct UpgradeSlotHelper +{ + var name TemplateName; // Name of the non-X2WeaponTemplate to be assigned slots (X2WeaponTemplates have NumUpgradeSlots on the template) + var int NumUpgradeSlots; // The number of slots to assign +}; +// End Issue #93 + +var config array ModAddedTeams; //issue #188 - creating a usable array for modders + +var config array NonWeaponUpgradeSlots; // Issue #93 - configure upgrade slots for templates + var config int SPAWN_EXTRA_TILE; // Issue #18 - Add extra ini config var config int MAX_TACTICAL_AUTOSAVES; // Issue #53 - make configurable, only use if over 0 diff --git a/X2WOTCCommunityHighlander/Src/XComGame/Classes/UIArmory_WeaponUpgrade.uc b/X2WOTCCommunityHighlander/Src/XComGame/Classes/UIArmory_WeaponUpgrade.uc index 117b7ba7c..768938f26 100644 --- a/X2WOTCCommunityHighlander/Src/XComGame/Classes/UIArmory_WeaponUpgrade.uc +++ b/X2WOTCCommunityHighlander/Src/XComGame/Classes/UIArmory_WeaponUpgrade.uc @@ -253,7 +253,10 @@ simulated function UpdateSlots() // Get equipped upgrades EquippedUpgrades = Weapon.GetMyWeaponUpgradeTemplates(); WeaponTemplate = X2WeaponTemplate(Weapon.GetMyTemplate()); - NumUpgradeSlots = WeaponTemplate.NumUpgradeSlots; + // Start Issue #93 + //NumUpgradeSlots = WeaponTemplate.NumUpgradeSlots; + NumUpgradeSlots = Weapon.GetNumUpgradeSlots(); + // End Issue #93 if (XComHQ.bExtraWeaponUpgrade) NumUpgradeSlots++; diff --git a/X2WOTCCommunityHighlander/Src/XComGame/Classes/UILadderUpgradeScreen.uc b/X2WOTCCommunityHighlander/Src/XComGame/Classes/UILadderUpgradeScreen.uc index bae8085e2..a45dcb564 100644 --- a/X2WOTCCommunityHighlander/Src/XComGame/Classes/UILadderUpgradeScreen.uc +++ b/X2WOTCCommunityHighlander/Src/XComGame/Classes/UILadderUpgradeScreen.uc @@ -199,7 +199,8 @@ simulated function PopulateUpgradePanel( int Index, X2LadderUpgradeTemplate Upgr } WeaponTemplate = X2WeaponTemplate(primaryWeaponItem.GetMyTemplate()); - bAddLine = WeaponTemplate != none && WeaponTemplate.NumUpgradeSlots > 0 && ItemUpgradeTemplate.CanApplyUpgradeToWeapon(primaryWeaponItem); + // Single line for Issue #93 + bAddLine = WeaponTemplate != none && WeaponTemplate.GetNumUpgradeSlots() > 0 && ItemUpgradeTemplate.CanApplyUpgradeToWeapon(primaryWeaponItem); // ParamTag.StrValue0 = ClassTemplate.DisplayName; diff --git a/X2WOTCCommunityHighlander/Src/XComGame/Classes/UIUtilities_Strategy.uc b/X2WOTCCommunityHighlander/Src/XComGame/Classes/UIUtilities_Strategy.uc index 75bb2c6be..6785262aa 100644 --- a/X2WOTCCommunityHighlander/Src/XComGame/Classes/UIUtilities_Strategy.uc +++ b/X2WOTCCommunityHighlander/Src/XComGame/Classes/UIUtilities_Strategy.uc @@ -1607,7 +1607,10 @@ simulated static function GetWeaponUpgradeAvailability(XComGameState_Unit Unit, WeaponTemplate = X2WeaponTemplate(PrimaryWeapon.GetMyTemplate()); // Single line for Issue #306 EquippedUpgrades = PrimaryWeapon.GetMyWeaponUpgradeCount(); - AvailableSlots = WeaponTemplate.NumUpgradeSlots; + // Start Issue #93 + //AvailableSlots = WeaponTemplate.NumUpgradeSlots; + AvailableSlots = PrimaryWeapon.GetNumUpgradeSlots(); + // End Issue #93 // Only add extra slots if the weapon had some to begin with if (AvailableSlots > 0) diff --git a/X2WOTCCommunityHighlander/Src/XComGame/Classes/X2AchievementTracker.uc b/X2WOTCCommunityHighlander/Src/XComGame/Classes/X2AchievementTracker.uc index 990450812..2b3bc85f5 100644 --- a/X2WOTCCommunityHighlander/Src/XComGame/Classes/X2AchievementTracker.uc +++ b/X2WOTCCommunityHighlander/Src/XComGame/Classes/X2AchievementTracker.uc @@ -943,7 +943,10 @@ static function EventListenerReturn OnWeaponUpgraded(Object EventData, Object Ev { UpgradeTemplates = WeaponState.GetMyWeaponUpgradeTemplates(); - NumUpgradeSlots = WeaponTemplate.NumUpgradeSlots; + // Start Issue #93 + //NumUpgradeSlots = WeaponTemplate.NumUpgradeSlots; + NumUpgradeSlots = WeaponState.GetNumUpgradeSlots(); + // End Issue #93 if (XComHQ.bExtraWeaponUpgrade) NumUpgradeSlots++; if (XComHQ.ExtraUpgradeWeaponCats.Find(WeaponTemplate.WeaponCat) != INDEX_NONE) diff --git a/X2WOTCCommunityHighlander/Src/XComGame/Classes/X2ItemTemplate.uc b/X2WOTCCommunityHighlander/Src/XComGame/Classes/X2ItemTemplate.uc index ba0cd0610..7669b0fb1 100644 --- a/X2WOTCCommunityHighlander/Src/XComGame/Classes/X2ItemTemplate.uc +++ b/X2WOTCCommunityHighlander/Src/XComGame/Classes/X2ItemTemplate.uc @@ -362,6 +362,30 @@ function bool CanBeLootedByUnit(XComGameState_Item LootItem, XComGameState_Unit return true; } +// Start Issue #93 +function int GetNumUpgradeSlots() +{ + local X2WeaponTemplate SelfAsWeapon; + local int idx; + + SelfAsWeapon = X2WeaponTemplate(self); + + if (SelfAsWeapon != none) + { + return SelfAsWeapon.NumUpgradeSlots; + } + + idx = class'CHHelpers'.default.NonWeaponUpgradeSlots.Find('TemplateName', DataName); + + if (idx != INDEX_NONE) + { + return class'CHHelpers'.default.NonWeaponUpgradeSlots[idx].NumUpgradeSlots; + } + + return 0; +} +// End Issue #93 + DefaultProperties { iItemSize=1; diff --git a/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_HeadquartersXCom.uc b/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_HeadquartersXCom.uc index 02a9a9918..5f5f4b062 100644 --- a/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_HeadquartersXCom.uc +++ b/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_HeadquartersXCom.uc @@ -4651,6 +4651,17 @@ static function UpgradeItems(XComGameState NewGameState, name CreatorTemplateNam if (!XComHQ.HasItem(UpgradeItemTemplate)) { UpgradedItemState = UpgradeItemTemplate.CreateInstanceFromTemplate(NewGameState); + // Issue #289 - handle upgrades for infinite items + /// HL-Docs: feature:ItemUpgraded; issue:289; tags:strategy,events + /// This is an event that allows mods to perform non-standard handling to item states + /// when they are upgraded to a new tier. It is fired up to four times during upgrading: + /// * When upgrading the infinite item, if any. + /// * When upgrading utility items, like grenades and medkits. + /// * When upgrading unequipped items that have attachments + /// * When upgrading equipped items that have attachments + /// + /// The infinite item upgrade is the only firing that does not contain an EventData + `XEVENTMGR.TriggerEvent('ItemUpgraded', UpgradedItemState, none, NewGameState); XComHQ.AddItemToHQInventory(UpgradedItemState); } } @@ -4668,6 +4679,7 @@ static function UpgradeItems(XComGameState NewGameState, name CreatorTemplateNam // Otherwise match the base items quantity UpgradedItemState = UpgradeItemTemplate.CreateInstanceFromTemplate(NewGameState); UpgradedItemState.Quantity = BaseItemState.Quantity; + `XEVENTMGR.TriggerEvent('ItemUpgraded', UpgradedItemState, BaseItemState, NewGameState); // Issue #289 - handle upgrades for utility items like grenades and medkits // Then add the upgrade item and remove all of the base items from the inventory XComHQ.PutItemInInventory(NewGameState, UpgradedItemState); @@ -4703,6 +4715,7 @@ static function UpgradeItems(XComGameState NewGameState, name CreatorTemplateNam UpgradedItemState.ApplyWeaponUpgradeTemplate(WeaponUpgradeTemplate); } } + `XEVENTMGR.TriggerEvent('ItemUpgraded', UpgradedItemState, InventoryItemState, NewGameState); // Issue #289 - handle upgrades for unequipped items with attachments // Delete the old item, and add the new item to the inventory NewGameState.RemoveStateObject(InventoryItemState.GetReference().ObjectID); @@ -4747,6 +4760,7 @@ static function UpgradeItems(XComGameState NewGameState, name CreatorTemplateNam UpgradedItemState.ApplyWeaponUpgradeTemplate(WeaponUpgradeTemplate); } } + `XEVENTMGR.TriggerEvent('ItemUpgraded', UpgradedItemState, InventoryItemState, NewGameState); // Issue #289 - handle upgrades for equipped items with attachments // Delete the old item NewGameState.RemoveStateObject(InventoryItemState.GetReference().ObjectID); diff --git a/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_Item.uc b/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_Item.uc index 596891dc5..3eb4165e6 100644 --- a/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_Item.uc +++ b/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_Item.uc @@ -766,8 +766,8 @@ simulated function bool HasBeenModified() WeaponTemplate = X2WeaponTemplate( m_ItemTemplate ); - // Single line for Issue #306 - if ((WeaponTemplate != none) && (WeaponTemplate.NumUpgradeSlots > 0) && (GetMyWeaponUpgradeCount() > 0)) + // Single line for Issues #93 and #306 + if ((WeaponTemplate != none) && (GetNumUpgradeSlots() > 0) && (GetMyWeaponUpgradeCount() > 0)) return true; return false; @@ -2392,9 +2392,42 @@ function bool IsMissionObjectiveItem() return false; } +// Start Issue #93 +/// HL-Docs: feature:OverrideNumUpgradeSlots; issue:93; tags:strategy,events +/// This is an event that mods can listen for which will allow them to +/// modify upgrade slots on a per-gamestate basis. +/// +/// In general, it should only be used if you have some type of handling that allows +/// individual items to be customized in a way others of their type cannot. +function int GetNumUpgradeSlots() +{ + local Object ThisObj; + local XComLWTuple Tuple; + + ThisObj = self; + + Tuple = new class'XComLWTuple'; + Tuple.Id = 'OverrideNumUpgradeSlots'; + Tuple.Data.Add(1); + Tuple.Data[0].kind = XComLWTVInt; + Tuple.Data[0].i = GetMyTemplate().GetNumUpgradeSlots(); + + `XEVENTMGR.TriggerEvent('OverrideNumUpgradeSlots', Tuple, ThisObj); + + return Tuple.Data[0].i; +} +// End Issue #93 + // Issue #260 start -// This function will be used to cycle through DLCInfos that will allow mods to check generally whether or not a weapon is compatible with an upgrade -// X2WeaponUpgradeTemplate::CanApplyUpgradeToWeapon still exists as the "can this upgrade be applied to this weapon RIGHT NOW?" +/// HL-Docs: feature:CanWeaponApplyUpgrade; issue:260; tags:strategy,dlcinfo +/// This function will be used to cycle through DLCInfos that will allow mods to check generally +/// whether or not a weapon is compatible with an upgrade. X2WeaponUpgradeTemplate::CanApplyUpgradeToWeapon +/// still exists as the "can this upgrade be applied to this weapon RIGHT NOW?" +/// +/// * The best use case for this is to bar your weapon from applying upgrades that don't meet your criteria, +/// without having to edit those upgrades directly. +/// * Note that this check is /in addition to/, and not /in lieu of/, CanApplyUpgradeToWeapon. This means +/// you cannot use it to override that function's return value. function bool CanWeaponApplyUpgrade(X2WeaponUpgradeTemplate UpgradeTemplate) { local int i; diff --git a/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_LadderProgress.uc b/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_LadderProgress.uc index 9329a0e0a..a111fd526 100644 --- a/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_LadderProgress.uc +++ b/X2WOTCCommunityHighlander/Src/XComGame/Classes/XComGameState_LadderProgress.uc @@ -1116,7 +1116,7 @@ private static function UpdateUnitState( XComGameState StartState, XComGameState PrimaryWeapon = UnitState.GetPrimaryWeapon( ); PrimaryWeapon = XComGameState_Item( StartState.GetGameStateForObjectID( PrimaryWeapon.ObjectID ) ); WeaponTemplate = X2WeaponTemplate( PrimaryWeapon.GetMyTemplate( ) ); - if (WeaponTemplate.NumUpgradeSlots > 0) + if (WeaponTemplate.GetNumUpgradeSlots() > 0) // Single line for Issue #93 PrimaryWeapon.WipeUpgradeTemplates( ); ItemManager = class'X2ItemTemplateManager'.static.GetItemTemplateManager(); @@ -1151,7 +1151,7 @@ private static function UpdateUnitState( XComGameState StartState, XComGameState SwapUtilityItem( StartState, UnitState, ItemName, 1 ); } } - else if ((WeaponUpgradeTemplate != none) && (WeaponTemplate.NumUpgradeSlots > 0)) + else if ((WeaponUpgradeTemplate != none) && (WeaponTemplate.GetNumUpgradeSlots() > 0)) // Single line for Issue #93 { WeaponUpgrades = PrimaryWeapon.GetMyWeaponUpgradeTemplateNames( ); @@ -1166,7 +1166,7 @@ private static function UpdateUnitState( XComGameState StartState, XComGameState if (index == WeaponUpgrades.Length) { - if (index < WeaponTemplate.NumUpgradeSlots) + if (index < WeaponTemplate.GetNumUpgradeSlots()) // Single line for Issue #93 { PrimaryWeapon.ApplyWeaponUpgradeTemplate( WeaponUpgradeTemplate ); } diff --git a/docs_src/docs/dlcinfo.md b/docs_src/docs/dlcinfo.md new file mode 100644 index 000000000..72b6c4ce7 --- /dev/null +++ b/docs_src/docs/dlcinfo.md @@ -0,0 +1,13 @@ +

X2DownloadableContentInfo Hooks

+ +Many of the Highlander's features utilize function calls to the subclasses of +X2DownloadableContentInfo that all mods require. These are known colloquially +as DlcInfo hooks, and are commonly used as an alternative when an event will +not work for a given feature. + +Mods can define a function of the same name with the same arguments in their +X2DownloadableContentInfo file, and then perform any custom handling. + +Unlike events, these DlcInfo hooks are not limited to two arguments. However, +they are much slower than events are, so events should generally be used. +