1+ -- DDD零死王ゼロ・マキナ
2+ -- D/D/D Zero Demise King Zero Machinex
3+ -- Scripted by The Razgriz
4+ local s ,id = GetID ()
5+ function s .initial_effect (c )
6+ -- Pendulum Summon procedure
7+ Pendulum .AddProcedure (c ,false )
8+ -- Check if it was activated this turn
9+ local e0 = Effect .CreateEffect (c )
10+ e0 :SetDescription (1160 )
11+ e0 :SetType (EFFECT_TYPE_ACTIVATE )
12+ e0 :SetCode (EVENT_FREE_CHAIN )
13+ e0 :SetRange (LOCATION_HAND )
14+ e0 :SetCost (s .actreg )
15+ c :RegisterEffect (e0 )
16+ -- Place 1 "Dark Contract" Continuous Spell/Trap on the field
17+ local e1 = Effect .CreateEffect (c )
18+ e1 :SetDescription (aux .Stringid (id ,0 ))
19+ e1 :SetType (EFFECT_TYPE_IGNITION )
20+ e1 :SetRange (LOCATION_PZONE )
21+ e1 :SetCountLimit (1 ,id )
22+ e1 :SetCondition (function (e ) return e :GetHandler ():HasFlagEffect (id ) end )
23+ e1 :SetTarget (s .pltg )
24+ e1 :SetOperation (s .plop )
25+ c :RegisterEffect (e1 )
26+ -- Special Summon this card from the Extra Deck if a "Dark Contract" or "D/D/D" card(s) is destroyed
27+ local e2 = Effect .CreateEffect (c )
28+ e2 :SetDescription (aux .Stringid (id ,1 ))
29+ e2 :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O )
30+ e2 :SetProperty (EFFECT_FLAG_DELAY + EFFECT_FLAG_DAMAGE_STEP )
31+ e2 :SetCode (EVENT_DESTROYED )
32+ e2 :SetRange (LOCATION_EXTRA )
33+ e2 :SetCountLimit (1 ,{id ,1 })
34+ e2 :SetCondition (s .spcon )
35+ e2 :SetTarget (s .sptg )
36+ e2 :SetOperation (s .spop )
37+ c :RegisterEffect (e2 )
38+ -- Place this card in the Pendulum Zone if it's destroyed
39+ local e3 = Effect .CreateEffect (c )
40+ e3 :SetDescription (aux .Stringid (id ,2 ))
41+ e3 :SetType (EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O )
42+ e3 :SetProperty (EFFECT_FLAG_DELAY )
43+ e3 :SetCode (EVENT_DESTROYED )
44+ e3 :SetCountLimit (1 ,{id ,2 })
45+ e3 :SetCondition (function (e ) return e :GetHandler ():IsPreviousLocation (LOCATION_MZONE ) end )
46+ e3 :SetTarget (function (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk ) if chk == 0 then return Duel .CheckPendulumZones (tp ) end end )
47+ e3 :SetOperation (s .penop )
48+ c :RegisterEffect (e3 )
49+ end
50+ s .listed_series = {SET_DARK_CONTRACT ,SET_DDD }
51+ s .listed_names = {id }
52+ function s .actreg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
53+ if chk == 0 then return true end
54+ e :GetHandler ():RegisterFlagEffect (id ,RESET_PHASE |PHASE_END ,EFFECT_FLAG_OATH ,1 )
55+ end
56+ function s .plfilter (c ,tp )
57+ return c :IsSetCard (SET_DARK_CONTRACT ) and c :IsContinuousSpellTrap () and not c :IsForbidden () and c :CheckUniqueOnField (tp )
58+ end
59+ function s .pltg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
60+ if chk == 0 then return Duel .GetLocationCount (tp ,LOCATION_SZONE )> 0
61+ and Duel .IsExistingMatchingCard (s .plfilter ,tp ,LOCATION_DECK ,0 ,1 ,nil ,tp ) end
62+ end
63+ function s .plop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
64+ if Duel .GetLocationCount (tp ,LOCATION_SZONE )<= 0 then return end
65+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_TOFIELD )
66+ local sc = Duel .SelectMatchingCard (tp ,s .plfilter ,tp ,LOCATION_DECK ,0 ,1 ,1 ,nil ,tp ):GetFirst ()
67+ if sc then
68+ Duel .MoveToField (sc ,tp ,tp ,LOCATION_SZONE ,POS_FACEUP ,true )
69+ end
70+ end
71+ function s .spconfilter (c ,tp )
72+ return c :IsPreviousControler (tp ) and c :IsPreviousLocation (LOCATION_ONFIELD ) and not c :IsPreviousCodeOnField (id )
73+ and c :IsPreviousPosition (POS_FACEUP ) and c :IsPreviousSetCard ({SET_DDD ,SET_DARK_CONTRACT })
74+ end
75+ function s .spcon (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
76+ return not eg :IsContains (e :GetHandler ()) and eg :IsExists (s .spconfilter ,1 ,nil ,tp )
77+ end
78+ function s .sptg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
79+ local c = e :GetHandler ()
80+ if chk == 0 then return Duel .GetLocationCountFromEx (tp ,tp ,nil ,c )> 0
81+ and c :IsCanBeSpecialSummoned (e ,0 ,tp ,false ,false ) end
82+ Duel .SetOperationInfo (0 ,CATEGORY_SPECIAL_SUMMON ,c ,1 ,tp ,0 )
83+ Duel .SetPossibleOperationInfo (0 ,CATEGORY_DESTROY ,nil ,1 ,PLAYER_EITHER ,LOCATION_ONFIELD )
84+ end
85+ function s .spop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
86+ local c = e :GetHandler ()
87+ if c :IsRelateToEffect (e ) and Duel .SpecialSummon (c ,0 ,tp ,tp ,false ,false ,POS_FACEUP )> 0
88+ and Duel .IsExistingMatchingCard (nil ,tp ,LOCATION_ONFIELD ,LOCATION_ONFIELD ,1 ,nil )
89+ and Duel .SelectYesNo (tp ,aux .Stringid (id ,3 )) then
90+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_DESTROY )
91+ local g = Duel .SelectMatchingCard (tp ,nil ,tp ,LOCATION_ONFIELD ,LOCATION_ONFIELD ,1 ,1 ,nil )
92+ if # g > 0 then
93+ Duel .HintSelection (g )
94+ Duel .BreakEffect ()
95+ Duel .Destroy (g ,REASON_EFFECT )
96+ end
97+ end
98+ end
99+ function s .penop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
100+ local c = e :GetHandler ()
101+ if c :IsRelateToEffect (e ) then
102+ Duel .MoveToField (c ,tp ,tp ,LOCATION_PZONE ,POS_FACEUP ,true )
103+ end
104+ end
0 commit comments