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



Multi-Mode "Charm" spells
Moderator: CCGHQ Admins
Multi-Mode "Charm" spells
by Shatterhouse » 23 Apr 2011, 03:26
Okay, I seem to have gotten Charms working.
Charms are tricky because they could have different targets depending on which mode you select as the card is played.
Note that the repository already had Funeral Charm, but there was a flaw in that it only chose targets after it resolved, giving opposing players no clue what was about to happen until it was too late to cast a counterspell.
This solution is to trigger an ability as the spell is cast, have the triggered ability choose the targets, and then resolve the spell's effect onto the triggered ability's target. Here's how I handled the two relevant abilities of Fury Charm :
The only weird thing is that there will be a slight delay between the targeting and the resolving of the spell, because it's really two things that are resolving.
Charms are tricky because they could have different targets depending on which mode you select as the card is played.
Note that the repository already had Funeral Charm, but there was a flaw in that it only chose targets after it resolved, giving opposing players no clue what was about to happen until it was too late to cast a counterspell.
This solution is to trigger an ability as the spell is cast, have the triggered ability choose the targets, and then resolve the spell's effect onto the triggered ability's target. Here's how I handled the two relevant abilities of Fury Charm :
- Code: Select all
<SPELL_ABILITY layer="7c" tag="FURY_CHARM_RULE_1" simple_filter="Target">
<TARGET_DETERMINATION>
return TargetArtifactOrCreatureBad()
</TARGET_DETERMINATION>
<PLAYTIME>
Object():GetFilter():Clear()
Object():GetPlayer():BeginNewMultipleChoice( true )
Object():GetPlayer():AddMultipleChoiceAnswer( "FURY_CHARM_MODAL_1" )
Object():GetPlayer():AddMultipleChoiceAnswer( "FURY_CHARM_MODAL_2" )
Object():GetPlayer():AskMultipleChoiceQuestion( "MODAL_TITLE" )
</PLAYTIME>
<EFFECT>
if ((Object():GetMultipleChoiceResult() == 1) and (Object():GetTargetCard() ~= nil)) then
PlusOnePlusOneToTargetCard()
Trample()
end
if ((Object():GetMultipleChoiceResult() == 0) and (Object():GetTargetCard() ~= nil)) then
DestroyTargetCard()
end
</EFFECT>
<DURATION>
return UntilEndOfTurn()
</DURATION>
</SPELL_ABILITY>
<TRIGGERED_ABILITY layer="7c" zone="HAND" auto_skip="1" >
<TRIGGER value="SPELL_PLAYED">
return SelfTriggered()
</TRIGGER>
<PLAYTIME>
if Object():GetMultipleChoiceResult() == 0 then
TargetArtifactBad()
ChooseTargetArtifact()
end
if Object():GetMultipleChoiceResult() == 1 then
TargetCreatureBad()
ChooseTargetCreature()
end
</PLAYTIME>
<FILTER>
return TargetCard()
</FILTER>
<EFFECT>
<!-- Triggered ability has no real effect -->
</EFFECT>
</TRIGGERED_ABILITY>
The only weird thing is that there will be a slight delay between the targeting and the resolving of the spell, because it's really two things that are resolving.
- Shatterhouse
- Posts: 72
- Joined: 20 Apr 2011, 00:07
- Has thanked: 0 time
- Been thanked: 2 times
Re: Multi-Mode "Charm" spells
by spiwy » 23 Apr 2011, 13:17
Cool! Thanks for the Discovery
After i finish the deck i'm building, Myr Rampaging, I want to try to do a tribal Giant deck and I would like to have some Austere Command in it, so I think this can help much 
Regards!


Regards!
Re: Multi-Mode "Charm" spells
by spiwy » 17 May 2011, 11:04
Ok, so i made my first attemp to make a working Austere Command and this is what i did to select the first option:
- Code: Select all
<SPELL_ABILITY tag="AUSTERE_COMMAND_RULE_1" layer="0">
<PLAYTIME>
Object():GetFilter():Clear()
Object():GetPlayer():BeginNewMultipleChoice( true )
Object():GetPlayer():AddMultipleChoiceAnswer( "AUSTERE_COMMAND_OPTION_1" )
Object():GetPlayer():AddMultipleChoiceAnswer( "AUSTERE_COMMAND_OPTION_2" )
Object():GetPlayer():AddMultipleChoiceAnswer( "AUSTERE_COMMAND_OPTION_3" )
Object():GetPlayer():AddMultipleChoiceAnswer( "AUSTERE_COMMAND_OPTION_4" )
Object():GetPlayer():AskMultipleChoiceQuestion( "AUSTERE_COMMAND_ONE" )
</PLAYTIME>
<EFFECT>
if Object():GetMultipleChoiceResult() == 0 then
Object():Register_Set(0,1)
end
if Object():GetMultipleChoiceResult() == 1 then
Object():Register_Set(0,2)
end
if Object():GetMultipleChoiceResult() == 2 then
Object():Register_Set(0,3)
end
if Object():GetMultipleChoiceResult() == 3 then
Object():Register_Set(0,4)
end
</EFFECT>
</SPELL_ABILITY>
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 7 guests