mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-30 07:35:45 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d2aae4d79c | |||
| f9dc9da42b | |||
| 3f3bbe98b5 | |||
| 59537ae977 | |||
| ee45a28efe | |||
| 70ce81fb0a | |||
| e06d28ad20 | |||
| d57489781c |
@@ -1,3 +1,31 @@
|
||||
## [22.21.0] - 07/18/2023
|
||||
|
||||
### Data Buckets
|
||||
|
||||
* Implement scoped data buckets ([#3498](https://github.com/EQEmu/Server/pull/3498)) @Akkadius 2023-07-16
|
||||
|
||||
### Fixes
|
||||
|
||||
* Fix rule check and add rule for pickpocket command ([#3492](https://github.com/EQEmu/Server/pull/3492)) @tuday2 2023-07-16
|
||||
|
||||
### Pathing
|
||||
|
||||
* Improvements to roambox logic, pathing ([#3502](https://github.com/EQEmu/Server/pull/3502)) @Akkadius 2023-07-18
|
||||
|
||||
### Quest API
|
||||
|
||||
* Add SetLDoNPoints() to Perl/Lua ([#3496](https://github.com/EQEmu/Server/pull/3496)) @Kinglykrab 2023-07-16
|
||||
|
||||
### Z Clipping
|
||||
|
||||
* Don't issue zclip adjustments when NPC is not moving ([#3499](https://github.com/EQEmu/Server/pull/3499)) @Akkadius 2023-07-16
|
||||
|
||||
## [22.20.1] - 07/15/2023
|
||||
|
||||
### Database
|
||||
|
||||
* Fix database manifest entry for #3443 @neckkola 2023-07-15
|
||||
|
||||
## [22.20.0] - 07/15/2023
|
||||
|
||||
### Bots
|
||||
|
||||
@@ -4768,14 +4768,14 @@ UNIQUE KEY `name` (`name`)
|
||||
.match = "",
|
||||
.sql = R"(
|
||||
ALTER TABLE `raid_members`
|
||||
ADD COLUMN `is_marker` TINYINT UNSIGNED DEFAULT(0) NOT NULL AFTER `islooter`,
|
||||
ADD COLUMN `is_assister` TINYINT UNSIGNED DEFAULT(0) NOT NULL AFTER `is_marker`,
|
||||
ADD COLUMN `note` VARCHAR(64) DEFAULT("") NOT NULL AFTER `is_assister`;
|
||||
ADD COLUMN `is_marker` TINYINT UNSIGNED DEFAULT 0 NOT NULL AFTER `islooter`,
|
||||
ADD COLUMN `is_assister` TINYINT UNSIGNED DEFAULT 0 NOT NULL AFTER `is_marker`,
|
||||
ADD COLUMN `note` VARCHAR(64) DEFAULT '' NOT NULL AFTER `is_assister`;
|
||||
|
||||
ALTER TABLE `raid_details`
|
||||
ADD COLUMN `marked_npc_1` SMALLINT UNSIGNED DEFAULT(0) NOT NULL AFTER `motd`,
|
||||
ADD COLUMN `marked_npc_2` SMALLINT UNSIGNED DEFAULT(0) NOT NULL AFTER `marked_npc_1`,
|
||||
ADD COLUMN `marked_npc_3` SMALLINT UNSIGNED DEFAULT(0) NOT NULL AFTER `marked_npc_2`;
|
||||
ADD COLUMN `marked_npc_1` SMALLINT UNSIGNED DEFAULT 0 NOT NULL AFTER `motd`,
|
||||
ADD COLUMN `marked_npc_2` SMALLINT UNSIGNED DEFAULT 0 NOT NULL AFTER `marked_npc_1`,
|
||||
ADD COLUMN `marked_npc_3` SMALLINT UNSIGNED DEFAULT 0 NOT NULL AFTER `marked_npc_2`;
|
||||
)",
|
||||
},
|
||||
ManifestEntry{
|
||||
@@ -4804,6 +4804,27 @@ UNIQUE KEY `name` (`name`)
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE INDEX `command`(`parent_command`, `sub_command`)
|
||||
)
|
||||
)"
|
||||
},
|
||||
ManifestEntry{
|
||||
.version = 9233,
|
||||
.description = "2023_07_16_scoped_data_buckets.sql",
|
||||
.check = "SHOW COLUMNS FROM `data_buckets` LIKE 'character_id'",
|
||||
.condition = "empty",
|
||||
.match = "",
|
||||
.sql = R"(
|
||||
|
||||
ALTER TABLE `data_buckets`
|
||||
ADD COLUMN `character_id` bigint(11) NOT NULL DEFAULT 0 AFTER `expires`,
|
||||
ADD COLUMN `npc_id` bigint(11) NOT NULL DEFAULT 0 AFTER `character_id`,
|
||||
ADD COLUMN `bot_id` bigint(11) NOT NULL DEFAULT 0 AFTER `npc_id`,
|
||||
DROP INDEX `key_index`,
|
||||
ADD UNIQUE INDEX `keys`(`key`,`character_id`,`npc_id`,`bot_id`);
|
||||
|
||||
UPDATE data_buckets SET character_id = SUBSTRING_INDEX(SUBSTRING_INDEX( `key`, '-', 2 ), '-', -1), `key` = SUBSTR(SUBSTRING_INDEX(`key`, SUBSTRING_INDEX( `key`, '-', 2 ), -1), 2) WHERE `key` LIKE 'character-%';
|
||||
UPDATE data_buckets SET npc_id = SUBSTRING_INDEX(SUBSTRING_INDEX( `key`, '-', 2 ), '-', -1), `key` = SUBSTR(SUBSTRING_INDEX(`key`, SUBSTRING_INDEX( `key`, '-', 2 ), -1), 2) WHERE `key` LIKE 'npc-%';
|
||||
UPDATE data_buckets SET bot_id = SUBSTRING_INDEX(SUBSTRING_INDEX( `key`, '-', 2 ), '-', -1), `key` = SUBSTR(SUBSTRING_INDEX(`key`, SUBSTRING_INDEX( `key`, '-', 2 ), -1), 2) WHERE `key` LIKE 'bot-%';
|
||||
|
||||
)"
|
||||
},
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ public:
|
||||
std::string key_;
|
||||
std::string value;
|
||||
uint32_t expires;
|
||||
int64_t character_id;
|
||||
int64_t npc_id;
|
||||
int64_t bot_id;
|
||||
};
|
||||
|
||||
static std::string PrimaryKey()
|
||||
@@ -38,6 +41,9 @@ public:
|
||||
"`key`",
|
||||
"value",
|
||||
"expires",
|
||||
"character_id",
|
||||
"npc_id",
|
||||
"bot_id",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -48,6 +54,9 @@ public:
|
||||
"`key`",
|
||||
"value",
|
||||
"expires",
|
||||
"character_id",
|
||||
"npc_id",
|
||||
"bot_id",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -88,10 +97,13 @@ public:
|
||||
{
|
||||
DataBuckets e{};
|
||||
|
||||
e.id = 0;
|
||||
e.key_ = "";
|
||||
e.value = "";
|
||||
e.expires = 0;
|
||||
e.id = 0;
|
||||
e.key_ = "";
|
||||
e.value = "";
|
||||
e.expires = 0;
|
||||
e.character_id = 0;
|
||||
e.npc_id = 0;
|
||||
e.bot_id = 0;
|
||||
|
||||
return e;
|
||||
}
|
||||
@@ -128,10 +140,13 @@ public:
|
||||
if (results.RowCount() == 1) {
|
||||
DataBuckets e{};
|
||||
|
||||
e.id = strtoull(row[0], nullptr, 10);
|
||||
e.key_ = row[1] ? row[1] : "";
|
||||
e.value = row[2] ? row[2] : "";
|
||||
e.expires = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||
e.id = strtoull(row[0], nullptr, 10);
|
||||
e.key_ = row[1] ? row[1] : "";
|
||||
e.value = row[2] ? row[2] : "";
|
||||
e.expires = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||
e.character_id = strtoll(row[4], nullptr, 10);
|
||||
e.npc_id = strtoll(row[5], nullptr, 10);
|
||||
e.bot_id = strtoll(row[6], nullptr, 10);
|
||||
|
||||
return e;
|
||||
}
|
||||
@@ -168,6 +183,9 @@ public:
|
||||
v.push_back(columns[1] + " = '" + Strings::Escape(e.key_) + "'");
|
||||
v.push_back(columns[2] + " = '" + Strings::Escape(e.value) + "'");
|
||||
v.push_back(columns[3] + " = " + std::to_string(e.expires));
|
||||
v.push_back(columns[4] + " = " + std::to_string(e.character_id));
|
||||
v.push_back(columns[5] + " = " + std::to_string(e.npc_id));
|
||||
v.push_back(columns[6] + " = " + std::to_string(e.bot_id));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@@ -193,6 +211,9 @@ public:
|
||||
v.push_back("'" + Strings::Escape(e.key_) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.value) + "'");
|
||||
v.push_back(std::to_string(e.expires));
|
||||
v.push_back(std::to_string(e.character_id));
|
||||
v.push_back(std::to_string(e.npc_id));
|
||||
v.push_back(std::to_string(e.bot_id));
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
@@ -226,6 +247,9 @@ public:
|
||||
v.push_back("'" + Strings::Escape(e.key_) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.value) + "'");
|
||||
v.push_back(std::to_string(e.expires));
|
||||
v.push_back(std::to_string(e.character_id));
|
||||
v.push_back(std::to_string(e.npc_id));
|
||||
v.push_back(std::to_string(e.bot_id));
|
||||
|
||||
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
|
||||
}
|
||||
@@ -259,10 +283,13 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
DataBuckets e{};
|
||||
|
||||
e.id = strtoull(row[0], nullptr, 10);
|
||||
e.key_ = row[1] ? row[1] : "";
|
||||
e.value = row[2] ? row[2] : "";
|
||||
e.expires = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||
e.id = strtoull(row[0], nullptr, 10);
|
||||
e.key_ = row[1] ? row[1] : "";
|
||||
e.value = row[2] ? row[2] : "";
|
||||
e.expires = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||
e.character_id = strtoll(row[4], nullptr, 10);
|
||||
e.npc_id = strtoll(row[5], nullptr, 10);
|
||||
e.bot_id = strtoll(row[6], nullptr, 10);
|
||||
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
@@ -287,10 +314,13 @@ public:
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
DataBuckets e{};
|
||||
|
||||
e.id = strtoull(row[0], nullptr, 10);
|
||||
e.key_ = row[1] ? row[1] : "";
|
||||
e.value = row[2] ? row[2] : "";
|
||||
e.expires = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||
e.id = strtoull(row[0], nullptr, 10);
|
||||
e.key_ = row[1] ? row[1] : "";
|
||||
e.value = row[2] ? row[2] : "";
|
||||
e.expires = static_cast<uint32_t>(strtoul(row[3], nullptr, 10));
|
||||
e.character_id = strtoll(row[4], nullptr, 10);
|
||||
e.npc_id = strtoll(row[5], nullptr, 10);
|
||||
e.bot_id = strtoll(row[6], nullptr, 10);
|
||||
|
||||
all_entries.push_back(e);
|
||||
}
|
||||
|
||||
@@ -637,6 +637,7 @@ RULE_BOOL(Bots, OldRaceRezEffects, false, "Older clients had ID 757 for races wi
|
||||
RULE_BOOL(Bots, ResurrectionSickness, true, "Use Resurrection Sickness based on Resurrection spell cast, set to false to disable Resurrection Sickness.")
|
||||
RULE_INT(Bots, OldResurrectionSicknessSpell, 757, "757 is Default Old Resurrection Sickness Spell")
|
||||
RULE_INT(Bots, ResurrectionSicknessSpell, 756, "756 is Default Resurrection Sickness Spell")
|
||||
RULE_BOOL(Bots, AllowPickpocketCommand, true, "Allows the use of the bot command 'pickpocket'")
|
||||
RULE_CATEGORY_END()
|
||||
|
||||
RULE_CATEGORY(Chat)
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@
|
||||
|
||||
// Build variables
|
||||
// these get injected during the build pipeline
|
||||
#define CURRENT_VERSION "22.20.0-dev" // always append -dev to the current version for custom-builds
|
||||
#define CURRENT_VERSION "22.21.0-dev" // always append -dev to the current version for custom-builds
|
||||
#define LOGIN_VERSION "0.8.0"
|
||||
#define COMPILE_DATE __DATE__
|
||||
#define COMPILE_TIME __TIME__
|
||||
@@ -42,7 +42,7 @@
|
||||
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
|
||||
*/
|
||||
|
||||
#define CURRENT_BINARY_DATABASE_VERSION 9232
|
||||
#define CURRENT_BINARY_DATABASE_VERSION 9233
|
||||
|
||||
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9039
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "eqemu-server",
|
||||
"version": "22.20.0",
|
||||
"version": "22.21.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/EQEmu/Server.git"
|
||||
|
||||
+3
-7
@@ -6033,14 +6033,10 @@ float Mob::CheckHeroicBonusesDataBuckets(std::string bucket_name)
|
||||
{
|
||||
std::string bucket_value;
|
||||
if (!bucket_name.empty()) {
|
||||
const auto full_name = fmt::format(
|
||||
"{}-{}",
|
||||
GetBucketKey(),
|
||||
bucket_name
|
||||
);
|
||||
|
||||
DataBucketKey k = GetScopedBucketKeys();
|
||||
k.key = bucket_name;
|
||||
if (IsOfClientBot()) {
|
||||
bucket_value = DataBucket::CheckBucketKey(this, full_name);
|
||||
bucket_value = DataBucket::CheckBucketKey(this, k);
|
||||
}
|
||||
|
||||
if (bucket_value.empty() || !Strings::IsNumber(bucket_value)) {
|
||||
|
||||
+7
-12
@@ -8193,21 +8193,16 @@ void Bot::OwnerMessage(const std::string& message)
|
||||
bool Bot::CheckDataBucket(std::string bucket_name, const std::string& bucket_value, uint8 bucket_comparison)
|
||||
{
|
||||
if (!bucket_name.empty() && !bucket_value.empty()) {
|
||||
auto full_name = fmt::format(
|
||||
"{}-{}",
|
||||
GetBucketKey(),
|
||||
bucket_name
|
||||
);
|
||||
// try to fetch from bot first
|
||||
DataBucketKey k = GetScopedBucketKeys();
|
||||
k.key = bucket_name;
|
||||
|
||||
auto player_value = DataBucket::CheckBucketKey(this, full_name);
|
||||
auto player_value = DataBucket::CheckBucketKey(this, k);
|
||||
if (player_value.empty() && GetBotOwner()) {
|
||||
full_name = fmt::format(
|
||||
"{}-{}",
|
||||
GetBotOwner()->GetBucketKey(),
|
||||
bucket_name
|
||||
);
|
||||
// fetch from owner
|
||||
k = GetBotOwner()->GetScopedBucketKeys();
|
||||
|
||||
player_value = DataBucket::CheckBucketKey(GetBotOwner(), full_name);
|
||||
player_value = DataBucket::CheckBucketKey(GetBotOwner(), k);
|
||||
if (player_value.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -9170,7 +9170,7 @@ bool helper_cast_standard_spell(Bot* casting_bot, Mob* target_mob, int spell_id,
|
||||
|
||||
bool helper_command_disabled(Client* bot_owner, bool rule_value, const char* command)
|
||||
{
|
||||
if (rule_value) {
|
||||
if (!rule_value) {
|
||||
bot_owner->Message(Chat::White, "Bot command %s is not enabled on this server.", command);
|
||||
return true;
|
||||
}
|
||||
@@ -9999,6 +9999,10 @@ void bot_command_caster_range(Client* c, const Seperator* sep)
|
||||
|
||||
void bot_command_pickpocket(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (helper_command_disabled(c, RuleB(Bots, AllowPickpocketCommand), "pickpocket")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (helper_command_alias_fail(c, "bot_command_pickpocket", sep->arg[0], "pickpocket")) {
|
||||
return;
|
||||
}
|
||||
@@ -10032,7 +10036,9 @@ void bot_command_pickpocket(Client *c, const Seperator *sep)
|
||||
glm::vec4 mob_distance = (c->GetPosition() - target_mob->GetPosition());
|
||||
float mob_xy_distance = ((mob_distance.x * mob_distance.x) + (mob_distance.y * mob_distance.y));
|
||||
float mob_z_distance = (mob_distance.z * mob_distance.z);
|
||||
if (mob_z_distance >= 25 || mob_xy_distance > 250) {
|
||||
float z_offset_diff = target_mob->GetZOffset() - c->GetZOffset();
|
||||
|
||||
if (mob_z_distance >= (35-z_offset_diff) || mob_xy_distance > 250) {
|
||||
c->Message(Chat::White, "You must be closer to an enemy to use this command");
|
||||
return;
|
||||
}
|
||||
|
||||
+7
-1
@@ -1558,7 +1558,13 @@ void Client::SetLDoNPoints(uint32 theme_id, uint32 points)
|
||||
}
|
||||
}
|
||||
|
||||
m_pp.ldon_points_available += points;
|
||||
m_pp.ldon_points_available = (
|
||||
m_pp.ldon_points_guk +
|
||||
m_pp.ldon_points_mir +
|
||||
m_pp.ldon_points_mmc +
|
||||
m_pp.ldon_points_ruj +
|
||||
m_pp.ldon_points_tak
|
||||
);
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_AdventurePointsUpdate, sizeof(AdventurePoints_Update_Struct));
|
||||
|
||||
|
||||
@@ -853,13 +853,11 @@ void Client::BulkSendMerchantInventory(int merchant_id, int npcid) {
|
||||
auto bucket_name = ml.bucket_name;
|
||||
auto const& bucket_value = ml.bucket_value;
|
||||
if (!bucket_name.empty() && !bucket_value.empty()) {
|
||||
auto full_name = fmt::format(
|
||||
"{}-{}",
|
||||
GetBucketKey(),
|
||||
bucket_name
|
||||
);
|
||||
|
||||
auto const& player_value = DataBucket::CheckBucketKey(this, full_name);
|
||||
DataBucketKey k = GetScopedBucketKeys();
|
||||
k.key = bucket_name;
|
||||
|
||||
auto const& player_value = DataBucket::CheckBucketKey(this, k);
|
||||
if (player_value.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
+184
-158
@@ -1,173 +1,130 @@
|
||||
#include "data_bucket.h"
|
||||
#include "zonedb.h"
|
||||
#include "mob.h"
|
||||
#include <ctime>
|
||||
#include <cctype>
|
||||
#include "../common/repositories/data_buckets_repository.h"
|
||||
|
||||
/**
|
||||
* Persists data via bucket_name as key
|
||||
* @param bucket_key
|
||||
* @param bucket_value
|
||||
* @param expires_time
|
||||
*/
|
||||
void DataBucket::SetData(const std::string& bucket_key, const std::string& bucket_value, std::string expires_time) {
|
||||
uint64 bucket_id = DataBucket::DoesBucketExist(bucket_key);
|
||||
void DataBucket::SetData(const std::string &bucket_key, const std::string &bucket_value, std::string expires_time)
|
||||
{
|
||||
auto k = DataBucketKey{
|
||||
.key = bucket_key,
|
||||
.value = bucket_value,
|
||||
.expires = expires_time,
|
||||
.character_id = 0,
|
||||
.npc_id = 0,
|
||||
.bot_id = 0
|
||||
};
|
||||
|
||||
std::string query;
|
||||
DataBucket::SetData(k);
|
||||
}
|
||||
|
||||
void DataBucket::SetData(const DataBucketKey &k)
|
||||
{
|
||||
auto r = DataBucketsRepository::GetWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"{} `key` = '{}' AND (`expires` > {} OR `expires` = 0) LIMIT 1",
|
||||
DataBucket::GetScopedDbFilters(k),
|
||||
Strings::Escape(k.key),
|
||||
(long long) std::time(nullptr)
|
||||
)
|
||||
);
|
||||
|
||||
// if we have an entry, use it
|
||||
auto b = DataBucketsRepository::NewEntity();
|
||||
if (!r.empty()) {
|
||||
b = r[0];
|
||||
}
|
||||
|
||||
if (k.character_id > 0) {
|
||||
b.character_id = k.character_id;
|
||||
} else if (k.npc_id > 0) {
|
||||
b.npc_id = k.npc_id;
|
||||
} else if (k.bot_id > 0) {
|
||||
b.bot_id = k.bot_id;
|
||||
}
|
||||
|
||||
uint64 bucket_id = b.id;
|
||||
long long expires_time_unix = 0;
|
||||
|
||||
if (!expires_time.empty()) {
|
||||
if (isalpha(expires_time[0]) || isalpha(expires_time[expires_time.length() - 1])) {
|
||||
expires_time_unix = (long long) std::time(nullptr) + Strings::TimeToSeconds(expires_time);
|
||||
} else {
|
||||
expires_time_unix = (long long) std::time(nullptr) + Strings::ToInt(expires_time);
|
||||
if (!k.expires.empty()) {
|
||||
expires_time_unix = (long long) std::time(nullptr) + Strings::ToInt(k.expires);
|
||||
if (isalpha(k.expires[0]) || isalpha(k.expires[k.expires.length() - 1])) {
|
||||
expires_time_unix = (long long) std::time(nullptr) + Strings::TimeToSeconds(k.expires);
|
||||
}
|
||||
}
|
||||
|
||||
if (bucket_id > 0) {
|
||||
std::string update_expired_time;
|
||||
if (expires_time_unix > 0) {
|
||||
update_expired_time = StringFormat(", `expires` = %lld ", expires_time_unix);
|
||||
}
|
||||
|
||||
query = StringFormat(
|
||||
"UPDATE `data_buckets` SET `value` = '%s' %s WHERE `id` = %i",
|
||||
Strings::Escape(bucket_value).c_str(),
|
||||
Strings::Escape(update_expired_time).c_str(),
|
||||
bucket_id
|
||||
);
|
||||
b.expires = expires_time_unix;
|
||||
b.value = k.value;
|
||||
DataBucketsRepository::UpdateOne(database, b);
|
||||
}
|
||||
else {
|
||||
query = StringFormat(
|
||||
"INSERT INTO `data_buckets` (`key`, `value`, `expires`) VALUES ('%s', '%s', '%lld')",
|
||||
Strings::Escape(bucket_key).c_str(),
|
||||
Strings::Escape(bucket_value).c_str(),
|
||||
expires_time_unix
|
||||
);
|
||||
b.expires = expires_time_unix;
|
||||
b.key_ = k.key;
|
||||
b.value = k.value;
|
||||
DataBucketsRepository::InsertOne(database, b);
|
||||
}
|
||||
|
||||
database.QueryDatabase(query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves data via bucket_name as key
|
||||
* @param bucket_key
|
||||
* @return
|
||||
*/
|
||||
std::string DataBucket::GetData(const std::string& bucket_key) {
|
||||
std::string query = StringFormat(
|
||||
"SELECT `value` from `data_buckets` WHERE `key` = '%s' AND (`expires` > %lld OR `expires` = 0) LIMIT 1",
|
||||
bucket_key.c_str(),
|
||||
(long long) std::time(nullptr)
|
||||
);
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
if (results.RowCount() != 1)
|
||||
return std::string();
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
return std::string(row[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves data expires time via bucket_name as key
|
||||
* @param bucket_key
|
||||
* @return
|
||||
*/
|
||||
std::string DataBucket::GetDataExpires(const std::string& bucket_key) {
|
||||
std::string query = StringFormat(
|
||||
"SELECT `expires` from `data_buckets` WHERE `key` = '%s' AND (`expires` > %lld OR `expires` = 0) LIMIT 1",
|
||||
bucket_key.c_str(),
|
||||
(long long) std::time(nullptr)
|
||||
);
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
if (results.RowCount() != 1)
|
||||
return std::string();
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
return std::string(row[0]);
|
||||
}
|
||||
|
||||
std::string DataBucket::GetDataRemaining(const std::string& bucket_key) {
|
||||
if (DataBucket::GetDataExpires(bucket_key).empty()) {
|
||||
return "0";
|
||||
}
|
||||
std::string query = fmt::format(
|
||||
"SELECT (`expires` - UNIX_TIMESTAMP()) AS `remaining` from `data_buckets` WHERE `key` = '{}' AND (`expires` > {} OR `expires` = 0) LIMIT 1",
|
||||
bucket_key.c_str(),
|
||||
(long long) std::time(nullptr)
|
||||
);
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
if (results.RowCount() != 1)
|
||||
return std::string();
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
return std::string(row[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for bucket existence by bucket_name key
|
||||
* @param bucket_key
|
||||
* @return
|
||||
*/
|
||||
uint64 DataBucket::DoesBucketExist(const std::string& bucket_key) {
|
||||
std::string query = StringFormat(
|
||||
"SELECT `id` from `data_buckets` WHERE `key` = '%s' AND (`expires` > %lld OR `expires` = 0) LIMIT 1",
|
||||
Strings::Escape(bucket_key).c_str(),
|
||||
(long long) std::time(nullptr)
|
||||
);
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto row = results.begin();
|
||||
if (results.RowCount() != 1)
|
||||
return 0;
|
||||
|
||||
return Strings::ToUnsignedBigInt(row[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes data bucket by key
|
||||
* @param bucket_key
|
||||
* @return
|
||||
*/
|
||||
bool DataBucket::DeleteData(const std::string& bucket_key) {
|
||||
std::string query = StringFormat(
|
||||
"DELETE FROM `data_buckets` WHERE `key` = '%s'",
|
||||
Strings::Escape(bucket_key).c_str()
|
||||
);
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
|
||||
return results.Success();
|
||||
}
|
||||
|
||||
bool DataBucket::GetDataBuckets(Mob* mob)
|
||||
std::string DataBucket::GetData(const std::string &bucket_key)
|
||||
{
|
||||
auto l = BaseDataBucketsRepository::GetWhere(
|
||||
DataBucketKey k = {};
|
||||
k.key = bucket_key;
|
||||
return GetData(k);
|
||||
}
|
||||
|
||||
std::string DataBucket::GetData(const DataBucketKey &k)
|
||||
{
|
||||
auto r = DataBucketsRepository::GetWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"`key` LIKE '{}-%'",
|
||||
Strings::Escape(mob->GetBucketKey())
|
||||
"{} `key` = '{}' AND (`expires` > {} OR `expires` = 0) LIMIT 1",
|
||||
DataBucket::GetScopedDbFilters(k),
|
||||
k.key,
|
||||
(long long) std::time(nullptr)
|
||||
)
|
||||
);
|
||||
|
||||
if (r.empty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return r[0].value;
|
||||
}
|
||||
|
||||
std::string DataBucket::GetDataExpires(const std::string &bucket_key)
|
||||
{
|
||||
DataBucketKey k = {};
|
||||
k.key = bucket_key;
|
||||
|
||||
return GetDataExpires(k);
|
||||
}
|
||||
|
||||
std::string DataBucket::GetDataRemaining(const std::string &bucket_key)
|
||||
{
|
||||
DataBucketKey k = {};
|
||||
k.key = bucket_key;
|
||||
return GetDataRemaining(k);
|
||||
}
|
||||
|
||||
bool DataBucket::DeleteData(const std::string &bucket_key)
|
||||
{
|
||||
DataBucketKey r = {};
|
||||
r.key = bucket_key;
|
||||
return DeleteData(r);
|
||||
}
|
||||
|
||||
bool DataBucket::GetDataBuckets(Mob *mob)
|
||||
{
|
||||
DataBucketKey k = mob->GetScopedBucketKeys();
|
||||
auto l = BaseDataBucketsRepository::GetWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"{} (`expires` > {} OR `expires` = 0)",
|
||||
DataBucket::GetScopedDbFilters(k),
|
||||
(long long) std::time(nullptr)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -179,10 +136,10 @@ bool DataBucket::GetDataBuckets(Mob* mob)
|
||||
|
||||
DataBucketCache d;
|
||||
|
||||
for (const auto& e : l) {
|
||||
d.bucket_id = e.id;
|
||||
d.bucket_key = e.key_;
|
||||
d.bucket_value = e.value;
|
||||
for (const auto &e: l) {
|
||||
d.bucket_id = e.id;
|
||||
d.bucket_key = e.key_;
|
||||
d.bucket_value = e.value;
|
||||
d.bucket_expires = e.expires;
|
||||
|
||||
mob->m_data_bucket_cache.emplace_back(d);
|
||||
@@ -191,11 +148,11 @@ bool DataBucket::GetDataBuckets(Mob* mob)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string DataBucket::CheckBucketKey(const Mob* mob, std::string_view full_name)
|
||||
std::string DataBucket::CheckBucketKey(const Mob *mob, const DataBucketKey &k)
|
||||
{
|
||||
std::string bucket_value;
|
||||
for (const auto &d : mob->m_data_bucket_cache) {
|
||||
if (d.bucket_key == full_name) {
|
||||
std::string bucket_value;
|
||||
for (const auto &d: mob->m_data_bucket_cache) {
|
||||
if (d.bucket_key == k.key) {
|
||||
bucket_value = d.bucket_value;
|
||||
break;
|
||||
}
|
||||
@@ -203,3 +160,72 @@ std::string DataBucket::CheckBucketKey(const Mob* mob, std::string_view full_nam
|
||||
return bucket_value;
|
||||
}
|
||||
|
||||
bool DataBucket::DeleteData(const DataBucketKey &k)
|
||||
{
|
||||
return DataBucketsRepository::DeleteWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"{} `key` = '{}'",
|
||||
DataBucket::GetScopedDbFilters(k),
|
||||
k.key
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
std::string DataBucket::GetDataExpires(const DataBucketKey &k)
|
||||
{
|
||||
auto r = DataBucketsRepository::GetWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"{} `key` = '{}' AND (`expires` > {} OR `expires` = 0) LIMIT 1",
|
||||
DataBucket::GetScopedDbFilters(k),
|
||||
k.key,
|
||||
(long long) std::time(nullptr)
|
||||
)
|
||||
);
|
||||
|
||||
if (r.empty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return fmt::format("{}", r[0].expires);
|
||||
}
|
||||
|
||||
std::string DataBucket::GetDataRemaining(const DataBucketKey &k)
|
||||
{
|
||||
auto r = DataBucketsRepository::GetWhere(
|
||||
database,
|
||||
fmt::format(
|
||||
"{} `key` = '{}' AND (`expires` > {} OR `expires` = 0) LIMIT 1",
|
||||
DataBucket::GetScopedDbFilters(k),
|
||||
k.key,
|
||||
(long long) std::time(nullptr)
|
||||
)
|
||||
);
|
||||
|
||||
if (r.empty()) {
|
||||
return "0";
|
||||
}
|
||||
|
||||
return fmt::format("{}", r[0].expires - (long long) std::time(nullptr));
|
||||
}
|
||||
|
||||
std::string DataBucket::GetScopedDbFilters(const DataBucketKey &k)
|
||||
{
|
||||
std::vector<std::string> query = {};
|
||||
if (k.character_id > 0) {
|
||||
query.emplace_back(fmt::format("character_id = {}", k.character_id));
|
||||
}
|
||||
else if (k.npc_id > 0) {
|
||||
query.emplace_back(fmt::format("npc_id = {}", k.npc_id));
|
||||
}
|
||||
else if (k.bot_id > 0) {
|
||||
query.emplace_back(fmt::format("bot_id = {}", k.bot_id));
|
||||
}
|
||||
|
||||
return fmt::format(
|
||||
"{} {}",
|
||||
Strings::Join(query, " AND "),
|
||||
!query.empty() ? "AND" : ""
|
||||
);
|
||||
}
|
||||
|
||||
+21
-4
@@ -10,18 +10,35 @@
|
||||
#include "../common/repositories/data_buckets_repository.h"
|
||||
#include "mob.h"
|
||||
|
||||
|
||||
struct DataBucketKey {
|
||||
std::string key;
|
||||
std::string value;
|
||||
std::string expires;
|
||||
int64_t character_id;
|
||||
int64_t npc_id;
|
||||
int64_t bot_id;
|
||||
};
|
||||
|
||||
class DataBucket {
|
||||
public:
|
||||
// non-scoped bucket methods (for global buckets)
|
||||
static void SetData(const std::string& bucket_key, const std::string& bucket_value, std::string expires_time = "");
|
||||
static bool DeleteData(const std::string& bucket_key);
|
||||
static std::string GetData(const std::string& bucket_key);
|
||||
static std::string GetDataExpires(const std::string& bucket_key);
|
||||
static std::string GetDataRemaining(const std::string& bucket_key);
|
||||
static bool GetDataBuckets(Mob* mob);
|
||||
static std::string CheckBucketKey(const Mob* mob, std::string_view full_name);
|
||||
|
||||
private:
|
||||
static uint64 DoesBucketExist(const std::string& bucket_key);
|
||||
static bool GetDataBuckets(Mob* mob);
|
||||
|
||||
// scoped bucket methods
|
||||
static void SetData(const DataBucketKey& k);
|
||||
static bool DeleteData(const DataBucketKey& k);
|
||||
static std::string GetData(const DataBucketKey& k);
|
||||
static std::string GetDataExpires(const DataBucketKey& k);
|
||||
static std::string GetDataRemaining(const DataBucketKey& k);
|
||||
static std::string CheckBucketKey(const Mob* mob, const DataBucketKey& k);
|
||||
static std::string GetScopedDbFilters(const DataBucketKey& k);
|
||||
};
|
||||
|
||||
#endif //EQEMU_DATABUCKET_H
|
||||
|
||||
+3
-17
@@ -1273,24 +1273,10 @@ uint8 Client::GetCharMaxLevelFromQGlobal() {
|
||||
|
||||
uint8 Client::GetCharMaxLevelFromBucket()
|
||||
{
|
||||
auto new_bucket_name = fmt::format(
|
||||
"{}-CharMaxLevel",
|
||||
GetBucketKey()
|
||||
);
|
||||
DataBucketKey k = GetScopedBucketKeys();
|
||||
k.key = "CharMaxLevel";
|
||||
|
||||
auto bucket_value = DataBucket::GetData(new_bucket_name);
|
||||
if (!bucket_value.empty()) {
|
||||
if (Strings::IsNumber(bucket_value)) {
|
||||
return static_cast<uint8>(Strings::ToUnsignedInt(bucket_value));
|
||||
}
|
||||
}
|
||||
|
||||
auto old_bucket_name = fmt::format(
|
||||
"{}-CharMaxLevel",
|
||||
CharacterID()
|
||||
);
|
||||
|
||||
bucket_value = DataBucket::GetData(old_bucket_name);
|
||||
auto bucket_value = DataBucket::GetData(k);
|
||||
if (!bucket_value.empty()) {
|
||||
if (Strings::IsNumber(bucket_value)) {
|
||||
return static_cast<uint8>(Strings::ToUnsignedInt(bucket_value));
|
||||
|
||||
@@ -3092,6 +3092,12 @@ std::string Lua_Client::GetRaceAbbreviation()
|
||||
return GetPlayerRaceAbbreviation(self->GetBaseRace());
|
||||
}
|
||||
|
||||
void Lua_Client::SetLDoNPoints(uint32 theme_id, uint32 points)
|
||||
{
|
||||
Lua_Safe_Call_Void();
|
||||
self->SetLDoNPoints(theme_id, points);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_client() {
|
||||
return luabind::class_<Lua_Client, Lua_Mob>("Client")
|
||||
.def(luabind::constructor<>())
|
||||
@@ -3536,6 +3542,7 @@ luabind::scope lua_register_client() {
|
||||
.def("SetIPExemption", (void(Lua_Client::*)(int))&Lua_Client::SetIPExemption)
|
||||
.def("SetItemCooldown", (void(Lua_Client::*)(uint32,uint32))&Lua_Client::SetItemCooldown)
|
||||
.def("SetLanguageSkill", (void(Lua_Client::*)(int,int))&Lua_Client::SetLanguageSkill)
|
||||
.def("SetLDoNPoints", (void(Lua_Client::*)(uint32,uint32))&Lua_Client::SetLDoNPoints)
|
||||
.def("SetMaterial", (void(Lua_Client::*)(int,uint32))&Lua_Client::SetMaterial)
|
||||
.def("SetPEQZoneFlag", (void(Lua_Client::*)(uint32))&Lua_Client::SetPEQZoneFlag)
|
||||
.def("SetPVP", (void(Lua_Client::*)(bool))&Lua_Client::SetPVP)
|
||||
|
||||
@@ -473,6 +473,7 @@ public:
|
||||
uint32 GetEXPForLevel(uint16 check_level);
|
||||
std::string GetClassAbbreviation();
|
||||
std::string GetRaceAbbreviation();
|
||||
void SetLDoNPoints(uint32 theme_id, uint32 points);
|
||||
|
||||
void ApplySpell(int spell_id);
|
||||
void ApplySpell(int spell_id, int duration);
|
||||
|
||||
+1
-1
@@ -2353,7 +2353,7 @@ std::string Lua_Mob::GetBucketExpires(std::string bucket_name)
|
||||
std::string Lua_Mob::GetBucketKey()
|
||||
{
|
||||
Lua_Safe_Call_String();
|
||||
return self->GetBucketKey();
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string Lua_Mob::GetBucketRemaining(std::string bucket_name)
|
||||
|
||||
+52
-29
@@ -8049,54 +8049,63 @@ void Mob::SetCanOpenDoors(bool can_open)
|
||||
m_can_open_doors = can_open;
|
||||
}
|
||||
|
||||
void Mob::DeleteBucket(std::string bucket_name) {
|
||||
std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name);
|
||||
DataBucket::DeleteData(full_bucket_name);
|
||||
void Mob::DeleteBucket(std::string bucket_name)
|
||||
{
|
||||
DataBucketKey k = GetScopedBucketKeys();
|
||||
k.key = bucket_name;
|
||||
|
||||
DataBucket::DeleteData(k);
|
||||
}
|
||||
|
||||
std::string Mob::GetBucket(std::string bucket_name) {
|
||||
std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name);
|
||||
std::string bucket_value = DataBucket::GetData(full_bucket_name);
|
||||
std::string Mob::GetBucket(std::string bucket_name)
|
||||
{
|
||||
DataBucketKey k = GetScopedBucketKeys();
|
||||
k.key = bucket_name;
|
||||
|
||||
std::string bucket_value = DataBucket::GetData(k);
|
||||
if (!bucket_value.empty()) {
|
||||
return bucket_value;
|
||||
}
|
||||
return std::string();
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string Mob::GetBucketExpires(std::string bucket_name) {
|
||||
std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name);
|
||||
std::string bucket_expiration = DataBucket::GetDataExpires(full_bucket_name);
|
||||
std::string Mob::GetBucketExpires(std::string bucket_name)
|
||||
{
|
||||
DataBucketKey k = GetScopedBucketKeys();
|
||||
k.key = bucket_name;
|
||||
|
||||
std::string bucket_expiration = DataBucket::GetDataExpires(k);
|
||||
if (!bucket_expiration.empty()) {
|
||||
return bucket_expiration;
|
||||
}
|
||||
return std::string();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string Mob::GetBucketKey() {
|
||||
if (IsClient()) {
|
||||
return fmt::format("character-{}", CastToClient()->CharacterID());
|
||||
} else if (IsNPC()) {
|
||||
return fmt::format("npc-{}", GetNPCTypeID());
|
||||
} else if (IsBot()) {
|
||||
return fmt::format("bot-{}", CastToBot()->GetBotID());
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
std::string Mob::GetBucketRemaining(std::string bucket_name)
|
||||
{
|
||||
DataBucketKey k = GetScopedBucketKeys();
|
||||
k.key = bucket_name;
|
||||
|
||||
std::string Mob::GetBucketRemaining(std::string bucket_name) {
|
||||
std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name);
|
||||
std::string bucket_remaining = DataBucket::GetDataRemaining(full_bucket_name);
|
||||
std::string bucket_remaining = DataBucket::GetDataRemaining(k);
|
||||
if (!bucket_remaining.empty() && Strings::ToInt(bucket_remaining) > 0) {
|
||||
return bucket_remaining;
|
||||
} else if (Strings::ToInt(bucket_remaining) == 0) {
|
||||
}
|
||||
else if (Strings::ToInt(bucket_remaining) == 0) {
|
||||
return "0";
|
||||
}
|
||||
return std::string();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void Mob::SetBucket(std::string bucket_name, std::string bucket_value, std::string expiration) {
|
||||
std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name);
|
||||
DataBucket::SetData(full_bucket_name, bucket_value, expiration);
|
||||
void Mob::SetBucket(std::string bucket_name, std::string bucket_value, std::string expiration)
|
||||
{
|
||||
DataBucketKey k = GetScopedBucketKeys();
|
||||
k.key = bucket_name;
|
||||
k.expires = expiration;
|
||||
k.value = bucket_value;
|
||||
|
||||
DataBucket::SetData(k);
|
||||
}
|
||||
|
||||
std::string Mob::GetMobDescription()
|
||||
@@ -8329,3 +8338,17 @@ std::string Mob::GetClassPlural()
|
||||
return "Classes";
|
||||
}
|
||||
}
|
||||
|
||||
DataBucketKey Mob::GetScopedBucketKeys()
|
||||
{
|
||||
DataBucketKey k = {};
|
||||
if (IsClient()) {
|
||||
k.character_id = CastToClient()->CharacterID();
|
||||
} else if (IsNPC()) {
|
||||
k.npc_id = GetNPCTypeID();
|
||||
} else if (IsBot()) {
|
||||
k.bot_id = CastToBot()->GetBotID();
|
||||
}
|
||||
|
||||
return k;
|
||||
}
|
||||
|
||||
+3
-1
@@ -69,6 +69,7 @@ enum class eSpecialAttacks : int {
|
||||
ChaoticStab
|
||||
};
|
||||
|
||||
class DataBucketKey;
|
||||
class Mob : public Entity {
|
||||
public:
|
||||
enum CLIENT_CONN_STATUS { CLIENT_CONNECTING, CLIENT_CONNECTED, CLIENT_LINKDEAD,
|
||||
@@ -1413,7 +1414,6 @@ public:
|
||||
void DeleteBucket(std::string bucket_name);
|
||||
std::string GetBucket(std::string bucket_name);
|
||||
std::string GetBucketExpires(std::string bucket_name);
|
||||
std::string GetBucketKey();
|
||||
std::string GetBucketRemaining(std::string bucket_name);
|
||||
void SetBucket(std::string bucket_name, std::string bucket_value, std::string expiration = "");
|
||||
|
||||
@@ -1443,6 +1443,8 @@ public:
|
||||
|
||||
void CalcHeroicBonuses(StatBonuses* newbon);
|
||||
|
||||
DataBucketKey GetScopedBucketKeys();
|
||||
|
||||
protected:
|
||||
void CommonDamage(Mob* other, int64 &damage, const uint16 spell_id, const EQ::skills::SkillType attack_skill, bool &avoidable, const int8 buffslot, const bool iBuffTic, eSpecialAttacks specal = eSpecialAttacks::None);
|
||||
static uint16 GetProcID(uint16 spell_id, uint8 effect_index);
|
||||
|
||||
+9
-6
@@ -1071,12 +1071,15 @@ void Mob::AI_Process() {
|
||||
|
||||
if (engaged) {
|
||||
if (IsNPC() && m_z_clip_check_timer.Check()) {
|
||||
auto t = GetTarget();
|
||||
if (t) {
|
||||
float self_z = GetZ() - GetZOffset();
|
||||
float target_z = t->GetPosition().z - t->GetZOffset();
|
||||
if (DistanceNoZ(GetPosition(), t->GetPosition()) < 75 &&
|
||||
std::abs(self_z - target_z) >= 25 && !CheckLosFN(t)) {
|
||||
bool is_moving = IsMoving() && !(IsRooted() || IsStunned() || IsMezzed());
|
||||
auto t = GetTarget();
|
||||
if (is_moving && t) {
|
||||
float self_z = GetZ() - GetZOffset();
|
||||
float target_z = t->GetPosition().z - t->GetZOffset();
|
||||
bool can_path_to = CastToNPC()->CanPathTo(t->GetX(), t->GetY(), t->GetZ());
|
||||
bool within_distance = DistanceNoZ(GetPosition(), t->GetPosition()) < 75;
|
||||
bool within_z_distance = std::abs(self_z - target_z) >= 25;
|
||||
if (within_distance && within_z_distance && !can_path_to) {
|
||||
float new_z = FindDestGroundZ(t->GetPosition());
|
||||
GMMove(t->GetPosition().x, t->GetPosition().y, new_z + GetZOffset(), t->GetPosition().w, false);
|
||||
FaceTarget(t);
|
||||
|
||||
+27
-1
@@ -3825,9 +3825,14 @@ void NPC::HandleRoambox()
|
||||
auto requested_y = EQ::Clamp((GetY() + move_y), m_roambox.min_y, m_roambox.max_y);
|
||||
auto requested_z = GetGroundZ(requested_x, requested_y);
|
||||
|
||||
if (std::abs(requested_z - GetZ()) > 100) {
|
||||
LogNPCRoamBox("[{}] | Failed to find reasonable ground [{}]", GetCleanName(), i);
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<float> heights = {0, 250, -250};
|
||||
for (auto &h: heights) {
|
||||
if (CheckLosFN(requested_x, requested_y, requested_z + h, GetSize())) {
|
||||
if (CanPathTo(requested_x, requested_y, requested_z + h)) {
|
||||
LogNPCRoamBox("[{}] Found line of sight to path attempt [{}] at height [{}]", GetCleanName(), i, h);
|
||||
can_path = true;
|
||||
break;
|
||||
@@ -3942,3 +3947,24 @@ void NPC::SetTaunting(bool is_taunting) {
|
||||
GetOwner()->CastToClient()->SetPetCommandState(PET_BUTTON_TAUNT, is_taunting);
|
||||
}
|
||||
}
|
||||
|
||||
bool NPC::CanPathTo(float x, float y, float z)
|
||||
{
|
||||
PathfinderOptions opts;
|
||||
opts.smooth_path = true;
|
||||
opts.step_size = RuleR(Pathing, NavmeshStepSize);
|
||||
opts.offset = GetZOffset();
|
||||
opts.flags = PathingNotDisabled ^ PathingZoneLine;
|
||||
|
||||
bool partial = false;
|
||||
bool stuck = false;
|
||||
auto route = zone->pathing->FindPath(
|
||||
glm::vec3(GetX(), GetY(), GetZ()),
|
||||
glm::vec3(x, y, z),
|
||||
partial,
|
||||
stuck,
|
||||
opts
|
||||
);
|
||||
|
||||
return !route.empty();
|
||||
}
|
||||
|
||||
@@ -541,6 +541,8 @@ public:
|
||||
|
||||
static LootDropEntries_Struct NewLootDropEntry();
|
||||
|
||||
bool CanPathTo(float x, float y, float z);
|
||||
|
||||
protected:
|
||||
|
||||
void HandleRoambox();
|
||||
|
||||
@@ -2947,6 +2947,11 @@ std::string Perl_Client_GetRaceAbbreviation(Client* self)
|
||||
return GetPlayerRaceAbbreviation(self->GetBaseRace());
|
||||
}
|
||||
|
||||
void Perl_Client_SetLDoNPoints(Client* self, uint32 theme_id, uint32 points)
|
||||
{
|
||||
self->SetLDoNPoints(theme_id, points);
|
||||
}
|
||||
|
||||
void perl_register_client()
|
||||
{
|
||||
perl::interpreter perl(PERL_GET_THX);
|
||||
@@ -3394,6 +3399,7 @@ void perl_register_client()
|
||||
package.add("SetInvulnerableEnvironmentDamage", &Perl_Client_SetInvulnerableEnvironmentDamage);
|
||||
package.add("SetItemCooldown", &Perl_Client_SetItemCooldown);
|
||||
package.add("SetLanguageSkill", &Perl_Client_SetLanguageSkill);
|
||||
package.add("SetLDoNPoints", &Perl_Client_SetLDoNPoints);
|
||||
package.add("SetMaterial", &Perl_Client_SetMaterial);
|
||||
package.add("SetPEQZoneFlag", &Perl_Client_SetPEQZoneFlag);
|
||||
package.add("SetPVP", &Perl_Client_SetPVP);
|
||||
|
||||
+1
-1
@@ -2420,7 +2420,7 @@ std::string Perl_Mob_GetBucketExpires(Mob* self, std::string bucket_name) // @ca
|
||||
|
||||
std::string Perl_Mob_GetBucketKey(Mob* self) // @categories Script Utility
|
||||
{
|
||||
return self->GetBucketKey();
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string Perl_Mob_GetBucketRemaining(Mob* self, std::string bucket_name) // @categories Script Utility
|
||||
|
||||
+3
-6
@@ -5877,13 +5877,10 @@ bool Client::SpellBucketCheck(uint16 spell_id, uint32 character_id) {
|
||||
return true; // If the entry in the spell_buckets table has nothing set for the qglobal name, allow scribing.
|
||||
}
|
||||
|
||||
auto new_bucket_name = fmt::format(
|
||||
"{}-{}",
|
||||
GetBucketKey(),
|
||||
spell_bucket_name
|
||||
);
|
||||
DataBucketKey k = GetScopedBucketKeys();
|
||||
k.key = spell_bucket_name;
|
||||
|
||||
auto bucket_value = DataBucket::GetData(new_bucket_name);
|
||||
auto bucket_value = DataBucket::GetData(k);
|
||||
if (!bucket_value.empty()) {
|
||||
if (Strings::IsNumber(bucket_value) && Strings::IsNumber(spell_bucket_value)) {
|
||||
if (Strings::ToInt(bucket_value) >= Strings::ToInt(spell_bucket_value)) {
|
||||
|
||||
+8
-1
@@ -846,8 +846,15 @@ void Mob::FixZ(int32 z_find_offset /*= 5*/, bool fix_client_z /*= false*/) {
|
||||
glm::vec3 current_loc(m_Position);
|
||||
float new_z = GetFixedZ(current_loc, z_find_offset);
|
||||
|
||||
if (new_z == m_Position.z)
|
||||
// reject z if it is too far from the current z
|
||||
if (std::abs(new_z - m_Position.z) > 100) {
|
||||
return;
|
||||
}
|
||||
|
||||
// reject if it's the same as the current z
|
||||
if (new_z == m_Position.z) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((new_z > -2000) && new_z != BEST_Z_INVALID) {
|
||||
if (RuleB(Map, MobZVisualDebug)) {
|
||||
|
||||
Reference in New Issue
Block a user