1+ -- リリーフカー・D
2+ -- Chaos Emperor Dragon - Envoy of the End
3+ -- scripted by YoshiDuels
4+ local s ,id = GetID ()
5+ function s .initial_effect (c )
6+ -- Special Summon procedure
7+ local e1 = Effect .CreateEffect (c )
8+ e1 :SetDescription (aux .Stringid (id ,0 ))
9+ e1 :SetType (EFFECT_TYPE_FIELD )
10+ e1 :SetProperty (EFFECT_FLAG_UNCOPYABLE )
11+ e1 :SetCode (EFFECT_SPSUMMON_PROC )
12+ e1 :SetRange (LOCATION_HAND )
13+ e1 :SetCondition (s .spcon )
14+ e1 :SetTarget (s .sptg )
15+ e1 :SetOperation (s .spop )
16+ e1 :SetValue (1 )
17+ c :RegisterEffect (e1 )
18+ -- to grave
19+ local e2 = Effect .CreateEffect (c )
20+ e2 :SetDescription (aux .Stringid (id ,0 ))
21+ e2 :SetCategory (CATEGORY_TOGRAVE |CATEGORY_DAMAGE )
22+ e2 :SetType (EFFECT_TYPE_IGNITION )
23+ e2 :SetRange (LOCATION_MZONE )
24+ e2 :SetCountLimit (1 )
25+ e2 :SetCondition (s .tgcon )
26+ e2 :SetCost (s .tgcost )
27+ e2 :SetTarget (s .tgtg )
28+ e2 :SetOperation (s .tgop )
29+ c :RegisterEffect (e2 )
30+ aux .GlobalCheck (s ,function ()
31+ local ge1 = Effect .CreateEffect (c )
32+ ge1 :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS )
33+ ge1 :SetCode (EVENT_CHAIN_SOLVED )
34+ ge1 :SetOperation (s .checkop )
35+ Duel .RegisterEffect (ge1 ,0 )
36+ end )
37+ end
38+ function s .checkop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
39+ if re :GetHandler ():IsControler (rp ) then
40+ Duel .RegisterFlagEffect (rp ,id ,RESET_PHASE |PHASE_END ,0 ,1 )
41+ end
42+ end
43+ function s .spcostfilter (c ,att )
44+ return c :IsAttribute (att ) and c :IsAbleToDeck ()
45+ end
46+ function s .spcon (e ,c )
47+ if c == nil then return true end
48+ local tp = c :GetControler ()
49+ return Duel .GetLocationCount (tp ,LOCATION_MZONE )> 0
50+ and Duel .IsExistingMatchingCard (s .spcostfilter ,tp ,LOCATION_GRAVE ,0 ,1 ,nil ,ATTRIBUTE_DARK )
51+ and Duel .IsExistingMatchingCard (s .spcostfilter ,tp ,LOCATION_GRAVE ,0 ,1 ,nil ,ATTRIBUTE_LIGHT )
52+ end
53+ function s .sptg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,c )
54+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_DISCARD )
55+ local g = Duel .GetMatchingGroup (s .spcostfilter ,tp ,LOCATION_GRAVE ,0 ,nil ,ATTRIBUTE_DARK )
56+ local sg = aux .SelectUnselectGroup (g ,e ,tp ,1 ,1 ,aux .ChkfMMZ (1 ),1 ,tp ,HINTMSG_TODECK ,nil ,nil ,true )
57+ local g2 = Duel .GetMatchingGroup (s .spcostfilter ,tp ,LOCATION_GRAVE ,0 ,nil ,ATTRIBUTE_LIGHT )
58+ local sg2 = aux .SelectUnselectGroup (g2 ,e ,tp ,1 ,1 ,aux .ChkfMMZ (1 ),1 ,tp ,HINTMSG_TODECK ,nil ,nil ,true )
59+ sg :Merge (sg2 )
60+ if # sg > 1 then
61+ sg :KeepAlive ()
62+ e :SetLabelObject (sg )
63+ return true
64+ end
65+ return false
66+ end
67+ function s .spop (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,c )
68+ local g = e :GetLabelObject ()
69+ if not g then return end
70+ Duel .HintSelection (g )
71+ Duel .SendtoDeck (g ,nil ,SEQ_DECKBOTTOM ,REASON_COST )
72+ local og = Duel .GetOperatedGroup ():Filter (Card .IsLocation ,nil ,LOCATION_DECK )
73+ if # og > 0 then Duel .SortDeckbottom (tp ,tp ,# og ) end
74+ g :DeleteGroup ()
75+ end
76+ function s .tgcon (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
77+ return e :GetHandler ():GetSummonType ()== SUMMON_TYPE_SPECIAL + 1 and Duel .GetFlagEffect (tp ,id )== 0
78+ end
79+ function s .tgcost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
80+ if chk == 0 then return Duel .CheckLPCost (tp ,1000 ) end
81+ end
82+ function s .tgtg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
83+ local g = Duel .GetFieldGroup (tp ,LOCATION_HAND |LOCATION_ONFIELD ,LOCATION_HAND |LOCATION_ONFIELD )
84+ if chk == 0 then return # g > 0 end
85+ Duel .SetOperationInfo (0 ,CATEGORY_TOGRAVE ,g ,# g ,0 ,0 )
86+ Duel .SetOperationInfo (0 ,CATEGORY_DAMAGE ,0 ,0 ,1 - tp ,300 )
87+ end
88+ function s .sgfilter (c ,p )
89+ return c :IsLocation (LOCATION_GRAVE ) and c :IsControler (p ) and not c :WasMaximumModeSide ()
90+ end
91+ function s .tgop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
92+ -- Requirement
93+ Duel .PayLPCost (tp ,1000 )
94+ -- Effect
95+ local g = Duel .GetFieldGroup (tp ,LOCATION_HAND |LOCATION_ONFIELD ,LOCATION_HAND |LOCATION_ONFIELD )
96+ Duel .SendtoGrave (g ,REASON_EFFECT )
97+ local og = Duel .GetOperatedGroup ()
98+ local ct = og :FilterCount (s .sgfilter ,nil ,1 - tp )
99+ if ct > 0 then
100+ Duel .BreakEffect ()
101+ Duel .Damage (1 - tp ,ct * 300 ,REASON_EFFECT )
102+ end
103+ end
0 commit comments