Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers Programming Talk
[DotP2013] Simic Manipulator
Moderator: CCGHQ Admins
[DotP2013] Simic Manipulator
by BETenner » 15 Mar 2013, 14:57
I thought this card would be very difficult to implement.
I tried my solution, but it leads to crash (yes, crash, not error)
Is there a way to implement this card?
Here's my code:
I tried my solution, but it leads to crash (yes, crash, not error)
Is there a way to implement this card?
Here's my code:
- Code: Select all
<ACTIVATED_ABILITY filter_zone="ZONE_IN_PLAY">
<COST type="TapSelf"/>
<TARGET_DEFINITION id="0">
local filter = Object():GetFilter()
filter:Clear()
filter:AddCardType(CARD_TYPE_CREATURE)
filter:SetZone(ZONE_IN_PLAY)
</TARGET_DEFINITION>
<TARGET_DETERMINATION>
return AtLeastOneTargetFromDefinition(0)
</TARGET_DETERMINATION>
<PLAY_TIME_ACTION>
local index = ObjectDC():Get_Int(0)
EffectController():ChooseTarget( 0, "CARD_QUERY_CHOOSE_CREATURE_TO_GAIN_CONTROL", EffectDC():Make_Targets(index) )
</PLAY_TIME_ACTION>
<PLAY_TIME_ACTION>
EffectController():BeginNewNumericalChoice()
EffectController():AddNumericalChoiceAnswer(Object():CountCounters(MTG():PlusOnePlusOneCounters()))
EffectController():AskNumericalChoiceQuestion("CARD_QUERY_CHOOSE_REMOVE_X_1_1_COUNTER")
</PLAY_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local index = ObjectDC():Get_Int(0)
local target = EffectDC():Get_Targets(index) and EffectDC():Get_Targets(index):Get_CardPtr(0)
local x = Object():GetNumericalChoiceResult()
if (target ~= nil and
Object():CountCounters(MTG():PlusOnePlusOneCounters()) > x - 1 and
target:GetCurrentPower() < x + 1) then
Object():RemoveCounters(MTG():PlusOnePlusOneCounters(), x)
ObjectDC():Set_CardPtr(index, target)
ObjectDC():Set_Int(0, index + 1)
end
</RESOLUTION_TIME_ACTION>
<CONTINUOUS_ACTION layer="4">
local count = ObjectDC():Get_Int(0)
for i=0,count do
local target = ObjectDC():Get_CardPtr(i)
if (target ~= nil) then
target:SetController(Object():GetController())
end
end
</CONTINUOUS_ACTION>
</ACTIVATED_ABILITY>
Re: [DotP2013] Simic Manipulator
by RiiakShiNal » 15 Mar 2013, 15:40
Try this for the second ability of Simic Manipulator:
This is a simplistic method and does not allow for padding the amount removed, that could be added, but makes things a bit more complicated.
Edit 2: Updated to use GetCurrentCharacteristics():Power_Get() instead of GetCurrentPower().
- Code: Select all
<ACTIVATED_ABILITY filter_zone="ZONE_IN_PLAY">
<COST type="TapSelf"/>
<TARGET_DEFINITION id="0">
local filter = Object():GetFilter()
filter:Clear()
filter:AddCardType(CARD_TYPE_CREATURE)
filter:SetZone(ZONE_IN_PLAY)
filter:SetPowerMax(Object():CountCounters(MTG():PlusOnePlusOneCounters())
</TARGET_DEFINITION>
<TARGET_DETERMINATION>
return AtLeastOneTargetFromDefinition(0)
</TARGET_DETERMINATION>
<PLAY_TIME_ACTION>
EffectController():ChooseTarget( 0, "CARD_QUERY_CHOOSE_CREATURE_TO_GAIN_CONTROL", EffectDC():Make_Targets(0) )
</PLAY_TIME_ACTION>
<PLAY_TIME_ACTION>
local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
if (target ~= nil) then
local countersRemoved = target:GetCurrentCharacteristics():Power_Get()
Object():RemoveCounters(MTG():PlusOnePlusOneCounters(), countersRemoved)
EffectDC():Int_Set(1, countersRemoved)
end
</PLAY_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
local countersRemoved = EffectDC():Int_Get(1)
if (target ~= nil) then
if (target:GetCurrentCharacteristics():Power_Get() <= countersRemoved) then
target:SetPermanentController(EffectController())
end
end
</RESOLUTION_TIME_ACTION>
</ACTIVATED_ABILITY>
This is a simplistic method and does not allow for padding the amount removed, that could be added, but makes things a bit more complicated.
Edit 2: Updated to use GetCurrentCharacteristics():Power_Get() instead of GetCurrentPower().
Last edited by RiiakShiNal on 15 Mar 2013, 16:07, edited 1 time in total.
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: 2185
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 496 times
Re: [DotP2013] Simic Manipulator
by thefiremind » 15 Mar 2013, 16:02
Proliferate is also coded in a "best result with least effort" way, so I think this solution is perfectly acceptable.
Just one warning: if you see strange things happening, like you gain control of the target even after its power has been raised, it's because GetCurrentPower sometimes doesn't get updated results, I don't know why. If that's the case, just substitute target:GetCurrentPower() with target:GetCurrentCharacteristics():Power_Get() which always works.
Just one warning: if you see strange things happening, like you gain control of the target even after its power has been raised, it's because GetCurrentPower sometimes doesn't get updated results, I don't know why. If that's the case, just substitute target:GetCurrentPower() with target:GetCurrentCharacteristics():Power_Get() which always works.
Last edited by thefiremind on 15 Mar 2013, 16:35, edited 1 time in total.
< 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: 721 times
Re: [DotP2013] Simic Manipulator
by RiiakShiNal » 15 Mar 2013, 16:08
Fair enough, updated to use GetCurrentCharacteristics():Power_Get() instead of GetCurrentPower().
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: 2185
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 496 times
Re: [DotP2013] Simic Manipulator
by BETenner » 16 Mar 2013, 02:39
Thanks!
Due to the ruling, you can't remove 0 +1/+1 counter to gain control of a creature with 0 or less power. So I added a check in the resolution to make sure you removed at least 1 +1/+1 counter.
Due to the ruling, you can't remove 0 +1/+1 counter to gain control of a creature with 0 or less power. So I added a check in the resolution to make sure you removed at least 1 +1/+1 counter.
Re: [DotP2013] Simic Manipulator
by RiiakShiNal » 16 Mar 2013, 03:26
Good catch, an oversight on my part, though since removing the counters is actually part of the cost it should be done in the PLAY_TIME_ACTION (where the counters are normally removed) instead of at resolution time. So the action would become this:
- Code: Select all
<PLAY_TIME_ACTION>
local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
if (target ~= nil) then
local countersRemoved = target:GetCurrentCharacteristics():Power_Get()
if (countersRemoved < 1) then
countersRemoved = 1
end
Object():RemoveCounters(MTG():PlusOnePlusOneCounters(), countersRemoved)
EffectDC():Int_Set(1, countersRemoved)
end
</PLAY_TIME_ACTION>
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: 2185
- Joined: 16 May 2011, 21:37
- Has thanked: 75 times
- Been thanked: 496 times
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 19 guests