mirror of
https://github.com/EQEmu/Server.git
synced 2026-08-29 12:47:54 +00:00
[Quest API] Add TrackNPC to Perl/Lua. (#2272)
* [Quest API] Add TrackNPC to Perl/Lua. - Add quest::tracknpc(entity_id) to Perl. - Add eq.track_npc(entity_id) to Lua. - This will allow server operators to arbitrarily Track NPCs for clients with scripts. - Modified tracking to auto turn off and tell you that you discovered your target if within 10 units, this is to allow scripted Tracking to turn off without the need for the Tracking skill. * Remove unnecessary DoTracking() call. * Update client.cpp
This commit is contained in:
+29
-22
@@ -3668,46 +3668,53 @@ void EntityList::SignalMobsByNPCID(uint32 snpc, int signal_id)
|
||||
bool EntityList::MakeTrackPacket(Client *client)
|
||||
{
|
||||
std::list<std::pair<Mob *, float> > tracking_list;
|
||||
uint32 distance = 0;
|
||||
float MobDistance;
|
||||
auto distance = static_cast<float>(client->GetSkill(EQ::skills::SkillTracking) * client->GetClassTrackingDistanceMultiplier(client->GetClass()));
|
||||
|
||||
distance = (client->GetSkill(EQ::skills::SkillTracking) * client->GetClassTrackingDistanceMultiplier(client->GetClass()));
|
||||
|
||||
if (distance <= 0)
|
||||
if (distance <= 0.0f) {
|
||||
return false;
|
||||
if (distance < 300)
|
||||
distance = 300;
|
||||
}
|
||||
|
||||
if (distance < 300.0f) {
|
||||
distance = 300.0f;
|
||||
}
|
||||
|
||||
for (auto it = mob_list.cbegin(); it != mob_list.cend(); ++it) {
|
||||
if (!it->second || it->second == client || !it->second->IsTrackable() ||
|
||||
it->second->IsInvisible(client))
|
||||
if (
|
||||
!it->second ||
|
||||
it->second == client ||
|
||||
!it->second->IsTrackable() ||
|
||||
it->second->IsInvisible(client)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MobDistance = DistanceNoZ(it->second->GetPosition(), client->GetPosition());
|
||||
if (MobDistance > distance)
|
||||
const auto mob_distance = DistanceNoZ(it->second->GetPosition(), client->GetPosition());
|
||||
if (mob_distance > distance) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tracking_list.push_back(std::make_pair(it->second, MobDistance));
|
||||
tracking_list.push_back(std::make_pair(it->second, mob_distance));
|
||||
}
|
||||
|
||||
tracking_list.sort(
|
||||
[](const std::pair<Mob *, float> &a, const std::pair<Mob *, float> &b) {
|
||||
return a.first->GetSpawnTimeStamp() > b.first->GetSpawnTimeStamp();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
auto outapp = new EQApplicationPacket(OP_Track, sizeof(Track_Struct) * tracking_list.size());
|
||||
Tracking_Struct *outtrack = (Tracking_Struct *)outapp->pBuffer;
|
||||
auto pack = (Tracking_Struct *) outapp->pBuffer;
|
||||
outapp->priority = 6;
|
||||
|
||||
int index = 0;
|
||||
for (auto it = tracking_list.cbegin(); it != tracking_list.cend(); ++it, ++index) {
|
||||
Mob *cur_entity = it->first;
|
||||
outtrack->Entrys[index].entityid = (uint32)cur_entity->GetID();
|
||||
outtrack->Entrys[index].distance = it->second;
|
||||
outtrack->Entrys[index].level = cur_entity->GetLevel();
|
||||
outtrack->Entrys[index].is_npc = !cur_entity->IsClient();
|
||||
strn0cpy(outtrack->Entrys[index].name, cur_entity->GetName(), sizeof(outtrack->Entrys[index].name));
|
||||
outtrack->Entrys[index].is_pet = cur_entity->IsPet();
|
||||
outtrack->Entrys[index].is_merc = cur_entity->IsMerc();
|
||||
pack->Entrys[index].entityid = static_cast<uint32>(it->first->GetID());
|
||||
pack->Entrys[index].distance = it->second;
|
||||
pack->Entrys[index].level = it->first->GetLevel();
|
||||
pack->Entrys[index].is_npc = !it->first->IsClient();
|
||||
strn0cpy(pack->Entrys[index].name, it->first->GetName(), sizeof(pack->Entrys[index].name));
|
||||
pack->Entrys[index].is_pet = it->first->IsPet();
|
||||
pack->Entrys[index].is_merc = it->first->IsMerc();
|
||||
}
|
||||
|
||||
client->QueuePacket(outapp);
|
||||
|
||||
Reference in New Issue
Block a user