Commit 50c30893 authored by POLYMER's avatar POLYMER

fix

parent eac5d6dc
......@@ -767,11 +767,6 @@
53796188 0
53796189 0
53796190 0
53796193 0
53796194 0
53796195 0
53796196 0
53796197 0
58510970 0
60000002 0
60000003 0
......
No preview for this file type
......@@ -12,14 +12,14 @@ function cm.initial_effect(c)
c:RegisterEffect(e1)
local e2=e1:Clone()
e2:SetDescription(aux.Stringid(m,1))
e2:SetCategory(CATEGORY_REMOVE)
e2:SetCategory(CATEGORY_DESTROY)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetTarget(cm.target2)
e2:SetOperation(cm.activate2)
c:RegisterEffect(e2)
local e3=e2:Clone()
e3:SetDescription(aux.Stringid(m,2))
e3:SetCategory(CATEGORY_TOHAND)
e3:SetCategory(CATEGORY_REMOVE)
e3:SetTarget(cm.target3)
e3:SetOperation(cm.activate3)
c:RegisterEffect(e3)
......
if not require and dofile then function require(str) return dofile(str..".lua") end end
if not pcall(function() require("expansions/script/c53702500") end) then require("script/c53702500") end
local s,id,o=GetID()
function s.initial_effect(c)
aux.AddCodeList(c,53796195)
c:EnableReviveLimit()
local e0=Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_SINGLE)
e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e0:SetCode(EFFECT_SPSUMMON_CONDITION)
e0:SetValue(function(e,se,sp,st)return se==e:GetLabelObject() and Duel.GetFlagEffect(e:GetHandlerPlayer(),id)==0 end)
c:RegisterEffect(e0)
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,12))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetRange(LOCATION_EXTRA)
e1:SetCountLimit(1,EFFECT_COUNT_CODE_CHAIN)
e1:SetHintTiming(0,TIMING_DRAW_PHASE+TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e1:SetCondition(s.spcon)
e1:SetCost(s.spcost)
e1:SetTarget(s.sptg)
e1:SetOperation(s.spop)
c:RegisterEffect(e1)
e0:SetLabelObject(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_SUMMON_COST)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetRange(LOCATION_MZONE)
e2:SetTargetRange(0xff,0xff)
e2:SetLabel(0)
e2:SetCondition(s.costcon)
e2:SetOperation(s.costop)
c:RegisterEffect(e2)
local e3=e2:Clone()
e3:SetCode(EFFECT_SPSUMMON_COST)
c:RegisterEffect(e3)
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(id,13))
e4:SetCategory(CATEGORY_TODECK+CATEGORY_TOGRAVE)
e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e4:SetCode(EVENT_CUSTOM+id)
e4:SetRange(LOCATION_MZONE)
e4:SetLabel(0)
e4:SetCondition(s.tgcon)
e4:SetTarget(s.tgtg)
c:RegisterEffect(e4)
e2:SetLabelObject(e4)
e3:SetLabelObject(e4)
local g=Group.CreateGroup()
g:KeepAlive()
local e5=Effect.CreateEffect(c)
e5:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e5:SetCode(EVENT_SUMMON_SUCCESS)
e5:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e5:SetRange(LOCATION_MZONE)
e5:SetOperation(s.MergedDelayEventCheck1(g,e2,e3,e4))
c:RegisterEffect(e5)
local e6=e5:Clone()
e6:SetCode(EVENT_SPSUMMON_SUCCESS)
c:RegisterEffect(e6)
local e7=e5:Clone()
e7:SetCode(EVENT_CHAIN_END)
e7:SetOperation(s.MergedDelayEventCheck2(g,e2,e3,e4))
c:RegisterEffect(e7)
local e8=Effect.CreateEffect(c)
e8:SetType(EFFECT_TYPE_FIELD)
e8:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_CANNOT_DISABLE)
e8:SetCode(id)
e8:SetRange(LOCATION_MZONE)
e8:SetTargetRange(1,1)
c:RegisterEffect(e8)
if not s.global_check then
s.global_check=true
if c53796195 and not c53796195[0] then
c53796195[0]={}
c53796195[1]={}
end
local f1=aux.PendOperation
aux.PendOperation=function()
local func1=f1()
local func2=func1
func2=function(e,tp,eg,ep,ev,re,r,rp,c,sg,og)
local res=func1(e,tp,eg,ep,ev,re,r,rp,c,sg,og)
if Duel.IsPlayerAffectedByEffect(0,id) then s.pendcount=#sg end
return res
end
return func2
end
local f2=Duel.SpecialSummon
Duel.SpecialSummon=function(tg,...)
if Duel.IsPlayerAffectedByEffect(0,id) then if aux.GetValueType(tg)=="Card" then s.pendcount=1 else s.pendcount=#tg end end
local ct=f2(tg,...)
s.pendcount=0 s.pendcheck=0
return ct
end
end
end
s.pendcount=0
s.pendcheck=0
function s.MergedDelayEventCheck1(g,e2,e3,e4)
return function(e,tp,eg,ep,ev,re,r,rp)
g:Merge(eg)
if Duel.GetCurrentChain()==0 and not Duel.CheckEvent(EVENT_CHAIN_END) then
local _eg=g:Clone()
local t=SNNM.Remove(SNNM.Merged({e2:GetLabel()},{e3:GetLabel()}),0)
if #t>0 then e4:SetLabel(table.unpack(t)) Duel.RaiseEvent(Group.__add(_eg,e:GetHandler()),EVENT_CUSTOM+id,re,r,rp,ep,ev) end
e2:SetLabel(0) e3:SetLabel(0)
g:Clear()
end
end
end
function s.MergedDelayEventCheck2(g,e2,e3,e4)
return function(e,tp,eg,ep,ev,re,r,rp)
if #g>0 then
local _eg=g:Clone()
local t=SNNM.Remove(SNNM.Merged({e2:GetLabel()},{e3:GetLabel()}),0)
if #t>0 then e4:SetLabel(table.unpack(t)) Duel.RaiseEvent(Group.__add(_eg,e:GetHandler()),EVENT_CUSTOM+id,re,r,rp,ep,ev) end
e2:SetLabel(0) e3:SetLabel(0)
g:Clear()
end
end
end
function s.cfilter(c)
return c:IsCode(53796195) and c:IsFaceup()
end
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_EXTRA,0,1,nil)
end
function s.spcfilter(c,e,tp)
return c:IsFaceup() and c:IsAbleToExtraAsCost() and Duel.GetLocationCountFromEx(tp,tp,c,e:GetHandler()) and (aux.IsCodeListed(c,53796195) or c:IsType(0x40))
end
function s.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.spcfilter,tp,LOCATION_MZONE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local g=Duel.SelectMatchingCard(tp,s.spcfilter,tp,LOCATION_MZONE,0,1,1,nil,e,tp)
Duel.SendtoDeck(g,nil,0,REASON_COST)
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToEffect(e) then return end
if Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)==0 then return end
c:CompleteProcedure()
Duel.RegisterFlagEffect(tp,id,RESET_PHASE+SNNM.GetCurrentPhase(),0,1)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_IMMUNE_EFFECT)
e1:SetTargetRange(LOCATION_ONFIELD,0)
e1:SetValue(s.efilter)
e1:SetReset(RESET_CHAIN)
Duel.RegisterEffect(e1,tp)
end
function s.efilter(e,te,c)
if te:GetHandlerPlayer()==e:GetHandlerPlayer() or not te:IsActivated() then return false end
if not te:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then return true end
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
return not g or not g:IsContains(c)
end
function s.costcon(e)
return Duel.IsExistingMatchingCard(Card.IsFacedown,e:GetHandlerPlayer(),LOCATION_REMOVED,0,1,nil)
end
function s.costop(e,tp,eg,ep,ev,re,r,rp)
local p=e:GetHandlerPlayer()
local e1=e:GetLabelObject()
local check=true
if e:GetHandler():IsHasEffect(EFFECT_CANNOT_TRIGGER) then check=false end
local p=e:GetHandlerPlayer()
local le1={Duel.IsPlayerAffectedByEffect(p,EFFECT_CANNOT_ACTIVATE)}
for _,v in pairs(le1) do
local val=v:GetValue()
if aux.GetValueType(val)=="number" or val(v,e1,p) then check=false end
end
local le2={Duel.IsPlayerAffectedByEffect(p,EFFECT_ACTIVATE_COST)}
for _,v in pairs(le2) do
local cost=v:GetCost()
if cost and not cost(v,e1,p) then
local tg=v:GetTarget()
if not tg or tg(v,e1,p) then check=false end
end
end
if tp==p or not check then s.pendcount=0 s.pendcheck=0 return end
if s.pendcheck==0 then s.pendcount=(s.pendcount>0 and s.pendcount) or 1 end
if s.pendcount>0 and s.pendcheck==0 then
s.pendcheck=s.pendcount-1
local g=Duel.GetMatchingGroup(aux.AND(Card.IsFacedown,Card.IsAbleToDeck),p,LOCATION_REMOVED,0,nil)
if g:GetClassCount(Card.GetCode)>=s.pendcount and Duel.SelectEffectYesNo(p,e:GetHandler(),aux.Stringid(id,s.pendcount-1)) then
local ag=Group.CreateGroup()
local codes={}
for c in aux.Next(g) do
local code=c:GetCode()
if not ag:IsExists(Card.IsCode,1,nil,code) then
ag:AddCard(c)
table.insert(codes,code)
end
end
table.sort(codes)
local ct=#codes
local nt={codes[1],OPCODE_ISCODE}
if ct>1 then
for i=2,ct do
table.insert(nt,codes[i])
table.insert(nt,OPCODE_ISCODE)
table.insert(nt,OPCODE_OR)
end
end
local t={}
Duel.Hint(HINT_SELECTMSG,p,HINTMSG_CODE)
while s.pendcount>0 and ct>0 do
local ac=Duel.AnnounceCard(p,table.unpack(nt))
table.insert(t,ac)
table.insert(nt,ac)
table.insert(nt,OPCODE_ISCODE)
table.insert(nt,OPCODE_NOT)
table.insert(nt,OPCODE_AND)
ct=ct-1
s.pendcount=s.pendcount-1
end
if e:GetLabel()==0 then e:SetLabel(table.unpack(t)) else e:SetLabel(table.unpack(SNNM.Merged({e:GetLabel()},t))) end
end
s.pendcount=0
end
end
function s.tgcon(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(Card.IsSummonPlayer,1,nil,1-tp) and eg:IsContains(e:GetHandler())
end
function s.tgtg(e,tp,eg,ep,ev,re,r,rp,chk)
local t={e:GetLabel()}
local table=t
if chk==0 then return true end
e:SetOperation(s.tgop(table))
local g=eg:Filter(Card.IsSummonPlayer,nil,1-tp)
Duel.SetTargetCard(g)
Duel.SetOperationInfo(0,CATEGORY_TODECK,nil,1,tp,LOCATION_REMOVED)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,g,g:GetCount(),0,0)
end
function s.tdfilter(c,t,g)
return c:IsFacedown() and c:IsCode(table.unpack(t)) and g:IsExists(Card.IsCode,1,nil,c:GetCode()) and c:IsAbleToDeck()
end
function s.tgop(t)
return function(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetTargetsRelateToChain():Filter(Card.IsFaceup,nil)
local tdg=Duel.GetMatchingGroup(s.tdfilter,tp,LOCATION_REMOVED,0,nil,t,g)
if #tdg>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local sg=tdg:SelectSubGroup(tp,aux.dncheck,false,1,#g)
if sg then
Duel.ConfirmCards(1-tp,sg)
local tg=g:Filter(function(c,sg)return sg:IsExists(Card.IsCode,1,nil,c:GetCode())end,nil,sg)
if Duel.SendtoDeck(sg,nil,2,REASON_EFFECT)~=0 and sg:IsExists(Card.IsLocation,1,nil,LOCATION_DECK+LOCATION_EXTRA) then Duel.SendtoGrave(tg,REASON_RULE) end
end
end
if c53796195 and not SNNM.AllExist(c53796195[tp],t) and Duel.SelectYesNo(tp,aux.Stringid(id,14)) then SNNM.Merge(c53796195[tp],t) end
e:SetOperation(nil)
end
end
if not require and dofile then function require(str) return dofile(str..".lua") end end
if not pcall(function() require("expansions/script/c53702500") end) then require("script/c53702500") end
local s,id,o=GetID()
function s.initial_effect(c)
aux.AddCodeList(c,53796195)
c:EnableReviveLimit()
local e0=Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_SINGLE)
e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e0:SetCode(EFFECT_SPSUMMON_CONDITION)
e0:SetValue(function(e,se,sp,st)return se==e:GetLabelObject() and Duel.GetFlagEffect(e:GetHandlerPlayer(),id)==0 end)
c:RegisterEffect(e0)
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,12))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetRange(LOCATION_EXTRA)
e1:SetCountLimit(1,EFFECT_COUNT_CODE_CHAIN)
e1:SetHintTiming(0,TIMING_DRAW_PHASE+TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e1:SetCondition(s.spcon)
e1:SetCost(s.spcost)
e1:SetTarget(s.sptg)
e1:SetOperation(s.spop)
c:RegisterEffect(e1)
e0:SetLabelObject(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EFFECT_SEND_REPLACE)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetRange(LOCATION_MZONE)
e2:SetTarget(s.reptg)
e2:SetValue(s.repval)
c:RegisterEffect(e2)
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(id,13))
e3:SetCategory(CATEGORY_TODECK+CATEGORY_REMOVE)
e3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e3:SetCode(EVENT_CUSTOM+id)
e3:SetRange(LOCATION_MZONE)
e3:SetLabel(0)
e3:SetCondition(s.rmcon)
e3:SetTarget(s.rmtg)
c:RegisterEffect(e3)
e2:SetLabelObject(e3)
local g=Group.CreateGroup()
g:KeepAlive()
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e4:SetCode(EVENT_TO_GRAVE)
e4:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e4:SetRange(LOCATION_MZONE)
e4:SetOperation(s.MergedDelayEventCheck1(g,e2,e3))
c:RegisterEffect(e4)
local e5=e4:Clone()
e5:SetCode(EVENT_CHAIN_END)
e5:SetOperation(s.MergedDelayEventCheck2(g,e2,e3))
c:RegisterEffect(e5)
if not s.global_check then
s.global_check=true
if c53796195 and not c53796195[0] then
c53796195[0]={}
c53796195[1]={}
end
end
end
function s.MergedDelayEventCheck1(g,e2,e3)
return function(e,tp,eg,ep,ev,re,r,rp)
g:Merge(eg)
if Duel.GetCurrentChain()==0 and not Duel.CheckEvent(EVENT_CHAIN_END) then
local _eg=g:Clone()
local t=SNNM.Remove({e2:GetLabel()},0)
if #t>0 then e3:SetLabel(table.unpack(t)) Duel.RaiseEvent(Group.__add(_eg,e:GetHandler()),EVENT_CUSTOM+id,re,r,rp,ep,ev) end
e2:SetLabel(0)
g:Clear()
end
end
end
function s.MergedDelayEventCheck2(g,e2,e3)
return function(e,tp,eg,ep,ev,re,r,rp)
if #g>0 then
local _eg=g:Clone()
local t=SNNM.Remove({e2:GetLabel()},0)
if #t>0 then e3:SetLabel(table.unpack(t)) Duel.RaiseEvent(Group.__add(_eg,e:GetHandler()),EVENT_CUSTOM+id,re,r,rp,ep,ev) end
e2:SetLabel(0) e3:SetLabel(0)
g:Clear()
end
end
end
function s.cfilter(c)
return c:IsCode(53796195) and c:IsFaceup()
end
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_EXTRA,0,1,nil)
end
function s.spcfilter(c,e,tp)
return c:IsFaceup() and c:IsAbleToExtraAsCost() and Duel.GetLocationCountFromEx(tp,tp,c,e:GetHandler())>0 and (aux.IsCodeListed(c,53796195) or c:IsType(TYPE_LINK))
end
function s.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.spcfilter,tp,LOCATION_MZONE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local g=Duel.SelectMatchingCard(tp,s.spcfilter,tp,LOCATION_MZONE,0,1,1,nil,e,tp)
Duel.SendtoDeck(g,nil,0,REASON_COST)
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToEffect(e) then return end
if Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)==0 then return end
c:CompleteProcedure()
Duel.RegisterFlagEffect(tp,id,RESET_PHASE+SNNM.GetCurrentPhase(),0,1)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_IMMUNE_EFFECT)
e1:SetTargetRange(LOCATION_REMOVED,0)
e1:SetValue(s.efilter)
e1:SetReset(RESET_PHASE+SNNM.GetCurrentPhase())
Duel.RegisterEffect(e1,tp)
end
function s.efilter(e,te,c)
return te:GetHandlerPlayer()~=e:GetHandlerPlayer()
end
function s.repfilter(c,tp)
return c:IsControler(1-tp) and c:GetDestination()==LOCATION_GRAVE and c:IsAbleToRemove(tp,POS_FACEDOWN)
end
function s.reptg(e,tp,eg,ep,ev,re,r,rp,chk)
local repg=eg:Filter(s.repfilter,nil,tp)
local gct=#repg
local g=Duel.GetMatchingGroup(aux.AND(Card.IsFacedown,Card.IsAbleToDeck),e:GetHandlerPlayer(),LOCATION_REMOVED,0,nil)
local e1=e:GetLabelObject()
local check=true
if e:GetHandler():IsHasEffect(EFFECT_CANNOT_TRIGGER) then check=false end
local p=e:GetHandlerPlayer()
local le1={Duel.IsPlayerAffectedByEffect(p,EFFECT_CANNOT_ACTIVATE)}
for _,v in pairs(le1) do
local val=v:GetValue()
if aux.GetValueType(val)=="number" or val(v,e1,p) then check=false end
end
local le2={Duel.IsPlayerAffectedByEffect(p,EFFECT_ACTIVATE_COST)}
for _,v in pairs(le2) do
local cost=v:GetCost()
if cost and not cost(v,e1,p) then
local tg=v:GetTarget()
if not tg or tg(v,e1,p) then check=false end
end
end
if chk==0 then return gct>0 and g:GetClassCount(Card.GetCode)>=gct and check end
local sel=gct-1
if sel>10 then sel=10 end
if Duel.SelectEffectYesNo(tp,e:GetHandler(),aux.Stringid(id,sel)) then
local ag=Group.CreateGroup()
local codes={}
for c in aux.Next(g) do
local code=c:GetCode()
if not ag:IsExists(Card.IsCode,1,nil,code) then
ag:AddCard(c)
table.insert(codes,code)
end
end
table.sort(codes)
local ct=#codes
local nt={codes[1],OPCODE_ISCODE}
if ct>1 then
for i=2,ct do
table.insert(nt,codes[i])
table.insert(nt,OPCODE_ISCODE)
table.insert(nt,OPCODE_OR)
end
end
local t={}
Duel.Hint(HINT_SELECTMSG,p,HINTMSG_CODE)
while gct>0 and ct>0 do
local ac=Duel.AnnounceCard(p,table.unpack(nt))
table.insert(t,ac)
table.insert(nt,ac)
table.insert(nt,OPCODE_ISCODE)
table.insert(nt,OPCODE_NOT)
table.insert(nt,OPCODE_AND)
ct=ct-1
gct=gct-1
end
if e:GetLabel()==0 then e:SetLabel(table.unpack(t)) else e:SetLabel(table.unpack(SNNM.Merged({e:GetLabel()},t))) end
end
return false
end
function s.repval(e,c)
return false
end
function s.rmcon(e,tp,eg,ep,ev,re,r,rp)
return eg:IsExists(Card.IsPreviousControler,1,nil,1-tp) and eg:IsContains(e:GetHandler())
end
function s.rmtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local t={e:GetLabel()}
local table=t
if chk==0 then return true end
e:SetOperation(s.rmop(table))
local g=eg:Filter(Card.IsPreviousControler,nil,1-tp)
Duel.SetTargetCard(g)
Duel.SetOperationInfo(0,CATEGORY_TODECK,nil,1,tp,LOCATION_REMOVED)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,g,g:GetCount(),0,0)
end
function s.tdfilter(c,t,g)
return c:IsFacedown() and c:IsCode(table.unpack(t)) and g:IsExists(Card.IsCode,1,nil,c:GetCode()) and c:IsAbleToDeck()
end
function s.rmop(t)
return function(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetTargetsRelateToChain():Filter(Card.IsAbleToRemove,nil,tp,POS_FACEDOWN)
local tdg=Duel.GetMatchingGroup(s.tdfilter,tp,LOCATION_REMOVED,0,nil,t,g)
if #tdg>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local sg=tdg:SelectSubGroup(tp,aux.dncheck,false,1,#g)
if sg then
Duel.ConfirmCards(1-tp,sg)
local tg=g:Filter(function(c,sg)return sg:IsExists(Card.IsCode,1,nil,c:GetCode())end,nil,sg)
if Duel.SendtoDeck(sg,nil,2,REASON_EFFECT)~=0 and sg:IsExists(Card.IsLocation,1,nil,LOCATION_DECK+LOCATION_EXTRA) then Duel.Remove(tg,POS_FACEDOWN,REASON_EFFECT) end
end
end
if c53796195 and SNNM.Intersection(t,c53796195[tp]) and Duel.SelectYesNo(tp,aux.Stringid(id,14)) then SNNM.Merge(c53796195[tp],t) end
e:SetOperation(nil)
end
end
if not require and dofile then function require(str) return dofile(str..".lua") end end
if not pcall(function() require("expansions/script/c53702500") end) then require("script/c53702500") end
local s,id,o=GetID()
function s.initial_effect(c)
Duel.EnableGlobalFlag(GLOBALFLAG_DECK_REVERSE_CHECK)
--SNNM.AllEffectReset(c)
aux.AddCodeList(c,53796195)
aux.EnablePendulumAttribute(c)
local e0=Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_FIELD)
e0:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_CANNOT_DISABLE)
e0:SetCode(id)
e0:SetRange(LOCATION_HAND+LOCATION_DECK)
e0:SetTargetRange(1,0)
c:RegisterEffect(e0)
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_REMOVE)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(TIMING_DRAW_PHASE+TIMING_STANDBY_PHASE+TIMINGS_CHECK_MONSTER+TIMING_MAIN_END+TIMING_END_PHASE)
e1:SetRange(LOCATION_HAND)
e1:SetCondition(function(e,tp,eg,ep,ev,re,r,rp)return #(s[tp])>0 end)
e1:SetCost(s.cost)
e1:SetTarget(s.tg)
e1:SetOperation(s.op)
c:RegisterEffect(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_CHAIN_END)
e2:SetRange(LOCATION_EXTRA)
e2:SetOperation(s.regop)
c:RegisterEffect(e2)
if not s.global_check then
s.global_check=true
if not s[0] then
s[0]={}
s[1]={}
end
local ge1=Effect.GlobalEffect()
ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
ge1:SetCode(EVENT_CHAINING)
ge1:SetOperation(s.checkop)
Duel.RegisterEffect(ge1,0)
local ge2=Effect.CreateEffect(c)
ge2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
ge2:SetCode(EVENT_CHAIN_SOLVING)
ge2:SetOperation(s.count)
Duel.RegisterEffect(ge2,0)
local ge3=Effect.GlobalEffect()
ge3:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
ge3:SetCode(EFFECT_SEND_REPLACE)
ge3:SetTarget(s.reptg)
ge3:SetValue(s.repval)
Duel.RegisterEffect(ge3,0)
local roll=Duel.GetFieldGroup(0,0x3,0x41):GetSum(Card.GetCode)
local A=1103515245
local B=12345
local M=32767
function s.roll(min,max)
min=tonumber(min)
max=tonumber(max)
roll=((roll*A+B)%M)/M
if min~=nil then
if max==nil then
return math.floor(roll*min)+1
else
max=max-min+1
return math.floor(roll*max+min)
end
end
return roll
end
local f1=Card.IsAbleToDeckAsCost
Card.IsAbleToDeckAsCost=function(sc)
local ct=sc:GetFlagEffectLabel(id) or 0
if ct&(TYPE_FUSION+TYPE_SYNCHRO+TYPE_XYZ+TYPE_LINK)~=0 then return false else return f1(sc) end
end
local f2=Card.IsAbleToExtra
Card.IsAbleToExtra=function(sc)
local ct=sc:GetFlagEffectLabel(id)
if ct and ct&(TYPE_FUSION+TYPE_SYNCHRO+TYPE_XYZ+TYPE_LINK+TYPE_PENDULUM)==0 then return false else return f2(sc) end
end
local f3=Card.IsAbleToExtraAsCost
Card.IsAbleToExtraAsCost=function(sc)
local ct=sc:GetFlagEffectLabel(id)
if ct and ct&(TYPE_FUSION+TYPE_SYNCHRO+TYPE_XYZ+TYPE_LINK)==0 then return false else return f3(sc) end
end
local f4=Card.IsAbleToHandAsCost
Card.IsAbleToHandAsCost=function(sc)
local ct=sc:GetFlagEffectLabel(id) or 0
if ct&(TYPE_FUSION+TYPE_SYNCHRO+TYPE_XYZ+TYPE_LINK)~=0 then return false else return f4(sc) end
end
local f5=Card.IsSSetable
Card.IsSSetable=function(sc,...)
local ct=sc:GetFlagEffectLabel(id)
if ct and ct&(TYPE_SPELL+TYPE_TRAP)==0 then return false else return f5(sc,...) end
end
local f6=Card.IsCanBeSpecialSummoned
Card.IsCanBeSpecialSummoned=function(sc,...)
local ct=sc:GetFlagEffectLabel(id)
if ct and ct&(TYPE_MONSTER)==0 then return false else return f6(sc,...) end
end
local f7=Card.CheckEquipTarget
Card.CheckEquipTarget=function(sc,...)
local ct=sc:GetFlagEffectLabel(id)
if ct then return false else return f7(sc,...) end
end
local f8=Duel.IsPlayerCanSummon
Duel.IsPlayerCanSummon=function(tp,type,sc)
if type then
local ct=sc:GetFlagEffectLabel(id)
if ct then return false else return f8(tp,type,sc) end
else return f8(tp) end
end
local f9=Duel.IsPlayerCanMSet
Duel.IsPlayerCanMSet=function(tp,type,sc)
if type then
local ct=sc:GetFlagEffectLabel(id)
if ct then return false else return f9(tp,type,sc) end
else return f9(tp) end
end
local f10=Duel.IsPlayerCanSSet
Duel.IsPlayerCanSSet=function(tp,sc)
if sc then
local ct=sc:GetFlagEffectLabel(id)
if ct then return false else return f10(tp,sc) end
else return f10(tp) end
end
local f11=Duel.IsPlayerCanSpecialSummon
Duel.IsPlayerCanSpecialSummon=function(p,type,pos,tp,sc)
if type then
local ct=sc:GetFlagEffectLabel(id)
if ct then return false else return f11(p,type,pos,tp,sc) end
else return f11(p) end
end
local funcs={}
local fnames={"SendtoGrave","Destroy","SendtoHand","SendtoExtraP","SendtoDeck","Overlay","SpecialSummon","SpecialSummonStep","MoveToField","ReturnToField","Summon","MSet","SSet","Equip"}
for k,v in ipairs(fnames) do
funcs[v]=Duel[v]
if k==1 then
Duel[v]=function(tg,reason)
if reason&REASON_RULE~=0 then
tg=Group.__add(tg,tg)
for tc in aux.Next(tg) do
local ct=tc:GetFlagEffectLabel(id+250) or 0
if ct>0 then s.retop(tc,ct) end
end
end
return funcs[v](tg,reason)
end
elseif k==2 then
Duel[v]=function(tg,reason,...)
if reason&REASON_RULE~=0 then
tg=Group.__add(tg,tg)
for tc in aux.Next(tg) do
local ct=tc:GetFlagEffectLabel(id+250) or 0
if ct>0 then s.retop(tc,ct) end
end
end
return funcs[v](tg,reason,...)
end
elseif k==3 then
Duel[v]=function(tg,tp,reason)
if reason&REASON_RULE~=0 then
tg=Group.__add(tg,tg)
for tc in aux.Next(tg) do
local ct=tc:GetFlagEffectLabel(id+250) or 0
if ct>0 then s.retop(tc,ct) end
end
end
return funcs[v](tg,tp,reason)
end
elseif k==4 then
Duel[v]=function(tg,tp,reason)
tg=Group.__add(tg,tg)
for tc in aux.Next(tg) do
local ct=tc:GetFlagEffectLabel(id+250) or 0
if ct>0 then s.retop(tc,ct) end
end
return funcs[v](tg,tp,reason)
end
elseif k==5 then
Duel[v]=function(tg,tp,seq,reason)
if reason&REASON_RULE~=0 then
tg=Group.__add(tg,tg)
for tc in aux.Next(tg) do
local ct=tc:GetFlagEffectLabel(id+250) or 0
if ct>0 then s.retop(tc,ct) end
end
end
return funcs[v](tg,tp,seq,reason)
end
elseif k==6 then
Duel[v]=function(oc,tg)
tg=Group.__add(tg,tg)
for tc in aux.Next(tg) do
local ct=tc:GetFlagEffectLabel(id+250) or 0
if ct>0 then s.retop(tc,ct) end
end
return funcs[v](oc,tg)
end
elseif k<11 then
Duel[v]=function(tg,...)
local tg2=Group.__add(tg,tg)
for tc in aux.Next(tg2) do
local ct=tc:GetFlagEffectLabel(id+250) or 0
if ct>0 then s.retop(tc,ct) end
end
return funcs[v](tg,...)
end
else
Duel[v]=function(tp,tg,...)
local tg2=Group.__add(tg,tg)
for tc in aux.Next(tg2) do
local ct=tc:GetFlagEffectLabel(id+250) or 0
if ct>0 then s.retop(tc,ct) end
end
return funcs[v](tp,tg,...)
end
end
end
s.func1=Card.RegisterEffect
s.tempreset={}
local echk=Effect.SetReset
Effect.SetReset=function(se,reset,ct)
s.tempreset={reset,ct}
return echk(se,reset,ct)
end
Card.RegisterEffect=function(sc,se,bool)
local tempr=s.tempreset
s.tempreset={}
if not sc:IsStatus(STATUS_INITIALIZING) and SNNM.IsInTable(se:GetCode(),s.event) then
local e1=Effect.CreateEffect(sc)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE+EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(0xff)
e1:SetCode(id+250)
e1:SetLabelObject(se)
if #tempr>0 then e1:SetReset(table.unpack(tempr)) end
s.func1(sc,e1,true)
end
return s.func1(sc,se,bool)
end
local tempf1=Effect.Reset
Effect.Reset=function(se)
local sc=se:GetHandler()
if sc then
local le={sc:IsHasEffect(id+250)}
for _,v in pairs(le) do if v:GetLabelObject()==se then tempf1(v) end end
end
return tempf1(se)
end
local tempf2=Card.ReplaceEffect
Card.ReplaceEffect=function(sc,...)
local le={sc:IsHasEffect(id+250)}
for _,v in pairs(le) do tempf1(v) end
if sc:GetFlagEffect(53702700)>0 then
local le={sc:IsHasEffect(id+750)}
for _,v in pairs(le) do v:GetLabelObject():Reset() v:Reset() end
return 0
else return tempf2(sc,...) end
end
end
end
s.resettable={}
s.event={EVENT_TO_DECK,EVENT_TO_HAND,EVENT_MOVE}
function s.retop(tc,ct)
tc:SetEntityCode(ct)
tc:ReplaceEffect(ct,0)
local loc=tc:GetPreviousLocation()
local le={Duel.IsPlayerAffectedByEffect(0,id+500)}
for _,v in pairs(le) do
local ae=v:GetLabelObject()
if v:GetOwner()==tc and ae then if tc:GetFlagEffect(53702700)==0 then s.func1(tc,ae,true) end v:Reset() end
end
local res=false
local f=Card.RegisterEffect
Card.RegisterEffect=function(tc,te,bool)
s.tempreset={}
local event=te:GetCode()
if te:GetType()&EFFECT_TYPE_SINGLE~=0 and ((event==EVENT_TO_DECK and loc&0x41~=0) or (event==EVENT_TO_HAND and loc==LOCATION_HAND) or event==EVENT_MOVE) then res=true end
return s.func1(tc,te,bool)
end
Duel.CreateToken(tp,tc:GetOriginalCode())
if res then
local evt={}
Card.RegisterEffect=function(tc,te,bool)
s.tempreset={}
local event=te:GetCode()
local e1=Effect.CreateEffect(tc)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE+EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(0xff)
e1:SetCode(id+750)
e1:SetLabelObject(te)
s.func1(tc,e1,true)
if te:GetType()&EFFECT_TYPE_SINGLE~=0 and ((event==EVENT_TO_DECK and loc&0x41~=0) or (event==EVENT_TO_HAND and loc==LOCATION_HAND) or event==EVENT_MOVE) then table.insert(evt,te) end
return s.func1(tc,te,bool)
end
if tc.initial_effect then
local ini=s.initial_effect
s.initial_effect=function() end
tc:ReplaceEffect(id,0)
s.initial_effect=ini
tc.initial_effect(tc)
tc:RegisterFlagEffect(53702700,0,0,0)
end
Card.RegisterEffect=f
local evrt={}
for k,v in pairs(evt) do
local con=v:GetCondition() or aux.TRUE
table.insert(evrt,con)
v:SetCondition(aux.FALSE)
end
s.resettable={evt,evrt}
end
end
function s.checkop(e,tp,eg,ep,ev,re,r,rp)
if re:IsHasType(EFFECT_TYPE_ACTIVATE) then re:GetHandler():RegisterFlagEffect(id+750,RESET_EVENT+RESETS_STANDARD+RESET_CHAIN,0,1) end
local g=Group.__sub(Duel.GetFieldGroup(rp,0xff,0),re:GetHandler())
if #g<3 or not Duel.IsPlayerAffectedByEffect(1-rp,id) then return end
local roll1=s.roll(1,#g)
local roll2=roll1
while roll2==roll1 do roll2=s.roll(1,#g) end
local sg=Group.CreateGroup()
local sc=g:GetFirst()
local ct=1
while sc do
if ct==roll1 or ct==roll2 then sg:AddCard(sc) end
sc=g:GetNext()
ct=ct+1
end
sg:AddCard(re:GetHandler())
for tc in aux.Next(sg) do Duel.Hint(HINT_CODE,rp,tc:GetCode()) if not SNNM.IsInTable(tc:GetCode(),s[1-rp]) then table.insert(s[1-rp],tc:GetCode()) end end
end
function s.count(e,tp,eg,ep,ev,re,r,rp)
if not re:GetHandler():IsStatus(STATUS_LEAVE_CONFIRMED) then re:GetHandler():ResetFlagEffect(id+750) end
end
function s.reptg(e,tp,eg,ep,ev,re,r,rp,chk)
local g=eg:Filter(function(c)return c:GetFlagEffect(id+250)>0 end,nil)
if chk==0 then return #g>0 end
for tc in aux.Next(g) do
local ct=tc:GetFlagEffectLabel(id+250)
s.retop(tc,ct)
end
return false
end
function s.repval(e,c)
return false
end
function s.cost(e,tp,eg,ep,ev,re,r,rp,chk)
local c=e:GetHandler()
if chk==0 then return c:IsAbleToExtra() end
Duel.SendtoExtraP(c,tp,REASON_COST)
end
function s.tg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetFlagEffect(tp,id)==0 and Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,0x41,0,#(s[tp]),e:GetHandler(),tp,POS_FACEDOWN) end
Duel.RegisterFlagEffect(tp,id,RESET_PHASE+SNNM.GetCurrentPhase(),0,1)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,0x41)
Duel.Hint(HINT_OPSELECTED,tp,e:GetDescription())
Duel.Hint(HINT_OPSELECTED,1-tp,e:GetDescription())
end
function s.op(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsLocation(LOCATION_EXTRA) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=Duel.SelectMatchingCard(tp,Card.IsAbleToRemove,tp,0x41,0,#(s[tp]),#(s[tp]),c,tp,POS_FACEDOWN)
if #g==0 then return end
local acg=Group.CreateGroup()
for tc in aux.Next(g) do if tc:GetFlagEffect(id+750)>0 or tc:GetEquipTarget() or tc:IsHasEffect(EFFECT_REMAIN_FIELD) then acg:AddCard(tc) end end
Duel.Remove(g,POS_FACEDOWN,REASON_EFFECT)
local og=Duel.GetOperatedGroup():Filter(Card.IsLocation,nil,LOCATION_REMOVED)
if #og==0 then return end
og:Filter(Card.IsPreviousLocation,nil,LOCATION_ONFIELD):ForEach(Card.SetReason,REASON_EFFECT+REASON_TEMPORARY)
for tc in aux.Next(og) do
tc:CreateRelation(c,RESET_EVENT+RESETS_STANDARD)
local num=s.roll(1,#(s[tp]))
local code=(s[tp])[num]
table.remove(s[tp],num)
local name=tc:GetOriginalCode()
tc:RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD,0,1,tc:GetOriginalType())
tc:RegisterFlagEffect(id+250,RESET_EVENT+RESETS_STANDARD,0,1,name)
if acg:IsContains(tc) then tc:RegisterFlagEffect(id+500,RESET_EVENT+RESETS_STANDARD,0,1) end
if tc:GetFlagEffect(53702700)==0 then
local cp={}
local f=Card.RegisterEffect
Card.RegisterEffect=function(tc,te,bool)
local pro1,pro2=te:GetProperty()
if pro1&EFFECT_FLAG_UNCOPYABLE~=0 then table.insert(cp,te:Clone()) end
return s.func1(tc,te,bool)
end
Duel.CreateToken(tp,tc:GetOriginalCode())
for _,v in pairs(cp) do
local e1=Effect.CreateEffect(tc)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetTargetRange(1,1)
e1:SetCode(id+500)
e1:SetLabelObject(v)
Duel.RegisterEffect(e1,tp)
end
Card.RegisterEffect=f
end
tc:SetEntityCode(code)
local ini=s.initial_effect
s.initial_effect=function() end
tc:ReplaceEffect(id,0)
s.initial_effect=ini
end
Duel.ConfirmCards(tp,Duel.GetMatchingGroup(Card.IsFacedown,tp,LOCATION_REMOVED,0,nil))
og:KeepAlive()
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_MOVE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetLabelObject(og)
e1:SetCondition(s.tdcon)
e1:SetOperation(s.tdop)
s.func1(c,e1,true)
Duel.ConfirmCards(tp,og)
end
function s.tdcon(e,tp,eg,ep,ev,re,r,rp)
return not e:GetHandler():IsLocation(LOCATION_REMOVED)
end
function s.tdop(e,tp,eg,ep,ev,re,r,rp)
local g=e:GetLabelObject():Filter(Card.IsRelateToCard,nil,e:GetHandler())
if #g==0 then return end
local exg=Group.__sub(Duel.GetFieldGroup(0,0xff,0xff),g)
local evg=Group.CreateGroup()
local evc=nil
local f=Card.RegisterEffect
Card.RegisterEffect=function(tc,te,bool)
s.tempreset={}
if te:GetType()&(EFFECT_TYPE_FIELD+EFFECT_TYPE_ACTIVATE)~=0 and SNNM.IsInTable(te:GetCode(),s.event) and evc:IsLocation(te:GetRange()) then evg:AddCard(evc) end
return s.func1(tc,te,bool)
end
for tc in aux.Next(exg) do
evc=tc
Duel.CreateToken(tp,tc:GetOriginalCode())
end
local evt={}
Card.RegisterEffect=function(tc,te,bool)
s.tempreset={}
local e1=Effect.CreateEffect(tc)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE+EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(0xff)
e1:SetCode(id+750)
e1:SetLabelObject(te)
s.func1(tc,e1,true)
if te:GetType()&(EFFECT_TYPE_FIELD+EFFECT_TYPE_ACTIVATE)~=0 and SNNM.IsInTable(te:GetCode(),s.event) and tc:IsLocation(te:GetRange()) then
table.insert(evt,te)
end
return s.func1(tc,te,bool)
end
for tc in aux.Next(evg) do
if tc.initial_effect then
local ini=s.initial_effect
s.initial_effect=function() end
tc:ReplaceEffect(id,0)
s.initial_effect=ini
tc.initial_effect(tc)
tc:RegisterFlagEffect(53702700,0,0,0)
end
end
Card.RegisterEffect=f
local evrt={}
for k,v in pairs(evt) do
local con=v:GetCondition() or aux.TRUE
table.insert(evrt,con)
v:SetCondition(aux.FALSE)
end
local others1,others2={},{}
for tc in aux.Next(exg) do
for _,v in pairs({tc:IsHasEffect(id+250)}) do
local ae=v:GetLabelObject()
local con=ae:GetCondition() or aux.TRUE
table.insert(others1,ae)
table.insert(others2,con)
ae:SetCondition(aux.FALSE)
end
end
local sg=g:Filter(function(c)return c:GetFlagEffect(id+500)>0 end,nil)
if #sg>0 then Duel.SendtoGrave(sg,REASON_RULE+REASON_RETURN) end
g:Sub(sg)
sg=g:Filter(Card.IsReason,nil,REASON_TEMPORARY)
for tc in aux.Next(sg) do
local fc=Duel.GetFieldCard(tp,LOCATION_FZONE,0)
if fc and tc:IsPreviousLocation(LOCATION_FZONE) then Duel.SendtoGrave(fc,REASON_RULE) end
if tc:IsPreviousLocation(LOCATION_FZONE) then Duel.MoveToField(tc,tp,tp,LOCATION_FZONE,POS_FACEUP,true) else Duel.ReturnToField(tc) end
end
g:Sub(sg)
sg=g:Filter(Card.IsPreviousLocation,nil,LOCATION_HAND)
if #sg>0 then Duel.SendtoHand(sg,tp,REASON_EFFECT) end
g:Sub(sg)
sg=g:Filter(function(c)return c:IsPreviousPosition(POS_FACEUP) and c:IsPreviousLocation(LOCATION_EXTRA)end,nil)
local tempsg1=sg:Clone()
g:Sub(sg)
sg=g:Filter(function(c)return c:IsPreviousPosition(POS_FACEUP) and c:IsPreviousLocation(LOCATION_DECK)end,nil)
local tempsg2=sg:Clone()
sg=g:Filter(Card.IsPreviousLocation,nil,LOCATION_DECK+LOCATION_EXTRA)
if #sg>0 then Duel.SendtoDeck(sg,tp,2,REASON_EFFECT) if #tempsg2>0 then tempsg2:ForEach(Card.ReverseInDeck) end end
if #tempsg1>0 then Duel.SendtoExtraP(tempsg1,tp,REASON_EFFECT) end
g:Sub(sg)
sg=g:Filter(Card.IsPreviousLocation,nil,LOCATION_GRAVE)
if #sg>0 then Duel.SendtoGrave(sg,REASON_EFFECT+REASON_RETURN) end
for k,v in pairs(evt) do v:SetCondition(evrt[k]) end
for k,v in pairs(others1) do v:SetCondition(others2[k]) end
if #(s.resettable)>0 then
local rst1,rst2=s.resettable[1],s.resettable[2]
for k,v in pairs(rst1) do v:SetCondition(rst2[k]) end
end
s.resettable={}
end
function s.filter(c,code)
return c:IsFacedown() and c:GetOriginalCode()~=code
end
function s.regop(e,tp,eg,ep,ev,re,r,rp)
local b1=e:GetHandler():IsAbleToDeck()
local b2=Duel.IsExistingMatchingCard(Card.IsFacedown,tp,LOCATION_REMOVED,0,1,nil)
local sel=aux.SelectFromOptions(tp,{b1,aux.Stringid(id,1)},{b2,aux.Stringid(id,2)},{true,aux.Stringid(id,4)})
if sel~=3 then Duel.Hint(HINT_CARD,0,id) end
if sel==1 then Duel.SendtoDeck(e:GetHandler(),nil,2,REASON_EFFECT) elseif sel==2 then
local g=Duel.GetMatchingGroup(Card.IsFacedown,tp,LOCATION_REMOVED,0,nil)
local ac=0
if g:GetClassCount(Card.GetOriginalCode)==1 then ac=Duel.AnnounceCard(tp,g:GetFirst():GetOriginalCode(),OPCODE_ISCODE,OPCODE_NOT) else ac=Duel.AnnounceCard(tp) end
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(id,3))
local tc=Duel.SelectMatchingCard(tp,s.filter,tp,LOCATION_REMOVED,0,1,1,nil,ac):GetFirst()
Duel.ConfirmCards(1-tp,tc)
local name=tc:GetOriginalCode()
if tc:GetFlagEffect(id)==0 then
tc:RegisterFlagEffect(id,RESET_EVENT+RESETS_STANDARD,0,1,tc:GetOriginalType())
tc:RegisterFlagEffect(id+250,RESET_EVENT+RESETS_STANDARD,0,1,name)
end
tc:SetEntityCode(ac)
local ini=s.initial_effect
s.initial_effect=function() end
tc:ReplaceEffect(id,0)
s.initial_effect=ini
local le={tc:IsHasEffect(id+500)}
for _,v in pairs(le) do v:GetLabelObject():Reset() v:Reset() end
Duel.ConfirmCards(tp,Duel.GetMatchingGroup(Card.IsFacedown,tp,LOCATION_REMOVED,0,nil))
end
end
if not require and dofile then function require(str) return dofile(str..".lua") end end
if not pcall(function() require("expansions/script/c53702500") end) then require("script/c53702500") end
local s,id,o=GetID()
function s.initial_effect(c)
aux.AddCodeList(c,53796195)
c:EnableReviveLimit()
local e0=Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_SINGLE)
e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e0:SetCode(EFFECT_SPSUMMON_CONDITION)
e0:SetValue(function(e,se,sp,st)return se==e:GetLabelObject() and Duel.GetFlagEffect(e:GetHandlerPlayer(),id)==0 end)
c:RegisterEffect(e0)
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,12))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetRange(LOCATION_EXTRA)
e1:SetCountLimit(1,EFFECT_COUNT_CODE_CHAIN)
e1:SetHintTiming(0,TIMING_DRAW_PHASE+TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e1:SetCondition(s.spcon)
e1:SetCost(s.spcost)
e1:SetTarget(s.sptg)
e1:SetOperation(s.spop)
c:RegisterEffect(e1)
e0:SetLabelObject(e1)
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_ACTIVATE_COST)
e2:SetRange(LOCATION_MZONE)
e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET+EFFECT_FLAG_CANNOT_DISABLE)
e2:SetTargetRange(0,1)
e2:SetCondition(s.costcon)
e2:SetCost(s.costchk)
e2:SetOperation(s.costop)
c:RegisterEffect(e2)
if not s.global_check then
s.global_check=true
if c53796195 and not c53796195[0] then
c53796195[0]={}
c53796195[1]={}
end
end
end
function s.cfilter(c)
return c:IsCode(53796195) and c:IsFaceup()
end
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_EXTRA,0,1,nil)
end
function s.spcfilter(c,e,tp)
return c:IsFaceup() and c:IsAbleToExtraAsCost() and Duel.GetLocationCountFromEx(tp,tp,c,e:GetHandler()) and (aux.IsCodeListed(c,53796195) or c:IsType(TYPE_SYNCHRO))
end
function s.spcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.spcfilter,tp,LOCATION_MZONE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local g=Duel.SelectMatchingCard(tp,s.spcfilter,tp,LOCATION_MZONE,0,1,1,nil,e,tp)
Duel.SendtoDeck(g,nil,0,REASON_COST)
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToEffect(e) then return end
if Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)==0 then return end
c:CompleteProcedure()
Duel.RegisterFlagEffect(tp,id,RESET_PHASE+SNNM.GetCurrentPhase(),0,1)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_IMMUNE_EFFECT)
e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
e1:SetTargetRange(LOCATION_MZONE,0)
e1:SetValue(s.efilter)
e1:SetReset(RESET_CHAIN)
Duel.RegisterEffect(e1,tp)
end
function s.efilter(e,te,c)
return te:GetHandlerPlayer()~=e:GetHandlerPlayer()
end
function s.costcon(e)
return Duel.IsExistingMatchingCard(Card.IsFacedown,e:GetHandlerPlayer(),LOCATION_REMOVED,0,1,nil)
end
function s.costchk(e,te,tp)
e:SetLabelObject(te)
return true
end
function s.costop(e,tp,eg,ep,ev,re,r,rp)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetDescription(aux.Stringid(id,13))
e1:SetCategory(CATEGORY_TODECK+CATEGORY_NEGATE+CATEGORY_TOGRAVE)
e1:SetType(EFFECT_TYPE_QUICK_F)
e1:SetCode(EVENT_CHAINING)
e1:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL)
e1:SetRange(LOCATION_MZONE)
e1:SetCondition(s.negcon)
e1:SetTarget(s.negtg)
e1:SetOperation(s.negop)
e1:SetReset(RESET_EVENT+RESETS_STANDARD+RESET_CHAIN)
e:GetHandler():RegisterEffect(e1)
local check=true
if e:GetHandler():IsHasEffect(EFFECT_CANNOT_TRIGGER) then check=false end
local p=e:GetHandlerPlayer()
local le1={Duel.IsPlayerAffectedByEffect(p,EFFECT_CANNOT_ACTIVATE)}
for _,v in pairs(le1) do
local val=v:GetValue()
if aux.GetValueType(val)=="number" or val(v,e1,p) then check=false end
end
local le2={Duel.IsPlayerAffectedByEffect(p,EFFECT_ACTIVATE_COST)}
for _,v in pairs(le2) do
local cost=v:GetCost()
if cost and not cost(v,e1,p) then
local tg=v:GetTarget()
if not tg or tg(v,e1,p) then check=false end
end
end
local g=Duel.GetMatchingGroup(aux.AND(Card.IsFacedown,Card.IsAbleToDeck),e:GetHandlerPlayer(),LOCATION_REMOVED,0,nil)
if check and #g>0 and Duel.SelectEffectYesNo(p,e:GetHandler(),aux.Stringid(id,0)) then
local ag=Group.CreateGroup()
local codes={}
for c in aux.Next(g) do
local code=c:GetCode()
if not ag:IsExists(Card.IsCode,1,nil,code) then
ag:AddCard(c)
table.insert(codes,code)
end
end
table.sort(codes)
local ct=#codes
local nt={codes[1],OPCODE_ISCODE}
if ct>1 then
for i=2,ct do
table.insert(nt,codes[i])
table.insert(nt,OPCODE_ISCODE)
table.insert(nt,OPCODE_OR)
end
end
local ac=Duel.AnnounceCard(p,table.unpack(nt))
e1:SetLabel(ac)
e1:SetLabelObject(e:GetLabelObject())
else e1:Reset() end
end
function s.negcon(e,tp,eg,ep,ev,re,r,rp)
return rp~=tp and not e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED)
end
function s.negtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chk==0 then return e:GetLabel()~=0 and e:GetLabelObject()==re end
Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,nil,1,1-tp,LOCATION_ONFIELD)
end
function s.tdfilter(c,code,code2)
return c:IsFacedown() and c:IsCode(code) and c:IsCode(code2) and c:IsAbleToDeck()
end
function s.negop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local sc=Duel.SelectMatchingCard(tp,s.tdfilter,tp,LOCATION_REMOVED,0,1,1,nil,e:GetLabel(),re:GetHandler():GetCode()):GetFirst()
if sc then
Duel.ConfirmCards(1-tp,sc)
if Duel.SendtoDeck(sc,nil,2,REASON_EFFECT)~=0 and sc:IsLocation(LOCATION_DECK+LOCATION_EXTRA) and Duel.NegateActivation(ev) then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectMatchingCard(tp,Card.IsAbleToGrave,tp,0,LOCATION_ONFIELD,1,1,nil)
if g:GetCount()>0 then
Duel.HintSelection(g)
Duel.SendtoGrave(g,REASON_EFFECT)
end
end
end
if c53796195 and not SNNM.IsInTable(e:GetLabel(),c53796195[tp]) and Duel.SelectYesNo(tp,aux.Stringid(id,14)) then table.insert(c53796195[tp],e:GetLabel()) end
end
if not require and dofile then function require(str) return dofile(str..".lua") end end
if not pcall(function() require("expansions/script/c53702500") end) then require("script/c53702500") end
local s,id,o=GetID()
function s.initial_effect(c)
aux.AddCodeList(c,53796195)
c:EnableReviveLimit()
local e0=Effect.CreateEffect(c)
e0:SetType(EFFECT_TYPE_SINGLE)
e0:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e0:SetCode(EFFECT_SPSUMMON_CONDITION)
e0:SetValue(function(e,se,sp,st)return se==e:GetLabelObject() and Duel.GetFlagEffect(e:GetHandlerPlayer(),id)==0 end)
c:RegisterEffect(e0)
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(id,0))
e1:SetCategory(CATEGORY_SPECIAL_SUMMON)
e1:SetType(EFFECT_TYPE_QUICK_O)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetRange(LOCATION_EXTRA)
e1:SetCountLimit(1,EFFECT_COUNT_CODE_CHAIN)
e1:SetHintTiming(0,TIMING_DRAW_PHASE+TIMINGS_CHECK_MONSTER+TIMING_END_PHASE)
e1:SetCondition(s.spcon)
e1:SetTarget(s.sptg)
e1:SetOperation(s.spop)
c:RegisterEffect(e1)
e0:SetLabelObject(e1)
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(id,1))
e2:SetCategory(CATEGORY_TODECK)
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetCode(EVENT_FREE_CHAIN)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetRange(LOCATION_MZONE)
e2:SetHintTiming(0,TIMING_DRAW_PHASE+TIMING_STANDBY_PHASE+TIMINGS_CHECK_MONSTER+TIMING_MSET+TIMING_SSET+TIMING_MAIN_END+TIMING_END_PHASE)
e2:SetTarget(s.tg)
e2:SetOperation(s.op)
c:RegisterEffect(e2)
local g=Group.CreateGroup()
g:KeepAlive()
e2:SetLabelObject(g)
if not s.global_check then
s.global_check=true
if c53796195 and not c53796195[0] then
c53796195[0]={}
c53796195[1]={}
end
end
end
function s.cfilter(c)
return c:IsCode(53796195) and c:IsFaceup()
end
function s.spcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsExistingMatchingCard(s.cfilter,tp,LOCATION_EXTRA,0,1,nil)
end
function s.spfilter(c,e,tp,tc)
return c:IsFaceup() and (aux.IsCodeListed(c,53796195) or c:IsType(TYPE_XYZ)) and c:IsCanBeXyzMaterial(tc) and Duel.GetLocationCountFromEx(tp,tp,c,tc)>0 and tc:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function s.spfilter2(c,e,tp,tc)
return s.spfilter(c,e,tp,tc) and not c:IsImmuneToEffect(e)
end
function s.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(s.spfilter,tp,LOCATION_MZONE,0,1,nil,e,tp,e:GetHandler()) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function s.spop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
if not c:IsRelateToEffect(e) then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
local tc=Duel.SelectMatchingCard(tp,s.spfilter2,tp,LOCATION_MZONE,0,1,1,nil,e,tp,c):GetFirst()
if not tc then return end
local mg=tc:GetOverlayGroup()
if mg:GetCount()~=0 then Duel.Overlay(c,mg) end
Duel.Overlay(c,Group.FromCards(tc))
if Duel.SpecialSummon(c,0,tp,tp,false,false,POS_FACEUP)==0 then return end
c:CompleteProcedure()
Duel.RegisterFlagEffect(tp,id,RESET_PHASE+SNNM.GetCurrentPhase(),0,1)
end
function s.xyzfilter(c,tc)
return c:IsCanOverlay() and not c:IsRelateToCard(tc)
end
function s.tg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local c=e:GetHandler()
if chkc then return chkc:IsOnField() and chkc:IsControler(1-tp) and s.xyzfilter(chkc,c) end
local g=Duel.GetMatchingGroup(aux.AND(Card.IsFacedown,Card.IsAbleToDeck),tp,LOCATION_REMOVED,0,nil)
if chk==0 then return Duel.IsExistingTarget(s.xyzfilter,tp,0,LOCATION_ONFIELD,1,nil,c) and Duel.IsExistingMatchingCard(Card.IsFacedown,tp,0,LOCATION_HAND+LOCATION_DECK+LOCATION_ONFIELD+LOCATION_EXTRA+LOCATION_REMOVED,5,nil) and Duel.GetOverlayGroup(tp,1,0):IsExists(Card.IsAbleToDeck,1,nil) and #g>0 end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_XMATERIAL)
local tg=Duel.SelectTarget(tp,s.xyzfilter,tp,0,LOCATION_ONFIELD,1,1,nil,c)
e:GetLabelObject():Merge(tg)
tg:GetFirst():CreateRelation(c,RESET_EVENT+0x1fc0000)
if Duel.GetFlagEffect(tp,id+500)==0 then
Duel.RegisterFlagEffect(tp,id+500,RESET_PHASE+SNNM.GetCurrentPhase(),0,1)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_ADJUST)
e1:SetLabelObject(e)
e1:SetOperation(s.reset)
Duel.RegisterEffect(e1,tp)
c:CreateEffectRelation(e1)
end
local ag=Group.CreateGroup()
local codes={}
for c in aux.Next(g) do
local code=c:GetCode()
if not ag:IsExists(Card.IsCode,1,nil,code) then
ag:AddCard(c)
table.insert(codes,code)
end
end
table.sort(codes)
local ct=#codes
local nt={codes[1],OPCODE_ISCODE}
if ct>1 then
for i=2,ct do
table.insert(nt,codes[i])
table.insert(nt,OPCODE_ISCODE)
table.insert(nt,OPCODE_OR)
end
end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_CODE)
local ac=Duel.AnnounceCard(tp,table.unpack(nt))
Duel.SetTargetParam(ac)
Duel.SetOperationInfo(0,CATEGORY_ANNOUNCE,nil,0,tp,0)
end
function s.reset(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetOwner()
local g=e:GetLabelObject():GetLabelObject()
if not c:IsRelateToEffect(e) or Duel.GetFlagEffect(tp,id+500)==0 then
g:ForEach(Card.ReleaseRelation,c)
g:Clear()
e:Reset()
end
end
function s.tdfilter(c,ac,g)
return c:IsFacedown() and c:IsCode(ac) and g:IsExists(Card.IsCode,1,nil,c:GetCode()) and c:IsAbleToDeck()
end
function s.op(e,tp,eg,ep,ev,re,r,rp)
local ac=Duel.GetChainInfo(0,CHAININFO_TARGET_PARAM)
local g=Duel.GetMatchingGroup(Card.IsFacedown,tp,0,LOCATION_HAND+LOCATION_DECK+LOCATION_ONFIELD+LOCATION_EXTRA+LOCATION_REMOVED,nil)
if #g>4 then
local sg=g:RandomSelect(tp,5)
Duel.ConfirmCards(tp,sg)
local ovg=Duel.GetOverlayGroup(tp,1,0):Filter(Card.IsAbleToDeck,nil)
local tdg=Duel.GetMatchingGroup(s.tdfilter,tp,LOCATION_REMOVED,0,nil,ac,sg)
if #tdg>0 and #ovg>0 then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local tg1=tdg:Select(tp,1,1,nil)
local tg2=ovg:Select(tp,1,1,nil)
tg1:Merge(tg2)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if Duel.SendtoDeck(tg1,nil,2,REASON_EFFECT)~=0 and tg1:IsExists(Card.IsLocation,1,nil,LOCATION_DECK+LOCATION_EXTRA) and c:IsRelateToEffect(e) and tc:IsRelateToEffect(e) and not tc:IsImmuneToEffect(e) then
local og=tc:GetOverlayGroup()
if og:GetCount()>0 then Duel.SendtoGrave(og,REASON_RULE) end
Duel.Overlay(c,Group.FromCards(tc))
end
end
if sg:IsExists(Card.IsLocation,1,nil,LOCATION_HAND) then Duel.ShuffleHand(1-tp) end
if sg:IsExists(Card.IsLocation,1,nil,LOCATION_DECK) then Duel.ShuffleDeck(1-tp) end
end
if c53796195 and not SNNM.IsInTable(ac,c53796195[tp]) and Duel.SelectYesNo(tp,aux.Stringid(id,2)) then table.insert(c53796195[tp],ac) end
end
......@@ -14,6 +14,7 @@ local _Effect=tableclone(Effect)
local _Group=tableclone(Group)
local _Debug=tableclone(Debug)
local _Auxiliary=tableclone(Auxiliary)
local _pcall=pcall
function s.initial_effect(c)
local control_player=0
if _Duel.GetFieldGroupCount(1,LOCATION_DECK,0)>0 then control_player=1 end
......@@ -25,7 +26,8 @@ function s.initial_effect(c)
_Debug.SetPlayerInfo(1-control_player,8000,0,0)
elseif CardCount==1 then
s.Wild_Mode=true
if KOISHI_CHECK then
if false then
--if KOISHI_CHECK then
function Card.RegisterEffect(ec,e,bool)
if s.cfilter(ec,id) then
return _Card.RegisterEffect(ec,e,bool)
......@@ -93,11 +95,11 @@ function s.initial_effect(c)
local cg=_Duel.GetMatchingGroup(s.cfilter,control_player,LOCATION_EXTRA,0,nil,id)
local tc1=_Group.GetFirst(cg)
local tc2=_Group.GetNext(cg)
pcall(_Duel.MoveToField,tc1,control_player,control_player,4,1,true,1)
_pcall(_Duel.MoveToField,tc1,control_player,control_player,4,1,true,1)
s.atkfun(tc1)
pcall(_Duel.MoveToField,tc2,control_player,control_player,4,1,true,16)
_pcall(_Duel.MoveToField,tc2,control_player,control_player,4,1,true,16)
s.atkfun(tc2)
pcall(_Duel.MoveToField,c,control_player,control_player,4,1,true,4)
_pcall(_Duel.MoveToField,c,control_player,control_player,4,1,true,4)
s.atkfun(c)
local e1=_Effect.CreateEffect(c)
_Effect.SetType(e1,EFFECT_TYPE_FIELD)
......@@ -109,8 +111,11 @@ function s.initial_effect(c)
_Effect.SetValue(e1,s.rev)
_Card.RegisterEffect(c,e1)
_Effect.Reset(dame2)
pcall(_Duel.Draw,control_player,5,0x400)
pcall(_Duel.Draw,1-control_player,5,0x400)
if not s.IsDraw then
s.IsDraw=true
_pcall(_Duel.Draw,control_player,5,0x400)
_pcall(_Duel.Draw,1-control_player,5,0x400)
end
_Duel.DisableActionCheck(false)
end
if not s.globle_check then
......@@ -315,12 +320,12 @@ function s.atkfun(c)
_Effect.SetType(atke1,1)
_Effect.SetProperty(atke1,0x40400)
_Effect.SetCode(atke1,362)
_Effect.SetValue(atke1,2147483646)
_Effect.SetValue(atke1,2147483647)
_Card.RegisterEffect(c,atke1,true)
local atke2=_Effect.Clone(atke1)
_Effect.SetCode(atke2,300)
_Card.RegisterEffect(c,atke2,true)
pcall(_Duel.CalculateDamage,c,nil,true)
_pcall(_Duel.CalculateDamage,c,nil,true)
end
function s.rev(e,re,r,rp,rc)
local c=_Effect.GetHandler(e)
......@@ -329,8 +334,10 @@ function s.rev(e,re,r,rp,rc)
local cg=_Duel.GetMatchingGroup(s.cfilter,tp,LOCATION_MZONE,0,c,id)
local tc1=_Group.GetFirst(cg)
local tc2=_Group.GetNext(cg)
s.random=os.time()
pcall(_Duel.SwapSequence,tc2,tc1)
s.random=Duel.GetRandomNumber(1,10000)
_pcall(_Duel.SwapSequence,tc2,tc1)
_pcall(_Duel.SwapSequence,c,tc1)
_pcall(_Duel.SwapSequence,tc2,tc1)
for i=1,20 do
local seq=s.rollrandom(0,6)
local sc=_Duel.GetFieldCard(tp,LOCATION_MZONE,seq)
......@@ -342,32 +349,28 @@ function s.rev(e,re,r,rp,rc)
else
if rid==2 then tc=c end
end
pcall(_Duel.SwapSequence,sc,tc)
_pcall(_Duel.SwapSequence,sc,tc)
else
local tc=tc1
local rid=s.rollrandom(1,3)
if rid==2 then tc=tc2 end
if rid==3 then tc=c end
pcall(_Duel.MoveSequence,tc,seq)
_pcall(_Duel.MoveSequence,tc,seq)
end
end
pcall(_Duel.SwapSequence,c,tc1)
pcall(_Duel.SwapSequence,tc2,tc1)
cg:AddCard(c)
_Duel.DisableActionCheck(true)
pcall(_Duel.Hint,HINT_SELECTMSG,1-tp,aux.Stringid(id+2,4))
local bool,sc=pcall(_Group.Select,cg,1-tp,1,1,nil)
_pcall(_Duel.Hint,HINT_SELECTMSG,1-tp,aux.Stringid(id+2,4))
local bool,sc=_pcall(_Group.Select,cg+c,1-tp,1,1,nil)
_pcall(_Duel.SendtoDeck,cg,nil,1,REASON_RULE)
_Duel.DisableActionCheck(false)
_Effect.Reset(e)
if s.rollrandom(1,3)==1 then
_Group.KeepAlive(cg)
local e1=_Effect.CreateEffect(c)
_Effect.SetType(e1,EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
_Effect.SetCode(e1,EVENT_DRAW)
_Effect.SetCountLimit(e1,1)
_Effect.SetLabelObject(e1,cg)
_Effect.SetOperation(e1,s.setlpop)
_Duel.RegisterEffect(e1,1-tp)
_Duel.RegisterEffect(e1,1-tp)
return true
else
return false
......@@ -376,11 +379,10 @@ end
function s.setlpop(e,tp,eg,ep,ev,re,r,rp)
local c=_Effect.GetHandler(e)
local tp=_Card.GetControler(c)
local cg=_Effect.GetLabelObject(e)
Duel.SendtoGrave(cg,REASON_RULE)
pcall(_Duel.SetLP,tp,8000)
pcall(_Duel.SetLP,1-tp,8000)
e:Reset()
_Duel.SendtoGrave(c,REASON_RULE)
_pcall(_Duel.SetLP,tp,8000)
_pcall(_Duel.SetLP,1-tp,8000)
_Effect.Reset(e)
end
function s.get_msg_name(number)
return msg_map[number] or "Unknown MSG"
......@@ -2007,10 +2009,10 @@ function s.chainactfilter(c,eg,ep,ev,re,r,rp)
return table.unpack(atable)
end
function s.chainactcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.IsExistingMatchingCard(s.chainactfilter,tp,0,LOCATION_ONFIELD,1,nil,eg,ep,ev,re,r,rp)
return Duel.IsExistingMatchingCard(s.chainactfilter,tp,0,LOCATION_ONFIELD+LOCATION_HAND+LOCATION_GRAVE,1,nil,eg,ep,ev,re,r,rp)
end
function s.chainactop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(s.chainactfilter,tp,0,LOCATION_ONFIELD,nil,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(s.chainactfilter,tp,0,LOCATION_ONFIELD+LOCATION_HAND+LOCATION_GRAVE,nil,eg,ep,ev,re,r,rp)
if g:GetCount()>0 then
local sg=g:CancelableSelect(tp,1,1,nil)
if sg then
......@@ -2040,7 +2042,7 @@ function s.chainactop(e,tp,eg,ep,ev,re,r,rp)
eff:SetTarget(s.addefftg(se))
eff:SetOperation(s.addeffop(se))
eff:SetReset(RESET_CHAIN)
Debug.Message(sc:RegisterEffect(eff,true))
sc:RegisterEffect(eff,true)
Duel.RaiseEvent(eg,233+code,re,r,rp,ep,ev)
end
end
......@@ -2136,7 +2138,6 @@ function s.mindcon(e,tp)
local mp=e:GetLabel()
local c=e:GetHandler()
local tep=c:GetControler()
return s.Control_Mode and tp~=tep and tp==mp and effect:IsActivatable(tep,false,false)
end
function s.mindcon2(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