Commit d8c1c36b authored by whenmo's avatar whenmo Committed by GitHub

Update VgD.Lua

parent bdb09189
--VgD库 --VgD库
VgD = {} VgD = {}
vgd = VgD vgd, vgf = VgD, VgF
--骑升 ---初始化卡片,使卡片具有基本的功能。
---@param c Card 要初始化的卡
function vgd.VgCard(c)
VgD.Rule(c)
VgD.RideUp(c)
VgD.CardTrigger(c)
if c:IsType(TYPE_MONSTER) then
VgD.CallToR(c)
VgD.MonsterBattle(c)
end
end
---使卡片遵守VG的规则,已包含在 vgd.VgCard(c) 内
---@param c Card 要注册规则的卡
function VgD.Rule(c)
local e1 = Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_PHASE + PHASE_DRAW)
e1:SetRange(LOCATION_ALL)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetCountLimit(1, VgID + 2)
e1:SetCondition(VgD.RuelDrawCondition)
e1:SetOperation(VgD.RuelDrawOperation)
c:RegisterEffect(e1)
local e2 = Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_BATTLED)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetRange(LOCATION_MZONE)
e2:SetOperation(VgD.ResetOperation)
c:RegisterEffect(e2)
local e3 = Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
e3:SetCode(EVENT_PHASE_START + PHASE_STANDBY)
e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e3:SetRange(LOCATION_ALL)
e3:SetCountLimit(1, VgID + 3)
e3:SetCondition(VgF.RuleCardCondtion)
e3:SetOperation(VgD.EventRideStart)
c:RegisterEffect(e3)
local e10 = Effect.CreateEffect(c)
e10:SetType(EFFECT_TYPE_FIELD)
e10:SetCode(EFFECT_HAND_LIMIT)
e10:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_CANNOT_DISABLE)
e10:SetRange(LOCATION_ALL)
e10:SetTargetRange(1, 0)
e10:SetValue(100)
e10:SetCondition(VgF.RuleCardCondtion)
c:RegisterEffect(e10)
local e11 = Effect.CreateEffect(c)
e11:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
e11:SetCode(EVENT_ADJUST)
e11:SetRange(LOCATION_ALL)
e11:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e11:SetCondition(VgF.RuleCardCondtion)
e11:SetOperation(VgD.RuleWin)
c:RegisterEffect(e11)
local e12 = Effect.CreateEffect(c)
e12:SetType(EFFECT_TYPE_FIELD)
e12:SetCode(EFFECT_SKIP_M2)
e12:SetRange(LOCATION_ALL)
e12:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_CANNOT_DISABLE)
e12:SetTargetRange(1, 0)
c:RegisterEffect(e12)
local e13 = e12:Clone()
e13:SetCode(EFFECT_CANNOT_SUMMON)
c:RegisterEffect(e13)
local e14 = e12:Clone()
e14:SetCode(EFFECT_CANNOT_MSET)
c:RegisterEffect(e14)
local e15 = e12:Clone()
e15:SetCode(EFFECT_CANNOT_SSET)
c:RegisterEffect(e15)
local e16 = Effect.CreateEffect(c)
e16:SetType(EFFECT_TYPE_FIELD)
e16:SetCode(EFFECT_QP_ACT_IN_NTPHAND)
e16:SetRange(LOCATION_ALL)
e16:SetCondition(VgF.RuleCardCondtion)
e16:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e16:SetTargetRange(LOCATION_HAND, 0)
c:RegisterEffect(e16)
end
function VgD.EventRideStart(e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler()
if Duel.GetTurnPlayer() == tp then
Duel.RaiseEvent(c, EVENT_CUSTOM + EVENT_RIDE_START, e, 0, tp, tp, 0)
end
end
function VgD.RuleWin(e, tp, eg, ep, ev, re, r, rp)
if Duel.GetCurrentChain() > 0 then return end
local g1 = Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0)
local g2 = Duel.GetFieldGroupCount(tp, 0, LOCATION_DECK)
if g1 == 0 and g2 == 0 then
Duel.Win(PLAYER_NONE, 0x2)
elseif g1 == 0 then
Duel.Win(1 - tp, 0x2)
elseif g2 == 0 then
Duel.Win(tp, 0x2)
end
end
function VgD.RuelDrawCondition(e, tp, eg, ep, ev, re, r, rp)
return VgF.RuleTurnCondtion(e) and VgF.RuleCardCondtion(e)
end
function VgD.RuelDrawOperation(e, tp, eg, ep, ev, re, r, rp)
local ct = Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0)
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK)
local g = Duel.GetFieldGroup(tp, LOCATION_HAND, 0):Select(tp, 0, ct, nil)
if g:GetCount() > 0 then
ct = Duel.SendtoDeck(g, tp, 1, REASON_PHASEDRAW)
Duel.Draw(tp, ct, REASON_PHASEDRAW)
Duel.ShuffleDeck(tp)
end
if Duel.GetTurnPlayer() == tp then
Duel.Draw(tp, 1, REASON_PHASEDRAW)
end
end
function VgD.ResetOperation(e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler()
if c:GetFlagEffect(FLAG_SUPPORT) > 0 then c:ResetFlagEffect(FLAG_SUPPORT) end
if c:GetFlagEffect(FLAG_SUPPORTED) > 0 then c:ResetFlagEffect(FLAG_SUPPORTED) end
if c:GetFlagEffect(FLAG_DEFENSE_ENTIRELY) > 0 then c:ResetFlagEffect(FLAG_DEFENSE_ENTIRELY) end
end
---使卡片具有骑升的功能,已包含在 vgd.VgCard(c) 内
---@param c Card 要注册骑升功能的卡
function VgD.RideUp(c) function VgD.RideUp(c)
local e1 = Effect.CreateEffect(c) local e1 = Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS) e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
...@@ -176,141 +300,253 @@ function VgD.RideZeroOperation(e, tp, eg, ep, ev, re, r, rp) ...@@ -176,141 +300,253 @@ function VgD.RideZeroOperation(e, tp, eg, ep, ev, re, r, rp)
end end
VgF.Sendto(LOCATION_MZONE, g, SUMMON_TYPE_RIDE, tp, 0x20) VgF.Sendto(LOCATION_MZONE, g, SUMMON_TYPE_RIDE, tp, 0x20)
end end
--Call到R位
function VgD.CallToR(c) ---使卡片具有触发卡的功能,已包含在 vgd.VgCard(c) 内
---@param c Card 要注册触发功能的卡
function VgD.CardTrigger(c)
local e1 = Effect.CreateEffect(c) local e1 = Effect.CreateEffect(c)
e1:SetDescription(1152) e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
e1:SetType(EFFECT_TYPE_FIELD) e1:SetProperty(EFFECT_FLAG_DELAY + EFFECT_CANNOT_DISABLE + EFFECT_FLAG_DAMAGE_STEP)
e1:SetCode(EFFECT_SPSUMMON_PROC) e1:SetCode(EVENT_MOVE)
e1:SetRange(LOCATION_HAND) e1:SetCondition(VgD.CardTriggerCondtion(0))
e1:SetProperty(EFFECT_FLAG_SPSUM_PARAM) e1:SetOperation(VgD.CardTriggerOperation(0))
e1:SetTargetRange(POS_FACEUP_ATTACK, 0)
e1:SetCondition(VgD.CallCondition)
e1:SetOperation(VgD.CallOperation)
c:RegisterEffect(e1) c:RegisterEffect(e1)
local e2 = e1:Clone()
e2:SetCondition(VgD.CardTriggerCondtion(1))
e2:SetOperation(VgD.CardTriggerOperation(1))
c:RegisterEffect(e2)
end end
function VgD.CallCondition(e, c) function VgD.CardTriggerCondtion(chkcon)
if c == nil then return true end return function (e, tp, eg, ep, ev, re, r, rp)
local tp = e:GetHandlerPlayer()
if VgF.GetAvailableLocation(tp) <= 0 then return end
return VgF.LvCondition(e)
end
function VgD.CallFilter(c, tp, zone)
return VgF.RMonsterFilter(c) and zone == VgF.SequenceToGlobal(tp, c:GetLocation(), c:GetSequence())
end
function VgD.CallOperation(e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler() local c = e:GetHandler()
local z = bit.bnot(VgF.GetAvailableLocation(tp)) local cp = tp
local rg = Duel.GetMatchingGroup(Card.IsPosition, tp, LOCATION_MZONE, 0, nil, POS_FACEDOWN_ATTACK) if chkcon == 0 then
for tc in VgF.Next(rg) do cp = 1 - tp
local szone = VgF.SequenceToGlobal(tp, tc:GetLocation(), tc:GetSequence())
z = bit.bor(z, szone)
end end
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CallZONE) return Duel.GetTurnPlayer() == cp and c:IsLocation(LOCATION_TRIGGER)
local zone = Duel.SelectField(tp, 1, LOCATION_MZONE, 0, z)
if VgF.IsExistingMatchingCard(VgD.CallFilter, tp, LOCATION_MZONE, 0, 1, nil, tp, zone) then
local tc = Duel.GetMatchingGroup(VgD.CallFilter, tp, LOCATION_MZONE, 0, nil, tp, zone):GetFirst()
VgF.Sendto(LOCATION_DROP, tc, REASON_COST)
end end
e:SetValue(function () return SUMMON_VALUE_CALL, zone end)
end
--超限舞装
function VgD.OverDress(c, f)
local e2 = Effect.CreateEffect(c)
e2:SetDescription(VgF.Stringid(VgID, 9))
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetCode(EFFECT_SPSUMMON_PROC)
e2:SetRange(LOCATION_HAND)
e2:SetProperty(EFFECT_FLAG_SPSUM_PARAM)
e2:SetTargetRange(POS_FACEUP_ATTACK, 0)
e2:SetCondition(VgD.OverDressCondition(f))
e2:SetOperation(VgD.OverDressOperation(f))
c:RegisterEffect(e2)
local e3 = Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
e3:SetCode(EVENT_SPSUMMON_SUCCESS)
e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e3:SetOperation(VgD.OverDressSum)
c:RegisterEffect(e3)
end end
function VgD.OverDressCondition(f) function VgD.CardTriggerOperation(chkop, f)
return function (e, c) return function (e, tp, eg, ep, ev, re, r, rp)
if c == nil then return true end local c = e:GetHandler()
local tp = e:GetHandlerPlayer() if c:IsRace(TRIGGER_CRITICAL_STRIKE) then
return VgF.LvCondition(e) and VgF.IsExistingMatchingCard(VgD.OverDressFilter, tp, LOCATION_MZONE, 0, 1, nil, f) local g1 = VgF.SelectMatchingCard(HINTMSG_CRITICAL_STRIKE, e, tp, nil, tp, LOCATION_MZONE, 0, 1, 1, nil)
VgF.StarUp(c, g1, 1, nil)
local g2 = VgF.SelectMatchingCard(HINTMSG_ATKUP, e, tp, nil, tp, LOCATION_MZONE, 0, 1, 1, nil)
VgF.AtkUp(c, g2, 10000, nil)
elseif c:IsRace(TRIGGER_DRAW) then
local g = VgF.SelectMatchingCard(HINTMSG_ATKUP, e, tp, nil, tp, LOCATION_MZONE, 0, 1, 1, nil)
VgF.AtkUp(c, g, 10000, nil)
Duel.Draw(tp, 1, REASON_TRIGGER)
elseif c:IsRace(TRIGGER_HEAL) then
local g = VgF.SelectMatchingCard(HINTMSG_ATKUP, e, tp, nil, tp, LOCATION_MZONE, 0, 1, 1, nil)
VgF.AtkUp(c, g, 10000, nil)
if Duel.GetMatchingGroupCount(nil, tp, LOCATION_DAMAGE, 0, nil) >= Duel.GetMatchingGroupCount(nil, tp, 0, LOCATION_DAMAGE, nil) then
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODROP)
local tc = Duel.SelectMatchingCard(tp, nil, tp, LOCATION_DAMAGE, 0, 1, 1, nil):GetFirst()
if tc then
VgF.Sendto(LOCATION_DROP, tc, REASON_TRIGGER)
Duel.Recover(tp, 1, REASON_RULE)
end end
end
function VgD.OverDressFilter(c, f, tp, zone)
if zone and zone > 0 then
if zone ~= VgF.SequenceToGlobal(tp, c:GetLocation(), c:GetSequence()) then return false end
end end
return ((VgF.GetValueType(f) == "function" and f(c)) or (VgF.GetValueType(f) == "number" and c:IsCode(f))) and c:IsFaceup() elseif c:IsRace(TRIGGER_ADVANCE) then
end local g = Duel.GetMatchingGroup(VgF.IsSequence, tp, LOCATION_MZONE, 0, nil, 0, 4, 5)
function VgD.OverDressOperation(f) VgF.AtkUp(c, g, 10000, nil)
return function(e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler()
local g = Duel.GetMatchingGroup(VgD.OverDressFilter, tp, LOCATION_MZONE, 0, nil, f, tp)
local szone
local zone = 0x00
for tc in VgF.Next(g) do
zone = bit.bor(zone, VgF.SequenceToGlobal(tp, tc:GetLocation(), tc:GetSequence()))
end end
if zone == 0x00 then return end if chkop == 0 then
zone = bit.bnot(zone) if c:IsRace(TRIGGER_SUPER) then
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CallZONE) local ops = {}
szone = Duel.SelectField(tp, 1, LOCATION_MZONE, 0, zone) local sel = {}
e:SetValue(function () return SUMMON_VALUE_CALL + SUMMON_VALUE_OverDress, szone end) if c:IsRelateToEffect(e) then
local tc = Duel.GetMatchingGroup(VgD.OverDressFilter, tp, LOCATION_MZONE, 0, nil, f, tp, szone):GetFirst() table.insert(ops, VgF.Stringid(VgID + 5, 3))
if not tc then return end table.insert(sel, function ()
local mg = tc:GetOverlayGroup() VgF.Sendto(LOCATION_EXILE, c, REASON_TRIGGER)
if mg:GetCount() ~= 0 then end)
VgF.Sendto(LOCATION_OVERLAY, mg, c)
end end
c:SetMaterial(Group.FromCards(tc)) if true then
VgF.Sendto(LOCATION_OVERLAY, Group.FromCards(tc), c) table.insert(ops, VgF.Stringid(VgID + 5, 4))
table.insert(sel, function ()
Duel.Draw(tp, 1, REASON_TRIGGER)
end)
end end
end if VgF.IsExistingMatchingCard(nil, tp, LOCATION_MZONE, 0, 1, nil) then
function VgD.OverDressSum(e, tp, eg, ep, ev, re, r, rp) table.insert(ops, VgF.Stringid(VgID + 5, 5))
local c = e:GetHandler() table.insert(sel, function ()
c:RegisterFlagEffect(FLAG_CONDITION, RESET_EVENT + RESETS_STANDARD, EFFECT_FLAG_CLIENT_HINT, 1, 201, VgF.Stringid(10101006, 0)) local g = VgF.SelectMatchingCard(HINTMSG_ATKUP, e, tp, nil, tp, LOCATION_MZONE, 0, 1, 1, nil)
end VgF.AtkUp(c, g, 100000000, nil)
end)
--交织超限舞装 end
function VgD.XOverDress(c, f) if VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, 0) then
table.insert(ops, VgF.Stringid(VgID + 5, 5))
end table.insert(sel, function ()
VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, 1)
---舞装加身-「code」(在游戏中,也当做与指定的卡同名的卡使用。) end)
function VgD.DressUp(c, code) end
local e = Effect.CreateEffect(c) while #ops > 0 do
e:SetType(EFFECT_TYPE_SINGLE) local i = Duel.SelectOption(tp, table.unpack(ops)) + 1
e:SetCode(EFFECT_ADD_CODE) sel[i]()
e:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE) table.remove(ops, i)
e:SetValue(code) table.remove(sel, i)
c:RegisterEffect(e) end
end else
if VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, 0) then VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, 1) end
--战斗阶段 if c:IsRelateToEffect(e) then
function VgD.MonsterBattle(c) VgF.Sendto(LOCATION_DAMAGE, c, tp, POS_FACEUP_ATTACK, REASON_EFFECT)
--攻击转守备 Duel.Damage(tp, 1, REASON_TRIGGER)
local e1 = Effect.CreateEffect(c) end
e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS) end
e1:SetCode(EVENT_ATTACK_ANNOUNCE) local rc = VgF.GetVMonster(tp)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) local bc = rc:GetBattleTarget()
e1:SetOperation(VgD.MonsterPosDefenseOperation) local label = bc:GetFlagEffectLabel(FLAG_DAMAGE_TRIGGER)
c:RegisterEffect(e1) if not label then return end
--回合开始转攻 if label > 0 then
local e2 = Effect.CreateEffect(c) label = label - 1
e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS) Duel.RaiseEvent(c, EVENT_CUSTOM + EVENT_TRIGGER, e, 0, tp, tp, 0)
e2:SetCode(EVENT_PREDRAW) bc:ResetFlagEffect(FLAG_DAMAGE_TRIGGER)
e2:SetRange(LOCATION_ALL) bc:RegisterFlagEffect(FLAG_DAMAGE_TRIGGER, RESET_EVENT + RESETS_STANDARD, 0, 1, label)
e2:SetCountLimit(1, VgID + 4) elseif label == 0 then
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) bc:ResetFlagEffect(FLAG_DAMAGE_TRIGGER)
e2:SetCondition(VgF.RuleCardCondtion) Duel.RaiseEvent(rc, EVENT_CUSTOM + EVENT_DAMAGE_TRIGGER, e, 0, tp, tp, 0)
e2:SetOperation(VgD.MonsterPosAttackOperation) end
c:RegisterEffect(e2) else
--扣血 if c:IsRace(TRIGGER_SUPER) then
local ops = {}
local sel = {}
if c:IsRelateToEffect(e) then
table.insert(ops, VgF.Stringid(VgID + 5, 3))
table.insert(sel, function ()
VgF.Sendto(LOCATION_EXILE, c, REASON_TRIGGER)
end)
end
if true then
table.insert(ops, VgF.Stringid(VgID + 5, 4))
table.insert(sel, function ()
Duel.Draw(tp, 1, REASON_TRIGGER)
end)
end
if VgF.IsExistingMatchingCard(nil, tp, LOCATION_MZONE, 0, 1, nil) then
table.insert(ops, VgF.Stringid(VgID + 5, 5))
table.insert(sel, function ()
local g = VgF.SelectMatchingCard(HINTMSG_ATKUP, e, tp, nil, tp, LOCATION_MZONE, 0, 1, 1, nil)
VgF.AtkUp(c, g, 100000000, nil)
end)
end
if VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, 0) then
table.insert(ops, VgF.Stringid(VgID + 5, 6))
table.insert(sel, function ()
return VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, 1)
end)
end
while #ops > 0 do
local i = Duel.SelectOption(tp, table.unpack(ops)) + 1
sel[i]()
table.remove(ops, i)
table.remove(sel, i)
end
else
if VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, 0) then VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, 1) end
if c:IsRelateToEffect(e) then VgF.Sendto(LOCATION_HAND, c, nil, REASON_TRIGGER) end
end
local rc = VgF.GetVMonster(tp)
local label = rc:GetFlagEffectLabel(FLAG_ATTACK_TRIGGER)
if not label then return end
if label > 1 then
label = label - 1
Duel.RaiseEvent(c, EVENT_CUSTOM + EVENT_TRIGGER, e, 0, tp, tp, 0)
rc:ResetFlagEffect(FLAG_ATTACK_TRIGGER)
rc:RegisterFlagEffect(FLAG_ATTACK_TRIGGER, RESET_EVENT + RESETS_STANDARD, 0, 1, label)
elseif label == 1 then
rc:ResetFlagEffect(FLAG_ATTACK_TRIGGER)
end
end
end
end
function VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, chk)
local effect_when_trigger = c.effect_when_trigger
local cost, con, tg = true, true, true
if not effect_when_trigger or #effect_when_trigger == 0 then return end
if (VgF.GetValueType(effect_when_trigger[5]) == "boolean" and not effect_when_trigger[5]) or (VgF.GetValueType(effect_when_trigger[5]) ~= "boolean" and Duel.GetTurnPlayer() ~= c:GetControler()) then return false end
if VgF.GetValueType(effect_when_trigger[2]) == "function" then cost = effect_when_trigger[2](e, tp, eg, ep, ev, re, r, rp, 0) end
if VgF.GetValueType(effect_when_trigger[3]) == "function" then con = effect_when_trigger[3](e, tp, eg, ep, ev, re, r, rp) end
if VgF.GetValueType(effect_when_trigger[4]) == "function" then tg = effect_when_trigger[4](e, tp, eg, ep, ev, re, r, rp, 0) end
if VgF.GetValueType(effect_when_trigger[1]) == "function" and cost and con and tg then
if chk == 0 then return true end
local activate_chk = true
if VgF.GetValueType(effect_when_trigger[2]) == "function" then activate_chk = Duel.SelectYesNo(tp, VgF.Stringid(VgID, 15)) end
if activate_chk then
Duel.HintSelection(Group.FromCards(c))
local _, m = c:GetOriginalCode()
Duel.Hint(HINT_CARD, 0, m)
if VgF.GetValueType(effect_when_trigger[2]) == "function" then effect_when_trigger[2](e, tp, eg, ep, ev, re, r, rp, 1) end
if VgF.GetValueType(effect_when_trigger[4]) == "function" then effect_when_trigger[4](e, tp, eg, ep, ev, re, r, rp, 1) end
effect_when_trigger[1](e, tp, eg, ep, ev, re, r, rp)
end
end
return false
end
---使卡片具有Call到R位的功能,已包含在 vgd.VgCard(c) 内
---@param c Card 要注册Call到R位功能的卡
function VgD.CallToR(c)
local e1 = Effect.CreateEffect(c)
e1:SetDescription(1152)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetRange(LOCATION_HAND)
e1:SetProperty(EFFECT_FLAG_SPSUM_PARAM)
e1:SetTargetRange(POS_FACEUP_ATTACK, 0)
e1:SetCondition(VgD.CallCondition)
e1:SetOperation(VgD.CallOperation)
c:RegisterEffect(e1)
end
function VgD.CallCondition(e, c)
if c == nil then return true end
local tp = e:GetHandlerPlayer()
if VgF.GetAvailableLocation(tp) <= 0 then return end
return VgF.LvCondition(e)
end
function VgD.CallFilter(c, tp, zone)
return VgF.RMonsterFilter(c) and zone == VgF.SequenceToGlobal(tp, c:GetLocation(), c:GetSequence())
end
function VgD.CallOperation(e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler()
local z = bit.bnot(VgF.GetAvailableLocation(tp))
local rg = Duel.GetMatchingGroup(Card.IsPosition, tp, LOCATION_MZONE, 0, nil, POS_FACEDOWN_ATTACK)
for tc in VgF.Next(rg) do
local szone = VgF.SequenceToGlobal(tp, tc:GetLocation(), tc:GetSequence())
z = bit.bor(z, szone)
end
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CallZONE)
local zone = Duel.SelectField(tp, 1, LOCATION_MZONE, 0, z)
if VgF.IsExistingMatchingCard(VgD.CallFilter, tp, LOCATION_MZONE, 0, 1, nil, tp, zone) then
local tc = Duel.GetMatchingGroup(VgD.CallFilter, tp, LOCATION_MZONE, 0, nil, tp, zone):GetFirst()
VgF.Sendto(LOCATION_DROP, tc, REASON_COST)
end
e:SetValue(function () return SUMMON_VALUE_CALL, zone end)
end
---使卡片遵守VG的战斗规则,已包含在 vgd.VgCard(c) 内
---@param c Card 要注册战斗规则的卡
function VgD.MonsterBattle(c)
--攻击转守备
local e1 = Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_ATTACK_ANNOUNCE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetOperation(VgD.MonsterPosDefenseOperation)
c:RegisterEffect(e1)
--回合开始转攻
local e2 = Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_PREDRAW)
e2:SetRange(LOCATION_ALL)
e2:SetCountLimit(1, VgID + 4)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetCondition(VgF.RuleCardCondtion)
e2:SetOperation(VgD.MonsterPosAttackOperation)
c:RegisterEffect(e2)
--扣血
local e3 = Effect.CreateEffect(c) local e3 = Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F) e3:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
e3:SetCode(EVENT_BATTLED) e3:SetCode(EVENT_BATTLED)
...@@ -539,377 +775,139 @@ function VgD.MonsterCannotBeAttackedCondition(e, c) ...@@ -539,377 +775,139 @@ function VgD.MonsterCannotBeAttackedCondition(e, c)
return VgF.IsSequence(e:GetHandler(), 1, 2, 3) return VgF.IsSequence(e:GetHandler(), 1, 2, 3)
end end
--送去g区 --起自永以外关键字----------------------------------------------------------------------------------------
function vgd.CardToG(c, m, cost, op, con)
local cm = _G["c"..m]
if not cm.is_has_trigger then cm.is_has_trigger = true end
local type = EFFECT_TYPE_TRIGGER_F
if VgF.GetValueType(cost) == "function" then type = EFFECT_TYPE_TRIGGER_O end
local e1 = Effect.CreateEffect(c)
e1:SetDescription(VgF.Stringid(VgID, 2))
e1:SetType(EFFECT_TYPE_SINGLE + type)
e1:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_DAMAGE_STEP)
e1:SetCode(EVENT_MOVE)
if VgF.GetValueType(con) == "function" then e1:SetCondition(con) end
if VgF.GetValueType(cost) == "function" then e1:SetCost(cost) end
e1:SetCondition(VgD.CardToGCondition)
if VgF.GetValueType(op) ~= "function" then e1:SetOperation(VgD.CardToGOperation) else e1:SetOperation(op) end
c:RegisterEffect(e1)
end
function VgD.CardToGCondition(e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler()
return c:IsLocation(LOCATION_GZONE) and Duel.GetAttackTarget()
end
function VgD.CardToGOperation(e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler()
local tc = Duel.GetAttackTarget()
if vgf.RMonsterFilter(tc) then
local e1 = Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e1:SetRange(LOCATION_MZONE)
e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
e1:SetReset(RESET_EVENT + RESETS_STANDARD)
e1:SetValue(1)
tc:RegisterEffect(e1)
vgf.EffectReset(c, e1, EVENT_BATTLED)
elseif vgf.VMonsterFilter(tc) then
tc:RegisterFlagEffect(FLAG_DEFENSE_ENTIRELY, RESET_EVENT + RESETS_STANDARD, 0, 1)
end
end
--判定
function VgD.CardTrigger(c)
local e1 = Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_TRIGGER_F)
e1:SetProperty(EFFECT_FLAG_DELAY + EFFECT_CANNOT_DISABLE + EFFECT_FLAG_DAMAGE_STEP)
e1:SetCode(EVENT_MOVE)
e1:SetCondition(VgD.CardTriggerCondtion(0))
e1:SetOperation(VgD.CardTriggerOperation(0))
c:RegisterEffect(e1)
local e2 = e1:Clone()
e2:SetCondition(VgD.CardTriggerCondtion(1))
e2:SetOperation(VgD.CardTriggerOperation(1))
c:RegisterEffect(e2)
end
function VgD.CardTriggerCondtion(chkcon)
return function (e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler()
local cp = tp
if chkcon == 0 then
cp = 1 - tp
end
return Duel.GetTurnPlayer() == cp and c:IsLocation(LOCATION_TRIGGER)
end
end
function VgD.CardTriggerOperation(chkop, f)
return function (e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler()
if c:IsRace(TRIGGER_CRITICAL_STRIKE) then
local g1 = VgF.SelectMatchingCard(HINTMSG_CRITICAL_STRIKE, e, tp, nil, tp, LOCATION_MZONE, 0, 1, 1, nil)
VgF.StarUp(c, g1, 1, nil)
local g2 = VgF.SelectMatchingCard(HINTMSG_ATKUP, e, tp, nil, tp, LOCATION_MZONE, 0, 1, 1, nil)
VgF.AtkUp(c, g2, 10000, nil)
elseif c:IsRace(TRIGGER_DRAW) then
local g = VgF.SelectMatchingCard(HINTMSG_ATKUP, e, tp, nil, tp, LOCATION_MZONE, 0, 1, 1, nil)
VgF.AtkUp(c, g, 10000, nil)
Duel.Draw(tp, 1, REASON_TRIGGER)
elseif c:IsRace(TRIGGER_HEAL) then
local g = VgF.SelectMatchingCard(HINTMSG_ATKUP, e, tp, nil, tp, LOCATION_MZONE, 0, 1, 1, nil)
VgF.AtkUp(c, g, 10000, nil)
if Duel.GetMatchingGroupCount(nil, tp, LOCATION_DAMAGE, 0, nil) >= Duel.GetMatchingGroupCount(nil, tp, 0, LOCATION_DAMAGE, nil) then
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODROP)
local tc = Duel.SelectMatchingCard(tp, nil, tp, LOCATION_DAMAGE, 0, 1, 1, nil):GetFirst()
if tc then
VgF.Sendto(LOCATION_DROP, tc, REASON_TRIGGER)
Duel.Recover(tp, 1, REASON_RULE)
end
end
elseif c:IsRace(TRIGGER_ADVANCE) then
local g = Duel.GetMatchingGroup(VgF.IsSequence, tp, LOCATION_MZONE, 0, nil, 0, 4, 5)
VgF.AtkUp(c, g, 10000, nil)
end
if chkop == 0 then
if c:IsRace(TRIGGER_SUPER) then
local ops = {}
local sel = {}
if c:IsRelateToEffect(e) then
table.insert(ops, VgF.Stringid(VgID + 5, 3))
table.insert(sel, function ()
VgF.Sendto(LOCATION_EXILE, c, REASON_TRIGGER)
end)
end
if true then
table.insert(ops, VgF.Stringid(VgID + 5, 4))
table.insert(sel, function ()
Duel.Draw(tp, 1, REASON_TRIGGER)
end)
end
if VgF.IsExistingMatchingCard(nil, tp, LOCATION_MZONE, 0, 1, nil) then
table.insert(ops, VgF.Stringid(VgID + 5, 5))
table.insert(sel, function ()
local g = VgF.SelectMatchingCard(HINTMSG_ATKUP, e, tp, nil, tp, LOCATION_MZONE, 0, 1, 1, nil)
VgF.AtkUp(c, g, 100000000, nil)
end)
end
if VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, 0) then
table.insert(ops, VgF.Stringid(VgID + 5, 5))
table.insert(sel, function ()
VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, 1)
end)
end
while #ops > 0 do
local i = Duel.SelectOption(tp, table.unpack(ops)) + 1
sel[i]()
table.remove(ops, i)
table.remove(sel, i)
end
else
if VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, 0) then VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, 1) end
if c:IsRelateToEffect(e) then
VgF.Sendto(LOCATION_DAMAGE, c, tp, POS_FACEUP_ATTACK, REASON_EFFECT)
Duel.Damage(tp, 1, REASON_TRIGGER)
end
end
local rc = VgF.GetVMonster(tp)
local bc = rc:GetBattleTarget()
local label = bc:GetFlagEffectLabel(FLAG_DAMAGE_TRIGGER)
if not label then return end
if label > 0 then
label = label - 1
Duel.RaiseEvent(c, EVENT_CUSTOM + EVENT_TRIGGER, e, 0, tp, tp, 0)
bc:ResetFlagEffect(FLAG_DAMAGE_TRIGGER)
bc:RegisterFlagEffect(FLAG_DAMAGE_TRIGGER, RESET_EVENT + RESETS_STANDARD, 0, 1, label)
elseif label == 0 then
bc:ResetFlagEffect(FLAG_DAMAGE_TRIGGER)
Duel.RaiseEvent(rc, EVENT_CUSTOM + EVENT_DAMAGE_TRIGGER, e, 0, tp, tp, 0)
end
else
if c:IsRace(TRIGGER_SUPER) then
local ops = {}
local sel = {}
if c:IsRelateToEffect(e) then
table.insert(ops, VgF.Stringid(VgID + 5, 3))
table.insert(sel, function ()
VgF.Sendto(LOCATION_EXILE, c, REASON_TRIGGER)
end)
end
if true then
table.insert(ops, VgF.Stringid(VgID + 5, 4))
table.insert(sel, function ()
Duel.Draw(tp, 1, REASON_TRIGGER)
end)
end
if VgF.IsExistingMatchingCard(nil, tp, LOCATION_MZONE, 0, 1, nil) then
table.insert(ops, VgF.Stringid(VgID + 5, 5))
table.insert(sel, function ()
local g = VgF.SelectMatchingCard(HINTMSG_ATKUP, e, tp, nil, tp, LOCATION_MZONE, 0, 1, 1, nil)
VgF.AtkUp(c, g, 100000000, nil)
end)
end
if VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, 0) then
table.insert(ops, VgF.Stringid(VgID + 5, 6))
table.insert(sel, function ()
return VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, 1)
end)
end
while #ops > 0 do
local i = Duel.SelectOption(tp, table.unpack(ops)) + 1
sel[i]()
table.remove(ops, i)
table.remove(sel, i)
end
else
if VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, 0) then VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, 1) end
if c:IsRelateToEffect(e) then VgF.Sendto(LOCATION_HAND, c, nil, REASON_TRIGGER) end
end
local rc = VgF.GetVMonster(tp)
local label = rc:GetFlagEffectLabel(FLAG_ATTACK_TRIGGER)
if not label then return end
if label > 1 then
label = label - 1
Duel.RaiseEvent(c, EVENT_CUSTOM + EVENT_TRIGGER, e, 0, tp, tp, 0)
rc:ResetFlagEffect(FLAG_ATTACK_TRIGGER)
rc:RegisterFlagEffect(FLAG_ATTACK_TRIGGER, RESET_EVENT + RESETS_STANDARD, 0, 1, label)
elseif label == 1 then
rc:ResetFlagEffect(FLAG_ATTACK_TRIGGER)
end
end
end
end
function VgD.OperationWhenCardTrigger(e, tp, eg, ep, ev, re, r, rp, c, chk)
local effect_when_trigger = c.effect_when_trigger
local cost, con, tg = true, true, true
if not effect_when_trigger or #effect_when_trigger == 0 then return end
if (VgF.GetValueType(effect_when_trigger[5]) == "boolean" and not effect_when_trigger[5]) or (VgF.GetValueType(effect_when_trigger[5]) ~= "boolean" and Duel.GetTurnPlayer() ~= c:GetControler()) then return false end
if VgF.GetValueType(effect_when_trigger[2]) == "function" then cost = effect_when_trigger[2](e, tp, eg, ep, ev, re, r, rp, 0) end
if VgF.GetValueType(effect_when_trigger[3]) == "function" then con = effect_when_trigger[3](e, tp, eg, ep, ev, re, r, rp) end
if VgF.GetValueType(effect_when_trigger[4]) == "function" then tg = effect_when_trigger[4](e, tp, eg, ep, ev, re, r, rp, 0) end
if VgF.GetValueType(effect_when_trigger[1]) == "function" and cost and con and tg then
if chk == 0 then return true end
local activate_chk = true
if VgF.GetValueType(effect_when_trigger[2]) == "function" then activate_chk = Duel.SelectYesNo(tp, VgF.Stringid(VgID, 15)) end
if activate_chk then
Duel.HintSelection(Group.FromCards(c))
local _, m = c:GetOriginalCode()
Duel.Hint(HINT_CARD, 0, m)
if VgF.GetValueType(effect_when_trigger[2]) == "function" then effect_when_trigger[2](e, tp, eg, ep, ev, re, r, rp, 1) end
if VgF.GetValueType(effect_when_trigger[4]) == "function" then effect_when_trigger[4](e, tp, eg, ep, ev, re, r, rp, 1) end
effect_when_trigger[1](e, tp, eg, ep, ev, re, r, rp)
end
end
return false
end
--vg规则 ---使卡片具有超限舞装的功能
function VgD.Rule(c) ---@param c Card 要注册超限舞装功能的卡
---@param filter number 卡名为 filter 的后防者,或符合 filter 的后防者等
---@return Effect 这个效果
function VgD.OverDress(c, filter)
local e1 = Effect.CreateEffect(c) local e1 = Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS) e1:SetDescription(VgF.Stringid(VgID, 9))
e1:SetCode(EVENT_PHASE + PHASE_DRAW) e1:SetType(EFFECT_TYPE_FIELD)
e1:SetRange(LOCATION_ALL) e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e1:SetRange(LOCATION_HAND)
e1:SetCountLimit(1, VgID + 2) e1:SetProperty(EFFECT_FLAG_SPSUM_PARAM)
e1:SetCondition(VgD.RuelDrawCondition) e1:SetTargetRange(POS_FACEUP_ATTACK, 0)
e1:SetOperation(VgD.RuelDrawOperation) e1:SetCondition(VgD.OverDressCondition(filter))
e1:SetOperation(VgD.OverDressOperation(filter))
c:RegisterEffect(e1) c:RegisterEffect(e1)
local e2 = Effect.CreateEffect(c) local e2 = Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS) e2:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
e2:SetCode(EVENT_BATTLED) e2:SetCode(EVENT_SPSUMMON_SUCCESS)
e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE) e2:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e2:SetRange(LOCATION_MZONE) e2:SetOperation(VgD.OverDressSum)
e2:SetOperation(VgD.ResetOperation)
c:RegisterEffect(e2) c:RegisterEffect(e2)
local e3 = Effect.CreateEffect(c) return e1
e3:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
e3:SetCode(EVENT_PHASE_START + PHASE_STANDBY)
e3:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e3:SetRange(LOCATION_ALL)
e3:SetCountLimit(1, VgID + 3)
e3:SetCondition(VgF.RuleCardCondtion)
e3:SetOperation(VgD.EventRideStart)
c:RegisterEffect(e3)
local e10 = Effect.CreateEffect(c)
e10:SetType(EFFECT_TYPE_FIELD)
e10:SetCode(EFFECT_HAND_LIMIT)
e10:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_CANNOT_DISABLE)
e10:SetRange(LOCATION_ALL)
e10:SetTargetRange(1, 0)
e10:SetValue(100)
e10:SetCondition(VgF.RuleCardCondtion)
c:RegisterEffect(e10)
local e11 = Effect.CreateEffect(c)
e11:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
e11:SetCode(EVENT_ADJUST)
e11:SetRange(LOCATION_ALL)
e11:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e11:SetCondition(VgF.RuleCardCondtion)
e11:SetOperation(VgD.RuleWin)
c:RegisterEffect(e11)
local e12 = Effect.CreateEffect(c)
e12:SetType(EFFECT_TYPE_FIELD)
e12:SetCode(EFFECT_SKIP_M2)
e12:SetRange(LOCATION_ALL)
e12:SetProperty(EFFECT_FLAG_PLAYER_TARGET + EFFECT_FLAG_CANNOT_DISABLE)
e12:SetTargetRange(1, 0)
c:RegisterEffect(e12)
local e13 = e12:Clone()
e13:SetCode(EFFECT_CANNOT_SUMMON)
c:RegisterEffect(e13)
local e14 = e12:Clone()
e14:SetCode(EFFECT_CANNOT_MSET)
c:RegisterEffect(e14)
local e15 = e12:Clone()
e15:SetCode(EFFECT_CANNOT_SSET)
c:RegisterEffect(e15)
local e16 = Effect.CreateEffect(c)
e16:SetType(EFFECT_TYPE_FIELD)
e16:SetCode(EFFECT_QP_ACT_IN_NTPHAND)
e16:SetRange(LOCATION_ALL)
e16:SetCondition(VgF.RuleCardCondtion)
e16:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e16:SetTargetRange(LOCATION_HAND, 0)
c:RegisterEffect(e16)
end
function VgD.EventRideStart(e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler()
if Duel.GetTurnPlayer() == tp then
Duel.RaiseEvent(c, EVENT_CUSTOM + EVENT_RIDE_START, e, 0, tp, tp, 0)
end
end end
function VgD.RuleWin(e, tp, eg, ep, ev, re, r, rp) function VgD.OverDressCondition(filter)
if Duel.GetCurrentChain() > 0 then return end return function (e, c)
local g1 = Duel.GetFieldGroupCount(tp, LOCATION_DECK, 0) if c == nil then return true end
local g2 = Duel.GetFieldGroupCount(tp, 0, LOCATION_DECK) local tp = e:GetHandlerPlayer()
if g1 == 0 and g2 == 0 then return VgF.LvCondition(e) and VgF.IsExistingMatchingCard(VgD.OverDressFilter, tp, LOCATION_MZONE, 0, 1, nil, filter)
Duel.Win(PLAYER_NONE, 0x2)
elseif g1 == 0 then
Duel.Win(1 - tp, 0x2)
elseif g2 == 0 then
Duel.Win(tp, 0x2)
end end
end end
function VgD.RuelDrawCondition(e, tp, eg, ep, ev, re, r, rp) function VgD.OverDressFilter(c, filter, tp, zone)
return VgF.RuleTurnCondtion(e) and VgF.RuleCardCondtion(e) if not c:IsFaceup() then return false end
if zone and zone ~= VgF.SequenceToGlobal(tp, c:GetLocation(), c:GetSequence()) then return false end
return not filter or (type(filter) == "function" and filter(c)) or (type(filter) == "number" and c:IsCode(filter))
end end
function VgD.RuelDrawOperation(e, tp, eg, ep, ev, re, r, rp) function VgD.OverDressOperation(filter)
local ct = Duel.GetFieldGroupCount(tp, LOCATION_HAND, 0) return function(e, tp, eg, ep, ev, re, r, rp)
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_TODECK) local c = e:GetHandler()
local g = Duel.GetFieldGroup(tp, LOCATION_HAND, 0):Select(tp, 0, ct, nil) local g = Duel.GetMatchingGroup(VgD.OverDressFilter, tp, LOCATION_MZONE, 0, nil, filter, tp)
if g:GetCount() > 0 then local zone, szone = 0, 0
ct = Duel.SendtoDeck(g, tp, 1, REASON_PHASEDRAW) for tc in VgF.Next(g) do
Duel.Draw(tp, ct, REASON_PHASEDRAW) zone = bit.bor(zone, VgF.SequenceToGlobal(tp, tc:GetLocation(), tc:GetSequence()))
Duel.ShuffleDeck(tp)
end end
if Duel.GetTurnPlayer() == tp then if zone == 0 then return end
Duel.Draw(tp, 1, REASON_PHASEDRAW) zone = bit.bnot(zone)
Duel.Hint(HINT_SELECTMSG, tp, HINTMSG_CallZONE)
szone = Duel.SelectField(tp, 1, LOCATION_MZONE, 0, zone)
e:SetValue(function () return SUMMON_VALUE_CALL + SUMMON_VALUE_OverDress, szone end)
local mg = Duel.GetMatchingGroup(VgD.OverDressFilter, tp, LOCATION_MZONE, 0, nil, filter, tp, szone)
if #mg == 0 then return end
local og = tc:GetOverlayGroup()
if #og ~= 0 then
VgF.Sendto(LOCATION_OVERLAY, og, c)
end
c:SetMaterial(Group.FromCards(tc))
VgF.Sendto(LOCATION_OVERLAY, mg, c)
end end
end end
function VgD.ResetOperation(e, tp, eg, ep, ev, re, r, rp) function VgD.OverDressSum(e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler() e:GetHandler():RegisterFlagEffect(FLAG_CONDITION, RESET_EVENT + RESETS_STANDARD, EFFECT_FLAG_CLIENT_HINT, 1, 201, VgF.Stringid(10101006, 0))
if c:GetFlagEffect(FLAG_SUPPORT) > 0 then c:ResetFlagEffect(FLAG_SUPPORT) end end
if c:GetFlagEffect(FLAG_SUPPORTED) > 0 then c:ResetFlagEffect(FLAG_SUPPORTED) end
if c:GetFlagEffect(FLAG_DEFENSE_ENTIRELY) > 0 then c:ResetFlagEffect(FLAG_DEFENSE_ENTIRELY) end ---使卡片具有交织超限舞装的功能
---@param c Card 要注册交织超限舞装功能的卡
---@param filter number 卡名为 filter 的后防者,或符合 filter 的后防者等
---@return Effect 这个效果
function VgD.XOverDress(c, filter)
end
---使卡片具有舞装加身的功能
---@param c Card 要注册舞装加身功能的卡
---@param code number 指定卡的卡号
---@return Effect 这个效果
function VgD.DressUp(c, code)
local e = Effect.CreateEffect(c)
e:SetType(EFFECT_TYPE_SINGLE)
e:SetCode(EFFECT_ADD_CODE)
e:SetProperty(EFFECT_FLAG_CANNOT_DISABLE + EFFECT_FLAG_UNCOPYABLE)
e:SetValue(code)
c:RegisterEffect(e)
return e
end end
--指令卡 --指令卡相关----------------------------------------------------------------------------------------
---使c可以作为指令卡发动。
---@param c Card 要操作的卡 ---使卡片可以作为指令卡发动
---@param m integer 指示脚本的整数。cxxx的脚本应填入xxx。cm的脚本应填入m。 ---@param c Card 要注册指令卡功能的卡
---@param m number|nil 指示脚本的整数。cxxx的脚本应填入xxx。cm的脚本应填入m。
---@param op function|nil 作为指令卡的效果 ---@param op function|nil 作为指令卡的效果
---@param con function|nil 作为指令卡的发动条件
---@param cost function|nil 作为指令卡的发动费用 ---@param cost function|nil 作为指令卡的发动费用
---@param con function|nil 作为指令卡的发动条件
---@return Effect 这个效果
function VgD.SpellActivate(c, m, op, cost, con) function VgD.SpellActivate(c, m, op, cost, con)
local e1 = Effect.CreateEffect(c) -- check func
e1:SetDescription(VgF.Stringid(m, 0)) local fchk = VgF.IllegalFunctionCheck("SpellActivate")
e1:SetType(EFFECT_TYPE_ACTIVATE) if fchk.con(con) or fchk.cost(cost) or fchk.op(op) then return end
e1:SetCode(EVENT_FREE_CHAIN) -- set param
e1:SetCost(VgD.MixCost(cost)) m = m or c:GetOriginalCode()
e1:SetCondition(VgD.SpellCondtion(con)) -- set effect
e1:SetTarget(VgD.SpellTarget) local e = Effect.CreateEffect(c)
e1:SetOperation(VgD.SpellOperation(op)) e:SetDescription(VgF.Stringid(m, 0))
c:RegisterEffect(e1) e:SetType(EFFECT_TYPE_ACTIVATE)
e:SetCode(EVENT_FREE_CHAIN)
e:SetCondition(VgD.SpellCondtion(con))
e:SetCost(VgD.MixCost(cost))
e:SetTarget(VgD.SpellTarget)
e:SetOperation(VgD.SpellOperation(op))
c:RegisterEffect(e)
return e
end
function VgD.SpellCondtion(con)
return function(e, tp, eg, ep, ev, re, r, rp)
return VgF.LvCondition(e) and (not con or con(e, tp, eg, ep, ev, re, r, rp))
end
end end
function VgD.MixCost(cost) function VgD.MixCost(cost)
return function(e, tp, eg, ep, ev, re, r, rp, chk) return function(e, tp, eg, ep, ev, re, r, rp, chk)
cost = cost or aux.TRUE
local c = e:GetHandler() local c = e:GetHandler()
if chk == 0 then local alchemagic_g = Duel.GetMatchingGroup(VgD.MixCostFilter, tp, LOCATION_DROP, 0, nil, e, tp, eg, ep, ev, re, r, rp, c)
return VgF.GetValueType(cost) ~= "function" or cost(e, tp, eg, ep, ev, re, r, rp, 0) or (Duel.IsPlayerAffectedByEffect(tp, AFFECT_CODE_MIX) and VgF.IsExistingMatchingCard(VgD.MixCostFilter, tp, LOCATION_DROP, 0, 1, nil, e, tp, eg, ep, ev, re, r, rp, c)) local alchemagic_chk = Duel.IsPlayerAffectedByEffect(tp, AFFECT_CODE_MIX) and #alchemagic_g > 0
end local cost_chk = cost(e, tp, eg, ep, ev, re, r, rp, 0)
if Duel.IsPlayerAffectedByEffect(tp, AFFECT_CODE_MIX) and VgF.IsExistingMatchingCard(VgD.MixCostFilter, tp, LOCATION_DROP, 0, 1, nil, e, tp, eg, ep, ev, re, r, rp, c) then if chk == 0 then return cost_chk or alchemagic_chk end
local a = false if alchemagic_chk and (not cost_chk or Duel.SelectYesNo(tp, VgF.Stringid(VgID, 6))) then
if VgF.GetValueType(cost) == "function" and not cost(e, tp, eg, ep, ev, re, r, rp, 0) then a = true end local alchemagic_c = alchemagic_g:Select(tp, 1, 1, nil):GetFirst()
if not a then a = Duel.SelectYesNo(tp, VgF.Stringid(VgID, 6)) end VgF.Sendto(LOCATION_LOCK, alchemagic_c, POS_FACEUP, REASON_COST)
if a then e:SetLabelObject(alchemagic_c)
local bc = Duel.SelectMatchingCard(tp, VgD.MixCostFilter, tp, LOCATION_DROP, 0, 1, 1, nil, e, tp, eg, ep, ev, re, r, rp, c):GetFirst() VgD.MixCostOperation(c, alchemagic_c, tp)
if bc then
VgF.Sendto(LOCATION_LOCK, bc, POS_FACEUP, REASON_COST)
e:SetLabelObject(bc)
VgD.MixCostOperation(c, bc, tp)
end
end
else else
if VgF.GetValueType(cost) == "function" then cost(e, tp, eg, ep, ev, re, r, rp, 1) end cost(e, tp, eg, ep, ev, re, r, rp, 1)
end end
end end
end end
...@@ -1192,294 +1190,424 @@ function VgD.MixCostOperation(c, bc, tp) ...@@ -1192,294 +1190,424 @@ function VgD.MixCostOperation(c, bc, tp)
::continue:: ::continue::
end end
end end
function VgD.SpellCondtion(con)
return function (e, tp, eg, ep, ev, re, r, rp)
if VgF.GetValueType(con) == "function" and not con(e, tp, eg, ep, ev, re, r, rp) then return false end
return VgF.LvCondition(e)
end
end
function VgD.SpellTarget(e, tp, eg, ep, ev, re, r, rp, chk) function VgD.SpellTarget(e, tp, eg, ep, ev, re, r, rp, chk)
local ct1 = Duel.GetFlagEffectLabel(tp, FLAG_SPELL_COUNT_LIMIT) local ct1 = Duel.GetFlagEffectLabel(tp, FLAG_SPELL_COUNT_LIMIT) or 1
local ct2 = Duel.GetFlagEffectLabel(tp, FLAG_SPELL_USED_COUNT) local ct2 = Duel.GetFlagEffectLabel(tp, FLAG_SPELL_USED_COUNT) or 0
if VgF.GetValueType(ct1) ~= "number" then ct1 = 1 end
if VgF.GetValueType(ct2) ~= "number" then ct2 = 0 end
if chk == 0 then return ct2 < ct1 end if chk == 0 then return ct2 < ct1 end
Duel.RegisterFlagEffect(tp, FLAG_SPELL_USED_COUNT, RESET_PHASE + PHASE_END, 0, 1, ct2 + 1) Duel.RegisterFlagEffect(tp, FLAG_SPELL_USED_COUNT, RESET_PHASE + PHASE_END, 0, 1, ct2 + 1)
end end
function VgD.SpellOperation(op) function VgD.SpellOperation(op)
return function (e, tp, eg, ep, ev, re, r, rp, bool) return function(e, tp, eg, ep, ev, re, r, rp, no_alchemagic)
if op then op(e, tp, eg, ep, ev, re, r, rp, 1) end if op then op(e, tp, eg, ep, ev, re, r, rp, true) end
local mc = e:GetLabelObject() local mc = e:GetLabelObject()
if bool or not mc then return end if no_alchemagic or not mc then return end
local te = mc:GetActivateEffect() local alchemagic_op = mc:GetActivateEffect():GetOperation()
local op2 = te:GetOperation() if alchemagic_op then alchemagic_op(e, tp, eg, ep, ev, re, r, rp, true) end
if op2 then op2(e, tp, eg, ep, ev, re, r, rp, true) end
end
end
---当c被卡号为code的卡Ride时触发的效果。
---@param c Card 被Ride的卡
---@param m integer 指示脚本的整数。cxxx的脚本应填入xxx。cm的脚本应填入m。
---@param code integer|nil Ride的卡
---@param op function|nil 触发的效果
---@param cost function|nil 效果的费用
---@param con function|nil 效果的条件
---@param tg function|nil
function VgD.BeRidedByCard(c, m, code, op, cost, con, tg)
local cm = _G["c"..m]
if not cm.is_has_trigger then cm.is_has_trigger = true end
local e1 = Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_BE_MATERIAL)
e1:SetProperty(EFFECT_FLAG_EVENT_PLAYER)
e1:SetCondition(VgD.BeRidedByCardCondition(code, con))
e1:SetOperation(VgD.BeRidedByCardOperation(m, op, cost, tg))
c:RegisterEffect(e1)
end
function VgD.BeRidedByCardCondition(code, f)
return function (e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler()
if VgF.GetValueType(code) == "function" and not code(c:GetReasonCard()) then return false
elseif VgF.GetValueType(code) == "number" and not c:GetReasonCard():IsCode(code) then return false end
return r == REASON_RIDEUP and (VgF.GetValueType(f) == "nil" or f(e, tp, eg, ep, ev, re, r, rp))
end end
end end
function VgD.BeRidedByCardOperation(m, op, cost, tg, stringid)
return function (e, tp, eg, ep, ev, re, r, rp) ---使卡片可以作为闪现指令卡发动
local c = e:GetHandler() ---@param c Card 要注册闪现指令卡功能的卡
local rc = c:GetReasonCard() ---@param op function|nil 作为指令卡的效果
local type = EFFECT_TYPE_TRIGGER_F ---@param cost function|nil 作为指令卡的发动费用
if not stringid then stringid = 2 end ---@param con function|nil 作为指令卡的发动条件
if VgF.GetValueType(cost) == "function" then type = EFFECT_TYPE_TRIGGER_O end ---@param tg function|nil 作为指令卡的发动检查
local e1 = Effect.CreateEffect(rc) ---@return Effect 这个效果
e1:SetDescription(VgF.Stringid(m, stringid)) function VgD.QuickSpell(c, op, cost, con, tg)
e1:SetType(type + EFFECT_TYPE_FIELD) -- check func
e1:SetProperty(EFFECT_FLAG_DELAY) local fchk = VgF.IllegalFunctionCheck("QuickSpell")
e1:SetCode(EVENT_SPSUMMON_SUCCESS) if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) or fchk.op(op) then return end
e1:SetLabelObject(c) -- set param
e1:SetRange(LOCATION_MZONE) local condition = function(e, tp, eg, ep, ev, re, r, rp)
e1:SetCondition(VgD.BeRidedByCardOpCondtion) local bc = Duel.GetAttackTarget()
if VgF.GetValueType(cost) == "function" then e1:SetCost(cost) end return bc and bc:IsControler(tp) and VgD.SpellCondtion(con)(e, tp, eg, ep, ev, re, r, rp)
if VgF.GetValueType(tg) == "function" then e1:SetTarget(tg) end
if VgF.GetValueType(op) == "function" then e1:SetOperation(op) end
e1:SetReset(RESET_EVENT + RESETS_STANDARD)
rc:RegisterEffect(e1, true)
end end
end -- set effect
function VgD.BeRidedByCardOpCondtion(e, tp, eg, ep, ev, re, r, rp) local e = Effect.CreateEffect(c)
local c = e:GetLabelObject() e:SetType(EFFECT_TYPE_ACTIVATE)
return eg:GetFirst() == e:GetHandler() and e:GetHandler():GetOverlayGroup():IsContains(c) e:SetCode(EVENT_BATTLE_START)
e:SetCondition(condition)
if cost then e:SetCost(cost) end
if tg then e:SetTarget(tg) end
if op then e:SetOperation(op) end
c:RegisterEffect(e)
return e
end end
---当c在loc时,可以发动的【起】效果。 ---使卡片可以作为设置指令卡发动
---@param c Card 要触发效果的卡 ---@param c Card 要注册设置指令卡功能的卡
---@param m integer 指示脚本的整数。cxxx的脚本应填入xxx。cm的脚本应填入m。 ---@param cost function|nil 作为指令卡的发动费用
---@param loc integer 发动时所处的位置 ---@param con function|nil 作为指令卡的发动条件
---@param op function|nil 触发的效果 ---@param tg function|nil 作为指令卡的发动检查
---@param cost function|nil 效果的费用 ---@return Effect 这个效果
---@param con function|nil 效果触发的条件 function VgD.ContinuousSpell(c, cost, con, tg)
---@param tg function|nil
---@param count integer|nil 指示效果在同一回合内最多发动的次数
---@param property integer|nil 指示效果的特殊属性。
function VgD.EffectTypeIgnition(c, m, loc, op, cost, con, tg, count, property, stringid)
-- check func -- check func
local cm = _G["c"..m] local fchk = VgF.IllegalFunctionCheck("ContinuousSpell")
if not VgF.FunctionLegal(op, m, "op") then return end if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) then return end
if not VgF.FunctionLegal(cost, m, "cost") then return end
if not VgF.FunctionLegal(con, m, "con") then return end
if not VgF.FunctionLegal(tg, m, "tg") then return end
-- set param -- set param
cm.is_has_ignition = true local operation = function(e, tp, eg, ep, ev, re, r, rp)
local con_exf = VgF.True VgF.Sendto(LOCATION_ORDER, e:GetHandler(), tp, POS_FACEUP_ATTACK, REASON_RULE)
loc = loc or LOCATION_MZONE
if loc == LOCATION_RZONE then
loc, con_exf = LOCATION_MZONE, VgF.RMonsterCondition
elseif loc == LOCATION_VZONE then
loc, con_exf = LOCATION_MZONE, VgF.VMonsterCondition
end end
-- set effect -- set effect
local e1 = Effect.CreateEffect(c) local e = Effect.CreateEffect(c)
e1:SetDescription(VgF.Stringid(VgID + 2, stringid or 1)) e:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetType(EFFECT_TYPE_IGNITION) e:SetCode(EVENT_FREE_CHAIN)
e1:SetRange(loc) e:SetCountLimit(1, VgID + EFFECT_COUNT_CODE_OATH)
if property then e1:SetProperty(property) end e:SetCondition(VgD.SpellCondtion(con))
if count then e1:SetCountLimit(count) end if cost then e:SetCost(cost) end
e1:SetCondition(function(e, tp, eg, ep, ev, re, r, rp) if tg then e:SetTarget(tg) end
return (not con or con(e, tp, eg, ep, ev, re, r, rp)) and con_exf(e) e:SetOperation(operation)
end) c:RegisterEffect(e)
if cost then e1:SetCost(cost) end return e
e1:SetTarget(function(e, tp, eg, ep, ev, re, r, rp, chk)
if chk == 0 then return not tg or tg(e, tp, eg, ep, ev, re, r, rp, 0) end
Duel.SetTargetCard(e:GetLabelObject())
tg(e, tp, eg, ep, ev, re, r, rp)
end)
if op then e1:SetOperation(op) end
c:RegisterEffect(e1)
return e1
end end
---当c在loc时,code时点被触发时执行的效果。【自】效果模板
---@param c Card 要触发效果的卡 --自相关----------------------------------------------------------------------------------------
---@param m integer 指示脚本的整数。cxxx的脚本应填入xxx。cm的脚本应填入m。
---@param loc integer 发动时所处的位置 ---【自】效果模板:当单位在loc时,code时点被触发时执行的效果
---@param typ integer 若是自己状态变化引发,则填EFFECT_TYPE_SINGLE;<br>若是场上任意一卡状态变化引发,则填EFFECT_TYPE_FIELD。 ---@param c Card 拥有这个效果的卡
---@param code integer 触发的时点 ---@param m number|nil 指示脚本的整数。cxxx的脚本应填入xxx。cm的脚本应填入m。
---@param op function|nil 触发的效果 ---@param loc number 可以发动的区域
---@param cost function|nil 效果的费用 ---@param typ number 若是自己状态变化引发,则填EFFECT_TYPE_SINGLE;<br>若是场上任意一卡状态变化引发,则填EFFECT_TYPE_FIELD。
---@param con function|nil 效果触发的条件 ---@param code number 触发的时点
---@param tg function|nil ---@param op function|nil 这个效果的处理函数
---@param count integer|nil 指示效果在同一回合内最多发动的次数 ---@param cost function|nil 这个效果的费用函数
---@param property integer|nil 指示效果的特殊属性。 ---@param con function|nil 这个效果的条件函数
function VgD.EffectTypeTrigger(c, m, loc, typ, code, op, cost, con, tg, count, property, stringid) ---@param tg function|nil 这个效果的检查函数
---@param count number|nil 同一回合内最多发动的次数
---@param property number|nil 这个效果的特殊属性。
---@param id number|nil 提示脚本的卡号索引
---@return Effect 这个效果
function VgD.EffectTypeTrigger(c, m, loc, typ, code, op, cost, con, tg, count, property, id)
-- check func -- check func
local cm = _G["c"..m] local fchk = VgF.IllegalFunctionCheck("EffectTypeTrigger")
if not VgF.FunctionLegal(op, m, "op") then return end if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) or fchk.op(op) then return end
if not VgF.FunctionLegal(cost, m, "cost") then return end
if not VgF.FunctionLegal(con, m, "con") then return end
if not VgF.FunctionLegal(tg, m, "tg") then return end
-- set param -- set param
cm.is_has_trigger = true m = m or c:GetOriginalCode()
_G["c"..m].is_has_trigger = true
typ = (typ or EFFECT_TYPE_SINGLE) + (cost and EFFECT_TYPE_TRIGGER_O or EFFECT_TYPE_TRIGGER_F) typ = (typ or EFFECT_TYPE_SINGLE) + (cost and EFFECT_TYPE_TRIGGER_O or EFFECT_TYPE_TRIGGER_F)
local con_exf = VgF.True loc, con = VgF.GetLocCondition(loc, con)
loc = loc or LOCATION_MZONE
if loc == LOCATION_RZONE then
loc, con_exf = LOCATION_MZONE, VgF.RMonsterCondition
elseif loc == LOCATION_VZONE then
loc, con_exf = LOCATION_MZONE, VgF.VMonsterCondition
end
-- set effect -- set effect
local e1 = Effect.CreateEffect(c) local e = Effect.CreateEffect(c)
e1:SetDescription(VgF.Stringid(VgID + 1, stringid or 1)) e:SetDescription(VgF.Stringid(VgID + 1, id or 1))
e1:SetType(typ) e:SetType(typ)
e1:SetCode(code) e:SetCode(code)
e1:SetRange(loc) e:SetRange(loc)
e1:SetProperty((property or 1) + EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DELAY) e:SetProperty((property or 0) + EFFECT_FLAG_DAMAGE_STEP + EFFECT_FLAG_DELAY)
if count then e1:SetCountLimit(count) end if count then e:SetCountLimit(count) end
e1:SetCondition(function(e, tp, eg, ep, ev, re, r, rp) e:SetCondition(con)
return (not con or con(e, tp, eg, ep, ev, re, r, rp)) and con_exf(e) if cost then e:SetCost(cost) end
end) if tg then e:SetTarget(tg) end
if cost then e1:SetCost(cost) end if op then e:SetOperation(op) end
if tg then e1:SetTarget(tg) end c:RegisterEffect(e)
if op then e1:SetOperation(op) end return e
c:RegisterEffect(e1)
return e1
end end
function VgD.EffectTypeTriggerWhenHitting(c, m, loc, typ, op, cost, con, tg, count, p, property, stringid)
---【自】攻击击中时触发
---@param c Card 拥有这个效果的卡
---@param m number|nil 指示脚本的整数。cxxx的脚本应填入xxx。cm的脚本应填入m。
---@param loc number 可以发动的区域
---@param typ number 若是自己状态变化引发,则填EFFECT_TYPE_SINGLE;<br>若是场上任意一卡状态变化引发,则填EFFECT_TYPE_FIELD
---@param op function|nil 这个效果的处理函数
---@param cost function|nil 这个效果的费用函数
---@param con function|nil 这个效果的条件函数
---@param tg function|nil 这个效果的检查函数
---@param count number|nil 同一回合内最多发动的次数
---@param p number|nil 被击中的卡的控制者
---@param property number|nil 这个效果的特殊属性。
---@param id number|nil 提示脚本的卡号索引
---@return Effect 这个效果 *回传两个效果*
function VgD.EffectTypeTriggerWhenHitting(c, m, loc, typ, op, cost, con, tg, count, p, property, id)
-- check func
local fchk = VgF.IllegalFunctionCheck("EffectTypeTriggerWhenHitting")
if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) or fchk.op(op) then return end
-- set param
typ = typ or EFFECT_TYPE_SINGLE typ = typ or EFFECT_TYPE_SINGLE
local e1 = VgD.EffectTypeTrigger(c, m, loc, typ, EVENT_BATTLE_DESTROYING, op, cost, con, tg, count, property, stringid) -- set effect
p = p or c:GetControler() local e1 = VgD.EffectTypeTrigger(c, m, loc, typ, EVENT_BATTLE_DESTROYING, op, cost, con, tg, count, property, id)
local e2 = VgD.EffectTypeTrigger(c, m, loc, EFFECT_TYPE_FIELD, EVENT_CUSTOM + EVENT_DAMAGE_TRIGGER, op, cost, VgD.EffectTypeTriggerWhenHittingCon(typ, con, p), tg, count, property, stringid) local e2 = VgD.EffectTypeTrigger(c, m, loc, EFFECT_TYPE_FIELD, EVENT_CUSTOM + EVENT_DAMAGE_TRIGGER, op, cost, VgD.EffectTypeTriggerWhenHittingCon(typ, con, p), tg, count, property, id)
return e1, e2 return e1, e2
end end
function VgD.EffectTypeTriggerWhenHittingCon(typ, con, p) function VgD.EffectTypeTriggerWhenHittingCon(typ, con, p)
return function (e, tp, eg, ep, ev, re, r, rp) return function (e, tp, eg, ep, ev, re, r, rp)
if eg:GetFirst():GetControler() == p and (con and not con(e, tp, eg, ep, ev, re, r, rp)) then return false end if con and not con(e, tp, eg, ep, ev, re, r, rp) then return false end
if typ == EFFECT_TYPE_SINGLE then return Duel.GetAttacker() == e:GetHandler() end if eg:GetFirst():IsControler(p or e:GetOwner():GetControl()) then return false end
return true return typ == EFFECT_TYPE_FIELD or Duel.GetAttacker() == e:GetHandler()
end end
end end
function VgD.QuickSpell(c, op, cost, con, tg)
local e1 = Effect.CreateEffect(c) ---【自】这个单位被放置到G时触发
e1:SetType(EFFECT_TYPE_ACTIVATE) ---@param c Card 拥有这个效果的卡
e1:SetCode(EVENT_BATTLE_START) ---@param m number|nil 指示脚本的整数。cxxx的脚本应填入xxx。cm的脚本应填入m。
e1:SetCondition(function (e, tp, eg, ep, ev, re, r, rp) ---@param op function|nil 这个效果的处理函数
if VgF.GetValueType(con) == "function" and not con(e, tp, eg, ep, ev, re, r, rp) then return false end ---@param cost function|nil 这个效果的费用函数
local bc = Duel.GetAttackTarget() ---@param con function|nil 这个效果的条件函数
return bc and bc:IsControler(tp) and VgF.LvCondition(e) ---@return Effect 这个效果
end) function VgD.CardToG(c, m, op, cost, con)
if VgF.GetValueType(cost) == "function" then e1:SetCost(cost) end -- check func
if VgF.GetValueType(tg) == "function" then e1:SetTarget(tg) end local fchk = VgF.IllegalFunctionCheck("CardToG")
if VgF.GetValueType(op) == "function" then e1:SetOperation(op) end if fchk.con(con) or fchk.cost(cost) or fchk.op(op) then return end
c:RegisterEffect(e1) -- set param
return e1 m = m or c:GetOriginalCode()
_G["c"..m].is_has_trigger = true
local typ = cost and EFFECT_TYPE_TRIGGER_O or EFFECT_TYPE_TRIGGER_F
op = op or VgD.CardToGOperation
-- set effect
local e = Effect.CreateEffect(c)
e:SetDescription(VgF.Stringid(VgID, 2))
e:SetType(EFFECT_TYPE_SINGLE + typ)
e:SetProperty(EFFECT_FLAG_DELAY + EFFECT_FLAG_DAMAGE_STEP)
e:SetCode(EVENT_MOVE)
if cost then e:SetCost(cost) end
e:SetCondition(VgD.CardToGCondition(con))
e:SetOperation(op)
c:RegisterEffect(e)
return e
end end
function VgD.ContinuousSpell(c, cost, con, tg) function VgD.CardToGCondition(con)
return function(e, tp, eg, ep, ev, re, r, rp)
return (not con or con(e, tp, eg, ep, ev, re, r, rp)) and e:GetHandler():IsLocation(LOCATION_GZONE) and Duel.GetAttackTarget()
end
end
function VgD.CardToGOperation(e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler()
local tc = Duel.GetAttackTarget()
if vgf.RMonsterFilter(tc) then
local e1 = Effect.CreateEffect(c) local e1 = Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_ACTIVATE) e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EVENT_FREE_CHAIN) e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e1:SetCountLimit(1, VgID + EFFECT_COUNT_CODE_OATH) e1:SetRange(LOCATION_MZONE)
e1:SetCondition(function (e, tp, eg, ep, ev, re, r, rp) e1:SetCode(EFFECT_INDESTRUCTABLE_BATTLE)
if VgF.GetValueType(con) == "function" and not con(e, tp, eg, ep, ev, re, r, rp) then return false end e1:SetReset(RESET_EVENT + RESETS_STANDARD)
return VgF.LvCondition(e) e1:SetValue(1)
end) tc:RegisterEffect(e1)
if VgF.GetValueType(cost) == "function" then e1:SetCost(cost) end vgf.EffectReset(c, e1, EVENT_BATTLED)
if VgF.GetValueType(tg) == "function" then e1:SetTarget(tg) end elseif vgf.VMonsterFilter(tc) then
e1:SetOperation(VgD.ContinuousSpellOperation) tc:RegisterFlagEffect(FLAG_DEFENSE_ENTIRELY, RESET_EVENT + RESETS_STANDARD, 0, 1)
c:RegisterEffect(e1) end
return e1 end
---【自】这个单位被 Ride 时触发
---@param c Card 被Ride的卡
---@param m number|nil 指示脚本的整数。cxxx的脚本应填入xxx。cm的脚本应填入m。
---@param filter number|nil Ride c 的卡
---@param op function|nil 这个效果的处理函数
---@param cost function|nil 这个效果的费用函数
---@param con function|nil 这个效果的条件函数
---@param tg function|nil 这个效果的检查函数
---@param id number|nil 提示脚本的卡号索引
---@return Effect 这个效果
function VgD.BeRidedByCard(c, m, filter, op, cost, con, tg, id)
-- check func
local fchk = VgF.IllegalFunctionCheck("BeRidedByCard")
if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) or fchk.op(op) then return end
-- set param
m = m or c:GetOriginalCode()
_G["c"..m].is_has_trigger = true
local desc = VgF.Stringid(m, id or 2)
-- set effect
local e = Effect.CreateEffect(c)
e:SetType(EFFECT_TYPE_SINGLE + EFFECT_TYPE_CONTINUOUS)
e:SetCode(EVENT_BE_MATERIAL)
e:SetProperty(EFFECT_FLAG_EVENT_PLAYER)
e:SetCondition(VgD.BeRidedByCardCondition(con, filter))
e:SetOperation(VgD.BeRidedByCardOperation(desc, op, cost, tg))
c:RegisterEffect(e)
return e
end
function VgD.BeRidedByCardCondition(con, filter)
return function (e, tp, eg, ep, ev, re, r, rp)
if r ~= REASON_RIDEUP or (con and not con(e, tp, eg, ep, ev, re, r, rp)) then return false end
local c, rc = e:GetHandler(), e:GetHandler():GetReasonCard()
filter = filter or vgf.True
if type(filter) == "number" then
filter = function(c, rc)
return rc:IsCode(filter)
end
end
return filter(c:GetReasonCard(), c)
end
end end
function VgD.ContinuousSpellOperation(e, tp, eg, ep, ev, re, r, rp) function VgD.BeRidedByCardOperation(desc, op, cost, tg)
return function(e, tp, eg, ep, ev, re, r, rp)
local c = e:GetHandler() local c = e:GetHandler()
VgF.Sendto(LOCATION_ORDER, c, tp, POS_FACEUP_ATTACK, REASON_RULE) local rc = c:GetReasonCard()
local typ = cost and EFFECT_TYPE_TRIGGER_O or EFFECT_TYPE_TRIGGER_F
local e = Effect.CreateEffect(rc)
e:SetDescription(desc)
e:SetType(typ + EFFECT_TYPE_FIELD)
e:SetProperty(EFFECT_FLAG_DELAY+EFFECT_FLAG_IGNORE_IMMUNE)
e:SetCode(EVENT_SPSUMMON_SUCCESS)
e:SetLabelObject(c)
e:SetRange(LOCATION_MZONE)
e:SetCondition(VgD.BeRidedByCardOpCondtion)
if cost then e:SetCost(cost) end
if tg then e:SetTarget(tg) end
if op then e:SetOperation(op) end
e:SetReset(RESET_EVENT + RESETS_STANDARD)
rc:RegisterEffect(e)
end
end
function VgD.BeRidedByCardOpCondtion(e, tp, eg, ep, ev, re, r, rp)
local c = e:GetLabelObject()
return eg:GetFirst() == e:GetHandler() and e:GetHandler():GetOverlayGroup():IsContains(c)
end
--起相关----------------------------------------------------------------------------------------
---【起】效果模板:当单位在loc时,可以发动的【起】效果
---@param c Card 要触发效果的卡
---@param m number|nil 指示脚本的整数。cxxx的脚本应填入xxx。cm的脚本应填入m。
---@param loc number 可以发动的区域
---@param op function|nil 这个效果的处理函数
---@param cost function|nil 这个效果的费用函数
---@param con function|nil 这个效果的条件函数
---@param tg function|nil 这个效果的检查函数
---@param count number|nil 同一回合内最多发动的次数
---@param property number|nil 这个效果的特殊属性。
---@param id number|nil 提示脚本的卡号索引
---@return Effect 这个效果
function VgD.EffectTypeIgnition(c, m, loc, op, cost, con, tg, count, property, id)
-- check func
local fchk = VgF.IllegalFunctionCheck("EffectTypeIgnition")
if fchk.con(con) or fchk.cost(cost) or fchk.tg(tg) or fchk.op(op) then return end
-- set param
m = m or c:GetOriginalCode()
_G["c"..m].is_has_ignition = true
loc, con = VgF.GetLocCondition(loc, con)
-- set effect
local e = Effect.CreateEffect(c)
e:SetDescription(VgF.Stringid(VgID + 2, id or 1))
e:SetType(EFFECT_TYPE_IGNITION)
e:SetRange(loc)
if property then e:SetProperty(property) end
if count then e:SetCountLimit(count) end
e:SetCondition(con)
if cost then e:SetCost(cost) end
if tg then e:SetTarget(tg) end
if op then e:SetOperation(op) end
c:RegisterEffect(e)
return e
end end
--永相关----------------------------------------------------------------------------------------
---【永】效果模板 ---【永】效果模板
---@param c Card 效果的创建者 ---@param c Card 效果的创建者
---@param m integer 指示脚本的整数。cxxx的脚本应填入xxx。cm的脚本应填入m。 ---@param m number|nil 效果的创建者的卡号
---@param loc integer 发动时所处的位置 ---@param loc number 生效的区域
---@param typ integer 只影响自己,则填EFFECT_TYPE_SINGLE;<br>影响场上,则填EFFECT_TYPE_FIELD。 ---@param typ number 只影响自己,则填EFFECT_TYPE_SINGLE;<br>影响场上,则填EFFECT_TYPE_FIELD。
---@param code integer 触发的效果 ---@param code number 触发的效果
---@param val integer 触发的效果的数值 ---@param val number 触发的效果的数值
---@param con function|nil 效果触发的条件 ---@param con function|nil 这个效果的条件函数
---@param tg function|nil 效果的适用对象过滤 ---@param tg function|nil 这个效果的影响目标(全域)
---@param loc_self integer|nil 效果的影响的自己区域 ---@param loc_self number|nil 这个效果影响的自己区域,影响全域范围才需填
---@param loc_op integer|nil 效果的影响的对方区域 ---@param loc_op number|nil 这个效果影响的对方区域,影响全域范围才需填
---@param reset integer|nil 效果的重置条件 ---@param reset number|nil 效果的重置条件
---@param mc Card|nil 效果的拥有者, 没有则为 c ---@param hc Card|nil 效果的拥有者, 没有则为 c
function VgD.EffectTypeContinuous(c, m, loc, typ, code, val, con, tg, loc_self, loc_op, reset, mc) ---@return Effect 这个效果
function VgD.EffectTypeContinuous(c, m, loc, typ, code, val, con, tg, loc_self, loc_op, reset, hc)
-- check func -- check func
local cm = _G["c"..m] local fchk = VgF.IllegalFunctionCheck("EffectTypeContinuous")
if not VgF.FunctionLegal(con, m, "con") then return end if fchk.con(con) or fchk.tg(tg) then return end
if not VgF.FunctionLegal(tg, m, "tg") then return end
if not VgF.CardLegal(c, m, "c") then return end
-- set param -- set param
if not cm.is_has_continuous and not reset then cm.is_has_continuous = true end local cm = _G["c"..(m or c:GetOriginalCode())]
local con_exf = VgF.True cm.is_has_continuous = cm.is_has_continuous or not reset
loc = loc or LOCATION_MZONE loc, con = VgF.GetLocCondition(loc, con)
if loc == LOCATION_RZONE then hc = hc or c
loc, con_exf = LOCATION_MZONE, VgF.RMonsterCondition
elseif loc == LOCATION_VZONE then
loc, con_exf = LOCATION_MZONE, VgF.VMonsterCondition
end
-- set effect -- set effect
local e1 = Effect.CreateEffect(c) local e = Effect.CreateEffect(c)
e1:SetType(typ or EFFECT_TYPE_SINGLE) e:SetType(typ or EFFECT_TYPE_SINGLE)
e1:SetCode(code) e:SetCode(code)
e1:SetRange(loc) e:SetRange(loc)
if typ == EFFECT_TYPE_FIELD then e1:SetTargetRange(loc_self or 0, loc_op or 0) end if typ == EFFECT_TYPE_FIELD then e:SetTargetRange(loc_self or 0, loc_op or 0) end
e1:SetCondition(function(e, tp, eg, ep, ev, re, r, rp) e:SetCondition(con)
return (not con or con(e, tp, eg, ep, ev, re, r, rp)) and con_exf(e) e:SetValue(val)
end) if tg then e:SetTarget(tg) end
e1:SetValue(val) if reset then e:SetReset(RESET_EVENT + RESETS_STANDARD + reset) end
if tg then e1:SetTarget(tg) end hc:RegisterEffect(e)
if reset then e1:SetReset(RESET_EVENT + RESETS_STANDARD + reset) end return e
(mc or c):RegisterEffect(e1)
return e1
end end
function VgD.EffectTypeContinuousChangeAttack(c, m, loc, typ, val, con, tg, loc_self, loc_op, reset, mc)
return VgD.EffectTypeContinuous(c, m, loc, typ, EFFECT_UPDATE_ATTACK, val, con, tg, loc_self, loc_op, reset, mc) ---【永】力量数值变更
---@param c Card 效果的创建者
---@param m number|nil 效果的创建者的卡号
---@param loc number 生效的区域
---@param typ number 只影响自己,则填EFFECT_TYPE_SINGLE;<br>影响场上,则填EFFECT_TYPE_FIELD。
---@param val number 变更的数值
---@param con function|nil 这个效果的条件函数
---@param tg function|nil 这个效果的影响目标(全域)
---@param loc_self number|nil 这个效果影响的自己区域,影响全域范围才需填
---@param loc_op number|nil 这个效果影响的对方区域,影响全域范围才需填
---@param reset number|nil 效果的重置条件
---@param hc Card|nil 效果的拥有者, 没有则为 c
---@return Effect 这个效果
function VgD.EffectTypeContinuousChangeAttack(c, m, loc, typ, val, con, tg, loc_self, loc_op, reset, hc)
return VgD.EffectTypeContinuous(c, m, loc, typ, EFFECT_UPDATE_ATTACK, val, con, tg, loc_self, loc_op, reset, hc)
end end
function VgD.EffectTypeContinuousChangeDefense(c, m, typ, val, con, tg, loc_self, loc_op, reset, mc)
return VgD.EffectTypeContinuous(c, m, LOCATION_GZONE, typ, EFFECT_UPDATE_DEFENSE, val, con, tg, loc_self, loc_op, reset, mc) ---【永】盾护数值变更
---@param c Card 效果的创建者
---@param m number|nil 效果的创建者的卡号
---@param typ number 只影响自己,则填EFFECT_TYPE_SINGLE;<br>影响场上,则填EFFECT_TYPE_FIELD。
---@param val number 变更的数值
---@param con function|nil 这个效果的条件函数
---@param tg function|nil 这个效果的影响目标(全域)
---@param loc_self number|nil 这个效果影响的自己区域,影响全域范围才需填
---@param loc_op number|nil 这个效果影响的对方区域,影响全域范围才需填
---@param reset number|nil 效果的重置条件
---@param hc Card|nil 效果的拥有者, 没有则为 c
---@return Effect 这个效果
function VgD.EffectTypeContinuousChangeDefense(c, m, typ, val, con, tg, loc_self, loc_op, reset, hc)
return VgD.EffectTypeContinuous(c, m, LOCATION_GZONE, typ, EFFECT_UPDATE_DEFENSE, val, con, tg, loc_self, loc_op, reset, hc)
end end
function VgD.EffectTypeContinuousChangeStar(c, m, typ, val, con, tg, loc_self, loc_op, reset, mc)
local e1 = VgD.EffectTypeContinuous(c, m, LOCATION_MZONE, typ, EFFECT_UPDATE_LSCALE, val, con, tg, loc_self, loc_op, reset, mc) ---【永】暴击数值变更
local e2 = VgD.EffectTypeContinuous(c, m, LOCATION_MZONE, typ, EFFECT_UPDATE_RSCALE, val, con, tg, loc_self, loc_op, reset, mc) ---@param c Card 效果的创建者
---@param m number|nil 效果的创建者的卡号
---@param typ number 只影响自己,则填EFFECT_TYPE_SINGLE;<br>影响场上,则填EFFECT_TYPE_FIELD。
---@param val number 变更的数值
---@param con function|nil 这个效果的条件函数
---@param tg function|nil 这个效果的影响目标(全域)
---@param loc_self number|nil 这个效果影响的自己区域,影响全域范围才需填
---@param loc_op number|nil 这个效果影响的对方区域,影响全域范围才需填
---@param reset number|nil 效果的重置条件
---@param hc Card|nil 效果的拥有者, 没有则为 c
---@return Effect 两个效果
function VgD.EffectTypeContinuousChangeStar(c, m, typ, val, con, tg, loc_self, loc_op, reset, hc)
local e1 = VgD.EffectTypeContinuous(c, m, LOCATION_MZONE, typ, EFFECT_UPDATE_LSCALE, val, con, tg, loc_self, loc_op, reset, hc)
local e2 = VgD.EffectTypeContinuous(c, m, LOCATION_MZONE, typ, EFFECT_UPDATE_RSCALE, val, con, tg, loc_self, loc_op, reset, hc)
return e1, e2 return e1, e2
end end
function VgD.TriggerCountUp(c, m, num, reset, tc)
local cm = _G["c"..m] ---【永】驱动数值变更
if not cm.is_has_continuous and not reset then cm.is_has_continuous = true end ---@param c Card 效果的创建者
if tc then tc = VgF.ReturnCard(tc) else tc = c end ---@param m number|nil 效果的创建者的卡号
local e1 = Effect.CreateEffect(c) ---@param num number 变更的数值
e1:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS) ---@param con function|nil 这个效果的条件函数
e1:SetRange(LOCATION_MZONE) ---@param reset number|nil 效果的重置条件
e1:SetCode(EVENT_CUSTOM + EVENT_TRIGGERCOUNTUP) ---@param hc Card|nil 效果的拥有者, 没有则为 c
e1:SetProperty(EFFECT_FLAG_DELAY) ---@return Effect 这个效果
e1:SetCondition(function (e, tp, eg, ep, ev, re, r, rp) function VgD.TriggerCountUp(c, m, num, con, reset, hc)
return VgF.ReturnCard(eg) == e:GetHandler() -- check func
end) if VgF.IllegalFunctionCheck("TriggerCountUp").con(con) then return end
if VgF.GetValueType(reset) == "number" then e1:SetReset(RESET_EVENT + RESETS_STANDARD + reset) end -- set param
e1:SetOperation(VgD.TriggerCountUpOperation(num)) local cm = _G["c"..(m or c:GetOriginalCode())]
tc:RegisterEffect(e1) cm.is_has_continuous = cm.is_has_continuous or not reset
return e1 local condition = function(e, tp, eg, ep, ev, re, r, rp)
return (not con or con(e, tp, eg, ep, ev, re, r, rp)) and VgF.ReturnCard(eg) == e:GetHandler()
end
hc = hc and VgF.ReturnCard(hc) or c
-- set effect
local e = Effect.CreateEffect(c)
e:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
e:SetRange(LOCATION_MZONE)
e:SetCode(EVENT_CUSTOM + EVENT_TRIGGERCOUNTUP)
e:SetProperty(EFFECT_FLAG_DELAY)
e:SetCondition(condition)
if reset then e:SetReset(RESET_EVENT + RESETS_STANDARD + reset) end
e:SetOperation(VgD.TriggerCountUpOperation(num))
hc:RegisterEffect(e)
return e
end end
function VgD.TriggerCountUpOperation(num) function VgD.TriggerCountUpOperation(num)
return function (e, tp, eg, ep, ev, re, r, rp) return function (e, tp, eg, ep, ev, re, r, rp)
...@@ -1492,104 +1620,95 @@ function VgD.TriggerCountUpOperation(num) ...@@ -1492,104 +1620,95 @@ function VgD.TriggerCountUpOperation(num)
c:RegisterFlagEffect(FLAG_ATTACK_TRIGGER, RESET_EVENT + RESETS_STANDARD, 0, 1, label) c:RegisterFlagEffect(FLAG_ATTACK_TRIGGER, RESET_EVENT + RESETS_STANDARD, 0, 1, label)
end end
end end
function VgD.GlobalCheckEffect(c, m, code, con, op)
local typ = EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS
local cm = _G["c"..m]
if not cm.global_check then
cm.global_check = true
local ge1 = Effect.CreateEffect(c)
ge1:SetType(typ)
ge1:SetCode(code)
if VgF.GetValueType(con) == "function" then ge1:SetCondition(con) end
if VgF.GetValueType(op) == "function" then ge1:SetOperation(op) else
ge1:SetOperation(function (e, tp, eg, ep, ev, re, r, rp)
Duel.RegisterFlagEffect(tp, m, RESET_PHASE + PHASE_END, 0, 1)
end)
end
Duel.RegisterEffect(ge1, 0)
end
end
function VgD.CannotBeTarget(c, m, con, val, loc, tg, range) ---【永】这个单位不会被对手的卡片的效果选择
local cm = _G["c"..m] ---@param c Card 拥有这个效果的卡
local f = VgF.True ---@param m number|nil 效果的拥有者的卡号
if not cm.is_has_continuous then cm.is_has_continuous = true end ---@param loc number 生效的区域
if not loc then loc = LOCATION_MZONE end ---@param typ number 只影响自己,则填EFFECT_TYPE_SINGLE;<br>影响场上,则填EFFECT_TYPE_FIELD。
if loc == LOCATION_RZONE then loc = LOCATION_MZONE f = VgF.RMonsterCondition end ---@param val number 不会被 val 的效果选择
if loc == LOCATION_VZONE then loc = LOCATION_MZONE f = VgF.VMonsterCondition end ---@param con function|nil 这个效果的条件函数
if VgF.GetValueType(tg) == "function" or VgF.GetValueType(tg) == "number" then ---@param tg function|nil 这个效果的影响目标,影响全域范围才需填
if VgF.GetValueType(range) ~= "tabel" then range = {} end ---@param loc_self number|nil 这个效果影响的自己区域,影响全域范围才需填
if #range == 0 then range = {LOCATION_MZONE, 0} ---@return Effect 这个效果
elseif #range == 1 then table.insert(range, 0) function VgD.CannotBeTarget(c, m, loc, typ, val, con, tg, loc_self)
end -- check func
local e1 = Effect.CreateEffect(c) local fchk = VgF.IllegalFunctionCheck("CannotBeTarget")
e1:SetType(EFFECT_TYPE_FIELD) if fchk.con(con) or fchk.tg(tg) then return end
e1:SetRange(loc) -- set param
e1:SetTargetRange(range[1], range[2]) local cm = _G["c"..(m or c:GetOriginalCode())]
e1:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET) cm.is_has_continuous = true
e1:SetCondition(function (e, tp, eg, ep, ev, re, r, rp) return (VgF.GetValueType(con) ~= "function" or con(e, tp, eg, ep, ev, re, r, rp)) and f(e) end) typ = typ or EFFECT_TYPE_SINGLE
if VgF.GetValueType(val) == "function" then e1:SetValue(val) else loc, con = VgF.GetLocCondition(loc, con)
e1:SetValue(function (e, re, rp) val = val or function(e, re, rp)
return rp == 1 - e:GetHandlerPlayer() return rp == 1 - e:GetHandlerPlayer()
end)
end end
if VgF.GetValueType(tg) == "function" then e1:SetTarget(tg) end -- set effect
c:RegisterEffect(e1) local e = Effect.CreateEffect(c)
return e1 e:SetRange(loc)
e:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
e:SetCondition(con)
e:SetValue(val)
if typ == EFFECT_TYPE_FIELD or tg or loc_self then
e:SetType(EFFECT_TYPE_FIELD)
e:SetTargetRange(loc_self or LOCATION_MZONE , 0)
if tg then e:SetTarget(tg) end
else else
local e1 = Effect.CreateEffect(c) e:SetType(EFFECT_TYPE_SINGLE)
e1:SetType(EFFECT_TYPE_SINGLE) e:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e1:SetRange(loc)
e1:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
if VgF.GetValueType(con) == "function" then e1:SetCondition(con) end
if VgF.GetValueType(val) == "function" then e1:SetValue(val) else
e1:SetValue(function (e, re, rp)
return rp == 1 - e:GetHandlerPlayer()
end)
end
c:RegisterEffect(e1)
return e1
end end
c:RegisterEffect(e)
return e
end end
---【永】【指令区】:你的指令区中没有世界卡以外的设置指令卡的话,根据你的指令区中的卡的张数生效以下全部的效果。
---●1张——你的世界卡的内容变为黑夜。
---●2张以上——你的世界卡的内容变为深渊黑夜。
---@param c Card 要注册以上功能的卡
---@param m number|nil 效果的创建者的卡号
---@return Effect 两个效果
function VgD.NightEffect(c, m) function VgD.NightEffect(c, m)
local cm = _G["c"..m] -- set param
if not cm.is_has_continuous then cm.is_has_continuous = true end local cm = _G["c"..(m or c:GetOriginalCode())]
cm.is_has_continuous = true
local condition = function(equl_one)
return function(e)
local og = vgf.GetMatchingGroup(nil, e:GetHandlerPlayer(), LOCATION_ORDER, 0, nil)
if og:IsExists(VgD.NightFilter, 1, nil) then return false end
if equl_one then return #og == 1 end
return #og >= 2
end
end
-- set effect
local e1 = Effect.CreateEffect(c) local e1 = Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD) e1:SetType(EFFECT_TYPE_FIELD)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET) e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetCode(AFFECT_CODE_NIGHT) e1:SetCode(AFFECT_CODE_NIGHT)
e1:SetRange(LOCATION_ORDER) e1:SetRange(LOCATION_ORDER)
e1:SetTargetRange(1, 0) e1:SetTargetRange(1, 0)
e1:SetCondition(function (e) e1:SetCondition(condition(true))
local tp = e:GetHandlerPlayer()
return not vgf.IsExistingMatchingCard(VgD.NightFilter, tp, LOCATION_ORDER, 0, 1, nil) and vgf.GetMatchingGroupCount(nil, tp, LOCATION_ORDER, 0, nil) == 1
end)
c:RegisterEffect(e1)
return e1
end
function VgD.DeepNightEffect(c, m)
local cm = _G["c"..m]
if not cm.is_has_continuous then cm.is_has_continuous = true end
local e1 = Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e1:SetCode(AFFECT_CODE_DEEP_NIGHT)
e1:SetRange(LOCATION_ORDER)
e1:SetTargetRange(1, 0)
e1:SetCondition(function (e)
local tp = e:GetHandlerPlayer()
return not vgf.IsExistingMatchingCard(VgD.NightFilter, tp, LOCATION_ORDER, 0, 1, nil) and vgf.GetMatchingGroupCount(nil, tp, LOCATION_ORDER, 0, nil) >= 2
end)
c:RegisterEffect(e1) c:RegisterEffect(e1)
return e1 local e2 = e1:Clone()
e2:SetCode(AFFECT_CODE_DEEP_NIGHT)
e2:SetCondition(condition(false))
c:RegisterEffect(e2)
return e1, e2
end end
function VgD.NightFilter(c) function VgD.NightFilter(c)
return not c:IsSetCard(0x5040) and c:IsType(TYPE_CONTINUOUS) return not c:IsSetCard(0x5040) and c:IsType(TYPE_CONTINUOUS)
end end
---【永】【指令区】:对手在可以将后防者通常CALL出场的时段,对手可以将以下的效果执行。
---●灵魂爆发1。这样做了的话,选择被收容的他自己的1张卡,CALL到他自己的R上。
---●计数爆发1。这样做了的话,选择被收容的他自己的2张卡,CALL到他自己的R上。
---@param c Card 要注册以上功能的卡
---@param m number|nil 效果的创建者的卡号
---@return Effect 两个效果
function VgD.CallInPrison(c, m) function VgD.CallInPrison(c, m)
local cm = _G["c"..m] -- set param
if not cm.is_has_continuous then cm.is_has_continuous = true end local cm = _G["c"..(m or c:GetOriginalCode())]
cm.is_has_continuous = true
-- set effect
local e1 = Effect.CreateEffect(c) local e1 = Effect.CreateEffect(c)
e1:SetDescription(VgF.Stringid(VgID, 11)) e1:SetDescription(VgF.Stringid(VgID, 11))
e1:SetType(EFFECT_TYPE_FIELD) e1:SetType(EFFECT_TYPE_FIELD)
...@@ -1648,3 +1767,40 @@ function VgD.CallInPrisonFilter(c, e, tp) ...@@ -1648,3 +1767,40 @@ function VgD.CallInPrisonFilter(c, e, tp)
return c:GetFlagEffect(FLAG_IMPRISON) > 0 and (vgf.IsCanBeCalled(c, e, tp) or not c:IsType(TYPE_MONSTER)) return c:GetFlagEffect(FLAG_IMPRISON) > 0 and (vgf.IsCanBeCalled(c, e, tp) or not c:IsType(TYPE_MONSTER))
end end
--其他----------------------------------------------------------------------------------------
---建立一个全局检查
---@param c Card 效果的创建者
---@param m number|nil 效果的创建者的卡号
---@param code number 触发的时点
---@param op function|nil 这个效果的处理函数
---@param con function|nil 这个效果的条件函数
function VgD.GlobalCheckEffect(c, m, code, con, op)
-- check func
local fchk = VgF.IllegalFunctionCheck("GlobalCheckEffect")
if fchk.con(con) or fchk.op(op) then return end
-- set param and check global
m = m or c:GetOriginalCode()
local cm = _G["c"..m]
cm.global_check = cm.global_check or {}
local code_tab = cm.global_check[code] or {}
local key, tab = next(code_tab)
if next(code_tab) then
while key do
if tab.con == con and tab.op == op then return end
key, tab = next(code_tab, key)
end
end
cm.global_check[code][#code_tab + 1] = {con = con, op = op}
op = op or function(e, tp, eg, ep, ev, re, r, rp)
Duel.RegisterFlagEffect(1 - tp, m, RESET_PHASE + PHASE_END, 0, 1)
Duel.RegisterFlagEffect(tp, m, RESET_PHASE + PHASE_END, 0, 1)
end
-- set effect
local ge = Effect.CreateEffect(c)
ge:SetType(EFFECT_TYPE_FIELD + EFFECT_TYPE_CONTINUOUS)
ge:SetCode(code)
if con then ge:SetCondition(con) end
ge:SetOperation(op)
Duel.RegisterEffect(ge, 0)
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