1+ -- 磁石の戦士Ω+
2+ -- Magnet Warrior Ω+
3+ -- scripted by pyrQ
4+ local s ,id = GetID ()
5+ function s .initial_effect (c )
6+ -- Destroy 1 other Rock monster in your hand or face-up field, and if you do, Special Summon this card, but banish it when it leaves the field
7+ local e1 = Effect .CreateEffect (c )
8+ e1 :SetDescription (aux .Stringid (id ,0 ))
9+ e1 :SetCategory (CATEGORY_DESTROY + CATEGORY_SPECIAL_SUMMON + CATEGORY_REMOVE )
10+ e1 :SetType (EFFECT_TYPE_IGNITION )
11+ e1 :SetRange (LOCATION_HAND |LOCATION_GRAVE )
12+ e1 :SetCountLimit (1 ,id )
13+ e1 :SetTarget (s .sptg )
14+ e1 :SetOperation (s .spop )
15+ c :RegisterEffect (e1 )
16+ -- Change 1 face-up monster on the field to face-down Defense Position
17+ local e2 = Effect .CreateEffect (c )
18+ e2 :SetDescription (aux .Stringid (id ,1 ))
19+ e2 :SetCategory (CATEGORY_POSITION )
20+ e2 :SetType (EFFECT_TYPE_QUICK_O )
21+ e2 :SetProperty (EFFECT_FLAG_CARD_TARGET )
22+ e2 :SetCode (EVENT_CHAINING )
23+ e2 :SetRange (LOCATION_MZONE )
24+ e2 :SetCountLimit (1 ,{id ,1 })
25+ e2 :SetCondition (s .poscon )
26+ e2 :SetCost (Cost .SelfTribute )
27+ e2 :SetTarget (s .postg )
28+ e2 :SetOperation (s .posop )
29+ c :RegisterEffect (e2 )
30+ end
31+ function s .desfilter (c ,tp )
32+ return c :IsRace (RACE_ROCK ) and (c :IsFaceup () or c :IsLocation (LOCATION_HAND )) and Duel .GetMZoneCount (tp ,c )> 0
33+ end
34+ function s .sptg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
35+ local c = e :GetHandler ()
36+ if chk == 0 then return Duel .IsExistingMatchingCard (s .desfilter ,tp ,LOCATION_HAND |LOCATION_MZONE ,0 ,1 ,c ,tp )
37+ and c :IsCanBeSpecialSummoned (e ,0 ,tp ,false ,false ) end
38+ Duel .SetOperationInfo (0 ,CATEGORY_DESTROY ,nil ,1 ,tp ,LOCATION_HAND |LOCATION_MZONE )
39+ Duel .SetOperationInfo (0 ,CATEGORY_SPECIAL_SUMMON ,c ,1 ,tp ,0 )
40+ Duel .SetPossibleOperationInfo (0 ,CATEGORY_REMOVE ,nil ,1 ,tp ,LOCATION_MZONE )
41+ end
42+ function s .spop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
43+ local c = e :GetHandler ()
44+ local exc = c :IsRelateToEffect (e ) and c or nil
45+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_DESTROY )
46+ local g = Duel .SelectMatchingCard (tp ,s .desfilter ,tp ,LOCATION_HAND |LOCATION_MZONE ,0 ,1 ,1 ,exc ,tp )
47+ if # g > 0 and Duel .Destroy (g ,REASON_EFFECT )> 0 and c :IsRelateToEffect (e )
48+ and Duel .SpecialSummon (c ,0 ,tp ,tp ,false ,false ,POS_FACEUP )> 0 then
49+ -- Banish it when it leaves the field
50+ local e1 = Effect .CreateEffect (c )
51+ e1 :SetDescription (3300 )
52+ e1 :SetType (EFFECT_TYPE_SINGLE )
53+ e1 :SetProperty (EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_CLIENT_HINT )
54+ e1 :SetCode (EFFECT_LEAVE_FIELD_REDIRECT )
55+ e1 :SetValue (LOCATION_REMOVED )
56+ e1 :SetReset (RESET_EVENT |RESETS_REDIRECT )
57+ c :RegisterEffect (e1 ,true )
58+ end
59+ end
60+ function s .poscon (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
61+ if not re :IsMonsterEffect () then return false end
62+ local trig_loc ,trig_attr = Duel .GetChainInfo (ev ,CHAININFO_TRIGGERING_LOCATION ,CHAININFO_TRIGGERING_ATTRIBUTE )
63+ return (trig_attr &ATTRIBUTE_EARTH )> 0 and (trig_loc &LOCATION_ONFIELD )> 0
64+ end
65+ function s .postg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk ,chkc )
66+ if chkc then return chkc :IsLocation (LOCATION_MZONE ) and chkc :IsCanTurnSet () end
67+ if chk == 0 then return Duel .IsExistingTarget (Card .IsCanTurnSet ,tp ,LOCATION_MZONE ,LOCATION_MZONE ,1 ,e :GetHandler ()) end
68+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_TARGET )
69+ local g = Duel .SelectTarget (tp ,Card .IsCanTurnSet ,tp ,LOCATION_MZONE ,LOCATION_MZONE ,1 ,1 ,nil )
70+ Duel .SetOperationInfo (0 ,CATEGORY_POSITION ,g ,1 ,tp ,POS_FACEDOWN_DEFENSE )
71+ end
72+ function s .posop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
73+ local tc = Duel .GetFirstTarget ()
74+ if tc :IsRelateToEffect (e ) and tc :IsMonster () then
75+ Duel .ChangePosition (tc ,POS_FACEDOWN_DEFENSE )
76+ end
77+ end
0 commit comments