--created by Swag, coded by Lyris local s,id=GetID() function s.initial_effect(c) c:EnableReviveLimit() aux.AddOrigTimeleapType(c) aux.AddTimeleapProc(c,9,s.sumcon,aux.FilterBoolFunction(Card.IsSetCard,0xd78),{s.sumop,Card.IsAbleToGrave}) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_SPSUMMON_PROC) e1:SetProperty(EFFECT_FLAG_UNCOPYABLE) e1:SetRange(LOCATION_EXTRA) e1:SetCondition(s.hspcon) e1:SetOperation(s.hspop) e1:SetValue(SUMMON_TYPE_TIMELEAP) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET) e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e2:SetRange(LOCATION_MZONE) e2:SetValue(1) c:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_IGNITION) e3:SetCode(EVENT_SPSUMMON_SUCCESS) e3:SetCountLimit(1,id) e3:SetCategory(CATEGORY_SEARCH+CATEGORY_TOHAND+CATEGORY_DECKDES) e3:SetCondition(function(e) return e:GetHandler():IsSummonType(SUMMON_TYPE_TIMELEAP) end) e3:SetTarget(s.tg) e3:SetOperation(s.op) c:RegisterEffect(e3) local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_QUICK_O) e4:SetCode(EVENT_CHAINING) e4:SetRange(LOCATION_MZONE) e4:SetCountLimit(1,id+100) e4:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL) e4:SetCategory(CATEGORY_DECKDES+CATEGORY_NEGATE) e4:SetCondition(s.condition) e4:SetTarget(s.target) e4:SetOperation(s.operation) c:RegisterEffect(e4) end function s.mfilter(c) return c:IsLevelAbove(5) and c:IsRace(RACE_ZOMBIE) and c:IsType(TYPE_MONSTER) end function s.sumcon(e,c) if c==nil then return true end return Duel.IsExistingMatchingCard(s.mfilter,c:GetControler(),LOCATION_GRAVE,0,3,nil) end function s.sumop(e,tp,eg,ep,ev,re,r,rp,c,g) Duel.SendtoGrave(g,REASON_MATERIAL+REASON_TIMELEAP) end function s.hspfilter(c,tp) return c:IsFuture(8) and c:IsSetCard(0xd78) and c:IsType(TYPE_TIMELEAP) and c:IsAbleToGraveAsCost() and Duel.GetLocationCountFromEx(tp,tp,c,TYPE_TIMELEAP)>0 end function s.hspcon(e,c) if c==nil then return true end local tp=c:GetControler() return s.sumcon(e,c) and Duel.IsExistingMatchingCard(s.hspfilter,tp,LOCATION_MZONE,0,1,nil,tp) and Duel.GetFlagEffect(tp,828)<=0 end function s.hspop(e,tp,eg,ep,ev,re,r,rp,c) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,s.hspfilter,tp,LOCATION_MZONE,0,1,1,nil,tp) c:SetMaterial(g) s.sumop(e,tp,eg,ep,ev,re,r,rp,c,g) end function s.tg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDiscardDeck(tp,1) and Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)>9 end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,0,tp,LOCATION_DECK) end function s.filter(c) return c:IsRace(RACE_ZOMBIE) and c:IsType(TYPE_MONSTER) end function s.thfilter(c) return c:IsSetCard(0xd78) and c:IsAbleToHand() end function s.op(e,tp,eg,ep,ev,re,r,rp) if not Duel.IsPlayerCanDiscardDeck(tp,1) then return end local g=Duel.GetDecktopGroup(tp,10) Duel.ConfirmCards(tp,g) local tg=g:Filter(aux.AND(Card.IsAbleToGrave,Card.IsRace),nil,RACE_ZOMBIE) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local sg=g:FilterSelect(tp,s.thfilter,1,1,nil):GetFirst() if sg then Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,sg) Duel.ShuffleHand(tp) if tg:IsContains(sg) then tg:Sub(sg) end end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local gg=tg:Select(tp,1,2,nil) if Duel.SendtoGrave(gg,REASON_EFFECT)>0 and not gg:IsExists(aux.NOT(Card.IsLocation),1,nil,LOCATION_GRAVE) then Duel.BreakEffect() end Duel.ShuffleDeck(tp) end function s.condition(e,tp,eg,ep,ev,re,r,rp) return ep~=tp and re:IsHasType(EFFECT_TYPE_ACTIVATE) and Duel.IsChainNegatable(ev) and not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) 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) end function s.cfilter(c) return c:IsLocation(LOCATION_GRAVE) and c:IsSetCard(0xd78) and c:IsType(TYPE_MONSTER) and c:IsLevelAbove(5) end function s.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if Duel.GetCurrentChain()~=ev+1 or c:IsStatus(STATUS_BATTLE_DESTROYED) then return end Duel.DiscardDeck(tp,3,REASON_EFFECT) local ct=Duel.GetOperatedGroup():FilterCount(s.cfilter,nil) if ct>0 then Duel.NegateActivation(ev) end end