路旁的落叶
- CN币
- 0 颗
- 威望
- 4
- 贡献
- 7
- UID
- 690
- QQ

- 微信Wechat
- liveforwind
- 居住地
- 中国
|
如何实现血魔池的开关,在战斗结束后正常恢复(带英雄版本)。 我的问题是如何在战斗函数中获取player?
----血魔池开关展示实现--- (这一步没问题)
function Module:wanjiashuohua(player, msg) 【利用发言函数可以获取player】
-- 先获取基础数据
local lpPool = tonumber(Field.Get(player, 'LpPool')) or 0
local fpPool = tonumber(Field.Get(player, 'FpPool')) or 0
local xmon_switch = tonumber(Field.Get(player, 'xmon_switch')) or 0
local xmon_status = (xmon_switch == 0) and "关闭" or "开启"
-- 查询功能
if msg == '/xm' then
NLG.Say(player, -1,
'生命之泉剩余:'..lpPool..
',魔力之泉剩余:'..fpPool..
',状态:'..xmon_status,
CONST.颜色_黄色, 3)
return 1
end
-- 开关功能
if msg == '/xmon' then
if xmon_switch == 0 then
Field.Set(player, 'xmon_switch', 1)
NLG.SystemMessage(player, '生命/魔力之泉已开启')
NLG.Say(player, -1,
'生命之泉剩余:'..lpPool..
',魔力之泉剩余:'..fpPool,
CONST.颜色_白色, 3)
else
Field.Set(player, 'xmon_switch', 0)
NLG.SystemMessage(player, '生命/魔力之泉已关闭')
end
return 0
end
return 1
end
------战斗后根据血魔池状态决定是否回复----
function Module nBattleOver(battleIndex) 【有且只有一个battleIndex 无法传player】
local poss={}
for i = 0, 9 do
table.insert(poss,i)
end
_.each(poss,function(pos)
local charIndex = Battle.GetPlayer(battleIndex, pos);
if Char.GetData(charIndex,CONST.CHAR_类型)~=CONST.对象类型_人 then
-- if(battleIndex==0)then
-- local xmon_switch = tonumber(Field.Get(Char, 'xmon_switch')) or 0 【根本不会执行如何获取PLAYER?】
--NLG.Say('xmon_switch:',xmon_switch)
-- end
return
end
NLG.SortItem(charIndex);
if Char.IsDummy(charIndex) then
return
end
NLG.UpChar(charIndex);
Item.UpItem(charIndex, -1);
-- 获取英雄
local campHeroesData = getModule('heroesFn'):getCampHeroesData(charIndex)
for k,v in pairs(campHeroesData) do
if Char.GetData(charIndex,%对象_交易开关%) == 1 then
self:clearBag(charIndex,v.index)
end
end
--- 血魔池开关判断
if xmon_switch == 1 then
-- 玩家自己补血魔
self:heal(charIndex,charIndex)
-- 玩家的英雄补血魔
for k,v in pairs(campHeroesData) do
self:heal(charIndex,v.index)
Item.UpItem(v.index, -1);
NLG.UpChar(v.index);
end
end
---
end)
end |
|