--created & coded by Lyris, art from Naruto Episode 33 --RUM呪わらし剣主 local s,id,o=GetID() function s.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetProperty(EFFECT_FLAG_CARD_TARGET) e1:SetCode(EVENT_FREE_CHAIN) e1:SetTarget(s.target) e1:SetOperation(s.activate) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetRange(LOCATION_GRAVE) e2:SetCost(aux.bfgcost) e2:SetTarget(s.mattg) e2:SetOperation(s.matop) c:RegisterEffect(e2) end function s.filter1(c,e,tp) local rk=c:GetRank() return rk>0 and c:IsFaceup() and Duel.IsExistingMatchingCard(s.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,c,c:GetRank()+1) and Duel.GetLocationCountFromEx(tp,tp,c)>0 end function s.filter2(c,e,tp,mc,rk) if c.rum_limit and not c.rum_limit(mc,e,tp,c) then return false end return c:GetRank()==rk and c:IsAttribute(ATTRIBUTE_DARK) and c:IsRace(RACE_WARRIOR) and mc:IsCanBeXyzMaterial(c) 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:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and s.filter1(chkc,e,tp) end if chk==0 then return Duel.IsExistingTarget(s.filter1,tp,LOCATION_MZONE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) local g=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 c=e:GetHandler() local tc=Duel.GetFirstTarget() if Duel.GetLocationCountFromEx(tp,tp,tc)<=0 then return end if tc:IsFacedown() or not tc:IsRelateToEffect(e) or tc:IsControler(1-tp) or tc:IsImmuneToEffect(e) or not tc:IsRace(RACE_WARRIOR) or not tc:IsType(TYPE_XYZ) then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,s.filter2,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,tc,tc:GetRank()+1) local sc=g:GetFirst() if sc then local mg=tc:GetOverlayGroup() if #mg~=0 then Duel.Overlay(sc,mg) end sc:SetMaterial(Group.FromCards(tc)) Duel.Overlay(sc,Group.FromCards(tc)) Duel.SpecialSummon(sc,SUMMON_TYPE_XYZ,tp,tp,false,false,POS_FACEUP) sc:CompleteProcedure() end end function s.xyzfilter(c) return c:IsFaceup() and c:IsAttribute(ATTRIBUTE_DARK) and c:IsType(TYPE_XYZ) and c:IsRace(RACE_WARRIOR) end function s.mattg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and s.xyzfilter(chkc) end if chk==0 then return Duel.IsExistingTarget(s.xyzfilter,tp,LOCATION_MZONE,0,1,nil) and Duel.GetOverlayCount(tp,0,1)~=0 end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_FACEUP) Duel.SelectTarget(tp,s.xyzfilter,tp,LOCATION_MZONE,0,1,1,nil) end function s.matop(e,tp,eg,ep,ev,re,r,rp) local sc=Duel.GetFirstTarget() if not sc:IsRelateToEffect(e) or sc:IsControler(1-tp) then return end local g1=Duel.GetOverlayGroup(tp,0,1) Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(id,0)) local mg2=g1:Select(tp,1,1,nil) local oc=mg2:GetFirst():GetOverlayTarget() Duel.Overlay(sc,mg2) Duel.RaiseSingleEvent(oc,EVENT_DETACH_MATERIAL,e,0,0,0,0) end