1+ -- JP name
2+ -- Mechanical Mechanic
3+ -- scripted by pyrQ
4+ local s ,id = GetID ()
5+ function s .initial_effect (c )
6+ -- When an attack is declared involving your other Machine monster: You can increase or decrease the Level of that other monster you control by 1
7+ local e1 = Effect .CreateEffect (c )
8+ e1 :SetDescription (aux .Stringid (id ,0 ))
9+ e1 :SetCategory (CATEGORY_LVCHANGE )
10+ e1 :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O )
11+ e1 :SetCode (EVENT_ATTACK_ANNOUNCE )
12+ e1 :SetRange (LOCATION_MZONE )
13+ e1 :SetCondition (s .lvcon )
14+ e1 :SetTarget (s .lvtg )
15+ e1 :SetOperation (s .lvop )
16+ c :RegisterEffect (e1 )
17+ -- If a card is in the Field Zone: You can Special Summon this card from your hand
18+ local e2 = Effect .CreateEffect (c )
19+ e2 :SetDescription (aux .Stringid (id ,1 ))
20+ e2 :SetCategory (CATEGORY_SPECIAL_SUMMON )
21+ e2 :SetType (EFFECT_TYPE_IGNITION )
22+ e2 :SetRange (LOCATION_HAND )
23+ e2 :SetCountLimit (1 ,{id ,0 })
24+ e2 :SetCondition (s .spcon )
25+ e2 :SetTarget (s .sptg )
26+ e2 :SetOperation (s .spop )
27+ c :RegisterEffect (e2 )
28+ -- You can target 1 face-up Spell/Trap Card you control; destroy it, and if you do, add 1 WIND Machine monster with 0 ATK from your Deck to your hand, also you cannot Special Summon from the Extra Deck for the rest of this turn, except Machine monsters
29+ local e3 = Effect .CreateEffect (c )
30+ e3 :SetDescription (aux .Stringid (id ,2 ))
31+ e3 :SetCategory (CATEGORY_DESTROY + CATEGORY_TOHAND + CATEGORY_SEARCH )
32+ e3 :SetType (EFFECT_TYPE_IGNITION )
33+ e3 :SetProperty (EFFECT_FLAG_CARD_TARGET )
34+ e3 :SetRange (LOCATION_MZONE )
35+ e3 :SetCountLimit (1 ,{id ,1 })
36+ e3 :SetTarget (s .thtg )
37+ e3 :SetOperation (s .thop )
38+ c :RegisterEffect (e3 )
39+ end
40+ function s .lvcon (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
41+ local bc = Duel .GetBattleMonster (tp )
42+ return bc and bc ~= e :GetHandler () and bc :IsRace (RACE_MACHINE ) and bc :HasLevel () and bc :IsFaceup ()
43+ end
44+ function s .lvtg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
45+ if chk == 0 then return true end
46+ local bc = Duel .GetBattleMonster (tp )
47+ e :SetLabelObject (bc )
48+ bc :CreateEffectRelation (e )
49+ Duel .SetOperationInfo (0 ,CATEGORY_LVCHANGE ,bc ,1 ,tp ,1 )
50+ end
51+ function s .lvop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
52+ local bc = e :GetLabelObject ()
53+ if bc :IsRelateToEffect (e ) and bc :IsFaceup () and bc :IsControler (tp ) and bc :HasLevel () then
54+ local op = bc :IsLevelAbove (2 ) and Duel .SelectOption (tp ,aux .Stringid (id ,3 ),aux .Stringid (id ,4 )) or 0
55+ local lv = op == 0 and 1 or - 1
56+ -- Increase or decrease its Level by 1
57+ local e1 = Effect .CreateEffect (e :GetHandler ())
58+ e1 :SetType (EFFECT_TYPE_SINGLE )
59+ e1 :SetProperty (EFFECT_FLAG_CANNOT_DISABLE )
60+ e1 :SetCode (EFFECT_UPDATE_LEVEL )
61+ e1 :SetValue (lv )
62+ e1 :SetReset (RESET_EVENT |RESETS_STANDARD )
63+ bc :RegisterEffect (e1 )
64+ end
65+ end
66+ function s .spcon (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
67+ return Duel .IsExistingMatchingCard (nil ,tp ,LOCATION_FZONE ,LOCATION_FZONE ,1 ,nil )
68+ end
69+ function s .sptg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
70+ local c = e :GetHandler ()
71+ if chk == 0 then return Duel .GetLocationCount (tp ,LOCATION_MZONE )> 0
72+ and c :IsCanBeSpecialSummoned (e ,0 ,tp ,false ,false ) end
73+ Duel .SetOperationInfo (0 ,CATEGORY_SPECIAL_SUMMON ,c ,1 ,tp ,0 )
74+ end
75+ function s .spop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
76+ local c = e :GetHandler ()
77+ if c :IsRelateToEffect (e ) then
78+ Duel .SpecialSummon (c ,0 ,tp ,tp ,false ,false ,POS_FACEUP )
79+ end
80+ end
81+ function s .thfilter (c )
82+ return c :IsAttribute (ATTRIBUTE_WIND ) and c :IsRace (RACE_MACHINE ) and c :IsAttack (0 ) and c :IsAbleToHand ()
83+ end
84+ function s .thtg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk ,chkc )
85+ if chkc then return chkc :IsOnField () and chkc :IsControler (tp ) and chkc :IsSpellTrap () and chkc :IsFaceup () end
86+ if chk == 0 then return Duel .IsExistingTarget (aux .FaceupFilter (Card .IsSpellTrap ),tp ,LOCATION_ONFIELD ,0 ,1 ,nil )
87+ and Duel .IsExistingMatchingCard (s .thfilter ,tp ,LOCATION_DECK ,0 ,1 ,nil ) end
88+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_DESTROY )
89+ local g = Duel .SelectTarget (tp ,aux .FaceupFilter (Card .IsSpellTrap ),tp ,LOCATION_ONFIELD ,0 ,1 ,1 ,nil )
90+ Duel .SetOperationInfo (0 ,CATEGORY_DESTROY ,g ,1 ,tp ,0 )
91+ Duel .SetOperationInfo (0 ,CATEGORY_TOHAND ,nil ,1 ,tp ,LOCATION_DECK )
92+ end
93+ function s .thop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
94+ local tc = Duel .GetFirstTarget ()
95+ if tc :IsRelateToEffect (e ) and Duel .Destroy (tc ,REASON_EFFECT )> 0 then
96+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_ATOHAND )
97+ local g = Duel .SelectMatchingCard (tp ,s .thfilter ,tp ,LOCATION_DECK ,0 ,1 ,1 ,nil )
98+ if # g > 0 then
99+ Duel .SendtoHand (g ,nil ,REASON_EFFECT )
100+ Duel .ConfirmCards (1 - tp ,g )
101+ end
102+ end
103+ -- You cannot Special Summon from the extra Deck for the rest of this turn, except Machine monsters
104+ local e1 = Effect .CreateEffect (e :GetHandler ())
105+ e1 :SetDescription (aux .Stringid (id ,5 ))
106+ e1 :SetType (EFFECT_TYPE_FIELD )
107+ e1 :SetProperty (EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_CLIENT_HINT )
108+ e1 :SetCode (EFFECT_CANNOT_SPECIAL_SUMMON )
109+ e1 :SetTargetRange (1 ,0 )
110+ e1 :SetTarget (function (e ,c ) return c :IsLocation (LOCATION_EXTRA ) and not c :IsRace (RACE_MACHINE ) end )
111+ e1 :SetReset (RESET_PHASE |PHASE_END )
112+ Duel .RegisterEffect (e1 ,tp )
113+ end
0 commit comments