--Gamel, Protector of the Star Regalia function c97569818.initial_effect(c) aux.EnablePendulumAttribute(c) --pendulum summon aux.EnablePendulumAttribute(c) --special summon local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(97569818,0)) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_SPSUMMON_PROC) e1:SetProperty(EFFECT_FLAG_UNCOPYABLE) e1:SetRange(LOCATION_HAND+LOCATION_GRAVE) e1:SetCountLimit(1,97569818) e1:SetCondition(c97569818.spcon) c:RegisterEffect(e1) --XYZ SUmmon using a xyz local e2=Effect.CreateEffect(c) e2:SetCategory(CATEGORY_SPECIAL_SUMMON) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetRange(LOCATION_PZONE) e2:SetCost(c97569818.spcost) e2:SetTarget(c97569818.sptg) e2:SetOperation(c97569818.spop) c:RegisterEffect(e2) --synchro limit local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetCode(EFFECT_CANNOT_BE_SYNCHRO_MATERIAL) e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e3:SetValue(c97569818.synlimit) c:RegisterEffect(e3) --todeck local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_SINGLE) e4:SetCode(EFFECT_LEAVE_FIELD_REDIRECT) e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE) e4:SetValue(LOCATION_DECKBOT) e4:SetCondition(c97569818.rdcon) c:RegisterEffect(e4) local e5=Effect.CreateEffect(c) e5:SetType(EFFECT_TYPE_FIELD) e5:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_SET_AVAILABLE+EFFECT_FLAG_IGNORE_RANGE) e5:SetRange(LOCATION_MZONE) e5:SetCode(EFFECT_MATERIAL_CHECK) e5:SetValue(c97569818.valcheck) e5:SetLabelObject(e4) c:RegisterEffect(e5) end function c97569818.filter(c) return c:IsFaceup() and c:IsSetCard(0xd0a2) end function c97569818.spcon(e,c) if c==nil then return true end return Duel.GetLocationCount(c:GetControler(),LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(c97569818.filter,c:GetControler(),LOCATION_ONFIELD,0,1,nil) end function c97569818.spcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST) end function c97569818.filter1(c,e,tp) return c:IsFaceup() and c:IsType(TYPE_XYZ) and c:IsSetCard(0xd0a1) and Duel.IsExistingMatchingCard(c97569818.filter2,tp,LOCATION_EXTRA,0,1,nil,e,tp,c,c:GetCode()) and aux.MustMaterialCheck(c,tp,EFFECT_MUST_BE_XMATERIAL) end function c97569818.filter2(c,e,tp,mc,code) return c:IsType(TYPE_XYZ) and c:IsSetCard(0xd0a1) and not c:IsCode(code) and mc:IsCanBeXyzMaterial(c) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_XYZ,tp,false,false) and Duel.GetLocationCountFromEx(tp,tp,mc,c)>0 end function c97569818.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_MZONE) and c97569818.filter1(chkc,e,tp) end if chk==0 then return Duel.IsExistingTarget(c97569818.filter1,tp,LOCATION_MZONE,0,1,nil,e,tp) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) Duel.SelectTarget(tp,c97569818.filter1,tp,LOCATION_MZONE,0,1,1,nil,e,tp) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_EXTRA) end function c97569818.spop(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 g=Duel.SelectMatchingCard(tp,c97569818.filter2,tp,LOCATION_EXTRA,0,1,1,nil,e,tp,tc,tc:GetCode()) local sc=g:GetFirst() if sc then local mg=tc:GetOverlayGroup() if mg:GetCount()~=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 c97569818.synlimit(e,c) if not c then return false end return not c:IsRace(RACE_WARRIOR) end function c97569818.rdcon(e) return e:GetHandler():IsReason(REASON_MATERIAL) and e:GetHandler():IsReason(REASON_SYNCHRO) and e:GetLabel()==1 end function c97569818.sfilter(c) return not c:IsSetCard(0xd0a1) end function c97569818.valcheck(e,c) if c:GetMaterial():IsExists(c97569818.sfilter,1,e:GetHandler()) then e:GetLabelObject():SetLabel(1) else e:GetLabelObject():SetLabel(0) end end