--created by Discord \ Ace/Verloren, coded by Lyris, art from "Shellrokket Dragon" --業が深いシェルヴァレット・ドラゴン local s,id,o=GetID() function s.initial_effect(c) aux.EnablePendulumAttribute(c) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_EXTRA_TOMAIN_KOISHI) e1:SetRange(LOCATION_PZONE) e1:SetTargetRange(LOCATION_EXTRA,0) e1:SetTarget(aux.TargetBoolFunction(Card.IsType,TYPE_PENDULUM)) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e2:SetCode(EVENT_CUSTOM+id) e2:SetCountLimit(1,id) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetTarget(s.psptg) e2:SetOperation(s.pspop) c:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F) e3:SetCode(EVENT_DESTROYED) e3:SetRange(LOCATION_PZONE) e3:SetCountLimit(1,id+o*10) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetCondition(s.dspcon) e3:SetTarget(s.dsptg) e3:SetOperation(s.dspop) c:RegisterEffect(e3) local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_QUICK_O) e4:SetCode(EVENT_CHAINING) e4:SetRange(LOCATION_MZONE) e4:SetCategory(CATEGORY_TOGRAVE+CATEGORY_DESTROY) e4:SetCondition(s.descon) e4:SetTarget(s.destg) e4:SetOperation(s.desop) c:RegisterEffect(e4) local e5=Effect.CreateEffect(c) e5:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e5:SetCode(EVENT_DESTROYED) e5:SetProperty(EFFECT_FLAG_DELAY) e5:SetCondition(s.pzcon) e5:SetTarget(s.pztg) e5:SetOperation(s.pzop) c:RegisterEffect(e5) end function s.psptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function s.filter(c,e,tp,lv) return c:IsSetCard(0x102) and c:IsLevelBelow(lv-1) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function s.pspop(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) Duel.SpecialSummon(Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_DECK,0,1,nil,e,tp,2),0,tp,tp,false,false,POS_FACEUP) end function s.cfilter(c,tp) return c:IsSetCard(0x102) and c:IsPreviousLocation(LOCATION_MZONE) and c:IsPreviousControler(tp) end function s.dspcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(s.cfilter,1,nil,tp) end function s.dsptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function s.dspop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end local g,lv=eg:Filter(s.cfilter,nil,tp):GetMaxGroup(Card.GetLevel()) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) Duel.SpecialSummon(Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_DECK,0,1,nil,e,tp,lv),0,tp,tp,false,false,POS_FACEUP) end function s.descon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then return false end local g=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS) return g and g:IsContains(c) and re:IsActiveType(TYPE_LINK) end function s.destg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() local g=Duel.GetMatchingGroup(Card.IsType,tp,LOCATION_MZONE,LOCATION_MZONE,c,TYPE_FUSION+TYPE_SYNCHRO+TYPE_XYZ+TYPE_LINK) if chk==0 then return c:IsDestructable() and #g>0 end Duel.SetOperationInfo(0,CATEGORY_DESTROY,c,1,0,0) Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,g,1,0,0) end function s.desop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and Duel.Destroy(c,REASON_EFFECT)>0 then local g=Duel.GetMatchingGroup(Card.IsType,tp,LOCATION_MZONE,LOCATION_MZONE,nil,TYPE_FUSION+TYPE_SYNCHRO+TYPE_XYZ+TYPE_LINK) if #g==0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local sg=g:Select(tp,1,1,nil) Duel.HintSelection(sg) Duel.BreakEffect() Duel.SendtoGrave(sg,REASON_EFFECT) end end function s.pzcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsPreviousPosition(POS_FACEUP) and c:IsPreviousLocation(LOCATION_ONFIELD) and rp==tp and c:IsReason(REASON_EFFECT) end function s.pztg(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) end end function s.pzop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and Duel.MoveToField(c,tp,tp,LOCATION_PZONE,POS_FACEUP,true) then Duel.RaiseSingleEvent(c,EVENT_CUSTOM+id,e,REASON_EFFECT,tp,tp,0) end end