--Orilynn, Wisprit Mage local cid,id=GetID() function cid.initial_effect(c) --draw local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,0)) e1:SetCategory(CATEGORY_HANDES+CATEGORY_DRAW) e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e1:SetCode(EVENT_SUMMON_SUCCESS) e1:SetCost(cid.drcost) e1:SetTarget(cid.drtg) e1:SetOperation(cid.drop) c:RegisterEffect(e1) --to hand local e2=Effect.CreateEffect(c) e2:SetDescription(aux.Stringid(id,1)) e2:SetCategory(CATEGORY_TOHAND) e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O) e2:SetProperty(EFFECT_FLAG_DELAY) e2:SetCode(EVENT_REMOVE) e2:SetCountLimit(1,id) e2:SetCondition(cid.thcon) e2:SetTarget(cid.thtg) e2:SetOperation(cid.thop) c:RegisterEffect(e2) local e3=e2:Clone() e3:SetCode(EVENT_TO_GRAVE) e3:SetCondition(cid.thcon1) c:RegisterEffect(e3) --gain local e4=Effect.CreateEffect(c) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e4:SetCode(EVENT_BE_MATERIAL) e4:SetCondition(cid.mtcon) e4:SetOperation(cid.mtop) c:RegisterEffect(e4) end --filters function cid.costfilter(c) return bit.band(c:GetType(),0x82)==0x82 and not c:IsPublic() end function cid.thfilter(c) return c:IsSetCard(0x26c) and c:IsAbleToHand() and not c:IsCode(id) end function cid.repfilter(c) return c:IsRace(RACE_FAIRY) and c:IsAbleToRemove() end --draw function cid.drcost(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.costfilter,tp,LOCATION_HAND,0,1,nil) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CONFIRM) local g=Duel.SelectMatchingCard(tp,cid.costfilter,tp,LOCATION_HAND,0,1,1,nil) Duel.ConfirmCards(1-tp,g) Duel.ShuffleHand(tp) end function cid.drtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.GetFieldGroupCount(tp,LOCATION_HAND,0)>0 and Duel.IsPlayerCanDraw(tp,2) end Duel.SetOperationInfo(0,CATEGORY_HANDES,nil,0,tp,1) Duel.SetOperationInfo(0,CATEGORY_DRAW,nil,0,tp,2) end function cid.drop(e,tp,eg,ep,ev,re,r,rp) if Duel.DiscardHand(tp,nil,1,1,REASON_EFFECT+REASON_DISCARD)>0 then Duel.Draw(tp,2,REASON_EFFECT) end if not e:IsHasType(EFFECT_TYPE_ACTIVATE) then return end local e1=Effect.CreateEffect(e:GetHandler()) e1:SetType(EFFECT_TYPE_FIELD) e1:SetCode(EFFECT_CANNOT_DRAW) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetTargetRange(1,0) e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp) end --to hand function cid.thcon(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsPreviousLocation(LOCATION_GRAVE) end function cid.thcon1(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() return (c:IsReason(REASON_EFFECT) and not re:GetHandler():IsCode(id)) end function cid.thtg(e,tp,eg,ep,ev,re,r,rp,chk) if chk==0 then return Duel.IsExistingMatchingCard(cid.thfilter,tp,LOCATION_GRAVE,0,1,nil) end Duel.SetOperationInfo(0,CATEGORY_TOHAND,nil,1,tp,LOCATION_GRAVE) end function cid.thop(e,tp,eg,ep,ev,re,r,rp) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectMatchingCard(tp,aux.NecroValleyFilter(cid.thfilter),tp,LOCATION_GRAVE,0,1,1,nil) if g:GetCount()>0 then Duel.SendtoHand(g,nil,REASON_EFFECT) Duel.ConfirmCards(1-tp,g) end end --gain function cid.mtcon(e,tp,eg,ep,ev,re,r,rp) return r==REASON_RITUAL end function cid.mtop(e,tp,eg,ep,ev,re,r,rp) local c=e:GetHandler() local g=eg:Filter(Card.IsSetCard,nil,0x26c) local rc=g:GetFirst() if not rc then return end local e1=Effect.CreateEffect(c) e1:SetDescription(aux.Stringid(id,2)) e1:SetProperty(EFFECT_FLAG_CLIENT_HINT) e1:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_SINGLE) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e1:SetRange(LOCATION_MZONE) e1:SetCode(EFFECT_DESTROY_REPLACE) e1:SetTarget(cid.reptg) rc:RegisterEffect(e1,true) if not rc:IsType(TYPE_EFFECT) then local e3=Effect.CreateEffect(c) e3:SetType(EFFECT_TYPE_SINGLE) e3:SetCode(EFFECT_ADD_TYPE) e3:SetValue(TYPE_EFFECT) e3:SetReset(RESET_EVENT+RESETS_STANDARD) rc:RegisterEffect(e3,true) end rc:RegisterFlagEffect(0,RESET_EVENT+RESETS_STANDARD,EFFECT_FLAG_CLIENT_HINT,1,0,aux.Stringid(id,2)) end function cid.reptg(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return c:IsReason(REASON_BATTLE+REASON_EFFECT) and not c:IsReason(REASON_REPLACE) and Duel.IsExistingMatchingCard(cid.repfilter,tp,LOCATION_GRAVE,0,1,nil) end if Duel.SelectEffectYesNo(tp,c,96) then Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESREPLACE) local g=Duel.SelectMatchingCard(tp,cid.repfilter,tp,LOCATION_GRAVE,0,1,1,nil) Duel.Remove(g,POS_FACEUP,REASON_EFFECT+REASON_REPLACE) return true else return false end end