-
-
Notifications
You must be signed in to change notification settings - Fork 63
/
proc_normal.lua
142 lines (142 loc) · 4.12 KB
/
proc_normal.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
--tribute
function Auxiliary.AddNormalSummonProcedure(c,ns,opt,min,max,val,desc,f,sumop)
val = val or SUMMON_TYPE_TRIBUTE
local e1=Effect.CreateEffect(c)
if desc then e1:SetDescription(desc) end
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetType(EFFECT_TYPE_SINGLE)
if ns and opt then
e1:SetCode(EFFECT_SUMMON_PROC)
else
e1:SetCode(EFFECT_LIMIT_SUMMON_PROC)
end
if ns then
e1:SetCondition(Auxiliary.NormalSummonCondition1(min,max,f,opt))
e1:SetTarget(Auxiliary.NormalSummonTarget(min,max,f))
e1:SetOperation(Auxiliary.NormalSummonOperation(min,max,sumop))
else
e1:SetCondition(Auxiliary.NormalSummonCondition2())
end
e1:SetValue(val)
c:RegisterEffect(e1)
return e1
end
function maplevel(level)
if level>=5 and level<=6 then
return 1
elseif level>=7 then
return 2
end
return 0
end
function Auxiliary.NormalSummonCondition1(min,max,f,opt)
return function (e,c,minc,zone,relzone,exeff)
if c==nil then return true end
local tp=c:GetControler()
local mg=Duel.GetTributeGroup(c):Match(Auxiliary.IsZone,nil,relzone,tp)
if f then
mg:Match(f,nil,tp)
end
local tributes=maplevel(c:GetLevel())
return (not opt or (tributes>0 and tributes~=max)) and minc<=min and Duel.CheckTribute(c,min,max,mg,tp,zone)
end
end
function Auxiliary.NormalSummonCondition2()
return function (e,c,minc,zone,relzone,exeff)
if c==nil then return true end
return false
end
end
function Auxiliary.NormalSummonTarget(min,max,f)
return function (e,tp,eg,ep,ev,re,r,rp,chk,c,minc,zone,relzone,exeff)
local mg=Duel.GetTributeGroup(c):Match(Auxiliary.IsZone,nil,relzone,tp)
if f then
mg:Match(f,nil,tp)
end
local g=Duel.SelectTribute(tp,c,min,max,mg,tp,zone,Duel.IsSummonCancelable())
if g and #g>0 then
g:KeepAlive()
e:SetLabelObject(g)
return true
end
return false
end
end
function Auxiliary.NormalSummonOperation(min,max,sumop)
return function (e,tp,eg,ep,ev,re,r,rp,c,minc,zone,relzone,exeff)
local g=e:GetLabelObject()
c:SetMaterial(g)
Duel.Release(g,REASON_SUMMON+REASON_MATERIAL)
if sumop then
sumop(g:Clone(),e,tp,eg,ep,ev,re,r,rp,c,minc,zone,relzone,exeff)
end
g:DeleteGroup()
end
end
--add normal set
function Auxiliary.AddNormalSetProcedure(c,ns,opt,min,max,val,desc,f,sumop)
val = val or SUMMON_TYPE_TRIBUTE
local e1=Effect.CreateEffect(c)
if desc then e1:SetDescription(desc) end
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetType(EFFECT_TYPE_SINGLE)
if ns and opt then
e1:SetCode(EFFECT_SET_PROC)
else
e1:SetCode(EFFECT_LIMIT_SET_PROC)
end
if ns then
e1:SetCondition(Auxiliary.NormalSetCondition1(min,max,f))
e1:SetTarget(Auxiliary.NormalSetTarget(min,max,f))
e1:SetOperation(Auxiliary.NormalSetOperation(min,max,sumop))
else
e1:SetCondition(Auxiliary.NormalSetCondition2())
end
e1:SetValue(val)
c:RegisterEffect(e1)
return e1
end
function Auxiliary.NormalSetCondition1(min,max,f,opt)
return function (e,c,minc,zone,relzone,exeff)
if c==nil then return true end
local tp=c:GetControler()
local mg=Duel.GetTributeGroup(c):Match(Auxiliary.IsZone,nil,relzone,tp)
if f then
mg:Match(f,nil,tp)
end
local tributes=maplevel(c:GetLevel())
return (not opt or (tributes>0 and tributes~=max)) and minc<=min and Duel.CheckTribute(c,min,max,mg,tp,zone)
end
end
function Auxiliary.NormalSetCondition2()
return function (e,c,minc,zone,relzone,exeff)
if c==nil then return true end
return false
end
end
function Auxiliary.NormalSetTarget(min,max,f)
return function (e,tp,eg,ep,ev,re,r,rp,chk,c,minc,zone,relzone,exeff)
local mg=Duel.GetTributeGroup(c):Match(Auxiliary.IsZone,nil,relzone,tp)
if f then
mg:Match(f,nil,tp)
end
local g=Duel.SelectTribute(tp,c,min,max,mg,tp,zone,Duel.IsSummonCancelable())
if g and #g>0 then
g:KeepAlive()
e:SetLabelObject(g)
return true
end
return false
end
end
function Auxiliary.NormalSetOperation(min,max,sumop)
return function (e,tp,eg,ep,ev,re,r,rp,c,minc,zone,relzone,exeff)
local g=e:GetLabelObject()
c:SetMaterial(g)
Duel.Release(g,REASON_SUMMON+REASON_MATERIAL)
if sumop then
sumop(g:Clone(),e,tp,eg,ep,ev,re,r,rp,c,minc,zone,relzone,exeff)
end
g:DeleteGroup()
end
end