--Carnevale Dorein Sotto il Chiaro di Luna --Scripted by: XGlitchy30 local s,id=GetID() function s.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCost(s.cost) e1:SetOperation(s.activate) e1:SetLabel(0) c:RegisterEffect(e1) --pierce local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,2)) e2:SetType(EFFECT_TYPE_FIELD) e2:SetProperty(EFFECT_FLAG_CLIENT_HINT) e2:SetCode(EFFECT_PIERCE) e2:SetRange(LOCATION_FZONE) e2:SetTargetRange(LOCATION_MZONE,0) e2:SetCondition(s.damchk(1000)) e2:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0xd04)) c:RegisterEffect(e2) --boost local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetCode(EFFECT_UPDATE_ATTACK) e3:SetRange(LOCATION_FZONE) e3:SetTargetRange(LOCATION_MZONE,0) e3:SetCondition(s.damchk(2000)) e3:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0xd04)) e3:SetValue(500) c:RegisterEffect(e3) --pierce local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(id,3)) e4:SetType(EFFECT_TYPE_FIELD) e4:SetProperty(EFFECT_FLAG_CLIENT_HINT) e4:SetCode(EFFECT_GLITCHY_CANNOT_DISABLE) e4:SetRange(LOCATION_FZONE) e4:SetTargetRange(0xff,0xff) e4:SetCondition(s.damchk(3000)) e4:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0xd04)) e4:SetValue(s.value) c:RegisterEffect(e4) --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.filter(c,e,tp) return c:IsSetCard(0xd04) and c:IsType(TYPE_MONSTER) and c:IsLevelBelow(4) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function s.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return true end if Duel.GetMZoneCount(tp)>0 and Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,nil,e,tp) and Duel.IsExistingMatchingCard(Card.IsDiscardable,tp,LOCATION_HAND,0,1,nil) and Duel.SelectYesNo(tp,aux.Stringid(id,1)) then Duel.DiscardHand(tp,Card.IsDiscardable,1,1,REASON_COST+REASON_DISCARD) e:SetLabel(1) else e:SetLabel(0) end end function s.activate(e,tp,eg,ep,ev,re,r,rp) if e:GetLabel()~=1 or Duel.GetMZoneCount(tp)<=0 or not e:GetHandler():IsRelateToEffect(e) then return end local g=Duel.GetMatchingGroup(aux.NecroValleyFilter(s.filter),tp,LOCATION_DECK+LOCATION_GRAVE,0,nil,e,tp) if #g>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg=g:Select(tp,1,1,nil) if #sg>0 then Duel.SpecialSummon(sg,0,tp,tp,false,false,POS_FACEUP) end end end function s.value(e,re) return re:GetOwnerPlayer()~=e:GetHandlerPlayer() end