--Corona di Zaffiro Spektrale --Scripted by: XGlitchy30 local s,id = GetID() function s.initial_effect(c) --cannot link material local e0=Effect.CreateEffect(c) e0:SetType(EFFECT_TYPE_SINGLE) e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e0:SetCode(EFFECT_CANNOT_BE_LINK_MATERIAL) e0:SetValue(1) c:RegisterEffect(e0) --If normal summoned, special summon "Valkyrie" monster local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_HAND) e1:SetCountLimit(1,id) e1:SetCost(s.spcost) e1:SetTarget(s.sptg) e1:SetOperation(s.spop) c:RegisterEffect(e1) --lvchange local e4=Effect.CreateEffect(c) e4:SetDescription(aux.Stringid(id,3)) e4:SetType(EFFECT_TYPE_IGNITION) e4:SetRange(LOCATION_GRAVE) e4:SetCountLimit(1,id+100) e4:SetCost(s.lvcost) e4:SetTarget(s.lvtg) e4:SetOperation(s.lvop) c:RegisterEffect(e4) if not s.global_check then s.global_check=true local g1=Effect.CreateEffect(c) g1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) g1:SetCode(EVENT_SUMMON_SUCCESS) g1:SetOperation(s.regop) Duel.RegisterEffect(g1,0) local g2=g1:Clone() g2:SetCode(EVENT_SPSUMMON_SUCCESS) Duel.RegisterEffect(g2,0) local g3=g1:Clone() g3:SetCode(EVENT_FLIP_SUMMON_SUCCESS) Duel.RegisterEffect(g3,0) end end function s.regop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetOwner() for p=0,1 do if eg:IsExists(s.counterfilter,1,c,p) then Duel.RegisterFlagEffect(p,id,RESET_PHASE+PHASE_END,0,1) end end end function s.counterfilter(c,p) return not c:IsAttribute(ATTRIBUTE_DARK) and c:GetSummonPlayer()==p end function s.sharedcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetFlagEffect(tp,id)<=0 end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_OATH) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetReset(RESET_PHASE+PHASE_END) e1:SetTargetRange(1,0) e1:SetTarget(s.sumlimit) Duel.RegisterEffect(e1,tp) local e2=e1:Clone() e2:SetCode(EFFECT_CANNOT_SUMMON) Duel.RegisterEffect(e2,tp) local e3=e1:Clone() e3:SetCode(EFFECT_CANNOT_FLIP_SUMMON) Duel.RegisterEffect(e3,tp) local e4=Effect.CreateEffect(e:GetHandler()) e4:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_CLIENT_HINT+EFFECT_FLAG_OATH) e4:SetDescription(aux.Stringid(id,4)) e4:SetReset(RESET_PHASE+PHASE_END) e4:SetTargetRange(1,0) Duel.RegisterEffect(e4,tp) end function s.sumlimit(e,c,sump,sumtype,sumpos,targetp,se) return not c:IsAttribute(ATTRIBUTE_DARK) end function s.spfilter(c,e,tp) return c:IsLevel(2) and c:IsAttribute(ATTRIBUTE_DARK) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and not c:IsCode(id) and c~=e:GetHandler() end function s.spcost(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return s.sharedcost(e,tp,eg,ep,ev,re,r,rp,0) and c:IsDiscardable() end Duel.SendtoGrave(c,REASON_COST+REASON_DISCARD) s.sharedcost(e,tp,eg,ep,ev,re,r,rp,1) end function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return not Duel.IsPlayerAffectedByEffect(tp,CARD_BLUEEYES_SPIRIT) and Duel.GetLocationCount(tp,LOCATION_MZONE)>1 and Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_HAND+LOCATION_GRAVE,0,2,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,2,tp,LOCATION_HAND+LOCATION_GRAVE) end function s.spop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if Duel.IsPlayerAffectedByEffect(tp,CARD_BLUEEYES_SPIRIT) then return end if Duel.GetLocationCount(tp,LOCATION_MZONE)<2 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g1=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.spfilter),tp,LOCATION_GRAVE+LOCATION_HAND,0,2,2,nil,e,tp) if #g1>0 and Duel.SpecialSummon(g1,0,tp,tp,false,false,POS_FACEUP)==2 then local og=g1:Filter(Card.IsLocation,nil,LOCATION_MZONE):Filter(Card.IsFaceup,nil) local _,lv=g1:GetMinGroup(Card.GetLevel) local sel=0 if math.abs(lv)>1 then sel=Duel.SelectOption(tp,aux.Stringid(id,1),aux.Stringid(id,2)) else sel=Duel.SelectOption(tp,aux.Stringid(id,2))+1 end for tc in aux.Next(og) do local lv=tc:GetLevel() local val=(sel==0) and math.floor(lv/2) or lv*2 local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_CHANGE_LEVEL) e1:SetReset(RESET_EVENT+RESETS_STANDARD) e1:SetValue(val) tc:RegisterEffect(e1,true) end end end function s.lvcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return aux.bfgcost(e,tp,eg,ep,ev,re,r,rp,0) and s.sharedcost(e,tp,eg,ep,ev,re,r,rp,0) end aux.bfgcost(e,tp,eg,ep,ev,re,r,rp,1) s.sharedcost(e,tp,eg,ep,ev,re,r,rp,1) end function s.lvtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.lvtarget,tp,LOCATION_MZONE,0,1,nil) end local g=Duel.GetMatchingGroup(s.lvtarget,tp,LOCATION_MZONE,0,nil) local invalid_lv=(g:GetClassCount(Card.GetLevel)==1) and g:GetFirst():GetLevel() or nil Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(id,1)) local lv=Duel.AnnounceLevel(tp,1,8,invalid_lv) e:SetLabel(lv) end function s.lvop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local g=Duel.GetMatchingGroup(s.lvtarget,tp,LOCATION_MZONE,0,nil) for tc in aux.Next(g) do local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,5)) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_CLIENT_HINT) e1:SetCode(EFFECT_CHANGE_LEVEL) e1:SetValue(e:GetLabel()) e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1) end end function s.lvtarget(c) return c:IsSetCard(0x27a) and c:IsFaceup() and c:GetLevel()>0 end