{"action":"closed","issue":{"url":"https://api.github.com/repos/X2CommunityCore/X2WOTCCommunityHighlander/issues/64","repository_url":"https://api.github.com/repos/X2CommunityCore/X2WOTCCommunityHighlander","labels_url":"https://api.github.com/repos/X2CommunityCore/X2WOTCCommunityHighlander/issues/64/labels{/name}","comments_url":"https://api.github.com/repos/X2CommunityCore/X2WOTCCommunityHighlander/issues/64/comments","events_url":"https://api.github.com/repos/X2CommunityCore/X2WOTCCommunityHighlander/issues/64/events","html_url":"https://github.com/X2CommunityCore/X2WOTCCommunityHighlander/issues/64","id":263655852,"number":64,"title":"Streamline code for number of utility item slots and add DLC Hook.","user":{"login":"robojumper","id":14299449,"avatar_url":"https://avatars0.githubusercontent.com/u/14299449?v=4","gravatar_id":"","url":"https://api.github.com/users/robojumper","html_url":"https://github.com/robojumper","followers_url":"https://api.github.com/users/robojumper/followers","following_url":"https://api.github.com/users/robojumper/following{/other_user}","gists_url":"https://api.github.com/users/robojumper/gists{/gist_id}","starred_url":"https://api.github.com/users/robojumper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robojumper/subscriptions","organizations_url":"https://api.github.com/users/robojumper/orgs","repos_url":"https://api.github.com/users/robojumper/repos","events_url":"https://api.github.com/users/robojumper/events{/privacy}","received_events_url":"https://api.github.com/users/robojumper/received_events","type":"User","site_admin":false},"labels":[{"id":681384115,"url":"https://api.github.com/repos/X2CommunityCore/X2WOTCCommunityHighlander/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-10-07T16:57:48Z","updated_at":"2018-03-18T22:52:51Z","closed_at":"2018-03-18T22:52:51Z","author_association":"CONTRIBUTOR","body":"In the vanilla Highlander, there was a function `GetNumUtilitySlots()` (see X2CommunityCore/X2CommunityHighlander#114 ). It was called wherever some code would change / reset the number, and expected an override number. This made a lot of code more ugly than it already is.\r\n\r\nIn WotC, it gets worse. Consider this code that handles unequipping a piece of armor:\r\n\r\n\tcase eInvSlot_Armor:\r\n\t\tif(!IsMPCharacter() && X2ArmorTemplate(Item.GetMyTemplate()).bAddsUtilitySlot)\r\n\t\t{\r\n\t\t\tif (!HasExtraUtilitySlotFromAbility())      //  don't lower the bonus if one is given via an ability\r\n\t\t\t{\r\n\t\t\t\tSetBaseMaxStat(eStat_UtilityItems, GetMyTemplate().GetCharacterBaseStat(eStat_UtilityItems));\r\n\t\t\t\tSetCurrentStat(eStat_UtilityItems, GetMyTemplate().GetCharacterBaseStat(eStat_UtilityItems));\r\n\t\t\t}\r\n\t\t}\r\n\t\tbreak;\r\n\r\nThis is bad. All code that handles the utility item stat needs to be aware of any other systems that touch the slot number.\r\n\r\nI would use a slightly different approach: A function called `RealizeNumUtilitySlots()` that can be called whenever anything happens that would modify utility slot numbers, and an additional DLC hook that allows mods to modify / override this number. This function would always run all the checks: Character Base Stat, Bonus Armor Slot, Tactical Rigging, DLC Hooks, and then set the character stat. Sensible places to do this are equipping / unequipping items, buying abilities.\r\n\r\nThis function should then be the only code that sets this stat (except TQL / dev tools, cheats and MP)."}}
{"actor":{"display_login":"bountygiver"}}