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
+30
View File
@@ -67,10 +67,12 @@
#include "titles.h"
#include "water_map.h"
#include "worldserver.h"
#include "fastmath.h"
extern QueryServ* QServ;
extern WorldServer worldserver;
extern TaskManager *taskmanager;
extern FastMath g_Math;
void CatchSignal(int sig_num);
@@ -306,6 +308,7 @@ int command_init(void)
command_add("profilereset", "- Reset profiling info", 250, command_profilereset) ||
#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("qglobal", "[on/off/view] - Toggles qglobal functionality on an NPC", 100, command_qglobal) ||
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.");
}
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)
{
bool state=atobool(sep->arg[1]);