--Automate ID local s,id=GetID() function s.initial_effect(c) --time leap procedure aux.AddOrigTimeleapType(c,false) aux.AddTimeleapProc(c,5,s.sumcon,s.tlfilter,nil) c:EnableReviveLimit() --destroy replace local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_DESTROY_REPLACE) e2:SetRange(LOCATION_MZONE) e2:SetTarget(s.destg) e2:SetValue(s.value) e2:SetOperation(s.desop) e2:SetCountLimit(1,id) c:RegisterEffect(e2) --negate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_DECKDES) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetCondition(s.negcon) e1:SetTarget(s.destg) e1:SetOperation(s.negop) e1:SetCountLimit(1,id+1000) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_MATERIAL_CHECK) e2:SetValue(s.valcheck) e2:SetLabelObject(e1) c:RegisterEffect(e2) --set local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_LEAVE_GRAVE) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_MZONE) e1:SetTarget(s.settg) e1:SetOperation(s.setop) e1:SetCountLimit(1,id+2000) c:RegisterEffect(e1) end function s.sumcon(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetMatchingGroup(Card.IsSetCard,tp,LOCATION_GRAVE,0,nil,0x301) return g:GetClassCount(Card.GetCode,nil)>=3 end function s.tlfilter(c,e,mg) return c:IsSetCard(0x301) and c:GetLevel()==e:GetHandler():GetFuture()-1 end function s.dfilter(c,tp) return c:IsFaceup() and c:IsSetCard(0x301) and not c:IsReason(REASON_REPLACE) and c:IsControler(tp) end function s.destg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return not eg:IsContains(e:GetHandler()) and eg:IsExists(s.dfilter,1,nil,tp) and e:GetHandler():GetAttack()>=500 end return Duel.SelectEffectYesNo(tp,e:GetHandler(),96) end function s.value(e,c) return c:IsFaceup() and c:IsSetCard(0x301) and not c:IsReason(REASON_REPLACE) and c:IsControler(e:GetHandlerPlayer()) end function s.desop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetReset(RESET_EVENT+RESETS_STANDARD) e1:SetValue(-500) c:RegisterEffect(e1) end function s.valcheck(e,c) local g=c:GetMaterial() if g:IsExists(Card.IsCode,1,nil,130010006) then e:GetLabelObject():SetLabel(1) else e:GetLabelObject():SetLabel(0) end end function s.negcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsSummonType(SUMMON_TYPE_TIMELEAP) and e:GetLabel()==1 end function s.destg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsPlayerCanDraw(tp,1) and Duel.IsPlayerCanDiscardDeck(tp,2) and Duel.GetFieldGroupCount(tp,LOCATION_DECK,0)>=3 end Duel.SetTargetPlayer(tp) Duel.SetTargetParam(1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) Duel.SetOperationInfo(0,CATEGORY_DECKDES,nil,0,tp,2) end function s.negop(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) Duel.Draw(p,d,REASON_EFFECT) Duel.BreakEffect() Duel.DiscardDeck(tp,2,REASON_EFFECT) end function s.setfilter(c) return --[[c:IsSetCard(0x301) and]] c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsSSetable() end function s.settg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and s.setfilter(chkc) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0 and Duel.IsExistingMatchingCard(Card.IsDiscardable,tp,LOCATION_HAND,0,1,nil,REASON_EFFECT) and Duel.IsExistingMatchingCard(s.setfilter,tp,LOCATION_GRAVE,0,1,nil) end local g=Duel.GetMatchingGroup(s.setfilter,tp,LOCATION_GRAVE,0,nil) Duel.SetOperationInfo(0,CATEGORY_LEAVE_GRAVE,g,1,0,0) local g=Duel.GetMatchingGroup(Card.IsDiscardable,tp,LOCATION_HAND,0,nil,REASON_EFFECT) Duel.SetOperationInfo(0,CATEGORY_HANDES,g,1,0,0) end function s.setop(e,tp,eg,ep,ev,re,r,rp) if Duel.DiscardHand(tp,Card.IsDiscardable,1,1,REASON_EFFECT+REASON_DISCARD)>0 then local g=Duel.SelectMatchingCard(tp,s.setfilter,tp,LOCATION_GRAVE,0,1,1,nil) if #g==0 then return end local tc=g:GetFirst() Duel.BreakEffect() Duel.SSet(tp,tc) Duel.ConfirmCards(1-tp,tc) end end