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



Infect: Possible or not?
Moderator: CCGHQ Admins
Re: Infect: Possible or not?
by thefiremind » 29 Feb 2012, 14:55
Badges are only a way to show some properties, but it has nothing to do with making them work. When you set the haste badge on a creature, for instance, the game has some internal code that tells how haste works. But for flanking (in the deck pack), there was no internal code, so the cards contain how to manage it. That's why creating an infect badge would solve nothing. And keep in mind that there's only 1 free badge constant at the moment: badge #31 (#32 is treated the same as #0, #33 as #1, and it goes on like that). Even if we knew how to make new badges, we could insert at most 1 in the game.sadlyblue wrote:Can't decode the .cnt .mdl and .mtl for the badges. Maybe that would be the best way to implement infect.
Anyway infect (and also wither, which is half infect) seems impossible to code properly. The damage must be dealt, but at the same time it must not damage the creatures. The latest (as far as I know) solution found by nabeshin, that consists in clearing the damage after dealing it, actually clears all damage on the creature. So if your opponent has a 4/4 creature, you play a Shock on it, and then on the same turn you deal 2 infect damage to it, it will become 2/2 but won't die.
< 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: Infect: Possible or not?
by sadlyblue » 29 Feb 2012, 17:14
Even only for show, a badge for infect would be great.
But, of course, i'm interested in coding an infect set of funtions. Including a bool_set to be easy to on/off.
So i'm trying to understand Lua and decode/decompile the .lol files. Anyone knows how?
Meanwhile, i was trying a way to on/off. Coding each card with infect with MTG():ObjectDataChest():Int_Set(COMPARTMENT_POISON, 1) for on and MTG():ObjectDataChest():Int_Set(COMPARTMENT_POISON, 0) for off. So my problem right now is how can another card (for example Melira) change the Int(COMPARTMENT_POISON) on another card.
But, of course, i'm interested in coding an infect set of funtions. Including a bool_set to be easy to on/off.
So i'm trying to understand Lua and decode/decompile the .lol files. Anyone knows how?
Meanwhile, i was trying a way to on/off. Coding each card with infect with MTG():ObjectDataChest():Int_Set(COMPARTMENT_POISON, 1) for on and MTG():ObjectDataChest():Int_Set(COMPARTMENT_POISON, 0) for off. So my problem right now is how can another card (for example Melira) change the Int(COMPARTMENT_POISON) on another card.
Re: Infect: Possible or not?
by thefiremind » 29 Feb 2012, 19:01
If you use the data chests, you should be able to do it with
target_card:GetDataChest():Int_Set(...)
(where target_card is the card you want to change)
target_card:GetDataChest():Int_Set(...)
(where target_card is the card you want to change)
< 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: Infect: Possible or not?
by Persee » 10 Mar 2012, 23:50
My version of wither :
But I have 2 issues :
- the creature don't have the good power until the end of turn.
- creature with regenerate. There is no trigger on it
If you have advice...
- Code: Select all
<?xml version='1.0'?>
<CARD_V2 custom="true">
<FILENAME text="TWINBLADE_SLASHER_12340024" />
<CARDNAME text="TWINBLADE_SLASHER" />
<TITLE>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Twinblade Slasher]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[]]></LOCALISED_TEXT>
</TITLE>
<MULTIVERSEID value="12340024" />
<ARTID value="" />
<FRAMECOLOUR name="G" />
<COLOUR value="G" />
<ARTIST name="Trevor Hairsine" />
<CASTING_COST cost="{G}" />
<FLAVOURTEXT>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Righteous anger hones a humble soul.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[]]></LOCALISED_TEXT>
</FLAVOURTEXT>
<TYPE metaname="Creature" order_de-DE="0" order_es-ES="0" order_fr-FR="0" order_it-IT="0" order_jp-JA="0" />
<SUB_TYPE metaname="Elf" order_de-DE="0" order_es-ES="0" order_fr-FR="0" order_it-IT="0" order_jp-JA="0" />
<SUB_TYPE metaname="Warrior" order_de-DE="0" order_es-ES="0" order_fr-FR="0" order_it-IT="0" order_jp-JA="0" />
<EXPANSION value="DPE" />
<RARITY metaname="U" />
<POWER value="1" />
<TOUGHNESS value="1" />
<TRIGGERED_ABILITY internal="1" active_zone="any">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Wither]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Wither]]></LOCALISED_TEXT>
<TRIGGER value="CREATURE_TOOK_DAMAGE">
return Damage():GetSource() == Object()
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local damage_amount = Damage():GetAmount()
local target = TriggerObject()
local mystore = Storage(Object())
mystore.push(target)
mystore.push(damage_amount)
</RESOLUTION_TIME_ACTION>
<AI_BASE_SCORE score="300" zone="in_play" />
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY internal="1" active_zone="any">
<TRIGGER value="BEGINNING_OF_STEP">
return (MTG():GetStep() == STEP_END_OF_TURN)
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local mystore = Storage(Object())
local total = mystore.count()/2
local index = 1
for i = 0, total-1 do
local target = mystore.get(index)
local counters = mystore.get(index+1)
if target:GetCardType():Test(CARD_TYPE_CREATURE) ~= 0 and target:GetZone() ~= ZONE_IN_PLAY then
target:ClearDamage()
target:AddCounters( MTG():MinusOneMinusOneCounters(), counters )
end
index = index+2
end
mystore.clear()
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<ACTIVATED_ABILITY per_turn_limit="1">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[{1}{G}: Twinblade Slasher gets +2/+2 until end of turn. Activate this ability only once each turn.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[{1}{G}: Twinblade Slasher gets +2/+2 until end of turn. Activate this ability only once each turn.]]></LOCALISED_TEXT>
<COST type="mana" cost="{1}{G}" />
<CONTINUOUS_ACTION>
if Object():GetZone() == ZONE_IN_PLAY then
Object():GetCurrentCharacteristics():Power_Add( 2 )
Object():GetCurrentCharacteristics():Toughness_Add( 2 )
end
</CONTINUOUS_ACTION>
<DURATION>
return (MTG():GetStep() == STEP_CLEANUP)
</DURATION>
<AI_AVAILABILITY behaviour="Firebreathing" />
</ACTIVATED_ABILITY>
</CARD_V2>
But I have 2 issues :
- the creature don't have the good power until the end of turn.
- creature with regenerate. There is no trigger on it

