--Mist Valley Thunder Avian local s,id=GetID() function s.initial_effect(c) aux.AddOrigTimeleapType(c,false) aux.AddTimeleapProc(c,8,aux.FALSE,aux.FALSE) c:EnableReviveLimit() --Time Leap Summon local e0=Effect.CreateEffect(c) e0:SetType(EFFECT_TYPE_FIELD) e0:SetCode(EFFECT_SPSUMMON_PROC) e0:SetProperty(EFFECT_FLAG_UNCOPYABLE) e0:SetRange(LOCATION_EXTRA) e0:SetCondition(s.sumcon) e0:SetTarget(s.sumtg) e0:SetOperation(s.sumop) e0:SetValue(SUMMON_TYPE_TIMELEAP) c:RegisterEffect(e0) --During the Main Phase (Quick Effect): You can target 1 WIND monster you control and 1 card your opponent controls; return them to the hand. local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND) e1:SetType(EFFECT_TYPE_QUICK_O) e1:SetCode(EVENT_FREE_CHAIN) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetRange(LOCATION_MZONE) e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_MAIN_END) e1:SetCountLimit(1,{id,0}) e1:SetCondition(s.thcon) e1:SetTarget(s.thtg) e1:SetOperation(s.thop) c:RegisterEffect(e1) aux.GlobalCheck(s,function() local ge1=Effect.CreateEffect(c) ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) ge1:SetCode(EVENT_TO_HAND) ge1:SetLabel(id) ge1:SetCondition(s.regcon) ge1:SetOperation(s.regop) Duel.RegisterEffect(ge1,0) end) end function s.sumcon(e) local c=e:GetHandler() local tp=c:GetControler() return Duel.GetFlagEffect(0,id)>0 and Duel.IsExistingMatchingCard(s.tlfilter,tp,LOCATION_MZONE,0,1,nil,e,tp) and s.checkatls(c,e,tp) end function s.tlfilter(c,e,tp) return c:IsAttribute(ATTRIBUTE_WIND) and c:IsLevel(7) and c:IsAbleToHand() and c:IsFaceup() end function s.sumtg(e,tp,eg,ep,ev,re,r,rp,chk,c) s.performatls(tp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND) local g=Duel.SelectMatchingCard(tp,s.tlfilter,tp,LOCATION_MZONE,0,0,1,true,nil,tp) if #g==0 then return false end if #g>0 then g:KeepAlive() e:SetLabelObject(g) return true end end function s.sumop(e,tp,eg,ep,ev,re,r,rp,c) local c=e:GetHandler() local g=e:GetLabelObject() if not g then return end c:SetMaterial(g) --The monster used as material for this card's Time Leap Summon is returned to the hand instead of being banished. Duel.SendtoHand(g,nil,REASON_MATERIAL+REASON_TIMELEAP) aux.TimeleapHOPT(tp) end function s.thcon(e,tp,eg,ep,ev,re,r,rp) local ph=Duel.GetCurrentPhase() return ph==PHASE_MAIN1 or ph==PHASE_MAIN2 end function s.thfilter(c) return c:IsAttribute(ATTRIBUTE_WIND) and c:IsAbleToHand() end function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return false end if chk==0 then return Duel.IsExistingTarget(s.thfilter,tp,LOCATION_MZONE,0,1,nil) and Duel.IsExistingTarget(Card.IsAbleToHand,tp,0,LOCATION_ONFIELD,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND) local g1=Duel.SelectTarget(tp,s.thfilter,tp,LOCATION_MZONE,0,1,1,nil) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND) local g2=Duel.SelectTarget(tp,Card.IsAbleToHand,tp,0,LOCATION_ONFIELD,1,1,nil) g1:Merge(g2) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g1,2,0,0) end function s.thop(e,tp,eg,ep,ev,re,r,rp) local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS):Filter(Card.IsRelateToEffect,nil,e) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) end end function s.regcon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(Card.IsPreviousLocation,1,nil,LOCATION_ONFIELD) end function s.regop(e,tp,eg,ep,ev,re,r,rp) Duel.RegisterFlagEffect(tp,id,RESET_PHASE+PHASE_END,0,1) Duel.RegisterFlagEffect(1-tp,id,RESET_PHASE+PHASE_END,0,1) end --STUFF TO MAKE IT WORK WITH EFFECT_EXTRA_TIMELEAP_SUMMON function s.checkatls(c,e,tp) if c==nil then return true end if (c:IsType(TYPE_PENDULUM) or c:IsType(TYPE_PANDEMONIUM)) and c:IsFaceup() then return false end local eset={Duel.IsPlayerAffectedByEffect(tp,EFFECT_EXTRA_TIMELEAP_SUMMON)} local exsumcheck=false for _,te in ipairs(eset) do if not te:GetValue() or type(te:GetValue())=="number" or te:GetValue()(e,c) then exsumcheck=true end end eset={Duel.IsPlayerAffectedByEffect(tp,EFFECT_IGNORE_TIMELEAP_HOPT)} local ignsumcheck=false for _,te in ipairs(eset) do if te:CheckCountLimit(tp) then ignsumcheck=true break end end return (Duel.GetFlagEffect(tp,828)<=0 or (exsumcheck and Duel.GetFlagEffect(tp,830)<=0) or c:IsHasEffect(EFFECT_IGNORE_TIMELEAP_HOPT) or ignsumcheck) end function s.performatls(tp) local eset={Duel.IsPlayerAffectedByEffect(tp,EFFECT_EXTRA_TIMELEAP_SUMMON)} local igneset={Duel.IsPlayerAffectedByEffect(tp,EFFECT_IGNORE_TIMELEAP_HOPT)} local exsumeff,ignsumeff local options={} if (#eset>0 and Duel.GetFlagEffect(tp,830)<=0) or #igneset>0 then local cond=1 if Duel.GetFlagEffect(tp,828)<=0 then table.insert(options,aux.Stringid(433005,15)) cond=0 end for _,te in ipairs(eset) do table.insert(options,te:GetDescription()) end for _,te in ipairs(igneset) do if te:CheckCountLimit(tp) then table.insert(options,te:GetDescription()) end end local op=Duel.SelectOption(tp,table.unpack(options))+cond if op>0 then if op<=#eset then exsumeff=eset[op] else ignsumeff=igneset[op-#eset] end end end if exsumeff~=nil then Duel.RegisterFlagEffect(tp,829,RESET_PHASE+PHASE_END,0,1) Duel.Hint(HINT_CARD,0,exsumeff:GetHandler():GetOriginalCode()) elseif ignsumeff~=nil then Duel.Hint(HINT_CARD,0,ignsumeff:GetHandler():GetOriginalCode()) ignsumeff:UseCountLimit(tp) end end