[confirmed]Display curse auras correctly see Koraths post

Posted:
10 Aug 2017, 17:04
by Aswan jaguar
Describe the Bug:AI never played Reverse Damage in several games not even to save it from losing.fixed
Which card did behave improperly?Reverse Damage AI part.
Which update are you using? (date, name)Which type? (duel, gauntlet, sealed deck) Manalink 2016/08/27: Eldritch Moon v2, duel
What exactly should be the correct behavior/interaction? Are any other cards possibly affected by this bug? -
Re: AI never plays Reverse Damage

Posted:
11 Aug 2017, 06:30
by Korath
default_target_definition() still defaults to preferring 1-who_chooses, right, Gargaroz? That'll be the problem here if so, and the same with anything else that can target damage to a player. Damage to a player is always created as controlled by that player, not by its actual controller; see whose_bf in damage_creature(). I suspect that was intentional, as a workaround for a bug that causes anything attached to a player be shown attached to the player it's controlled by, rather which player it's attached to.
Tangent:
The fix for that bug in Shandalar is in 63df3e7, as a change to functions moved out of Shandalar.exe in e4db35d. It should be sufficient to just change return_displayed_bitfield_of_1summonsick_2tapped_4attacking_8blocking_10damage_target_player_and_damage_target_card_20oublietted() directly, removing the inst->damage_target_card != -1 check in the 0x10 bit. The other functions looking at that bit are wndproc_AttackClass(), where it won't matter since players can't attack or block, and wndproc_TerritoryClass()'s WM_USER handler, which just checks the other player's territory if the card window's not found in the territory window it thinks it belongs in.
Then you can display Curse Auras as attached to players, whee. But there's still too many things that rely on damage_creature() (and so damage_player(), which just forwards to it) creating damage attached to the damaged player to safely change that.
Re: [confirmed]AI never plays Reverse Damage

Posted:
17 Aug 2017, 07:52
by Korath
Healer's Headdress as reported
here almost certainly has the same cause.
A whole bunch of other duplicates can be found with
- Code: Select all
git grep -PnH "\bextra\s*=\s*damage_card\b"
. Instead of fixing them all individually and risking the bug showing up again in new cards, or accidentally breaking it again when you notice the "obvious error" that it can target "your" damage and "fix" it, it might be better to add a hack to validate_target_impl() to fix this at the targeting level: if extra == damage_card, then compare query_controller against 1-tgt_instance->damage_target_player instead of tgt_player. Alternately, force preferred_controller to ANYBODY there - the AI shouldn't care
whose source is damaging a given player or creature, just that it's being damaged.
Re: [confirmed]AI never plays Reverse Damage

Posted:
25 Dec 2019, 12:00
by Aswan jaguar
I used force preferred_controller to ANYBODY there as I couldn't find how to use the "extra == damage_card" way you mention which I preferred to use because it seems not likely to cause issues. Please take a look I didn't mess things up. I tested the prevent damage targeting and everything seems fine with that for both AI and human but preferred_controller there is not only for prevent damage targeting right?
Fixed this in commit d12b4dde.
I will rename this and leave it open at least for the info Korath has for display Curse Auras.
Re: [confirmed]Display curse auras correctly see Koraths pos

Posted:
12 Jan 2020, 11:55
by Aswan jaguar
Aswan jaguar wrote:Please take a look I didn't mess things up. I tested the prevent damage targeting and everything seems fine with that for both AI and human but preferred_controller there is not only for prevent damage targeting right?
Well I did mess things up as I suspected i did.
Fixed my screw up that made AI had no restrictions in which player it
targeted and followed better this time what Korath has suggested.
This time at least any screw up will be only in extra damage.
Committed in 4716b4ab.