--Occhio d'Avorio 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) --search local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_HAND) e1:SetCountLimit(1,id) e1:SetCost(s.cost) e1:SetTarget(s.target) e1:SetOperation(s.operation) c:RegisterEffect(e1) --choose effect local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_CHAINING) e2:SetRange(LOCATION_GRAVE) e2:SetCountLimit(1,id+100) e2:SetCost(s.sharedcost) e2:SetCondition(s.discon) e2:SetTarget(s.distg) e2:SetOperation(s.disop) c:RegisterEffect(e2) --check summons 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.cost(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.filter(c) return c:IsSetCard(0x27a) and c:IsAbleToHand() and not c:IsCode(id) end function s.target(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK+LOCATION_GRAVE,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK+LOCATION_GRAVE) end function s.operation(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(s.filter),tp,LOCATION_DECK+LOCATION_GRAVE,0,1,1,nil) if #g>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end function s.thfilter(c) return c:IsSetCard(0x27a) and c:IsType(TYPE_MONSTER) and c:IsAbleToGrave() and not c:IsCode(id) end function s.discon(e,tp,eg,ep,ev,re,r,rp) return rp==1-tp and re:IsActiveType(TYPE_MONSTER) and re:IsActiveType(TYPE_TUNER) end function s.distg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then local b1=(not re:GetHandler():IsStatus(STATUS_DISABLED) and Duel.IsChainDisablable(ev) and c:IsAbleToRemove()) local b2=(c:IsAbleToHand() and Duel.IsExistingMatchingCard(s.thfilter,tp,LOCATION_HAND+LOCATION_DECK,0,1,nil)) local sel=0 if b1 then sel=sel+1 end if b2 then sel=sel+2 end e:SetLabel(sel) return sel~=0 end local sel=e:GetLabel() if sel==3 then Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(id,1)) sel=Duel.SelectOption(tp,aux.Stringid(id,2),aux.Stringid(id,3))+1 elseif sel==1 then Duel.SelectOption(tp,aux.Stringid(id,2)) else Duel.SelectOption(tp,aux.Stringid(id,3)) end e:SetLabel(sel) if sel==1 then e:SetCategory(CATEGORY_DISABLE+CATEGORY_REMOVE) Duel.SetOperationInfo(0,CATEGORY_DISABLE,eg,1,0,0) Duel.SetOperationInfo(0,CATEGORY_REMOVE,c,1,0,0) else e:SetCategory(CATEGORY_TOHAND+CATEGORY_TOGRAVE) Duel.SetOperationInfo(0,CATEGORY_TOHAND,c,1,0,0) Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,tp,LOCATION_HAND+LOCATION_DECK) end end function s.disop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local sel=e:GetLabel() if sel==1 then if c:IsRelateToEffect(e) and c:IsAbleToRemove() and Duel.NegateEffect(ev) then Duel.Remove(c,POS_FACEUP,REASON_EFFECT) end else if c:IsRelateToEffect(e) and Duel.SendtoHand(c,nil,REASON_EFFECT)>0 and c:IsLocation(LOCATION_HAND) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,s.thfilter,tp,LOCATION_HAND+LOCATION_DECK,0,1,1,nil) if #g>0 then Duel.SendtoGrave(g,REASON_EFFECT) end end end end