--Medivatale Awakening local cid,id=GetID() function cid.initial_effect(c) --Activate local e1=Effect.CreateEffect(c) e1:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) e1:SetCountLimit(1,id+EFFECT_COUNT_CODE_OATH) e1:SetCost(cid.cost) --e1:SetTarget(cid.target) e1:SetOperation(cid.activate) c:RegisterEffect(e1) --extra summon local e2=Effect.CreateEffect(c) e2:SetType(EFFECT_TYPE_FIELD) e2:SetTargetRange(LOCATION_HAND+LOCATION_MZONE,0) e2:SetCode(EFFECT_EXTRA_SUMMON_COUNT) e2:SetCondition(cid.sprcon) e2:SetTarget(cid.target) e2:SetRange(LOCATION_SZONE) c:RegisterEffect(e2) local e3=e2:Clone() e3:SetCode(EFFECT_EXTRA_SET_COUNT) c:RegisterEffect(e3) --to deck local e4=Effect.CreateEffect(c) e4:SetCategory(CATEGORY_TOHAND+CATEGORY_SEARCH) e4:SetCountLimit(1,id+1) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e4:SetCode(EVENT_TO_GRAVE) e4:SetCondition(cid.retcon) e4:SetOperation(cid.retop) c:RegisterEffect(e4) end function cid.cost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetCustomActivityCount(id,tp,ACTIVITY_SPSUMMON)==0 end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_OATH) e1:SetCode(EFFECT_CANNOT_SPECIAL_SUMMON) e1:SetReset(RESET_PHASE+PHASE_END) e1:SetTargetRange(1,0) e1:SetLabelObject(e) e1:SetTarget(cid.splimit) Duel.RegisterEffect(e1,tp) end function cid.splimit(e,c,sump,sumtype,sumpos,targetp,se) return c:IsLocation(LOCATION_EXTRA) and not c:IsSetCard(0xab5) end function cid.filter(c) return c:IsSetCard(0xab5) and c:IsType(TYPE_MONSTER) and c:IsAbleToHand() end function cid.activate(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local g=Duel.GetMatchingGroup(cid.filter,tp,LOCATION_DECK,0,nil) if g:GetCount()>0 and Duel.SelectYesNo(tp,aux.Stringid(id,0)) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local sg=g:Select(tp,1,1,nil) Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,sg) end end function cid.cfilter(c) return c:IsFaceup() and not c:IsAbleToHandAsCost() and c:IsType(TYPE_EFFECT) end function cid.sprcon(e,c) if c==nil then return true end local tp=c:GetControler() return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and not Duel.IsExistingMatchingCard(cid.cfilter,tp,LOCATION_MZONE,0,1,nil) end function cid.filter2(c) return c:IsSetCard(0xab5) and c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsAbleToHand() end function cid.retcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsReason(REASON_DESTROY) and e:GetHandler():GetReasonPlayer()==1-tp and e:GetHandler():GetPreviousControler()==tp end function cid.retop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local g=Duel.GetMatchingGroup(cid.filter2,tp,LOCATION_DECK,0,nil) if g:GetCount()>0 then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local sg=g:Select(tp,1,1,nil) Duel.SendtoHand(sg,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,sg) end end function cid.target(e,c) return c:IsSetCard(0xab5) end