--Zodiakieri of the Starry Nights function c9945580.initial_effect(c) c:EnableReviveLimit() aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsLinkType,TYPE_SPIRIT),2,2) --to hand local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(9945580,0)) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1,9945580) e1:SetTarget(c9945580.thtg) e1:SetOperation(c9945580.thop) c:RegisterEffect(e1) --inaff local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(9945580,1)) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_FREE_CHAIN) e2:SetCountLimit(1,9945581) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetRange(LOCATION_MZONE) e2:SetCondition(c9945580.condition) e2:SetTarget(c9945580.intg) e2:SetOperation(c9945580.inop) c:RegisterEffect(e2) --return local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e3:SetCode(EVENT_SPSUMMON_SUCCESS) e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e3:SetOperation(c9945580.retreg) c:RegisterEffect(e3) end function c9945580.filter(c) return c:IsLevelBelow(4) and c:IsType(TYPE_SPIRIT) and c:IsAbleToHand() end function c9945580.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c9945580.filter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function c9945580.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,c9945580.filter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end function c9945580.cfilter(c) return c:IsFaceup() and c:IsType(TYPE_SPIRIT) end function c9945580.condition(e,tp,eg,ep,ev,re,r,rp) return Duel.GetCurrentPhase()~=PHASE_DAMAGE or not Duel.IsDamageCalculated() end function c9945580.intg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and c9945580.cfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(c9945580.cfilter,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) Duel.SelectTarget(tp,c9945455.cfilter,tp,LOCATION_MZONE,0,1,1,nil) end function c9945580.inop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() local ph=Duel.GetCurrentPhase() if tc:IsRelateToEffect(e) and tc:IsFaceup() then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_IMMUNE_EFFECT) e1:SetReset(RESET_PHASE+(ph)+RESET_EVENT+0x1fc0000) e1:SetValue(1) tc:RegisterEffect(e1) end end function c9945580.retreg(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F) e1:SetDescription(1104) e1:SetCategory(CATEGORY_TODECK+CATEGORY_SPECIAL_SUMMON) e1:SetCode(EVENT_PHASE+PHASE_END) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1) e1:SetReset(RESET_EVENT+0x1ee0000+RESET_PHASE+PHASE_END) e1:SetCondition(c9945580.retcon) e1:SetTarget(c9945580.rettg) e1:SetOperation(c9945580.retop) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) c:RegisterEffect(e2) end function c9945580.retcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not bit.band(e:GetHandler():GetSummonType(),SUMMON_TYPE_RITUAL)==SUMMON_TYPE_RITUAL or c:IsHasEffect(EFFECT_SPIRIT_DONOT_RETURN) then return false end if e:IsHasType(EFFECT_TYPE_TRIGGER_F) then return not c:IsHasEffect(EFFECT_SPIRIT_MAYNOT_RETURN) and Duel.GetTurnPlayer()==tp else return c:IsHasEffect(EFFECT_SPIRIT_MAYNOT_RETURN) and Duel.GetTurnPlayer()==tp end end function c9945580.retfilter(c,e,tp) return c:IsSetCard(0x12D7) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c9945580.rettg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then if e:IsHasType(EFFECT_TYPE_TRIGGER_F) then return true else return Duel.GetLocationCount(tp,LOCATION_MZONE)>-1 and Duel.IsExistingMatchingCard(c9945580.retfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end end Duel.SetOperationInfo(0,CATEGORY_TODECK,e:GetHandler(),1,0,0) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function c9945580.retop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and c:IsFaceup() and Duel.GetLocationCount(tp,LOCATION_MZONE)>-1 then Duel.SendtoDeck(c,nil,2,REASON_EFFECT) local g=Duel.SelectMatchingCard(tp,c9945580.retfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp) if g:GetCount()>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end end