--Alchemage Melana local cid,id=GetID() function cid.initial_effect(c) --SS from GY local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_SPECIAL_SUMMON) e1:SetType(EFFECT_TYPE_IGNITION) e1:SetRange(LOCATION_MZONE) e1:SetCountLimit(1,id+100) e1:SetCost(cid.ctcost) e1:SetTarget(cid.sptg) e1:SetOperation(cid.spop) c:RegisterEffect(e1) local e2=e1:Clone() e2:SetDescription(aux.Stringid(id,1)) e2:SetCost(cid.ctcost2) c:RegisterEffect(e2) --Special Summon local e3=Effect.CreateEffect(c) e3:SetCategory(CATEGORY_SPECIAL_SUMMON) e3:SetType(EFFECT_TYPE_IGNITION) e3:SetRange(LOCATION_HAND) e3:SetCountLimit(1,id) e3:SetCondition(cid.spcon1) e3:SetTarget(cid.sptg1) e3:SetOperation(cid.spop1) c:RegisterEffect(e3) end --Filters function cid.spfilter(c,e,tp) return c:IsSetCard(0x8108) and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end function cid.thfilter2(c) return (c:IsCode(21770262) or c:IsCode(21770263) or c:IsCode(21770264)) and c:IsReleasable() end function cid.cfilter(c) return (c:IsCode(21770262) or c:IsCode(21770263) or c:IsCode(21770264)) end --Recover from GY function cid.ctcost2(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.thfilter2,tp,LOCATION_MZONE,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,cid.thfilter2,tp,LOCATION_MZONE,0,1,1,nil) Duel.Release(g,nil,1,REASON_COST) end function cid.ctcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsCanRemoveCounter(tp,1,0,0x1818,2,REASON_COST) end Duel.RemoveCounter(tp,1,0,0x1818,2,REASON_COST) end function cid.sptg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and Duel.IsExistingMatchingCard(cid.spfilter,tp,LOCATION_GRAVE,0,1,nil,e,tp) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_GRAVE) end function cid.spop(e,tp,eg,ep,ev,re,r,rp) if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) local g=Duel.SelectMatchingCard(tp,cid.spfilter,tp,LOCATION_GRAVE,0,1,1,nil,e,tp) if g:GetCount()>0 then Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP) end end --Special Summon function cid.spcon1(e,tp,eg,ep,ev,re,r,rp) return Duel.IsExistingMatchingCard(cid.cfilter,tp,LOCATION_MZONE,0,1,nil) end function cid.sptg1(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0 and c:IsCanBeSpecialSummoned(e,0,tp,false,false) end Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,c,1,0,0) end function cid.spop1(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() if c:IsRelateToEffect(e) then Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP) end end