--Bigbang Defender local s,id=GetID() function s.initial_effect(c) c:EnableReviveLimit() aux.AddOrigBigbangType(c) aux.AddBigbangProc(c,Card.IsNeutral,1,1,Card.IsNegative,1) --The first time this card would be destroyed by card effect each turn, it is not destroyed. local e0=Effect.CreateEffect(c) e0:SetType(EFFECT_TYPE_SINGLE) e0:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e0:SetRange(LOCATION_MZONE) e0:SetCode(EFFECT_INDESTRUCTABLE_COUNT) e0:SetCountLimit(1) e0:SetValue(s.valcon) c:RegisterEffect(e0) --Once per turn, when an opponent's monster activates its effects on the field, or declares an attack, while you control this Defense Position monster --(Quick Effect): You can banish 1 Negative monster from your hand, field or GY; negate the activation or attack, and if you do banish that opponent's monster. local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_NEGATE+CATEGORY_REMOVE) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_CHAINING) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE) e1:SetCondition(s.negcon) e1:SetCost(s.negcost) e1:SetTarget(aux.nbtg) e1:SetOperation(s.negop) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_ATTACK_ANNOUNCE) e2:SetCondition(s.negcon2) e2:SetTarget(s.negtg2) e2:SetOperation(s.negop2) c:RegisterEffect(e2) --If this card attacks, it is changed to Defense Position at the end of the Damage Step. local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e3:SetCode(EVENT_DAMAGE_STEP_END) e3:SetCondition(s.poscon) e3:SetOperation(s.posop) c:RegisterEffect(e3) end function s.valcon(e,re,r,rp) return bit.band(r,REASON_EFFECT)~=0 end function s.negcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local rc=re:GetHandler() return re:IsActiveType(TYPE_MONSTER) and rc~=c and rc:GetControler()~=tp and not c:IsStatus(STATUS_BATTLE_DESTROYED) and Duel.IsChainNegatable(ev) and c:IsDefensePos() end function s.banishfilter(c) return c:IsNegative() and c:IsAbleToRemoveAsCost() and (not c:IsLocation(LOCATION_MZONE) or c:IsFaceup()) end function s.negcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.banishfilter,tp,0x16,0,1,nil) end local g=Duel.SelectMatchingCard(tp,s.banishfilter,tp,0x16,0,1,1,nil) Duel.Remove(g,POS_FACEUP,REASON_COST) end function s.negop(e,tp,eg,ep,ev,re,r,rp) if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then Duel.Remove(eg,POS_FACEUP,REASON_EFFECT) end end function s.negcon2(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return Duel.GetAttacker():GetControler()~=tp and c:IsDefensePos() end function s.negtg2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetAttacker():IsAbleToRemove() end Duel.SetOperationInfo(0,CATEGORY_REMOVE,Duel.GetAttacker(),1,0,0) end function s.negop2(e,tp,eg,ep,ev,re,r,rp) if Duel.NegateAttack() then Duel.Remove(Duel.GetAttacker(),POS_FACEUP,REASON_EFFECT) end end function s.poscon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler()==Duel.GetAttacker() and e:GetHandler():IsRelateToBattle() end function s.posop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsAttackPos() then Duel.ChangePosition(c,POS_FACEUP_DEFENSE) end end