--Dorein Appuntamento --Scripted by: XGlitchy30 local s,id=GetID() function s.initial_effect(c) --Activate local e0=Effect.CreateEffect(c) e0:SetDescription(aux.Stringid(id,0)) e0:SetType(EFFECT_TYPE_ACTIVATE) e0:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e0) --Protect local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_INDESTRUCTABLE_COUNT) e1:SetRange(LOCATION_SZONE) e1:SetTargetRange(LOCATION_MZONE,0) e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0xd04)) e1:SetCondition(s.damchk(1000)) e1:SetValue(s.indct) c:RegisterEffect(e1) --Shuffle local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetCategory(CATEGORY_TODECK+CATEGORY_DRAW) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_FREE_CHAIN) e2:SetRange(LOCATION_SZONE) e2:SetCountLimit(1) e2:SetCondition(s.damchk(2000)) e2:SetTarget(s.target) e2:SetOperation(s.activate) c:RegisterEffect(e2) --SS local e3=Effect.CreateEffect(c) e3:SetDescription(aux.Stringid(id,2)) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetType(EFFECT_TYPE_QUICK_O) e3:SetCode(EVENT_FREE_CHAIN) e3:SetRange(LOCATION_SZONE) e3:SetCountLimit(1,id) e3:SetCondition(s.damchk(3000)) e3:SetTarget(s.sptg) e3:SetOperation(s.spop) c:RegisterEffect(e3) --Inflict Damage local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e4:SetCode(EVENT_CHAINING) e4:SetRange(LOCATION_SZONE) e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e4:SetOperation(s.regop) c:RegisterEffect(e4) local e5=Effect.CreateEffect(c) e5:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e5:SetCode(EVENT_CHAIN_SOLVED) e5:SetRange(LOCATION_SZONE) e5:SetCondition(s.damcon) e5:SetOperation(s.damop) c:RegisterEffect(e5) --count damage if not s.global_check then s.global_check=true s[0]=0 s[1]=0 local ge1=Effect.CreateEffect(c) ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) ge1:SetCode(EVENT_DAMAGE) ge1:SetOperation(s.checkop) Duel.RegisterEffect(ge1,0) end end function s.checkop(e,tp,eg,ep,ev,re,r,rp) if bit.band(r,REASON_EFFECT)~=0 and rp==1-ep then s[rp]=s[rp]+ev end end function s.damchk(val) return function(e,tp,eg,ep,ev,re,r,rp) if not tp then tp=e:GetHandlerPlayer() end return s[tp]>=val end end function s.indct(e,re,r,rp) if r&(REASON_BATTLE+REASON_EFFECT)>0 then return 1 else return 0 end end function s.filter(c) return c:IsSetCard(0xd04) and c:IsAbleToDeck() and c:NotBanishedOrFaceup() end function s.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_GRAVE+LOCATION_REMOVED,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TODECK,nil,1,tp,LOCATION_GRAVE+LOCATION_REMOVED) end function s.activate(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local g=Duel.GetMatchingGroup(aux.NecroValleyFilter(s.filter),tp,LOCATION_GRAVE+LOCATION_REMOVED,0,nil) if #g<1 then return end local max=Duel.IsPlayerCanDraw(tp,2) and 4 or Duel.IsPlayerCanDraw(tp,1) and 3 or 1 Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK) local dg=g:Select(tp,1,max,nil) if #dg>0 then Duel.HintSelection(dg) if Duel.SendtoDeck(dg,nil,2,REASON_EFFECT)>0 then local check=dg:FilterCount(aux.PLChk,nil,nil,LOCATION_DECK+LOCATION_EXTRA) if check<=0 then return end aux.AfterShuffle(dg) if check>1 then Duel.BreakEffect() Duel.Draw(tp,math.floor(check/2),REASON_EFFECT) end end end end function s.spfilter(c,e,tp) return c:IsSetCard(0xd04) and c:IsType(TYPE_MONSTER) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_HAND+LOCATION_DECK,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND+LOCATION_DECK) end function s.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end local c=e:GetHandler() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,s.spfilter,tp,LOCATION_HAND+LOCATION_DECK,0,1,1,nil,e,tp) if #g>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end function s.regop(e,tp,eg,ep,ev,re,r,rp) if rp~=tp and re:IsActiveType(TYPE_MONSTER) then e:GetHandler():RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD-RESET_TURN_SET+RESET_CHAIN,0,1) end end function s.damcon(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return ep~=tp and c:GetFlagEffect(id)~=0 end function s.damop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_CARD,0,id) Duel.Damage(1-tp,200,REASON_EFFECT) end