--Uru-Chain Overlayer function c249001209.initial_effect(c) aux.EnablePendulumAttribute(c) --enable chain overlay local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetCountLimit(1,2490012091) e1:SetRange(LOCATION_MZONE) e1:SetCost(c249001209.cost) e1:SetOperation(c249001209.operation) c:RegisterEffect(e1) --negate local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(50275295,0)) e2:SetCategory(CATEGORY_DISABLE) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetRange(LOCATION_PZONE) e2:SetCountLimit(1,2490012092) e2:SetCost(c249001209.discost) e2:SetTarget(c249001209.distg) e2:SetOperation(c249001209.disop) c:RegisterEffect(e2) end function c249001209.costfilter(c) return c:IsSetCard(0x232) and c:IsAbleToRemoveAsCost() and c:IsType(TYPE_MONSTER) and (c:IsFaceup() or not c:IsLocation(LOCATION_EXTRA)) end function c249001209.costfilter2(c,e) return c:IsSetCard(0x232) and not c:IsPublic() and c:IsType(TYPE_MONSTER) end function c249001209.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return (Duel.IsExistingMatchingCard(c249001209.costfilter,tp,LOCATION_GRAVE+LOCATION_EXTRA,0,1,nil) or Duel.IsExistingMatchingCard(c249001209.costfilter2,tp,LOCATION_HAND,0,1,nil)) end local option if Duel.IsExistingMatchingCard(c249001209.costfilter2,tp,LOCATION_HAND,0,1,nil) then option=0 end if Duel.IsExistingMatchingCard(c249001209.costfilter,tp,LOCATION_GRAVE+LOCATION_EXTRA,0,1,nil) then option=1 end if Duel.IsExistingMatchingCard(c249001209.costfilter,tp,LOCATION_GRAVE+LOCATION_EXTRA,0,1,nil) and Duel.IsExistingMatchingCard(c249001209.costfilter2,tp,LOCATION_HAND,0,1,nil) then option=Duel.SelectOption(tp,526,1102) end if option==0 then g=Duel.SelectMatchingCard(tp,c249001209.costfilter2,tp,LOCATION_HAND,0,1,1,nil) Duel.ConfirmCards(1-tp,g) Duel.ShuffleHand(tp) end if option==1 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE) local g=Duel.SelectMatchingCard(tp,c249001209.costfilter,tp,LOCATION_GRAVE+LOCATION_EXTRA,0,1,1,nil) Duel.Remove(g,POS_FACEUP,REASON_COST) end end function c249001209.operation(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE+EFFECT_FLAG_IGNORE_RANGE+EFFECT_FLAG_IGNORE_IMMUNE) e1:SetCode(EFFECT_TO_GRAVE_REDIRECT) e1:SetTarget(aux.TargetBoolFunction(Card.IsType,TYPE_MONSTER)) e1:SetTargetRange(LOCATION_OVERLAY,0) e1:SetValue(LOCATION_REMOVED) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) local hg=Duel.GetFieldGroup(tp,LOCATION_GRAVE,0):Filter(Card.IsType,nil,TYPE_MONSTER) local tc=hg:GetFirst() while tc do local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_EXTRA_XYZ_MATERIAL) e1:SetRange(LOCATION_GRAVE) e1:SetValue(aux.TRUE) e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1) tc=hg:GetNext() end local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_TO_GRAVE) e2:SetReset(RESET_PHASE+PHASE_END) e2:SetOperation(c249001209.gop) Duel.RegisterEffect(e2,tp) end function c249001209.gfilter(c,tp) return c:IsType(TYPE_MONSTER) and c:IsControler(tp) end function c249001209.gop(e,tp,eg,ep,ev,re,r,rp) local hg=eg:Filter(c249001209.gfilter,nil,tp) local tc=hg:GetFirst() while tc do local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_EXTRA_XYZ_MATERIAL) e1:SetRange(LOCATION_GRAVE) e1:SetValue(aux.TRUE) e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1) tc=hg:GetNext() end end function c249001209.discon(e,tp,eg,ep,ev,re,r,rp) return Duel.IsExistingMatchingCard(Card.IsSetCard,tp,LOCATION_PZONE,0,1,e:GetHandler(),0x232) end function c249001209.discost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsDiscardable,tp,LOCATION_HAND,0,1,e:GetHandler()) end Duel.DiscardHand(tp,Card.IsDiscardable,1,1,REASON_COST+REASON_DISCARD) end function c249001209.distg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) and aux.NegateMonsterFilter(chkc) end if chk==0 then return Duel.IsExistingTarget(aux.NegateMonsterFilter,tp,0,LOCATION_MZONE,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DISABLE) local g=Duel.SelectTarget(tp,aux.NegateMonsterFilter,tp,0,LOCATION_MZONE,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_DISABLE,g,1,0,0) end function c249001209.disop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if tc:IsFaceup() and tc:IsRelateToEffect(e) and not tc:IsDisabled() then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_DISABLE) e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END) tc:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE) e2:SetCode(EFFECT_DISABLE_EFFECT) e2:SetValue(RESET_TURN_SET) e2:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END) tc:RegisterEffect(e2) end end