It is currently 19 Nov 2025, 00:42
   
Text Size

Need an advice for Nettlevine Blight

Moderator: CCGHQ Admins

Need an advice for Nettlevine Blight

Postby thefiremind » 11 Oct 2012, 15:04

I'm trying to code Nettlevine Blight. The problem is: how can I let the enchanted permanent know which copy of Nettlevine Blight granted the ability that is resolving at the moment? The easiest solution would be to code Nettlevine Blight as I would have done on DotP2012, without granting any ability and letting Nettlevine Blight do everything... but if I wanted to use GrantAbility anyway, how would you suggest me to solve the problem?
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 722 times

Re: Need an advice for Nettlevine Blight

Postby RiiakShiNal » 11 Oct 2012, 15:37

I don't really remember clearly as the tests in which this occurred were so long ago now, but I seem to remember that in at least one of my GrantAbility tests Object() referred back to the card that granted the ability (instead of the card that received the ability), but it has been so long that I can't be sure until I re-run some of those tests.
RiiakShiNal
Programmer
 
Posts: 2189
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: Need an advice for Nettlevine Blight

Postby thefiremind » 11 Oct 2012, 15:40

I don't think it's true, because if I look at Cast Through Time, the granted ability always uses Object and I'm sure it doesn't refer to Cast Through Time:
Code: Select all
  <SPELL_ABILITY resource_id="1" filter_zone="ZONE_IN_PLAY" active_zone="ZONE_STACK">
    <RESOLUTION_TIME_ACTION>
    if ( Object():GetErstwhileZone() == ZONE_HAND and Object():GetResolutionZone() == ZONE_GRAVEYARD ) then
        Object():SetResolutionZone( ZONE_REMOVED_FROM_GAME )
          
       local delayDC = EffectDC():Make_Chest(100)
       delayDC:Set_CardPtr(0, Object())
       delayDC:Protect_CardPtr(0)
       MTG():CreateDelayedTrigger(2, delayDC)
    end
    </RESOLUTION_TIME_ACTION>
  </SPELL_ABILITY>
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 722 times

Re: Need an advice for Nettlevine Blight

Postby BlindWillow » 11 Oct 2012, 17:44

Can you use the ObjectDataChest of the enchanted card to point to Nettlevine Blight? I guess that would be best accomplished through the enchant spell ability part of Nettlevine.
BlindWillow
 
Posts: 213
Joined: 19 Jul 2012, 00:26
Has thanked: 11 times
Been thanked: 46 times

Re: Need an advice for Nettlevine Blight

Postby RiiakShiNal » 11 Oct 2012, 17:49

I can't find my original tests and I can't reproduce what I saw back then, so right now I know of no way to get the granting card from a granted ability.

It wouldn't be too hard to just use the granted ability to give the enchanted card the text then use either regular or delayed triggers to actually do the work, but that wasn't what the question was.

You could possibly use the object data chest to store the information for each Nettlevine Blight by using unique spots on the DC, then unfolding as they resolve, but it still won't tell you which card is the one that granted the ability that triggered. This could lead to enchanted creature moving Nettlevine Blight A from Nettlevine Blight B's granted ability or vice-versa if you have two or more Nettlevine Blights on the same permanent. Which may or may not cause problems with the granted ability from the other Nettlevine Blight.
RiiakShiNal
Programmer
 
Posts: 2189
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: Need an advice for Nettlevine Blight

Postby thefiremind » 11 Oct 2012, 17:59

BlindWillow wrote:Can you use the ObjectDataChest of the enchanted card to point to Nettlevine Blight? I guess that would be best accomplished through the enchant spell ability part of Nettlevine.
I thought about that, but I have 1 unique code that could need to point to different copies of Nettlevine Blight. Even if I made a new chest inside the ObjectDC of the enchanted card and fill it with pointers to the various Nettlevine Blights, I don't know how to distinguish them for each trigger.

EDIT: ...exactly as RiiakShiNal wrote at the same time. :D
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 722 times

Re: Need an advice for Nettlevine Blight

Postby BlindWillow » 11 Oct 2012, 18:22

Yeah, I guess I can only think of ways to work around GrantAbility. GrantAbility itself is just too crudely programmed. Worse than delayed triggers. :)
BlindWillow
 
Posts: 213
Joined: 19 Jul 2012, 00:26
Has thanked: 11 times
Been thanked: 46 times

Re: Need an advice for Nettlevine Blight

Postby thefiremind » 11 Oct 2012, 18:49

I actually found something interesting while making tests about this. I had the idea of making the granted ability create a delayed trigger at the end step, so that maybe Nettlevine Blight could keep the ownership of the delayed trigger... well it doesn't! That means that we can "nest" a delayed trigger into a granted ability, and the delayed trigger will be "owned" by the object that is using the granted ability. Probably very useful for some other cards... but it ruined my plans for this one. :lol:

