mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
Add another layer of randomization to roam box logic, npc's who weren't originally spawned in water won't roambox into water
This commit is contained in:
parent
4b6ab34fd9
commit
834062fbf9
@ -5455,3 +5455,11 @@ void Mob::DoOffHandAttackRounds(Mob *target, ExtraAttackOptions *opts)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Mob::GetWasSpawnedInWater() const {
|
||||||
|
return spawned_in_water;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mob::SetSpawnedInWater(bool spawned_in_water) {
|
||||||
|
Mob::spawned_in_water = spawned_in_water;
|
||||||
|
}
|
||||||
|
|||||||
@ -39,6 +39,7 @@
|
|||||||
#include "raids.h"
|
#include "raids.h"
|
||||||
#include "string_ids.h"
|
#include "string_ids.h"
|
||||||
#include "worldserver.h"
|
#include "worldserver.h"
|
||||||
|
#include "water_map.h"
|
||||||
|
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
#define snprintf _snprintf
|
#define snprintf _snprintf
|
||||||
@ -686,6 +687,15 @@ void EntityList::AddNPC(NPC *npc, bool SendSpawnPacket, bool dontqueue)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether NPC was spawned in or out of water
|
||||||
|
*/
|
||||||
|
if (zone->HasMap() && zone->HasWaterMap()) {
|
||||||
|
npc->SetSpawnedInWater(false);
|
||||||
|
if (zone->watermap->InLiquid(npc->GetPosition())) {
|
||||||
|
npc->SetSpawnedInWater(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityList::AddMerc(Merc *merc, bool SendSpawnPacket, bool dontqueue)
|
void EntityList::AddMerc(Merc *merc, bool SendSpawnPacket, bool dontqueue)
|
||||||
|
|||||||
@ -1414,6 +1414,13 @@ protected:
|
|||||||
bool pseudo_rooted;
|
bool pseudo_rooted;
|
||||||
bool endur_upkeep;
|
bool endur_upkeep;
|
||||||
bool degenerating_effects; // true if we have a buff that needs to be recalced every tick
|
bool degenerating_effects; // true if we have a buff that needs to be recalced every tick
|
||||||
|
bool spawned_in_water;
|
||||||
|
public:
|
||||||
|
bool GetWasSpawnedInWater() const;
|
||||||
|
|
||||||
|
void SetSpawnedInWater(bool spawned_in_water);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
// Bind wound
|
// Bind wound
|
||||||
Timer bindwound_timer;
|
Timer bindwound_timer;
|
||||||
|
|||||||
@ -1663,9 +1663,35 @@ void NPC::AI_DoMovement() {
|
|||||||
auto move_x = static_cast<float>(zone->random.Real(-roambox_distance, roambox_distance));
|
auto move_x = static_cast<float>(zone->random.Real(-roambox_distance, roambox_distance));
|
||||||
auto move_y = static_cast<float>(zone->random.Real(-roambox_distance, roambox_distance));
|
auto move_y = static_cast<float>(zone->random.Real(-roambox_distance, roambox_distance));
|
||||||
|
|
||||||
roambox_destination_x = EQEmu::Clamp((GetX() + move_x), roambox_min_x, roambox_min_y);
|
roambox_destination_x = EQEmu::Clamp((GetX() + move_x), roambox_min_x, roambox_max_x);
|
||||||
roambox_destination_y = EQEmu::Clamp((GetY() + move_y), roambox_min_y, roambox_max_y);
|
roambox_destination_y = EQEmu::Clamp((GetY() + move_y), roambox_min_y, roambox_max_y);
|
||||||
|
|
||||||
|
if (roambox_destination_x == roambox_min_x || roambox_destination_x == roambox_max_x) {
|
||||||
|
roambox_destination_x = static_cast<float>(zone->random.Real(roambox_min_x, roambox_max_y));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (roambox_destination_y == roambox_min_y || roambox_destination_y == roambox_max_y) {
|
||||||
|
roambox_destination_y = static_cast<float>(zone->random.Real(roambox_min_y, roambox_max_y));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If mob was not spawned in water, let's not randomly roam them into water
|
||||||
|
* if the roam box was sloppily configured
|
||||||
|
*/
|
||||||
|
if (!this->GetWasSpawnedInWater()) {
|
||||||
|
if (zone->zonemap != nullptr && zone->watermap != nullptr) {
|
||||||
|
auto position = glm::vec3(
|
||||||
|
roambox_destination_x,
|
||||||
|
roambox_destination_y,
|
||||||
|
this->FindGroundZ(roambox_destination_x, roambox_destination_y, 5)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (zone->watermap->InLiquid(position)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->FixZ();
|
this->FixZ();
|
||||||
|
|
||||||
Log(Logs::Detail,
|
Log(Logs::Detail,
|
||||||
@ -1681,7 +1707,9 @@ void NPC::AI_DoMovement() {
|
|||||||
roambox_destination_y);
|
roambox_destination_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CalculateNewPosition(roambox_destination_x, roambox_destination_y, GetFixedZ(m_Position), move_speed, true)) {
|
float new_z = this->FindGroundZ(m_Position.x, m_Position.y, 5) + GetZOffset();
|
||||||
|
|
||||||
|
if (!CalculateNewPosition(roambox_destination_x, roambox_destination_y, new_z, move_speed, true)) {
|
||||||
time_until_can_move = Timer::GetCurrentTime() + RandomTimer(roambox_min_delay, roambox_delay);
|
time_until_can_move = Timer::GetCurrentTime() + RandomTimer(roambox_min_delay, roambox_delay);
|
||||||
SetMoving(false);
|
SetMoving(false);
|
||||||
this->FixZ();
|
this->FixZ();
|
||||||
|
|||||||
@ -30,7 +30,7 @@ bool WaterMapV2::InLava(const glm::vec3& location) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool WaterMapV2::InLiquid(const glm::vec3& location) const {
|
bool WaterMapV2::InLiquid(const glm::vec3& location) const {
|
||||||
return InWater(location) || InLava(location);
|
return InWater(location) || InLava(location) || InVWater(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WaterMapV2::InPvP(const glm::vec3& location) const {
|
bool WaterMapV2::InPvP(const glm::vec3& location) const {
|
||||||
|
|||||||
@ -455,7 +455,7 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, b
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_Position.x - x == 0) && (m_Position.y - y == 0)) {//spawn is at target coords
|
if ((m_Position.x - x == 0) && (m_Position.y - y == 0)) { //spawn is at target coords
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if ((std::abs(m_Position.x - x) < 0.1) && (std::abs(m_Position.y - y) < 0.1)) {
|
else if ((std::abs(m_Position.x - x) < 0.1) && (std::abs(m_Position.y - y) < 0.1)) {
|
||||||
|
|||||||
@ -212,8 +212,8 @@ public:
|
|||||||
void ReloadWorld(uint32 Option);
|
void ReloadWorld(uint32 Option);
|
||||||
void ReloadMerchants();
|
void ReloadMerchants();
|
||||||
|
|
||||||
Map* zonemap;
|
Map *zonemap;
|
||||||
WaterMap* watermap;
|
WaterMap *watermap;
|
||||||
IPathfinder *pathing;
|
IPathfinder *pathing;
|
||||||
NewZone_Struct newzone_data;
|
NewZone_Struct newzone_data;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user