找回密码
 立即注册
查看: 12|回复: 0

[提问/求助] 脚本问题求助

[复制链接]
路旁的落叶

1

主题

6

回帖

22

积分
CN币
0 颗


威望
4

贡献
7

UID
690

QQ
QQ

微信Wechat
liveforwind

居住地
中国

发表于 9 小时前 | 显示全部楼层 |阅读模式
如何实现血魔池的开关,在战斗结束后正常恢复(带英雄版本)。 我的问题是如何在战斗函数中获取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 ModulenBattleOver(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
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|CN魔力实验室

GMT+8, 2025-4-27 20:49 , Processed in 0.059935 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表