Board index
Programs with AI or Rules Enforcement
Magic: The Gathering - Duels of the Planeswalkers
Programming Talk



LinkedDC cannot pass data from a trigger to a spell?
Moderator: CCGHQ Admins
LinkedDC cannot pass data from a trigger to a spell?
by 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":
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>
Last edited by Rholin on 09 Oct 2016, 04:23, edited 1 time in total.
Re: LinkedDC cannot pass data from a trigger to a spell?
by 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.
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>
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
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
-
Xander9009 - Programmer
- Posts: 2905
- Joined: 29 Jun 2013, 07:44
- Location: Indiana, United States
- Has thanked: 121 times
- Been thanked: 445 times
Re: LinkedDC cannot pass data from a trigger to a spell?
by Rholin » 09 Oct 2016, 04:22
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!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.Note that I code for 2014, so I can't guarantee any of this (or even test it).
- 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>
Re: LinkedDC cannot pass data from a trigger to a spell?
by 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...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 722 times
Re: LinkedDC cannot pass data from a trigger to a spell?
by 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).
Just getting started: Xander9009's DotP 2014 Community Wad
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
- RiiakShiNal
- Programmer
- Posts: 2188
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 497 times
Re: LinkedDC cannot pass data from a trigger to a spell?
by Xander9009 » 10 Oct 2016, 10:42
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.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).
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
-
Xander9009 - Programmer
- Posts: 2905
- Joined: 29 Jun 2013, 07:44
- Location: Indiana, United States
- Has thanked: 121 times
- Been thanked: 445 times
Re: LinkedDC cannot pass data from a trigger to a spell?
by 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!
Re: LinkedDC cannot pass data from a trigger to a spell?
by RiiakShiNal » 10 Oct 2016, 12:01
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.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.
Just getting started: Xander9009's DotP 2014 Community Wad
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
- RiiakShiNal
- Programmer
- Posts: 2188
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 497 times
Re: LinkedDC cannot pass data from a trigger to a spell?
by 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...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 722 times
9 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 4 guests