It is currently 19 Jun 2019, 05:19
   
Text Size

LinkedDC cannot pass data from a trigger to a spell?

Moderators: Xander9009, CCGHQ Admins

LinkedDC cannot pass data from a trigger to a spell?

Postby Rholin » 09 Oct 2016, 03:33

I want to create a new type of ability called "overspell" which consists in 2 effects:
1. If this card is in your hand, whenever you cast a sorcery or instant, it gains a overspell point.
2. when you cast this spell, it will have extra effect according to it's overspell point number.

For example, I made a card "Insight":
Code: Select all
   <SPELL_ABILITY linked_ability_group="0">
      <LOCALISED_TEXT LanguageCode="en-US">Draw a card.</LOCALISED_TEXT>
      <RESOLUTION_TIME_ACTION>
         if EffectSource() ~= nil then
            local n = LinkedDC():Get_Int("overspell")
            EffectController():DrawCards(1+n)
            LinkedDC():Set_Int("overspell",0)
         end
      </RESOLUTION_TIME_ACTION>
   </SPELL_ABILITY>
   <TRIGGERED_ABILITY active_zone="ZONE_ANY" replacement_effect="1" linked_ability_group="0">
      <LOCALISED_TEXT LanguageCode="en-US">Overspell:</LOCALISED_TEXT>
      <TRIGGER value="SPELL_PLAYED" simple_qualifier="controller">
         return (TriggerObject():GetCardType():Test(CARD_TYPE_SORCERY) or TriggerObject():GetCardType():Test(CARD_TYPE_INSTANT)) and (TriggerObject() ~= EffectSource())
      </TRIGGER>
      <RESOLUTION_TIME_ACTION>
         if EffectSource() ~= nil then
            if LinkedDC():Get_Int("overspell") == nil then
               LinkedDC():Set_Int("overspell",0)
            end
            local ovsp = LinkedDC():Get_Int("overspell")
            LinkedDC():Set_Int("overspell", ovsp+1)
         end
      </RESOLUTION_TIME_ACTION>
      <DERIVED_INFO tag="DERIVED_INFO_X_OVSP_ON_THIS_CARD">
         return LinkedDC():Get_Int("overspell")
      </DERIVED_INFO>
   </TRIGGERED_ABILITY>
   <QUERYTEXT tag="DERIVED_INFO_X_OVSP_ON_THIS_CARD">
      <LOCALISED_TEXT LanguageCode="en-US">draw %d card(s) more</LOCALISED_TEXT>
   </QUERYTEXT>
In the game, the overspell trigger works but when the card is in the stack zone, the LinkedDC():Get_Int("overspell") is always 0.
Last edited by Rholin on 09 Oct 2016, 04:23, edited 1 time in total.
Rholin
 
Posts: 5
Joined: 04 Oct 2016, 06:33
Has thanked: 1 time
Been thanked: 0 time

Re: LinkedDC cannot pass data from a trigger to a spell?

Postby Xander9009 » 09 Oct 2016, 04:05

First up, on lines 21 and 22, you can just use LinkedDC():Add_Int("overspell", 1).

The issue is probably that on line 5, you're getting the int stored in DuelDataChest instead of LinkedDC().

