Commit 4f6c266a authored by wyykak's avatar wyykak

fix exlink by gugu

Signed-off-by: wyykak's avatarwyykak <wyy_1414@126.com>
parent c3cb0608
Pipeline #26211 passed with stage
in 16 seconds
Exlink = Exlink or {}
--extra link
function Exlink.AddLinkProcedure(c,f,min,max,mattg,matval,loc1,loc2,count,code,gf)
local e1=Effect.CreateEffect(c)
e1:SetDescription(1166)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetRange(LOCATION_EXTRA)
if max==nil then max=c:GetLink() end
e1:SetCondition(Exlink.LinkCondition(f,min,max,loc1,loc2,gf))
e1:SetTarget(Exlink.LinkTarget(f,min,max,loc1,loc2,gf))
e1:SetOperation(Exlink.LinkOperation(f,min,max,loc1,loc2,gf))
e1:SetValue(SUMMON_TYPE_LINK)
c:RegisterEffect(e1)
--extra material
if mattg and matval and (loc1 or loc2) then
local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE+EFFECT_FLAG_SET_AVAILABLE)
e2:SetCode(EFFECT_EXTRA_LINK_MATERIAL)
e2:SetRange(LOCATION_EXTRA)
if count then
if code==nil then code=c:GetOriginalCode() end
e2:SetCountLimit(count,code)
end
e2:SetLabel(404)
e2:SetTarget(Exlink.exmattg(mattg))
e2:SetTargetRange(loc1,loc2)
e2:SetValue(Exlink.exmatval(matval))
c:RegisterEffect(e2)
end
return e1
end
function Exlink.LConditionFilter(c,f,lc,e)
return (c:IsFaceup() or not c:IsOnField() or e:IsHasProperty(EFFECT_FLAG_SET_AVAILABLE))
and c:IsCanBeLinkMaterial(lc) and (not f or f(c))
end
function Exlink.LExtraFilter(c,f,lc,tp)
if c:IsOnField() and c:IsFacedown() then return false end
if not c:IsCanBeLinkMaterial(lc) or f and not f(c) then return false end
local le={c:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp)}
for _,te in pairs(le) do
local tf=te:GetValue()
local related,valid=tf(te,lc,nil,c,tp)
if related and valid then return true end
end
return false
end
function Exlink.LExtraFilter2(c,f,lc,tp)
if not c:IsCanBeLinkMaterial(lc) or f and not f(c) then return false end
local le={c:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp)}
for _,te in pairs(le) do
local tf=te:GetValue()
local label=te:GetLabel()
local related,valid=tf(te,lc,nil,c,tp)
if related and valid and label and label==404 then return true end
end
return false
end
function Exlink.GetLinkCount(c)
if c:IsType(TYPE_LINK) and c:GetLink()>1 then
return 1+0x10000*c:GetLink()
else return 1 end
end
function Exlink.GetLinkMaterials(tp,f,lc,e,loc1,loc2)
local mg=Duel.GetMatchingGroup(Exlink.LConditionFilter,tp,LOCATION_MZONE,0,nil,f,lc,e)
local mg2=Duel.GetMatchingGroup(Exlink.LExtraFilter,tp,LOCATION_HAND+LOCATION_SZONE,LOCATION_ONFIELD,nil,f,lc,tp)
local mg3=Duel.GetMatchingGroup(Exlink.LExtraFilter2,tp,loc1,loc2,nil,f,lc,tp)
if mg2:GetCount()>0 then mg:Merge(mg2) end
if mg3:GetCount()>0 then mg:Merge(mg3) end
return mg
end
function Exlink.LCheckOtherMaterial(c,mg,lc,tp)
local le={c:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp)}
local res1=false
local res2=true
for _,te in pairs(le) do
local f=te:GetValue()
local related,valid=f(te,lc,mg,c,tp)
if related then res2=false end
if related and valid then res1=true end
end
return res1 or res2
end
function Exlink.LUncompatibilityFilter(c,sg,lc,tp)
local mg=sg:Filter(aux.TRUE,c)
return not Exlink.LCheckOtherMaterial(c,mg,lc,tp)
end
function Exlink.LCheckGoal(sg,tp,lc,gf,lmat)
return sg:CheckWithSumEqual(Exlink.GetLinkCount,lc:GetLink(),#sg,#sg)
and Duel.GetLocationCountFromEx(tp,tp,sg,lc)>0 and (not gf or gf(sg,lc,tp))
and not sg:IsExists(Exlink.LUncompatibilityFilter,1,nil,sg,lc,tp)
and (not lmat or sg:IsContains(lmat))
end
function Exlink.LExtraMaterialCount(mg,lc,tp)
for tc in aux.Next(mg) do
local le={tc:IsHasEffect(EFFECT_EXTRA_LINK_MATERIAL,tp)}
for _,te in pairs(le) do
local sg=mg:Filter(aux.TRUE,tc)
local f=te:GetValue()
local related,valid=f(te,lc,sg,tc,tp)
if related and valid then
te:UseCountLimit(tp)
end
end
end
end
function Exlink.LinkCondition(f,minc,maxc,loc1,loc2,gf)
return function(e,c,og,lmat,min,max)
if c==nil then return true end
if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end
local minc=minc
local maxc=maxc
if min then
if min>minc then minc=min end
if max<maxc then maxc=max end
if minc>maxc then return false end
end
local tp=c:GetControler()
local mg=nil
if og then
mg=og:Filter(Exlink.LConditionFilter,nil,f,c,e)
else
mg=Exlink.GetLinkMaterials(tp,f,c,e,loc1,loc2)
end
if lmat~=nil then
if not Exlink.LConditionFilter(lmat,f,c,e) then return false end
mg:AddCard(lmat)
end
local fg=Duel.GetMustMaterial(tp,EFFECT_MUST_BE_LMATERIAL)
if fg:IsExists(Auxiliary.MustMaterialCounterFilter,1,nil,mg) then return false end
Duel.SetSelectedCard(fg)
return mg:CheckSubGroup(Exlink.LCheckGoal,minc,maxc,tp,c,gf,lmat)
end
end
function Exlink.LinkTarget(f,minc,maxc,loc1,loc2,gf)
return function(e,tp,eg,ep,ev,re,r,rp,chk,c,og,lmat,min,max)
local minc=minc
local maxc=maxc
if min then
if min>minc then minc=min end
if max<maxc then maxc=max end
if minc>maxc then return false end
end
local mg=nil
if og then
mg=og:Filter(Exlink.LConditionFilter,nil,f,c,e)
else
mg=Exlink.GetLinkMaterials(tp,f,c,e,loc1,loc2)
end
if lmat~=nil then
if not Exlink.LConditionFilter(lmat,f,c,e) then return false end
mg:AddCard(lmat)
end
local fg=Duel.GetMustMaterial(tp,EFFECT_MUST_BE_LMATERIAL)
Duel.SetSelectedCard(fg)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL)
local cancel=Duel.IsSummonCancelable()
local sg=mg:SelectSubGroup(tp,Exlink.LCheckGoal,cancel,minc,maxc,tp,c,gf,lmat)
if sg then
sg:KeepAlive()
e:SetLabelObject(sg)
return true
else return false end
end
end
function Exlink.LinkOperation(f,minc,maxc,loc1,loc2,gf)
return function(e,tp,eg,ep,ev,re,r,rp,c,og,lmat,min,max)
local g=e:GetLabelObject()
c:SetMaterial(g)
Exlink.LExtraMaterialCount(g,c,tp)
Duel.SendtoGrave(g,REASON_MATERIAL+REASON_LINK)
g:DeleteGroup()
end
end
function Exlink.exmattg(mattg)
return function(e,c)
return mattg(e,c)
end
end
function Exlink.exmatval(matval)
return function(e,lc,mg,c,tp)
return matval(e,lc,mg,c,tp)
end
end
\ No newline at end of file
...@@ -6,6 +6,7 @@ Duel.LoadScript("nef/elf.lua") ...@@ -6,6 +6,7 @@ Duel.LoadScript("nef/elf.lua")
Duel.LoadScript("nef/dss.lua") Duel.LoadScript("nef/dss.lua")
Duel.LoadScript("nef/afi.lua") Duel.LoadScript("nef/afi.lua")
Duel.LoadScript("nef/TheElementTheory.lua") Duel.LoadScript("nef/TheElementTheory.lua")
Duel.LoadScript("nef/Exlink.lua")
-- require "expansions/script/nef/nef" -- require "expansions/script/nef/nef"
-- require "expansions/script/nef/msc" -- require "expansions/script/nef/msc"
......
--花与妖的连结✿风见幽香 --花与妖的连结✿风见幽香
function c25501.initial_effect(c) function c25501.initial_effect(c)
c:EnableReviveLimit() --link summon
--link summon Exlink.AddLinkProcedure(c,nil,7,nil,c25501.mattg,c25501.matval,0,LOCATION_MZONE)
local e1=Effect.CreateEffect(c) c:EnableReviveLimit()
e1:SetType(EFFECT_TYPE_FIELD) --atk
e1:SetCode(EFFECT_SPSUMMON_PROC) local e2=Effect.CreateEffect(c)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE) e2:SetType(EFFECT_TYPE_SINGLE)
e1:SetRange(LOCATION_EXTRA) e2:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetCondition(c25501.lkcon) e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e1:SetOperation(c25501.lkop) e2:SetRange(LOCATION_MZONE)
e1:SetValue(SUMMON_TYPE_LINK) e2:SetValue(c25501.atkval)
c:RegisterEffect(e1) c:RegisterEffect(e2)
--atk --cannot attack
local e2=Effect.CreateEffect(c) local e4=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE) e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EFFECT_UPDATE_ATTACK) e4:SetCode(EVENT_SPSUMMON_SUCCESS)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE) e4:SetOperation(c25501.atklimit)
e2:SetRange(LOCATION_MZONE) c:RegisterEffect(e4)
e2:SetValue(c25501.atkval) --immune trap
c:RegisterEffect(e2) local e6=Effect.CreateEffect(c)
--cannot attack e6:SetType(EFFECT_TYPE_SINGLE)
local e4=Effect.CreateEffect(c) e6:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_CONTINUOUS) e6:SetRange(LOCATION_MZONE)
e4:SetCode(EVENT_SPSUMMON_SUCCESS) e6:SetCode(EFFECT_IMMUNE_EFFECT)
e4:SetOperation(c25501.atklimit) e6:SetCondition(c25501.econ)
c:RegisterEffect(e4) e6:SetValue(c25501.efilter)
--immune trap c:RegisterEffect(e6)
local e6=Effect.CreateEffect(c) end
e6:SetType(EFFECT_TYPE_SINGLE) function c25501.mattg(e,c)
e6:SetProperty(EFFECT_FLAG_SINGLE_RANGE) local tp=e:GetHandler():GetControler()
e6:SetRange(LOCATION_MZONE) local check1=c:IsType(TYPE_MONSTER) and (c:IsOnField() or c:IsFacedown())
e6:SetCode(EFFECT_IMMUNE_EFFECT) return check1 and not (c:IsType(TYPE_LINK) and c:IsControler(1-tp))
e6:SetCondition(c25501.econ) end
e6:SetValue(c25501.efilter) function c25501.matval(e,lc,mg,c,tp)
c:RegisterEffect(e6) if e:GetHandler()~=lc then return false,nil end
end return true,not mg or mg
-- end
function c25501.lkfilter(c,lc,tp) function c25501.atkval(e,c)
local flag=c:IsFaceup() and c:IsCanBeLinkMaterial(lc) return c:GetLinkedGroupCount()*1000
if c:IsControler(tp) then end
return flag and c:IsType(TYPE_MONSTER) function c25501.atklimit(e,tp,eg,ep,ev,re,r,rp)
else local e1=Effect.CreateEffect(e:GetHandler())
return flag and c:IsType(TYPE_MONSTER) and not c:IsType(TYPE_LINK) e1:SetType(EFFECT_TYPE_SINGLE)
end e1:SetCode(EFFECT_CANNOT_ATTACK)
end e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
function c25501.lvfilter(c) e:GetHandler():RegisterEffect(e1)
if c:IsType(TYPE_LINK) and c:GetLink()>1 then end
return 1+0x10000*c:GetLink() function c25501.econ(e)
else local tp=e:GetHandler():GetControler()
return 1 return Duel.GetLP(tp) > Duel.GetLP(1-tp)
end end
end function c25501.efilter(e,te)
-- return te:IsActiveType(TYPE_TRAP)
function c25501.lcheck(tp,sg,lc,minc,ct) end
return ct>=minc and sg:CheckWithSumEqual(c25501.lvfilter,lc:GetLink(),ct,ct) and Duel.GetLocationCountFromEx(tp,tp,sg,lc)>0
end
function c25501.lkchenk(c,tp,sg,mg,lc,ct,minc,maxc)
sg:AddCard(c)
ct=ct+1
local res=c25501.lcheck(tp,sg,lc,minc,ct) or (ct<maxc and mg:IsExists(c25501.lkchenk,1,sg,tp,sg,mg,lc,ct,minc,maxc))
sg:RemoveCard(c)
ct=ct-1
return res
end
--
function c25501.lkcon(e,c)
if c==nil then return true end
if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end
local tp=c:GetControler()
local mg=Duel.GetMatchingGroup(c25501.lkfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,c,tp)
local sg=Group.CreateGroup()
for i,pe in ipairs({Duel.IsPlayerAffectedByEffect(tp,EFFECT_MUST_BE_LMATERIAL)}) do
local pc=pe:GetHandler()
if not mg:IsContains(pc) then return false end
sg:AddCard(pc)
end
local ct=sg:GetCount()
local minc=7
local maxc=8
if ct>maxc then return false end
return c25501.lcheck(tp,sg,c,minc,ct) or mg:IsExists(c25501.lkchenk,1,nil,tp,sg,mg,c,ct,minc,maxc)
end
--
function c25501.lkop(e,tp,eg,ep,ev,re,r,rp,c)
local mg=Duel.GetMatchingGroup(c25501.lkfilter,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,c,tp)
local sg=Group.CreateGroup()
for i,pe in ipairs({Duel.IsPlayerAffectedByEffect(tp,EFFECT_MUST_BE_LMATERIAL)}) do
sg:AddCard(pe:GetHandler())
end
local ct=sg:GetCount()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL)
sg:Select(tp,ct,ct,nil)
local minc=7
local maxc=8
for i=ct,maxc-1 do
local cg=mg:Filter(c25501.lkchenk,sg,tp,sg,mg,c,i,minc,maxc)
if cg:GetCount()==0 then break end
local minct=1
if c25501.lcheck(tp,sg,c,minc,i) then
if not Duel.SelectYesNo(tp,210) then break end
minct=0
end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL)
local g=cg:Select(tp,minct,1,nil)
if g:GetCount()==0 then break end
sg:Merge(g)
end
c:SetMaterial(sg)
Duel.SendtoGrave(sg,REASON_MATERIAL+REASON_LINK)
end
--
function c25501.atkval(e,c)
return c:GetLinkedGroupCount()*1000
end
function c25501.atklimit(e,tp,eg,ep,ev,re,r,rp)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_CANNOT_ATTACK)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+PHASE_END)
e:GetHandler():RegisterEffect(e1)
end
function c25501.econ(e)
local tp=e:GetHandler():GetControler()
return Duel.GetLP(tp) > Duel.GetLP(1-tp)
end
function c25501.efilter(e,te)
return te:IsActiveType(TYPE_TRAP)
end
--蓬莱-永夜的隐者✿八意永琳 --蓬莱-永夜的隐者✿八意永琳
function c86379558.initial_effect(c) function c86379558.initial_effect(c)
--link summon --link summon
c:EnableReviveLimit() Exlink.AddLinkProcedure(c,nil,7,nil,c86379558.mattg,c86379558.matval,LOCATION_ONFIELD,LOCATION_ONFIELD)
local e0=Effect.CreateEffect(c) --moon
e0:SetType(EFFECT_TYPE_FIELD) local e1=Effect.CreateEffect(c)
e0:SetCode(EFFECT_SPSUMMON_PROC) e1:SetType(EFFECT_TYPE_FIELD)
e0:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE) e1:SetCode(EFFECT_TRAP_ACT_IN_SET_TURN)
e0:SetRange(LOCATION_EXTRA) e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
e0:SetCondition(c86379558.lkcon1) e1:SetRange(LOCATION_MZONE)
e0:SetOperation(c86379558.lkop1) e1:SetTargetRange(LOCATION_SZONE,0)
e0:SetValue(SUMMON_TYPE_LINK) e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x257))
c:RegisterEffect(e0) c:RegisterEffect(e1)
--moon --destroy
local e1=Effect.CreateEffect(c) local e2=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD) e2:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_TRAP_ACT_IN_SET_TURN) e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
e1:SetProperty(EFFECT_FLAG_SET_AVAILABLE) e2:SetRange(LOCATION_MZONE)
e1:SetRange(LOCATION_MZONE) e2:SetTargetRange(LOCATION_ONFIELD,0)
e1:SetTargetRange(LOCATION_SZONE,0) e2:SetTarget(c86379558.indes)
e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x257)) e2:SetValue(1)
c:RegisterEffect(e1) c:RegisterEffect(e2)
--destroy --lp
local e2=Effect.CreateEffect(c) local e3=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD) e3:SetDescription(aux.Stringid(86379558,0))
e2:SetCode(EFFECT_INDESTRUCTABLE_EFFECT) e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e2:SetRange(LOCATION_MZONE) e3:SetCode(EVENT_DESTROYED)
e2:SetTargetRange(LOCATION_ONFIELD,0) e3:SetTarget(c86379558.lptg)
e2:SetTarget(c86379558.indes) e3:SetOperation(c86379558.lpop)
e2:SetValue(1) c:RegisterEffect(e3)
c:RegisterEffect(e2) end
--lp function c86379558.mattg(e,c)
local e3=Effect.CreateEffect(c) return c:IsOnField() and c:IsFacedown()
e3:SetDescription(aux.Stringid(86379558,0)) end
e3:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F) function c86379558.matval(e,lc,mg,c,tp)
e3:SetCode(EVENT_DESTROYED) if e:GetHandler()~=lc then return false,nil end
e3:SetTarget(c86379558.lptg) return true,not mg or mg
e3:SetOperation(c86379558.lpop) end
c:RegisterEffect(e3) --
end function c86379558.indes(e,c)
-- return c:IsFaceup() and c:IsSetCard(0x257) and c:IsType(TYPE_SPELL+TYPE_TRAP)
function c86379558.indes(e,c) end
return c:IsFaceup() and c:IsSetCard(0x257) and c:IsType(TYPE_SPELL+TYPE_TRAP) --
end function c86379558.lptg(e,tp,eg,ep,ev,re,r,rp,chk)
-- if chk==0 then return e:GetHandler():IsReason(REASON_EFFECT) end
function c86379558.lptg(e,tp,eg,ep,ev,re,r,rp,chk) end
if chk==0 then return e:GetHandler():IsReason(REASON_EFFECT) end function c86379558.lpop(e,tp,eg,ep,ev,re,r,rp)
end local e1=Effect.CreateEffect(e:GetHandler())
function c86379558.lpop(e,tp,eg,ep,ev,re,r,rp) e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
local e1=Effect.CreateEffect(e:GetHandler()) e1:SetCountLimit(1)
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS) e1:SetCode(EVENT_PHASE+PHASE_END)
e1:SetCountLimit(1) e1:SetReset(RESET_PHASE+PHASE_END)
e1:SetCode(EVENT_PHASE+PHASE_END) e1:SetOperation(c86379558.damop)
e1:SetReset(RESET_PHASE+PHASE_END) Duel.RegisterEffect(e1,tp)
e1:SetOperation(c86379558.damop) end
Duel.RegisterEffect(e1,tp) function c86379558.damop(e,tp,eg,ep,ev,re,r,rp)
end Duel.Hint(HINT_CARD,0,86379558)
function c86379558.damop(e,tp,eg,ep,ev,re,r,rp) Duel.SetLP(1-tp,Duel.GetLP(1-tp)-1800)
Duel.Hint(HINT_CARD,0,86379558) end
Duel.SetLP(1-tp,Duel.GetLP(1-tp)-1800)
end
--
function c86379558.lkfilter1(c,lc,tp)
if c:IsType(TYPE_MONSTER) and c:IsFaceup() then
return c:IsCanBeLinkMaterial(lc) and c:IsControler(tp)
else
return c:IsFacedown()
end
end
function c86379558.lvfilter1(c)
if c:IsType(TYPE_LINK) and c:GetLink()>1 then
return 1+0x10000*c:GetLink()
else
return 1
end
end
function c86379558.lcheck1(tp,sg,lc,minc,ct)
return ct>=minc and sg:CheckWithSumEqual(c86379558.lvfilter1,lc:GetLink(),ct,ct) and Duel.GetLocationCountFromEx(tp,tp,sg,lc)>0
end
function c86379558.lkchenk1(c,tp,sg,mg,lc,ct,minc,maxc)
sg:AddCard(c)
ct=ct+1
local res=c86379558.lcheck1(tp,sg,lc,minc,ct) or (ct<maxc and mg:IsExists(c86379558.lkchenk1,1,sg,tp,sg,mg,lc,ct,minc,maxc))
sg:RemoveCard(c)
ct=ct-1
return res
end
function c86379558.lkcon1(e,c)
if c==nil then return true end
if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end
local tp=c:GetControler()
local mg=Duel.GetMatchingGroup(c86379558.lkfilter1,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,c,tp)
local sg=Group.CreateGroup()
for i,pe in ipairs({Duel.IsPlayerAffectedByEffect(tp,EFFECT_MUST_BE_LMATERIAL)}) do
local pc=pe:GetHandler()
if not mg:IsContains(pc) then return false end
sg:AddCard(pc)
end
local ct=sg:GetCount()
local minc=7
local maxc=8
if ct>maxc then return false end
return (c86379558.lcheck1(tp,sg,c,minc,ct) or mg:IsExists(c86379558.lkchenk1,1,nil,tp,sg,mg,c,ct,minc,maxc))
end
function c86379558.lkop1(e,tp,eg,ep,ev,re,r,rp,c)
local mg=Duel.GetMatchingGroup(c86379558.lkfilter1,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,c,tp)
local sg=Group.CreateGroup()
for i,pe in ipairs({Duel.IsPlayerAffectedByEffect(tp,EFFECT_MUST_BE_LMATERIAL)}) do
sg:AddCard(pe:GetHandler())
end
local ct=sg:GetCount()
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL)
sg:Select(tp,ct,ct,nil)
local minc=7
local maxc=8
for i=ct,maxc-1 do
local cg=mg:Filter(c86379558.lkchenk1,sg,tp,sg,mg,c,i,minc,maxc)
if cg:GetCount()==0 then break end
local minct=1
if c86379558.lcheck1(tp,sg,c,minc,i) then
if not Duel.SelectYesNo(tp,210) then break end
minct=0
end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL)
local g=cg:Select(tp,minct,1,nil)
if g:GetCount()==0 then break end
sg:Merge(g)
end
c:SetMaterial(sg)
Duel.SendtoGrave(sg,REASON_MATERIAL+REASON_LINK)
end
--境界的妖怪✿八云紫 --境界的妖怪✿八云紫
function c86379662.initial_effect(c) function c86379662.initial_effect(c)
aux.AddCodeList(c,20038) aux.AddCodeList(c,20038)
--link summon --link summon
c:EnableReviveLimit() Exlink.AddLinkProcedure(c,nil,7,nil,c86379662.mattg,c86379662.matval,LOCATION_ONFIELD,LOCATION_ONFIELD)
local e0=Effect.CreateEffect(c) c:EnableReviveLimit()
e0:SetType(EFFECT_TYPE_FIELD) --Remove
e0:SetCode(EFFECT_SPSUMMON_PROC) local e1=Effect.CreateEffect(c)
e0:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE) e1:SetDescription(aux.Stringid(86379662,0))
e0:SetRange(LOCATION_EXTRA) e1:SetCategory(CATEGORY_REMOVE)
e0:SetCondition(c86379662.lkcon1) e1:SetType(EFFECT_TYPE_QUICK_O)
e0:SetOperation(c86379662.lkop1) e1:SetCode(EVENT_FREE_CHAIN)
e0:SetValue(SUMMON_TYPE_LINK) e1:SetHintTiming(0,TIMING_MAIN_END)
c:RegisterEffect(e0) e1:SetRange(LOCATION_MZONE)
--Remove e1:SetCondition(c86379662.rmcon)
local e1=Effect.CreateEffect(c) e1:SetCost(c86379662.rmcost)
e1:SetDescription(aux.Stringid(86379662,0)) e1:SetTarget(c86379662.rmtg)
e1:SetCategory(CATEGORY_REMOVE) e1:SetOperation(c86379662.rmop)
e1:SetType(EFFECT_TYPE_QUICK_O) c:RegisterEffect(e1)
e1:SetCode(EVENT_FREE_CHAIN) --tohand
e1:SetHintTiming(0,TIMING_MAIN_END) local e2=Effect.CreateEffect(c)
e1:SetRange(LOCATION_MZONE) e2:SetDescription(aux.Stringid(86379662,1))
e1:SetCondition(c86379662.rmcon) e2:SetCategory(CATEGORY_TOHAND)
e1:SetCost(c86379662.rmcost) e2:SetType(EFFECT_TYPE_IGNITION)
e1:SetTarget(c86379662.rmtg) e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e1:SetOperation(c86379662.rmop) e2:SetRange(LOCATION_REMOVED)
c:RegisterEffect(e1) e2:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE)
--tohand e2:SetCondition(c86379662.gcon1)
local e2=Effect.CreateEffect(c) e2:SetTarget(c86379662.gtg)
e2:SetDescription(aux.Stringid(86379662,1)) e2:SetOperation(c86379662.gop)
e2:SetCategory(CATEGORY_TOHAND) c:RegisterEffect(e2)
e2:SetType(EFFECT_TYPE_IGNITION) --
e2:SetProperty(EFFECT_FLAG_CARD_TARGET) local e3=e2:Clone()
e2:SetRange(LOCATION_REMOVED) e3:SetType(EFFECT_TYPE_QUICK_O)
e2:SetCountLimit(1,EFFECT_COUNT_CODE_SINGLE) e3:SetCode(EVENT_FREE_CHAIN)
e2:SetCondition(c86379662.gcon1) e3:SetCondition(c86379662.gcon2)
e2:SetTarget(c86379662.gtg) c:RegisterEffect(e3)
e2:SetOperation(c86379662.gop) --immune trap
c:RegisterEffect(e2) local e4=Effect.CreateEffect(c)
-- e4:SetType(EFFECT_TYPE_SINGLE)
local e3=e2:Clone() e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e3:SetType(EFFECT_TYPE_QUICK_O) e4:SetRange(LOCATION_MZONE)
e3:SetCode(EVENT_FREE_CHAIN) e4:SetCode(EFFECT_IMMUNE_EFFECT)
e3:SetCondition(c86379662.gcon2) e4:SetCondition(c86379662.econ)
c:RegisterEffect(e3) e4:SetValue(c86379662.efilter)
--immune trap c:RegisterEffect(e4)
local e4=Effect.CreateEffect(c) end
e4:SetType(EFFECT_TYPE_SINGLE) function c86379662.mattg(e,c)
e4:SetProperty(EFFECT_FLAG_SINGLE_RANGE) return c:IsType(TYPE_SPELL) and c:IsOnField() and c:IsFaceup()
e4:SetRange(LOCATION_MZONE) end
e4:SetCode(EFFECT_IMMUNE_EFFECT) function c86379662.matval(e,lc,mg,c,tp)
e4:SetCondition(c86379662.econ) if e:GetHandler()~=lc then return false,nil end
e4:SetValue(c86379662.efilter) return true,not mg or mg
c:RegisterEffect(e4) end
end --
-- function c86379662.rmcon(e,tp,eg,ep,ev,re,r,rp)
function c86379662.lkfilter1(c,lc,tp) return Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2
local flag=c:IsFaceup() and c:IsCanBeLinkMaterial(lc) and c:IsControler(tp) end
if c:IsType(TYPE_MONSTER) then function c86379662.rmcost(e,tp,eg,ep,ev,re,r,rp,chk)
return flag if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end
else if Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST+REASON_TEMPORARY)~=0 then
return c:IsFaceup() and c:IsType(TYPE_SPELL) local e1=Effect.CreateEffect(e:GetHandler())
end e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
end e1:SetCode(EVENT_PHASE+PHASE_END)
function c86379662.lvfilter1(c) e1:SetReset(RESET_PHASE+PHASE_END)
if c:IsType(TYPE_LINK) and c:GetLink()>1 then e1:SetLabelObject(e:GetHandler())
return 1+0x10000*c:GetLink() e1:SetCountLimit(1)
else e1:SetOperation(c86379662.retop)
return 1 Duel.RegisterEffect(e1,tp)
end end
end end
function c86379662.lcheck1(tp,sg,lc,minc,ct) function c86379662.retop(e,tp,eg,ep,ev,re,r,rp)
return ct>=minc and sg:CheckWithSumEqual(c86379662.lvfilter1,lc:GetLink(),ct,ct) and Duel.GetLocationCountFromEx(tp,tp,sg,lc)>0 Duel.ReturnToField(e:GetLabelObject())
end end
function c86379662.lkchenk1(c,tp,sg,mg,lc,ct,minc,maxc) function c86379662.rmtg(e,tp,eg,ep,ev,re,r,rp,chk)
sg:AddCard(c) if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,nil) end
ct=ct+1 local g=Duel.GetMatchingGroup(Card.IsAbleToRemove,tp,LOCATION_GRAVE,LOCATION_GRAVE,nil)
local res=c86379662.lcheck1(tp,sg,lc,minc,ct) or (ct<maxc and mg:IsExists(c86379662.lkchenk1,1,sg,tp,sg,mg,lc,ct,minc,maxc)) Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,LOCATION_GRAVE)
sg:RemoveCard(c) Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,1-tp,LOCATION_GRAVE)
ct=ct-1 end
return res function c86379662.rmop(e,tp,eg,ep,ev,re,r,rp)
end Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
function c86379662.lkcon1(e,c) local g=Duel.SelectMatchingCard(tp,Card.IsAbleToRemove,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,4,nil)
if c==nil then return true end if g:GetCount()>0 then
if c:IsType(TYPE_PENDULUM) and c:IsFaceup() then return false end Duel.Remove(g,POS_FACEUP,REASON_EFFECT)
local tp=c:GetControler() end
local mg=Duel.GetMatchingGroup(c86379662.lkfilter1,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,c,tp) end
local sg=Group.CreateGroup() --
for i,pe in ipairs({Duel.IsPlayerAffectedByEffect(tp,EFFECT_MUST_BE_LMATERIAL)}) do function c86379662.gconfilter(c)
local pc=pe:GetHandler() return aux.IsCodeListed(c,20038) and c:IsFaceup()
if not mg:IsContains(pc) then return false end end
sg:AddCard(pc) function c86379662.gcon1(e,tp,eg,ep,ev,re,r,rp)
end return Duel.GetMatchingGroupCount(c86379662.gconfilter,tp,LOCATION_ONFIELD,0,nil)<4
local ct=sg:GetCount() end
local minc=7 function c86379662.gcon2(e,tp,eg,ep,ev,re,r,rp)
local maxc=8 return Duel.GetMatchingGroupCount(c86379662.gconfilter,tp,LOCATION_ONFIELD,0,nil)>=4
if ct>maxc then return false end end
return (c86379662.lcheck1(tp,sg,c,minc,ct) or mg:IsExists(c86379662.lkchenk1,1,nil,tp,sg,mg,c,ct,minc,maxc)) function c86379662.gfilter(c)
end return c:IsAbleToHand() and aux.IsCodeListed(c,20038) and c:IsFaceup()
function c86379662.lkop1(e,tp,eg,ep,ev,re,r,rp,c) end
local mg=Duel.GetMatchingGroup(c86379662.lkfilter1,tp,LOCATION_ONFIELD,LOCATION_ONFIELD,nil,c,tp) function c86379662.gtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
local sg=Group.CreateGroup() if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_ONFIELD) and c86379662.gfilter(chkc) end
for i,pe in ipairs({Duel.IsPlayerAffectedByEffect(tp,EFFECT_MUST_BE_LMATERIAL)}) do if chk==0 then return Duel.IsExistingTarget(c86379662.gfilter,tp,LOCATION_ONFIELD,0,1,nil) end
sg:AddCard(pe:GetHandler()) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
end local g=Duel.SelectTarget(tp,c86379662.gfilter,tp,LOCATION_ONFIELD,0,1,1,nil)
local ct=sg:GetCount() Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL) end
sg:Select(tp,ct,ct,nil) function c86379662.gop(e,tp,eg,ep,ev,re,r,rp)
local minc=7 local tc=Duel.GetFirstTarget()
local maxc=8 if tc:IsRelateToEffect(e) then
for i=ct,maxc-1 do Duel.SendtoHand(tc,nil,REASON_EFFECT)
local cg=mg:Filter(c86379662.lkchenk1,sg,tp,sg,mg,c,i,minc,maxc) end
if cg:GetCount()==0 then break end end
local minct=1 --
if c86379662.lcheck1(tp,sg,c,minc,i) then function c86379662.econ(e)
if not Duel.SelectYesNo(tp,210) then break end local tp=e:GetHandler():GetControler()
minct=0 return Duel.GetLP(tp) > Duel.GetLP(1-tp)
end end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_LMATERIAL) function c86379662.efilter(e,te)
local g=cg:Select(tp,minct,1,nil) return te:IsActiveType(TYPE_SPELL)
if g:GetCount()==0 then break end end
sg:Merge(g)
end
c:SetMaterial(sg)
Duel.SendtoGrave(sg,REASON_MATERIAL+REASON_LINK)
end
--
function c86379662.rmcon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetCurrentPhase()==PHASE_MAIN1 or Duel.GetCurrentPhase()==PHASE_MAIN2
end
function c86379662.rmcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():IsAbleToRemoveAsCost() end
if Duel.Remove(e:GetHandler(),POS_FACEUP,REASON_COST+REASON_TEMPORARY)~=0 then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_PHASE+PHASE_END)
e1:SetReset(RESET_PHASE+PHASE_END)
e1:SetLabelObject(e:GetHandler())
e1:SetCountLimit(1)
e1:SetOperation(c86379662.retop)
Duel.RegisterEffect(e1,tp)
end
end
function c86379662.retop(e,tp,eg,ep,ev,re,r,rp)
Duel.ReturnToField(e:GetLabelObject())
end
function c86379662.rmtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(Card.IsAbleToRemove,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,nil) end
local g=Duel.GetMatchingGroup(Card.IsAbleToRemove,tp,LOCATION_GRAVE,LOCATION_GRAVE,nil)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,tp,LOCATION_GRAVE)
Duel.SetOperationInfo(0,CATEGORY_REMOVE,nil,1,1-tp,LOCATION_GRAVE)
end
function c86379662.rmop(e,tp,eg,ep,ev,re,r,rp)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_REMOVE)
local g=Duel.SelectMatchingCard(tp,Card.IsAbleToRemove,tp,LOCATION_GRAVE,LOCATION_GRAVE,1,4,nil)
if g:GetCount()>0 then
Duel.Remove(g,POS_FACEUP,REASON_EFFECT)
end
end
--
function c86379662.gconfilter(c)
return aux.IsCodeListed(c,20038) and c:IsFaceup()
end
function c86379662.gcon1(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetMatchingGroupCount(c86379662.gconfilter,tp,LOCATION_ONFIELD,0,nil)<4
end
function c86379662.gcon2(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetMatchingGroupCount(c86379662.gconfilter,tp,LOCATION_ONFIELD,0,nil)>=4
end
function c86379662.gfilter(c)
return c:IsAbleToHand() and aux.IsCodeListed(c,20038) and c:IsFaceup()
end
function c86379662.gtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsControler(tp) and chkc:IsLocation(LOCATION_ONFIELD) and c86379662.gfilter(chkc) end
if chk==0 then return Duel.IsExistingTarget(c86379662.gfilter,tp,LOCATION_ONFIELD,0,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_RTOHAND)
local g=Duel.SelectTarget(tp,c86379662.gfilter,tp,LOCATION_ONFIELD,0,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOHAND,g,1,0,0)
end
function c86379662.gop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) then
Duel.SendtoHand(tc,nil,REASON_EFFECT)
end
end
--
function c86379662.econ(e)
local tp=e:GetHandler():GetControler()
return Duel.GetLP(tp) > Duel.GetLP(1-tp)
end
function c86379662.efilter(e,te)
return te:IsActiveType(TYPE_SPELL)
end
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