Page 1 of 1

[fixed/closed]Protection from creatures

PostPosted: 23 Aug 2013, 12:23
by stassy
Just wanted confirmation that Protection from creatures is an approx of unblockable + autoregen, because creatures/enchantment like Beloved Chaplain, Commander Eesha, Spirit Mantle, Holy Mantle and Teysa, Envoy of Ghosts have/give unblockable effect, auto regen vs non combat damage type like Prodigal Sorcerer but not against non combat lethal effect like Royal Assassin.

Also applies to:
Protection from multicolored (ex. Soldier of the Pantheon)

Re: Protection from creatures

PostPosted: 23 Aug 2013, 23:47
by Korath
There doesn't seem to be any barrier to correctly implementing protection from creatures.

Targetability against KEYWORD_PROT_CREATURES already works, exactly the same as from colors, artifacts, sorceries, instants, and lands. This is usually the hard part of implementing protection from unusual things.

Blocking seems indistinguishable from normal unblockability; but even if it weren't, EVENT_BLOCK_LEGALITY is dispatched in exactly the same place as protection from colors and artifacts is checked. (Protection from lands doesn't work here automatically either, nor does protection from enchantments. Though protection from enchantments was more or less completely broken by shroud, and I can't recall if Lucent Liminid works anyway.)

Enchanting/equipping isn't relevant for protection from creatures (though see below). That needs to be explicitly handled by the card function for protection from colors anyway.

I don't know the damage prevention functions well enough yet to be completely sure, but it looks like damage reduction is handled as a side-effect of destroying protected-from auras. If that's impractical, handling EVENT_PREVENT_DAMAGE by destroying the attached damage card should work.

Re: Protection from creatures

PostPosted: 24 Aug 2013, 23:30
by Gargaroz
The problem is, "KEYWORD_PROT_CREATURES" originally was "Banding when attacking", so if you simply use it, that will enable that effect too. And yes, it's an approximation right now.

Re: Protection from creatures

PostPosted: 24 Aug 2013, 23:36
by Korath
OK, I'll fix it properly once the Mana Flare wreck is behind me.

Have you decided on something to reassign protection from interrupts to? Or are you leaving it as changeling?

Re: Protection from creatures

PostPosted: 25 Aug 2013, 12:33
by Gargaroz
For now, it'll remain as "Changling" placeholder. I removed it from the "real_validate_target" so there shouldn't be any more problems with a Cryptic Command targeting Chameleon Colossus and such.

Re: Protection from creatures

PostPosted: 05 Dec 2013, 15:24
by Aswan jaguar
Describe the Bug:
AI destroyed my creature with Royal Assassin which was enchanted with Spirit Mantle.

Which card did behave improperly ?
Protection from creatures?Royal Assassin?Spirit Mantle to ASM coded cards?

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

What exactly should be the correct behavior/interaction ?
Protection from creatures,protects also from abilities of creatures that target.

Are any other cards possibly affected by this bug ?

Re: [confirmed]Protection from creatures

PostPosted: 05 Dec 2013, 17:44
by Korath
Damage reduction's done in the damage card's function, fx_damage_901() at 0x4a0f00.

The way forward here looks to be:
  1. Make an is_protected_from() function, which checks the protections that have their own bits (each color, artifacts, instants, sorceries, lands), and sends an event only to the card being checked. The current is_protected_from_me(), which checks for specific card ids, isn't scalable.
  2. Co-opt one of the rarer ability bits, like KEYWORD_PROT_INSTANTS, KEYWORD_PROT_SORCERIES, or KEYWORD_PROT_LANDS, to indicate "this card has been granted an unusual protection"; if set, make is_protected_from() send its event to all cards instead. This is about the most straightforward way I can see to implement effects like Riders of Gavony, Holy Mantle, or Guildscorn Ward. (As far as I've found so far, 1<<23 and 1<<31 are completely unused, so they're candidates too.)
  3. Move the damage card into C, so we can add a protection check.
  4. The main blockability function's been moved into C, so adding a protection check there will be easy.
  5. Targeting already has access to the source card now, so adding a protection check there will be easy for most cases. It's not going to work quite right for cases where it's not really the original source that's doing the targeting, like for Fire Whip or Mortarpod or anything else that reads like "X has '[cost]: This creature deals Y damage to whatever'", nor for cases where targetting has to be done by an auxiliary effect card. On the plus side, those cases are and will remain easy to find if we can figure out how to fix them properly; they all call get_protections_from() directly, and almost nothing else in the C codebase does.
  6. Handle equipment/auras falling off in either recalculate_all_cards_in_play() (already moved to C) or reassess_all_cards() at 0x472260; I'm not sure which is more appropriate yet. Doing it continuously on either the attaching card (as with equipment) or attached-to card (as with auras) clearly doesn't work, though - see the Mishra's Factory + equipment bug, or how only a small handful of even the original exe cards will unenchant themselves if you attach an aura to them and then lace it to a color they're protected from - and I don't think it can practically be made to. This is the biggest stumbling block.

Re: [waitlist]Protection from creatures

PostPosted: 30 Apr 2014, 05:14
by stassy
I didn't see if the waitlist issue also affect lethal multicolored spell target such as Dreadbore so giving an up to be sure

Image

Re: [waitlist]Protection from creatures

PostPosted: 30 Apr 2014, 09:53
by Korath
Yes, protection from anything except artifacts and specific colors all use the same workaround currently.

Re: [waitlist]Protection from creatures

PostPosted: 17 Feb 2022, 14:54
by Aswan jaguar
These should be fixed by drool66 in commit c04a46f.