--Hatchling, The Origin Dragon --created by Ace, coded by Lyris local s,id=GetID() function s.initial_effect(c) --search local e1=Effect.CreateEffect(c) e1:Desc(0) e1:SetCategory(CATEGORY_SEARCH|CATEGORY_TOHAND) e1:SetType(EFFECT_TYPE_SINGLE|EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetProperty(EFFECT_FLAG_DELAY) e1:SetTarget(s.thtg) e1:SetOperation(s.thop) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetCode(EVENT_SUMMON_SUCCESS) c:RegisterEffect(e2) local e3=e1:Clone() e3:SetCode(EVENT_FLIP_SUMMON_SUCCESS) c:RegisterEffect(e3) --token local e4=Effect.CreateEffect(c) e4:Desc(1) e4:SetCategory(CATEGORY_TOKEN|CATEGORY_SPECIAL_SUMMON) e4:SetType(EFFECT_TYPE_SINGLE|EFFECT_TYPE_TRIGGER_F) e4:SetCode(EVENT_TO_GRAVE) e4:SetTarget(s.tg) e4:SetOperation(s.op) c:RegisterEffect(e4) end function s.filter(c) return (c:IsSetCard(ARCHE_ORIGIN_DRAGON) or c:IsCode(CARD_THE_ORIGIN_OF_DRAGONS)) and c:IsAbleToHand() end function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return not Duel.PlayerHasFlagEffectLabel(tp,id,1) and Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK,0,1,nil) end Duel.RegisterFlagEffect(tp,id,RESET_PHASE|PHASE_END,0,1,0) Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_DECK) end function s.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_DECK,0,1,1,nil) if #g>0 and Duel.SearchAndCheck(g,tp) 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 function s.tg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return not Duel.PlayerHasFlagEffectLabel(tp,id,0) end Duel.RegisterFlagEffect(tp,id,RESET_PHASE|PHASE_END,0,1,1) 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