--Moonvale Spiritualist function c10505087.initial_effect(c) c:EnableReviveLimit() --Proctection local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(10505087,1)) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e1:SetCountLimit(1,10505087) e1:SetCondition(c10505087.tgcon) e1:SetOperation(c10505087.operation) c:RegisterEffect(e1) --Special up to 2 from grave local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(10505087,1)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetCode(EVENT_FREE_CHAIN) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1,10505079) e2:SetCost(c10505087.spcost) e2:SetTarget(c10505087.sptg) e2:SetOperation(c10505087.spop) c:RegisterEffect(e2) end function c10505087.tgcon(e,tp,eg,ep,ev,re,r,rp) return bit.band(e:GetHandler():GetSummonType(),SUMMON_TYPE_RITUAL)==SUMMON_TYPE_RITUAL end function c10505087.operation(e,tp,eg,ep,ev,re,r,rp) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_INDESTRUCTABLE) e1:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e1:SetTargetRange(LOCATION_MZONE,0) e1:SetTarget(c10505087.target) e1:SetReset(RESET_PHASE+PHASE_END) e1:SetValue(1) Duel.RegisterEffect(e1,tp) end function c10505087.target(e,c) return c:IsSetCard(0x1a4) end function c10505087.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 c10505087.spfilter(c,e,tp) return c:IsLevelBelow(5) and c:IsSetCard(0x1a4) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function c10505087.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and c10505087.spfilter(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingTarget(c10505087.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end local ct=Duel.GetLocationCount(tp,LOCATION_MZONE) if ct>2 then ct=2 end if Duel.IsPlayerAffectedByEffect(tp,59822133) then ct=1 end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectTarget(tp,c10505087.spfilter,tp,LOCATION_GRAVE,0,1,ct,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,g:GetCount(),0,0) end function c10505087.spop(e,tp,eg,ep,ev,re,r,rp) local ft=Duel.GetLocationCount(tp,LOCATION_MZONE) if ft<=0 then return end local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS) local sg=g:Filter(Card.IsRelateToEffect,nil,e) if sg:GetCount()==0 or (sg:GetCount()>1 and Duel.IsPlayerAffectedByEffect(tp,59822133)) then return end if ft>=g:GetCount() then Duel.SpecialSummon(sg,0,tp,tp,false,false,POS_FACEUP) else Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg2=sg:Select(tp,ft,ft,nil) Duel.SpecialSummon(sg2,0,tp,tp,false,false,POS_FACEUP) end end