--Etherveil Soul Caller local cid,id=GetID() function cid.initial_effect(c) --cannot special summon local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e1:SetCode(EFFECT_SPSUMMON_CONDITION) e1:SetValue(cid.splimit) c:RegisterEffect(e1) --remove local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,0)) e2:SetCategory(CATEGORY_REMOVE) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1,id) e2:SetCondition(cid.tdcon1) e2:SetCost(cid.bcost) e2:SetTarget(cid.btg) e2:SetOperation(cid.bop) c:RegisterEffect(e2) local e2x=e2:Clone() e2x:SetType(EFFECT_TYPE_QUICK_O) e2x:SetCode(EVENT_FREE_CHAIN) e2x:SetCondition(cid.tdcon2) c:RegisterEffect(e2x) --destroyed local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(id,1)) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e3:SetProperty(EFFECT_FLAG_DELAY) e3:SetCode(EVENT_DESTROYED) e3:SetCountLimit(1,id+10000) e3:SetCost(cid.spcost) e3:SetTarget(cid.sptg) e3:SetOperation(cid.spop) c:RegisterEffect(e3) end function cid.tdcon1(e,tp,eg,ep,ev,re,r,rp) return not Duel.IsPlayerAffectedByEffect(tp,21022007) end function cid.tdcon2(e,tp,eg,ep,ev,re,r,rp) return Duel.IsPlayerAffectedByEffect(tp,21022007) end function cid.splimit(e,se,sp,st) return se:IsHasType(EFFECT_TYPE_ACTIONS) end function cid.cfilter(c) return c:IsFacedown() and c:IsAbleToDeckAsCost() end function cid.bcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.cfilter,tp,LOCATION_REMOVED,0,3,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local g=Duel.SelectMatchingCard(tp,cid.cfilter,tp,LOCATION_REMOVED,0,3,3,nil) if #g>0 then Duel.SendtoDeck(g,nil,2,REASON_COST) end end function cid.btg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsAbleToRemove(POS_FACEDOWN) end if chk==0 then return Duel.IsExistingTarget(Card.IsAbleToRemove,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,nil,POS_FACEDOWN) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectTarget(tp,Card.IsAbleToRemove,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,1,nil,POS_FACEDOWN) Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,1,0,0) end function cid.bop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.Remove(tc,POS_FACEDOWN,REASON_EFFECT) end end function cid.spcost(e,tp,eg,ep,ev,re,r,rp,chk) local g=Duel.GetDecktopGroup(tp,5) if chk==0 then return g:FilterCount(Card.IsAbleToRemoveAsCost,nil,POS_FACEDOWN)==5 end Duel.DisableShuffleCheck() Duel.Remove(g,POS_FACEDOWN,REASON_COST) end function cid.filter(c,e,tp) return c:IsSetCard(0x312) and c:IsType(TYPE_MONSTER) and not c:IsCode(id) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function cid.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(cid.filter,tp,LOCATION_HAND+LOCATION_GRAVE,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND+LOCATION_GRAVE) end function cid.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(cid.filter),tp,LOCATION_HAND+LOCATION_GRAVE,0,1,1,nil,e,tp) if g:GetCount()>0 and Duel.SpecialSummonStep(g,0,tp,tp,false,false,POS_FACEUP) then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetCode(EFFECT_SEND_REPLACE) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e1:SetTarget(cid.reptg) e1:SetOperation(cid.repop) e1:SetReset(RESET_EVENT+RESETS_STANDARD) g:GetFirst():RegisterEffect(e1,true) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_LEAVE_FIELD_REDIRECT) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetReset(RESET_EVENT+RESETS_STANDARD) e1:SetCondition(cid.regcon) e1:SetValue(LOCATION_REMOVED) g:GetFirst():RegisterEffect(e1,true) end Duel.SpecialSummonComplete() end function cid.reptg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then if ((c:IsReason(REASON_COST) and c:IsAbleToRemoveAsCost()) or (not c:IsReason(REASON_COST) and c:IsAbleToRemove())) and c:GetFlagEffect(id)==0 then c:RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD,0,1) return true else return false end end return true end function cid.repop(e,tp,eg,ep,ev,re,r,rp) Duel.Remove(e:GetHandler(),POS_FACEDOWN,bit.bor(c:GetReason(),REASON_REDIRECT)) end function cid.regcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():GetDestination()~=LOCATION_REMOVED end