Commit 5d1c4f8e authored by Nemo Ma's avatar Nemo Ma

Update glitchylib_regeff.lua

parent 9aa154b0
...@@ -71,7 +71,7 @@ function Auxiliary.CheckAlreadyRegisteredEffects() ...@@ -71,7 +71,7 @@ function Auxiliary.CheckAlreadyRegisteredEffects()
e1:SetCode(EVENT_PREDRAW) e1:SetCode(EVENT_PREDRAW)
e1:OPT() e1:OPT()
e1:SetOperation(function(e) e1:SetOperation(function(e)
local g=Duel.Group(function(c) return not c:IsOriginalType(TYPE_NORMAL) end,0,LOCATION_ALL,LOCATION_ALL,nil) local g=Duel.Group(function(c) return not c:IsOriginalType(TYPE_NORMAL) end,0,LOCATION_ALL,0,nil)
for tc in aux.Next(g) do for tc in aux.Next(g) do
if not global_card_effect_table[tc] then if not global_card_effect_table[tc] then
local code=tc:GetOriginalCode() local code=tc:GetOriginalCode()
...@@ -115,7 +115,12 @@ if not global_card_effect_table_global_check then ...@@ -115,7 +115,12 @@ if not global_card_effect_table_global_check then
if not global_card_effect_table[self] then global_card_effect_table[self]={} end if not global_card_effect_table[self] then global_card_effect_table[self]={} end
table.insert(global_card_effect_table[self],e) table.insert(global_card_effect_table[self],e)
local code=e:GetCode() local typ,code=e:GetType(),e:GetCode()
local IsSingleOrField=typ==EFFECT_TYPE_SINGLE or typ==EFFECT_TYPE_FIELD
local IsInherentSummonProc=code==EFFECT_SPSUMMON_PROC or code==EFFECT_SPSUMMON_PROC_G
local IsHasExceptionType=typ==EFFECT_TYPE_XMATERIAL or typ==EFFECT_TYPE_XMATERIAL+EFFECT_TYPE_FIELD or typ&EFFECT_TYPE_GRANT~=0
local selfp,oppo=e:GLGetTargetRange() local selfp,oppo=e:GLGetTargetRange()
local condition,cost,tg,op,val=e:GetCondition(),e:GetCost(),e:GetTarget(),e:GetOperation(),e:GetValue() local condition,cost,tg,op,val=e:GetCondition(),e:GetCost(),e:GetTarget(),e:GetOperation(),e:GetValue()
...@@ -183,71 +188,75 @@ if not global_card_effect_table_global_check then ...@@ -183,71 +188,75 @@ if not global_card_effect_table_global_check then
end end
--Define self_reference_effect --Define self_reference_effect
if condition and ((e:GetCode()==EFFECT_SPSUMMON_PROC or e:GetCode()==EFFECT_SPSUMMON_PROC_G) or not (e:GetType()==EFFECT_TYPE_FIELD or e:GetType()==EFFECT_TYPE_SINGLE or e:GetType()==EFFECT_TYPE_XMATERIAL or e:GetType()==EFFECT_TYPE_XMATERIAL+EFFECT_TYPE_FIELD or e:GetType()&EFFECT_TYPE_GRANT~=0)) then if condition and not IsHasExceptionType then
local newcon = function(...) local newcon = function(...)
self_reference_effect=e local x={...}
local previous_sre=self_reference_effect
self_reference_effect=x[1]
local x={...} local x={...}
if type(x[2])=="number" and (x[2]==0 or x[2]==1) then if type(x[2])=="number" and (x[2]==0 or x[2]==1) then
self_reference_tp = x[2] self_reference_tp = x[2]
end end
return condition(...) local res=condition(table.unpack(x))
self_reference_effect=previous_sre
return res
end end
e:SetCondition(newcon) e:SetCondition(newcon)
end end
if cost and not (e:GetType()==EFFECT_TYPE_FIELD or e:GetType()==EFFECT_TYPE_SINGLE or e:GetType()==EFFECT_TYPE_XMATERIAL or e:GetType()==EFFECT_TYPE_XMATERIAL+EFFECT_TYPE_FIELD or e:GetType()&EFFECT_TYPE_GRANT~=0) then if cost and not IsHasExceptionType then
local newcost = function(...) local newcost = function(...)
self_reference_effect=e
local x={...} local x={...}
local previous_sre=self_reference_effect
self_reference_effect=x[1]
if #x>1 and type(x[2])=="number" and (x[2]==0 or x[2]==1) then if #x>1 and type(x[2])=="number" and (x[2]==0 or x[2]==1) then
self_reference_tp = x[2] self_reference_tp = x[2]
end end
return cost(...) local res=cost(table.unpack(x))
self_reference_effect=previous_sre
return res
end end
e:SetCost(newcost) e:SetCost(newcost)
end end
if tg then if tg and not IsHasExceptionType then
if e:GetCode()==EFFECT_SPSUMMON_PROC or e:GetCode()==EFFECT_SPSUMMON_PROC_G then local newtg = function(...)
local newtg = function(...) local x={...}
self_reference_effect=e local previous_sre=self_reference_effect
local x={...} self_reference_effect=x[1]
if #x>1 and type(x[2])=="number" and (x[2]==0 or x[2]==1) then if #x>1 and type(x[2])=="number" and (x[2]==0 or x[2]==1) then
self_reference_tp = x[2] self_reference_tp = x[2]
end
return tg(...)
end
e:SetTarget(newtg)
elseif not (e:GetType()==EFFECT_TYPE_FIELD or e:GetType()==EFFECT_TYPE_SINGLE or e:GetType()==EFFECT_TYPE_XMATERIAL or e:GetType()==EFFECT_TYPE_XMATERIAL+EFFECT_TYPE_FIELD or e:GetType()&EFFECT_TYPE_GRANT~=0) then
local newtg = function(...)
self_reference_effect=e
local x={...}
if #x>1 and type(x[2])=="number" and (x[2]==0 or x[2]==1) then
self_reference_tp = x[2]
end
return tg(...)
end end
e:SetTarget(newtg) local res=tg(table.unpack(x))
end self_reference_effect=previous_sre
return res
end
e:SetTarget(newtg)
end end
if op and ((e:GetCode()==EFFECT_SPSUMMON_PROC or e:GetCode()==EFFECT_SPSUMMON_PROC_G) or not (e:GetType()==EFFECT_TYPE_FIELD or e:GetType()==EFFECT_TYPE_SINGLE or e:GetType()==EFFECT_TYPE_XMATERIAL or e:GetType()==EFFECT_TYPE_XMATERIAL+EFFECT_TYPE_FIELD or e:GetType()&EFFECT_TYPE_GRANT~=0)) then if op and not IsHasExceptionType then
local newop = function(...) local newop = function(...)
self_reference_effect=e
local x={...} local x={...}
local previous_sre=self_reference_effect
self_reference_effect = x[1]
if #x>1 and type(x[2])=="number" and (x[2]==0 or x[2]==1) then if #x>1 and type(x[2])=="number" and (x[2]==0 or x[2]==1) then
self_reference_tp = x[2] self_reference_tp = x[2]
end end
return op(...) local res=op(table.unpack(x))
self_reference_effect=previous_sre
return res
end end
e:SetOperation(newop) e:SetOperation(newop)
end end
if val then if val and type(val)=="function" and not IsHasExceptionType then
if type(val)=="function" and ((e:GetCode()==EFFECT_SPSUMMON_PROC or e:GetCode()==EFFECT_SPSUMMON_PROC_G) or not (e:GetType()==EFFECT_TYPE_FIELD or e:GetType()==EFFECT_TYPE_SINGLE or e:GetType()==EFFECT_TYPE_XMATERIAL or e:GetType()==EFFECT_TYPE_XMATERIAL+EFFECT_TYPE_FIELD or e:GetType()&EFFECT_TYPE_GRANT~=0)) then local newval = function(...)
local newval = function(...) local x={...}
self_reference_effect=e local previous_sre=self_reference_effect
return val(...) if aux.GetValueType(x[1])=="Effect" then
self_reference_effect = x[1]
end end
e:SetValue(newval) local res=val(...)
self_reference_effect=previous_sre
end return res
end
e:SetValue(newval)
end end
if aux.PreventSecondRegistration then return end if aux.PreventSecondRegistration then return end
return self.register_global_card_effect_table(self,e,forced) return self.register_global_card_effect_table(self,e,forced)
...@@ -264,7 +273,12 @@ if not global_duel_effect_table_global_check then ...@@ -264,7 +273,12 @@ if not global_duel_effect_table_global_check then
if not global_duel_effect_table[tp] then global_duel_effect_table[tp]={} end if not global_duel_effect_table[tp] then global_duel_effect_table[tp]={} end
table.insert(global_duel_effect_table[tp],e) table.insert(global_duel_effect_table[tp],e)
local code=e:GetCode() local typ,code=e:GetType(),e:GetCode()
local IsSingleOrField=typ==EFFECT_TYPE_SINGLE or typ==EFFECT_TYPE_FIELD
local IsInherentSummonProc=code==EFFECT_SPSUMMON_PROC or code==EFFECT_SPSUMMON_PROC_G
local IsHasExceptionType=typ==EFFECT_TYPE_XMATERIAL or typ==EFFECT_TYPE_XMATERIAL+EFFECT_TYPE_FIELD or typ&EFFECT_TYPE_GRANT~=0
local condition,cost,tg,op,val=e:GetCondition(),e:GetCost(),e:GetTarget(),e:GetOperation(),e:GetValue() local condition,cost,tg,op,val=e:GetCondition(),e:GetCost(),e:GetTarget(),e:GetOperation(),e:GetValue()
--Damage Replacement Effects --Damage Replacement Effects
...@@ -297,71 +311,77 @@ if not global_duel_effect_table_global_check then ...@@ -297,71 +311,77 @@ if not global_duel_effect_table_global_check then
end end
--Define self_reference_effect --Define self_reference_effect
if condition and ((e:GetCode()==EFFECT_SPSUMMON_PROC or e:GetCode()==EFFECT_SPSUMMON_PROC_G) or not (e:GetType()==EFFECT_TYPE_FIELD or e:GetType()==EFFECT_TYPE_SINGLE or e:GetType()&EFFECT_TYPE_GRANT~=0)) then if condition and not IsHasExceptionType then
local newcon = function(...) local newcon = function(...)
self_reference_effect=e
local x={...} local x={...}
local previous_sre=self_reference_effect
self_reference_effect=x[1]
if #x>1 and type(x[2])=="number" and (x[2]==0 or x[2]==1) then if #x>1 and type(x[2])=="number" and (x[2]==0 or x[2]==1) then
self_reference_tp = x[2] self_reference_tp = x[2]
end end
return condition(...) local res=condition(table.unpack(x))
self_reference_effect=previous_sre
return res
end end
e:SetCondition(newcon) e:SetCondition(newcon)
end end
if cost and ((e:GetCode()==EFFECT_SPSUMMON_PROC or e:GetCode()==EFFECT_SPSUMMON_PROC_G) or not (e:GetType()==EFFECT_TYPE_FIELD or e:GetType()==EFFECT_TYPE_SINGLE or e:GetType()&EFFECT_TYPE_GRANT~=0)) then if cost and not IsHasExceptionType then
local newcost = function(...) local newcost = function(...)
self_reference_effect=e
local x={...} local x={...}
local previous_sre=self_reference_effect
self_reference_effect=x[1]
if #x>1 and type(x[2])=="number" and (x[2]==0 or x[2]==1) then if #x>1 and type(x[2])=="number" and (x[2]==0 or x[2]==1) then
self_reference_tp = x[2] self_reference_tp = x[2]
end end
return cost(...) local res=cost(table.unpack(x))
self_reference_effect=previous_sre
return res
end end
e:SetCost(newcost) e:SetCost(newcost)
end end
if tg then if tg and not IsHasExceptionType then
if e:GetCode()==EFFECT_SPSUMMON_PROC or e:GetCode()==EFFECT_SPSUMMON_PROC_G then local newtg = function(...)
local newtg = function(...) local x={...}
self_reference_effect=e local previous_sre=self_reference_effect
local x={...} self_reference_effect=x[1]
if #x>1 and type(x[2])=="number" and (x[2]==0 or x[2]==1) then local x={...}
self_reference_tp = x[2] if #x>1 and type(x[2])=="number" and (x[2]==0 or x[2]==1) then
end self_reference_tp = x[2]
return tg(...)
end
e:SetTarget(newtg)
elseif not (e:GetType()==EFFECT_TYPE_FIELD or e:GetType()==EFFECT_TYPE_SINGLE or e:GetType()&EFFECT_TYPE_GRANT~=0) then
local newtg = function(...)
self_reference_effect=e
local x={...}
if #x>1 and type(x[2])=="number" and (x[2]==0 or x[2]==1) then
self_reference_tp = x[2]
end
return tg(...)
end end
e:SetTarget(newtg) local res=tg(table.unpack(x))
end self_reference_effect=previous_sre
return res
end
e:SetTarget(newtg)
end end
if op and ((e:GetCode()==EFFECT_SPSUMMON_PROC or e:GetCode()==EFFECT_SPSUMMON_PROC_G) or not (e:GetType()==EFFECT_TYPE_FIELD or e:GetType()==EFFECT_TYPE_SINGLE or e:GetType()&EFFECT_TYPE_GRANT~=0)) then if op and not IsHasExceptionType then
local newop = function(...) local newop = function(...)
self_reference_effect=e
local x={...} local x={...}
local previous_sre=self_reference_effect
self_reference_effect=x[1]
if #x>1 and type(x[2])=="number" and (x[2]==0 or x[2]==1) then if #x>1 and type(x[2])=="number" and (x[2]==0 or x[2]==1) then
self_reference_tp = x[2] self_reference_tp = x[2]
end end
return op(...) local res=op(table.unpack(x))
self_reference_effect=previous_sre
return res
end end
e:SetOperation(newop) e:SetOperation(newop)
end end
if val then if val and type(val)=="function" and not IsHasExceptionType then
if type(val)=="function" and ((e:GetCode()==EFFECT_SPSUMMON_PROC or e:GetCode()==EFFECT_SPSUMMON_PROC_G) or not (e:GetType()==EFFECT_TYPE_FIELD or e:GetType()==EFFECT_TYPE_SINGLE or e:GetType()&EFFECT_TYPE_GRANT~=0)) then local newval = function(...)
local newval = function(...) local x={...}
self_reference_effect=e local previous_sre=self_reference_effect
return val(...) if aux.GetValueType(x[1])=="Effect" then
self_reference_effect = x[1]
end end
e:SetValue(newval) local res=val(...)
self_reference_effect=previous_sre
return res
end
e:SetValue(newval)
end
end end
if aux.PreventSecondRegistration then return end if aux.PreventSecondRegistration then return end
return Duel.register_global_duel_effect_table(e,tp) return Duel.register_global_duel_effect_table(e,tp)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment