--Esprision Ambush --Scripted by: XGlitchy30 local s,id=GetID() function s.initial_effect(c) --When your opponent activates a Spell/Trap card, or monster effect: Detach all materials from 1 "Esprision" Xyz Monster you control; negate the activation, and if you do, destroy it. local e1=Effect.CreateEffect(c) e1:Desc(0) e1:SetCategory(CATEGORY_NEGATE|CATEGORY_DESTROY) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_CHAINING) e1:HOPT() e1:SetCondition(s.condition) e1:SetCost(s.cost) e1:SetTarget(s.target) e1:SetOperation(s.activate) c:RegisterEffect(e1) --If this card is added from your Deck to your hand, except by drawing it: You can target 1 "Esprision" monster you control; it gains 1600 ATK, until the end of this turn. local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetCategory(CATEGORY_ATKCHANGE) e2:SetType(EFFECT_TYPE_SINGLE|EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY|EFFECT_FLAG_CARD_TARGET) e2:SetCode(EVENT_TO_HAND) e2:HOPT() e2:SetCondition(s.atkcon) e2:SetTarget(s.atktg) e2:SetOperation(s.atkop) c:RegisterEffect(e2) end function s.condition(e,tp,eg,ep,ev,re,r,rp) return rp==1-tp and (re:IsActiveType(TYPE_MONSTER) or re:IsHasType(EFFECT_TYPE_ACTIVATE)) and Duel.IsChainNegatable(ev) end function s.cfilter(c,tp) return c:IsFaceup() and c:IsMonster(TYPE_XYZ) and c:IsSetCard(0xe50) and not c:IsStatus(STATUS_BATTLE_DESTROYED) and c:GetOverlayCount()>0 end function s.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_MZONE,0,1,nil,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVEXYZ) local sg=Duel.SelectMatchingCard(tp,s.cfilter,tp,LOCATION_MZONE,0,1,1,nil,tp) if #sg>0 then local sc=sg:GetFirst() Duel.HintSelection(sg) Duel.SendtoGrave(sc:GetOverlayGroup(),REASON_COST) end end function s.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 re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,0,0) end end function s.activate(e,tp,eg,ep,ev,re,r,rp) if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToChain(ev) then Duel.Destroy(eg,REASON_EFFECT) end end function s.atkcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:GetPreviousLocation()&LOCATION_DECK==LOCATION_DECK and c:GetPreviousControler()==tp and not c:IsReason(REASON_DRAW) end function s.atkfilter(c) return c:IsFaceup() and c:IsSetCard(0xe50,0xe51) end function s.atktg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.atkfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(s.atkfilter,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) local g=Duel.SelectTarget(tp,s.atkfilter,tp,LOCATION_MZONE,0,1,1,nil) local tc=g:GetFirst() Duel.SetCustomOperationInfo(0,CATEGORY_ATKCHANGE,g,#g,tc:GetControler(),tc:GetLocation(),1600) end function s.atkop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc:IsRelateToChain() and tc:IsFaceup() then tc:UpdateATK(1600,RESET_PHASE|PHASE_END,e:GetHandler()) end end