Commit 937e833a authored by VanillaSalt's avatar VanillaSalt

simple implementation of link summon

parent 42cfec6f
--デコード・トーカー
function c1861692.initial_effect(c)
aux.AddLinkProcedure(c,aux.FilterBoolFunction(Card.IsType,TYPE_EFFECT),2)
--atk
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e1:SetRange(LOCATION_MZONE)
e1:SetValue(c1861692.atkval)
c:RegisterEffect(e1)
--negate
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(1861692,0))
e2:SetCategory(CATEGORY_NEGATE+CATEGORY_DESTROY)
e2:SetType(EFFECT_TYPE_QUICK_O)
e2:SetCode(EVENT_CHAINING)
e2:SetProperty(EFFECT_FLAG_DAMAGE_STEP+EFFECT_FLAG_DAMAGE_CAL)
e2:SetRange(LOCATION_MZONE)
e2:SetCondition(c1861692.discon)
e2:SetCost(c1861692.discost)
e2:SetTarget(c1861692.distg)
e2:SetOperation(c1861692.disop)
c:RegisterEffect(e2)
end
function c1861692.adval(e,c)
return c:GetLinkedGroupCount()*500
end
function c1861692.discon(e,tp,eg,ep,ev,re,r,rp)
if rp==tp or e:GetHandler():IsStatus(STATUS_BATTLE_DESTROYED) then return false end
if not re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then return false end
local tg=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS)
return tg and tg:IsExists(Card.IsOnField,1,nil) and Duel.IsChainNegatable(ev)
end
function c1861692.cfilter(c,g)
return g:IsContains(c) and not c:IsStatus(STATUS_BATTLE_DESTROYED)
end
function c1861692.discost(e,tp,eg,ep,ev,re,r,rp,chk)
local lg=e:GetHandler():GetLinkedGroup()
if chk==0 then return Duel.CheckReleaseGroup(tp,c1861692.cfilter,1,nil,lg) end
local g=Duel.SelectReleaseGroup(tp,c1861692.cfilter,1,1,nil,lg)
Duel.Release(g,REASON_COST)
end
function c1861692.distg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetOperationInfo(0,CATEGORY_NEGATE,eg,1,0,0)
if re:GetHandler():IsDestructable() and re:GetHandler():IsRelateToEffect(re) then
Duel.SetOperationInfo(0,CATEGORY_DESTROY,eg,1,0,0)
end
end
function c1861692.disop(e,tp,eg,ep,ev,re,r,rp)
if Duel.NegateActivation(ev) and re:GetHandler():IsRelateToEffect(re) then
Duel.Destroy(eg,REASON_EFFECT)
end
end
...@@ -115,7 +115,7 @@ REASON_XYZ =0x200000 --用於超量召喚 ...@@ -115,7 +115,7 @@ REASON_XYZ =0x200000 --用於超量召喚
REASON_REPLACE =0x1000000 --代替 REASON_REPLACE =0x1000000 --代替
REASON_DRAW =0x2000000 --抽卡 REASON_DRAW =0x2000000 --抽卡
REASON_REDIRECT =0x4000000 --改变去向(大宇宙,带菌等) REASON_REDIRECT =0x4000000 --改变去向(大宇宙,带菌等)
REASON_REVEAL =0x8000000 --翻开卡组(森罗) REASON_LINK =0x8000000 --
--Location Reason --Location Reason
LOCATION_REASON_TOFIELD =0x1 --Duel.GetLocationCount()預設值,凱薩競技場 LOCATION_REASON_TOFIELD =0x1 --Duel.GetLocationCount()預設值,凱薩競技場
LOCATION_REASON_CONTROL =0x2 --Card.IsControlerCanBeChanged()使用 LOCATION_REASON_CONTROL =0x2 --Card.IsControlerCanBeChanged()使用
...@@ -130,6 +130,7 @@ SUMMON_TYPE_RITUAL =0x45000000 --仪式召唤 ...@@ -130,6 +130,7 @@ SUMMON_TYPE_RITUAL =0x45000000 --仪式召唤
SUMMON_TYPE_SYNCHRO =0x46000000 --同调召唤 SUMMON_TYPE_SYNCHRO =0x46000000 --同调召唤
SUMMON_TYPE_XYZ =0x49000000 --超量召唤 SUMMON_TYPE_XYZ =0x49000000 --超量召唤
SUMMON_TYPE_PENDULUM =0x4a000000 --灵摆召唤 SUMMON_TYPE_PENDULUM =0x4a000000 --灵摆召唤
SUMMON_TYPE_LINK =0x4c000000 --
--Status --卡片当前状态 --Status --卡片当前状态
STATUS_DISABLED =0x0001 --效果被无效 STATUS_DISABLED =0x0001 --效果被无效
STATUS_TO_ENABLE =0x0002 --将变成有效 STATUS_TO_ENABLE =0x0002 --将变成有效
......
...@@ -1619,6 +1619,44 @@ function Auxiliary.PendOperation() ...@@ -1619,6 +1619,44 @@ function Auxiliary.PendOperation()
Duel.HintSelection(Group.FromCards(rpz)) Duel.HintSelection(Group.FromCards(rpz))
end end
end end
--Link Summon
function Auxiliary.AddLinkProcedure(c,f,ct)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE+EFFECT_FLAG_IGNORE_IMMUNE)
e1:SetRange(LOCATION_EXTRA)
e1:SetTargetRange(POS_FACEUP_ATTACK,0)
e1:SetCondition(Auxiliary.LinkCondition(f,ct,99))
e1:SetOperation(Auxiliary.LinkOperation(f,ct,99))
e1:SetValue(SUMMON_TYPE_LINK)
c:RegisterEffect(e1)
end
function Auxiliary.LConditionFilter(c,f)
return c:IsFaceup() and (not f or f(c))
end
function Auxiliary.GetLinkCount(c)
if c:IsType(TYPE_LINK) and c:GetLink()>1 then
return 1+0x10000*c:GetLink()
else return 1 end
end
function Auxiliary.LinkCondition(f,minc,maxc)
return function(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(Auxiliary.LConditionFilter,tp,LOCATION_MZONE,0,nil,f)
return mg:CheckWithSumEqual(Auxiliary.GetLinkCount,c:GetLink(),minc,maxc)
end
end
function Auxiliary.LinkOperation(f,minc,maxc)
return function(e,tp,eg,ep,ev,re,r,rp,c)
local mg=Duel.GetMatchingGroup(Auxiliary.LConditionFilter,tp,LOCATION_MZONE,0,nil,f)
local g=mg:SelectWithSumEqual(tp,Auxiliary.GetLinkCount,c:GetLink(),minc,maxc)
c:SetMaterial(g)
Duel.SendtoGrave(g,REASON_MATERIAL+REASON_LINK)
end
end
function Auxiliary.IsMaterialListCode(c,code) function Auxiliary.IsMaterialListCode(c,code)
if not c.material then return false end if not c.material then return false end
for i,mcode in ipairs(c.material) do for i,mcode in ipairs(c.material) do
......
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