Page 1 of 1

[fixed/closed]Legendary and exchange of control

PostPosted: 26 Sep 2013, 21:46
by HarlequinCasts
Describe the Bug:
Can't tell if this is known or previously reported, but I've seem a few examples recently.

Exchange of control does not trigger legendary rule:

Example:
Olivia Voldaren can take control of an opponent's Olivia Voldaren and you keep both.

Nicol Bolas, Planeswalker can take control of a duplicate legendary creature.

Control Magic... etc

Which card did behave improperly ?
Legendary

Which update are you using?(date,name)Which type(Duel,Gauntlet,Sealed Deck)
OoAv1

What exactly should be the correct behavior/interaction ?
Enforce legendary rule upon exchange of control.

Are any other cards possibly affected by this bug ?
All control effects.

Re: Legendary and exchange of control

PostPosted: 27 Sep 2013, 00:19
by Gargaroz
Ah, this is an issue we never touch before... It'll take a while to fix, be patient.

Re: Legendary and exchange of control

PostPosted: 27 Sep 2013, 01:53
by HarlequinCasts
Gargaroz wrote:Ah, this is an issue we never touch before... It'll take a while to fix, be patient.
No worries. I was suspicious that it may have been an elephant in the room.

Re: [wait list]Legendary and exchange of control

PostPosted: 27 Sep 2013, 10:59
by Korath
Just responding to EVENT_CARDCONTROLLED in check_legend_rule() should be sufficient. Add the EA_CONTROLLED bit to Rules Engine or such so that the event's always dispatched; or I can make an injection to change this
Code: Select all
if (saved_instance->state & STATE_IN_PLAY)
  dword_4EF188 |= (EA_CONTROLLED | EA_FELLWAR_STONE | EA_DECLARE_ATTACK | EA_BEFORE_COMBAT | EA_FORCE_ATTACK | EA_PAID_BLOCK | EA_PAID_ATTACK | EA_LICH | EA_SELECT_BLOCK | EA_SELECT_ATTACK | EA_MARTYR) & card_data_pointers[saved_instance->internal_card_id]->extra_ability;
at the end of get_abilities() into just
Code: Select all
  dword_4EF188 |= (EA_CONTROLLED | EA_FELLWAR_STONE | EA_DECLARE_ATTACK | EA_BEFORE_COMBAT | EA_FORCE_ATTACK | EA_PAID_BLOCK | EA_PAID_ATTACK | EA_LICH | EA_SELECT_BLOCK | EA_SELECT_ATTACK | EA_MARTYR);
and we never have to worry about any of those bits in ct_all.csv ever again.

Re: [wait list]Legendary and exchange of control

PostPosted: 27 Sep 2013, 13:44
by Gargaroz
The last solutiom your proposed, Korath, it's surely the most easy, but I'll prefer a more "soft" approach.
Adding that bit to Rules Engine will not solve all the issues, as it'll require to set some specific values to "cc[2]" for all the "stealing / cloning" effects in order put the Rules Engine in play at game's start. And I'm agains putting in play Rules Engine at each game' start, even if it's not required, as it could slow down the game a lot in some cases (trap conditions, for example).
Since almost all the "exchange of control" is done via our "gain_control" functions, maybe we could add a check in the end of that.

Re: [wait list]Legendary and exchange of control

PostPosted: 27 Sep 2013, 14:10
by Korath
There was once perhaps a performance argument to be made for some of these bits - EA_PAID_ATTACK, EA_PAID_BLOCK, EA_SELECT_ATTACK, and EA_SELECT_BLOCK guard triggers that are called many times in ai combat assessment - but most were premature optimization even in 1997.

How about if we always set EA_CONTROLLED in dword_4EF188? It's only ever checked to see whether to dispatch EVENT_CARDCONTROLLED at the end of gain_control() and exchange_control(). This lets us fix the issue now, and robustly.

Re: confirmed]Legendary and exchange of control

PostPosted: 27 Sep 2013, 20:47
by Gargaroz
Ok, prepare an injection for the middle / end of October update ;)

Re: confirmed]Legendary and exchange of control

PostPosted: 11 Oct 2013, 10:29
by Korath
Fixed, 614b123 and 5eca2a6, for everything except Power Struggle.