mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-19 17:38:26 +00:00
+85
-94
@@ -68,7 +68,7 @@ Entity::Entity()
|
||||
|
||||
Entity::~Entity()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
Client *Entity::CastToClient()
|
||||
@@ -484,14 +484,14 @@ void EntityList::MobProcess()
|
||||
while (it != mob_list.end()) {
|
||||
uint16 id = it->first;
|
||||
Mob *mob = it->second;
|
||||
|
||||
|
||||
size_t sz = mob_list.size();
|
||||
bool p_val = mob->Process();
|
||||
size_t a_sz = mob_list.size();
|
||||
|
||||
|
||||
if(a_sz > sz) {
|
||||
//increased size can potentially screw with iterators so reset it to current value
|
||||
//if buckets are re-orderered we may skip a process here and there but since
|
||||
//if buckets are re-orderered we may skip a process here and there but since
|
||||
//process happens so often it shouldn't matter much
|
||||
it = mob_list.find(id);
|
||||
++it;
|
||||
@@ -846,10 +846,11 @@ bool EntityList::MakeDoorSpawnPacket(EQApplicationPacket *app, Client *client)
|
||||
strlen(door->GetDoorName()) > 3) {
|
||||
memset(&nd, 0, sizeof(nd));
|
||||
memcpy(nd.name, door->GetDoorName(), 32);
|
||||
nd.xPos = door->GetX();
|
||||
nd.yPos = door->GetY();
|
||||
nd.zPos = door->GetZ();
|
||||
nd.heading = door->GetHeading();
|
||||
auto position = door->GetPosition();
|
||||
nd.xPos = position.m_X;
|
||||
nd.yPos = position.m_Y;
|
||||
nd.zPos = position.m_Z;
|
||||
nd.heading = position.m_Heading;
|
||||
nd.incline = door->GetIncline();
|
||||
nd.size = door->GetSize();
|
||||
nd.doorId = door->GetDoorID();
|
||||
@@ -1551,16 +1552,14 @@ Client *EntityList::GetClientByWID(uint32 iWID)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Client *EntityList::GetRandomClient(float x, float y, float z, float Distance, Client *ExcludeClient)
|
||||
Client *EntityList::GetRandomClient(const xyz_location& location, float Distance, Client *ExcludeClient)
|
||||
{
|
||||
std::vector<Client *> ClientsInRange;
|
||||
|
||||
auto it = client_list.begin();
|
||||
while (it != client_list.end()) {
|
||||
if ((it->second != ExcludeClient) && (it->second->DistNoRoot(x, y, z) <= Distance))
|
||||
|
||||
for (auto it = client_list.begin();it != client_list.end(); ++it)
|
||||
if ((it->second != ExcludeClient) && (it->second->DistNoRoot(location.m_X, location.m_Y, location.m_Z) <= Distance))
|
||||
ClientsInRange.push_back(it->second);
|
||||
++it;
|
||||
}
|
||||
|
||||
if (ClientsInRange.empty())
|
||||
return nullptr;
|
||||
@@ -3065,54 +3064,43 @@ void EntityList::AddHealAggro(Mob *target, Mob *caster, uint16 thedam)
|
||||
|
||||
void EntityList::OpenDoorsNear(NPC *who)
|
||||
{
|
||||
auto it = door_list.begin();
|
||||
while (it != door_list.end()) {
|
||||
|
||||
for (auto it = door_list.begin();it != door_list.end(); ++it) {
|
||||
Doors *cdoor = it->second;
|
||||
if (cdoor && !cdoor->IsDoorOpen()) {
|
||||
float zdiff = who->GetZ() - cdoor->GetZ();
|
||||
if (zdiff < 0)
|
||||
zdiff = 0 - zdiff;
|
||||
float curdist = 0;
|
||||
float tmp = who->GetX() - cdoor->GetX();
|
||||
curdist += tmp * tmp;
|
||||
tmp = who->GetY() - cdoor->GetY();
|
||||
curdist += tmp * tmp;
|
||||
if (zdiff < 10 && curdist <= 100)
|
||||
cdoor->NPCOpen(who);
|
||||
}
|
||||
++it;
|
||||
if (!cdoor || cdoor->IsDoorOpen())
|
||||
continue;
|
||||
|
||||
auto diff = who->GetPosition() - cdoor->GetPosition();
|
||||
diff.ABS_XYZ();
|
||||
|
||||
float curdist = diff.m_X * diff.m_X + diff.m_Y * diff.m_Y;
|
||||
|
||||
if (diff.m_Z * diff.m_Z < 10 && curdist <= 100)
|
||||
cdoor->NPCOpen(who);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityList::SendAlarm(Trap *trap, Mob *currenttarget, uint8 kos)
|
||||
{
|
||||
float val2 = trap->effectvalue * trap->effectvalue;
|
||||
float preSquareDistance = trap->effectvalue * trap->effectvalue;
|
||||
|
||||
auto it = npc_list.begin();
|
||||
while (it != npc_list.end()) {
|
||||
for (auto it = npc_list.begin();it != npc_list.end(); ++it) {
|
||||
NPC *cur = it->second;
|
||||
float curdist = 0;
|
||||
float tmp = cur->GetX() - trap->x;
|
||||
curdist += tmp*tmp;
|
||||
tmp = cur->GetY() - trap->y;
|
||||
curdist += tmp*tmp;
|
||||
tmp = cur->GetZ() - trap->z;
|
||||
curdist += tmp*tmp;
|
||||
if (!cur->GetOwner() &&
|
||||
/*!cur->CastToMob()->dead && */
|
||||
!cur->IsEngaged() &&
|
||||
curdist <= val2 )
|
||||
{
|
||||
if (kos) {
|
||||
uint8 factioncon = currenttarget->GetReverseFactionCon(cur);
|
||||
if (factioncon == FACTION_THREATENLY || factioncon == FACTION_SCOWLS) {
|
||||
cur->AddToHateList(currenttarget,1);
|
||||
}
|
||||
} else {
|
||||
|
||||
auto diff = cur->GetPosition() - trap->m_Position;
|
||||
float curdist = diff.m_X * diff.m_X + diff.m_Y * diff.m_Y + diff.m_Z * diff.m_Z;
|
||||
|
||||
if (cur->GetOwner() || cur->IsEngaged() || curdist > preSquareDistance )
|
||||
continue;
|
||||
|
||||
if (kos) {
|
||||
uint8 factioncon = currenttarget->GetReverseFactionCon(cur);
|
||||
if (factioncon == FACTION_THREATENLY || factioncon == FACTION_SCOWLS) {
|
||||
cur->AddToHateList(currenttarget,1);
|
||||
}
|
||||
}
|
||||
++it;
|
||||
}
|
||||
else
|
||||
cur->AddToHateList(currenttarget,1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3149,7 +3137,7 @@ struct quest_proximity_event {
|
||||
int area_type;
|
||||
};
|
||||
|
||||
void EntityList::ProcessMove(Client *c, float x, float y, float z)
|
||||
void EntityList::ProcessMove(Client *c, const xyz_location& location)
|
||||
{
|
||||
float last_x = c->ProximityX();
|
||||
float last_y = c->ProximityY();
|
||||
@@ -3171,9 +3159,9 @@ void EntityList::ProcessMove(Client *c, float x, float y, float z)
|
||||
last_z < l->min_z || last_z > l->max_z) {
|
||||
old_in = false;
|
||||
}
|
||||
if (x < l->min_x || x > l->max_x ||
|
||||
y < l->min_y || y > l->max_y ||
|
||||
z < l->min_z || z > l->max_z) {
|
||||
if (location.m_X < l->min_x || location.m_X > l->max_x ||
|
||||
location.m_Y < l->min_y || location.m_Y > l->max_y ||
|
||||
location.m_Z < l->min_z || location.m_Z > l->max_z) {
|
||||
new_in = false;
|
||||
}
|
||||
|
||||
@@ -3206,9 +3194,9 @@ void EntityList::ProcessMove(Client *c, float x, float y, float z)
|
||||
old_in = false;
|
||||
}
|
||||
|
||||
if (x < a.min_x || x > a.max_x ||
|
||||
y < a.min_y || y > a.max_y ||
|
||||
z < a.min_z || z > a.max_z ) {
|
||||
if (location.m_X < a.min_x || location.m_X > a.max_x ||
|
||||
location.m_Y < a.min_y || location.m_Y > a.max_y ||
|
||||
location.m_Z < a.min_z || location.m_Z > a.max_z ) {
|
||||
new_in = false;
|
||||
}
|
||||
|
||||
@@ -3611,7 +3599,7 @@ int16 EntityList::CountTempPets(Mob *owner)
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
|
||||
owner->SetTempPetCount(count);
|
||||
|
||||
return count;
|
||||
@@ -3802,51 +3790,54 @@ void EntityList::GroupMessage(uint32 gid, const char *from, const char *message)
|
||||
}
|
||||
}
|
||||
|
||||
uint16 EntityList::CreateGroundObject(uint32 itemid, float x, float y, float z,
|
||||
float heading, uint32 decay_time)
|
||||
uint16 EntityList::CreateGroundObject(uint32 itemid, const xyz_heading& position, uint32 decay_time)
|
||||
{
|
||||
const Item_Struct *is = database.GetItem(itemid);
|
||||
if (is) {
|
||||
ItemInst *i = new ItemInst(is, is->MaxCharges);
|
||||
if (i) {
|
||||
Object *object = new Object(i, x, y, z, heading,decay_time);
|
||||
entity_list.AddObject(object, true);
|
||||
if (!is)
|
||||
return 0;
|
||||
|
||||
safe_delete(i);
|
||||
if (object)
|
||||
return object->GetID();
|
||||
}
|
||||
return 0; // fell through itemstruct
|
||||
}
|
||||
return 0; // fell through everything, this is bad/incomplete from perl
|
||||
ItemInst *i = new ItemInst(is, is->MaxCharges);
|
||||
if (!i)
|
||||
return 0;
|
||||
|
||||
Object *object = new Object(i, position.m_X, position.m_Y, position.m_Z, position.m_Heading,decay_time);
|
||||
entity_list.AddObject(object, true);
|
||||
|
||||
safe_delete(i);
|
||||
if (!object)
|
||||
return 0;
|
||||
|
||||
return object->GetID();
|
||||
}
|
||||
|
||||
uint16 EntityList::CreateGroundObjectFromModel(const char *model, float x,
|
||||
float y, float z, float heading, uint8 type, uint32 decay_time)
|
||||
uint16 EntityList::CreateGroundObjectFromModel(const char *model, const xyz_heading& position, uint8 type, uint32 decay_time)
|
||||
{
|
||||
if (model) {
|
||||
Object *object = new Object(model, x, y, z, heading, type);
|
||||
entity_list.AddObject(object, true);
|
||||
if (!model)
|
||||
return 0;
|
||||
|
||||
if (object)
|
||||
return object->GetID();
|
||||
}
|
||||
return 0; // fell through everything, this is bad/incomplete from perl
|
||||
Object *object = new Object(model, position.m_X, position.m_Y, position.m_Z, position.m_Heading, type);
|
||||
entity_list.AddObject(object, true);
|
||||
|
||||
if (!object)
|
||||
return 0;
|
||||
|
||||
return object->GetID();
|
||||
}
|
||||
|
||||
uint16 EntityList::CreateDoor(const char *model, float x, float y, float z,
|
||||
float heading, uint8 opentype, uint16 size)
|
||||
uint16 EntityList::CreateDoor(const char *model, const xyz_heading& position, uint8 opentype, uint16 size)
|
||||
{
|
||||
if (model) {
|
||||
Doors *door = new Doors(model, x, y, z, heading, opentype, size);
|
||||
RemoveAllDoors();
|
||||
zone->LoadZoneDoors(zone->GetShortName(), zone->GetInstanceVersion());
|
||||
entity_list.AddDoor(door);
|
||||
entity_list.RespawnAllDoors();
|
||||
if (!model)
|
||||
return 0; // fell through everything, this is bad/incomplete from perl
|
||||
|
||||
Doors *door = new Doors(model, position, opentype, size);
|
||||
RemoveAllDoors();
|
||||
zone->LoadZoneDoors(zone->GetShortName(), zone->GetInstanceVersion());
|
||||
entity_list.AddDoor(door);
|
||||
entity_list.RespawnAllDoors();
|
||||
|
||||
if (door)
|
||||
return door->GetEntityID();
|
||||
|
||||
if (door)
|
||||
return door->GetEntityID();
|
||||
}
|
||||
return 0; // fell through everything, this is bad/incomplete from perl
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user