cgmsv引擎论坛

 找回密码
 注册/Sign up
搜索
查看: 1142|回复: 5

[LUA] 硬汉模式

[复制链接]
发表于 2023-10-11 23:34:12 | 显示全部楼层 |阅读模式
本帖最后由 muscipular 于 2023-10-11 23:35 编辑

死亡删除角色

  1. ---硬汉模式
  2. local Module = ModuleBase:createModule('hardcoreMode')
  3. local death = {}
  4. --- 加载模块钩子
  5. function Module:onLoad()
  6.   self:logInfo('load')
  7.   NLG.SetDexRearrangeRate(1, 0);
  8.   NLG.SetCriticalDamageAddition(1, 1.2);
  9.   self:regCallback('BattleOverEvent', OrderedCallback(Func.bind(self.onBattleOver, self), -999));
  10.   self:regCallback('BattleExitEvent', OrderedCallback(Func.bind(self.onBattleExit, self), -999));
  11.   self:regCallback('ResetCharaBattleStateEvent', OrderedCallback(Func.bind(self.onResetCharaBattleStateEvent, self), -999));
  12. end
  13. function Module:onBattleOver(battleIndex)
  14.   for i = 0, 9 do
  15.     local ch = Battle.GetPlayIndex(battleIndex, i);
  16.     self:logInfo('ch', ch, Char.GetData(ch, CONST.CHAR_战死));
  17.     if ch >=0 and Char.IsPlayer(ch) then
  18.       if Char.GetData(ch, CONST.CHAR_战死) == 1 then
  19.         NLG.SystemMessage(ch, '你的角色已死亡,将被永久删除');
  20.         death['#'..ch] = ch;
  21.       end
  22.     end
  23.   end
  24. end
  25. function Module:onBattleExit(ch, battleIndex, type)
  26.   self:logInfo('onBattleExit', battleIndex, ch, type);
  27.   if type == 2 then
  28.     if ch >=0 and Char.IsPlayer(ch) then
  29.       NLG.SystemMessage(ch, '你的角色已死亡,将被永久删除');
  30.       death['#'..ch] = ch;
  31.     end
  32.   end
  33. end
  34. function Module:onResetCharaBattleStateEvent(ch)
  35.   self:logInfo('ResetCharaBattleStateEvent', ch);
  36.   if death['#'..ch] == ch then
  37.     self:delChara(ch);
  38.   end
  39.   death['#'..ch] = nil;
  40. end
  41. function Module:delChara(ch)
  42.   local cdkey = Char.GetData(ch, CONST.CHAR_CDK);
  43.   local registNumber = Char.GetData(ch, CONST.CHAR_RegistNumber);
  44.   NLG.SystemMessage(ch, '你的角色已死亡,将被永久删除');
  45.   NLG.UpChar(ch);
  46.   NLG.DropPlayer(ch);
  47.   NL.DelNpc(ch);
  48.   SQL.QueryEx('delete from tbl_character where cdkey = ? and registNumber = ?', cdkey, registNumber);
  49.   SQL.QueryEx('DELETE FROM tbl_skill WHERE CdKey=? and RegistNumber=?', cdkey, registNumber);
  50.   SQL.QueryEx('DELETE FROM tbl_addressbook WHERE CdKey=? and RegistNumber=?', cdkey, registNumber);
  51.   SQL.QueryEx('DELETE FROM tbl_item WHERE CdKey=? and RegistNumber=?', cdkey, registNumber);
  52.   SQL.QueryEx('DELETE FROM tbl_pet WHERE CdKey=? and RegistNumber=?', cdkey, registNumber);
  53.   SQL.querySQL('delete from tbl_lock where CdKey = ?', cdkey);
  54.   SQL.querySQL('delete from tbl_lock2 where CdKey = ?', cdkey);
  55. end
  56. --- 卸载模块钩子
  57. function Module:onUnload()
  58.   self:logInfo('unload')
  59. end
  60. return Module;
复制代码


Rank: 1

发表于 2023-10-12 00:07:06 | 显示全部楼层
逆天的思路
参考了,我将改成宠物死亡直接放生

Rank: 1

发表于 2023-10-12 08:46:58 | 显示全部楼层
暗黑like,专家模式来袭

Rank: 1

发表于 2023-10-15 14:35:10 | 显示全部楼层
哈哈这个可以

Rank: 1

发表于 2023-10-19 19:33:29 | 显示全部楼层
好好好
可以改成pk模式
您需要登录后才可以回帖 登录 | 注册/Sign up

本版积分规则

手机版|cgmsv引擎论坛

GMT+8, 2024-11-21 22:38 , Processed in 0.161344 second(s), 8 queries , Gzip On, MemCached On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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