--Saruves, The Origin Dragon --created by Ace, coded by Lyris local s,id=GetID() function s.initial_effect(c) --draw local e1=Effect.CreateEffect(c) e1:Desc(0) e1:SetCategory(CATEGORY_DRAW|CATEGORY_SUMMON) e1:SetType(EFFECT_TYPE_SINGLE|EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetProperty(EFFECT_FLAG_DELAY) e1:SetCost(s.dcost) e1:SetTarget(s.dtg) e1:SetOperation(s.dop) 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.cfilter(c) return (c:IsSetCard(ARCHE_ORIGIN_DRAGON) or c:IsCode(CARD_THE_ORIGIN_OF_DRAGONS)) and c:IsDiscardable() end function s.dcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_HAND,0,1,nil) end Duel.DiscardHand(tp,s.cfilter,1,1,REASON_COST|REASON_DISCARD) end function s.dtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return not Duel.PlayerHasFlagEffectLabel(tp,id,1) and Duel.IsPlayerCanDraw(tp,2) end Duel.RegisterFlagEffect(tp,id,RESET_PHASE|PHASE_END,0,1,0) Duel.SetTargetPlayer(tp) Duel.SetTargetParam(2) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,2) Duel.SetPossibleOperationInfo(0,CATEGORY_SUMMON,nil,1,tp,LOCATION_HAND) end function s.filter(c) return c:IsSetCard(ARCHE_ORIGIN_DRAGON) and c:IsSummonable(true,nil) end function s.dop(e,tp,eg,ep,ev,re,r,rp) local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM) if Duel.Draw(p,d,REASON_EFFECT)>0 and Duel.IsExists(false,s.filter,tp,LOCATION_HAND,0,1,1,nil) and Duel.SelectYesNo(tp,STRING_ASK_SUMMON) then Duel.ShuffleHand(tp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SUMMON) local g=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_HAND,0,1,1,nil) local tc=g:GetFirst() if tc then Duel.Summon(tp,tc,true,nil) end 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