BloodReyvyn wrote:Alright, I give... I cannot for the life of me figure out why this demon won't make you sac any permanents. I have re-written the code about 10 times and tried troubleshooting it far more than I care to count, but no matter how I try to do it, it never makes you sacrifice a creature, or even choose one to sacrifice... Any help would be greatly appreciated.
There's no "then" after an "if" and there's an "if" too much after an "end" (doesn't SCRIPT_LOG.TXT warn you about those?). Anyway the ability isn't totally right because
Shadowborn Demon has an "intervening if clause": each time an ability text has a condition that starts with "if" and stands between 2 commas, that condition must be verified both at the trigger condition and at the resolution.
PLAYTIME has no meaning outside of a COST block. And PLAY_TIME_ACTION would be wrong, either: when you don't need to target, your choice should happen at resolution. In general, you should get used not to use TARGET_DEFINITIONs and TARGET_DETERMINATIONs (and PLAY_TIME_ACTIONs of course) for abilities that aren't targetted. There are some scenarios where making a definition could be handy anyway, but most of the times you are going to confuse yourself.
- Code: Select all
<TRIGGERED_ABILITY dangerous="1">
-- localised text
<TRIGGER value="BEGINNING_OF_STEP">
if EffectController():MyTurn() ~= 0 and MTG():GetStep() == STEP_UPKEEP then
local filter = Object():GetFilter()
filter:Clear()
filter:NotTargetted()
filter:SetPlayer( EffectController() )
filter:SetZone( ZONE_GRAVEYARD )
filter:AddCardType( CARD_TYPE_CREATURE )
return filter:CountStopAt(6) < 6
end
return false
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local filter = Object():GetFilter()
local player = EffectController()
filter:Clear()
filter:NotTargetted()
filter:SetPlayer( player )
filter:SetZone( ZONE_GRAVEYARD )
filter:AddCardType( CARD_TYPE_CREATURE )
if filter:CountStopAt(6) < 6 then
filter:Clear()
filter:NotTargetted()
filter:SetController( player )
filter:SetZone( ZONE_IN_PLAY )
filter:AddCardType( CARD_TYPE_CREATURE )
filter:SetHint( HINT_ENEMY, player )
player:ChooseTarget( NO_VALIDATION, "CARD_QUERY_CHOOSE_CREATURE_TO_SACRIFICE", EffectDC():Make_Targets(0) )
end
</RESOLUTION_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local target = EffectDC():Get_Targets(0) and EffectDC():Get_Targets(0):Get_CardPtr(0)
if target ~= nil then
target:Sacrifice( EffectController() )
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
BloodReyvyn wrote:I tried to make the ability ask a query whether or not you wish to use its ability during your upkeep (as a triggered ability, which it does), but regardless of the option you choose, he does not get sacrificed and life totals remain the same.
I'm not sure for how long Object():GetMultipleChoiceResult() is saved, but I wouldn't make it cross 2 abilities (I usually don't make it cross even 2 actions without saving it in an EffectDC register). There could be a much easier approximation if you use a conditional cost, I'm not sure about how the game handles 2 conditional costs together, but you just have to try. The only drawback is that you'll always be asked to select the target first, but as long as you play 1v1, there will be only 1 opponent and you won't even notice it.
- Code: Select all
<TRIGGERED_ABILITY dangerous="1">
-- localised text
<TRIGGER value="BEGINNING_OF_STEP" simple_qualifier="controller">
return EffectController():MyTurn() ~= 0 and MTG():GetStep() == STEP_UPKEEP
</TRIGGER>
<COST type="TapSelf" qualifier="conditional" />
<COST type="SacrificeSelf" qualifier="conditional" />
<TARGET_DEFINITION id="0">
local filter = Object():GetFilter()
filter:Clear()
filter:SetFilterType( FILTER_TYPE_PLAYERS + FILTER_TYPE_OPPONENTS)
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_OPPONENT_EXCHANGE_LIFE_TOTALS", EffectDC():Make_Targets(0) )
</PLAY_TIME_ACTION>
<RESOLUTION_TIME_ACTION conditional="if">
local target = EffectDC():Get_Targets(0):Get_PlayerPtr(0)
if target ~= nil then
local my_life = EffectController():GetLifeTotal()
local target_life = target:GetLifeTotal()
EffectController():SetLifeTotal( target_life )
target:SetLifeTotal( my_life )
end
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>
You only need this ability, nothing else.
auto_skip doesn't interfere with how an ability works, it just tells the game that players who have "automatic resolution" enabled should get that ability resolved immediately. That's why auto_skip should be used only when it's very unlikely that an opponent would need to respond to the ability.
Firebreathing abilities, for example, use auto_skip because increasing power without increasing toughness usually leaves the creature as easy to kill as before. Exalted doesn't use auto_skip because that +1/+1 could move the creature away from the killing range of a
Searing Spear.
EDIT: forget what I wrote earlier about
Hindering Light: my idea might have worked if it said only "that targets a permanent you control", without "you or".
