Hi everyone, I created a custom monster, and I'm having trouble getting its effect to work the way I'd like it to. The card's effect in question is as follows:
[...] You can Tribute 1 monster you control to inflict 500 damage to your opponent. If you Tributed a Toon monster for this card's effect, your opponent discards 1 random card.
First of all, is it even possible to implement this kind of effect (one where you can perform an additional effect based on a certain kind of monster being Tributed as a cost)? I've looked everywhere, and the closest thing I could find to this was Granmarg the Mega Monarch, who gains that extra effect when you Tribute an EARTH monster, but when I tried adding in the effect, it didn't do anything different. Here is my card's script file:
--Toon Cannon Soldier #2
function c10000023.initial_effect(c)
c:EnableReviveLimit()
--cannot special summon
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
e1:SetValue(c10000023.splimit)
c:RegisterEffect(e1)
--special summon
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_SPSUMMON_PROC)
e2:SetProperty(EFFECT_FLAG_UNCOPYABLE)
e2:SetRange(LOCATION_HAND)
e2:SetCondition(c10000023.spcon)
e2:SetOperation(c10000023.spop)
c:RegisterEffect(e2)
--destroy
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e3:SetRange(LOCATION_MZONE)
e3:SetCode(EVENT_LEAVE_FIELD)
e3:SetCondition(c10000023.sdescon)
e3:SetOperation(c10000023.sdesop)
c:RegisterEffect(e3)
--direct attack
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_SINGLE)
e4:SetCode(EFFECT_DIRECT_ATTACK)
e4:SetCondition(c10000023.dircon)
c:RegisterEffect(e4)
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_FIELD)
e5:SetCode(EFFECT_CANNOT_BE_BATTLE_TARGET)
e5:SetRange(LOCATION_MZONE)
e5:SetTargetRange(0,LOCATION_MZONE)
e5:SetTarget(c10000023.attg)
e5:SetCondition(c10000023.atcon)
e5:SetValue(c10000023.atval)
c:RegisterEffect(e5)
local e6=Effect.CreateEffect(c)
e6:SetType(EFFECT_TYPE_SINGLE)
e6:SetCode(EFFECT_CANNOT_DIRECT_ATTACK)
e6:SetCondition(c10000023.atcon)
c:RegisterEffect(e6)
--cannot attack
local e7=Effect.CreateEffect(c)
e7:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e7:SetCode(EVENT_SPSUMMON_SUCCESS)
e7:SetOperation(c10000023.atklimit)
c:RegisterEffect(e7)
--attack cost
local e8=Effect.CreateEffect(c)
e8:SetType(EFFECT_TYPE_SINGLE)
e8:SetCode(EFFECT_ATTACK_COST)
e8:SetCost(c10000023.atcost)
e8:SetOperation(c10000023.atop)
c:RegisterEffect(e8)
--damage
local e9=Effect.CreateEffect(c)
e9:SetDescription(aux.Stringid(10000023,0))
e9:SetCategory(CATEGORY_DAMAGE)
e9:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e9:SetType(EFFECT_TYPE_IGNITION)
e9:SetRange(LOCATION_MZONE)
e9:SetCost(c10000023.damcost)
e9:SetTarget(c10000023.damtg)
e9:SetOperation(c10000023.damop)
c:RegisterEffect(e9)
local e10=Effect.CreateEffect(c)
e10:SetType(EFFECT_TYPE_SINGLE)
e10:SetCode(EFFECT_MATERIAL_CHECK)
e10:SetValue(c10000023.valcheck)
e10:SetLabelObject(e9)
c:RegisterEffect(e10)
end
function c10000023.splimit(e,se,sp,st,spos,tgp)
return Duel.IsExistingMatchingCard(c10000023.cfilter,tgp,LOCATION_ONFIELD,0,1,nil)
end
function c10000023.cfilter(c)
return c:IsFaceup() and c:IsCode(15259703)
end
function c10000023.spcon(e,c)
if c==nil then return true end
local tp=c:GetControler()
if not Duel.IsExistingMatchingCard(c10000023.cfilter,tp,LOCATION_ONFIELD,0,1,nil) then return false end
local lv=c:GetLevel()
if lv<5 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
elseif lv<7 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1 and Duel.CheckReleaseGroup(tp,nil,1,nil)
else return Duel.GetLocationCount(tp,LOCATION_MZONE)>-2 and Duel.CheckReleaseGroup(tp,nil,2,nil) end
end
function c10000023.spop(e,tp,eg,ep,ev,re,r,rp,c)
local lv=c:GetLevel()
local tp=c:GetControler()
if lv<5 then
elseif lv<7 then
local g=Duel.SelectReleaseGroup(tp,nil,1,1,nil)
Duel.Release(g,REASON_COST)
else
local g=Duel.SelectReleaseGroup(tp,nil,2,2,nil)
Duel.Release(g,REASON_COST)
end
end
function c10000023.sfilter(c)
return c:IsReason(REASON_DESTROY) and c:IsCode(15259703) and c:IsPreviousLocation(LOCATION_ONFIELD)
end
function c10000023.sdescon(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(c10000023.sfilter,1,nil)
end
function c10000023.sdesop(e,tp,eg,ep,ev,re,r,rp)
Duel.Destroy(e:GetHandler(),REASON_EFFECT)
end
function c10000023.atkfilter(c)
return c:IsFaceup() and c:IsType(TYPE_TOON)
end
function c10000023.dircon(e)
return not Duel.IsExistingMatchingCard(c10000023.atkfilter,e:GetHandlerPlayer(),0,LOCATION_MZONE,1,nil)
end
function c10000023.atcon(e)
return Duel.IsExistingMatchingCard(c10000023.atkfilter,e:GetHandlerPlayer(),0,LOCATION_MZONE,1,nil)
end
function c10000023.attg(e,c)
return not c:IsType(TYPE_TOON)
end
function c10000023.atval(e,c)
return c==e:GetHandler()
end
function c10000023.atklimit(e,tp,eg,ep,ev,re,r,rp)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CANNOT_ATTACK)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
e:GetHandler():RegisterEffect(e1)
end
function c10000023.atcost(e,c,tp)
return Duel.CheckLPCost(tp,500)
end
function c10000023.atop(e,tp,eg,ep,ev,re,r,rp)
Duel.PayLPCost(tp,500)
end
function c10000023.damcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.CheckReleaseGroup(tp,nil,1,nil) end
local sg=Duel.SelectReleaseGroup(tp,nil,1,1,nil)
Duel.Release(sg,REASON_COST)
end
function c10000023.damtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetTargetPlayer(1-tp)
Duel.SetTargetParam(500)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,500)
if e:GetLabel()==1 then
Duel.SetOperationInfo(0,CATEGORY_HANDES,0,0,1-tp,1)
end
end
function c10000023.damop(e,tp,eg,ep,ev,re,r,rp)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Damage(p,d,REASON_EFFECT)
if e:GetLabel()==1 then
local g=Duel.GetFieldGroup(ep,LOCATION_HAND,0,nil)
local sg=g:RandomSelect(ep,1)
Duel.SendtoGrave(sg,REASON_DISCARD+REASON_EFFECT)
end
end
function c10000023.valcheck(e,c)
local g=c:GetCost()
if g:IsExists(Card.IsType,1,nil,TYPE_TOON) then
e:GetLabelObject():SetLabel(1)
else
e:GetLabelObject():SetLabel(0)
end
end
Thank you in advance for anyone who can help me with this!