EDIT: OK, this is Nettlevine Blight in "easy mode":
Code: Select all
<?xml version='1.0'?>
<CARD_V2>
  <FILENAME text="NETTLEVINE_BLIGHT_143731" />
  <CARDNAME text="NETTLEVINE_BLIGHT" />
  <TITLE>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Nettlevine Blight]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Avvizzimento di Orticanti]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Nesselrankenfäule]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Flétrissement d’ortilierre]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Ruina de parratejida]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[イラクサヅタ病]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Nettlevine Blight]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Сглаз Оплетающей Крапивы]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Ensoamento com Urtigueira]]></LOCALISED_TEXT>
  </TITLE>
  <MULTIVERSEID value="143731" />
  <ARTID value="A143731" />
  <ARTIST name="Michael Sutfin" />
  <CASTING_COST cost="{4}{B}{B}" />
  <TYPE metaname="Enchantment" />
  <SUB_TYPE metaname="Aura" />
  <EXPANSION value="LRW" />
  <RARITY metaname="R" />
  <STATIC_ABILITY attach_filter="1" filter_zone="ZONE_IN_PLAY">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Enchant creature or land]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Incanta creatura o terra]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Kreatur-oder-Land-Verzauberung]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Enchanter : créature ou terrain]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Encantar criatura o tierra.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[エンチャント(クリーチャーか土地)]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Enchant creature or land]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Зачаровать существо или землю]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Encantar criatura ou terreno]]></LOCALISED_TEXT>
    <CONTINUOUS_ACTION>
    local attach_filter = Object():AttachmentFilter_Get()
    attach_filter:Clear()
    attach_filter:AddCardType( CARD_TYPE_CREATURE )
    attach_filter:AddCardType( CARD_TYPE_LAND )
    </CONTINUOUS_ACTION>
  </STATIC_ABILITY>
  <TRIGGERED_ABILITY filter_zone="ZONE_IN_PLAY">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Enchanted permanent has “At the beginning of your end step, sacrifice this permanent and attach Nettlevine Blight to a creature or land you control.”]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Il permanente incantato ha “Alla fine del tuo turno, sacrifica questo permanente e assegna l’Avvizzimento di Orticanti a una creatura o a una terra che controlli.”]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Die verzauberte bleibende Karte hat „Opfere am Ende deines Zuges diese bleibende Karte und lege die Nesselrankenfäule an eine Kreatur oder ein Land an, die bzw. das du kontrollierst”.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Le permanent enchanté a « À la fin de votre tour, sacrifiez ce permanent et attachez le Flétrissement d’ortilierre à une créature ou un terrain que vous contrôlez. »]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[El permanente encantado tiene “Al final de tu turno, sacrifica este permanente y anexa la Ruina de parratejida a una criatura o tierra que controlas”.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[エンチャントされているパーマネントは「あなたのターンの終了時に、このパーマネントを生け贄に捧げ、イラクサヅタ病をあなたがコントロールするクリーチャーか土地につける。」を持つ。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Enchanted permanent has “At the beginning of your end step, sacrifice this permanent and attach Nettlevine Blight to a creature or land you control.”]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Зачарованный перманент имеет способность “В конце вашего хода пожертвуйте этот перманент и прикрепите Сглаз Оплетающей Крапивы к существу или земле под вашим контролем”.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[A permanente encantada tem “No final de seu turno, sacrifique esta permanente e anexe Ensoamento com Urtigueira a uma criatura ou terreno que você controla.”]]></LOCALISED_TEXT>
    <TRIGGER value="BEGINNING_OF_STEP">
    local parent = Object():GetParent()
    if parent ~= nil then
       local controller = parent:GetController()
       if controller ~= nil and TriggerPlayer() == controller and controller:MyTurn() ~= 0 and MTG():GetStep() == STEP_END_OF_TURN then
          EffectDC():Set_PlayerPtr(1, controller)
          return true
       end
    end
    return false
    </TRIGGER>
    <RESOLUTION_TIME_ACTION>
    local controller = EffectDC():Get_PlayerPtr(1)
    if controller ~= nil then
       local filter = Object():GetFilter()
       filter:Clear()
       filter:AddCardType( CARD_TYPE_CREATURE )
       filter:AddCardType( CARD_TYPE_LAND )
       filter:SetZone( ZONE_IN_PLAY )
       filter:SetController( controller )
       local parent = Object():GetParent()
       if parent ~= nil then
          filter:SetCardInstance( parent )
          filter:AddExtra( FILTER_EXTRA_FLIP_CARD_INSTANCE )
       end
       filter:NotTargetted()
       filter:SetHint( HINT_ENEMY, controller )
       controller:ChooseTarget( NO_VALIDATION, "CARD_QUERY_CHOOSE_PERMANENT_TO_ENCHANT", EffectDC():Make_Targets(6) )
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    local controller = EffectDC():Get_PlayerPtr(1)
    if controller ~= nil then
       local parent = Object():GetParent()
       if parent ~= nil then
          parent:Sacrifice( controller )
          local target = EffectDC():Get_Targets(6):Get_CardPtr(0)
          if target ~= nil then
             Object():Enchant( target )
          end
       end
    end
    </RESOLUTION_TIME_ACTION>
  </TRIGGERED_ABILITY>
  <STATIC_ABILITY filter_zone="ZONE_IN_PLAY">
    <CONTINUOUS_ACTION layer="6">
    local parent = Object():GetParent()
    if parent ~= nil then
       parent:GetCurrentCharacteristics():GrantAbility(1)
    end
    </CONTINUOUS_ACTION>
  </STATIC_ABILITY>
  <STATIC_ABILITY resource_id="1" internal="1" filter_zone="ZONE_IN_PLAY">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[At the beginning of your end step, sacrifice this permanent and attach Nettlevine Blight to a creature or land you control.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Alla fine del tuo turno, sacrifica questo permanente e assegna l’Avvizzimento di Orticanti a una creatura o a una terra che controlli.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Opfere am Ende deines Zuges diese bleibende Karte und lege die Nesselrankenfäule an eine Kreatur oder ein Land an, die bzw. das du kontrollierst.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[À la fin de votre tour, sacrifiez ce permanent et attachez le Flétrissement d’ortilierre à une créature ou un terrain que vous contrôlez.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Al final de tu turno, sacrifica este permanente y anexa la Ruina de parratejida a una criatura o tierra que controlas.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[あなたのターンの終了時に、このパーマネントを生け贄に捧げ、イラクサヅタ病をあなたがコントロールするクリーチャーか土地につける。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[At the beginning of your end step, sacrifice this permanent and attach Nettlevine Blight to a creature or land you control.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[В конце вашего хода пожертвуйте этот перманент и прикрепите Сглаз Оплетающей Крапивы к существу или земле под вашим контролем.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[No final de seu turno, sacrifique esta permanente e anexe Ensoamento com Urtigueira a uma criatura ou terreno que você controla.]]></LOCALISED_TEXT>
  </STATIC_ABILITY>
  <SPELL_ABILITY attach_filter="1" dangerous="1" filter_zone="ZONE_IN_PLAY">
    <TARGET_DEFINITION id="0">
    local filter = Object():GetFilter()
    filter:Clear()
    filter:AddCardType( CARD_TYPE_CREATURE )
    filter:AddCardType( CARD_TYPE_LAND )
    filter:SetZone( ZONE_IN_PLAY )
    filter:SetHint( HINT_ENEMY_ONLY, EffectController() )
    </TARGET_DEFINITION>
    <TARGET_DETERMINATION>
    return AtLeastOneTargetFromDefinition(0)
    </TARGET_DETERMINATION>
    <PLAY_TIME_ACTION target_choosing="1">
    EffectController():ChooseTarget( 0, "CARD_QUERY_CHOOSE_PERMANENT_TO_ENCHANT", EffectDC():Make_Targets(0) )
    </PLAY_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    local target_card = EffectDC():Get_Targets(0):Get_CardPtr(0)
    if target_card ~= nil then
          Object():Enchant( target_card )
    end
    </RESOLUTION_TIME_ACTION>
  </SPELL_ABILITY>
  <AI_BASE_SCORE score="2400" zone="ZONE_HAND" />
</CARD_V2>
It does what it should, so I'll leave it like this if no better solutions come up.

EDIT: Slightly modified to take care of the case when the Aura leaves play but the enchanted permanent doesn't.
Last edited by thefiremind on 13 Oct 2012, 15:33, edited 1 time in total.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 722 times

Re: Need an advice for Nettlevine Blight

Postby BlindWillow » 12 Oct 2012, 15:33

One thing that occurs to me is to base things on the order the game engine has things trigger. I assume this would be in the order cards are originally played. If so, wouldn't this allow for us to distinguish between Nettlevine Blights? Basically, we could keep appending Nettlevine Blights to the parent card's datachest and then for the trigger clear them as we go. I don't know if that actually translates to anything code-able in the game, but in my mind it's code-able. :lol:
BlindWillow
 
Posts: 213
Joined: 19 Jul 2012, 00:26
Has thanked: 11 times
Been thanked: 46 times

Re: Need an advice for Nettlevine Blight

Postby RiiakShiNal » 12 Oct 2012, 20:29

BlindWillow wrote:One thing that occurs to me is to base things on the order the game engine has things trigger. I assume this would be in the order cards are originally played.
This seems to be the case cards that are placed on the battlefield first do seem to trigger/work first.
BlindWillow wrote:If so, wouldn't this allow for us to distinguish between Nettlevine Blights? Basically, we could keep appending Nettlevine Blights to the parent card's datachest and then for the trigger clear them as we go. I don't know if that actually translates to anything code-able in the game, but in my mind it's code-able. :lol:
No, that wouldn't work because of this scenario (Which could happen):
  1. Player A plays Nettlevine Blight A on one of Player B's permanents.
  2. Player A plays Nettlevine Blight B on a different one of Player B's permanents.
  3. --== So far Everything is good ==--
  4. Player B's turn starts.
  5. To protect one of the permanents Player B uses a card or effect that allows an enchantment to be moved from one permanent he/she controls to another he/she controls. This effect moves Nettlevine Blight B to the same permanent that Nettlevine Blight A is already on.
  6. --== Now we have an issue ==--
    • If the card is coded to remove from the beginning of the list and shift everything later in the list down (or to skip nulls) then it will fail as the entries will be reversed.
    • If the card is coded to remove from the last on the list going up the list then this could work.
  7. Assuming it works then Nettlevine Blight A triggers.
  8. Nettlevine Blight B triggers and resolves. Player B puts it on an extra land, Nettlevine Blight B added to DC.
  9. Nettlevine Blight A resolves. Player B puts it on the same extra land, Nettlevine Blight A added to DC.
  10. Player A's Turn starts and ends then Player B's turn starts and ends.
  11. --== Now we have an issue ==--
    • If the card is coded to remove from the beginning of the list and shift everything later in the list down (or to skip nulls) then it could work for this case.
    • If the card is coded to remove from the last on the list going up the list then it would fail in this case because the entries would be reversed.
  12. --== There is no way for it to work properly here if it worked properly earlier because no matter how it is coded either it will fail earlier than this point or it will fail here because they have been put in the DC in two different orders. ==--
RiiakShiNal
Programmer
 
Posts: 2189
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: Need an advice for Nettlevine Blight

Postby BlindWillow » 13 Oct 2012, 02:11

Last idea and then I surrender: the Cloudpost route. Each Nettlevine Blight gives itself a unique index when it enters the battlefield (possibly using filter:EvaluateObjects() to check the data chest of all Nettlevine Blights already on the battlefield to assign an unused index) and grants an ability that corresponds to that index which in turn references the associatively indexed Nettlevine.
BlindWillow
 
Posts: 213
Joined: 19 Jul 2012, 00:26
Has thanked: 11 times
Been thanked: 46 times

Re: Need an advice for Nettlevine Blight

Postby RiiakShiNal » 13 Oct 2012, 13:40

BlindWillow wrote:Last idea and then I surrender: the Cloudpost route. Each Nettlevine Blight gives itself a unique index when it enters the battlefield (possibly using filter:EvaluateObjects() to check the data chest of all Nettlevine Blights already on the battlefield to assign an unused index) and grants an ability that corresponds to that index which in turn references the associatively indexed Nettlevine.
That could work, though to ensure it would work under all legal cases you would need to put in 16 indexed abilities (4 Nettlevine Blights, in up to 4 decks). Seems like a lot of extra code when it can be done more simply by using either regular or delayed trigger abilities instead of granted abilities.
RiiakShiNal
Programmer
 
Posts: 2189
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times

Re: Need an advice for Nettlevine Blight

Postby BlindWillow » 13 Oct 2012, 14:33

RiiakShiNal wrote:Seems like a lot of extra code when it can be done more simply by using either regular or delayed trigger abilities instead of granted abilities.
Yeah, I think we're well into thought experiment territory now. :) Still, an informative discussion.
BlindWillow
 
Posts: 213
Joined: 19 Jul 2012, 00:26
Has thanked: 11 times
Been thanked: 46 times

Re: Need an advice for Nettlevine Blight

Postby sadlyblue » 13 Oct 2012, 16:27

If you don't use the grant ability wouldn't it cause a conflict with if the same player has a Sigarda, Host Of Herons and a permanent enchanted with Nettlevine Blight?
sadlyblue
 
Posts: 175
Joined: 06 Feb 2012, 13:18
Has thanked: 18 times
Been thanked: 16 times

Re: Need an advice for Nettlevine Blight

Postby thefiremind » 13 Oct 2012, 18:00

sadlyblue wrote:If you don't use the grant ability wouldn't it cause a conflict with if the same player has a Sigarda, Host Of Herons and a permanent enchanted with Nettlevine Blight?
#-o So it seems I'll have to develop BlindWillow's idea after all... or strive to find an easier one, if possible.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 722 times

Next

Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 14 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 14 users online :: 0 registered, 0 hidden and 14 guests (based on users active over the past 10 minutes)
Most users ever online was 9824 on 10 Nov 2025, 04:33

Users browsing this forum: No registered users and 14 guests

Login Form