--Oniritron Empowering Device local s,id=GetID() function s.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetHintTiming(0,TIMING_END_PHASE) c:RegisterEffect(e1) --Your opponent cannot target "Oniritron" Xyz Monsters with material you control with card effects. local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET) e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e2:SetRange(LOCATION_SZONE) e2:SetTargetRange(LOCATION_MZONE,0) e2:SetTarget(s.tgtg) e2:SetValue(aux.tgoval) c:RegisterEffect(e2) --All monsters your opponent controls lose ATK/DEF equal to the combined number of materials attached to all "Oniritron" Xyz Monsters you control x 500 local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_FIELD) e3:SetCode(EFFECT_UPDATE_ATTACK) e3:SetRange(LOCATION_SZONE) e3:SetTargetRange(0,LOCATION_MZONE) e3:SetValue(s.atkval) c:RegisterEffect(e3) local e4=e3:Clone() e4:SetCode(EFFECT_UPDATE_DEFENSE) c:RegisterEffect(e4) --Once per turn: You can target 1 "Oniritron Device" Spell/Trap in your GY; attach it to 1 "Oniritron" Xyz Monster you control as material. local e5=Effect.CreateEffect(c) e5:SetProperty(EFFECT_FLAG_CARD_TARGET) e5:SetType(EFFECT_TYPE_QUICK_O) e5:SetRange(LOCATION_SZONE) e5:SetCode(EVENT_FREE_CHAIN) e5:SetCountLimit(1) e5:SetHintTiming(0,TIMING_MAIN_END) e5:SetTarget(s.xyztg) e5:SetOperation(s.xyzop) c:RegisterEffect(e5) end function s.tgtg(e,c) return c:IsSetCard(0x721) and c:IsType(TYPE_XYZ) and c:GetOverlayCount()>0 end function s.atkval(e,c) local g=Duel.GetMatchingGroup(s.xyzfilter,e:GetHandlerPlayer(),LOCATION_MZONE,0,nil) return g:GetSum(Card.GetOverlayCount)*-500 end function s.xyzfilter(c) return c:IsSetCard(0x721) and c:IsType(TYPE_XYZ) and c:IsFaceup() end function s.xyztg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_GRAVE) and chkc:IsSetCard(0x1721) end if chk==0 then return Duel.IsExistingTarget(Card.IsSetCard,tp,LOCATION_GRAVE,0,1,nil,0x1721) and Duel.IsExistingMatchingCard(s.xyzfilter,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SELECT) local g=Duel.SelectTarget(tp,Card.IsSetCard,tp,LOCATION_GRAVE,0,1,1,nil,0x1721) Duel.SetOperationInfo(0,CATEGORY_LEAVE_GRAVE,g,1,0,0) end function s.xyzop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if tc:IsRelateToEffect(e) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SELECT) local g=Duel.SelectMatchingCard(tp,s.xyzfilter,tp,LOCATION_MZONE,0,1,1,nil) if #g>0 then Duel.Overlay(g:GetFirst(),tc) end end end