Skip to content

Instantly share code, notes, and snippets.

@Lillecarl
Last active December 16, 2015 04:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lillecarl/5378801 to your computer and use it in GitHub Desktop.
Save Lillecarl/5378801 to your computer and use it in GitHub Desktop.
// 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();
}
@Bazzaktok
Copy link

I love it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment