找回密码
 立即注册
查看: 15|回复: 1

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

[复制链接]
路旁的落叶

1

主题

6

回帖

22

积分
CN币
0 颗


威望
4

贡献
7

UID
690

QQ
QQ

微信Wechat
liveforwind

居住地
中国

发表于 9 小时前 | 显示全部楼层 |阅读模式
本帖最后由 liveforwind 于 2025-4-27 21:12 编辑

如何实现血魔池的开关,在战斗结束后正常恢复(带英雄版本)。 我的问题是如何在战斗函数中获取player?
----血魔池开关展示实现--- (这一步没问题)
【利用发言函数可以获取player】
  1. function Module:wanjiashuohua(player, msg)
  2.     -- 先获取基础数据
  3.     local lpPool = tonumber(Field.Get(player, 'LpPool')) or 0
  4.     local fpPool = tonumber(Field.Get(player, 'FpPool')) or 0
  5.     local xmon_switch = tonumber(Field.Get(player, 'xmon_switch')) or 0
  6.     local xmon_status = (xmon_switch == 0) and "关闭" or "开启"
  7.    
  8.     -- 查询功能
  9.     if msg == '/xm' then
  10.         NLG.Say(player, -1,
  11.             '生命之泉剩余:'..lpPool..
  12.             ',魔力之泉剩余:'..fpPool..
  13.             ',状态:'..xmon_status,
  14.             CONST.颜色_黄色, 3)
  15.         return 1
  16.     end
  17.    
  18.     -- 开关功能
  19.     if msg == '/xmon' then
  20.         if xmon_switch == 0 then
  21.             Field.Set(player, 'xmon_switch', 1)
  22.             NLG.SystemMessage(player, '生命/魔力之泉已开启')
  23.             NLG.Say(player, -1,
  24.                 '生命之泉剩余:'..lpPool..
  25.                 ',魔力之泉剩余:'..fpPool,
  26.                 CONST.颜色_白色, 3)
  27.         else
  28.             Field.Set(player, 'xmon_switch', 0)
  29.             NLG.SystemMessage(player, '生命/魔力之泉已关闭')
  30.         end
  31.         return 0
  32.     end
  33.    
  34.     return 1
  35. end
  36. ------战斗后根据血魔池状态决定是否回复----
  37. function Module:onBattleOver(battleIndex)   【有且只有一个battleIndex 无法传player】
  38.   local poss={}
  39.   for i = 0, 9 do
  40.     table.insert(poss,i)
  41.   end
  42.   _.each(poss,function(pos)
  43.     local charIndex = Battle.GetPlayer(battleIndex, pos);

  44.     if Char.GetData(charIndex,CONST.CHAR_类型)~=CONST.对象类型_人 then
  45.          -- if(battleIndex==0)then

  46.          -- local xmon_switch = tonumber(Field.Get(Char, 'xmon_switch')) or 0  【根本不会执行如何获取PLAYER?】
  47.                     --NLG.Say('xmon_switch:',xmon_switch)
  48.          -- end
  49.       return
  50.     end

  51.     NLG.SortItem(charIndex);
  52.    
  53.     if Char.IsDummy(charIndex) then
  54.       return
  55.     end
  56.   NLG.UpChar(charIndex);
  57.   Item.UpItem(charIndex, -1);
  58.   -- 获取英雄
  59.     local campHeroesData = getModule('heroesFn'):getCampHeroesData(charIndex)
  60.         for k,v in pairs(campHeroesData) do
  61.                 if Char.GetData(charIndex,%对象_交易开关%) == 1 then
  62.     self:clearBag(charIndex,v.index)
  63.                 end
  64.     end
  65.         --- 血魔池开关判断
  66.         if xmon_switch == 1 then
  67.         -- 玩家自己补血魔
  68.     self:heal(charIndex,charIndex)
  69.     -- 玩家的英雄补血魔
  70.                 for k,v in pairs(campHeroesData) do
  71.                 self:heal(charIndex,v.index)
  72.                 Item.UpItem(v.index, -1);
  73.                 NLG.UpChar(v.index);
  74.                 end
  75.         end
  76.         ---

  77.       
  78.   end)
  79.   

  80. end
复制代码


万物创造者

188

主题

207

回帖

2341

积分
CN币
1 颗


威望
574

贡献
792

UID
1

QQ
QQ

微信Wechat
ahsinsoft

居住地
中国 上海市 杨浦区 定海路街道

发表于 23 分钟前 | 显示全部楼层
  1. 请重新贴出代码,编辑帖子界面,使用高级,点击<>图标,把代码插入。


  2. 像我这样
复制代码


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-4-27 21:26 , Processed in 0.068275 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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