Fix autobonus not working with ammo, item combos, and pets - #3446
Open
MrKeiKun wants to merge 2 commits into
Open
Fix autobonus not working with ammo, item combos, and pets#3446MrKeiKun wants to merge 2 commits into
MrKeiKun wants to merge 2 commits into
Conversation
autobonus() only worked from a plain equipped item's or card's script, keyed off a single EQP_* position bitmask read from a global that was never set for ammo scripts, combo scripts, or pet equip scripts. Adds a proper source identity (item/card/combo/pet) so autobonus registers and persists correctly for all of them, and stops a card sharing an equip slot with its host item from colliding with the item's own autobonus.
Hercules' interface validator flags any top-level <ifname>_<method> function that isn't registered on that interface. The new private helpers were named pc_* / script_* without being interface members, which tripped it; renamed them off that pattern.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Prelude
Changes Proposed
autobonus()/autobonus2()/autobonus3()identified the source of an autobonus purely by readingstatus->current_equip_item_index(an inventory index) and deriving anEQP_*position bitmask from it. That global was only correctly maintained by the plain equip-item loop and the card loop instatus_calc_pc_(), so every other script-execution path silently failed to register a working autobonus:status->current_equip_item_index, soautobonus()called from an ammo item's script either no-op'd or registered against whatever equip slot was last processed by the main loop.current_equip_item_indexis explicitly reset to-1, soautobonus()there was a guaranteed no-op.current_equip_item_indexpointing at the same inventory slot, so their autobonuses shared the exact same identity and could suppress or interfere with each other.This PR replaces the single
EQP_*-bitmask identity with a properstruct s_autobonus_source { pos, card_id, combo_pos, pet_id }, threaded throughpc_addautobonus/pc_delautobonus/pc_exeautobonus/autobonus_is_activeand the threeautobonus*()builtins. New context globals (current_equip_combo_pos,current_equip_pet_id) mirror the existingcurrent_equip_card_idpattern and are set around the combo and pet-equip script executions instatus_calc_pc_(). The oldsd->state.autobonusposition bitmask (which could only represent one active autobonus per equip slot) is removed in favor of per-entry lookups that re-validate the exact source (equip slot + specific card, or specific combo id, or specific pet id) against the character's live state.Also fixes a related gap:
pc_unequipitem()used to clear autobonus activation via that same bitmask unconditionally on unequip; sincestatus_calc_pc()isn't always called synchronously after an unequip (e.g.PCUNEQUIPITEM_FORCEwithoutPCUNEQUIPITEM_RECALC), this PR now callspc->delautobonus(..., true)directly inpc_unequipitem()so an unequipped item's autobonus timer is always stopped promptly regardless of the caller's recalc flag.Regenerated the affected
HPMHookingtrampolines/typedefs by hand for the changedpc->addautobonus/newpc->autobonus_is_activeinterface entries, sincepc_addautobonus's signature changed; maintainers may want to re-runHPMHookGen.plto confirm these match exactly.Issues addressed: #2764