--Amethyst-Wing Spine Tail local ref=_G['c'..171000116] function ref.initial_effect(c) --pendulum summon aux.EnablePendulumAttribute(c) --splimit local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetRange(LOCATION_PZONE) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_CANNOT_NEGATE) e1:SetTargetRange(1,0) e1:SetTarget(ref.splimit) c:RegisterEffect(e1) --pendulum set local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_DESTROYED) e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e2:SetCountLimit(1,171000116) e2:SetCondition(c171000116.pencon) e2:SetTarget(c171000116.pentg) e2:SetOperation(c171000116.penop) c:RegisterEffect(e2) --negate local e2x=Effect.CreateEffect(c) e2x:SetCategory(CATEGORY_DISABLE+CATEGORY_DESTROY) e2x:SetType(EFFECT_TYPE_QUICK_O) e2x:SetCode(EVENT_CHAINING) e2x:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e2x:SetRange(LOCATION_PZONE) e2x:SetCountLimit(1,171000116) e2x:SetCondition(c171000116.discon) e2x:SetTarget(c171000116.distg) e2x:SetOperation(c171000116.disop) c:RegisterEffect(e2x) --cannot be used as material local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e3:SetCode(EFFECT_CANNOT_BE_FUSION_MATERIAL) e3:SetValue(1) c:RegisterEffect(e3) local e4=e3:Clone() e4:SetCode(EFFECT_CANNOT_BE_SYNCHRO_MATERIAL) c:RegisterEffect(e4) local e5=e3:Clone() e5:SetCode(EFFECT_CANNOT_BE_XYZ_MATERIAL) c:RegisterEffect(e5) --cannot be targeted local e7=Effect.CreateEffect(c) e7:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e7:SetCode(EVENT_SUMMON_SUCCESS) e7:SetCountLimit(1,171000116) e7:SetOperation(c171000116.ctop) c:RegisterEffect(e7) local e8=e7:Clone() e8:SetCode(EVENT_SPSUMMON_SUCCESS) c:RegisterEffect(e8) --destroy local e9=Effect.CreateEffect(c) e9:SetCategory(CATEGORY_DESTROY) e9:SetType(EFFECT_TYPE_QUICK_O) e9:SetProperty(EFFECT_FLAG_CARD_TARGET) e9:SetCode(EVENT_FREE_CHAIN) e9:SetRange(LOCATION_MZONE) e9:SetCountLimit(1,171000116) e9:SetCost(c171000116.descost) e9:SetTarget(c171000116.destg) e9:SetOperation(c171000116.desop) c:RegisterEffect(e9) end function ref.splimit(e,c,sump,sumtype,sumpos,targetp) if c:IsSetCard(0xfef) then return false end return bit.band(sumtype,SUMMON_TYPE_PENDULUM)==SUMMON_TYPE_PENDULUM end function ref.pencon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsPreviousPosition(POS_FACEUP) and c:IsPreviousLocation(LOCATION_PZONE) end function ref.penfilter(c) return c:IsSetCard(0xfef) and c:IsType(TYPE_PENDULUM) and not c:IsForbidden() end function ref.pentg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return (Duel.CheckLocation(tp,LOCATION_PZONE,0) or Duel.CheckLocation(tp,LOCATION_PZONE,1)) and Duel.IsExistingMatchingCard(c171000116.penfilter,tp,LOCATION_DECK,0,1,nil) end end function ref.penop(e,tp,eg,ep,ev,re,r,rp) if not (Duel.CheckLocation(tp,LOCATION_PZONE,0) or Duel.CheckLocation(tp,LOCATION_PZONE,1)) then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOFIELD) local g=Duel.SelectMatchingCard(tp,c171000116.penfilter,tp,LOCATION_DECK,0,1,1,nil) local tc=g:GetFirst() if tc then Duel.MoveToField(tc,tp,tp,LOCATION_PZONE,POS_FACEUP,true) end end function c171000116.atkcon(e,tp,eg,ep,ev,re,r,rp) local at=eg:GetFirst() return at:IsFaceup() and at:IsControler(tp) and at:IsSetCard(0xfef) end function c171000116.atkop(e,tp,eg,ep,ev,re,r,rp) local atk=eg:GetFirst() if atk:IsRelateToBattle() then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) e1:SetValue(e:GetHandler():GetDefense()) atk:RegisterEffect(e1) end end function c171000116.atkfilter(c) return c:IsFaceup() and c:IsSetCard(0xfef) end function c171000116.atkval(e,c) return Duel.GetMatchingGroupCount(c171000116.atkfilter,c:GetControler(),LOCATION_MZONE,LOCATION_MZONE,nil)*500 end function c171000116.disfilter(c,tp) return c:IsSetCard(0xfef) and c:IsLocation(LOCATION_MZONE) and c:IsFaceup() and c:IsType(TYPE_MONSTER) and c:IsControler(tp) end function c171000116.discon(e,tp,eg,ep,ev,re,r,rp) if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then return false end local tg=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS) return tg and tg:IsExists(c171000116.disfilter,1,nil,tp) and Duel.IsChainDisablable(ev) end function c171000116.distg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsDestructable(e) end Duel.SetOperationInfo(0,CATEGORY_DESTROY,e:GetHandler(),1,0,0) Duel.SetOperationInfo(0,CATEGORY_DISABLE,eg,1,0,0) end function c171000116.disop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and Duel.Destroy(c,REASON_EFFECT)~=0 then Duel.NegateEffect(ev) end end function c171000116.ctop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsFaceup() and c:IsRelateToEffect(e) then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) e1:SetValue(1) c:RegisterEffect(e1) end end function c171000116.descost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsReleasable() end Duel.Release(e:GetHandler(),REASON_COST) end function c171000116.desfilter(c) return c:IsSetCard(0xfef) and c:IsType(TYPE_PENDULUM) and c:IsFaceup() end function c171000116.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return false end if chk==0 then return Duel.IsExistingTarget(c171000116.desfilter,tp,LOCATION_PZONE,0,1,nil) and Duel.IsExistingTarget(aux.TRUE,tp,0,LOCATION_ONFIELD,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g1=Duel.SelectTarget(tp,c171000116.desfilter,tp,LOCATION_PZONE,0,1,1,nil) if #g1<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g2=Duel.SelectTarget(tp,aux.TRUE,tp,0,LOCATION_ONFIELD,1,1,g1:GetFirst()) g1:Merge(g2) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g1,g1:GetCount(),0,0) end function c171000116.desop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,nil,e) if #g>0 then Duel.Destroy(g,REASON_EFFECT) end end