It is currently 16 Apr 2024, 06:12
   
Text Size

Help fixing an Origins PW

Moderator: CCGHQ Admins

Help fixing an Origins PW

Postby fallenangle » 26 Oct 2015, 20:14

I've been dissatisfied with the way Origins PWs work, and I've been trying to work out a different way to code them. To that end, I've added the following lines to the PLW.LOL:

Code: Select all
PLWORI_NameSet = function(nameset, index)
local t = {}

t.EINHANDER = {
         "OBLIVION_RING",
         "SKYBIND",
         "QUARANTINE_FIELD",
         "GLIMMERPOINT_STAG",
         "EXCLUSION_RITUAL",
         "DETENTION_SPHERE",
         "BANISHING_LIGHT",
         "ADMONITION_ANGEL"
         }
return t[nameset:upper()][index]
end

PLWORI_IsInNameSet = function(card, nameset)
-- returns true if card's name is in the given nameset
   if card ~= nil and nameset ~= nil then
      local index = 1
      local name = PLWORI_NameSet(nameset, 1)
      while name ~= nil do
         if card:GetCardName() == name then
            return true
         end
         index = index + 1
         name = PLWORI_NameSet(nameset, index)
      end
   end
   return false
end

PLWORI_FilterNameSet = function()
-- The Origins Planeswalker redirection filter
-- adds the given nameset to the filter (condition=true/1 means to include the names, otherwise the names will be excluded)
   if filter ~= nil and nameset ~= nil then
      local locfilter = filter
      local operator = OP_NOT
      if condition == 1 or condition == true then
         locfilter = filter:AddSubFilter_Or()
         operator = OP_IS
      end
      local index = 1
      local name = PLWORI_NameSet(nameset, 1)
      while name ~= nil do
         locfilter:Add(FE_CARD_NAME, operator, name)
         index = index + 1
         name = PLWORI_NameSet(nameset, index)
      end
   end
