--Spirit Cycle --Scripted by: XGlitchy30 local s,id=GetID() function s.initial_effect(c) --Special Summon 1 Level 3 Beast monster from your Deck, but destroy it during the End Phase. local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:HOPT() e1:SetTarget(s.target) e1:SetOperation(s.activate) c:RegisterEffect(e1) --You can banish this card and 2 Beast monsters from your GY; add 1 Beast monster from your Deck to your hand, with a different Attribute than your banished monsters. local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetCategory(CATEGORIES_SEARCH) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_GRAVE) e2:HOPT() e2:SetCost(s.thcost) e2:SetTarget(s.thtg) e2:SetOperation(s.thop) c:RegisterEffect(e2) end function s.filter(c,e,tp) return c:IsMonster() and c:IsSetCard(0xe51) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function s.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,0,LOCATION_DECK) end function s.activate(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,s.filter,tp,LOCATION_DECK,0,1,1,nil,e,tp) local tc=g:GetFirst() if tc and Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP)~=0 then local c=e:GetHandler() local fid=c:GetFieldID() tc:RegisterFlagEffect(id,RESET_EVENT|RESETS_STANDARD,0,1,fid) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD|EFFECT_TYPE_CONTINUOUS) e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e1:SetCode(EVENT_PHASE|PHASE_END) e1:SetCountLimit(1) e1:SetLabel(fid) e1:SetLabelObject(tc) e1:SetCondition(s.descon) e1:SetOperation(s.desop) Duel.RegisterEffect(e1,tp) end end function s.descon(e,tp,eg,ep,ev,re,r,rp) local tc=e:GetLabelObject() if tc and tc:HasFlagEffectLabel(id,e:GetLabel()) then return true else e:Reset() return false end end function s.desop(e,tp,eg,ep,ev,re,r,rp) local tc=e:GetLabelObject() if tc then Duel.Destroy(tc,REASON_EFFECT) end end function s.cfilter(c) return c:IsMonster() and c:IsRace(RACE_BEAST) and c:IsAbleToRemoveAsCost() end function s.costcheck(g,tp,attg,c) local cg=g:Clone() cg:AddCard(c) local res=Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_DECK,0,1,nil,tp,attg,cg) cg:DeleteGroup() return res end function s.thfilter(c,tp,g,cg) if cg then g:Merge(cg) end return c:IsMonster() and c:IsSetCard(0xe51) and c:IsAbleToHand() and not g:IsExists(Card.IsAttribute,1,nil,c:GetAttribute()) end function s.attfilter(c) return c:IsFaceup() and c:IsMonster() and c:GetAttribute()~=0 end function s.thcost(e,tp,eg,ep,ev,re,r,rp,chk) e:SetLabel(1) local c=e:GetHandler() local g=Duel.GetMatchingGroup(s.cfilter,tp,LOCATION_GRAVE,0,c) local attg=Duel.GetMatchingGroup(s.attfilter,tp,LOCATION_REMOVED,0,nil) if chk==0 then return c:IsAbleToRemoveAsCost() and #g>=2 and g:CheckSubGroup(s.costcheck,2,2,tp,attg,c) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local sg=g:SelectSubGroup(tp,s.costcheck,false,2,2,tp,attg,c) sg:AddCard(c) Duel.Remove(sg,POS_FACEUP,REASON_COST) end function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then if e:GetLabel()==1 then e:SetLabel(0) return true end e:SetLabel(0) local attg=Duel.GetMatchingGroup(s.attfilter,tp,LOCATION_REMOVED,0,nil) return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_DECK,0,1,nil,tp,attg) end e:SetLabel(0) Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function s.thop(e,tp,eg,ep,ev,re,r,rp) local attg=Duel.GetMatchingGroup(s.attfilter,tp,LOCATION_REMOVED,0,nil) local g=Duel.Select(HINTMSG_ATOHAND,false,tp,s.thfilter,tp,LOCATION_DECK,0,1,1,nil,tp,attg) if #g>0 then Duel.Search(g,tp) end end