--Mantra Counterforce --Automate ID local scard,s_id=GetID() function scard.initial_effect(c) Card.IsMantra=Card.IsMantra or (function(tc) return tc:IsSetCard(0x7d0) or (tc:GetCode()>30200 and tc:GetCode()<30230) end) --Activate local e1=Effect.CreateEffect(c) e1:Desc(0) e1:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_CHAINING) e1:SetCondition(scard.condition) e1:SetCost(scard.cost) e1:SetTarget(scard.target) e1:SetOperation(scard.activate) c:RegisterEffect(e1) end function scard.condition(e,tp,eg,ep,ev,re,r,rp) return re:IsActiveType(TYPE_MONSTER) and Duel.IsChainNegatable(ev) end function scard.cfilter(c) return c:NotOnFieldOrFaceup() and c:IsType(TYPE_MONSTER) and c:IsMantra() and c:IsAbleToGraveAsCost() end function scard.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(scard.cfilter,tp,LOCATION_MZONE+LOCATION_HAND,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,scard.cfilter,tp,LOCATION_MZONE+LOCATION_HAND,0,1,1,nil) Duel.SendtoGrave(g,REASON_COST) end function scard.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) local rc=re:GetHandler() if rc:IsDestructable() then if rc:IsRelateToChain(ev) then Duel.SetCardOperationInfo(rc,CATEGORY_DESTROY) else Duel.SetOperationInfo(0,CATEGORY_DESTROY,nil,0,rc:GetPreviousControler(),rc:GetPreviousLocation()) end end end function scard.activate(e,tp,eg,ep,ev,re,r,rp) if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToChain(ev) then Duel.Destroy(eg,REASON_EFFECT) end end