1+ -- カウンターマジック「攻撃の無力化」
2+ -- Counter Spell "Negate Attack"
3+ -- scripted by Naim
4+ local s ,id = GetID ()
5+ function s .initial_effect (c )
6+ -- During the Battle Phase: Activate 1 of these effects;
7+ -- ● When an opponent's monster declares an attack while they control more monsters than you do: Negate the attack, then end the Battle Phase
8+ -- ● When your opponent activates a monster effect: Negate that effect, and if you do, destroy that monster
9+ local e1 = Effect .CreateEffect (c )
10+ e1 :SetDescription (aux .Stringid (id ,0 ))
11+ e1 :SetType (EFFECT_TYPE_ACTIVATE )
12+ e1 :SetCode (EVENT_FREE_CHAIN )
13+ e1 :SetCondition (function (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
14+ return Duel .IsBattlePhase ()
15+ end )
16+ e1 :SetTarget (s .efftg )
17+ e1 :SetOperation (s .effop )
18+ c :RegisterEffect (e1 )
19+ -- When you draw for your normal draw in your Draw Phase: You can banish this card from your GY; Special Summon 1 monster from your hand
20+ local e2 = Effect .CreateEffect (c )
21+ e2 :SetDescription (aux .Stringid (id ,1 ))
22+ e2 :SetCategory (CATEGORY_SPECIAL_SUMMON )
23+ e2 :SetType (EFFECT_TYPE_FIELD + EFFECT_TYPE_TRIGGER_O )
24+ e2 :SetCode (EVENT_DRAW )
25+ e2 :SetRange (LOCATION_GRAVE )
26+ e2 :SetCondition (s .spcon )
27+ e2 :SetCost (Cost .SelfBanish )
28+ e2 :SetTarget (s .sptg )
29+ e2 :SetOperation (s .spop )
30+ c :RegisterEffect (e2 )
31+ end
32+ function s .efftg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
33+ -- ● When an opponent's monster declares an attack while they control more monsters than you do: Negate the attack, then end the Battle Phase
34+ local option_1 = Duel .CheckEvent (EVENT_ATTACK_ANNOUNCE ) and Duel .GetAttacker ():IsControler (1 - tp )
35+ and Duel .GetFieldGroupCount (tp ,0 ,LOCATION_MZONE )> Duel .GetFieldGroupCount (tp ,LOCATION_MZONE ,0 )
36+ -- ● When your opponent activates a monster effect: Negate that effect, and if you do, destroy that monster
37+ local event_check ,_ ,event_player ,event_value ,event_reff = Duel .CheckEvent (EVENT_CHAINING ,true )
38+ local option_2 = event_check and event_player == 1 - tp and event_reff :IsMonsterEffect () and Chain .IsDisablable (event_value )
39+ if chk == 0 then return option_1 or option_2 end
40+ local choice = Duel .SelectEffect (tp ,
41+ {option_1 ,aux .Stringid (id ,2 )},
42+ {option_2 ,aux .Stringid (id ,3 )})
43+ local chain_data = e :GetChainData ()
44+ chain_data .choice = choice
45+ if choice == 1 then
46+ -- ● When an opponent's monster declares an attack while they control more monsters than you do: Negate the attack, then end the Battle Phase
47+ e :SetCategory (0 )
48+ elseif choice == 2 then
49+ -- ● When your opponent activates a monster effect: Negate that effect, and if you do, destroy that monster
50+ e :SetCategory (CATEGORY_DISABLE + CATEGORY_DESTROY )
51+ local event_rcard = event_reff :GetHandler ()
52+ chain_data .event_value = event_value
53+ chain_data .event_rcard = event_rcard
54+ chain_data .event_reff = event_reff
55+ Duel .SetOperationInfo (0 ,CATEGORY_DISABLE ,event_rcard ,1 ,tp ,0 )
56+ if event_rcard :IsDestructable () and event_rcard :IsRelateToEffect (event_reff ) then
57+ Duel .SetOperationInfo (0 ,CATEGORY_DESTROY ,event_rcard ,1 ,tp ,0 )
58+ end
59+ end
60+ end
61+ function s .effop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
62+ local chain_data = e :GetChainData ()
63+ if chain_data .choice == 1 then
64+ -- ● When an opponent's monster declares an attack while they control more monsters than you do: Negate the attack, then end the Battle Phase
65+ if Duel .NegateAttack () then
66+ Duel .SkipPhase (1 - tp ,PHASE_BATTLE ,RESET_PHASE |PHASE_BATTLE_STEP ,1 )
67+ end
68+ elseif chain_data .choice == 2 then
69+ -- ● When your opponent activates a monster effect: Negate that effect, and if you do, destroy that monster
70+ local event_value = chain_data .event_value
71+ local event_rcard = chain_data .event_rcard
72+ local event_reff = chain_data .event_reff
73+ if Duel .NegateEffect (event_value ) and event_rcard :IsRelateToEffect (event_reff ) then
74+ Duel .Destroy (event_rcard ,REASON_EFFECT )
75+ end
76+ end
77+ end
78+ function s .spcon (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
79+ return ep == tp and (r &REASON_RULE )> 0
80+ end
81+ function s .sptg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
82+ if chk == 0 then return Duel .GetLocationCount (tp ,LOCATION_MZONE )> 0
83+ and Duel .IsExistingMatchingCard (Card .IsCanBeSpecialSummoned ,tp ,LOCATION_HAND ,0 ,1 ,nil ,e ,0 ,tp ,false ,false ) end
84+ Duel .SetOperationInfo (0 ,CATEGORY_SPECIAL_SUMMON ,nil ,1 ,tp ,LOCATION_HAND )
85+ end
86+ function s .spop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
87+ if Duel .GetLocationCount (tp ,LOCATION_MZONE )<= 0 then return end
88+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_SPSUMMON )
89+ local g = Duel .SelectMatchingCard (tp ,Card .IsCanBeSpecialSummoned ,tp ,LOCATION_HAND ,0 ,1 ,1 ,nil ,e ,0 ,tp ,false ,false )
90+ if # g > 0 then
91+ Duel .SpecialSummon (g ,0 ,tp ,tp ,false ,false ,POS_FACEUP )
92+ end
93+ end
0 commit comments