--Deltaingranaggi Omega --Scripted by: XGlitchy30 local s,id = GetID() function s.initial_effect(c) c:EnableReviveLimit() aux.AddFusionProcFunRep(c,aux.FilterBoolFunction(Card.IsFusionSetCard,0xfa6),3,true) aux.AddContactFusionProcedure(c,s.matfilter,LOCATION_MZONE,LOCATION_MZONE,aux.tdcfop(c)) --spsummon condition local e0=Effect.CreateEffect(c) e0:SetType(EFFECT_TYPE_SINGLE) e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e0:SetCode(EFFECT_SPSUMMON_CONDITION) e0:SetValue(s.splimit) c:RegisterEffect(e0) --protection c:EffectProtection() --search local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetProperty(EFFECT_FLAG_DELAY) e1:HOPT() e1:SetTarget(aux.SearchTarget(s.thfilter)) e1:SetOperation(s.thop) c:RegisterEffect(e1) --negate c:CreateNegateEffect(true,1,nil,1,nil,true,s.discon,aux.TributeSelfCost,nil,nil) --spsummon back c:TributedTrigger(true,nil,nil,EFFECT_FLAG_CANNOT_DISABLE,nil,s.regcon,nil,nil,s.regop,0) c:PhaseTrigger(false,PHASE_END,2,CATEGORY_SPECIAL_SUMMON,nil,LOCATION_GRAVE,true,s.spcon,nil,aux.SSSelfTarget(),aux.SSSelfOperation()) --If this card is destroyed: Add 1 Deltagears Spell/Trap from your GY to your hand. local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_TOHAND) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e2:SetCode(EVENT_DESTROYED) e2:HOPT() e2:SetTarget(s.thtg2) e2:SetOperation(s.thop2) c:RegisterEffect(e2) end function s.matfilter(c,fc) local tp=fc:GetControler() return c:IsAbleToDeckOrExtraAsCost() and (c:IsControler(tp) or c:IsFaceup()) end function s.splimit(e,se,sp,st) return e:GetHandler():GetLocation()~=LOCATION_EXTRA end function s.thfilter(c) return c:IsST() and c:IsSetCard(0xfa6) and c:IsAbleToHand() end function s.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,s.thfilter,tp,LOCATION_DECK,0,1,1,nil) local tc=g:GetFirst() if not tc then return end Duel.SendtoHand(tc,nil,REASON_EFFECT) end function s.discon(e,tp,eg,ep,ev,re,r,rp) local ex4=re:IsHasCategory(CATEGORY_DRAW) local ex5=re:IsHasCategory(CATEGORY_SEARCH) return (ex4 or ex5) and Duel.IsChainDisablable(ev) end function s.regcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return c:IsReason(REASON_COST) and re and re:GetOwner()==c and re:IsActivated() end function s.regop(e,tp,eg,ep,ev,re,r,rp) e:GetHandler():RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END,0,1) end function s.spcon(e,tp) return e:GetHandler():HasFlagEffect(id) end function s.thtg2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_GRAVE,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_GRAVE) end function s.thop2(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.thfilter),tp,LOCATION_GRAVE,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) end end