--Pandemoniumgraph Lich local cid,id=GetID() function cid.initial_effect(c) aux.AddOrigPandemoniumType(c) --protection local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) 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(cid.prottg) e1:SetOperation(cid.protop) c:RegisterEffect(e1) aux.EnablePandemoniumAttribute(c,e1) --spsummon local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP) e2:SetCode(EVENT_DESTROYED) e2:SetTarget(cid.sumtg) e2:SetOperation(cid.sumop) c:RegisterEffect(e2) end function cid.spfilter(c,e,tp) return c:IsSetCard(0xcf80) and c:IsType(TYPE_MONSTER) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and c:IsFaceup() and not c:IsCode(id) end function cid.sumtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCountFromEx(tp)>0 and Duel.IsExistingMatchingCard(cid.spfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function cid.sumop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end if Duel.GetLocationCountFromEx(tp)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,cid.spfilter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp) if g:GetCount()>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end function cid.indfilter(c) return c:IsFaceup() and c:IsSetCard(0xcf80) and c:IsType(TYPE_MONSTER) end function cid.prottg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and cid.indfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(cid.indfilter,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) Duel.SelectTarget(tp,cid.indfilter,tp,LOCATION_MZONE,0,1,1,nil) end function cid.protop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local tc=Duel.GetFirstTarget() if tc and tc:IsRelateToEffect(e) then local rct=1 if Duel.GetCurrentPhase()==PHASE_END and Duel.GetTurnPlayer()==1-tp then rct=2 end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_INDESTRUCTABLE_COUNT) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetValue(cid.valcon) e1:SetReset(RESET_PHASE+PHASE_END+RESET_OPPO_TURN,rct) tc:RegisterEffect(e1) Duel.BreakEffect() Duel.Destroy(e:GetHandler(),REASON_EFFECT) end end function cid.valcon(e,re,r,rp) return bit.band(r,REASON_BATTLE+REASON_EFFECT)~=0 end