--Zodiakieri of the Crescent Moon function c9945465.initial_effect(c) c:EnableReviveLimit() --ExRitual local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE) e1:SetCode(EFFECT_REMOVE_TYPE) e1:SetRange(LOCATION_ONFIELD+LOCATION_GRAVE+LOCATION_EXTRA+LOCATION_REMOVED+LOCATION_OVERLAY) e1:SetValue(TYPE_FUSION) c:RegisterEffect(e1) --Set local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(9945465,0)) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCode(EVENT_SPSUMMON_SUCCESS) e2:SetTarget(c9945465.settg) e2:SetCondition(c9945465.setcon) e2:SetCountLimit(1,9945465) e2:SetOperation(c9945465.setop) c:RegisterEffect(e2) --negate local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(9945465,1)) e3:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY) e3:SetType(EFFECT_TYPE_QUICK_O) e3:SetCode(EVENT_CHAINING) e3:SetCountLimit(1) e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e3:SetRange(LOCATION_MZONE) e3:SetCondition(c9945465.discon) e3:SetCost(c9945465.discost) e3:SetTarget(c9945465.distg) e3:SetOperation(c9945465.disop) c:RegisterEffect(e3) --return local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e4:SetCode(EVENT_SPSUMMON_SUCCESS) e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e4:SetOperation(c9945465.retreg) c:RegisterEffect(e4) --Revive local e5=Effect.CreateEffect(c) e5:SetDescription(aux.Stringid(9945465,3)) e5:SetType(EFFECT_TYPE_TRIGGER_F+EFFECT_TYPE_FIELD) e5:SetCategory(CATEGORY_SPECIAL_SUMMON) e5:SetCode(EVENT_PHASE+PHASE_STANDBY) e5:SetRange(LOCATION_EXTRA) e5:SetLabelObject(e4) e5:SetCountLimit(1) e5:SetCondition(c9945465.spcon) e5:SetTarget(c9945465.sumtg) e5:SetOperation(c9945465.sumop) c:RegisterEffect(e5) end function c9945465.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(c9945465.retcon) e1:SetTarget(c9945465.rettg) e1:SetOperation(c9945465.retop) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) c:RegisterEffect(e2) end function c9945465.setcon(e,tp,eg,ep,ev,re,r,rp) return bit.band(e:GetHandler():GetSummonType(),SUMMON_TYPE_RITUAL)==SUMMON_TYPE_RITUAL end function c9945465.setfilter(c) return c:IsCode(9945555) and c:IsSSetable() end function c9945465.settg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.IsExistingMatchingCard(c9945465.setfilter,tp,LOCATION_EXTRA,0,1,nil) end end function c9945465.setop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET) local g=Duel.SelectMatchingCard(tp,c9945465.setfilter,tp,LOCATION_EXTRA,0,1,1,nil) if g:GetCount()>0 then Duel.SSet(tp,g:GetFirst()) Duel.ConfirmCards(1-tp,g) end end function c9945465.discon(e,tp,eg,ep,ev,re,r,rp) return not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) and Duel.IsChainNegatable(ev) end function c9945465.disfilter(c) return c:IsSetCard(0x12D7) and c:IsFaceup() and c:IsAbleToHandAsCost() end function c9945465.discost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(c9945465.disfilter,tp,LOCATION_MZONE,0,1,e:GetHandler()) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND) local g=Duel.SelectMatchingCard(tp,c9945465.disfilter,tp,LOCATION_MZONE,0,1,1,e:GetHandler()) Duel.SendtoHand(g,nil,REASON_COST) end function c9945465.distg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,0,0) end end function c9945465.disop(e,tp,eg,ep,ev,re,r,rp) if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then Duel.Destroy(eg,REASON_EFFECT) end end function c9945465.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 c9945465.retfilter(c,e,tp) return c:IsSetCard(0x12D7) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c9945465.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(c9945465.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 c9945465.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) if c:IsLocation(LOCATION_EXTRA) and c:IsPreviousLocation(LOCATION_MZONE) then if Duel.GetTurnPlayer()==tp and Duel.GetCurrentPhase()==PHASE_STANDBY then e:SetLabel(Duel.GetTurnCount()) c:RegisterFlagEffect(9945465,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN,0,2) else e:SetLabel(0) c:RegisterFlagEffect(9945465,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_STANDBY+RESET_SELF_TURN,0,1) end end local g=Duel.SelectMatchingCard(tp,c9945465.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 function c9945465.spcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return e:GetLabelObject():GetLabel()~=Duel.GetTurnCount() and tp==Duel.GetTurnPlayer() and c:GetFlagEffect(9945465)>0 end function c9945465.sumtg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and c:IsCanBeSpecialSummoned(e,0,tp,true,true) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0) c:ResetFlagEffect(9945465) end function c9945465.sumop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToEffect(e) then return end if Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)==0 and Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then Duel.SendtoGrave(c,REASON_RULE) end end