--Pandemoniumgraph Berserker local cid,id=GetID() function cid.initial_effect(c) aux.AddOrigPandemoniumType(c) --Negate local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_CHAINING) e1:SetRange(LOCATION_SZONE) e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e1:SetCondition(cid.condition) e1:SetTarget(cid.target) e1:SetOperation(cid.operation) c:RegisterEffect(e1) aux.EnablePandemoniumAttribute(c,e1) --set local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_DAMAGE_STEP) e2:SetCode(EVENT_DESTROYED) e2:SetCountLimit(1,id) e2:SetTarget(cid.settg) e2:SetOperation(cid.setop) c:RegisterEffect(e2) end function cid.setfilter(c) return c:IsSetCard(0xcf80) and c:IsPandemoniumSSetable() and not c:IsCode(id) end function cid.settg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.IsExistingMatchingCard(cid.setfilter,tp,LOCATION_DECK,0,1,nil) end end function cid.setop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SET) local g=Duel.SelectMatchingCard(tp,cid.setfilter,tp,LOCATION_DECK,0,1,1,nil) if g:GetCount()>0 then Duel.PandSSet(g,e,tp,REASON_EFFECT) end end function cid.filter(c,tp) return c:IsControler(tp) and c:IsType(TYPE_MONSTER) and c:IsFaceup() and c:IsSetCard(0xcf80) end function cid.condition(e,tp,eg,ep,ev,re,r,rp) if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then return false end local g=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS) return aux.PandActCheck(e) and g and g:IsExists(cid.filter,1,nil,tp) and Duel.IsChainNegatable(ev) end function cid.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0) if e:GetHandler():IsDestructable(e) and e:GetHandler():IsRelateToEffect(e) then Duel.SetOperationInfo(0,CATEGORY_DESTROY,e:GetHandler(),1,0,0) end end function cid.operation(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end if Duel.NegateActivation(ev) then if re:IsHasType(EFFECT_TYPE_ACTIVATE) and re:GetHandler():IsRelateToEffect(re) then Duel.SendtoGrave(eg,REASON_EFFECT) end Duel.BreakEffect() Duel.Destroy(e:GetHandler(),REASON_EFFECT) end end