[GM Command] Door Manipulation Command Port (#1524)

* Initial commit

* Push latest

* Update door_manipulation.cpp

* More door work

* More doors work

* Upload notes

* Finalize changes

* Remove comment

* Add missing chat line

* Swapped URI parser with something not using deprecated C++ functions
This commit is contained in:
Chris Miles
2021-09-12 22:08:04 -05:00
committed by GitHub
parent 31ab1d4287
commit 94c1a50cc8
22 changed files with 2007 additions and 9 deletions
+2
View File
@@ -80,6 +80,7 @@ SET(zone_sources
fearpath.cpp
forage.cpp
global_loot_manager.cpp
gm_commands/door_manipulation.cpp
groups.cpp
guild.cpp
guild_mgr.cpp
@@ -198,6 +199,7 @@ SET(zone_headers
fastmath.h
forage.h
global_loot_manager.h
gm_commands/door_manipulation.h
groups.h
guild_mgr.h
hate_list.h
+10
View File
@@ -10515,3 +10515,13 @@ void Client::ApplyWeaponsStance()
weaponstance.spellbonus_enabled = false;
}
}
uint16 Client::GetDoorToolEntityId() const
{
return m_door_tool_entity_id;
}
void Client::SetDoorToolEntityId(uint16 door_tool_entity_id)
{
Client::m_door_tool_entity_id = door_tool_entity_id;
}
+8
View File
@@ -1764,9 +1764,17 @@ private:
int Haste; //precalced value
uint32 tmSitting; // time stamp started sitting, used for HP regen bonus added on MAY 5, 2004
// dev tools
bool display_mob_info_window;
bool dev_tools_enabled;
uint16 m_door_tool_entity_id;
public:
uint16 GetDoorToolEntityId() const;
void SetDoorToolEntityId(uint16 door_tool_entity_id);
private:
int32 max_end;
int32 current_endurance;
+15
View File
@@ -66,6 +66,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../common/repositories/character_instance_safereturns_repository.h"
#include "../common/repositories/criteria/content_filter_criteria.h"
#include "../common/shared_tasks.h"
#include "gm_commands/door_manipulation.h"
#ifdef BOTS
#include "bot.h"
@@ -4356,6 +4357,20 @@ void Client::Handle_OP_ClickDoor(const EQApplicationPacket *app)
return;
}
// set door selected
if (IsDevToolsEnabled()) {
SetDoorToolEntityId(currentdoor->GetEntityID());
DoorManipulation::CommandHeader(this);
Message(
Chat::White,
fmt::format(
"Door ({}) [{}]",
currentdoor->GetEntityID(),
EQ::SayLinkEngine::GenerateQuestSaylink("#door edit", false, "#door edit")
).c_str()
);
}
char buf[20];
snprintf(buf, 19, "%u", cd->doorid);
buf[19] = '\0';
+6
View File
@@ -78,6 +78,7 @@
#include "../common/content/world_content_service.h"
#include "../common/http/httplib.h"
#include "../common/shared_tasks.h"
#include "gm_commands/door_manipulation.h"
extern QueryServ* QServ;
extern WorldServer worldserver;
@@ -202,6 +203,7 @@ int command_init(void)
command_add("disablerecipe", "[recipe_id] - Disables a recipe using the recipe id.", 80, command_disablerecipe) ||
command_add("disarmtrap", "Analog for ldon disarm trap for the newer clients since we still don't have it working.", 80, command_disarmtrap) ||
command_add("distance", "- Reports the distance between you and your target.", 80, command_distance) ||
command_add("door", "Door editing command", 80, command_door) ||
command_add("doanim", "[animnum] [type] - Send an EmoteAnim for you or your target", 50, command_doanim) ||
command_add("dz", "Manage expeditions and dynamic zone instances", 80, command_dz) ||
command_add("dzkickplayers", "Removes all players from current expedition. (/kickplayers alternative for pre-RoF clients)", 0, command_dzkickplayers) ||
@@ -12940,6 +12942,10 @@ void command_distance(Client *c, const Seperator *sep) {
}
}
void command_door(Client *c, const Seperator *sep) {
DoorManipulation::CommandHandler(c, sep);
}
void command_cvs(Client *c, const Seperator *sep)
{
if(c)
+1
View File
@@ -90,6 +90,7 @@ void command_devtools(Client *c, const Seperator *sep);
void command_details(Client *c, const Seperator *sep);
void command_disablerecipe(Client *c, const Seperator *sep);
void command_disarmtrap(Client *c, const Seperator *sep);
void command_door(Client *c, const Seperator *sep);
void command_distance(Client *c, const Seperator *sep);
void command_doanim(Client *c, const Seperator *sep);
void command_dz(Client *c, const Seperator *sep);
+6
View File
@@ -801,6 +801,12 @@ void Doors::SetIncline(int in) {
entity_list.RespawnAllDoors();
}
void Doors::SetInvertState(int in) {
entity_list.DespawnAllDoors();
invert_state = in;
entity_list.RespawnAllDoors();
}
void Doors::SetOpenType(uint8 in) {
entity_list.DespawnAllDoors();
open_type = in;
+1
View File
@@ -54,6 +54,7 @@ public:
void SetDoorName(const char *name);
void SetEntityID(uint32 entity) { entity_id = entity; }
void SetIncline(int in);
void SetInvertState(int in);
void SetKeyItem(uint32 in) { key_item_id = in; }
void SetLocation(float x, float y, float z);
void SetLockpick(uint16 in) { lockpick = in; }
+779
View File
@@ -0,0 +1,779 @@
#include "door_manipulation.h"
#include "../doors.h"
#include "../../common/misc_functions.h"
#define MAX_CLIENT_MESSAGE_LENGTH 2000
void DoorManipulation::CommandHandler(Client *c, const Seperator *sep)
{
// this should never happen
if (!c) {
return;
}
// args
std::string arg1(sep->arg[1]);
std::string arg2(sep->arg[2]);
std::string arg3(sep->arg[3]);
// table check
std::string table_name = "tool_game_objects";
std::string url = "https://raw.githubusercontent.com/EQEmu/database-tool-sqls/main/tool_game_objects.sql";
if (!database.DoesTableExist(table_name)) {
c->Message(
Chat::White,
fmt::format(
"Table [{}] does not exist. Downloading from [{}] and installing locally",
table_name,
url
).c_str()
);
database.SourceDatabaseTableFromUrl(
table_name,
url
);
}
// option
if (arg1.empty()) {
DoorManipulation::CommandHeader(c);
c->Message(Chat::White, "#door create <modelname> | Creates a door from a model. (Example IT78 creates a campfire)");
c->Message(Chat::White, "#door setinvertstate [0|1] | Sets selected door invert state");
c->Message(Chat::White, "#door setincline <incline> | Sets selected door incline");
c->Message(Chat::White, "#door opentype <opentype> | Sets selected door opentype");
c->Message(
Chat::White,
fmt::format(
"#door model <modelname> | Changes door model for selected door or select from [{}] or [{}]",
EQ::SayLinkEngine::GenerateQuestSaylink("#door showmodelszone", false, "local zone"),
EQ::SayLinkEngine::GenerateQuestSaylink("#door showmodelsglobal", false, "global")
).c_str()
);
c->Message(
Chat::White,
"#door showmodelsfromfile <file.eqg|file.s3d> | Shows models from s3d or eqg file. Example tssequip.eqg or wallet01.eqg"
);
c->Message(
Chat::White,
fmt::format(
"{} | Shows available models in the current zone that you are in",
EQ::SayLinkEngine::GenerateQuestSaylink("#door showmodelszone", false, "#door showmodelszone")
).c_str()
);
c->Message(
Chat::White,
fmt::format(
"{} | Shows available models globally by first listing all global model files",
EQ::SayLinkEngine::GenerateQuestSaylink("#door showmodelsglobal", false, "#door showmodelsglobal")
).c_str()
);
c->Message(Chat::White, "#door save | Creates database entry for selected door");
c->Message(
Chat::White,
fmt::format(
"{} - Brings up editing interface for selected door",
EQ::SayLinkEngine::GenerateQuestSaylink("#door edit", false, "#door edit")
).c_str()
);
c->Message(
Chat::White,
fmt::format(
"{} - lists doors in zone",
EQ::SayLinkEngine::GenerateQuestSaylink("#list doors", false, "#list doors")
).c_str()
);
return;
}
// edit menu
if (arg1 == "edit") {
Doors *door = entity_list.GetDoorsByID(c->GetDoorToolEntityId());
if (door) {
c->Message(
Chat::White,
fmt::format(
"Door Selected ID [{}] Name [{}] OpenType [{}] Invertstate [{} | {}/{}] ",
c->GetDoorToolEntityId(),
door->GetDoorName(),
door->GetOpenType(),
door->GetInvertState(),
EQ::SayLinkEngine::GenerateQuestSaylink("#door setinvertstate 0", false, "0"),
EQ::SayLinkEngine::GenerateQuestSaylink("#door setinvertstate 1", false, "1")
).c_str()
);
const std::string move_x_action = "move_x";
const std::string move_y_action = "move_y";
const std::string move_z_action = "move_z";
const std::string move_h_action = "move_h";
const std::string set_size_action = "set_size";
std::vector<std::string> move_options = {
move_x_action,
move_y_action,
move_z_action,
move_h_action,
set_size_action
};
std::vector<std::string> move_x_options_positive;
std::vector<std::string> move_x_options_negative;
std::vector<std::string> move_y_options_positive;
std::vector<std::string> move_y_options_negative;
std::vector<std::string> move_z_options_positive;
std::vector<std::string> move_z_options_negative;
std::vector<std::string> move_h_options_positive;
std::vector<std::string> move_h_options_negative;
std::vector<std::string> set_size_options_positive;
std::vector<std::string> set_size_options_negative;
for (const auto &move_option : move_options) {
if (move_option == move_x_action) {
move_x_options_positive.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door edit {} .25", move_option),
false,
".25"
)
);
for (int move_index = 0; move_index <= 15; move_index += 5) {
int value = (move_index == 0 ? 1 : move_index);
move_x_options_positive.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door edit {} {}", move_option, value),
false,
fmt::format("{}", std::abs(value))
)
);
}
for (int move_index = -15; move_index <= 0; move_index += 5) {
int value = (move_index == 0 ? 1 : move_index);
move_x_options_negative.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door edit {} {}", move_option, value),
false,
fmt::format("{}", std::abs(value))
)
);
}
move_x_options_negative.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door edit {} -.25", move_option),
false,
"-.25"
)
);
}
else if (move_option == move_y_action) {
move_y_options_positive.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door edit {} .25", move_option),
false,
".25"
)
);
for (int move_index = 0; move_index <= 15; move_index += 5) {
int value = (move_index == 0 ? 1 : move_index);
move_y_options_positive.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door edit {} {}", move_option, value),
false,
fmt::format("{}", std::abs(value))
)
);
}
for (int move_index = -15; move_index <= 0; move_index += 5) {
int value = (move_index == 0 ? 1 : move_index);
move_y_options_negative.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door edit {} {}", move_option, value),
false,
fmt::format("{}", std::abs(value))
)
);
}
move_y_options_negative.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door edit {} -.25", move_option),
false,
"-.25"
)
);
}
else if (move_option == move_z_action) {
move_z_options_positive.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door edit {} .25", move_option),
false,
".25"
)
);
for (int move_index = 0; move_index <= 15; move_index += 5) {
int value = (move_index == 0 ? 1 : move_index);
move_z_options_positive.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door edit {} {}", move_option, value),
false,
fmt::format("{}", std::abs(value))
)
);
}
for (int move_index = -15; move_index <= 0; move_index += 5) {
int value = (move_index == 0 ? 1 : move_index);
move_z_options_negative.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door edit {} {}", move_option, value),
false,
fmt::format("{}", std::abs(value))
)
);
}
move_z_options_negative.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door edit {} -.25", move_option),
false,
"-.25"
)
);
}
else if (move_option == move_h_action) {
for (int move_index = 0; move_index <= 50; move_index += 5) {
int value = (move_index == 0 ? 1 : move_index);
move_h_options_positive.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door edit {} {}", move_option, value),
false,
fmt::format("{}", std::abs(value))
)
);
}
for (int move_index = -50; move_index <= 0; move_index += 5) {
int value = (move_index == 0 ? 1 : move_index);
move_h_options_negative.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door edit {} {}", move_option, value),
false,
fmt::format("{}", std::abs(value))
)
);
}
}
else if (move_option == set_size_action) {
for (int move_index = 0; move_index <= 100; move_index += 10) {
int value = (move_index == 0 ? 1 : move_index);
set_size_options_positive.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door edit {} {}", move_option, value),
false,
fmt::format("{}", std::abs(value))
)
);
}
for (int move_index = -100; move_index <= 0; move_index += 10) {
int value = (move_index == 0 ? 1 : move_index);
set_size_options_negative.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door edit {} {}", move_option, value),
false,
fmt::format("{}", std::abs(value))
)
);
}
}
}
// we're passing a move action here
if (!arg3.empty() && StringIsNumber(arg3)) {
int x_move = 0;
int y_move = 0;
int z_move = 0;
int h_move = 0;
int set_size = 0;
if (arg2 == move_x_action) {
x_move = std::atoi(arg3.c_str());
}
if (arg2 == move_y_action) {
y_move = std::atoi(arg3.c_str());
}
if (arg2 == move_z_action) {
z_move = std::atoi(arg3.c_str());
}
if (arg2 == move_h_action) {
h_move = std::atoi(arg3.c_str());
}
if (arg2 == set_size_action) {
set_size = std::atoi(arg3.c_str());
}
door->SetLocation(
door->GetX() + x_move,
door->GetY() + y_move,
door->GetZ() + z_move
);
glm::vec4 door_position = door->GetPosition();
door_position.w = door_position.w + h_move;
door->SetPosition(door_position);
door->SetSize(door->GetSize() + set_size);
}
// spawn and move helpers
uint16 helper_mob_x_negative = 0;
uint16 helper_mob_x_positive = 0;
uint16 helper_mob_y_positive = 0;
uint16 helper_mob_y_negative = 0;
for (auto &n: entity_list.GetNPCList()) {
NPC *npc = n.second;
std::string npc_name = npc->GetName();
if (npc_name.find("-X") != std::string::npos) {
helper_mob_x_negative = npc->GetID();
}
if (npc_name.find("-Y") != std::string::npos) {
helper_mob_y_negative = npc->GetID();
}
if (npc_name.find("+X") != std::string::npos) {
helper_mob_x_positive = npc->GetID();
}
if (npc_name.find("+Y") != std::string::npos) {
helper_mob_y_positive = npc->GetID();
}
}
// -X
glm::vec4 door_position = door->GetPosition();
if (helper_mob_x_negative == 0) {
door_position.x = door_position.x - 15;
helper_mob_x_negative = NPC::SpawnNodeNPC("-X", "", door_position)->GetID();
}
else {
auto n = entity_list.GetNPCByID(helper_mob_x_negative);
n->GMMove(door->GetX() - 15, door->GetY(), door->GetZ(), n->GetHeading());
}
// +X
door_position = door->GetPosition();
if (helper_mob_x_positive == 0) {
door_position.x = door_position.x + 15;
helper_mob_x_positive = NPC::SpawnNodeNPC("+X", "", door_position)->GetID();
}
else {
auto n = entity_list.GetNPCByID(helper_mob_x_positive);
n->GMMove(door->GetX() + 15, door->GetY(), door->GetZ(), n->GetHeading());
}
// -Y
door_position = door->GetPosition();
if (helper_mob_y_negative == 0) {
door_position.y = door_position.y - 15;
helper_mob_y_negative = NPC::SpawnNodeNPC("-Y", "", door_position)->GetID();
}
else {
auto n = entity_list.GetNPCByID(helper_mob_y_negative);
n->GMMove(door->GetX(), door->GetY() - 15, door->GetZ(), n->GetHeading());
}
// +Y
door_position = door->GetPosition();
if (helper_mob_y_positive == 0) {
door_position.y = door_position.y + 15;
helper_mob_y_positive = NPC::SpawnNodeNPC("+Y", "", door_position)->GetID();
}
else {
auto n = entity_list.GetNPCByID(helper_mob_y_positive);
n->GMMove(door->GetX(), door->GetY() + 15, door->GetZ(), n->GetHeading());
}
c->Message(
Chat::White,
fmt::format(
"Name [{}] [{}] [{}] [{}]",
door->GetDoorName(),
EQ::SayLinkEngine::GenerateQuestSaylink(
"#door save",
false,
"Save"
),
EQ::SayLinkEngine::GenerateQuestSaylink(
"#door changemodelqueue",
false,
"Change Model"
),
EQ::SayLinkEngine::GenerateQuestSaylink(
"#door setinclineinc",
false,
"Incline"
)
).c_str()
);
c->Message(
Chat::White,
fmt::format(
"[{}] - [X] + [{}]",
implode(" | ", move_x_options_negative),
implode(" | ", move_x_options_positive)
).c_str()
);
c->Message(
Chat::White,
fmt::format(
"[{}] - [Y] + [{}]",
implode(" | ", move_y_options_negative),
implode(" | ", move_y_options_positive)
).c_str()
);
c->Message(
Chat::White,
fmt::format(
"[{}] - [Z] + [{}]",
implode(" | ", move_z_options_negative),
implode(" | ", move_z_options_positive)
).c_str()
);
c->Message(
Chat::White,
fmt::format(
"[{}] - [H] + [{}]",
implode(" | ", move_h_options_negative),
implode(" | ", move_h_options_positive)
).c_str()
);
c->Message(
Chat::White,
fmt::format(
"[{}] - [Size] + [{}]",
implode(" | ", set_size_options_negative),
implode(" | ", set_size_options_positive)
).c_str()
);
return;
}
c->Message(Chat::Red, "Door selection invalid...");
}
// create
if (arg1 == "create") {
std::string model = str_toupper(arg2);
uint16 entity_id = entity_list.CreateDoor(
model.c_str(),
c->GetPosition(),
58,
100
);
c->Message(
Chat::White,
fmt::format("Creating door entity_id [{}] with model [{}]", entity_id, model).c_str());
c->SetDoorToolEntityId(entity_id);
}
// set model
if (arg1 == "model") {
Doors *door = entity_list.GetDoorsByID(c->GetDoorToolEntityId());
std::string model = str_toupper(arg2);
if (door) {
door->SetDoorName(model.c_str());
}
}
// change model queue
if (arg1 == "changemodelqueue") {
c->Message(
Chat::White,
fmt::format(
"#door model <modelname> | Changes door model for selected door or select from [{}] or [{}]",
EQ::SayLinkEngine::GenerateQuestSaylink("#door showmodelszone", false, "local zone"),
EQ::SayLinkEngine::GenerateQuestSaylink("#door showmodelsglobal", false, "global")
).c_str()
);
}
// open type
if (arg1 == "opentype" && !arg2.empty() && StringIsNumber(arg2)) {
Doors *door = entity_list.GetDoorsByID(c->GetDoorToolEntityId());
if (door) {
door->SetOpenType(std::atoi(arg2.c_str()));
}
}
// incline
if (arg1 == "setincline" && !arg2.empty() && StringIsNumber(arg2)) {
Doors *door = entity_list.GetDoorsByID(c->GetDoorToolEntityId());
if (door) {
door->SetIncline(std::atoi(arg2.c_str()));
}
}
// incline
if (arg1 == "setinvertstate" && !arg2.empty() && StringIsNumber(arg2)) {
Doors *door = entity_list.GetDoorsByID(c->GetDoorToolEntityId());
if (door) {
door->SetInvertState(std::atoi(arg2.c_str()));
}
}
// save
if (arg1 == "save") {
Doors *door = entity_list.GetDoorsByID(c->GetDoorToolEntityId());
if (door) {
door->CreateDatabaseEntry();
c->Message(Chat::White, "Door saved");
}
}
// incline incremental
if (arg1 == "setinclineinc" && !arg2.empty() && StringIsNumber(arg2)) {
Doors *door = entity_list.GetDoorsByID(c->GetDoorToolEntityId());
if (door) {
door->SetIncline(door->GetIncline() + std::atoi(arg2.c_str()));
}
}
if (arg1 == "setinclineinc") {
std::map<float, std::string> incline_values = {
{.01, "Upright"},
{63.75, "45 Degrees",},
{130, "90 Degrees"},
{192.5, "135 Degrees"},
{255, "180 Degrees"},
{321.25, "225 Degrees"},
{385, "270 Degrees"},
{448.75, "315 Degrees"},
{512.5, "360 Degrees"}
};
std::vector<std::string> incline_normal_options;
std::vector<std::string> incline_positive_options;
std::vector<std::string> incline_negative_options;
for (auto incline_value : incline_values) {
incline_normal_options.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format(
"#door setincline {}",
incline_value.first
),
false,
incline_value.second
)
);
}
for (int incline_index = 0; incline_index <= 100; incline_index += 10) {
int incline_value = (incline_index == 0 ? 1 : incline_index);
incline_positive_options.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format(
"#door setinclineinc {}",
incline_value
),
false,
itoa(std::abs(incline_value))
)
);
}
for (int incline_index = -100; incline_index <= 1; incline_index += 10) {
int incline_value = (incline_index == 0 ? -1 : incline_index);
incline_negative_options.emplace_back(
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format(
"#door setinclineinc {}",
incline_value
),
false,
itoa(std::abs(incline_value))
)
);
}
c->Message(
Chat::White,
fmt::format(
"[Incline] [{}]",
implode(" | ", incline_normal_options)
).c_str()
);
c->Message(
Chat::White,
fmt::format(
"[Incline Increments] [{}] - | + [{}]",
implode(" | ", incline_negative_options),
implode(" | ", incline_positive_options)
).c_str()
);
}
// show models in zone
if (arg1 == "showmodelsglobal") {
auto game_objects = ToolGameObjectsRepository::GetWhere(
database,
"object_name LIKE '%IT%' AND zoneid = 0 AND object_name NOT LIKE '%OBJ%' GROUP by file_from"
);
if (game_objects.empty()) {
c->Message(Chat::White, "There are no models to display...");
}
c->Message(Chat::White, "------------------------------------------------");
c->Message(Chat::White, "# Models (Global)");
c->Message(Chat::White, "------------------------------------------------");
DisplayModelsFromFileResults(c, game_objects);
}
// show models in zone
if (arg1 == "showmodelszone") {
auto game_objects = ToolGameObjectsRepository::GetWhere(
database,
fmt::format("zoneid = {}", zone->GetZoneID())
);
if (game_objects.empty()) {
c->Message(Chat::White, "There are no models for this zone...");
}
c->Message(Chat::White, "------------------------------------------------");
c->Message(Chat::White, "# Models from zone");
c->Message(Chat::White, "------------------------------------------------");
DisplayObjectResultToClient(c, game_objects);
}
// show models from file name
if (arg1 == "showmodelsfromfile" && !arg2.empty()) {
const std::string &file_name = arg2;
auto game_objects = ToolGameObjectsRepository::GetWhere(
database,
fmt::format("file_from = '{}'", file_name)
);
if (game_objects.empty()) {
c->Message(Chat::White, "There are no models for this zone...");
}
c->Message(Chat::White, "------------------------------------------------");
c->Message(Chat::White, fmt::format("# Models from file name [{}]", file_name).c_str());
c->Message(Chat::White, "------------------------------------------------");
DisplayObjectResultToClient(c, game_objects);
}
}
void DoorManipulation::CommandHeader(Client *c)
{
c->Message(Chat::White, "------------------------------------------------");
c->Message(Chat::White, "# Door Commands");
c->Message(Chat::White, "------------------------------------------------");
}
void DoorManipulation::DisplayObjectResultToClient(
Client *c,
std::vector<ToolGameObjectsRepository::ToolGameObjects> game_objects
)
{
std::vector<std::string> say_links;
for (auto &g: game_objects) {
say_links.emplace_back(
fmt::format(
"[{}] ",
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door model {}", g.object_name),
false,
g.object_name
)
)
);
}
int character_length = 0;
std::vector<std::string> buffered_links;
for (auto &links: say_links) {
buffered_links.emplace_back(links);
character_length += links.length();
// empty buffer
if (character_length > MAX_CLIENT_MESSAGE_LENGTH) {
std::string message_buffer;
for (auto &buffered_link: buffered_links) {
message_buffer += buffered_link;
}
c->Message(Chat::White, message_buffer.c_str());
// reset
character_length = 0;
buffered_links = {};
}
}
if (!buffered_links.empty()) {
c->Message(Chat::White, implode(" ", buffered_links).c_str());
}
}
void DoorManipulation::DisplayModelsFromFileResults(
Client *c,
std::vector<ToolGameObjectsRepository::ToolGameObjects> game_objects
)
{
std::vector<std::string> say_links;
for (auto &g: game_objects) {
say_links.emplace_back(
fmt::format(
"[{}] ",
EQ::SayLinkEngine::GenerateQuestSaylink(
fmt::format("#door showmodelsfromfile {}", g.file_from),
false,
g.file_from
)
)
);
}
int character_length = 0;
std::vector<std::string> buffered_links;
for (auto &links: say_links) {
buffered_links.emplace_back(links);
character_length += links.length();
// empty buffer
if (character_length > MAX_CLIENT_MESSAGE_LENGTH) {
std::string message_buffer;
for (auto &buffered_link: buffered_links) {
message_buffer += buffered_link;
}
c->Message(Chat::White, message_buffer.c_str());
// reset
character_length = 0;
buffered_links = {};
}
}
if (!buffered_links.empty()) {
c->Message(Chat::White, implode(" ", buffered_links).c_str());
}
}
+23
View File
@@ -0,0 +1,23 @@
#ifndef EQEMU_DOOR_MANIPULATION_H
#define EQEMU_DOOR_MANIPULATION_H
#include "../client.h"
#include "../../common/repositories/tool_game_objects_repository.h"
class DoorManipulation {
public:
static void CommandHandler(Client *c, const Seperator *sep);
static void CommandHeader(Client *c);
static void DisplayObjectResultToClient(
Client *c,
std::vector<ToolGameObjectsRepository::ToolGameObjects> game_objects
);
static void DisplayModelsFromFileResults(
Client *c,
std::vector<ToolGameObjectsRepository::ToolGameObjects> game_objects
);
};
#endif //EQEMU_DOOR_MANIPULATION_H
+13 -6
View File
@@ -284,7 +284,7 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi
entity_list.MakeNameUnique(name);
npc_aggro = npc_type_data->npc_aggro;
AISpellVar.fail_recast = static_cast<uint32>(RuleI(Spells, AI_SpellCastFinishedFailRecast));
AISpellVar.engaged_no_sp_recast_min = static_cast<uint32>(RuleI(Spells, AI_EngagedNoSpellMinRecast));
AISpellVar.engaged_no_sp_recast_max = static_cast<uint32>(RuleI(Spells, AI_EngagedNoSpellMaxRecast));
@@ -694,7 +694,7 @@ bool NPC::HasItem(uint32 item_id) {
if (loot_item->item_id == item_id) {
return true;
}
}
}
return false;
}
@@ -1124,7 +1124,7 @@ bool NPC::SpawnZoneController()
memset(npc_type, 0, sizeof(NPCType));
strncpy(npc_type->name, "zone_controller", 60);
npc_type->current_hp = 2000000000;
npc_type->current_hp = 2000000000;
npc_type->max_hp = 2000000000;
npc_type->hp_regen = 100000000;
npc_type->race = 240;
@@ -1207,7 +1207,7 @@ void NPC::SpawnGridNodeNPC(const glm::vec4 &position, int32 grid_id, int32 grid_
entity_list.AddNPC(npc);
}
void NPC::SpawnZonePointNodeNPC(std::string name, const glm::vec4 &position)
NPC * NPC::SpawnZonePointNodeNPC(std::string name, const glm::vec4 &position)
{
auto npc_type = new NPCType;
memset(npc_type, 0, sizeof(NPCType));
@@ -1235,6 +1235,8 @@ void NPC::SpawnZonePointNodeNPC(std::string name, const glm::vec4 &position)
npc_type->show_name = true;
npc_type->findable = true;
strcpy(npc_type->special_abilities, "12,1^13,1^14,1^15,1^16,1^17,1^19,1^22,1^24,1^25,1^28,1^31,1^35,1^39,1^42,1");
auto node_position = glm::vec4(position.x, position.y, position.z, position.w);
auto npc = new NPC(npc_type, nullptr, node_position, GravityBehavior::Flying);
@@ -1243,14 +1245,15 @@ void NPC::SpawnZonePointNodeNPC(std::string name, const glm::vec4 &position)
npc->GiveNPCTypeData(npc_type);
entity_list.AddNPC(npc);
return npc;
}
NPC * NPC::SpawnNodeNPC(std::string name, std::string last_name, const glm::vec4 &position) {
auto npc_type = new NPCType;
memset(npc_type, 0, sizeof(NPCType));
sprintf(npc_type->name, "%s", name.c_str());
sprintf(npc_type->lastname, "%s", last_name.c_str());
strncpy(npc_type->name, name.c_str(), 60);
npc_type->current_hp = 4000000;
npc_type->max_hp = 4000000;
@@ -1272,9 +1275,13 @@ NPC * NPC::SpawnNodeNPC(std::string name, std::string last_name, const glm::vec4
npc_type->findable = true;
npc_type->runspeed = 1.25;
strcpy(npc_type->special_abilities, "12,1^13,1^14,1^15,1^16,1^17,1^19,1^22,1^24,1^25,1^28,1^31,1^35,1^39,1^42,1");
auto node_position = glm::vec4(position.x, position.y, position.z, position.w);
auto npc = new NPC(npc_type, nullptr, node_position, GravityBehavior::Flying);
npc->name[strlen(npc->name) - 3] = (char) NULL;
npc->GiveNPCTypeData(npc_type);
entity_list.AddNPC(npc, true, true);
+1 -1
View File
@@ -115,7 +115,7 @@ public:
static NPC *SpawnNodeNPC(std::string name, std::string last_name, const glm::vec4 &position);
static void SpawnGridNodeNPC(const glm::vec4 &position, int32 grid_id, int32 grid_number, int32 zoffset);
static void SpawnZonePointNodeNPC(std::string name, const glm::vec4 &position);
static NPC * SpawnZonePointNodeNPC(std::string name, const glm::vec4 &position);
//abstract virtual function implementations requird by base abstract class
virtual bool Death(Mob* killerMob, int32 damage, uint16 spell_id, EQ::skills::SkillType attack_skill);