该GM命令的适用方法:
.warp <方向> <距离> <on>
例如1: .warp y 5 on
这个你将要向前传送5码距离
例如2: .warp y 5
这个你将要向前传送5码距离, 有可能你会掉落虚空
例如3: .warp y -5
这个你将要向后传送5码距离
y = 向前或则向后
x = 向左或则向右
z = 向上或则向下
o = 旋转吧??这个不太清楚了
下面是代码
// LilleCarl made this based on code from Pwntzyou. So fuck you.
#include "Chat.h"
#include "Language.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "Opcodes.h"
#include "Common.h"
#define MSG_COLOR_MAGENTA "|cffff00ff"
#define MSG_COLOR_WHITE "|cffffffff"
class warp_commandscript : public CommandScript
{
public:
warp_commandscript() : CommandScript("warp_commandscript") { }
ChatCommand* GetCommands() const
{
static ChatCommand commandTable[] =
{
{ "warp", SEC_MODERATOR, false, &HandleWarpCommand, "", NULL },
{ NULL, SEC_PLAYER, false, NULL, "", NULL }
};
return commandTable;
}
static bool HandleWarpCommand(ChatHandler* handler, char const* args)
{
// Based on a concept by Pwntzyou
if (!*args)
return false;
Player* _player = handler->GetSession()->GetPlayer();
char* arg1 = strtok((char*)args, " ");
char* arg2 = strtok(NULL, " ");
char* arg3 = strtok(NULL, " ");
if (!arg1 || !arg2)
return false;
bool useVMap = false;
if(arg3)
useVMap = !strcmp("on", arg3);
char dir = arg1[0];
float amount = float(atof(arg2));
float x = _player->GetPositionX();
float y = _player->GetPositionY();
float z = _player->GetPositionZ();
float o = _player->GetOrientation();
switch (dir)
{
case 'x':
{
x = x + cos(o-(M_PI/2))*amount;
y = y + sin(o-(M_PI/2))*amount;
handler->PSendSysMessage("%s[Warp Info]%s You teleported %g yards in x direction",MSG_COLOR_MAGENTA,MSG_COLOR_WHITE,amount);
}
break;
case 'y':
{
x = x + cosf(o)*amount;
y = y + sinf(o)*amount;
handler->PSendSysMessage("%s[Warp Info]%s You teleported %g yards in y direction",MSG_COLOR_MAGENTA,MSG_COLOR_WHITE,amount);
}
break;
case 'z':
{
z += amount;
handler->PSendSysMessage("%s[Warp Info]%s You teleported %g yards in z direction",MSG_COLOR_MAGENTA,MSG_COLOR_WHITE,amount);
}
break;
case 'o':
{
o = Position::NormalizeOrientation((amount * M_PI/180.0f)+o);
handler->PSendSysMessage("%s[Warp Info]%s You rotated %g degrees (%g radians)",MSG_COLOR_MAGENTA,MSG_COLOR_WHITE,amount,amount * M_PI / 180.0f);
handler->PSendSysMessage("%sCurrent radian/degree: %g %g",MSG_COLOR_WHITE,o,o*180.0f/M_PI);
}
break;
}
if (useVMap && z == _player->GetPositionZ())
{
z = _player->GetMap()->GetHeight(x, y, MAX_HEIGHT);
handler->PSendSysMessage("%s[Warp Info]%s You were also teleported %g yards in z direction to be on ground.",MSG_COLOR_MAGENTA,MSG_COLOR_WHITE, z - _player->GetPositionZ());
}
else
{
if (abs(_player->GetMap()->GetHeight(x, y, MAX_HEIGHT) - z) >= 0.5f)
{
WorldPacket data(12);
data.SetOpcode(SMSG_MOVE_SET_CAN_FLY);
data.append(_player->GetPackGUID());
data << uint32(0); // unknown
_player->SendMessageToSet(&data, true);
handler->PSendSysMessage("%s[Warp Info]%s Enabled fly cheat, we expect you do not want to fall down.",MSG_COLOR_MAGENTA,MSG_COLOR_WHITE);
}
}
_player->NearTeleportTo(x,y,z,o);
return true;
}
};
void AddSC_warp_commandscript()
{
new warp_commandscript();
}
回复下载完整代码
|