1+ -- JP name
2+ -- R.B. Shepherd's Crook
3+ -- Scripted by The Razgriz
4+ local s ,id = GetID ()
5+ function s .initial_effect (c )
6+ c :EnableReviveLimit ()
7+ -- Link Summon procedure: 2+ monsters, including an "R.B." monster
8+ Link .AddProcedure (c ,nil ,2 ,3 ,s .linkmatcheck )
9+ -- Gains 500 ATK for each monster you control, except this card
10+ local e1 = Effect .CreateEffect (c )
11+ e1 :SetType (EFFECT_TYPE_SINGLE )
12+ e1 :SetProperty (EFFECT_FLAG_SINGLE_RANGE )
13+ e1 :SetCode (EFFECT_UPDATE_ATTACK )
14+ e1 :SetRange (LOCATION_MZONE )
15+ e1 :SetValue (function (e ,c ) return 500 * Duel .GetMatchingGroupCount (nil ,c :GetControler (),LOCATION_MZONE ,0 ,e :GetHandler ()) end )
16+ c :RegisterEffect (e1 )
17+ -- Set 1 "R.B." Spell/Trap from your Deck or GY
18+ local e2 = Effect .CreateEffect (c )
19+ e2 :SetDescription (aux .Stringid (id ,0 ))
20+ e2 :SetCategory (CATEGORY_LEAVE_GRAVE )
21+ e2 :SetType (EFFECT_TYPE_IGNITION )
22+ e2 :SetRange (LOCATION_MZONE )
23+ e2 :SetCountLimit (1 ,id )
24+ e2 :SetTarget (s .settg )
25+ e2 :SetOperation (s .setop )
26+ c :RegisterEffect (e2 )
27+ -- Target 3 Level 3 or higher "R.B." monsters; place 2 on the bottom of the Deck in any order, Special Summon the third
28+ local e3 = Effect .CreateEffect (c )
29+ e3 :SetDescription (aux .Stringid (id ,1 ))
30+ e3 :SetCategory (CATEGORY_TODECK + CATEGORY_SPECIAL_SUMMON )
31+ e3 :SetType (EFFECT_TYPE_QUICK_O )
32+ e3 :SetProperty (EFFECT_FLAG_CARD_TARGET )
33+ e3 :SetCode (EVENT_FREE_CHAIN )
34+ e3 :SetRange (LOCATION_MZONE )
35+ e3 :SetCountLimit (1 ,{id ,1 })
36+ e3 :SetCondition (function (e ,tp ) return Duel .IsMainPhase (1 - tp ) end )
37+ e3 :SetTarget (s .tdsptg )
38+ e3 :SetOperation (s .tdspop )
39+ e3 :SetHintTiming (0 ,TIMING_MAIN_END |TIMINGS_CHECK_MONSTER )
40+ c :RegisterEffect (e3 )
41+ end
42+ s .listed_series = {SET_RB }
43+ s .material_setcode = SET_RB
44+ function s .linkmatcheck (g ,lc ,sumtype ,tp )
45+ return g :IsExists (Card .IsSetCard ,1 ,nil ,SET_RB ,lc ,sumtype ,tp )
46+ end
47+ function s .setfilter (c )
48+ return c :IsSetCard (SET_RB ) and c :IsTrap () and c :IsSSetable ()
49+ end
50+ function s .settg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
51+ if chk == 0 then return Duel .IsExistingMatchingCard (s .setfilter ,tp ,LOCATION_DECK |LOCATION_GRAVE ,0 ,1 ,1 ,nil ) end
52+ Duel .SetPossibleOperationInfo (0 ,CATEGORY_LEAVE_GRAVE ,nil ,1 ,tp ,LOCATION_GRAVE )
53+ end
54+ function s .setop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
55+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_SET )
56+ local g = Duel .SelectMatchingCard (tp ,aux .NecroValleyFilter (s .setfilter ),tp ,LOCATION_DECK |LOCATION_GRAVE ,0 ,1 ,1 ,nil )
57+ if # g > 0 then
58+ Duel .SSet (tp ,g )
59+ end
60+ end
61+ function s .tdspfilter (c ,e ,tp )
62+ return c :IsLevelAbove (3 ) and c :IsSetCard (SET_RB ) and c :IsCanBeEffectTarget (e )
63+ and (c :IsAbleToDeck () or c :IsCanBeSpecialSummoned (e ,0 ,tp ,false ,false ,POS_FACEUP_DEFENSE ))
64+ end
65+ function s .rescon (sg ,e ,tp ,mg )
66+ return sg :IsExists (s .spcheck ,1 ,nil ,e ,tp ,sg )
67+ end
68+ function s .spcheck (c ,e ,tp ,sg )
69+ return c :IsCanBeSpecialSummoned (e ,0 ,tp ,false ,false ,POS_FACEUP_DEFENSE ) and sg :IsExists (Card .IsAbleToDeck ,2 ,c )
70+ end
71+ function s .tdsptg (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk ,chkc )
72+ if chkc then return false end
73+ local g = Duel .GetMatchingGroup (s .tdspfilter ,tp ,LOCATION_GRAVE ,0 ,nil ,e ,tp )
74+ if chk == 0 then return Duel .GetLocationCount (tp ,LOCATION_MZONE )> 0
75+ and # g >= 3 and aux .SelectUnselectGroup (g ,e ,tp ,3 ,3 ,s .rescon ,0 ) end
76+ local tg = aux .SelectUnselectGroup (g ,e ,tp ,3 ,3 ,s .rescon ,1 ,tp ,HINTMSG_TARGET )
77+ Duel .SetTargetCard (tg )
78+ Duel .SetOperationInfo (0 ,CATEGORY_TODECK ,tg ,2 ,tp ,0 )
79+ Duel .SetOperationInfo (0 ,CATEGORY_SPECIAL_SUMMON ,tg ,1 ,tp ,0 )
80+ end
81+ function s .tdrescon (sg ,e ,tp ,mg )
82+ return mg :IsExists (s .spcheck ,1 ,sg ,e ,tp ,sg )
83+ end
84+ function s .tdspop (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
85+ local tg = Duel .GetTargetCards (e )
86+ if # tg < 2 then return end
87+ if # tg == 2 and Duel .SendtoDeck (tg ,nil ,SEQ_DECKBOTTOM ,REASON_EFFECT )> 0 then
88+ local ct = tg :FilterCount (Card .IsLocation ,nil ,LOCATION_DECK )
89+ if ct > 0 then Duel .SortDeckbottom (tp ,tp ,ct ) end
90+ return
91+ end
92+ local dg = aux .SelectUnselectGroup (tg ,e ,tp ,2 ,2 ,s .tdrescon ,1 ,tp ,HINTMSG_TODECK )
93+ if # dg ~= 2 then return end
94+ Duel .HintSelection (dg )
95+ if Duel .SendtoDeck (dg ,nil ,SEQ_DECKBOTTOM ,REASON_EFFECT )> 0 and dg :FilterCount (Card .IsLocation ,nil ,LOCATION_DECK |LOCATION_EXTRA )== 2 then
96+ local ct = dg :FilterCount (Card .IsLocation ,nil ,LOCATION_DECK )
97+ if ct > 0 then Duel .SortDeckbottom (tp ,tp ,ct ) end
98+ local sg = tg - dg
99+ if # sg > 0 then
100+ Duel .SpecialSummon (sg ,0 ,tp ,tp ,false ,false ,POS_FACEUP_DEFENSE )
101+ end
102+ end
103+ end
0 commit comments