From 339e921f1793083e7ec3afc986d4a7ad0e47c37b Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Wed, 14 Mar 2018 16:09:43 -0400 Subject: [PATCH] Add a #push command, only works on NPCs for now --- zone/command.cpp | 30 ++++++++++++++++++++++++++++++ zone/command.h | 1 + zone/mob.h | 4 ++++ 3 files changed, 35 insertions(+) diff --git a/zone/command.cpp b/zone/command.cpp index 4ca94fcb4..3ef118934 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -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]); diff --git a/zone/command.h b/zone/command.h index 580dd00ff..d3bae6c0c 100644 --- a/zone/command.h +++ b/zone/command.h @@ -211,6 +211,7 @@ void command_profiledump(Client *c, const Seperator *sep); void command_profilereset(Client *c, const Seperator *sep); #endif +void command_push(Client *c, const Seperator *sep); void command_pvp(Client *c, const Seperator *sep); void command_qglobal(Client *c, const Seperator *sep); void command_qtest(Client *c, const Seperator *sep); diff --git a/zone/mob.h b/zone/mob.h index a160b2a45..43d8f9b59 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -582,6 +582,10 @@ public: m_Position.z = NewPosition.z; }; void TryMoveAlong(float distance, float angle, bool send = true); 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 static uint32 GetLevelCon(uint8 mylevel, uint8 iOtherLevel);