--created by Eaden, coded by Lyris local s,id=GetID() function s.initial_effect(c) local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH) e1:SetCost(s.cost) e1:SetOperation(s.activate) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_ACTIVATE) e2:SetCode(EVENT_BATTLED) e2:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH) e2:SetCondition(s.condition) e2:SetTarget(s.target) e2:SetOperation(s.operation) c:RegisterEffect(e2) end function s.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsDiscardable,tp,LOCATION_HAND,0,1,nil) end Duel.DiscardHand(tp,Card.IsDiscardable,1,1,REASON_COST) end function s.activate(e,tp,eg,ep,ev,re,r,rp) local e2=Effect.CreateEffect(e:GetHandler()) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e2:SetCode(EVENT_CHAINING) e2:SetOperation(s.chainop) e2:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e2,tp) end function s.chainop(e,tp,eg,ep,ev,re,r,rp) if re:IsActiveType(TYPE_MONSTER) and re:GetHandler():IsSetCard(0xead) then Duel.SetChainLimit(function(e,rpr,p) return p==rpr end) end end function s.condition(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetAttacker() local bc=tc:GetBattleTarget() if tc:IsType(TYPE_XYZ) and tc:IsSetCard(0x2ead) and tc:IsControler(tp) and tc:IsStatus(STATUS_OPPO_BATTLE) and bc and bc:IsStatus(STATUS_BATTLE_DESTROYED) then e:SetLabelObject(tc) return true elseif bc and bc:IsType(TYPE_XYZ) and bc:IsSetCard(0x2ead) and bc:IsControler(tp) and bc:IsStatus(STATUS_OPPO_BATTLE) and tc:IsStatus(STATUS_BATTLE_DESTROYED) then e:SetLabelObject(bc) return true else return false end end function s.filter(c,e,tp,mc) return c:IsRank(mc:GetRank()+2) and c:IsSetCard(0x2ead) and mc:IsCanBeXyzMaterial(c) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_XYZ,tp,false,false) and Duel.GetLocationCountFromEx(tp,tp,mc,c)>0 end function s.target(e,tp,eg,ep,ev,re,r,rp,chk) local tc=e:GetLabelObject() if chk==0 then return aux.MustMaterialCheck(tc,tp,EFFECT_MUST_BE_XMATERIAL) and Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_EXTRA,0,1,nil,e,tp,tc) end Duel.SetTargetCard(tc) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function s.operation(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if not aux.MustMaterialCheck(tc,tp,EFFECT_MUST_BE_XMATERIAL) then return end if tc:IsFacedown() or not tc:IsRelateToEffect(e) or tc:IsControler(1-tp) or tc:IsImmuneToEffect(e) then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local sc=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,tc):GetFirst() if sc then Duel.Overlay(sc,tc:GetOverlayGroup()) 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