Commit 5d391c54 authored by 八宫一月's avatar 八宫一月 Committed by GitHub

Add auxiliary.register merged delayed event to single card (#2573)

* Update utility.lua

* Update c1688285.lua

* Update c34090915.lua

* Update c48626373.lua

* Update c59071624.lua

* Update c62849088.lua

* Update c63767246.lua

* Update c66399653.lua

* Update c72656408.lua

* Update c72971064.lua

* Update c95973569.lua

* Update c95973569.lua

* Update c72971064.lua

* Update c72656408.lua

* Update utility.lua

* Update c1688285.lua

* Update c34090915.lua

* Update c48626373.lua

* Update c59071624.lua

* Update c62849088.lua

* Update c63767246.lua

* Update c66399653.lua

* Update c72656408.lua

* Update c72971064.lua

* Update c95973569.lua

* Update utility.lua

* Update c1688285.lua

* Update c59071624.lua

* Update c66399653.lua

* Update c66399653.lua
Co-authored-by: wind2009's avatarWind2009-Louse <wind.jackey@qq.com>

* Update c59071624.lua
Co-authored-by: wind2009's avatarWind2009-Louse <wind.jackey@qq.com>

---------
Co-authored-by: wind2009's avatarWind2009-Louse <wind.jackey@qq.com>
parent f0df8717
......@@ -26,19 +26,17 @@ function s.initial_effect(c)
e2:SetOperation(s.thop)
c:RegisterEffect(e2)
--material
local custom_code=aux.RegisterMergedDelayedEvent_ToSingleCard(c,id,{EVENT_TO_GRAVE,EVENT_REMOVE})
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,1))
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e3:SetProperty(EFFECT_FLAG_DELAY)
e3:SetCode(EVENT_CUSTOM+id)
e3:SetCode(custom_code)
e3:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1,id+o)
e3:SetTarget(s.mttg)
e3:SetOperation(s.mtop)
c:RegisterEffect(e3)
local g=Group.CreateGroup()
aux.RegisterMergedDelayedEvent(c,id,EVENT_TO_GRAVE,g)
aux.RegisterMergedDelayedEvent(c,id,EVENT_REMOVE,g)
end
function s.imcon(e)
local c=e:GetHandler()
......
......@@ -8,18 +8,18 @@ function s.initial_effect(c)
e0:SetCode(EVENT_FREE_CHAIN)
c:RegisterEffect(e0)
--to deck
local custom_code=aux.RegisterMergedDelayedEvent_ToSingleCard(c,id,EVENT_REMOVE)
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_TODECK+CATEGORY_DRAW)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e1:SetCode(EVENT_CUSTOM+id)
e1:SetCode(custom_code)
e1:SetRange(LOCATION_SZONE)
e1:SetCountLimit(1,id)
e1:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET)
e1:SetTarget(s.tdtg)
e1:SetOperation(s.tdop)
c:RegisterEffect(e1)
aux.RegisterMergedDelayedEvent(c,id,EVENT_REMOVE)
--special summon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,1))
......
......@@ -15,15 +15,15 @@ function s.initial_effect(c)
e1:SetValue(LOCATION_REMOVED)
c:RegisterEffect(e1)
--material
local custom_code=aux.RegisterMergedDelayedEvent_ToSingleCard(c,id,EVENT_REMOVE)
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,1))
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e2:SetRange(LOCATION_MZONE)
e2:SetCode(EVENT_CUSTOM+id)
e2:SetCode(custom_code)
e2:SetCountLimit(1,EFFECT_COUNT_CODE_CHAIN)
e2:SetOperation(s.mtop)
c:RegisterEffect(e2)
aux.RegisterMergedDelayedEvent(c,id,EVENT_REMOVE)
--remove
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,2))
......
......@@ -25,11 +25,12 @@ function c59071624.initial_effect(c)
e2:SetOperation(c59071624.spop1)
c:RegisterEffect(e2)
--spsummon2
local custom_code=aux.RegisterMergedDelayedEvent_ToSingleCard(c,59071624,{EVENT_TO_GRAVE,EVENT_REMOVE})
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(59071624,1))
e3:SetCategory(CATEGORY_SPECIAL_SUMMON)
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e3:SetCode(EVENT_CUSTOM+59071624)
e3:SetCode(custom_code)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e3:SetRange(LOCATION_MZONE)
e3:SetCountLimit(1,59071625)
......@@ -38,9 +39,6 @@ function c59071624.initial_effect(c)
e3:SetTarget(c59071624.sptg2)
e3:SetOperation(c59071624.spop2)
c:RegisterEffect(e3)
local g=Group.CreateGroup()
aux.RegisterMergedDelayedEvent(c,59071624,EVENT_TO_GRAVE,g)
aux.RegisterMergedDelayedEvent(c,59071624,EVENT_REMOVE,g)
end
function c59071624.imcon(e)
return e:GetHandler():GetOverlayCount()>0
......
......@@ -15,10 +15,11 @@ function c62849088.initial_effect(c)
e1:SetOperation(c62849088.spop)
c:RegisterEffect(e1)
--destroy
local custom_code=aux.RegisterMergedDelayedEvent_ToSingleCard(c,62849088,EVENT_SPSUMMON_SUCCESS)
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(62849088,1))
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_CUSTOM+62849088)
e2:SetCode(custom_code)
e2:SetProperty(EFFECT_FLAG_DELAY)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1,62849089)
......@@ -26,7 +27,6 @@ function c62849088.initial_effect(c)
e2:SetTarget(c62849088.destg)
e2:SetOperation(c62849088.desop)
c:RegisterEffect(e2)
aux.RegisterMergedDelayedEvent(c,62849088,EVENT_SPSUMMON_SUCCESS)
end
function c62849088.cfilter(c)
return c:IsFaceup() and c:IsDisabled() and c:IsType(TYPE_EFFECT)
......
......@@ -27,18 +27,18 @@ function c63767246.initial_effect(c)
e2:SetOperation(c63767246.cbop)
c:RegisterEffect(e2)
--atk up
local custom_code=aux.RegisterMergedDelayedEvent_ToSingleCard(c,63767246,EVENT_DESTROYED)
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(63767246,2))
e3:SetCategory(CATEGORY_ATKCHANGE)
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e3:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DELAY)
e3:SetCode(EVENT_CUSTOM+63767246)
e3:SetCode(custom_code)
e3:SetRange(LOCATION_MZONE)
e3:SetCondition(c63767246.atkcon)
e3:SetTarget(c63767246.atktg)
e3:SetOperation(c63767246.atkop)
c:RegisterEffect(e3)
aux.RegisterMergedDelayedEvent(c,63767246,EVENT_DESTROYED)
end
aux.xyz_number[63767246]=38
function c63767246.discon(e,tp,eg,ep,ev,re,r,rp)
......
......@@ -10,19 +10,17 @@ function c66399653.initial_effect(c)
e1:SetOperation(c66399653.activate)
c:RegisterEffect(e1)
--equip
local custom_code=aux.RegisterMergedDelayedEvent_ToSingleCard(c,66399653,{EVENT_SUMMON_SUCCESS,EVENT_SPSUMMON_SUCCESS})
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(66399653,1))
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_CUSTOM+66399653)
e2:SetCode(custom_code)
e2:SetRange(LOCATION_FZONE)
e2:SetCountLimit(1)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e2:SetTarget(c66399653.eqtg)
e2:SetOperation(c66399653.eqop)
c:RegisterEffect(e2)
local g=Group.CreateGroup()
aux.RegisterMergedDelayedEvent(c,66399653,EVENT_SUMMON_SUCCESS,g)
aux.RegisterMergedDelayedEvent(c,66399653,EVENT_SPSUMMON_SUCCESS,g)
end
c66399653.has_text_type=TYPE_UNION
function c66399653.thfilter(c)
......
......@@ -20,18 +20,18 @@ function s.initial_effect(c)
e2:SetCondition(s.spcon2)
c:RegisterEffect(e2)
--banish summoned monster
local custom_code=aux.RegisterMergedDelayedEvent_ToSingleCard(c,id,EVENT_SPSUMMON_SUCCESS)
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(id,1))
e4:SetCategory(CATEGORY_REMOVE)
e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e4:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_CARD_TARGET)
e4:SetCode(EVENT_CUSTOM+id)
e4:SetCode(custom_code)
e4:SetRange(LOCATION_MZONE)
e4:SetCountLimit(1,id+o)
e4:SetTarget(s.rmtg)
e4:SetOperation(s.rmop)
c:RegisterEffect(e4)
aux.RegisterMergedDelayedEvent(c,id,EVENT_SPSUMMON_SUCCESS)
end
function s.spcon1(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetFieldGroupCount(tp,0,LOCATION_MZONE)==0
......
......@@ -12,11 +12,12 @@ function c72971064.initial_effect(c)
e1:SetValue(c72971064.atkval)
c:RegisterEffect(e1)
--to hand
local custom_code=aux.RegisterMergedDelayedEvent_ToSingleCard(c,72971064,EVENT_SPSUMMON_SUCCESS)
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(72971064,0))
e2:SetCategory(CATEGORY_TOHAND)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e2:SetCode(EVENT_CUSTOM+72971064)
e2:SetCode(custom_code)
e2:SetRange(LOCATION_MZONE)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e2:SetCountLimit(1,EFFECT_COUNT_CODE_CHAIN)
......@@ -25,7 +26,6 @@ function c72971064.initial_effect(c)
e2:SetTarget(c72971064.thtg)
e2:SetOperation(c72971064.thop)
c:RegisterEffect(e2)
aux.RegisterMergedDelayedEvent(c,72971064,EVENT_SPSUMMON_SUCCESS)
--recover
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(72971064,1))
......
......@@ -33,18 +33,18 @@ function s.initial_effect(c)
e3:SetValue(s.matchk)
c:RegisterEffect(e3)
--spsummon
local custom_code=aux.RegisterMergedDelayedEvent_ToSingleCard(c,id,EVENT_REMOVE)
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(id,1))
e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_O)
e4:SetCode(EVENT_CUSTOM+id)
e4:SetCode(custom_code)
e4:SetRange(LOCATION_MZONE)
e4:SetCountLimit(1)
e4:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DELAY)
e4:SetTarget(s.sptg)
e4:SetOperation(s.spop)
c:RegisterEffect(e4)
aux.RegisterMergedDelayedEvent(c,id,EVENT_REMOVE)
end
function s.rmcon(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
......
......@@ -1621,6 +1621,96 @@ function Auxiliary.MergedDelayEventCheck2(e,tp,eg,ep,ev,re,r,rp)
g:Clear()
end
end
--Once the card has been moved to the public area, it should be listened to again
function Auxiliary.RegisterMergedDelayedEvent_ToSingleCard(c,code,events)
local g=Group.CreateGroup()
g:KeepAlive()
local mt=getmetatable(c)
local seed=0
if type(events) == "table" then
for _, event in ipairs(events) do
seed = seed + event
end
else
seed = events
end
while(mt[seed]==true)
do
seed = seed + 1
end
mt[seed]=true
local event_code_single = (code ~ (seed << 16)) | EVENT_CUSTOM
if type(events) == "table" then
for _, event in ipairs(events) do
Auxiliary.RegisterMergedDelayedEvent_ToSingleCard_AddOperation(c,g,event,event_code_single)
end
else
Auxiliary.RegisterMergedDelayedEvent_ToSingleCard_AddOperation(c,g,events,event_code_single)
end
--listened to again
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_SET_AVAILABLE)
e3:SetCode(EVENT_MOVE)
e3:SetLabelObject(g)
e3:SetOperation(Auxiliary.ThisCardMovedToPublicResetCheck_ToSingleCard)
c:RegisterEffect(e3)
return event_code_single
end
function Auxiliary.RegisterMergedDelayedEvent_ToSingleCard_AddOperation(c,g,event,event_code_single)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(event)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_SET_AVAILABLE)
e1:SetRange(0xff)
e1:SetLabel(event_code_single)
e1:SetLabelObject(g)
e1:SetOperation(Auxiliary.MergedDelayEventCheck1_ToSingleCard)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetCode(EVENT_CHAIN_END)
e2:SetOperation(Auxiliary.MergedDelayEventCheck2_ToSingleCard)
c:RegisterEffect(e2)
end
function Auxiliary.ThisCardMovedToPublicResetCheck_ToSingleCard(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetOwner()
local g=e:GetLabelObject()
if c:IsFaceup() or c:IsPublic() then
g:Clear()
end
end
function Auxiliary.MergedDelayEventCheck1_ToSingleCard(e,tp,eg,ep,ev,re,r,rp)
local g=e:GetLabelObject()
local c=e:GetOwner()
g:Merge(eg)
if Duel.CheckEvent(EVENT_MOVE) then
_,meg=Duel.CheckEvent(EVENT_MOVE,true)
local c=e:GetOwner()
if meg:IsContains(c) and (c:IsFaceup() or c:IsPublic()) then
g:Clear()
end
end
if Duel.GetCurrentChain()==0 and #g>0 and not Duel.CheckEvent(EVENT_CHAIN_END) then
local _eg=g:Clone()
Duel.RaiseEvent(_eg,e:GetLabel(),re,r,rp,ep,ev)
g:Clear()
end
end
function Auxiliary.MergedDelayEventCheck2_ToSingleCard(e,tp,eg,ep,ev,re,r,rp)
local g=e:GetLabelObject()
if Duel.CheckEvent(EVENT_MOVE) then
_,meg=Duel.CheckEvent(EVENT_MOVE,true)
local c=e:GetOwner()
if meg:IsContains(c) and (c:IsFaceup() or c:IsPublic()) then
g:Clear()
end
end
if #g>0 then
local _eg=g:Clone()
Duel.RaiseEvent(_eg,e:GetLabel(),re,r,rp,ep,ev)
g:Clear()
end
end
--B.E.S. remove counter
function Auxiliary.EnableBESRemove(c)
local e1=Effect.CreateEffect(c)
......
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