If that doesn't work, then here, try this code.
Code: Select all
   <SPELL_ABILITY>
      <LOCALISED_TEXT LanguageCode="en-US">Draw a card.</LOCALISED_TEXT>
      <RESOLUTION_TIME_ACTION>
         local oController = EffectController()
         local oSource = EffectSource()
         if oController ~= nil and oSource ~= nil then
            local oPlayerDC = oController:PlayerDataChest()
            if oPlayerDC ~= nil then
               local oOverspellDC = oPlayerDC:Get_Chest("Overspell_Chest_Register")
               if oOverspellDC ~= nil then
                  local oSpells = oOverspellDC:Get_Chest(1)
                  local oCounts = oOverspellDC:Get_Chest(2)
                  for i=0;oOverspellDC:Get_Int(0) do
                     if oSpells:Get_CardPtr(i) == oSource then
                        EffectController():DrawCards(Counts:Get_Int(i)+1)
                        Counts:Set_Int(0)
                     end
                  end
               end
            end
         end
         return 0
      </RESOLUTION_TIME_ACTION>
   </SPELL_ABILITY>
   <TRIGGERED_ABILITY active_zone="ZONE_ANY" replacement_effect="1">
      <LOCALISED_TEXT LanguageCode="en-US">Overspell:</LOCALISED_TEXT>
      <TRIGGER value="SPELL_PLAYED" simple_qualifier="objectyoucontrol">
         return TriggerObject() ~= nil and (TriggerObject():GetCardType():Test(CARD_TYPE_INSTANT) or TriggerObject():GetCardType():Test(CARD_TYPE_SORCERY))
      </TRIGGER>
      <RESOLUTION_TIME_ACTION>
         local oController = EffectController()
         local oSource = EffectSource()
         if oController ~= nil and oSource ~= nil then
            local oPlayerDC = oController:PlayerDataChest()
            if oPlayerDC ~= nil then
               local oOverspellDC = oPlayerDC:Get_Chest("Overspell_Chest_Register")
               if oOverspellDC == nil then
                  oOverspellDC = oPlayerDC:Make_Chest("Overspell_Chest_Register")
                  if oOverspellDC ~= nil then
                     oOverspellDC:Make_Chest(1)
                     oOverspellDC:Make_Chest(2)
                  end
               end
               if oOverspellDC ~= nil then
                  local oSpells = oOverspellDC:Get_Chest(1)
                  local oCounts = oOverspellDC:Get_Chest(2)
                  for i=0;oOverspellDC:Get_Int(0) do
                     if oSpells:Get_CardPtr(i) == oSource then
                        oCounts:Int_Add(i, 1)
                        break
                     end
                  end
               end
            end
         end
      </RESOLUTION_TIME_ACTION>
      <DERIVED_INFO tag="DERIVED_INFO_X_OVSP_ON_THIS_CARD">
         local oController = EffectController()
         local oSource = EffectSource()
         if oController ~= nil and oSource ~= nil then
            local oPlayerDC = oController:PlayerDataChest()
            if oPlayerDC ~= nil then
               local oOverspellDC = oPlayerDC:Get_Chest("Overspell_Chest_Register")
               if oOverspellDC ~= nil then
                  local oSpells = oOverspellDC:Get_Chest(1)
                  local oCounts = oOverspellDC:Get_Chest(2)
                  for i=0;oOverspellDC:Get_Int(0) do
                     if oSpells:Get_CardPtr(i) == oSource then
                        return oCounts:Get_Int(i)
                     end
                  end
               end
            end
         end
         return 0
      </DERIVED_INFO>
   </TRIGGERED_ABILITY>
   <QUERYTEXT tag="DERIVED_INFO_X_OVSP_ON_THIS_CARD">
      <LOCALISED_TEXT LanguageCode="en-US">draw %d card(s) more</LOCALISED_TEXT>
   </QUERYTEXT>
Note that I code for 2014, so I can't guarantee any of this (or even test it).
Last edited by Xander9009 on 09 Oct 2016, 06:35, 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: 2880
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 116 times
Been thanked: 435 times

Re: LinkedDC cannot pass data from a trigger to a spell?

Postby Rholin » 09 Oct 2016, 04:22

Xander9009 wrote:First up, on lines 21 and 22, you can just use LinkedDC():Add_Int("overspell", 1).

The issue is probably that on line 5, you're getting the int stored in DuelDataChest instead of LinkedDC().

If that doesn't work, then here, try this code.
Code: Select all
   <SPELL_ABILITY>
      <LOCALISED_TEXT LanguageCode="en-US">Draw a card.</LOCALISED_TEXT>
      <RESOLUTION_TIME_ACTION>
         local oController = EffectController()
         local oSource = EffectSource()
         if oController ~= nil and oSource ~= nil then
            local oPlayerDC = oController:PlayerDataChest()
            if oPlayerDC ~= nil then
               local oOverspellDC = oPlayerDC:Get_Chest("Overspell_Chest_Register")
               if oOverspellDC == nil then
                  oOverspellDC = oPlayerDC:Make_Chest("Overspell_Chest_Register")
                  if oOverspellDC ~= nil then
                     oOverspellDC:Make_Chest(1)
                     oOverspellDC:Make_Chest(2)
                  end
               end
               if oOverspellDC ~= nil then
                  local oSpells = oOverspellDC:Get_Chest(1)
                  local oCounts = oOverspellDC:Get_Chest(2)
                  for i=0;oOverspellDC:Get_Int(0) do
                     if oSpells:Get_CardPtr(i) == oSource then
                        EffectController():DrawCards(Counts:Get_Int(i)+1)
                        Counts:Set_Int(0)
                     end
                  end
               end
            end
         end
         return 0
      </RESOLUTION_TIME_ACTION>
   </SPELL_ABILITY>
   <TRIGGERED_ABILITY active_zone="ZONE_ANY" replacement_effect="1">
      <LOCALISED_TEXT LanguageCode="en-US">Overspell:</LOCALISED_TEXT>
      <TRIGGER value="SPELL_PLAYED" simple_qualifier="objectyoucontrol">
         return TriggerObject() ~= nil and (TriggerObject():GetCardType():Test(CARD_TYPE_INSTANT) or TriggerObject():GetCardType():Test(CARD_TYPE_SORCERY))
      </TRIGGER>
      <RESOLUTION_TIME_ACTION>
         local oController = EffectController()
         local oSource = EffectSource()
         if oController ~= nil and oSource ~= nil then
            local oPlayerDC = oController:PlayerDataChest()
            if oPlayerDC ~= nil then
               local oOverspellDC = oPlayerDC:Get_Chest("Overspell_Chest_Register")
               if oOverspellDC == nil then
                  oOverspellDC = oPlayerDC:Make_Chest("Overspell_Chest_Register")
                  if oOverspellDC ~= nil then
                     oOverspellDC:Make_Chest(1)
                     oOverspellDC:Make_Chest(2)
                  end
               end
               if oOverspellDC ~= nil then
                  local oSpells = oOverspellDC:Get_Chest(1)
                  local oCounts = oOverspellDC:Get_Chest(2)
                  for i=0;oOverspellDC:Get_Int(0) do
                     if oSpells:Get_CardPtr(i) == oSource then
                        oCounts:Int_Add(i, 1)
                        break
                     end
                  end
               end
            end
         end
      </RESOLUTION_TIME_ACTION>
      <DERIVED_INFO tag="DERIVED_INFO_X_OVSP_ON_THIS_CARD">
         local oController = EffectController()
         local oSource = EffectSource()
         if oController ~= nil and oSource ~= nil then
            local oPlayerDC = oController:PlayerDataChest()
            if oPlayerDC ~= nil then
               local oOverspellDC = oPlayerDC:Get_Chest("Overspell_Chest_Register")
               if oOverspellDC == nil then
                  oOverspellDC = oPlayerDC:Make_Chest("Overspell_Chest_Register")
                  if oOverspellDC ~= nil then
                     oOverspellDC:Make_Chest(1)
                     oOverspellDC:Make_Chest(2)
                  end
               end
               if oOverspellDC ~= nil then
                  local oSpells = oOverspellDC:Get_Chest(1)
                  local oCounts = oOverspellDC:Get_Chest(2)
                  for i=0;oOverspellDC:Get_Int(0) do
                     if oSpells:Get_CardPtr(i) == oSource then
                        return oCounts:Get_Int(i)
                     end
                  end
               end
            end
         end
         return 0
      </DERIVED_INFO>
   </TRIGGERED_ABILITY>
   <QUERYTEXT tag="DERIVED_INFO_X_OVSP_ON_THIS_CARD">
      <LOCALISED_TEXT LanguageCode="en-US">draw %d card(s) more</LOCALISED_TEXT>
   </QUERYTEXT>
