Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Call of the Shadow NOVA
- local s, id = GetID(19822)
- function s.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)
- e1:SetTarget(s.activate)
- e1:SetOperation(s.activate)
- c:RegisterEffect(e1)
- -- GY effect
- local e2 = Effect.CreateEffect(c)
- e2:SetCategory(CATEGORY_TOHAND + CATEGORY_SEARCH)
- e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_F)
- e2:SetCode(EVENT_PHASE + PHASE_END)
- e2:SetRange(LOCATION_GRAVE)
- e2:SetCountLimit(1, id+100)
- e2:SetCondition(s.gyCondition)
- e2:SetTarget(s.gyTarget)
- e2:SetOperation(s.gyOperation)
- c:RegisterEffect(e2)
- end
- function s.filter(c)
- return c:IsSetCard(0x123) and c:IsAbleToHand()
- end
- function s.activate(e, tp, eg, ep, ev, re, r, rp)
- if not e:GetHandler():IsRelateToEffect(e) then
- return
- end
- local g = Duel.GetMatchingGroup(s.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)
- e:SetLabel(1) -- Set a flag to indicate the activation of the first effect
- end
- end
- function s.gyCondition(e, tp, eg, ep, ev, re, r, rp)
- return Duel.GetTurnPlayer() ~= tp and e:GetHandler():IsPreviousLocation(LOCATION_ONFIELD)
- end
- function s.gyTarget(e, tp, eg, ep, ev, re, r, rp, chk)
- if chk == 0 then
- return Duel.IsExistingMatchingCard(s.filter, tp, LOCATION_DECK, 0, 1, nil)
- end
- Duel.SetOperationInfo(0, CATEGORY_TOHAND, nil, 1, tp, LOCATION_DECK)
- end
- function s.gyOperation(e, tp, eg, ep, ev, re, r, rp)
- if not e:GetHandler():IsRelateToEffect(e) then
- return
- end
- if e:GetLabel() == 1 then
- e:SetLabel(0) -- Reset the flag
- return
- end
- local g = Duel.GetMatchingGroup(s.filter, 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
Advertisement
Add Comment
Please, Sign In to add comment