If you have advice...
Re: Infect: Possible or not?
by Eglin » 11 Mar 2012, 00:42
Why wait until the trigger to apply the counters, Persee? Why not apply them immediately after reducing the damage? It seems like using Damage():SetAmount() to set the damage equal to Damage():GetAmount() less the damage the wither creature did and adding the -1/1 counters would be correct. And I don't see any reason you couldn't add the counters from within the same CREATURE_TOOK_DAMAGE trigger. I'd wrap it in a forced_skip="1" block, too.
Re: Infect: Possible or not?
by Persee » 11 Mar 2012, 03:19
We must apply the damages otherwise effects like lifelink and deathtouch don't work.
Re: Infect: Possible or not?
by Eglin » 11 Mar 2012, 05:53
Makes sense. If those are the only two fringe cases, it shouldn't be a big hill for a climber. Just manually check for lifelink/deathtouch and apply their effects manually.Persee wrote:We must apply the damages otherwise effects like lifelink and deathtouch don't work.
Re: Infect: Possible or not?
by thefiremind » 11 Mar 2012, 09:35
There are also cards that care for damage from other sources, Tephraderm for example. These must know if they took damage from a creature with wither/infect.Eglin wrote:Makes sense. If those are the only two fringe cases, it shouldn't be a big hill for a climber. Just manually check for lifelink/deathtouch and apply their effects manually.Persee wrote:We must apply the damages otherwise effects like lifelink and deathtouch don't work.
< 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: Infect: Possible or not?
by Persee » 11 Mar 2012, 14:13
For the power of the creatures, I can decrease it with a Power_Add(- damage_from_wither_creature) until end of turn
Remains the problem of regenerate creature, after they regenerate, the damages are cleared and I must put -1/-1 counter on it.
Remains the problem of regenerate creature, after they regenerate, the damages are cleared and I must put -1/-1 counter on it.
Re: Infect: Possible or not?
by sadlyblue » 11 Mar 2012, 15:06
Why don't you, after the damage takes places, set the thougness = thougness before damage + number of counters you'll place. Then place the counters on the creature.
This way you don't need to wait untill end of turn.
This way you don't need to wait untill end of turn.
Re: Infect: Possible or not?
by Persee » 11 Mar 2012, 16:11
The probleme is the damage from another source, getcurrentthoughness() return the toughness with or without damage ?
I'll try this.
Edit : Here's the new code :
And it works with creature with regenerate
but I don't understand why 
Thx for help.
Test it please.
I'll try this.
Edit : Here's the new code :
- Code: Select all
<?xml version='1.0'?>
<CARD_V2 custom="true">
<FILENAME text="TWINBLADE_SLASHER_12340024" />
<CARDNAME text="TWINBLADE_SLASHER" />
<TITLE>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Twinblade Slasher]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[]]></LOCALISED_TEXT>
</TITLE>
<MULTIVERSEID value="12340024" />
<ARTID value="" />
<FRAMECOLOUR name="G" />
<COLOUR value="G" />
<ARTIST name="Trevor Hairsine" />
<CASTING_COST cost="{G}" />
<FLAVOURTEXT>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Righteous anger hones a humble soul.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[]]></LOCALISED_TEXT>
</FLAVOURTEXT>
<TYPE metaname="Creature" order_de-DE="0" order_es-ES="0" order_fr-FR="0" order_it-IT="0" order_jp-JA="0" />
<SUB_TYPE metaname="Elf" order_de-DE="0" order_es-ES="0" order_fr-FR="0" order_it-IT="0" order_jp-JA="0" />
<SUB_TYPE metaname="Warrior" order_de-DE="0" order_es-ES="0" order_fr-FR="0" order_it-IT="0" order_jp-JA="0" />
<EXPANSION value="DPE" />
<RARITY metaname="U" />
<POWER value="1" />
<TOUGHNESS value="1" />
<TRIGGERED_ABILITY internal="1" active_zone="in_play">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Wither]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Wither]]></LOCALISED_TEXT>
<TRIGGER value="CREATURE_TOOK_DAMAGE">
return Damage():GetSource() == Object()
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local damage_amount = Damage():GetAmount()
local target = TriggerObject()
local mystore = Storage(Object())
mystore.push(target)
mystore.push(damage_amount)
</RESOLUTION_TIME_ACTION>
<AI_BASE_SCORE score="300" zone="in_play" />
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY internal="1" active_zone="any">
<TRIGGER value="BEGINNING_OF_STEP">
return (MTG():GetStep() == STEP_END_OF_COMBAT and TriggeredForMe())
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local mystore = Storage(Object())
local total = mystore.count()/2
local index = 1
for i = 0, total-1 do
local target = mystore.get(index)
local counters = mystore.get(index+1)
if target:GetCardType():Test(CARD_TYPE_CREATURE) ~= 0 and target:GetZone() == ZONE_IN_PLAY then
target:ClearDamage()
target:AddCounters( MTG():MinusOneMinusOneCounters(), counters )
end
index = index+2
end
</RESOLUTION_TIME_ACTION>
<CONTINUOUS_ACTION>
local mystore = Storage(Object())
local total = mystore.count()/2
local index = 1
for i = 0, total-1 do
local target = mystore.get(index)
local counters = mystore.get(index+1)
if target:GetCardType():Test(CARD_TYPE_CREATURE) ~= 0 and target:GetZone() == ZONE_IN_PLAY then
target:GetCurrentCharacteristics():Toughness_Add( counters )
end
index = index+2
end
</CONTINUOUS_ACTION>
<DURATION>
return (MTG():GetStep() == STEP_CLEANUP)
</DURATION>
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY internal="1" active_zone="any">
<TRIGGER value="END_OF_STEP">
return (MTG():GetStep() == STEP_END_OF_COMBAT)
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local mystore = Storage(Object())
mystore.clear()
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
<ACTIVATED_ABILITY per_turn_limit="1">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[{1}{G}: Twinblade Slasher gets +2/+2 until end of turn. Activate this ability only once each turn.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[{1}{G}: Twinblade Slasher gets +2/+2 until end of turn. Activate this ability only once each turn.]]></LOCALISED_TEXT>
<COST type="mana" cost="{1}{G}" />
<CONTINUOUS_ACTION>
if Object():GetZone() == ZONE_IN_PLAY then
Object():GetCurrentCharacteristics():Power_Add( 2 )
Object():GetCurrentCharacteristics():Toughness_Add( 2 )
end
</CONTINUOUS_ACTION>
<DURATION>
return (MTG():GetStep() == STEP_CLEANUP)
</DURATION>
<AI_AVAILABILITY behaviour="Firebreathing" />
</ACTIVATED_ABILITY>
</CARD_V2>
And it works with creature with regenerate


