--created by ZEN, coded by Lyris local s,id=GetID() function s.initial_effect(c) local e1=Effect.CreateEffect(c) e1:Desc(0) e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetCode(EVENT_FREE_CHAIN) c:RegisterEffect(e1) local e2=Effect.CreateEffect(c) e2:Desc(1) e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) e2:SetCode(EVENT_SPSUMMON_SUCCESS) e2:SetRange(LOCATION_SZONE) e2:SetCountLimit(1,id) e2:SetCategory(CATEGORY_TOHAND) e2:SetCondition(function(e,tp,eg) return eg:IsExists(function(tc) return tc:GetSummonPlayer()~=tp end,1,nil) end) e2:SetCost(s.cost) e2:SetTarget(s.thtg) e2:SetOperation(s.thop) c:RegisterEffect(e2) local e3=Effect.CreateEffect(c) e3:Desc(2) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) e3:SetCode(EVENT_TO_GRAVE) e3:SetProperty(EFFECT_FLAG_CARD_TARGET) e3:SetCategory(CATEGORY_TOHAND) e3:SetCondition(s.con) e3:SetTarget(s.target) e3:SetOperation(s.operation) c:RegisterEffect(e3) end function s.cfilter(c) return c:IsFaceup() and c:IsSetCard(0xd7c) and c:GetSequence()<5 and c:IsAbleToGraveAsCost() end function s.cost(e,tp,eg,ep,ev,re,r,rp,chk) local c=e:GetHandler() if chk==0 then return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_SZONE,0,1,c) end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE) local g=Duel.SelectMatchingCard(tp,s.cfilter,tp,LOCATION_SZONE,0,1,1,c) if #g>0 then Duel.SendtoGrave(g,REASON_COST) end end function s.filter(c,tp) return c:GetSummonPlayer()~=tp end function s.thtg(e,tp,eg,ep,ev,re,r,rp,chk) local g=eg:Filter(s.filter,nil,tp) if chk==0 then return #g>0 and g:IsExists(Card.IsAbleToHand,1,nil) end Duel.SetTargetCard(eg) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,#g,0,0) end function s.thop(e,tp,eg,ep,ev,re,r,rp) if not e:GetHandler():IsRelateToEffect(e) then return end local g=eg:Filter(s.filter,nil,tp):Filter(Card.IsRelateToEffect,nil,e) if #g<0 then return end Duel.SendtoHand(g,nil,REASON_EFFECT) end function s.con(e,tp,eg,ep,ev,re,r,rp) return e:GetHandler():IsReason(REASON_COST) and e:GetHandler():IsPreviousLocation(LOCATION_SZONE) and e:GetHandler():GetPreviousSequence()<5 and re:IsHasType(0x7e0) and re:IsActiveType(TYPE_MONSTER) and re:GetHandler():IsSetCard(0xd7c) end function s.thfilter(c) return c:IsType(TYPE_SPELL+TYPE_TRAP) and c:IsSetCard(0xd7c) and c:IsAbleToHand() and not c:IsCode(id) end function s.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc) if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp) and s.thfilter(chkc) end if chk==0 then return true end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_ATOHAND) local g=Duel.SelectTarget(tp,aux.NecroValleyFilter(s.thfilter),tp,LOCATION_GRAVE,0,1,1,nil) Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,#g,0,0) end function s.operation(e,tp,eg,ep,ev,re,r,rp) local tc=Duel.GetFirstTarget() if tc and tc:IsRelateToEffect(e) then Duel.SendtoHand(tc,nil,REASON_EFFECT) end end