--The Origin of Dragons --created by Ace, coded by Lyris local s,id=GetID() function s.initial_effect(c) --activate local e1=Effect.CreateEffect(c) e1:Desc(0) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) --atk local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetCode(EFFECT_UPDATE_ATTACK) e2:SetRange(LOCATION_FZONE) e2:SetTargetRange(LOCATION_MZONE,0) e2:SetTarget(s.atktg) e2:SetValue(s.atkval) c:RegisterEffect(e2) --token local e3=Effect.CreateEffect(c) e3:Desc(1) e3:SetCategory(CATEGORY_TOKEN|CATEGORY_SPECIAL_SUMMON) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetRange(LOCATION_FZONE) e3:SetCountLimit(1) e3:SetCost(aux.InfoCost) e3:SetTarget(s.tg) e3:SetOperation(s.op) c:RegisterEffect(e3) --spsummon local e4=Effect.CreateEffect(c) e4:Desc(2) e4:SetCategory(CATEGORY_SPECIAL_SUMMON) e4:SetType(EFFECT_TYPE_IGNITION) e4:SetRange(LOCATION_FZONE) e4:HOPT() e4:SetLabel(0) e4:SetCost(aux.InfoCost) e4:SetTarget(s.sptg) e4:SetOperation(s.spop) c:RegisterEffect(e4) end function s.atktg(e,c) return c:IsAttribute(ATTRIBUTE_FIRE) and c:IsRace(RACE_DRAGON) and not c:IsType(TYPE_TOKEN) and not c:IsCode(TOKEN_DRAGON_EGG) end function s.atkval(e,c) return Duel.GetMatchingGroup(aux.FaceupFilter(Card.IsCode,TOKEN_DRAGON_EGG),e:GetHandlerPlayer(),LOCATION_MZONE,0,nil):GetSum(Card.GetAttack) end function s.tg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsPlayerCanSpecialSummonMonster(tp,TOKEN_DRAGON_EGG,0,TYPES_TOKEN_MONSTER,300,300,1,RACE_DRAGON,ATTRIBUTE_FIRE) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,0) Duel.SetOperationInfo(0,CATEGORY_TOKEN,nil,1,tp,0) end function s.op(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 or not Duel.IsPlayerCanSpecialSummonMonster(tp,TOKEN_DRAGON_EGG,0,TYPES_TOKEN_MONSTER,300,300,1,RACE_DRAGON,ATTRIBUTE_FIRE) then return end local c=e:GetHandler() local token=Duel.CreateToken(tp,TOKEN_DRAGON_EGG) if Duel.SpecialSummonStep(token,0,tp,tp,false,false,POS_FACEUP) then local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_SINGLE) e1:SetCode(EFFECT_CANNOT_BE_SYNCHRO_MATERIAL) e1:SetValue(s.matlim) e1:SetReset(RESET_EVENT|RESETS_STANDARD) token:RegisterEffect(e1,true) local e2=e1:Clone() e2:SetCode(EFFECT_CANNOT_BE_LINK_MATERIAL) token:RegisterEffect(e2,true) local e3=e1:Clone() e3:SetCode(EFFECT_CANNOT_BE_FUSION_MATERIAL) token:RegisterEffect(e3,true) end Duel.SpecialSummonComplete() end function s.matlim(e,c) if not c then return false end return not c:IsSetCard(ARCHE_ORIGIN_DRAGON) end function s.gcheck(g,lv,tp) return #g==lv and Duel.GetMZoneCount(tp,g)>0 and Duel.CheckReleaseGroup(tp,Auxiliary.IsInGroup,#g,nil,g) end function s.filter(c,e,tp,rg) if not (c:IsSetCard(ARCHE_ORIGIN_DRAGON) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)) then return false end local lv=c:GetLevel() return lv>0 and rg:CheckSubGroup(s.gcheck,1,#rg,lv,tp) end function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk) local rg=Duel.GetReleaseGroup(tp):Filter(Card.IsCode,nil,TOKEN_DRAGON_EGG) if chk==0 then return e:IsCostChecked() and #rg>0 and Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK,0,1,nil,e,tp,rg) end local g=Duel.GetMatchingGroup(s.filter,tp,LOCATION_DECK,0,nil,e,tp,rg) local lvt={} for tc in aux.Next(g) do local tlv=tc:GetLevel() table.insert(lvt,tlv) end Duel.Hint(HINT_SELECTMSG,tp,567) local lv=Duel.AnnounceNumber(tp,table.unpack(lvt)) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RELEASE) local g=rg:SelectSubGroup(tp,aux.mzctcheckrel,false,lv,lv,tp) aux.UseExtraReleaseCount(g,tp) local ct=Duel.Release(g,REASON_COST) e:SetLabel(ct) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function s.sfilter(c,lv,e,tp) return c:IsSetCard(ARCHE_ORIGIN_DRAGON) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and c:IsLevel(lv) end function s.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end local lv=e:GetLabel() Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,s.sfilter,tp,LOCATION_DECK,0,1,1,nil,lv,e,tp) if #g>0 and Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)~=0 then local rct=Duel.GetNextPhaseCount(PHASE_DRAW,tp) local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EFFECT_SKIP_DP) e1:SetTargetRange(1,0) e1:SetReset(RESET_PHASE|PHASE_DRAW|RESET_SELF_TURN,rct) Duel.RegisterEffect(e1,tp) end end