--created by NovaTsukimori, coded by Lyris --RUM-ライリス・フォース local s,id,o=GetID() Card.IsLyrisForce=Card.IsLyrisForce or function(c) return c:IsCode(102400132,102400143,102400144) end function s.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetTarget(s.target) e1:SetOperation(s.activate) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_CUSTOM+id) e2:SetCategory(CATEGORY_TOHAND) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCountLimit(1,id+EFFECT_COUNT_CODE_DUEL) e2:SetTarget(s.thtg) e2:SetOperation(s.thop) c:RegisterEffect(e2) end function s.filter1(c,e,tp) local rk=c:GetRank() return c:IsFaceup() and c:IsType(TYPE_XYZ) and c:GetRank()>0 and Duel.IsExistingMatchingCard(s.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,c,c:GetRank(),c:GetRace()) end function s.filter2(c,e,tp,mc,rk,rc) return c:GetRank()==rk+1 and c:GetRace()==rc and c:IsSetCard(0x7c4) and mc:IsCanBeXyzMaterial(c) and c:IsType(TYPE_XYZ) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_XYZ,tp,false,false) end function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.filter1(chkc,e,tp) end if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE) and Duel.IsExistingTarget(s.filter1,tp,LOCATION_MZONE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) Duel.SelectTarget(tp,s.filter1,tp,LOCATION_MZONE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function s.activate(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if not tc:IsRelateToEffect(e) or tc:IsFacedown() or tc:IsControler(1-tp) or not tc:IsLocation(LOCATION_MZONE) or not tc:IsType(TYPE_XYZ) or tc:IsImmuneToEffect(e) then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sg=Duel.SelectMatchingCard(tp,s.filter2,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,tc,tc:GetRank(),tc:GetRace()) local sc=sg:GetFirst() if sc then Duel.Overlay(sc,tc:GetOverlayGroup()) Duel.Overlay(sc,Group.FromCards(tc)) Duel.BreakEffect() Duel.SpecialSummon(sc,SUMMON_TYPE_XYZ,tp,tp,false,false,POS_FACEUP) sc:CompleteProcedure() local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_TO_GRAVE) e1:SetOperation(s.check) e1:SetReset(RESET_EVENT+0x17a0000) sc:RegisterEffect(e1) end end function s.check(e,tp,eg,ep,ev,re,r,rp) if e:GetHandler():IsReason(REASON_DESTROY) then Duel.RaiseSingleEvent(e:GetOwner(),EVENT_CUSTOM+id,e,r,rp,tp,0) end end function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return c:IsLocation(LOCATION_GRAVE) and c:IsAbleToHand() end Duel.SetOperationInfo(0,CATEGORY_TOHAND,c,1,0,0) end function s.thop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) then Duel.SendtoHand(c,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,c) end end