1+ -- 魔弾の悪魔 カスパール
2+ -- Magical Musket Mastermind Caspar
3+ -- scripted by pyrQ
4+ local s ,id = GetID ()
5+ function s .initial_effect (c )
6+ c :EnableReviveLimit ()
7+ -- Link Summon procedure: 2 monsters, including a LIGHT Fiend monster
8+ Link .AddProcedure (c ,nil ,2 ,2 ,s .matcheck )
9+ -- Take 2 "Magical Musket" cards from your hand and/or Deck, including a monster, Special Summon 1 of those monsters, and Set the other card to your opponent's field
10+ local e1 = Effect .CreateEffect (c )
11+ e1 :SetDescription (aux .Stringid (id ,0 ))
12+ e1 :SetCategory (CATEGORY_SPECIAL_SUMMON )
13+ e1 :SetType (EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_O )
14+ e1 :SetProperty (EFFECT_FLAG_DELAY )
15+ e1 :SetCode (EVENT_SPSUMMON_SUCCESS )
16+ e1 :SetCountLimit (1 ,id )
17+ e1 :SetCondition (function (e ) return e :GetHandler ():IsLinkSummoned () end )
18+ e1 :SetTarget (s .spsettg )
19+ e1 :SetOperation (s .spsetop )
20+ c :RegisterEffect (e1 )
21+ -- During either player's turn, you can activate "Magical Musket" Spell/Trap Cards from your hand.
22+ local e2a = Effect .CreateEffect (c )
23+ e2a :SetType (EFFECT_TYPE_FIELD )
24+ e2a :SetCode (EFFECT_QP_ACT_IN_NTPHAND )
25+ e2a :SetRange (LOCATION_MZONE )
26+ e2a :SetTargetRange (LOCATION_HAND ,0 )
27+ e2a :SetTarget (aux .TargetBoolFunction (Card .IsSetCard ,SET_MAGICAL_MUSKET ))
28+ c :RegisterEffect (e2a )
29+ local e2b = e2a :Clone ()
30+ e2b :SetCode (EFFECT_TRAP_ACT_IN_HAND )
31+ c :RegisterEffect (e2b )
32+ end
33+ s .listed_series = {SET_MAGICAL_MUSKET }
34+ function s .matfilter (c ,lc ,sumtype ,tp )
35+ return c :IsAttribute (ATTRIBUTE_LIGHT ,lc ,sumtype ,tp ) and c :IsRace (RACE_FIEND ,lc ,sumtype ,tp )
36+ end
37+ function s .matcheck (g ,lc ,sumtype ,tp )
38+ return g :IsExists (s .matfilter ,1 ,nil ,lc ,sumtype ,tp )
39+ end
40+ function s .rescon (sg ,e ,tp ,mg )
41+ return sg :IsExists (Card .IsMonster ,1 ,nil ) and sg :IsExists (s .spfilter ,1 ,nil ,e ,tp ,sg )
42+ end
43+ function s .spfilter (c ,e ,tp ,sg )
44+ return c :IsCanBeSpecialSummoned (e ,0 ,tp ,false ,false ) and sg :IsExists (s .setfilter ,1 ,c ,e ,tp ,1 - tp )
45+ end
46+ function s .setfilter (c ,e ,tp ,opp )
47+ return (Duel .GetMZoneCount (opp )> 0 and c :IsCanBeSpecialSummoned (e ,0 ,tp ,false ,false ,POS_FACEDOWN_DEFENSE ,opp )) or c :IsSSetable (false ,opp )
48+ end
49+ function s .spsettg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
50+ if chk == 0 then
51+ if Duel .GetMZoneCount (tp )<= 0 then return false end
52+ local g = Duel .GetMatchingGroup (Card .IsSetCard ,tp ,LOCATION_HAND |LOCATION_DECK ,0 ,nil ,SET_MAGICAL_MUSKET )
53+ return aux .SelectUnselectGroup (g ,e ,tp ,2 ,2 ,s .rescon ,0 )
54+ end
55+ Duel .SetOperationInfo (0 ,CATEGORY_SPECIAL_SUMMON ,nil ,1 ,tp ,LOCATION_HAND |LOCATION_DECK )
56+ end
57+ function s .spsetop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
58+ if Duel .GetMZoneCount (tp )<= 0 then return end
59+ local g = Duel .GetMatchingGroup (Card .IsSetCard ,tp ,LOCATION_HAND |LOCATION_DECK ,0 ,nil ,SET_MAGICAL_MUSKET )
60+ if # g < 2 then return end
61+ local sg = aux .SelectUnselectGroup (g ,e ,tp ,2 ,2 ,s .rescon ,1 ,tp ,aux .Stringid (id ,1 ))
62+ if # sg ~= 2 then return end
63+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_SPSUMMON )
64+ local spg = sg :FilterSelect (tp ,s .spfilter ,1 ,1 ,nil ,e ,tp ,sg )
65+ if # spg > 0 and Duel .SpecialSummon (spg ,0 ,tp ,tp ,false ,false ,POS_FACEUP )> 0 then
66+ local opp = 1 - tp
67+ local setc = (sg - spg ):GetFirst ()
68+ local b1 = Duel .GetMZoneCount (opp )> 0 and setc :IsCanBeSpecialSummoned (e ,0 ,tp ,false ,false ,POS_FACEDOWN_DEFENSE ,opp )
69+ local b2 = setc :IsSSetable (false ,opp )
70+ local op = nil
71+ if b1 and b2 then
72+ op = Duel .SelectEffect (tp ,
73+ {b1 ,aux .Stringid (id ,2 )},
74+ {b2 ,aux .Stringid (id ,3 )})
75+ else
76+ op = b1 and 1 or 2
77+ end
78+ if op == 1 then
79+ Duel .SpecialSummon (setc ,0 ,tp ,opp ,false ,false ,POS_FACEDOWN_DEFENSE )
80+ Duel .ConfirmCards (tp ,setc )
81+ elseif op == 2 then
82+ Duel .SSet (tp ,setc ,opp )
83+ end
84+ end
85+ end
0 commit comments