Thx for help.
Test it please.
Re: Infect: Possible or not?
by thefiremind » 11 Mar 2012, 22:40
Nice idea sadlyblue, and nice implementation Persee! This is the best idea so far, according to me. It could lead to wrong results with cards like Vendetta, but this could really be called a "fringe case", as Eglin said. 
The code would have been shorter if you added counters and temporary toughness together with the damage without the need to save any information on storage, but I suppose you tried it and didn't work. Oh well, if this code works, its length isn't important.

The code would have been shorter if you added counters and temporary toughness together with the damage without the need to save any information on storage, but I suppose you tried it and didn't work. Oh well, if this code works, its length isn't important.

< 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: Infect: Possible or not?
by Persee » 11 Mar 2012, 23:42
I didn't think at this solutionthefiremind wrote:The code would have been shorter if you added counters and temporary toughness together with the damage without the need to save any information on storage, but I suppose you tried it and didn't work. Oh well, if this code works, its length isn't important.

It must work, I'll try it.
Re: Infect: Possible or not?
by sadlyblue » 11 Mar 2012, 23:49
i just think we should use a compartment (or storage) so activate/deactivate infect.
i tried, but couldn't get one card to change that value to deactivate it. of course that giving infect wouldn't be that easy.
the only way would be an invisible token, that i don't quite know how to create and use them, check each damage dealt. then, if it came from a creature with the compartment for infect = 1, would do the counter placing...
this way, any creature with infect, or card giving/removing infect would only change that int to 0 or 1.
what do you guys think?
i tried, but couldn't get one card to change that value to deactivate it. of course that giving infect wouldn't be that easy.
the only way would be an invisible token, that i don't quite know how to create and use them, check each damage dealt. then, if it came from a creature with the compartment for infect = 1, would do the counter placing...
this way, any creature with infect, or card giving/removing infect would only change that int to 0 or 1.
what do you guys think?
Re: Infect: Possible or not?
by Persee » 12 Mar 2012, 00:56
It didn't work with regenerate. The toughness that I add stay after regeneration.Persee wrote:I didn't think at this solutionthefiremind wrote:The code would have been shorter if you added counters and temporary toughness together with the damage without the need to save any information on storage, but I suppose you tried it and didn't work. Oh well, if this code works, its length isn't important.
It must work, I'll try it.
And I don't know why too

34 posts
• Page 2 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 11 guests