--Amethyst-Wing Dragon local ref=_G['c'..171000112] function c171000112.initial_effect(c) --pendulum summon aux.EnablePendulumAttribute(c) --pendulum set local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_DESTROYED) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e1:SetCountLimit(1,171000112) e1:SetCondition(c171000112.pencon) e1:SetTarget(c171000112.pentg) e1:SetOperation(c171000112.penop) c:RegisterEffect(e1) --atk local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_ATKCHANGE) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_ATTACK_ANNOUNCE) e2:SetRange(LOCATION_PZONE) e2:SetCountLimit(1,171000112) e2:SetCondition(c171000112.atkcon) e2:SetOperation(c171000112.atkop) c:RegisterEffect(e2) --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) --spsummon local e6=Effect.CreateEffect(c) e6:SetCategory(CATEGORY_SPECIAL_SUMMON) e6:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e6:SetCode(EVENT_BATTLE_DESTROYING) e6:SetCondition(aux.bdocon) e6:SetCost(c171000112.spcost) e6:SetTarget(c171000112.sptg) e6:SetOperation(c171000112.spop) c:RegisterEffect(e6) end function c171000112.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 c171000112.penfilter(c) return c:IsSetCard(0xfef) and c:IsType(TYPE_PENDULUM) and not c:IsForbidden() end function c171000112.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(c171000112.penfilter,tp,LOCATION_DECK,0,1,nil) end end function c171000112.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,c171000112.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 --gain atk function c171000112.atkcon(e,tp,eg,ep,ev,re,r,rp) local at=Duel.GetAttacker() return at and at:IsControler(tp) and at:IsSetCard(0xfef) and at:IsOnField() and Duel.IsExistingMatchingCard(c171000112.atkfilter,tp,LOCATION_PZONE,0,1,nil) end function c171000112.atkfilter(c) return c:IsFaceup() and c:IsType(TYPE_PENDULUM) and c:IsSetCard(0xfef) end function c171000112.atkop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local at=Duel.GetAttacker() if at:IsFaceup() and at:IsRelateToBattle() then local atkval=Duel.GetMatchingGroupCount(c171000112.atkfilter,tp,LOCATION_PZONE,0,nil)*500 if atkval<=0 then return end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetValue(atkval) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) at:RegisterEffect(e1) end end function c171000112.spcost(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 c171000112.spfilter(c,e,tp) return c:IsType(TYPE_PENDULUM) and c:IsSetCard(0xfef) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c171000112.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1 and Duel.IsExistingMatchingCard(c171000112.spfilter,tp,LOCATION_PZONE,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND+LOCATION_DECK) end function c171000112.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,c171000112.spfilter,tp,LOCATION_PZONE,0,1,1,nil,e,tp) if g:GetCount()>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end