Skip to content

Commit a609681

Browse files
committed
"Ghost Mourner & Moonlit Chill" update
- Rescripted it to handle the scenario where multiple monsters are summoned at different timings in the previous chain, allowing the player to target any of them.
1 parent 405279e commit a609681

File tree

1 file changed

+59
-27
lines changed

1 file changed

+59
-27
lines changed

official/c52038441.lua

Lines changed: 59 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,84 @@
33
--Scripted by AlphaKretin
44
local s,id=GetID()
55
function s.initial_effect(c)
6+
local g=Group.CreateGroup()
7+
g:KeepAlive()
68
--Negate effects of a Special Summoned monster and inflict damage if it leaves the field this turn
79
local e1=Effect.CreateEffect(c)
810
e1:SetDescription(aux.Stringid(id,0))
11+
e1:SetCategory(CATEGORY_DISABLE)
912
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
10-
e1:SetCode(EVENT_SPSUMMON_SUCCESS)
1113
e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
14+
e1:SetCode(EVENT_CUSTOM+id)
1215
e1:SetRange(LOCATION_HAND)
1316
e1:SetCountLimit(1,id)
14-
e1:SetCost(s.negcost)
17+
e1:SetCost(aux.SelfDiscardCost)
1518
e1:SetTarget(s.negtg)
1619
e1:SetOperation(s.negop)
20+
e1:SetLabelObject(g)
1721
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)
1831
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())
2234
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
2551
end
2652
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)
3164
Duel.SetOperationInfo(0,CATEGORY_DISABLE,g,1,0,0)
3265
end
3366
function s.negop(e,tp,eg,ep,ev,re,r,rp)
3467
local c=e:GetHandler()
3568
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)
5284
end
5385
end
5486
function s.leaveop(e,tp,eg,ep,ev,re,r,rp)

0 commit comments

Comments
 (0)