--Oniritron Orb Devices Recover local s,id=GetID() function s.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,id) e1:SetTarget(s.target) e1:SetOperation(s.activate) c:RegisterEffect(e1) --set local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetHintTiming(0,TIMINGS_CHECK_MONSTER+TIMING_END_PHASE) e2:SetType(EFFECT_TYPE_QUICK_O) e2:SetCode(EVENT_FREE_CHAIN) e2:SetRange(LOCATION_GRAVE) e2:SetHintTiming(0,TIMING_END_PHASE) e2:SetCountLimit(1,id) e2:SetCost(s.setcost) e2:SetTarget(s.settg) e2:SetOperation(s.setop) c:RegisterEffect(e2) end function s.xyzfilter(c) return c:IsSetCard(0x721) and c:IsType(TYPE_XYZ) and c:IsFaceup() end function s.target(e,tp,eg,ep,ev,re,r,rp,chk) c=e:GetHandler() if chk==0 then return Duel.IsExistingMatchingCard(Card.IsSetCard,tp,LOCATION_GRAVE+LOCATION_DECK,0,1,nil,0x1721) and Duel.IsExistingMatchingCard(s.xyzfilter,tp,LOCATION_MZONE,0,1,nil) end end function s.activate(e,tp,eg,ep,ev,re,r,rp) c=e:GetHandler() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SELECT) local g=Duel.SelectMatchingCard(tp,Card.IsSetCard,tp,LOCATION_GRAVE+LOCATION_DECK,0,1,1,nil,0x1721) if #g>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SELECT) local g2=Duel.SelectMatchingCard(tp,s.xyzfilter,tp,LOCATION_MZONE,0,1,1,nil) if #g2>0 then Duel.Overlay(g2:GetFirst(),g:GetFirst()) end end end function s.rmfilter(c,tp) return c:IsSetCard(0x1721) and c:IsType(TYPE_SPELL) and c:IsAbleToRemoveAsCost() --and aux.SpElimFilter(c,true) end function s.setcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.rmfilter,tp,LOCATION_GRAVE,0,1,e:GetHandler(),tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,s.rmfilter,tp,LOCATION_GRAVE,0,1,1,e:GetHandler(),tp) Duel.Remove(g,POS_FACEUP,REASON_COST) end function s.settg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsSSetable() end Duel.SetOperationInfo(0,CATEGORY_LEAVE_GRAVE,e:GetHandler(),1,0,0) end function s.setop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) and c:IsSSetable() then Duel.SSet(tp,c) end end