33-- fixed by MLD
44local s ,id = GetID ()
55function s .initial_effect (c )
6- -- activate
6+ -- Activate (Normal activation)
77 local e1 = Effect .CreateEffect (c )
88 e1 :SetType (EFFECT_TYPE_ACTIVATE )
99 e1 :SetCode (EVENT_FREE_CHAIN )
1010 c :RegisterEffect (e1 )
11- -- target
11+ -- Activate (Battle Timing)
1212 local e2 = Effect .CreateEffect (c )
1313 e2 :SetDescription (aux .Stringid (id ,0 ))
14- e2 :SetProperty (EFFECT_FLAG_CARD_TARGET )
1514 e2 :SetType (EFFECT_TYPE_QUICK_O )
15+ e2 :SetProperty (EFFECT_FLAG_CARD_TARGET )
1616 e2 :SetCode (EVENT_FREE_CHAIN )
1717 e2 :SetRange (LOCATION_SZONE )
18+ e2 :SetHintTiming (0 ,TIMING_BATTLE_PHASE |TIMING_BATTLE_START )
1819 e2 :SetCountLimit (1 )
19- e2 :SetCondition (s .atcon )
20- e2 :SetTarget (s .attg )
21- e2 :SetOperation (s .atop )
20+ e2 :SetCondition (s .forceoppattcon )
21+ e2 :SetTarget (s .forceoppatttg )
22+ e2 :SetOperation (s .forceoppattop )
2223 c :RegisterEffect (e2 )
23- -- prevent destroy
24+ -- Prevent a "Supreme King" monster(s) from being destroyed by 1 battle or card effect
2425 local e3 = Effect .CreateEffect (c )
2526 e3 :SetDescription (aux .Stringid (id ,1 ))
26- e3 :SetType (EFFECT_TYPE_TRIGGER_F + EFFECT_TYPE_FIELD )
27+ e3 :SetType (EFFECT_TYPE_QUICK_O )
2728 e3 :SetCode (EVENT_PRE_DAMAGE_CALCULATE )
2829 e3 :SetRange (LOCATION_SZONE )
2930 e3 :SetCountLimit (1 ,0 ,EFFECT_COUNT_CODE_SINGLE )
30- e3 :SetCondition (s .adescon )
31- e3 :SetOperation (s .adesop )
31+ e3 :SetCondition (s .batdescon )
32+ e3 :SetTarget (s .preventdestg )
33+ e3 :SetOperation (s .preventdesop )
3234 c :RegisterEffect (e3 )
33- local e4 = Effect .CreateEffect (c )
34- e4 :SetDescription (aux .Stringid (id ,1 ))
35- e4 :SetType (EFFECT_TYPE_QUICK_F )
35+ local e4 = e3 :Clone ()
3636 e4 :SetCode (EVENT_CHAINING )
37- e4 :SetRange (LOCATION_SZONE )
38- e4 :SetCountLimit (1 ,0 ,EFFECT_COUNT_CODE_SINGLE )
39- e4 :SetCondition (s .edescon )
40- e4 :SetTarget (s .edestg )
41- e4 :SetOperation (s .edesop )
37+ e4 :SetCondition (s .effdescon )
4238 c :RegisterEffect (e4 )
43- -- attack
39+ -- You can send this card from your field to the GY during your opponent's BP; all monsters they control must attack, if able
4440 local e5 = Effect .CreateEffect (c )
4541 e5 :SetDescription (aux .Stringid (id ,2 ))
4642 e5 :SetType (EFFECT_TYPE_QUICK_O )
4743 e5 :SetCode (EVENT_FREE_CHAIN )
4844 e5 :SetRange (LOCATION_SZONE )
49- e5 :SetCondition (s . atcon2 )
50- e5 :SetCost (s . atcost2 )
51- e5 :SetTarget (s .attg2 )
52- e5 :SetOperation (s .atop2 )
45+ e5 :SetCondition (function ( e , tp ) return Duel . IsTurnPlayer ( 1 - tp ) and Duel . IsBattlePhase () end )
46+ e5 :SetCost (Cost . SelfToGrave )
47+ e5 :SetTarget (s .tgforceattacktg )
48+ e5 :SetOperation (s .tgforceattackop )
5349 c :RegisterEffect (e5 )
5450end
55- s .listed_series = {0xf8 }
56- function s .atcon (e ,tp ,eg ,ev ,ep ,re ,r ,rp )
51+ s .listed_series = {SET_SUPREME_KING }
52+ function s .forceoppattcon (e ,tp ,eg ,ev ,ep ,re ,r ,rp )
5753 return Duel .IsTurnPlayer (1 - tp ) and Duel .IsBattlePhase ()
58- and Duel .IsExistingMatchingCard (aux .FaceupFilter (Card .IsSetCard ,0xf8 ),tp ,LOCATION_MZONE ,0 ,1 ,nil )
54+ and Duel .IsExistingMatchingCard (aux .FaceupFilter (Card .IsSetCard ,SET_SUPREME_KING ),tp ,LOCATION_MZONE ,0 ,1 ,nil )
5955end
60- function s .filter (c )
56+ function s .forceoppattfilter (c )
6157 return c :IsFaceup () and not c :IsHasEffect (EFFECT_CANNOT_ATTACK ) and not c :IsHasEffect (EFFECT_CANNOT_ATTACK_ANNOUNCE )
6258 and (c :IsAttackPos () or c :IsHasEffect (EFFECT_DEFENSE_ATTACK ))
6359end
64- function s .attg (e ,tp ,eg ,ev ,ep ,re ,r ,rp ,chk ,chkc )
65- if chkc then return chkc :IsControler (1 - tp ) and chkc :IsLocation (LOCATION_MZONE ) and s .filter (chkc ) end
66- if chk == 0 then return Duel .IsExistingTarget (s .filter ,tp ,0 ,LOCATION_MZONE ,1 ,nil ) end
67- Duel .SelectTarget (tp ,s .filter ,tp ,0 ,LOCATION_MZONE ,1 ,1 ,nil ,0 )
60+ function s .forceoppatttg (e ,tp ,eg ,ev ,ep ,re ,r ,rp ,chk ,chkc )
61+ if chkc then return chkc :IsControler (1 - tp ) and chkc :IsLocation (LOCATION_MZONE ) and s .forceoppattfilter (chkc ) end
62+ if chk == 0 then return Duel .IsExistingTarget (s .forceoppattfilter ,tp ,0 ,LOCATION_MZONE ,1 ,nil ) end
63+ Duel .SelectTarget (tp ,s .forceattackfilter ,tp ,0 ,LOCATION_MZONE ,1 ,1 ,nil ,0 )
6864end
69- function s .atop (e ,tp ,eg ,ev ,ep ,re ,r ,rp )
65+ function s .forceoppattop (e ,tp ,eg ,ev ,ep ,re ,r ,rp )
7066 if not e :GetHandler ():IsRelateToEffect (e ) then return end
7167 local g = Duel .GetTargetCards (e )
72- for tc in aux . Next ( g ) do
68+ for tc in g : Iter ( ) do
7369 local e1 = Effect .CreateEffect (e :GetHandler ())
7470 e1 :SetType (EFFECT_TYPE_SINGLE )
7571 e1 :SetCode (EFFECT_MUST_ATTACK )
76- e1 :SetReset (RESET_EVENT | RESETS_STANDARD | RESET_PHASE | PHASE_END )
72+ e1 :SetReset (RESETS_STANDARD_PHASE_END )
7773 tc :RegisterEffect (e1 )
78- if tc :GetAttackAnnouncedCount ()~= 0 then
74+ if tc :GetAttackAnnouncedCount ()> 0 then
7975 local e2 = e1 :Clone ()
8076 e2 :SetCode (EFFECT_EXTRA_ATTACK )
8177 e2 :SetValue (1 )
8278 tc :RegisterEffect (e2 )
8379 end
8480 end
8581end
86- function s .adescon (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
82+ function s .batdescon (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
8783 local tc = Duel .GetAttacker ()
88- if tc :IsControler (1 - tp ) then tc = Duel .GetAttackTarget () end
89- return tc and tc :IsSetCard (0xf8 ) and tc :IsRelateToBattle ()
90- end
91- function s .adesop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
92- local tc = Duel .GetAttacker ()
93- if tc :IsControler (1 - tp ) then tc = Duel .GetAttackTarget () end
94- if not e :GetHandler ():IsRelateToEffect (e ) or not tc or not tc :IsRelateToBattle () then return end
95- local e1 = Effect .CreateEffect (e :GetHandler ())
96- e1 :SetType (EFFECT_TYPE_SINGLE )
97- e1 :SetCode (EFFECT_INDESTRUCTABLE_BATTLE )
98- e1 :SetValue (1 )
99- e1 :SetReset (RESET_PHASE |PHASE_DAMAGE )
100- tc :RegisterEffect (e1 )
84+ local bc = tc :GetBattleTarget ()
85+ if tc :IsControler (1 - tp ) then
86+ tc ,bc = bc ,tc
87+ end
88+ if not tc or not bc or tc :IsControler (1 - tp ) or not tc :IsSetCard (SET_SUPREME_KING ) then return false end
89+ if tc :IsHasEffect (EFFECT_INDESTRUCTABLE_BATTLE ) then
90+ local tcind = {tc :GetCardEffect (EFFECT_INDESTRUCTABLE_BATTLE )}
91+ for _ ,te in ipairs (tcind ) do
92+ local f = te :GetValue ()
93+ if type (f )== ' function' then
94+ if f (te ,bc ) then return false end
95+ else return false end
96+ end
97+ end
98+ e :SetLabelObject (tc )
99+ if bc == Duel .GetAttackTarget () and bc :IsDefensePos () then return false end
100+ if bc :IsPosition (POS_FACEUP_DEFENSE ) and bc == Duel .GetAttacker () then
101+ if not bc :IsHasEffect (EFFECT_DEFENSE_ATTACK ) then return false end
102+ if bc :IsHasEffect (75372290 ) then
103+ if tc :IsAttackPos () then
104+ return bc :GetAttack ()> 0 and bc :GetAttack ()>= tc :GetAttack ()
105+ else
106+ return bc :GetAttack ()> tc :GetDefense ()
107+ end
108+ else
109+ if tc :IsAttackPos () then
110+ return bc :GetDefense ()> 0 and bc :GetDefense ()>= tc :GetAttack ()
111+ else
112+ return bc :GetDefense ()> tc :GetDefense ()
113+ end
114+ end
115+ else
116+ if tc :IsAttackPos () then
117+ return bc :GetAttack ()> 0 and bc :GetAttack ()>= tc :GetAttack ()
118+ else
119+ return bc :GetAttack ()> tc :GetDefense ()
120+ end
121+ end
101122end
102- function s .cdfilter (c ,tp )
103- return c :IsOnField () and c :IsControler (tp ) and c :IsSetCard (0xf8 )
123+ function s .effdesfilter (c ,tp )
124+ return c :IsOnField () and c :IsControler (tp ) and c :IsSetCard (SET_SUPREME_KING )
104125end
105- function s .edescon (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
126+ function s .effdescon (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
106127 local ex ,tg ,tc = Duel .GetOperationInfo (ev ,CATEGORY_DESTROY )
107- return ex and tg ~= nil and tc + tg :FilterCount (s .cdfilter ,nil ,tp )-# tg > 0
128+ if tg == nil then return end
129+ local g = tg :Filter (s .effdesfilter ,nil ,tp )
130+ g :KeepAlive ()
131+ e :SetLabelObject (g )
132+ return ex and tg ~= nil and tc + tg :FilterCount (s .effdesfilter ,nil ,tp )-# tg > 0
108133end
109- function s .edestg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
110- if chk == 0 then return true end
111- local ex ,tg ,tc = Duel .GetOperationInfo (ev ,CATEGORY_DESTROY )
112- local g = tg :Filter (s .cdfilter ,nil ,tp )
134+ function s .preventdestg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
135+ local g = e :GetLabelObject ()
136+ if chk == 0 then return g end
113137 Duel .SetTargetCard (g )
114138end
115- function s .edesop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
116- if not e :GetHandler (): IsRelateToEffect ( e ) then return end
139+ function s .preventdesop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
140+ local c = e :GetHandler ()
117141 local g = Duel .GetTargetCards (e )
118- if not g then return end
119- for tc in aux .Next (g ) do
120- local e1 = Effect .CreateEffect (e :GetHandler ())
121- e1 :SetType (EFFECT_TYPE_SINGLE )
122- e1 :SetCode (EFFECT_INDESTRUCTABLE_EFFECT )
123- e1 :SetValue (1 )
124- e1 :SetReset (RESET_CHAIN )
125- tc :RegisterEffect (e1 )
142+ if # g == 0 then return end
143+ for tc in g :Iter () do
144+ if tc :IsRelateToEffect (e ) then
145+ local e1 = Effect .CreateEffect (c )
146+ e1 :SetType (EFFECT_TYPE_SINGLE )
147+ if e :GetCode ()== EVENT_PRE_DAMAGE_CALCULATE then
148+ e1 :SetCode (EFFECT_INDESTRUCTABLE_BATTLE )
149+ e1 :SetValue (1 )
150+ e1 :SetReset (RESET_PHASE |PHASE_DAMAGE )
151+ else
152+ e1 :SetCode (EFFECT_INDESTRUCTABLE_EFFECT )
153+ e1 :SetValue (function (e ,te ) return re == te end )
154+ e1 :SetReset (RESET_CHAIN )
155+ end
156+ tc :RegisterEffect (e1 )
157+ end
126158 end
159+ g :DeleteGroup ()
127160end
128- function s .atcon2 (e ,tp ,eg ,ev ,ep ,re ,r ,rp )
129- return Duel .GetTurnPlayer ()~= tp and Duel .IsBattlePhase ()
130- end
131- function s .atcost2 (e ,tp ,eg ,ev ,ep ,re ,r ,rp ,chk )
132- if chk == 0 then return e :GetHandler ():IsAbleToGraveAsCost () end
133- Duel .SendtoGrave (e :GetHandler (),REASON_COST )
161+ function s .tgforceattacktg (e ,tp ,eg ,ev ,ep ,re ,r ,rp ,chk )
162+ if chk == 0 then return Duel .IsExistingMatchingCard (s .forceoppattfilter ,tp ,0 ,LOCATION_MZONE ,1 ,nil ) end
134163end
135- function s .attg2 (e ,tp ,eg ,ev ,ep ,re ,r ,rp ,chk )
136- if chk == 0 then return Duel .IsExistingMatchingCard (s .filter ,tp ,0 ,LOCATION_MZONE ,1 ,nil ) end
137- end
138- function s .atop2 (e ,tp ,eg ,ev ,ep ,re ,r ,rp )
139- local g = Duel .GetMatchingGroup (s .filter ,tp ,0 ,LOCATION_MZONE ,nil )
140- for tc in aux .Next (g ) do
164+ function s .tgforceattackop (e ,tp ,eg ,ev ,ep ,re ,r ,rp )
165+ local g = Duel .GetMatchingGroup (s .forceoppattfilter ,tp ,0 ,LOCATION_MZONE ,nil )
166+ for tc in g :Iter () do
141167 local e1 = Effect .CreateEffect (e :GetHandler ())
142168 e1 :SetType (EFFECT_TYPE_SINGLE )
143169 e1 :SetCode (EFFECT_MUST_ATTACK )
@@ -152,4 +178,4 @@ function s.atop2(e,tp,eg,ev,ep,re,r,rp)
152178 e2 :SetReset (RESET_PHASE |PHASE_BATTLE )
153179 e2 :SetTargetRange (0 ,1 )
154180 Duel .RegisterEffect (e2 ,tp )
155- end
181+ end
0 commit comments