--created by ZEN, coded by TaxingCorn117 local s,id=GetID() function s.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(math.floor(id/100),0)) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_PHASE+PHASE_END) e2:SetRange(LOCATION_SZONE) e2:SetCountLimit(1) e2:SetCondition(s.lpcon) e2:SetTarget(s.lptg) e2:SetOperation(s.lpop) c:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(math.floor(id/100),0)) e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e3:SetCode(EVENT_DAMAGE) e3:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY) e3:SetRange(LOCATION_GRAVE) e3:SetCountLimit(1,id) e3:SetCondition(s.actcon) e3:SetCost(aux.bfgcost) e3:SetTarget(s.acttg) e3:SetOperation(s.actop) c:RegisterEffect(e3) if s.counter==nil then s.counter=true s[0]=0 s[1]=0 local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e2:SetCode(EVENT_PHASE_START+PHASE_DRAW) e2:SetOperation(s.resetcount) Duel.RegisterEffect(e2,0) local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD) e3:SetCode(EVENT_TOSS_DICE_NEGATE) e3:SetOperation(s.addcount) Duel.RegisterEffect(e3,0) end end function s.resetcount(e,tp,eg,ep,ev,re,r,rp) s[0]=0 s[1]=0 end function s.addcount(e,tp,eg,ep,ev,re,r,rp) local cc=Duel.GetCurrentChain() local ci=Duel.GetChainInfo(cc,CHAININFO_CHAIN_ID) if s[2]~=ci then local dc={Duel.GetDiceResult()} for _,ct in ipairs(dc) do s[ep]=s[ep]+ct end Duel.SetDiceResult(table.unpack(dc)) s[2]=ci end end function s.lpcon(e,tp,eg,ep,ev,re,r,rp) return s[tp]>0 end function s.lptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end Duel.Hint(HINT_CARD,0,id) end function s.lpop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if not c:IsRelateToEffect(e) then return end local ap=Duel.Recover(tp,s[tp]*50,REASON_EFFECT) local ct=c:GetFlagEffectLabel(id) if not ct then c:RegisterFlagEffect(id,RESET_PHASE+PHASE_END,0,1,ap) else c:SetFlagEffectLabel(id,ct+ap) end if c:GetFlagEffectLabel(id)<1000 then return end Duel.BreakEffect() Duel.Draw(tp,1,REASON_EFFECT) end function s.actcon(e,tp,eg,ep,ev,re,r,rp) return ep==tp and bit.band(r,REASON_BATTLE+REASON_EFFECT)~=0 end function s.actfilter(c,tp) return c:IsCode(id) and c:GetActivateEffect():IsActivatable(tp) end function s.acttg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.actfilter,tp,LOCATION_DECK,0,1,nil,tp) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function s.actop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(math.floor(id/100),3)) local g=Duel.SelectMatchingCard(tp,s.actfilter,tp,LOCATION_DECK,0,1,1,nil,tp) local tc=g:GetFirst() if tc then Duel.MoveToField(tc,tp,tp,LOCATION_SZONE,POS_FACEUP,true) local te=tc:GetActivateEffect() local tep=tc:GetControler() local cost=te:GetCost() if cost then cost(te,tep,eg,ep,ev,re,r,rp,1) end end end