/
c5087128.lua
97 lines (97 loc) · 3.57 KB
/
c5087128.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
--シェルヴァレット・ドラゴン
function c5087128.initial_effect(c)
--destroy
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(5087128,0))
e1:SetCategory(CATEGORY_DESTROY)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_CHAINING)
e1:SetRange(LOCATION_MZONE)
e1:SetCountLimit(1,5087128)
e1:SetCondition(c5087128.descon)
e1:SetTarget(c5087128.destg)
e1:SetOperation(c5087128.desop)
c:RegisterEffect(e1)
--to grave
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetCode(EVENT_TO_GRAVE)
e2:SetOperation(c5087128.regop)
c:RegisterEffect(e2)
end
function c5087128.descon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then return false end
local g=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS)
if not g or not g:IsContains(c) then return false end
return re:IsActiveType(TYPE_LINK)
end
function c5087128.desfilter(c,g)
return g:IsContains(c)
end
function c5087128.desfilter2(c,s,tp)
local seq=c:GetSequence()
return seq<5 and math.abs(seq-s)==1 and c:IsControler(tp)
end
function c5087128.destg(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
local g=Duel.GetMatchingGroup(c5087128.desfilter,tp,LOCATION_MZONE,LOCATION_MZONE,nil,c:GetColumnGroup())
if chk==0 then return c:IsDestructable() and g:GetCount()>0 end
Duel.SetOperationInfo(0,CATEGORY_DESTROY,c,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,g,1,0,0)
end
function c5087128.desop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local lg=c:GetColumnGroup()
if c:IsRelateToEffect(e) and Duel.Destroy(c,REASON_EFFECT)>0 then
local g=Duel.GetMatchingGroup(c5087128.desfilter,tp,LOCATION_MZONE,LOCATION_MZONE,nil,lg)
if g:GetCount()==0 then return end
Duel.BreakEffect()
local tc=nil
if g:GetCount()==1 then
tc=g:GetFirst()
else
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_DESTROY)
tc=g:Select(tp,1,1,nil):GetFirst()
end
local seq=tc:GetSequence()
local dg=Group.CreateGroup()
if seq<5 then dg=Duel.GetMatchingGroup(c5087128.desfilter2,tp,LOCATION_MZONE,LOCATION_MZONE,nil,seq,tc:GetControler()) end
if Duel.Destroy(tc,REASON_EFFECT)~=0 and dg:GetCount()>0 then
Duel.Destroy(dg,REASON_EFFECT)
end
end
end
function c5087128.regop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if c:IsReason(REASON_BATTLE+REASON_EFFECT) and c:IsReason(REASON_DESTROY) and c:IsPreviousLocation(LOCATION_ONFIELD) then
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(5087128,1))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_PHASE+PHASE_END)
e1:SetCountLimit(1,5087129)
e1:SetRange(LOCATION_GRAVE)
e1:SetTarget(c5087128.sptg)
e1:SetOperation(c5087128.spop)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_PHASE+PHASE_END)
c:RegisterEffect(e1)
end
end
function c5087128.spfilter(c,e,tp)
return c:IsSetCard(0x102) and not c:IsCode(5087128) and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c5087128.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c5087128.spfilter,tp,LOCATION_DECK,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_DECK)
end
function c5087128.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c5087128.spfilter,tp,LOCATION_DECK,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
end
end