Commit c72ded18 authored by nanahira's avatar nanahira

add EFFECT_EXTRA_PENDULUM_SUMMON

parent 0900bf27
...@@ -87,178 +87,17 @@ function c29432356.hspop(e,tp,eg,ep,ev,re,r,rp,c) ...@@ -87,178 +87,17 @@ function c29432356.hspop(e,tp,eg,ep,ev,re,r,rp,c)
end end
function c29432356.penop(e,tp,eg,ep,ev,re,r,rp) function c29432356.penop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler() local c=e:GetHandler()
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(29432356,2))
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC_G)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE)
e1:SetRange(LOCATION_PZONE)
e1:SetCountLimit(1,29432356)
e1:SetCondition(c29432356.pencon1)
e1:SetOperation(c29432356.penop1)
e1:SetValue(SUMMON_TYPE_PENDULUM)
local e2=Effect.CreateEffect(c) local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_GRANT) e2:SetType(EFFECT_TYPE_FIELD)
e2:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE) e2:SetCode(EFFECT_EXTRA_PENDULUM_SUMMON)
e2:SetTargetRange(LOCATION_SZONE,0) e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e2:SetTarget(c29432356.eftg) e2:SetTargetRange(1,0)
e2:SetLabelObject(e1) e2:SetValue(c29432356.pendvalue)
e2:SetReset(RESET_PHASE+PHASE_END) e2:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e2,tp) Duel.RegisterEffect(e2,tp)
local e3=Effect.CreateEffect(c)
e3:SetDescription(aux.Stringid(29432356,2))
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetCode(EFFECT_SPSUMMON_PROC_G)
e3:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_CANNOT_DISABLE)
e3:SetRange(LOCATION_PZONE)
e3:SetCountLimit(1,29432356)
e3:SetCondition(c29432356.pencon2)
e3:SetOperation(c29432356.penop2)
e3:SetValue(SUMMON_TYPE_PENDULUM)
local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_GRANT)
e4:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e4:SetTargetRange(0,LOCATION_SZONE)
e4:SetTarget(c29432356.eftg2)
e4:SetLabelObject(e3)
e4:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e4,tp)
end
function c29432356.eftg(e,c)
return c==Duel.GetFieldCard(e:GetHandlerPlayer(),LOCATION_PZONE,0)
end end
function c29432356.eftg2(e,c) function c29432356.pendvalue(e,c)
local rpz=Duel.GetFieldCard(1-e:GetHandlerPlayer(),LOCATION_PZONE,1) return c:IsSetCard(0xc4)
return c==Duel.GetFieldCard(1-e:GetHandlerPlayer(),LOCATION_PZONE,0)
and rpz
and c:GetFlagEffectLabel(31531170)==rpz:GetFieldID()
and rpz:GetFlagEffectLabel(31531170)==c:GetFieldID()
end
function c29432356.penfilter(c,e,tp,lscale,rscale)
return c:IsSetCard(0xc4) and aux.PConditionFilter(c,e,tp,lscale,rscale)
end
function c29432356.pencon1(e,c,og)
if c==nil then return true end
local tp=c:GetControler()
local rpz=Duel.GetFieldCard(tp,LOCATION_PZONE,1)
if rpz==nil or c==rpz then return false end
local lscale=c:GetLeftScale()
local rscale=rpz:GetRightScale()
if lscale>rscale then lscale,rscale=rscale,lscale end
local loc=0
if Duel.GetLocationCount(tp,LOCATION_MZONE)>0 then loc=loc+LOCATION_HAND end
if Duel.GetLocationCountFromEx(tp)>0 then loc=loc+LOCATION_EXTRA end
if loc==0 then return false end
local g=nil
if og then
g=og:Filter(Card.IsLocation,nil,loc)
else
g=Duel.GetFieldGroup(tp,loc,0)
end
return g:IsExists(c29432356.penfilter,1,nil,e,tp,lscale,rscale)
end
function c29432356.penop1(e,tp,eg,ep,ev,re,r,rp,c,sg,og)
Duel.Hint(HINT_CARD,0,29432356)
local rpz=Duel.GetFieldCard(tp,LOCATION_PZONE,1)
local lscale=c:GetLeftScale()
local rscale=rpz:GetRightScale()
if lscale>rscale then lscale,rscale=rscale,lscale end
local ft1=Duel.GetLocationCount(tp,LOCATION_MZONE)
local ft2=Duel.GetLocationCountFromEx(tp)
local ft=Duel.GetUsableMZoneCount(tp)
if Duel.IsPlayerAffectedByEffect(tp,59822133) then
if ft1>0 then ft1=1 end
if ft2>0 then ft2=1 end
ft=1
end
local loc=0
if ft1>0 then loc=loc+LOCATION_HAND end
if ft2>0 then loc=loc+LOCATION_EXTRA end
local tg=nil
if og then
tg=og:Filter(Card.IsLocation,nil,loc):Filter(c29432356.penfilter,nil,e,tp,lscale,rscale)
else
tg=Duel.GetMatchingGroup(c29432356.penfilter,tp,loc,0,nil,e,tp,lscale,rscale)
end
ft1=math.min(ft1,tg:FilterCount(Card.IsLocation,nil,LOCATION_HAND))
ft2=math.min(ft2,tg:FilterCount(Card.IsLocation,nil,LOCATION_EXTRA))
local ect=c29724053 and Duel.IsPlayerAffectedByEffect(tp,29724053) and c29724053[tp]
if ect and ect<ft2 then ft2=ect end
while true do
local ct1=tg:FilterCount(Card.IsLocation,nil,LOCATION_HAND)
local ct2=tg:FilterCount(Card.IsLocation,nil,LOCATION_EXTRA)
local ct=ft
if ct1>ft1 then ct=math.min(ct,ft1) end
if ct2>ft2 then ct=math.min(ct,ft2) end
if ct<=0 then break end
if sg:GetCount()>0 and not Duel.SelectYesNo(tp,210) then ft=0 break end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=tg:Select(tp,1,ct,nil)
tg:Sub(g)
sg:Merge(g)
if g:GetCount()<ct then ft=0 break end
ft=ft-g:GetCount()
ft1=ft1-g:FilterCount(Card.IsLocation,nil,LOCATION_HAND)
ft2=ft2-g:FilterCount(Card.IsLocation,nil,LOCATION_EXTRA)
end
if ft>0 then
local tg1=tg:Filter(Card.IsLocation,nil,LOCATION_HAND)
local tg2=tg:Filter(Card.IsLocation,nil,LOCATION_EXTRA)
if ft1>0 and ft2==0 and tg1:GetCount()>0 and (sg:GetCount()==0 or Duel.SelectYesNo(tp,210)) then
local ct=math.min(ft1,ft)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=tg1:Select(tp,1,ct,nil)
sg:Merge(g)
end
if ft1==0 and ft2>0 and tg2:GetCount()>0 and (sg:GetCount()==0 or Duel.SelectYesNo(tp,210)) then
local ct=math.min(ft2,ft)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=tg2:Select(tp,1,ct,nil)
sg:Merge(g)
end
end
Duel.HintSelection(Group.FromCards(c))
Duel.HintSelection(Group.FromCards(rpz))
end
function c29432356.pencon2(e,c,og)
if c==nil then return true end
local tp=e:GetOwnerPlayer()
local rpz=Duel.GetFieldCard(1-tp,LOCATION_PZONE,1)
if rpz==nil or rpz:GetFieldID()~=c:GetFlagEffectLabel(31531170) then return false end
local lscale=c:GetLeftScale()
local rscale=rpz:GetRightScale()
if lscale>rscale then lscale,rscale=rscale,lscale end
local ft=Duel.GetLocationCountFromEx(tp)
if ft<=0 then return false end
if og then
return og:IsExists(c29432356.penfilter,1,nil,e,tp,lscale,rscale)
else
return Duel.IsExistingMatchingCard(c29432356.penfilter,tp,LOCATION_EXTRA,0,1,nil,e,tp,lscale,rscale)
end
end
function c29432356.penop2(e,tp,eg,ep,ev,re,r,rp,c,sg,og)
Duel.Hint(HINT_CARD,0,31531170)
Duel.Hint(HINT_CARD,0,29432356)
local tp=e:GetOwnerPlayer()
local rpz=Duel.GetFieldCard(1-tp,LOCATION_PZONE,1)
local lscale=c:GetLeftScale()
local rscale=rpz:GetRightScale()
if lscale>rscale then lscale,rscale=rscale,lscale end
local ft=Duel.GetLocationCountFromEx(tp)
if Duel.IsPlayerAffectedByEffect(tp,59822133) then ft=1 end
local ect=c29724053 and Duel.IsPlayerAffectedByEffect(tp,29724053) and c29724053[tp]
if ect~=nil then ft=math.min(ft,ect) end
if og then
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=og:FilterSelect(tp,c29432356.penfilter,1,ft,nil,e,tp,lscale,rscale)
sg:Merge(g)
else
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c29432356.penfilter,tp,LOCATION_EXTRA,0,1,ft,nil,e,tp,lscale,rscale)
sg:Merge(g)
end
Duel.HintSelection(Group.FromCards(c))
Duel.HintSelection(Group.FromCards(rpz))
end end
function c29432356.spcfilter(c,ft,tp) function c29432356.spcfilter(c,ft,tp)
return ft>0 or (c:IsControler(tp) and c:GetSequence()<5) return ft>0 or (c:IsControler(tp) and c:GetSequence()<5)
......
...@@ -533,6 +533,7 @@ EFFECT_ADD_LINK_ATTRIBUTE =356 --用作连接素材时的属性 ...@@ -533,6 +533,7 @@ EFFECT_ADD_LINK_ATTRIBUTE =356 --用作连接素材时的属性
EFFECT_ADD_LINK_RACE =357 --用作连接素材时的种族 EFFECT_ADD_LINK_RACE =357 --用作连接素材时的种族
EFFECT_EXTRA_LINK_MATERIAL =358 --手卡的连接素材 EFFECT_EXTRA_LINK_MATERIAL =358 --手卡的连接素材
EFFECT_QP_ACT_IN_SET_TURN =359 --速攻魔法可以在盖放的回合发动 EFFECT_QP_ACT_IN_SET_TURN =359 --速攻魔法可以在盖放的回合发动
EFFECT_EXTRA_PENDULUM_SUMMON =360 --extra pendulum summon
--下面是诱发效果的诱发事件、时点 (如果是TYPE_SINGLE则自己发生以下事件后触发,如果TYPE_FIELD则场上任何卡发生以下事件都触发) --下面是诱发效果的诱发事件、时点 (如果是TYPE_SINGLE则自己发生以下事件后触发,如果TYPE_FIELD则场上任何卡发生以下事件都触发)
EVENT_STARTUP =1000 --游戏开始时 EVENT_STARTUP =1000 --游戏开始时
......
...@@ -1500,7 +1500,18 @@ end ...@@ -1500,7 +1500,18 @@ end
function Auxiliary.PendulumReset(e,tp,eg,ep,ev,re,r,rp) function Auxiliary.PendulumReset(e,tp,eg,ep,ev,re,r,rp)
PENDULUM_CHECKLIST=0 PENDULUM_CHECKLIST=0
end end
function Auxiliary.PConditionFilter(c,e,tp,lscale,rscale) function Auxiliary.PConditionExtraFilterSpecific(c,e,tp,lscale,rscale,te)
if not te then return true end
local f=te:GetValue()
return not f or f(te,c,e,tp,lscale,rscale)
end
function Auxiliary.PConditionExtraFilter(c,e,tp,lscale,rscale,eset)
for _,te in ipairs(eset) do
if Auxiliary.PConditionExtraFilterSpecific(c,e,tp,lscale,rscale,te) then return true end
end
return false
end
function Auxiliary.PConditionFilter(c,e,tp,lscale,rscale,eset)
local lv=0 local lv=0
if c.pendulum_level then if c.pendulum_level then
lv=c.pendulum_level lv=c.pendulum_level
...@@ -1511,12 +1522,14 @@ function Auxiliary.PConditionFilter(c,e,tp,lscale,rscale) ...@@ -1511,12 +1522,14 @@ function Auxiliary.PConditionFilter(c,e,tp,lscale,rscale)
return (c:IsLocation(LOCATION_HAND) or (c:IsFaceup() and c:IsType(TYPE_PENDULUM))) return (c:IsLocation(LOCATION_HAND) or (c:IsFaceup() and c:IsType(TYPE_PENDULUM)))
and lv>lscale and lv<rscale and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_PENDULUM,tp,bool,bool) and lv>lscale and lv<rscale and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_PENDULUM,tp,bool,bool)
and not c:IsForbidden() and not c:IsForbidden()
and (PENDULUM_CHECKLIST&(0x1<<tp)==0 or Auxiliary.PConditionExtraFilter(c,e,tp,lscale,rscale,eset))
end end
function Auxiliary.PendCondition() function Auxiliary.PendCondition()
return function(e,c,og) return function(e,c,og)
if c==nil then return true end if c==nil then return true end
local tp=c:GetControler() local tp=c:GetControler()
if PENDULUM_CHECKLIST&(0x1<<tp)~=0 then return false end local eset={Duel.IsPlayerAffectedByEffect(tp,EFFECT_EXTRA_PENDULUM_SUMMON)}
if PENDULUM_CHECKLIST&(0x1<<tp)~=0 and #eset==0 then return false end
local rpz=Duel.GetFieldCard(tp,LOCATION_PZONE,1) local rpz=Duel.GetFieldCard(tp,LOCATION_PZONE,1)
if rpz==nil or c==rpz then return false end if rpz==nil or c==rpz then return false end
local lscale=c:GetLeftScale() local lscale=c:GetLeftScale()
...@@ -1532,7 +1545,7 @@ function Auxiliary.PendCondition() ...@@ -1532,7 +1545,7 @@ function Auxiliary.PendCondition()
else else
g=Duel.GetFieldGroup(tp,loc,0) g=Duel.GetFieldGroup(tp,loc,0)
end end
return g:IsExists(Auxiliary.PConditionFilter,1,nil,e,tp,lscale,rscale) return g:IsExists(Auxiliary.PConditionFilter,1,nil,e,tp,lscale,rscale,eset)
end end
end end
function Auxiliary.PendOperationCheck(g,tp) function Auxiliary.PendOperationCheck(g,tp)
...@@ -1556,16 +1569,45 @@ function Auxiliary.PendOperation() ...@@ -1556,16 +1569,45 @@ function Auxiliary.PendOperation()
local lscale=c:GetLeftScale() local lscale=c:GetLeftScale()
local rscale=rpz:GetRightScale() local rscale=rpz:GetRightScale()
if lscale>rscale then lscale,rscale=rscale,lscale end if lscale>rscale then lscale,rscale=rscale,lscale end
local eset={Duel.IsPlayerAffectedByEffect(tp,EFFECT_EXTRA_PENDULUM_SUMMON)}
local tg=nil local tg=nil
if og then if og then
tg=og:Filter(Card.IsLocation,nil,LOCATION_HAND+LOCATION_EXTRA):Filter(Auxiliary.PConditionFilter,nil,e,tp,lscale,rscale) tg=og:Filter(Card.IsLocation,nil,LOCATION_HAND+LOCATION_EXTRA):Filter(Auxiliary.PConditionFilter,nil,e,tp,lscale,rscale,eset)
else else
tg=Duel.GetMatchingGroup(Auxiliary.PConditionFilter,tp,LOCATION_HAND+LOCATION_EXTRA,0,nil,e,tp,lscale,rscale) tg=Duel.GetMatchingGroup(Auxiliary.PConditionFilter,tp,LOCATION_HAND+LOCATION_EXTRA,0,nil,e,tp,lscale,rscale,eset)
end
local ce=nil
local b1=PENDULUM_CHECKLIST&(0x1<<tp)==0
local b2=#eset>0
if b1 and b2 then
local options={1163}
for _,te in ipairs(eset) do
table.insert(options,te:GetDescription())
end
local op=Duel.SelectOption(tp,table.unpack(options))
if op>0 then
ce=eset[op]
end
elseif b2 and not b1 then
local options={}
for _,te in ipairs(eset) do
table.insert(options,te:GetDescription())
end
local op=Duel.SelectOption(tp,table.unpack(options))
ce=eset[op+1]
end
if ce then
tg=tg:Filter(Auxiliary.PConditionExtraFilterSpecific,nil,e,tp,lscale,rscale,ce)
end end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=tg:SelectSubGroup(tp,Auxiliary.PendOperationCheck,true,1,#tg,tp) local g=tg:SelectSubGroup(tp,Auxiliary.PendOperationCheck,true,1,#tg,tp)
if not g then return end if not g then return end
PENDULUM_CHECKLIST=PENDULUM_CHECKLIST|(0x1<<tp) if ce then
Duel.Hint(HINT_CARD,0,ce:GetOwner():GetOriginalCode())
ce:Reset()
else
PENDULUM_CHECKLIST=PENDULUM_CHECKLIST|(0x1<<tp)
end
sg:Merge(g) sg:Merge(g)
Duel.HintSelection(Group.FromCards(c)) Duel.HintSelection(Group.FromCards(c))
Duel.HintSelection(Group.FromCards(rpz)) Duel.HintSelection(Group.FromCards(rpz))
......
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