--Mysterious Dragon function c53313901.initial_effect(c) aux.AddOrigPandemoniumType(c) --Once per turn: You can target 1 face-up "Mysterious" monster you control; once during this turn, it cannot be destroyed by battle or by card effects. local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_FREE_CHAIN) e1:SetRange(LOCATION_SZONE) e1:SetCountLimit(1) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCondition(aux.PandActCheck) e1:SetTarget(c53313901.target) e1:SetOperation(c53313901.operation) c:RegisterEffect(e1) aux.EnablePandemoniumAttribute(c,e1) --effect change local e2=Effect.CreateEffect(c) e2:SetDescription(1102) e2:SetCategory(CATEGORY_REMOVE) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1) e2:SetTarget(c53313901.remtg) e2:SetOperation(c53313901.remop) c:RegisterEffect(e2) --lv change local e3=Effect.CreateEffect(c) e3:SetDescription(1370) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetCountLimit(1) e3:SetRange(LOCATION_MZONE) e3:SetProperty(EFFECT_FLAG_CARD_TARGET) e3:SetTarget(c53313901.lvtg) e3:SetOperation(c53313901.lvop) c:RegisterEffect(e3) end function c53313901.filter(c) return c:IsFaceup() and c:IsSetCard(0xcf6) end function c53313901.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsOnField() and c53313901.filter(chkc) end if chk==0 then return Duel.IsExistingTarget(c53313901.filter,tp,LOCATION_MZONE,0,1,nil) and e:GetHandler():GetFlagEffect(53313901)==0 end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) Duel.SelectTarget(tp,c53313901.filter,tp,LOCATION_MZONE,0,1,1,nil) e:GetHandler():RegisterFlagEffect(53313901,RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END,0,1) end function c53313901.operation(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if e:GetHandler():IsRelateToEffect(e) and tc:IsRelateToEffect(e) and tc:IsFaceup() then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_INDESTRUCTABLE_COUNT) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetCountLimit(1) e1:SetValue(c53313901.valcon) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1) end end function c53313901.valcon(e,re,r,rp) return bit.band(r,REASON_BATTLE+REASON_EFFECT)~=0 end function c53313901.rfilter(c) return (not c:IsLocation(LOCATION_EXTRA) or c:IsFaceup()) and c:IsType(TYPE_MONSTER) and c:IsAbleToRemove() and c:IsLevelAbove(2) and c:IsLevelBelow(8) end function c53313901.remtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(0x50) and chkc:IsType(TYPE_MONSTER) and chkc:IsAbleToRemove() end if chk==0 then return Duel.IsExistingMatchingCard(c53313901.rfilter,tp,LOCATION_GRAVE+LOCATION_EXTRA,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,0,0) end function c53313901.remop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,c53313901.rfilter,tp,LOCATION_GRAVE+LOCATION_EXTRA,0,1,1,nil) for tc in aux.Next(g) do c:CopyEffect(tc:GetCode(),RESET_EVENT+0x1ff0000+RESET_PHASE+PHASE_END) end if g:GetCount()>0 then Duel.Remove(g,POS_FACEUP,REASON_EFFECT) end end function c53313901.lvtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and chkc:IsFaceup() end if chk==0 then return Duel.IsExistingTarget(Card.IsFaceup,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) local g=Duel.SelectTarget(tp,Card.IsFaceup,tp,LOCATION_MZONE,0,1,1,nil) local t={} local i=1 local p=1 local lv=g:GetFirst():GetLevel() for i=1,7 do if lv~=i then t[p]=i p=p+1 end end t[p]=nil Duel.Hint(HINT_SELECTMSG,tp,567) e:SetLabel(Duel.AnnounceNumber(tp,table.unpack(t))) end function c53313901.lvop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsFaceup() and tc:IsRelateToEffect(e) then local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_CHANGE_LEVEL) e1:SetValue(e:GetLabel()) e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1) end end