本帖最后由 muscipular 于 2023-10-11 23:35 编辑
死亡删除角色
- ---硬汉模式
- local Module = ModuleBase:createModule('hardcoreMode')
- local death = {}
-
- --- 加载模块钩子
- function Module:onLoad()
- self:logInfo('load')
- NLG.SetDexRearrangeRate(1, 0);
- NLG.SetCriticalDamageAddition(1, 1.2);
- self:regCallback('BattleOverEvent', OrderedCallback(Func.bind(self.onBattleOver, self), -999));
- self:regCallback('BattleExitEvent', OrderedCallback(Func.bind(self.onBattleExit, self), -999));
- self:regCallback('ResetCharaBattleStateEvent', OrderedCallback(Func.bind(self.onResetCharaBattleStateEvent, self), -999));
- end
-
- function Module:onBattleOver(battleIndex)
- for i = 0, 9 do
- local ch = Battle.GetPlayIndex(battleIndex, i);
- self:logInfo('ch', ch, Char.GetData(ch, CONST.CHAR_战死));
- if ch >=0 and Char.IsPlayer(ch) then
- if Char.GetData(ch, CONST.CHAR_战死) == 1 then
- NLG.SystemMessage(ch, '你的角色已死亡,将被永久删除');
- death['#'..ch] = ch;
- end
- end
- end
- end
-
- function Module:onBattleExit(ch, battleIndex, type)
- self:logInfo('onBattleExit', battleIndex, ch, type);
- if type == 2 then
- if ch >=0 and Char.IsPlayer(ch) then
- NLG.SystemMessage(ch, '你的角色已死亡,将被永久删除');
- death['#'..ch] = ch;
- end
- end
- end
-
- function Module:onResetCharaBattleStateEvent(ch)
- self:logInfo('ResetCharaBattleStateEvent', ch);
- if death['#'..ch] == ch then
- self:delChara(ch);
- end
- death['#'..ch] = nil;
- end
-
- function Module:delChara(ch)
- local cdkey = Char.GetData(ch, CONST.CHAR_CDK);
- local registNumber = Char.GetData(ch, CONST.CHAR_RegistNumber);
- NLG.SystemMessage(ch, '你的角色已死亡,将被永久删除');
- NLG.UpChar(ch);
- NLG.DropPlayer(ch);
- NL.DelNpc(ch);
- SQL.QueryEx('delete from tbl_character where cdkey = ? and registNumber = ?', cdkey, registNumber);
- SQL.QueryEx('DELETE FROM tbl_skill WHERE CdKey=? and RegistNumber=?', cdkey, registNumber);
- SQL.QueryEx('DELETE FROM tbl_addressbook WHERE CdKey=? and RegistNumber=?', cdkey, registNumber);
- SQL.QueryEx('DELETE FROM tbl_item WHERE CdKey=? and RegistNumber=?', cdkey, registNumber);
- SQL.QueryEx('DELETE FROM tbl_pet WHERE CdKey=? and RegistNumber=?', cdkey, registNumber);
- SQL.querySQL('delete from tbl_lock where CdKey = ?', cdkey);
- SQL.querySQL('delete from tbl_lock2 where CdKey = ?', cdkey);
- end
-
- --- 卸载模块钩子
- function Module:onUnload()
- self:logInfo('unload')
- end
-
- return Module;
复制代码
|