--Oniritron Lands of Illusion local s,id=GetID() function s.initial_effect(c) --When this card is activated you can take 1 "Oniritron" monster from your Deck, and either add it to your hand or send it to the GY. local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH+CATEGORY_TOGRAVE) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,id,EFFECT_COUNT_CODE_OATH) e1:SetOperation(s.activate) c:RegisterEffect(e1) --The first time each "Oniritron" Xyz Monster you control would be destroyed by battle each turn, it is not destroyed. local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_INDESTRUCTABLE_COUNT) e2:SetRange(LOCATION_FZONE) e2:SetTargetRange(LOCATION_MZONE,0) e2:SetTarget(s.indtg) e2:SetValue(s.indct) c:RegisterEffect(e2) --Once per turn: you can target 1 card your opponent controls; attach it to 1 "Oniritron" Xyz Monster you control as material. local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetProperty(EFFECT_FLAG_CARD_TARGET) e3:SetRange(LOCATION_FZONE) e3:SetCountLimit(1) e3:SetTarget(s.atchtg) e3:SetOperation(s.atchop) c:RegisterEffect(e3) end function s.cfilter(c) return c:IsMonster() and c:IsSetCard(0x721) and (c:IsAbleToHand() or c:IsAbleToGrave()) end function s.activate(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local g=Duel.GetMatchingGroup(s.cfilter,tp,LOCATION_DECK,0,nil) if #g>0 and Duel.SelectYesNo(tp,aux.Stringid(id,0)) then local g2=Duel.SelectMatchingCard(tp,s.cfilter,tp,LOCATION_DECK,0,1,1,nil) local tc=g2:GetFirst() if tc and tc:IsAbleToHand() and (not tc:IsAbleToGrave() or Duel.SelectOption(tp,1190,1191)==0) then Duel.SendtoHand(tc,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,tc) else Duel.SendtoGrave(tc,REASON_EFFECT) end end end function s.indtg(e,c) return c:IsSetCard(0x721) and c:IsType(TYPE_XYZ) end function s.indct(e,re,r,rp) if (r&REASON_BATTLE)~=0 then return 1 else return 0 end end function s.atchfilter(c) return not c:IsType(TYPE_TOKEN) and c:IsAbleToChangeControler() end function s.xyzfilter(c,e) return c:IsFaceup() and not c:IsImmuneToEffect(e) and c:IsType(TYPE_XYZ) and c:IsSetCard(0x721) end function s.atchtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_ONFIELD) and chkc:IsControler(1-tp) and s.atchfilter(chkc) end if chk==0 then return Duel.IsExistingMatchingCard(s.xyzfilter,tp,LOCATION_MZONE,0,1,nil,e) and Duel.IsExistingTarget(s.atchfilter,tp,0,LOCATION_ONFIELD,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) Duel.SelectTarget(tp,s.atchfilter,tp,0,LOCATION_ONFIELD,1,1,nil) end function s.atchop(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() local xyz=Duel.SelectMatchingCard(tp,s.xyzfilter,tp,LOCATION_MZONE,0,1,1,nil,e):GetFirst() if tc:IsRelateToEffect(e) and not tc:IsImmuneToEffect(e) then local og=tc:GetOverlayGroup() if og:GetCount()>0 then Duel.SendtoGrave(og,REASON_RULE) end Duel.Overlay(xyz,Group.FromCards(tc),true) end end