33local s ,id = GetID ()
44function s .initial_effect (c )
55 aux .AddSkillProcedure (c ,1 ,false ,s .flipcon ,s .flipop )
6- -- Checks if Chimera was Fusion Summoned
7- local e1 = Effect .CreateEffect (c )
8- e1 :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS )
9- e1 :SetCode (EVENT_STARTUP )
10- e1 :SetRange (0x5f )
11- e1 :SetCountLimit (1 )
12- e1 :SetOperation (s .op )
13- c :RegisterEffect (e1 )
14- aux .GlobalCheck (s ,function ()
6+ -- Checks if Chimera was Fusion Summoned
7+ local e1 = Effect .CreateEffect (c )
8+ e1 :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS )
9+ e1 :SetCode (EVENT_STARTUP )
10+ e1 :SetRange (0x5f )
11+ e1 :SetCountLimit (1 )
12+ e1 :SetOperation (s .op )
13+ c :RegisterEffect (e1 )
14+ aux .GlobalCheck (s ,function ()
1515 s [0 ]= 0
1616 s [1 ]= 0
1717 local ge1 = Effect .CreateEffect (c )
@@ -20,163 +20,93 @@ function s.initial_effect(c)
2020 ge1 :SetOperation (s .checkop )
2121 Duel .RegisterEffect (ge1 ,0 )
2222 aux .AddValuesReset (function ()
23- s [0 ]= 0
24- s [1 ]= 0
23+ s [0 ]= 0
24+ s [1 ]= 0
2525 end )
2626 end )
2727end
28+ s .listed_names = {4796100 } -- "Chimera the Flying Mythical Beast"
29+ s .listed_series = {SET_PHANTOM_BEAST }
2830function s .op (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
29- local e1 = Effect .CreateEffect (e :GetHandler ())
30- e1 :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS )
31- e1 :SetCode (EVENT_PHASE + PHASE_END )
32- e1 :SetCountLimit (1 )
33- e1 :SetCondition (s .flipcon2 )
34- e1 :SetOperation (s .flipop2 )
35- Duel .RegisterEffect (e1 ,tp )
31+ local e1 = Effect .CreateEffect (e :GetHandler ())
32+ e1 :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS )
33+ e1 :SetCode (EVENT_PHASE + PHASE_END )
34+ e1 :SetCountLimit (1 )
35+ e1 :SetCondition (s .flipcon2 )
36+ e1 :SetOperation (s .flipop2 )
37+ Duel .RegisterEffect (e1 ,tp )
3638end
37- s .listed_names = {4796100 }
3839function s .checkop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
39- local tc = eg :GetFirst ()
40- for tc in aux .Next (eg ) do
41- if tc :IsCode (4796100 ) and tc :IsSummonType (SUMMON_TYPE_FUSION ) then
42- local p = tc :GetSummonPlayer ()
43- s [p ]= s [p ]+ 1
40+ for tc in eg :Iter () do
41+ if tc :IsCode (4796100 ) and tc :IsSummonType (SUMMON_TYPE_FUSION ) then
42+ local p = tc :GetSummonPlayer ()
43+ s [p ]= s [p ]+ 1
4444 end
4545 end
4646end
47+ function s .costfilter (c ,e ,tp ,eg ,ep ,ev ,re ,r ,rp )
48+ if not c :IsDiscardable () then return false end
49+ local params = {fusfilter = aux .FilterBoolFunction (Card .IsCode ,4796100 ),extrafil = s .fextra (c )}
50+ return Fusion .SummonEffTG (params )(e ,tp ,eg ,ep ,ev ,re ,r ,rp ,0 )
51+ end
52+ function s .cost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
53+ if chk == 0 then return Duel .IsExistingMatchingCard (s .costfilter ,tp ,LOCATION_HAND ,0 ,1 ,nil ,e ,tp ,eg ,ep ,ev ,re ,r ,rp ) end
54+ Duel .DiscardHand (tp ,s .costfilter ,1 ,1 ,REASON_COST |REASON_DISCARD ,nil ,e ,tp ,eg ,ep ,ev ,re ,r ,rp )
55+ end
4756function s .flipcon (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
48- -- condition
49- return aux .CanActivateSkill (tp ) and s .fusTarget (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,0 ) and Duel .GetFlagEffect (tp ,id )== 0
57+ return aux .CanActivateSkill (tp ) and s .cost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,0 ) and not Duel .HasFlagEffect (tp ,id )
5058end
5159function s .flipop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
5260 Duel .Hint (HINT_SKILL_FLIP ,tp ,id |(1 << 32 ))
5361 Duel .Hint (HINT_CARD ,tp ,id )
54- -- fusion
55- local g2 = s .fusTarget (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,0 )
56- Duel .RegisterFlagEffect (tp ,id ,RESET_PHASE + PHASE_END ,0 ,1 )
57- s .fusTarget (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,1 )
58- local chkf = tp
59- local mg1 = Duel .GetFusionMaterial (tp ):Filter (aux .NOT (Card .IsImmuneToEffect ),nil ,e )
60- local sg1 = Duel .GetMatchingGroup (s .fusfilter ,tp ,LOCATION_EXTRA ,0 ,nil ,e ,tp ,mg1 ,nil ,chkf )
61- local mg2 = nil
62- local sg2 = nil
63- local ce = Duel .GetChainMaterial (tp )
64- if ce ~= nil then
65- local fgroup = ce :GetTarget ()
66- mg2 = fgroup (ce ,e ,tp )
67- local mf = ce :GetValue ()
68- sg2 = Duel .GetMatchingGroup (s .fusfilter ,tp ,LOCATION_EXTRA ,0 ,nil ,e ,tp ,mg2 ,mf ,chkf )
69- end
70- if sg1 :GetCount ()> 0 or (sg2 ~= nil and sg2 :GetCount ()> 0 ) then
71- local sg = sg1 :Clone ()
72- if sg2 then sg :Merge (sg2 ) end
73- Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_SPSUMMON )
74- local tg = sg :Select (tp ,1 ,1 ,nil )
75- local tc = tg :GetFirst ()
76- if sg1 :IsContains (tc ) and (sg2 == nil or not sg2 :IsContains (tc ) or not Duel .SelectYesNo (tp ,ce :GetDescription ())) then
77- local mat1 = Duel .SelectFusionMaterial (tp ,tc ,mg1 ,nil ,chkf )
78- tc :SetMaterial (mat1 )
79- Duel .SendtoGrave (mat1 ,REASON_EFFECT + REASON_MATERIAL + REASON_FUSION )
80- Duel .BreakEffect ()
81- Duel .SpecialSummon (tc ,SUMMON_TYPE_FUSION ,tp ,tp ,false ,false ,POS_FACEUP )
82- else
83- local mat2 = Duel .SelectFusionMaterial (tp ,tc ,mg2 ,nil ,chkf )
84- local fop = ce :GetOperation ()
85- fop (ce ,e ,tp ,tc ,mat2 )
86- end
87- tc :CompleteProcedure ()
88- end
62+ local params = {fusfilter = aux .FilterBoolFunction (Card .IsCode ,4796100 ),extrafil = s .fextra (c )}
63+ -- You can only apply this effect once per turn
64+ Duel .RegisterFlagEffect (tp ,id ,RESET_PHASE |PHASE_END ,0 ,1 )
65+ -- Discard 1 card
66+ s .cost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,1 )
67+ -- Fusion Summon "Chimera the King of Mythical Beasts", using monsters from your hand or field as material
68+ Fusion .SummonEffTG (params )(e ,tp ,eg ,ep ,ev ,re ,r ,rp ,1 )
69+ Fusion .SummonEffOP (params )(e ,tp ,eg ,ep ,ev ,re ,r ,rp )
8970end
90- -- fusion Summon Chimera
91- function s .cfilter (c ,e ,tp )
92- if not c :IsDiscardable () then return false end
93- local chkf = tp
94- local mg1 = Duel .GetFusionMaterial (tp )
95- local res = Duel .IsExistingMatchingCard (s .fusfilter ,tp ,LOCATION_EXTRA ,0 ,1 ,c ,e ,tp ,mg1 - c ,nil ,chkf )
96- if not res then
97- local ce = Duel .GetChainMaterial (tp )
98- if ce ~= nil then
99- local fgroup = ce :GetTarget ()
100- local mg2 = fgroup (ce ,e ,tp )
101- local mf = ce :GetValue ()
102- res = Duel .IsExistingMatchingCard (s .fusfilter ,tp ,LOCATION_EXTRA ,0 ,1 ,c ,e ,tp ,mg2 - c ,mf ,chkf )
103- end
71+ function s .fextra (exc )
72+ return function (e ,tp ,mg )
73+ return nil ,s .fcheck (exc )
10474 end
105- return res
106- end
107- function s .fusfilter (c ,e ,tp ,m ,f ,chkf )
108- return c :IsType (TYPE_FUSION ) and (not f or f (c )) and c :IsCode (4796100 )
109- and c :IsCanBeSpecialSummoned (e ,SUMMON_TYPE_FUSION ,tp ,false ,false ) and c :CheckFusionMaterial (m ,nil ,chkf )
11075end
111- function s .fusTarget ( e , tp , eg , ep , ev , re , r , rp , chk )
112- if chk == 0 then return Duel . IsExistingMatchingCard ( s . cfilter , tp ,LOCATION_HAND , 0 , 1 , nil , e , tp ) end
113- Duel . DiscardHand ( tp , s . cfilter , 1 , 1 , REASON_COST + REASON_DISCARD , nil , e , tp )
114- Duel . SetOperationInfo ( 0 , CATEGORY_SPECIAL_SUMMON , nil , 1 , tp , LOCATION_EXTRA )
76+ function s .fcheck ( exc )
77+ return function ( tp ,sg , fc )
78+ return not ( exc and sg : IsContains ( exc ) )
79+ end
11580end
11681-- Add "Phantom Beast" card to hand
11782function s .thfilter (c )
118- return c :IsSetCard (0x1b ) and c :IsAbleToHand ()
119- end
120- function s .thcon (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
121- return (s [tp ]> 0 or s [1 - tp ]> 0 ) and Duel .IsExistingMatchingCard (s .thfilter ,tp ,LOCATION_GRAVE ,0 ,1 ,nil )
122- end
123- function s .thop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
124- if Duel .SelectYesNo (tp ,aux .Stringid (id ,0 )) then
125- local tc = Duel .SelectMatchingCard (tp ,s .thfilter ,tp ,LOCATION_GRAVE ,0 ,1 ,1 ,nil )
126- if tc then
127- Duel .SendtoHand (tc ,tp ,REASON_EFFECT )
128- Duel .ConfirmCards (1 - tp ,tc )
129- end
130- end
83+ return c :IsSetCard (SET_PHANTOM_BEAST ) and c :IsMonster () and c :IsAbleToHand ()
13184end
13285function s .flipcon2 (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
133- return (s [tp ]> 0 or s [1 - tp ]> 0 ) and Duel .IsExistingMatchingCard (s .thfilter ,tp ,LOCATION_GRAVE ,0 ,1 ,nil ) and Duel .GetFlagEffect ( tp ,id + 100 )== 0
86+ return (s [tp ]> 0 or s [1 - tp ]> 0 ) and Duel .IsExistingMatchingCard (s .thfilter ,tp ,LOCATION_GRAVE ,0 ,1 ,nil ) and Duel .GetTurnPlayer () == tp and not Duel . HasFlagEffect ( tp ,id + 100 )
13487end
13588function s .flipop2 (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
89+ -- Add 1 "Phantom Beast" monster from your GY to your hand
13690 if Duel .SelectYesNo (tp ,aux .Stringid (id ,0 )) then
137- Duel .RegisterFlagEffect (tp ,id + 100 ,RESET_PHASE + PHASE_END ,0 ,1 )
91+ Duel .RegisterFlagEffect (tp ,id + 100 ,RESET_PHASE | PHASE_END ,0 ,1 )
13892 Duel .Hint (HINT_SKILL_FLIP ,tp ,id |(1 << 32 ))
13993 Duel .Hint (HINT_CARD ,tp ,id )
140- local tc = Duel .SelectMatchingCard (tp ,s .thfilter ,tp ,LOCATION_GRAVE ,0 ,1 ,1 ,nil )
141- if tc then
142- Duel .SendtoHand (tc ,tp ,REASON_EFFECT )
143- Duel .ConfirmCards (1 - tp ,tc )
144- end
145- end
146- -- Fusion Summon Chimera
147- if not (Duel .IsMainPhase () and Duel .GetTurnPlayer ()== tp ) then return end
148- local g2 = s .fusTarget (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,0 )
149- Duel .RegisterFlagEffect (tp ,id ,RESET_PHASE + PHASE_END ,0 ,1 )
150- s .fusTarget (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,1 )
151- local chkf = tp
152- local mg1 = Duel .GetFusionMaterial (tp ):Filter (aux .NOT (Card .IsImmuneToEffect ),nil ,e )
153- local sg1 = Duel .GetMatchingGroup (s .fusfilter ,tp ,LOCATION_EXTRA ,0 ,nil ,e ,tp ,mg1 ,nil ,chkf )
154- local mg2 = nil
155- local sg2 = nil
156- local ce = Duel .GetChainMaterial (tp )
157- if ce ~= nil then
158- local fgroup = ce :GetTarget ()
159- mg2 = fgroup (ce ,e ,tp )
160- local mf = ce :GetValue ()
161- sg2 = Duel .GetMatchingGroup (s .fusfilter ,tp ,LOCATION_EXTRA ,0 ,nil ,e ,tp ,mg2 ,mf ,chkf )
162- end
163- if sg1 :GetCount ()> 0 or (sg2 ~= nil and sg2 :GetCount ()> 0 ) then
164- local sg = sg1 :Clone ()
165- if sg2 then sg :Merge (sg2 ) end
166- Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_SPSUMMON )
167- local tg = sg :Select (tp ,1 ,1 ,nil )
168- local tc = tg :GetFirst ()
169- if sg1 :IsContains (tc ) and (sg2 == nil or not sg2 :IsContains (tc ) or not Duel .SelectYesNo (tp ,ce :GetDescription ())) then
170- local mat1 = Duel .SelectFusionMaterial (tp ,tc ,mg1 ,nil ,chkf )
171- tc :SetMaterial (mat1 )
172- Duel .SendtoGrave (mat1 ,REASON_EFFECT + REASON_MATERIAL + REASON_FUSION )
173- Duel .BreakEffect ()
174- Duel .SpecialSummon (tc ,SUMMON_TYPE_FUSION ,tp ,tp ,false ,false ,POS_FACEUP )
175- else
176- local mat2 = Duel .SelectFusionMaterial (tp ,tc ,mg2 ,nil ,chkf )
177- local fop = ce :GetOperation ()
178- fop (ce ,e ,tp ,tc ,mat2 )
94+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_ATOHAND )
95+ local g = Duel .SelectMatchingCard (tp ,s .thfilter ,tp ,LOCATION_GRAVE ,0 ,1 ,1 ,nil )
96+ if # g > 0 then
97+ Duel .HintSelection (g ,true )
98+ Duel .SendtoHand (g ,tp ,REASON_EFFECT )
99+ Duel .ConfirmCards (1 - tp ,g )
179100 end
180- tc :CompleteProcedure ()
181101 end
102+ -- Fusion Summon effect
103+ if not (Duel .IsMainPhase () and aux .CanActivateSkill (tp ) and Duel .GetTurnPlayer ()== tp and s .cost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,0 )) then return end
104+ local params = {fusfilter = aux .FilterBoolFunction (Card .IsCode ,4796100 ),extrafil = s .fextra (c )}
105+ -- You can only apply this effect once per turn
106+ Duel .RegisterFlagEffect (tp ,id ,RESET_PHASE |PHASE_END ,0 ,1 )
107+ -- Discard 1 card
108+ s .cost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,1 )
109+ -- Fusion Summon "Chimera the King of Mythical Beasts", using monsters from your hand or field as material
110+ Fusion .SummonEffTG (params )(e ,tp ,eg ,ep ,ev ,re ,r ,rp ,1 )
111+ Fusion .SummonEffOP (params )(e ,tp ,eg ,ep ,ev ,re ,r ,rp )
182112end
0 commit comments