end
I'm trying to use this code so that if the token created by the walker is exiled by one of the cards in the EINHANDER NameSet, and that card subsequently becomes nil, the original creature will return to the battlefield under its owner's control. (I know that this is only one step toward a solution; but for me it's the most difficult and complex, so that's where I'm starting.) My test card is a Nissa, Vastwood Seer, with the following relevant code:

Code: Select all
<TRIGGERED_ABILITY>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Whenever a land enters the battlefield under your control, if you control seven or more lands, exile Nissa, then return her to the battlefield transformed under her owner's control.]]></LOCALISED_TEXT>
<TRIGGER value="ZONECHANGE_END" simple_qualifier="objectyoucontrol" to_zone="ZONE_BATTLEFIELD" from_zone="ZONE_ANY">
         return TriggerObject():GetCardType():Test( CARD_TYPE_LAND ) and EffectSource():GetZone() ~= ZONE_EXILE and EffectSource():GetZone() ~= ZONE_GRAVEYARD
      </TRIGGER>
<RESOLUTION_TIME_ACTION>
local filter = ClearFilter()
filter:Add( FE_TYPE, OP_IS, CARD_TYPE_LAND )
filter:Add(FE_CONTROLLER, OP_IS, EffectController())
local total = filter:Count()
if total &gt;= 7 and EffectSource() ~= nil then
local chest = EffectDC():Make_Chest(8)
chest:Set_CardPtr(0, EffectSource())
chest:Protect_CardPtr(0)
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local chest = EffectDC():Get_Chest(8)
if chest ~= nil and EffectSource() ~= nil then
EffectDC():Protect_CardPtr( COMPARTMENT_ID_EFFECT_SOURCE )
EffectSource():Exile()
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
if EffectSource():GetZone() == ZONE_EXILE then
MTG():PutTokensOntoBattlefield( "_NISSA_SAGE_ANIMIST_FA_4320005", 1, EffectSource():GetOwner(), EffectDC():Make_Chest(12)  )
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local chest = EffectDC():Get_Chest(12)
         if chest ~= nil then
            local token = chest:Get_NthCardPtr(0)
            local source_chest = EffectDC():Get_Chest(8)
            if source_chest ~= nil then
            local Source = EffectDC():Get_Chest(8):Get_CardPtr(0)
            if token ~= nil and Source ~= nil then
            Source:NailOnto(token)
            end
               end
                  end
            </RESOLUTION_TIME_ACTION>
            <RESOLUTION_TIME_ACTION>
            local chest = EffectDC():Get_Chest(12)
         if chest ~= nil then
            local token = chest:Get_NthCardPtr(0)
            local source_chest = EffectDC():Get_Chest(8)
            if source_chest ~= nil then
            local Source = EffectDC():Get_Chest(8):Get_CardPtr(0)
            if token ~= nil and Source ~= nil then
            local delayDC = EffectDC():Make_Chest(27)
            delayDC:Set_CardPtr(0, token)
            delayDC:Set_CardPtr(1, Source)
            delayDC:Protect_CardPtr(0)
            delayDC:Protect_CardPtr(1)
            MTG():CreateDelayedTrigger(19, delayDC)
            end
               end
                  end
                  </RESOLUTION_TIME_ACTION>
            <CLEANUP fire_once="1" />
</TRIGGERED_ABILITY>

<TRIGGERED_ABILITY resource_id="19" replacement_effect="1">
<TRIGGER value="BECAME_TARGET_OF_ABILITY">
return TriggerObject() == EffectDC():Get_Chest(27):Get_CardPtr(0) and PLWORI_IsInNameSet(SecondaryObject(), "EINHANDER")
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local chest = EffectDC():Get_Chest(27)
local Source = EffectDC():Get_Chest(27):Get_CardPtr(1)
local secondary_object = SecondaryObject()
if chest ~= nil and Source ~= nil and secondary_object ~= nil then
local delayDC = EffectDC():Make_Chest(5)
delayDC:Set_CardPtr(0, Source)
delayDC:Set_CardPtr(1, secondary_object)
delayDC:Protect_CardPtr(0)
delayDC:Protect_CardPtr(1)
MTG():CreateDelayedTrigger(14, delayDC)
MTG():CreateDelayedTrigger(15, delayDC)
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>

<TRIGGERED_ABILITY resource_id="14" replacement_effect="1">
<TRIGGER value="ZONECHANGE_BEGIN" from_zone="ZONE_BATTLEFIELD" to_zone="ZONE_ANY">
return TriggerObject() == EffectDC():Get_Chest(5):Get_CardPtr(1)
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local chest = EffectDC():Get_Chest(5)
if chest ~= nil then
local card = EffectDC():Get_Chest(5):Get_CardPtr(0)
if card:GetZone() == ZONE_EXILE then
card:PutOntoBattlefield(card:GetOwner())
end
   end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>

<TRIGGERED_ABILITY resource_id="15" replacement_effect="1">
<TRIGGER value="ZONECHANGE_BEGIN" from_zone="ZONE_BATTLEFIELD" to_zone="ZONE_EXILE">
return TriggerObject() == EffectDC():Get_Chest(5):Get_CardPtr(1)
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local chest = EffectDC():Get_Chest(5)
if chest ~= nil then
local card = EffectDC():Get_Chest(5):Get_CardPtr(0)
if card:GetZone() == ZONE_EXILE then
card:PutOntoBattlefield(card:GetOwner())
end
   end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
Every time I test this card, I get the following error: [lua] [string "NISSA_VASTWOOD_SEER_FA_CW_398438_TITLE (TRIGGER)~0x000003bb"]:2: attempt to index a nil value
[

Can anyone pinpoint where I've gone wrong and help me get back onto the right track? Any help would be greatly appreciated.
fallenangle
 
Posts: 319
Joined: 20 Jul 2013, 02:31
Has thanked: 73 times
Been thanked: 41 times

Re: Help fixing an Origins PW

Postby Xander9009 » 27 Oct 2015, 00:21

I promise I'm not ignoring the email. I've just been a bit busy/distracted.

Before I examine the code in depth, a question: you mention it's to solve a problem, but you don't specify the problem. Is the issue that when they're exiled as a planeswalker, they return as a planeswalker?
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2905
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 121 times
Been thanked: 445 times

Re: Help fixing an Origins PW

Postby fallenangle » 27 Oct 2015, 02:16

The "problems" I'm trying to fix are three: 1) The Origins Walkers continue to use the art of the creatures when they transform, rather than the art of the planeswalkers they become. 2) The creatures don't fully transform because they don't lose their legendary supertypes; and 3) multiple copies of transformed Origins walkers can currently be on the battlefield at the same time, which shouldn't be possible.

Edit: I know that the error comes from the fact that I try to call a SecondaryObject() when no secondary objects are possible.
fallenangle
 
Posts: 319
Joined: 20 Jul 2013, 02:31
Has thanked: 73 times
Been thanked: 41 times

Re: Help fixing an Origins PW

Postby fallenangle » 27 Oct 2015, 03:23

I tried rewriting the code after looking at what TFM did to prevent planeswalkers from being targeted, and now I don't get an error, but the code still doesn't work as I intend--when the permanents I specified in the filter are the targeting secondary objects of the Origins walkers, and they subsequently change zones, the creature doesn't get put onto the battlefield under its owner's control. I'm not sure what I'm doing wrong; but here is the code for the relevant abilities that I have now:

Code: Select all
<TRIGGERED_ABILITY>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Whenever a land enters the battlefield under your control, if you control seven or more lands, exile Nissa, then return her to the battlefield transformed under her owner's control.]]></LOCALISED_TEXT>
<TRIGGER value="ZONECHANGE_END" simple_qualifier="objectyoucontrol" to_zone="ZONE_BATTLEFIELD" from_zone="ZONE_ANY">
         return TriggerObject():GetCardType():Test( CARD_TYPE_LAND ) and EffectSource():GetZone() ~= ZONE_EXILE and EffectSource():GetZone() ~= ZONE_GRAVEYARD
      </TRIGGER>
<RESOLUTION_TIME_ACTION>
local filter = ClearFilter()
filter:Add( FE_TYPE, OP_IS, CARD_TYPE_LAND )
filter:Add(FE_CONTROLLER, OP_IS, EffectController())
local total = filter:Count()
if total &gt;= 7 and EffectSource() ~= nil then
local chest = EffectDC():Make_Chest(8)
chest:Set_CardPtr(0, EffectSource())
chest:Protect_CardPtr(0)
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local chest = EffectDC():Get_Chest(8)
if chest ~= nil and EffectSource() ~= nil then
EffectDC():Protect_CardPtr( COMPARTMENT_ID_EFFECT_SOURCE )
EffectSource():Exile()
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
if EffectSource():GetZone() == ZONE_EXILE then
MTG():PutTokensOntoBattlefield( "_NISSA_SAGE_ANIMIST_FA_4320005", 1, EffectSource():GetOwner(), EffectDC():Make_Chest(12)  )
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local chest = EffectDC():Get_Chest(12)
         if chest ~= nil then
            local token = chest:Get_NthCardPtr(0)
            local source_chest = EffectDC():Get_Chest(8)
            if source_chest ~= nil then
            local Source = EffectDC():Get_Chest(8):Get_CardPtr(0)
            if token ~= nil and Source ~= nil then
            Source:NailOnto(token)
            end
               end
                  end
            </RESOLUTION_TIME_ACTION>
            <CLEANUP fire_once="1" />
</TRIGGERED_ABILITY>

<TRIGGERED_ABILITY replacement_effect="1">
<TRIGGER value="CARD_CONSIDERED_FOR_TARGETTING">
local filter = ClearFilter()
local target = TriggerObject()
local targetter = SecondaryObject()
if target == EffectDC():Get_Chest(12):Get_NthCardPtr(0) and
target:GetCardName() == "NISSA_SAGE_ANIMIST" and
( PLWORI_IsInNameSet(targetter, "EINHANDER") ) then
return true
end
return false
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local chest = EffectDC():Get_Chest(8)
local Source = EffectDC():Get_Chest(8):Get_CardPtr(0)
local secondary_object = SecondaryObject()
if chest ~= nil and Source ~= nil and secondary_object ~= nil then
local delayDC = EffectDC():Make_Chest(5)
delayDC:Set_CardPtr(0, Source)
delayDC:Set_CardPtr(1, secondary_object)
delayDC:Protect_CardPtr(0)
delayDC:Protect_CardPtr(1)
MTG():CreateDelayedTrigger(14, delayDC)
MTG():CreateDelayedTrigger(15, delayDC)
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>

<TRIGGERED_ABILITY resource_id="14" replacement_effect="1">
<TRIGGER value="ZONECHANGE_BEGIN" from_zone="ZONE_BATTLEFIELD" to_zone="ZONE_ANY">
return TriggerObject() == EffectDC():Get_Chest(5):Get_CardPtr(1)
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local chest = EffectDC():Get_Chest(5)
if chest ~= nil then
local card = EffectDC():Get_Chest(5):Get_CardPtr(0)
if card:GetZone() == ZONE_EXILE then
card:PutOntoBattlefield(card:GetOwner())
end
   end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>

<TRIGGERED_ABILITY resource_id="15" replacement_effect="1">
<TRIGGER value="ZONECHANGE_BEGIN" from_zone="ZONE_BATTLEFIELD" to_zone="ZONE_EXILE">
return TriggerObject() == EffectDC():Get_Chest(5):Get_CardPtr(1)
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local chest = EffectDC():Get_Chest(5)
if chest ~= nil then
local card = EffectDC():Get_Chest(5):Get_CardPtr(0)
if card:GetZone() == ZONE_EXILE then
card:PutOntoBattlefield(card:GetOwner())
end
   end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
Any help or advice would be greatly appreciated.
fallenangle
 
Posts: 319
Joined: 20 Jul 2013, 02:31
Has thanked: 73 times
Been thanked: 41 times

Re: Help fixing an Origins PW

Postby Xander9009 » 27 Oct 2015, 03:43

The picture only seems to change if the color changes. I have no idea why, but various werewolves suffer the same bug. Since they're in exile, see if you can set up a series of triggers to make them: 1-exile, 2-change color (in a continuous action), 3-transform, 4-change color back (by making the previous continuous action's duration block return true), 5-put onto battlefield. I have no idea if it will work, but it might.

The trigger CONSIDERED_FOR_TARGETING would help in preventing a card from being targeted, but it doesn't say anything about whether or not it was actually chosen as a target.

For the multiple planeswalkers problem, they might need to handle that on the cards themselves. THe manager should normally handle it, but it might be on a lower layer than the planeswalkers use when calling UseStoredCharacteristics or whatever the function is. So, the manager only sees the creature. The code for selecting planeswalkers may need added to the planeswalkers themselves on a higher layer. Specifically, Gideon should only check for Gideon, and the same for the others.
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2905
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 121 times
Been thanked: 445 times

Re: Help fixing an Origins PW

Postby Xander9009 » 27 Oct 2015, 15:29

Oh, I forgot to mention it, but I recall someone mentioning they managed to add the legendary supertype. So, it's possible you could remove it by getting writable supertypes and clearing all of them. They shouldn't ever have any others (or at least not often enough to matter).
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2905
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 121 times
Been thanked: 445 times

Help fixing an Origins PW

Postby Randalllsaine » 02 Jan 2017, 15:44

That is good news, PA furtaker. Might be a good idea to share with the forum, as it might help somebody else who has a problem.
Randalllsaine
 
Posts: 2
Joined: 02 Jan 2017, 12:28
Has thanked: 0 time
Been thanked: 0 time


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 18 guests


Who is online

In total there are 18 users online :: 0 registered, 0 hidden and 18 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 18 guests

Login Form