Skip to content

Commit 517b75c

Browse files
committed
"Meklord Astro Dragon Triskelion" fix
- prevent script errors with an undefined group when effect to Equip a monster was activated - general script modernization
1 parent 7805280 commit 517b75c

File tree

1 file changed

+67
-68
lines changed

1 file changed

+67
-68
lines changed

official/c4837861.lua

Lines changed: 67 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,81 @@
44
local s,id=GetID()
55
function s.initial_effect(c)
66
c:EnableReviveLimit()
7-
--Equip
7+
--Must first be Special Summoned (from your hand) by banishing 3 "Meklord" monsters with different names from your GY
88
local e1=Effect.CreateEffect(c)
9-
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
10-
e1:SetCode(EVENT_ATTACK_ANNOUNCE)
11-
e1:SetCountLimit(1)
12-
e1:SetTarget(s.eqtg)
13-
e1:SetOperation(s.eqop)
9+
e1:SetDescription(aux.Stringid(id,0))
10+
e1:SetType(EFFECT_TYPE_FIELD)
11+
e1:SetCode(EFFECT_SPSUMMON_PROC)
12+
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
13+
e1:SetRange(LOCATION_HAND)
14+
e1:SetCondition(s.spcon)
15+
e1:SetTarget(s.sptg)
16+
e1:SetOperation(s.spop)
1417
c:RegisterEffect(e1)
15-
--Attack up to thrice
18+
--Look at your opponent's Extra Deck and equip 1 monster from it to this card
1619
local e2=Effect.CreateEffect(c)
17-
e2:SetType(EFFECT_TYPE_SINGLE)
18-
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
19-
e2:SetRange(LOCATION_MZONE)
20-
e2:SetCondition(s.atkcon)
21-
e2:SetCode(EFFECT_EXTRA_ATTACK_MONSTER)
22-
e2:SetValue(2)
20+
e2:SetDescription(aux.Stringid(id,1))
21+
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
22+
e2:SetCode(EVENT_ATTACK_ANNOUNCE)
23+
e2:SetCountLimit(1)
24+
e2:SetTarget(s.eqtg)
25+
e2:SetOperation(s.eqop)
2326
c:RegisterEffect(e2)
24-
--Special summon
27+
--Gains ATK equal to the combined ATK of the equipped monsters
2528
local e3=Effect.CreateEffect(c)
26-
e3:SetType(EFFECT_TYPE_FIELD)
27-
e3:SetCode(EFFECT_SPSUMMON_PROC)
28-
e3:SetProperty(EFFECT_FLAG_UNCOPYABLE)
29-
e3:SetRange(LOCATION_HAND)
30-
e3:SetCondition(s.spcon)
31-
e3:SetTarget(s.sptg)
32-
e3:SetOperation(s.spop)
29+
e3:SetType(EFFECT_TYPE_SINGLE)
30+
e3:SetCode(EFFECT_UPDATE_ATTACK)
31+
e3:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
32+
e3:SetRange(LOCATION_MZONE)
33+
e3:SetCondition(s.atkcon)
34+
e3:SetValue(s.atkval)
3335
c:RegisterEffect(e3)
34-
--increase ATK
36+
--While equipped with a Synchro Monster, this card can make up to 3 attacks on monsters during each Battle Phase
3537
local e4=Effect.CreateEffect(c)
3638
e4:SetType(EFFECT_TYPE_SINGLE)
39+
e4:SetCode(EFFECT_EXTRA_ATTACK_MONSTER)
3740
e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
3841
e4:SetRange(LOCATION_MZONE)
39-
e4:SetCode(EFFECT_UPDATE_ATTACK)
40-
e4:SetCondition(s.adcon)
41-
e4:SetValue(s.atkval)
42+
e4:SetCondition(s.extraatkcon)
43+
e4:SetValue(2)
4244
c:RegisterEffect(e4)
4345
end
4446
s.listed_series={SET_MEKLORD}
45-
function s.atkcon(e,tp,eg,ep,ev,re,r,rp)
46-
return e:GetHandler():GetEquipGroup():IsExists(Card.IsOriginalType,1,nil,TYPE_SYNCHRO)
47+
function s.spcostfilter(c)
48+
return c:IsSetCard(SET_MEKLORD) and c:IsMonster() and c:IsAbleToRemoveAsCost() and aux.SpElimFilter(c,true)
49+
end
50+
function s.rescon(sg,e,tp,mg)
51+
return aux.ChkfMMZ(1)(sg,e,tp,mg) and sg:GetClassCount(Card.GetCode)==#sg,sg:GetClassCount(Card.GetCode)~=#sg
52+
end
53+
function s.spcon(e,c)
54+
if c==nil then return true end
55+
local tp=c:GetControler()
56+
local rg=Duel.GetMatchingGroup(s.spcostfilter,tp,LOCATION_MZONE|LOCATION_GRAVE,0,nil)
57+
return #rg>=2 and aux.SelectUnselectGroup(rg,e,tp,3,3,s.rescon,0)
58+
end
59+
function s.sptg(e,tp,eg,ep,ev,re,r,rp,c)
60+
local rg=Duel.GetMatchingGroup(s.spcostfilter,tp,LOCATION_MZONE|LOCATION_GRAVE,0,nil)
61+
local g=aux.SelectUnselectGroup(rg,e,tp,3,3,s.rescon,1,tp,HINTMSG_REMOVE,nil,nil,true)
62+
if #g>0 then
63+
g:KeepAlive()
64+
e:SetLabelObject(g)
65+
return true
66+
end
67+
return false
68+
end
69+
function s.spop(e,tp,eg,ep,ev,re,r,rp,c)
70+
local g=e:GetLabelObject()
71+
if not g then return end
72+
Duel.Remove(g,POS_FACEUP,REASON_COST)
73+
g:DeleteGroup()
4774
end
4875
function s.eqfilter(c,tp)
4976
return c:CheckUniqueOnField(tp) and c:IsMonster() and not c:IsForbidden()
5077
end
5178
function s.eqtg(e,tp,eg,ep,ev,re,r,rp,chk)
52-
if chk==0 then return Duel.IsExistingMatchingCard(s.eqfilter,tp,0,LOCATION_EXTRA,1,nil,tp)
53-
and Duel.GetLocationCount(tp,LOCATION_SZONE)>0 end
54-
Duel.SetOperationInfo(0,CATEGORY_EQUIP,g,1,0,0)
79+
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_SZONE)>0
80+
and Duel.IsExistingMatchingCard(s.eqfilter,tp,0,LOCATION_EXTRA,1,nil,tp) end
81+
Duel.SetOperationInfo(0,CATEGORY_EQUIP,nil,1,tp,LOCATION_EXTRA)
5582
end
5683
function s.eqop(e,tp,eg,ep,ev,re,r,rp)
5784
local c=e:GetHandler()
@@ -60,57 +87,29 @@ function s.eqop(e,tp,eg,ep,ev,re,r,rp)
6087
if #g==0 then return end
6188
Duel.ConfirmCards(tp,Duel.GetFieldGroup(tp,0,LOCATION_EXTRA))
6289
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_EQUIP)
63-
local sg=g:Select(tp,1,1,nil):GetFirst()
64-
if Duel.Equip(tp,sg,c,true) then
90+
local ec=g:Select(tp,1,1,nil):GetFirst()
91+
if ec and Duel.Equip(tp,ec,c,true) then
6592
local e1=Effect.CreateEffect(c)
6693
e1:SetType(EFFECT_TYPE_SINGLE)
6794
e1:SetCode(EFFECT_EQUIP_LIMIT)
6895
e1:SetReset(RESET_EVENT|RESETS_STANDARD)
6996
e1:SetValue(s.eqlimit)
7097
e1:SetLabelObject(c)
71-
sg:RegisterEffect(e1)
72-
sg:RegisterFlagEffect(id,RESET_EVENT|RESETS_STANDARD,0,1)
98+
ec:RegisterEffect(e1)
99+
ec:RegisterFlagEffect(id,RESET_EVENT|RESETS_STANDARD,0,1)
73100
Duel.ShuffleExtra(1-tp)
74101
end
75102
end
76103
end
77104
function s.eqlimit(e,c)
78105
return c==e:GetLabelObject()
79106
end
80-
function s.spfilter(c)
81-
return c:IsSetCard(SET_MEKLORD) and c:IsMonster() and c:IsAbleToRemoveAsCost() and aux.SpElimFilter(c,true)
82-
end
83-
function s.rescon(sg,e,tp,mg)
84-
return aux.ChkfMMZ(1)(sg,e,tp,mg) and sg:GetClassCount(Card.GetCode)==#sg,sg:GetClassCount(Card.GetCode)~=#sg
85-
end
86-
function s.spcon(e,c)
87-
if c==nil then return true end
88-
local tp=c:GetControler()
89-
local rg=Duel.GetMatchingGroup(s.spfilter,tp,LOCATION_MZONE|LOCATION_GRAVE,0,nil)
90-
return Duel.GetLocationCount(tp,LOCATION_MZONE)>-3 and #rg>2 and aux.SelectUnselectGroup(rg,e,tp,3,3,s.rescon,0)
91-
end
92-
function s.sptg(e,tp,eg,ep,ev,re,r,rp,c)
93-
local rg=Duel.GetMatchingGroup(s.spfilter,tp,LOCATION_MZONE|LOCATION_GRAVE,0,nil)
94-
local g=aux.SelectUnselectGroup(rg,e,tp,3,3,s.rescon,1,tp,HINTMSG_REMOVE,nil,nil,true)
95-
if #g>0 then
96-
g:KeepAlive()
97-
e:SetLabelObject(g)
98-
return true
99-
end
100-
return false
101-
end
102-
function s.spop(e,tp,eg,ep,ev,re,r,rp,c)
103-
local g=e:GetLabelObject()
104-
if not g then return end
105-
Duel.Remove(g,POS_FACEUP,REASON_COST)
106-
g:DeleteGroup()
107-
end
108-
function s.efilter(c)
109-
return c:GetFlagEffect(id)~=0
110-
end
111-
function s.adcon(e,tp,eg,ep,ev,re,r,rp)
112-
return e:GetHandler():GetEquipGroup():IsExists(s.efilter,1,nil)
107+
function s.atkcon(e,tp,eg,ep,ev,re,r,rp)
108+
return e:GetHandler():GetEquipGroup():IsExists(Card.HasFlagEffect,1,nil,id)
113109
end
114110
function s.atkval(e,c)
115-
return e:GetHandler():GetEquipGroup():Filter(s.efilter,nil):GetSum(Card.GetAttack)
111+
return e:GetHandler():GetEquipGroup():Filter(Card.HasFlagEffect,nil,id):GetSum(Card.GetAttack)
112+
end
113+
function s.extraatkcon(e,tp,eg,ep,ev,re,r,rp)
114+
return e:GetHandler():GetEquipGroup():IsExists(Card.IsOriginalType,1,nil,TYPE_SYNCHRO)
116115
end

0 commit comments

Comments
 (0)