It is currently 16 Apr 2024, 18:55
   
Text Size

Regenerate ability not working has me baffled

Moderator: CCGHQ Admins

Regenerate ability not working has me baffled

Postby Rockenchick » 22 Oct 2015, 14:46

I'm totally baffled about why this card isn't working. I've checked the majority of code for cards that regenerate an enchanted creature and most use the same code I'm using for that part of the card. It works fine otherwise, the enchantment attaches, gives the creature 2 extra toughness but the enchantment just wont regenerate the card. I get the feeling I'm overlooking something very simple but I just can't tell.

I have no idea if it's related but I get this script error too upon testing.
Code: Select all
[lua] [string "CARAPACE_184777_TITLE (RESOLUTION_TIME_ACTION)~0x0000015d"]:2: attempt to index a nil value
It wont let me post the whole card code in one post, so I'm seperating it into 2 posts.

Carapace
| Open
Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<CARD_V2 ExportVersion="1">
  <FILENAME text="CARAPACE_184777" />
  <CARDNAME text="CARAPACE" />
  <TITLE>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Carapace]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Carapace]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Carapace]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Carapace]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Carapace]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Carapace]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Carapace]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Carapace]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Carapace]]></LOCALISED_TEXT>
  </TITLE>
  <MULTIVERSEID value="184777" />
  <ARTID value="184777" />
  <ARTIST name="Anson Maddocks" />
  <CASTING_COST cost="{G}" />
  <TYPE metaname="Enchantment" />
  <SUB_TYPE metaname="Aura" />
  <EXPANSION value="ME2" />
  <RARITY metaname="C" />
  <SPELL_ABILITY attach_definition="0">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Enchant creature]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Enchant creature]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Enchant creature]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Enchant creature]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Incanta creatura]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Enchant creature]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Enchant creature]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Enchant creature]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Enchant creature]]></LOCALISED_TEXT>
    <TARGET tag="CARD_QUERY_CHOOSE_CREATURE_TO_ENCHANT" definition="0" compartment="0" count="1" />
      <TARGET_DEFINITION id="0">
         local filter = ClearFilter()
         filter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
      </TARGET_DEFINITION>
      <RESOLUTION_TIME_ACTION>
         local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
         if (target ~= nil and EffectSource() ~= nil) then
            EffectSource():Attach( target )
         end
      </RESOLUTION_TIME_ACTION>
      <AI_SIMPLIFIED_TARGETING compartment="0" hint="HINT_ALLIED_ONLY" />
   </SPELL_ABILITY>
Last edited by Rockenchick on 22 Oct 2015, 14:50, edited 1 time in total.
Rockenchick
 
Posts: 21
Joined: 16 Oct 2015, 05:05
Has thanked: 4 times
Been thanked: 2 times

Re: Regenerate ability not working has me baffled

Postby Rockenchick » 22 Oct 2015, 14:48

Part two of the code.
| Open
Code: Select all
<STATIC_ABILITY>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Enchanted creature gets +0/+2.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Enchanted creature gets +0/+2.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Enchanted creature gets +0/+2.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Enchanted creature gets +0/+2.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[La creatura incantata prende +0/+2.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Enchanted creature gets +0/+2.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Enchanted creature gets +0/+2.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Enchanted creature gets +0/+2.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Enchanted creature gets +0/+2.]]></LOCALISED_TEXT>
    <CONTINUOUS_ACTION layer="7C">
         local parent = EffectSource():GetParent()
         if parent ~= nil then
            parent:GetCurrentCharacteristics():Power_Add( 0 )
            parent:GetCurrentCharacteristics():Toughness_Add( 2 )
         end
      </CONTINUOUS_ACTION>
  </STATIC_ABILITY>
  <ACTIVATED_ABILITY>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Sacrifica il Carapace: Rigenera la creatura incantata.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
    <COST type="SacrificeSelf" />
      <RESOLUTION_TIME_ACTION>
         local parent = EffectSource():GetParent()
         if parent ~= nil then
            parent:GiveRegeneration()
         end
      </RESOLUTION_TIME_ACTION>
      <AI_AVAILABILITY window_step="declare_blockers" type="window" window_in_combat="1" />
      <AI_AVAILABILITY type="in_response" response_source="1" />
      <AI_AVAILABILITY type="restriction" restriction_type="no_regeneration_shield" />
      <AI_MODIFIERS combat_immunity="1" />
   </ACTIVATED_ABILITY>
</CARD_V2>
Rockenchick
 
Posts: 21
Joined: 16 Oct 2015, 05:05
Has thanked: 4 times
Been thanked: 2 times

Re: Regenerate ability not working has me baffled

Postby Xander9009 » 22 Oct 2015, 15:30

The problem is that once you've sacrificed it, it no longer has a parent because it's no longer attached to anything. You'll need to store that information somehow. Try something like this:
Code: Select all
   <ACTIVATED_ABILITY>
      <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Sacrifica il Carapace: Rigenera la creatura incantata.]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
      <COST type="Generic">
         <PREREQUISITE>
            return EffectSource() ~= nil and EffectSource():GetParent() ~= nil
         </PREREQUISITE>
         <RESOLUTION_TIME_ACTION>
            if EffectSource() ~= nil and EffectSource():GetParent() ~= nil
               EffectDC():Set_CardPtr(0, EffectSource():GetParent())
               EffectController():Sacrifice(EffectSource())
            end
         </RESOLUTION_TIME_ACTION>
      </COST>
      <RESOLUTION_TIME_ACTION>
         local Parent = EffectSource():Get_CardPtr(0)
         if Parent ~= nil then
            Parent:GiveRegeneration()
         end
      </RESOLUTION_TIME_ACTION>
      <AI_AVAILABILITY window_step="declare_blockers" type="window" window_in_combat="1" />
      <AI_AVAILABILITY type="in_response" response_source="1" />
      <AI_AVAILABILITY type="restriction" restriction_type="no_regeneration_shield" />
      <AI_MODIFIERS combat_immunity="1" />
   </ACTIVATED_ABILITY>
