--NREM Thanatosa local cid,id=GetID() function cid.initial_effect(c) c:EnableReviveLimit() --destroy local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetCountLimit(1,id) e1:SetTarget(cid.destg) e1:SetOperation(cid.desop) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetDescription(aux.Stringid(id,1)) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetRange(LOCATION_MZONE) e2:SetCondition(cid.descon) c:RegisterEffect(e2) --Protect Nightmare local e9=Effect.CreateEffect(c) e9:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e9:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e9:SetCode(EVENT_RELEASE) e9:SetCondition(cid.indcon) e9:SetOperation(cid.atop) c:RegisterEffect(e9) end function cid.descon(e,tp,eg,ep,ev,re,r,rp) return not eg:IsContains(e:GetHandler()) and eg:IsExists(Card.IsControler,1,nil,1-tp) end function cid.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) end if chk==0 then return Duel.IsExistingTarget(aux.TRUE,tp,0,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectTarget(tp,aux.TRUE,tp,0,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,g:GetCount(),0,0) end function cid.desop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() local sq=tc:GetSequence() if tc:IsControler(1-tp) then sq=sq+16 end if tc:IsRelateToEffect(e) and Duel.Destroy(tc,REASON_EFFECT)~=0 then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetRange(LOCATION_MZONE) e1:SetCode(EFFECT_DISABLE_FIELD) e1:SetReset(RESET_EVENT+RESETS_STANDARD) e1:SetOperation(cid.disop) e1:SetLabel(sq) c:RegisterEffect(e1) end end function cid.disop(e,tp) local dis1=bit.lshift(0x1,e:GetLabel()) return dis1 end function cid.indcon(e,tp,eg,ep,ev,re,r,rp) return Duel.IsExistingTarget(cid.filter2,tp,LOCATION_MZONE,0,1,nil,tp) end function cid.filter2(c) return c:IsFaceup() and c:IsType(TYPE_RITUAL) end function cid.atop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(cid.filter2,tp,LOCATION_MZONE,0,nil) local tc=g:GetFirst() local c=e:GetHandler() while tc do --indes local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT) e2:SetRange(LOCATION_MZONE) e2:SetReset(RESET_EVENT+RESETS_STANDARD) e2:SetValue(1) tc:RegisterEffect(e2) tc=g:GetNext() end end