--Overlay Undine --Automate ID local s,id=GetID() function s.initial_effect(c) --spsummon local e1=Effect.CreateEffect(c) e1:Desc(0) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_SINGLE|EFFECT_TYPE_TRIGGER_O) e1:SetProperty(EFFECT_FLAG_DELAY) e1:SetCode(EVENT_SUMMON_SUCCESS) e1:SetTarget(s.sptg) e1:SetOperation(s.spop) c:RegisterEffect(e1) --material local e2=Effect.CreateEffect(c) e2:Desc(1) e2:SetType(EFFECT_TYPE_IGNITION) e2:SetProperty(EFFECT_FLAG_CARD_TARGET) e2:SetRange(LOCATION_MZONE) e2:SetTarget(s.mattg) e2:SetOperation(s.matop) c:RegisterEffect(e2) end function s.filter(c,e,tp) return c:IsLevel(1) and not c:IsType(TYPE_TUNER) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(s.filter,tp,LOCATION_DECK,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK) end function s.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_DECK,0,1,1,nil,e,tp) if g:GetCount()>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end local c=e:GetHandler() local e1=Effect.CreateEffect(c) e1:SetType(EFFECT_TYPE_FIELD|EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_SPSUMMON_SUCCESS) e1:SetCondition(s.sprescon) e1:SetOperation(s.spresop) e1:SetReset(RESET_PHASE|PHASE_END) Duel.RegisterEffect(e1,tp) Duel.RegisterHint(tp,id,PHASE_END,1,id,2) local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e2:SetCode(EFFECT_SET_SPSUMMON_LIMIT) e2:SetTargetRange(1,0) e2:SetTarget(s.splimit) e2:SetValue(1) e2:SetReset(RESET_PHASE|PHASE_END) Duel.RegisterEffect(e2,tp) end function s.spresfil(c,tp) return c:GetSummonLocation()==LOCATION_EXTRA and c:IsPreviousControler(tp) and c:IsSummonPlayer(tp) and not c:IsType(TYPE_XYZ) end function s.sprescon(e,tp,eg,ep,ev,re,r,rp) return eg:IsExists(s.spresfil,1,nil,tp) end function s.spresop(e,tp,eg,ep,ev,re,r,rp) local e1=Effect.CreateEffect(e:GetOwner()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetReset(RESET_PHASE|PHASE_END) e1:SetTargetRange(1,0) e1:SetTarget(s.splimit) Duel.RegisterEffect(e1,tp) end function s.splimit(e,c,sump,sumtype,sumpos,targetp,se) return c:IsLocation(LOCATION_EXTRA) and c:IsControler(sump) and not c:IsType(TYPE_XYZ) end --E2 function s.matfilter(c) return c:IsFaceup() and c:IsType(TYPE_XYZ) end function s.mattg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(tp) and s.matfilter(chkc) end if chk==0 then return e:GetHandler():IsCanOverlay() and Duel.IsExistingTarget(s.matfilter,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TARGET) Duel.SelectTarget(tp,s.matfilter,tp,LOCATION_MZONE,0,1,1,nil) end function s.matop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local tc=Duel.GetFirstTarget() if c:IsRelateToChain() and c:IsControler(tp) and tc:IsRelateToChain() and not tc:IsImmuneToEffect(e) then Duel.Attach(c,tc) end end