1+ -- デーモンの供物
2+ -- Offering to the Archfiend
3+ -- scripted by YoshiDuels
4+ local s ,id = GetID ()
5+ function s .initial_effect (c )
6+ -- Make 1 of opponent's monsters able to be Tributed
7+ local e1 = Effect .CreateEffect (c )
8+ e1 :SetDescription (aux .Stringid (id ,0 ))
9+ e1 :SetCategory (CATEGORY_ATKCHANGE )
10+ e1 :SetType (EFFECT_TYPE_ACTIVATE )
11+ e1 :SetCode (EVENT_FREE_CHAIN )
12+ e1 :SetCost (s .cost )
13+ e1 :SetTarget (s .target )
14+ e1 :SetOperation (s .activate )
15+ c :RegisterEffect (e1 )
16+ end
17+ function s .cfilter (c )
18+ return c :IsRace (RACE_FIEND ) and c :IsAbleToDeckOrExtraAsCost ()
19+ end
20+ function s .cost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
21+ if chk == 0 then return Duel .IsExistingMatchingCard (s .cfilter ,tp ,LOCATION_GRAVE ,0 ,2 ,nil ) end
22+ end
23+ function s .filter (c )
24+ return c :IsFaceup () and c :IsLevelBelow (8 ) and c :IsNotMaximumModeSide () and not c :IsHasEffect (id )
25+ end
26+ function s .target (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
27+ if chk == 0 then return Duel .IsExistingMatchingCard (s .filter ,tp ,0 ,LOCATION_MZONE ,1 ,nil ) end
28+ end
29+ function s .activate (e ,tp ,eg ,ep ,ev ,re ,r ,rp )
30+ local c = e :GetHandler ()
31+ -- Requirement
32+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_TODECK )
33+ local g = Duel .SelectMatchingCard (tp ,s .cfilter ,tp ,LOCATION_GRAVE ,0 ,2 ,2 ,nil )
34+ Duel .HintSelection (g )
35+ Duel .SendtoDeck (g ,nil ,SEQ_DECKBOTTOM ,REASON_EFFECT )
36+ local g2 = Duel .GetOperatedGroup ():Filter (Card .IsLocation ,nil ,LOCATION_DECK )
37+ if # g2 > 1 then
38+ Duel .SortDeckbottom (tp ,tp ,# g2 )
39+ end
40+ -- Effect
41+ Duel .Hint (HINT_SELECTMSG ,tp ,HINTMSG_FACEUP )
42+ local g = Duel .SelectMatchingCard (tp ,s .filter ,tp ,0 ,LOCATION_MZONE ,1 ,1 ,nil )
43+ if # g == 0 then return end
44+ local tc = g :GetFirst ()
45+ Duel .HintSelection (g )
46+ -- Tribute monster to summon Summoned Skull
47+ local e1 = Effect .CreateEffect (c )
48+ e1 :SetType (EFFECT_TYPE_SINGLE )
49+ e1 :SetProperty (EFFECT_FLAG_CANNOT_DISABLE )
50+ e1 :SetCode (id )
51+ e1 :SetValue (2 )
52+ e1 :SetReset (RESETS_STANDARD_PHASE_END )
53+ tc :RegisterEffect (e1 )
54+ local e2 = Effect .CreateEffect (c )
55+ e2 :SetDescription (aux .Stringid (id ,1 ))
56+ e2 :SetType (EFFECT_TYPE_FIELD )
57+ e2 :SetCode (EFFECT_SUMMON_PROC )
58+ e2 :SetTargetRange (LOCATION_HAND ,0 )
59+ e2 :SetCondition (s .otcon1 )
60+ e2 :SetTarget (aux .FieldSummonProcTg (s .ottg1 ,s .sumtg1 ))
61+ e2 :SetOperation (s .otop )
62+ e2 :SetReset (RESET_PHASE |PHASE_END )
63+ Duel .RegisterEffect (e2 ,tp )
64+ local e3 = Effect .CreateEffect (c )
65+ e3 :SetDescription (aux .Stringid (id ,1 ))
66+ e3 :SetType (EFFECT_TYPE_FIELD )
67+ e3 :SetCode (EFFECT_SUMMON_PROC )
68+ e3 :SetTargetRange (LOCATION_HAND ,0 )
69+ e3 :SetCondition (s .otcon2 )
70+ e3 :SetTarget (aux .FieldSummonProcTg (s .ottg2 ,s .sumtg2 ))
71+ e3 :SetOperation (s .otop )
72+ e3 :SetReset (RESET_PHASE |PHASE_END )
73+ Duel .RegisterEffect (e3 ,tp )
74+ end
75+ function s .tgfilter1 (c ,e )
76+ return c :IsReleasable (REASON_SUMMON ) and c :IsNotMaximumModeSide ()
77+ end
78+ function s .tgfilter2 (c ,e )
79+ return c :IsReleasable (REASON_SUMMON ) and c :IsNotMaximumModeSide () and c :IsHasEffect (id )
80+ end
81+ function s .tgfilter (c ,e ,tp )
82+ if c :IsControler (tp ) then return s .tgfilter1 (c ,e ) end
83+ return s .tgfilter2 (c ,e )
84+ end
85+ function s .otcon1 (e ,c )
86+ if c == nil then return true end
87+ local tp = c :GetControler ()
88+ return Duel .GetLocationCount (tp ,LOCATION_MZONE )> 0 and Duel .IsExistingMatchingCard (s .tgfilter2 ,tp ,0 ,LOCATION_MZONE ,1 ,nil ,e )
89+ end
90+ function s .ottg1 (e ,c )
91+ return c :IsCode (CARD_SUMMONED_SKULL ) and c :IsLevel (5 ,6 )
92+ end
93+ function s .sumtg1 (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,c )
94+ local oppg = Duel .GetMatchingGroup (s .tgfilter2 ,tp ,0 ,LOCATION_MZONE ,nil ,e )
95+ local g1 = oppg :Select (tp ,1 ,1 ,true ,nil )
96+ if not g1 then return false end
97+ g1 :KeepAlive ()
98+ e :SetLabelObject (g1 )
99+ return true
100+ end
101+ function s .otop (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,c )
102+ local sg = e :GetLabelObject ()
103+ if not sg then return end
104+ c :SetMaterial (sg )
105+ Duel .Release (sg ,REASON_SUMMON )
106+ sg :DeleteGroup ()
107+ end
108+ function s .otcon2 (e ,c )
109+ if c == nil then return true end
110+ local tp = c :GetControler ()
111+ return Duel .GetLocationCount (tp ,LOCATION_MZONE )>- 1
112+ and Duel .IsExistingMatchingCard (s .tgfilter ,tp ,LOCATION_MZONE ,LOCATION_MZONE ,2 ,nil ,e ,tp )
113+ end
114+ function s .ottg2 (e ,c )
115+ return c :IsCode (CARD_SUMMONED_SKULL ) and c :IsLevelAbove (7 )
116+ end
117+ function s .sumtg2 (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,c )
118+ local sg = Duel .GetMatchingGroup (s .tgfilter ,tp ,LOCATION_MZONE ,LOCATION_MZONE ,nil ,e ,tp )
119+ local g1 = aux .SelectUnselectGroup (sg ,1 ,tp ,2 ,2 ,aux .ChkfMMZ (1 ),1 ,tp ,HINTMSG_RELEASE ,nil ,nil ,true )
120+ if # g1 < 2 then return false end
121+ g1 :KeepAlive ()
122+ e :SetLabelObject (g1 )
123+ return true
124+ end
0 commit comments