--Pandemoniumgraph of Destruction local cid,id=GetID() function cid.initial_effect(c) --You can only control 1 face-up "Pandemoniumgraph of Destruction". c:SetUniqueOnField(1,0,id) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) --Your opponent cannot target Pandemonium Monsters you control with Spell effects. local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET) e2:SetRange(LOCATION_SZONE) e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e2:SetTargetRange(LOCATION_MZONE,0) e2:SetTarget(function(e,c) return c:IsType(TYPE_PANDEMONIUM) end) e2:SetValue(cid.evalue) c:RegisterEffect(e2) --Once per turn, if a face-up Pandemonium Monster(s) in your Main Monster Zone is destroyed by an opponent's card (either by battle or card effect) while you control a card in your Pandemonium zone: You can add 1 Level 4 or lower "Pandemoniumgraph" monster from your Deck to your hand. local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(id,0)) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_DESTROYED) e3:SetRange(LOCATION_SZONE) e3:SetCountLimit(1) e3:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP) e3:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND) e3:SetCondition(cid.condition) e3:SetTarget(cid.target) e3:SetOperation(cid.operation) c:RegisterEffect(e3) end function cid.evalue(e,re,rp) return re:IsActiveType(TYPE_SPELL) and rp~=e:GetHandlerPlayer() end function cid.cfilter(c,tp) return c:GetPreviousTypeOnField()&TYPE_PANDEMONIUM==TYPE_PANDEMONIUM and c:IsPreviousPosition(POS_FACEUP) and c:IsReason(REASON_BATTLE+REASON_EFFECT) and c:GetPreviousControler()==tp and c:IsPreviousLocation(LOCATION_MZONE) and c:GetPreviousSequence()<5 end function cid.condition(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(cid.cfilter,1,nil,tp) and Duel.IsExistingMatchingCard(aux.PaCheckFilter,tp,LOCATION_SZONE,0,1,nil) end function cid.filter(c) return c:IsLevelBelow(4) and c:IsSetCard(0xcf80) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand() and not c:IsCode(id) end function cid.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.filter,tp,LOCATION_DECK,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function cid.operation(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,cid.filter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end