|
3 | 3 | --Scripted by AlphaKretin |
4 | 4 | local s,id=GetID() |
5 | 5 | function s.initial_effect(c) |
| 6 | + local g=Group.CreateGroup() |
| 7 | + g:KeepAlive() |
6 | 8 | --Negate effects of a Special Summoned monster and inflict damage if it leaves the field this turn |
7 | 9 | local e1=Effect.CreateEffect(c) |
8 | 10 | e1:SetDescription(aux.Stringid(id,0)) |
| 11 | + e1:SetCategory(CATEGORY_DISABLE) |
9 | 12 | e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O) |
10 | | - e1:SetCode(EVENT_SPSUMMON_SUCCESS) |
11 | 13 | e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY) |
| 14 | + e1:SetCode(EVENT_CUSTOM+id) |
12 | 15 | e1:SetRange(LOCATION_HAND) |
13 | 16 | e1:SetCountLimit(1,id) |
14 | | - e1:SetCost(s.negcost) |
| 17 | + e1:SetCost(aux.SelfDiscardCost) |
15 | 18 | e1:SetTarget(s.negtg) |
16 | 19 | e1:SetOperation(s.negop) |
| 20 | + e1:SetLabelObject(g) |
17 | 21 | c:RegisterEffect(e1) |
| 22 | + --Register summons |
| 23 | + local e1a=Effect.CreateEffect(c) |
| 24 | + e1a:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) |
| 25 | + e1a:SetCode(EVENT_SPSUMMON_SUCCESS) |
| 26 | + e1a:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) |
| 27 | + e1a:SetRange(LOCATION_ALL) |
| 28 | + e1a:SetLabelObject(e1) |
| 29 | + e1a:SetOperation(s.regop) |
| 30 | + c:RegisterEffect(e1a) |
18 | 31 | end |
19 | | -function s.negcost(e,tp,eg,ep,ev,re,r,rp,chk) |
20 | | - if chk==0 then return e:GetHandler():IsDiscardable() end |
21 | | - Duel.SendtoGrave(e:GetHandler(),REASON_COST|REASON_DISCARD) |
| 32 | +function s.cfilter(c,e,tp) |
| 33 | + return c:IsSummonPlayer(1-tp) and c:IsCanBeEffectTarget(e) and c:IsLocation(LOCATION_MZONE) and (c:HasNonZeroAttack() or c:IsNegatableMonster()) |
22 | 34 | end |
23 | | -function s.negfilter(c,p,eg) |
24 | | - return c:IsSummonPlayer(p) and eg:IsContains(c) and (c:HasNonZeroAttack() or c:IsNegatableMonster()) |
| 35 | +function s.regop(e,tp,eg,ep,ev,re,r,rp) |
| 36 | + local tg=eg:Filter(s.cfilter,nil,e,tp) |
| 37 | + if #tg>0 then |
| 38 | + for tc in tg:Iter() do |
| 39 | + tc:RegisterFlagEffect(id,RESET_CHAIN,0,1) |
| 40 | + end |
| 41 | + local g=e:GetLabelObject():GetLabelObject() |
| 42 | + if Duel.GetCurrentChain()==0 then g:Clear() end |
| 43 | + g:Merge(tg) |
| 44 | + g:Remove(function(c) return c:GetFlagEffect(id)==0 end,nil) |
| 45 | + e:GetLabelObject():SetLabelObject(g) |
| 46 | + if Duel.GetFlagEffect(tp,id)==0 then |
| 47 | + Duel.RegisterFlagEffect(tp,id,RESET_CHAIN,0,1) |
| 48 | + Duel.RaiseEvent(eg,EVENT_CUSTOM+id,e,0,tp,tp,0) |
| 49 | + end |
| 50 | + end |
25 | 51 | end |
26 | 52 | function s.negtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc) |
27 | | - if chkc then return chkc:IsLocation(LOCATION_MZONE) and s.negfilter(chkc,1-tp,eg) end |
28 | | - if chk==0 then return Duel.IsExistingTarget(s.negfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,nil,1-tp,eg) end |
29 | | - Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_NEGATE) |
30 | | - local g=Duel.SelectTarget(tp,s.negfilter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil,1-tp,eg) |
| 53 | + local g=e:GetLabelObject():Filter(s.cfilter,nil,e,tp) |
| 54 | + if chkc then return g:IsContains(chkc) and s.cfilter(chkc,e,tp) end |
| 55 | + if chk==0 then return #g>0 end |
| 56 | + local tg=nil |
| 57 | + if #g>1 then |
| 58 | + Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_NEGATE) |
| 59 | + tg=g:Select(tp,1,1,nil) |
| 60 | + else |
| 61 | + tg=g |
| 62 | + end |
| 63 | + Duel.SetTargetCard(tg) |
31 | 64 | Duel.SetOperationInfo(0,CATEGORY_DISABLE,g,1,0,0) |
32 | 65 | end |
33 | 66 | function s.negop(e,tp,eg,ep,ev,re,r,rp) |
34 | 67 | local c=e:GetHandler() |
35 | 68 | local tc=Duel.GetFirstTarget() |
36 | | - if tc:IsRelateToEffect(e) then |
37 | | - if tc:IsNegatableMonster() then |
38 | | - tc:NegateEffects(c,RESET_PHASE|PHASE_END) |
39 | | - end |
40 | | - if tc:IsFaceup() then |
41 | | - local fid=c:GetFieldID() |
42 | | - tc:RegisterFlagEffect(id,RESET_EVENT|RESET_MSCHANGE|RESET_OVERLAY|RESET_TURN_SET|RESET_PHASE|PHASE_END,0,1,fid) |
43 | | - local e1=Effect.CreateEffect(c) |
44 | | - e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) |
45 | | - e1:SetCode(EVENT_LEAVE_FIELD) |
46 | | - e1:SetLabel(fid) |
47 | | - e1:SetLabelObject(tc) |
48 | | - e1:SetOperation(s.leaveop) |
49 | | - e1:SetReset(RESET_PHASE|PHASE_END) |
50 | | - Duel.RegisterEffect(e1,tp) |
51 | | - end |
| 69 | + if not tc:IsRelateToEffect(e) then return end |
| 70 | + if tc:IsNegatableMonster() then |
| 71 | + tc:NegateEffects(c,RESET_PHASE|PHASE_END) |
| 72 | + end |
| 73 | + if tc:IsFaceup() then |
| 74 | + local fid=c:GetFieldID() |
| 75 | + tc:RegisterFlagEffect(id,RESET_EVENT|RESET_MSCHANGE|RESET_OVERLAY|RESET_TURN_SET|RESET_PHASE|PHASE_END,0,1,fid) |
| 76 | + local e1=Effect.CreateEffect(c) |
| 77 | + e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) |
| 78 | + e1:SetCode(EVENT_LEAVE_FIELD) |
| 79 | + e1:SetLabel(fid) |
| 80 | + e1:SetLabelObject(tc) |
| 81 | + e1:SetOperation(s.leaveop) |
| 82 | + e1:SetReset(RESET_PHASE|PHASE_END) |
| 83 | + Duel.RegisterEffect(e1,tp) |
52 | 84 | end |
53 | 85 | end |
54 | 86 | function s.leaveop(e,tp,eg,ep,ev,re,r,rp) |
|
0 commit comments