现在的位置:首页 > 脚本相关(C++) >
reset 命令Bug的修正,及自己增加GM命令的方法
w1w218发布于2008-01-05 11:06:35 芒果中文
在测试时忽然发现我的 10级战士 远程AP竟然有400多,吓我一大跳!
然后在反复试验后发现问题出在,使用 levelup 命令升级后,再用 reset stats 命令 回到初始状态的时候,程序漏了把远程AP 复位。
修正方法:
打开 Level3.cpp
找到 bool ChatHandler::HandleResetCommand (const char * args)
蓝色部分为添加的语句。
| ... player->SetStat(STAT_STRENGTH,info->strength ); player->SetStat(STAT_AGILITY,info->agility ); player->SetStat(STAT_STAMINA,info->stamina ); player->SetStat(STAT_INTELLECT,info->intellect ); player->SetStat(STAT_SPIRIT,info->spirit ); player->SetArmor(info->basearmor ); player->SetUInt32Value(UNIT_FIELD_ATTACK_POWER, 0 ); player->SetUInt32Value(UNIT_FIELD_RANGED_ATTACK_POWER, 0 ); // modify by w1w player->SetHealth(info->health); player->SetMaxHealth(info->health); |
似乎没有一个能直接添加天赋点的命令,反正我是没找到。想想10级的人物就会了全部的天赋,多好玩,那就自己加一个
需要修改 chat.h, chat.cpp, level1.cpp,当然不要忘了在数据库里command表里也加上
chat.h:
在class ChatHandler 的 protected 部分
| bool HandleTargetObjectCommand(const char* args); bool HandleDelObjectCommand(const char* args); bool HandlesetTpCommand (const char* args); // modify by w1w // shutdown server bool ShutDown(const char* args); bool CancelShutdown (const char* args); |
chat.cpp:
static ChatCommand commandTable 里面
| { "acct", 0, &ChatHandler::HandleAcctCommand, "", NULL }, { "setTp", 1, &ChatHandler::HandlesetTpCommand, "", NULL }, // modify by w1w { "addmove", 2, &ChatHandler::HandleAddMoveCommand, "", NULL }, |
level1.cpp:
加上下面这一段
| bool ChatHandler::HandlesetTpCommand (const char* args) // modify by w1w { int tp = atoi((char*)args); if (tp>0) { Player* player = m_session->GetPlayer(); if(!player) { SendSysMessage(LANG_NO_CHAR_SELECTED); return true; } player->SetUInt32Value(PLAYER_CHARACTER_POINTS1, tp); return true; } return false; } |
一句话,1、在chat.h里修改ChatHandler类;2、修改chat.cpp里的command列表;3、在 level1.cpp里加具体代码;4、在command表里加命令。