_______________________________
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: Regenerate ability not working has me baffled

Postby Rockenchick » 23 Oct 2015, 05:36

Xander9009 wrote:The problem is that once you've sacrificed it, it no longer has a parent because it's no longer attached to anything. You'll need to store that information somehow. Try something like this:
Code: Select all
   <ACTIVATED_ABILITY>
      <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Sacrifica il Carapace: Rigenera la creatura incantata.]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
      <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Sacrifice Carapace: Regenerate enchanted creature.]]></LOCALISED_TEXT>
      <COST type="Generic">
         <PREREQUISITE>
            return EffectSource() ~= nil and EffectSource():GetParent() ~= nil
         </PREREQUISITE>
         <RESOLUTION_TIME_ACTION>
            if EffectSource() ~= nil and EffectSource():GetParent() ~= nil
               EffectDC():Set_CardPtr(0, EffectSource():GetParent())
               EffectController():Sacrifice(EffectSource())
            end
         </RESOLUTION_TIME_ACTION>
      </COST>
      <RESOLUTION_TIME_ACTION>
         local Parent = EffectSource():Get_CardPtr(0)
         if Parent ~= nil then
            Parent:GiveRegeneration()
         end
      </RESOLUTION_TIME_ACTION>
      <AI_AVAILABILITY window_step="declare_blockers" type="window" window_in_combat="1" />
      <AI_AVAILABILITY type="in_response" response_source="1" />
      <AI_AVAILABILITY type="restriction" restriction_type="no_regeneration_shield" />
      <AI_MODIFIERS combat_immunity="1" />
   </ACTIVATED_ABILITY>
I understand what generic does, I think, but in this case the generic code is preventing the sacrifice of the card and probably is why it's still not working. As I'm guessing the card has to be actually sacrificed before it'll grant the regenerate ability. I tried to add an additonal cost of SacrificeSelf before that, that sacrificed it but didn't give the card it was attached to regenerate. (I doubted it would, but was worth a try). Just to be clear what I meant by that is the following:
| Open
Code: Select all
<COST type="SacrificeSelf" />
          <COST type="Generic">
         <PREREQUISITE>
            return EffectSource() ~= nil and EffectSource():GetParent() ~= nil
         </PREREQUISITE>
         <RESOLUTION_TIME_ACTION>
            if EffectSource() ~= nil and EffectSource():GetParent() ~= nil
               EffectDC():Set_CardPtr(0, EffectSource():GetParent())
               EffectController():Sacrifice(EffectSource())
            end
         </RESOLUTION_TIME_ACTION>
      </COST>
I've seen LinkedDC used before, perhaps that would work, though I'm not sure how and it seems it doesn't tend to work in cost fields either.

It's still outputing the same script error upon exit, so I'm guessing it's still related somehow (at least it does when I use the selfsacrifice code).

As an aside, I use different game folders for testing vs general playing. Usually, I test with an almost unmodded version with the exception of Data_DLC_8192_Characteristics.wad, Data_DLC_8192_ObjectDC.wad, the card to be tested, a test deck wad (I only use Manual Mana if it seems needed). Is that the right kind of setup for testing in general? I realise different cards are going to need different files depending on their requirments, I'm mostly trying to get a standard default setup.
Rockenchick
 
Posts: 21
Joined: 16 Oct 2015, 05:05
Has thanked: 4 times
Been thanked: 2 times

Re: Regenerate ability not working has me baffled

Postby thefiremind » 23 Oct 2015, 08:35

I have no idea if it works, but why not trying to use EffectSourceLKI? The last known information should remember what the parent was... at least, in theory.
Code: Select all
    <COST type="SacrificeSelf" />
    <RESOLUTION_TIME_ACTION>
       local parent = EffectSourceLKI():GetParent()
       if parent ~= nil then
          parent:GiveRegeneration()
       end
    </RESOLUTION_TIME_ACTION>
< 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: 721 times

Re: Regenerate ability not working has me baffled

Postby Xander9009 » 23 Oct 2015, 12:48

Some cards will require function files or manager files from the CW. However, in general, yeah, a default installation with only the utility mods by Riiak will work well.

As for why my code didn't work, I think it's because of the missing "then" after the "if". However, if EffectSourceLKI() works for GetParent(), use that. I simply didn't think about it, because I always think of EffectSourceLKI() for characteristics of a card rather than for stored info, but it should work.
Last edited by Xander9009 on 23 Oct 2015, 15:24, edited 1 time in total.
_______________________________
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: Regenerate ability not working has me baffled

Postby Rockenchick » 23 Oct 2015, 14:53

thefiremind wrote:I have no idea if it works, but why not trying to use EffectSourceLKI? The last known information should remember what the parent was... at least, in theory.
Code: Select all
    <COST type="SacrificeSelf" />
    <RESOLUTION_TIME_ACTION>
       local parent = EffectSourceLKI():GetParent()
       if parent ~= nil then
          parent:GiveRegeneration()
       end
    </RESOLUTION_TIME_ACTION>
Many thanks! That worked really well, it works fine now. :D
Rockenchick
 
Posts: 21
Joined: 16 Oct 2015, 05:05
Has thanked: 4 times
Been thanked: 2 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 15 guests


Who is online

In total there are 15 users online :: 0 registered, 0 hidden and 15 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 15 guests

Login Form