Note that I code for 2014, so I can't guarantee any of this (or even test it).
I saw that the LinkedDC didn't work so I tried another ways like DuelDataChest, and forgot to change it back when post the code. Therefore I can confirm that LinkedDC() doesn't work. I'll try your code later, thanks very much!
Rholin
 
Posts: 5
Joined: 04 Oct 2016, 06:33
Has thanked: 1 time
Been thanked: 0 time

Re: LinkedDC cannot pass data from a trigger to a spell?

Postby thefiremind » 09 Oct 2016, 07:58

There are some zone changes that wipe LinkedDC. The transition to the stack, if I remember correctly, is a zone change that wipes LinkedDC, so you can't rely on it remembering what you stored there when you cast the spell. The only solution I can think of now is to make a delayed trigger that will set your variable to the right number again after the spell reached the stack.
< 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: 717 times

Re: LinkedDC cannot pass data from a trigger to a spell?

Postby RiiakShiNal » 10 Oct 2016, 10:41

Or use my ObjectDC functions and protect the chest on certain zone changes so that it doesn't clear (you only need to protect it for the zone changes in which you don't want it to clear, such as transitioning to the stack).
Problems with base game cards: DotP 2014 Core Fixes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
RiiakShiNal
Programmer
 
Posts: 2115
Joined: 16 May 2011, 21:37
Has thanked: 73 times
Been thanked: 468 times

Re: LinkedDC cannot pass data from a trigger to a spell?

Postby Xander9009 » 10 Oct 2016, 10:42

RiiakShiNal wrote:Or use my ObjectDC functions and protect the chest on certain zone changes so that it doesn't clear (you only need to protect it for the zone changes in which you don't want it to clear, such as transitioning to the stack).
Have those been tested for Magic Duels? I know a few functions (like Int_Inc) have been removed. Your functions were actually my first thought for how to solve it, but I didn't know if they'd been tested with it yet.
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2880
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 116 times
Been thanked: 435 times

Re: LinkedDC cannot pass data from a trigger to a spell?

Postby Rholin » 10 Oct 2016, 11:34

Thanks for help. Today I found a strange thing, it seems that the data are not wiped in the transition, but are more likely temporarily "unaccessible" in the stack zone, because I saw that when the card was in my hand, the derived info was "draw 2 card(s) more", in the stack zone, "draw 0...", but after the resolution, when it was in graveyard, it showed "draw 2 .." again!
Rholin
 
Posts: 5
Joined: 04 Oct 2016, 06:33
Has thanked: 1 time
Been thanked: 0 time

Re: LinkedDC cannot pass data from a trigger to a spell?

Postby RiiakShiNal » 10 Oct 2016, 12:01

Xander9009 wrote:Have those been tested for Magic Duels? I know a few functions (like Int_Inc) have been removed. Your functions were actually my first thought for how to solve it, but I didn't know if they'd been tested with it yet.
Oops, I missed that this was for Duels. No, I haven't done any testing with Duels (suffering from lack of time), though if things still work pretty much the same then they should work.
Problems with base game cards: DotP 2014 Core Fixes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
RiiakShiNal
Programmer
 
Posts: 2115
Joined: 16 May 2011, 21:37
Has thanked: 73 times
Been thanked: 468 times

Re: LinkedDC cannot pass data from a trigger to a spell?

Postby thefiremind » 17 Oct 2016, 08:41

Just a heads up on this matter, if Rholin hasn't found a solution yet: I implemented my own ObjectDC for Magic Duels (which is very simplified thanks to the possibility of using strings as index: I'm using tostring(object) as an index for object). You can find it in my test contents, inside the LOL file for general functions.
< 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: 717 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 1 guest


Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 10 minutes)
Most users ever online was 287 on 31 Mar 2019, 04:11

Users browsing this forum: No registered users and 1 guest

Login Form