Add a #push command, only works on NPCs for now

This commit is contained in:
Michael Cook (mackal) 2018-03-14 16:09:43 -04:00
parent 5e963c05af
commit 339e921f17
3 changed files with 35 additions and 0 deletions

View File

@ -67,10 +67,12 @@
#include "titles.h" #include "titles.h"
#include "water_map.h" #include "water_map.h"
#include "worldserver.h" #include "worldserver.h"
#include "fastmath.h"
extern QueryServ* QServ; extern QueryServ* QServ;
extern WorldServer worldserver; extern WorldServer worldserver;
extern TaskManager *taskmanager; extern TaskManager *taskmanager;
extern FastMath g_Math;
void CatchSignal(int sig_num); void CatchSignal(int sig_num);
@ -306,6 +308,7 @@ int command_init(void)
command_add("profilereset", "- Reset profiling info", 250, command_profilereset) || command_add("profilereset", "- Reset profiling info", 250, command_profilereset) ||
#endif #endif
command_add("push", "Lets you do spell push", 150, command_push) ||
command_add("pvp", "[on/off] - Set your or your player target's PVP status", 100, command_pvp) || command_add("pvp", "[on/off] - Set your or your player target's PVP status", 100, command_pvp) ||
command_add("qglobal", "[on/off/view] - Toggles qglobal functionality on an NPC", 100, command_qglobal) || command_add("qglobal", "[on/off/view] - Toggles qglobal functionality on an NPC", 100, command_qglobal) ||
command_add("questerrors", "Shows quest errors.", 100, command_questerrors) || command_add("questerrors", "Shows quest errors.", 100, command_questerrors) ||
@ -4052,6 +4055,33 @@ void command_unfreeze(Client *c, const Seperator *sep)
c->Message(0, "ERROR: Unfreeze requires a target."); c->Message(0, "ERROR: Unfreeze requires a target.");
} }
void command_push(Client *c, const Seperator *sep)
{
Mob *t = c;
if (c->GetTarget() != nullptr)
t = c->GetTarget();
if (!sep->arg[1] || !sep->IsNumber(1)) {
c->Message(0, "ERROR: Must provide at least a push back.");
return;
}
float back = atof(sep->arg[1]);
float up = 0.0f;
if (sep->arg[2] && sep->IsNumber(2))
up = atof(sep->arg[2]);
if (t->IsNPC()) {
t->IncDeltaX(back * g_Math.FastSin(c->GetHeading()));
t->IncDeltaY(back * g_Math.FastCos(c->GetHeading()));
t->IncDeltaZ(up);
t->SetForcedMovement(6);
} else if (t->IsClient()) {
// TODO: send packet to push
}
}
void command_pvp(Client *c, const Seperator *sep) void command_pvp(Client *c, const Seperator *sep)
{ {
bool state=atobool(sep->arg[1]); bool state=atobool(sep->arg[1]);

View File

@ -211,6 +211,7 @@ void command_profiledump(Client *c, const Seperator *sep);
void command_profilereset(Client *c, const Seperator *sep); void command_profilereset(Client *c, const Seperator *sep);
#endif #endif
void command_push(Client *c, const Seperator *sep);
void command_pvp(Client *c, const Seperator *sep); void command_pvp(Client *c, const Seperator *sep);
void command_qglobal(Client *c, const Seperator *sep); void command_qglobal(Client *c, const Seperator *sep);
void command_qtest(Client *c, const Seperator *sep); void command_qtest(Client *c, const Seperator *sep);

View File

@ -582,6 +582,10 @@ public:
m_Position.z = NewPosition.z; }; m_Position.z = NewPosition.z; };
void TryMoveAlong(float distance, float angle, bool send = true); void TryMoveAlong(float distance, float angle, bool send = true);
void ProcessForcedMovement(); void ProcessForcedMovement();
inline void IncDeltaX(float in) { m_Delta.x += in; }
inline void IncDeltaY(float in) { m_Delta.y += in; }
inline void IncDeltaZ(float in) { m_Delta.z += in; }
inline void SetForcedMovement(int in) { ForcedMovement = in; }
//AI //AI
static uint32 GetLevelCon(uint8 mylevel, uint8 iOtherLevel); static uint32 GetLevelCon(uint8 mylevel, uint8 iOtherLevel);