--Master of Chains local s,id=GetID() function s.initial_effect(c) aux.AddOrigTimeleapType(c,false) aux.AddTimeleapProc(c,5,aux.FALSE,aux.FALSE) c:EnableReviveLimit() --You can only Special Summon "Master of Chains(s)" once per turn. c:SetSPSummonOnce(id) --If a chain of 5 or more Links occured this turn, this card's Time Leap Summon is treated as an addtional Time Leap Summon. local e0=Effect.CreateEffect(c) e0:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e0:SetCode(EVENT_CHAINING) e0:SetRange(LOCATION_EXTRA) e0:SetOperation(s.chop) c:RegisterEffect(e0) 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.sumcon) e1:SetTarget(s.sumtg) e1:SetOperation(s.sumop) e1:SetValue(SUMMON_TYPE_TIMELEAP) c:RegisterEffect(e1) --Activate only once per chain as a Chain Link 3 or higher (Quick Effect): apply the following effects, depending on the Chain Link number of this card, in sequence. --● 3+: This card gains 200 ATK/DEF. --● 4+: Destroy 1 card your opponent controls. --● 5+: Draw 1 card. local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_FREE_CHAIN) e2:SetRange(LOCATION_MZONE) e2:SetCountLimit(1,EFFECT_COUNT_CODE_CHAIN) e2:SetCondition(s.actcon) e2:SetTarget(s.acttg) e2:SetOperation(s.actop) c:RegisterEffect(e2) end function s.chop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local chain=Duel.GetCurrentChain() if chain>c:GetFlagEffect(id) then c:ResetFlagEffect(id) for i=1, chain do c:RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END,0,1) end end end function s.sumcon(e) local c=e:GetHandler() local tp=c:GetControler() return c:GetFlagEffect(id)>=3 and Duel.IsExistingMatchingCard(s.tlfilter,tp,LOCATION_MZONE,0,1,nil,e,tp) and (s.checkatls(c,e,tp) or c:GetFlagEffect(id)>=5) end function s.tlfilter(c,e,tp) return c:IsFaceup() and c:IsLevel(4) and not c:IsType(TYPE_TOKEN) and c:IsAbleToRemove(tp,POS_FACEUP,REASON_MATERIAL+REASON_TIMELEAP) and c:IsCanBeTimeleapMaterial() end function s.sumtg(e,tp,eg,ep,ev,re,r,rp,chk,c) if e:GetHandler():GetFlagEffect(id)<5 then s.performatls(tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,s.tlfilter,tp,LOCATION_MZONE,0,0,1,nil,e,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 g=e:GetLabelObject() if not g then return end c:SetMaterial(g) Duel.Remove(g,POS_FACEUP,REASON_MATERIAL+REASON_TIMELEAP) if e:GetHandler():GetFlagEffect(id)<5 then aux.TimeleapHOPT(tp) end end function s.actcon(e,tp,eg,ep,ev,re,r,rp) return Duel.GetCurrentChain()>=2 end function s.acttg(e,tp,eg,ep,ev,re,r,rp,chk) local cl=Duel.GetCurrentChain() if chk==0 then return (cl<4 or Duel.IsExistingMatchingCard(aux.TRUE,tp,0,LOCATION_ONFIELD,1,nil)) and (cl<5 or Duel.IsPlayerCanDraw(tp,1)) end local cat=0 if cl>=3 then cat=cat|CATEGORY_ATKCHANGE cat=cat|CATEGORY_DEFCHANGE end if cl>=4 then cat=cat|CATEGORY_DESTROY g=Duel.GetMatchingGroup(aux.TRUE,tp,0,LOCATION_ONFIELD,nil) Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0) end if cl>=5 then cat=cat|CATEGORY_DRAW Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,1) end e:SetCategory(cat) end function s.actop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local cl=Duel.GetCurrentChain() if cl>=3 then if c:IsFaceup() and c:IsRelateToEffect(e) then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetProperty(EFFECT_FLAG_COPY_INHERIT) e1:SetValue(200) e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_DISABLE) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EFFECT_UPDATE_DEFENSE) c:RegisterEffect(e2) end end if cl>=4 then Duel.BreakEffect() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY) local g=Duel.SelectMatchingCard(tp,aux.TRUE,tp,0,LOCATION_ONFIELD,1,1,nil) if g:GetCount()>0 then Duel.HintSelection(g) Duel.Destroy(g,REASON_EFFECT) end end if cl>=5 then Duel.BreakEffect() Duel.Draw(tp,1,REASON_EFFECT) end 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