// 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"
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);
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();
}