[DotP2013] Spell Rupture
Posted: 20 Mar 2013, 13:37
I'm trying to coding Spell Rupture, I couldn't find any problem in my code, but it leads to a crash (not script error) while loading the card.
Please help me find the cause..
Please help me find the cause..
- Code: Select all
<SPELL_ABILITY filter_zone="ZONE_IN_PLAY">
<TARGET_DEFINITION id="0">
local filter = Object():GetFilter()
filter:Clear()
filter:SetZone( ZONE_STACK )
filter:SetStackObjectType( STACK_OBJECT_CARD )
filter:SetHint( HINT_ENEMY_ONLY, EffectController() )
</TARGET_DEFINITION>
<TARGET_DETERMINATION>
return AtLeastOneTargetFromDefinition(0)
</TARGET_DETERMINATION>
<PLAY_TIME_ACTION target_choosing="1">
EffectController():ChooseTarget( 0, "CARD_QUERY_CHOOSE_SPELL_TO_COUNTER", EffectDC():Make_Targets(0) )
</PLAY_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local filter = Object():GetFilter()
filter:Clear()
filter:AddCardType(CARD_TYPE_CREATURE)
filter:SetController(EffectController())
filter:SetZone(ZONE_IN_PLAY)
local count = filter:EvaluateObjects()
local maxpower = 0
for i=0,count-1 do
local crt = filter:GetNthEvaluatedObject(i)
if (crt ~= nil) then
if (crt:GetCurrentCharacteristics():Power_Get() > maxpower) then
maxpower = crt:GetCurrentCharacteristics():Power_Get()
end
end
end
EffectDC():Set_Int(1, maxpower)
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local target_spell = EffectDC():Get_Targets(0):Get_CardPtr(0)
local player = target_spell:GetPlayer()
local maxpower = EffectDC():Get_Int(1)
if player ~= nil then
if player:CanAfford("{"..maxpower.."}") == 1 then
player:BeginNewMultipleChoice()
player:AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_YES" )
player:AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_NO" )
player:AskMultipleChoiceQuestion( "CARD_QUERY_ASK_PAY_FOR_SPELL_RUPTURE" )
end
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local target_spell = EffectDC():Get_Targets(0):Get_CardPtr(0)
local player = target_spell:GetPlayer()
local maxpower = EffectDC():Get_Int(1)
local decision = Object():GetMultipleChoiceResult()
if player ~= nil then
if player:CanAfford("{"..maxpower.."}") == 1 then
if decision ~= 1 then
player:TapLand("{"..maxpower.."}")
else
target_spell:CounterSpell()
end
else
target_spell:CounterSpell()
end
end
</RESOLUTION_TIME_ACTION>
</SPELL_ABILITY>