eqemu-server/zone/entity.h
nytmyr f466964db8
[Bots] Bot Overhaul (#4580)
* Implement spell AI pulling, fix throw stone

* more pull tweaks

* holding check at start of ai process

* fully implement ^pull logic to always return, can still be overidden by ^attack

* Rewrite ^pull logic and handling. **MORE**

Add ^setassistee command to set who your bots will assist. Bots will always assist you first before anyone else.

If the rule Bots, AllowCrossGroupRaidAssist is enabled bots will assist the group or raid main assists.

Rewrites logic in handling of pull and returning to ensure bots make it back to their location.

* Move HateLine to a better ID

* cleanup ST_Self logic in CastChecks

* Removed unused BotSpellTypeRequiresLoS

* Move fizzle message to define

* add timer checks to Idle/Engaged/Pursue CastCheck to early terminate

* Add back !IsBotNonSpellFighter() check to the different CastCheck

* Correct IsValidSpellRange

* Implement AAs and harmtouch/layonhands to ^cast --- fix IsValidSpellRange

* Add PetDamageShields and PetResistBuffs to IsPetBotSpellType()

* Add priorities to HateLine inserts for db update

* Remove SpellTypeRequiresCastChecks

* Add bot check to DetermineSpellTargets for IsIllusionSpell

* merge with previous

* Correct bot checks for ST_GroupClientAndPet

* Remove misc target_type checks

* Add lull/aelull to ^cast

* Add more checks for CommandedSubTypes::AETarget

* remove unneeded checks on IsValidSpellTypeBySpellID

* add to aelull

* rewrite GetCorrectSpellType

* Add IsBlockedBuff to CastChecks

* Add spellid option to ^cast to allow casting of a specific spell by ID

* ^cast adjustments for spellid casts

* Add missing alert round for ranged attacks

* More castcheck improvements

* CanUseBotSpell for ^cast

* remove ht/loh from attack ai

* remove SetCombatRoundForAlerts that triggered every engagement

* Add RangedAttackImmunity checks before trying to ranged attack

* move bot backstab to mob

* fix MinStatusToBypassCreateLimit

* more backstab to mob cleanup

* add bot checks to tryheadshot / tryassassinate

* adjust version number for bots

* add back m_mob_check_moving_timer, necessary?

* add sanity checks for classattacks

* Get rid of Bots:BotGroupXP and change logic to support Bots:SameRaidGroupForXP

Bots won't do anything if not in the same group so this should more accurately control only when in the same raid group.

* add "confirm" check to ^delete

* Update bot.cpp

* Remove `id` from bot_settings, correct types

* Implement blocked_buffs and blocked_pet_buffs

* more blocked buff tweaks

* add beneficial check to ^blockedbuffs

* command grammar

* missing )

* Move getnames for categories and settings to mob, rename hptomed/manatomed

* add GetBotSpellCategoryIDByShortName and CopyBotBlockedPetBuffs, update ^defaultsettings command

* cls cleanup

* Allow bots to clear HasProjectIllusion flag

* Add PercentChanceToCastGroupCure

* Implmenet PetCures, add some missing types for defaults/chance to cast

* Change GetRaidByBotName to GetRaidByBot

* Typo on PetBuffs implement

* Change GetSpellListSpellType to GetParentSpellType

* missing from GetChanceToCastBySpellType

* Fix performance in IsValidSpellRange by flipping HasProjectIllusion

* merge with prev

* merge with cls cleanup

* Reorder IsTargetAlreadyReceivingSpell/CheckSpellLevelRestriction/IsBlockedBuff

* Combine GatherGroupSpellTargets and GatherSpellTargets

* Cleanup IsTargetAlreadyReceivingSpell

* Fix ^petsettype to account for usable levels of spells and remove hardcoded level limits.

* Remove Bot_AICheckCloseBeneficialSpells and use AttemptCloseBeneficialSpells for better performance

* remove default hold for resist buffa

* move IsValidSpellRange further down castchecks

* raid optimizations

* correct name checking to match players

* more name checks and add proper soft deletes to bots

* organize some checks in IsImmuneToBotSpell

* Fix GetRaidByBotName and GetRaidByBot checks to not loop unnecessarily

* Move GatherSpellTargets to mob

* Change GetPrioritizedBotSpellsBySpellType to vector

Some slipped through in "organize some checks in IsImmuneToBotSpell"

* Move GatherSpellTargets and Raid to stored variables.

Missing some in "organize some checks in IsImmuneToBotSpell"

* comment out precheck, delays, thresholds, etc logging

missed some in "organize some checks in IsImmuneToBotSpell"

* Missing IsInGroupOrRaid cleanup

* Implement AIBot_spells_by_type to reduce looping when searching for spells

* Add _tempSpellType as placeholder for any future passthru

* todo

* Move bot_list from std::list to std::unordered_map like other entities

* Fix missing raid assignment for GetStoredRaid in IsInGroupOrRaid

* TempPet owned by bots that get the kill will now give exp like a client would

* Remove unnecessary checks in bot process (closescanmoving timer, verify raid, send hp/mana/end packet

* Fix client spell commands from saving the wrong setting

* Cleanup ^copysettings command and add new commands

* Add pet option to ^taunt

No longer has toggle, required on/off option and an optional "pet" option to control pets' taunting state

* Allow pet types to ^cast, prevent failure spam, add cure check

* more raid optimizations, should be final.

10 clients, 710 bots, 10 raids, ~250 pets sits around 3.5% CPU idle

* Move spell range check to proper location

* Implement ^discipline

* remove ^aggressive/^defensive

* remove this for a separate PR

* cleanup

* Add BotGroupSay method

* todo list

* Add missing bot_blocked_buffs to schema

* Remove plural on ^spelltypeidsand ^spelltypenames

* Move spelltype names, spell subtypes, category names and setting names to maps.

* move los checks to mob.cpp

* Bot CampAll fix

* Bots special_attacks.cpp fix

* Add zero check for bot spawn limits

If the spawn limit rule is set to 0 and spawn limit is set by bucket, if no class buckets are set, it defaults to the rule of 0 and renders the player unable to spawn bots.

This adds a check where if the rule and class bucket are 0, it will check for the spawn limit bucket

* Add HasSkill checks to bot special abilities (kick/bash/etc)

* code cleanup 1

* code cleanup 2

* code cleanup 3

* code cleanup 4

* fix ^cast wirh commanded types

* Remove bcspells, fix helper_send_usage_required_bots

* linux build fix

* remove completed todo

* Allow inventory give to specific ID slots

* Update TODO

* Correct slot ranges for inventorygive

* Add zone specific spawn limits and zone specific forced spawn limits

* remove bd. from update queries where it doesn't exist

* Rename _spellSettings to m_bot_spell_settings

* Add IsPetOwnerOfClientBot(), add Lua and Perl methods

* Make botOwnerCharacterID snakecase

* Throw bot_camp_timer behind Bots:Enabled rule

* Move various Bot<>Checks logging to BotSpellChecks

* Remove from LogCategoryName

* Consolidate IsInGroupOrRaid

* Consolidate GatherSpellTargets

* Add missing Bot Spell Type Checks to log

* Add GetParentSpellType when checking spelltypes for idle, engaged, pursue CastChecks.

* Consolidate AttemptForcedCastSpell

* Consolidate SetBotBlockedBuff/SetBotBlockedPetBuff

* Add list option to ^spellpriority commands.

* Move client functions to client_bot

* Move mob functions to mob_bot

* Move bot spdat functions to spdat_bot

* Move SendCommandHelpWindow to SendBotCommandHelpWindow and simplify

* Change char_id to character_id for bot_settings

* update todo

* Fix typo on merge conflict

* Cleanup command format changes, remove hardcoded class IDs in examples.

* Set #illusionblock for players to guide access

* Move client commands for bot spells from gm commands to existing bot commands

* Fix alignment issues

* More alignment fixes

* More cleanup 1

* More cleanup 2

* Fix BotMeditate to med at proper percentages

* Correct GetStopMeleeLevel checks for some buff checks

* Add back hpmanaend update to bot raid, force timer update to prevent spamming

* Remove log

* Cleanup ranged and ammo calculations - Adds throwing check for match

* Add check in distance calculations to stay at range if set even if no ammo or ranged

* Move melee distance calculations to better function

* Add GetBuffTargets helper

* Missing p_item, s_item in CombatRangeInput

* Linux test?

* Reduce GetCorrectBotSpellType branching slightly

This is still an ugly ass function but my brain is melted

* Line fixes

* Make bot pets only do half damage in pvp

* Add bot pet pvp damage to tune

* Add bot pet check for AIYellForHelp

* Add bots to UseSpellImpliedTargeting

* Move toggleranged, togglehelm and illusionblock to new help window. Add actionable support

* Add bot and bot pet checks to various spells, auras and targeting checks that were missing.

* update todo

* New lines

* Correct DoLosChecks

* Remove Log TestDebug

* Remove _Struct from struct declarations

* Add bot check to IsAttackAllowed for GetUltimateOwner to skip entity list where possible

* Wrap SaveBotSettings in Bots Enabled check

* Remove comment

* Wrap bot setting loading for clients in bots enabled rule

* Cleanup BlockedBuffs logic in SpellOnTarget

* Rename BotSpells_Struct/BotSpells_Struct_wIndex

* Rename spawn/create status bypass rules, fix return for spawn limit

* Remove unnecessary return in CanBuffStack, cleanup

* Enable recastdelay support for clients

* Remove unused variables

* Rename _assistee to bot_assistee

* hardcode BotCommandHelpWindow colors

* todo

* Fix ^cast summoncorpse

* todo

* Reimplement secondary colors to BotSendCommandHelpWindow

* Give ^copysettings/^defaultsettings more options, cleanup.

* Cleanup some commands

* Add comment to CheckLosCheat/CheckLosCheatExempt

* Make struct BotSpellSettings snake case

* Allow duplicate casts of same spell on target for heals and cures

* Add default delay to cures

* Remove unused methods

* Implement missing ^spellresistlimits/^resistlimits command

* Move functions out of mob.h and cleanup

* Return for GetRawBotList

This checks offline bots too

* Rename BotGroupSay to RaidGroupSay

* Prevent bots from forming their own group if a bot that is a group leader is removed from the raid

* Linux fix?

* IsPetOwner fixes

* Add remove option to list for ^blockedbuffs / ^blockedpetbuffs

* Implement ^spellannouncecasts to toggle announcing casts of spell types

* Remove rule Bots:BardsAnnounceCasts

* Update bot.h

* Remove unused no_pets option from GatherSpellTargets

* Move ^attack response back to normal chat window (other)

* Set lower limit of spell delays to 100 rather than 1

* Correct pet checks on GetUltimateSpell functions

* Add rules (Bots, AICastSpellTypeDelay, Bots, AICastSpellTypeHeldDelay) to prevent spamming of failed spell type AI casts

* Correct pet buff type logic to catch DS/Resists with other spell effects in them

* Fix defaults for clients

* Add more logic for necros/shaman for default heal thresholds due to lich and canni

* Rename SpellHold, SpellDelay, SpellMinThreshold, SpellMaxThreshold, SpellRecastDelay to fit SpellType style naming

* Use GetTempSpellType() for announce check in RaidGroupSay

* Make all spell shortnames plural where applicable

* Update bot.cpp

* Bots:BotsUseLiveBlockedMessage filter to spell failure

* Move GetSpellTargetList to only get called when necessary to reduce overhead

* formatting

* Formatting

* Simplify case SE_Illusion and SE_IllusionCopy for GetIllusionBlock

* Clean up InterruptSpell

* Cleanup IsBot() checks for DetermineSpellTargets->ST_GroupClientAndPet

* Cleanup range/aoe_range check in SpellFinished

* Cleanup DetermineSpellTargets->ST_GroupNoPets

* Cleanup DetermineSpellTargets->ST_Self for bot summon corpse

* Cleanup DetermineSpellTargets->ST_Pet

* Cleanup bot logic in TryBackstab

* Cleanup IsAttackAllowed checks for bots and their pets

* Cleanup StopMoving for bots

* Cleanup CanThisClassTripleAttack

* Fix casting for GetIllusionBlock checks

* Formatting

* Fix DetermineSpellTargets for group spells (this also wasn't properly checking the rule Character:EnableTGB in master)

* Cleanup spelltarget grabbing logic, consolidate group heals in to GetNumberNeedingHealedInGroup

* Throw added client los pet checks behind LoS cheat rule for bots

* CLeanup give_exp on npc death logic and ensure client pets always pass.

* Undo unintended rename from previous refactor

* Remove pointless Bots, SameRaidGroupForXP rule

* Revision to 0690783a9d1e99005d6bee0824597ea920e26df9

---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
2025-02-03 04:02:42 -06:00

654 lines
24 KiB
C++

/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef ENTITY_H
#define ENTITY_H
#include <unordered_map>
#include <queue>
#include "../common/types.h"
#include "../common/linked_list.h"
#include "../common/servertalk.h"
#include "../common/bodytypes.h"
#include "../common/eq_constants.h"
#include "../common/emu_constants.h"
#include "position.h"
#include "zonedump.h"
#include "common.h"
class Encounter;
class Beacon;
class Client;
class Corpse;
class Doors;
class EQApplicationPacket;
class Entity;
class EntityList;
class Group;
class Merc;
class Mob;
class NPC;
class Object;
class Petition;
class Raid;
class Spawn2;
class Trap;
struct GuildBankItemUpdate_Struct;
struct NewSpawn_Struct;
struct QGlobal;
struct UseAA_Struct;
struct Who_All_Struct;
class Bot;
extern EntityList entity_list;
constexpr const char* SEE_BUFFS_FLAG = "see_buffs_flag";
class Entity
{
public:
Entity();
virtual ~Entity();
virtual bool IsClient() const { return false; }
virtual bool IsNPC() const { return false; }
virtual bool IsMob() const { return false; }
virtual bool IsMerc() const { return false; }
virtual bool IsCorpse() const { return false; }
virtual bool IsPlayerCorpse() const { return false; }
virtual bool IsNPCCorpse() const { return false; }
virtual bool IsObject() const { return false; }
virtual bool IsDoor() const { return false; }
virtual bool IsTrap() const { return false; }
virtual bool IsBeacon() const { return false; }
virtual bool IsEncounter() const { return false; }
virtual bool IsBot() const { return false; }
virtual bool IsAura() const { return false; }
virtual bool IsOfClientBot() const { return false; }
virtual bool IsOfClientBotMerc() const { return false; }
virtual bool Process() { return false; }
virtual bool Save() { return true; }
virtual void Depop(bool StartSpawnTimer = false) {}
Client *CastToClient();
NPC *CastToNPC();
Mob *CastToMob();
Merc *CastToMerc();
Corpse *CastToCorpse();
Object *CastToObject();
Doors *CastToDoors();
Trap *CastToTrap();
Beacon *CastToBeacon();
Encounter *CastToEncounter();
const Client *CastToClient() const;
const NPC *CastToNPC() const;
const Mob *CastToMob() const;
const Merc *CastToMerc() const;
const Corpse *CastToCorpse() const;
const Object *CastToObject() const;
const Doors *CastToDoors() const;
const Trap *CastToTrap() const;
const Beacon *CastToBeacon() const;
const Encounter *CastToEncounter() const;
inline const uint16& GetInitialId() const { return initial_id; }
inline const uint16& GetID() const { return id; }
inline const time_t& GetSpawnTimeStamp() const { return spawn_timestamp; }
virtual const char* GetName() { return ""; }
bool CheckCoordLosNoZLeaps(float cur_x, float cur_y, float cur_z, float trg_x, float trg_y, float trg_z, float perwalk=1);
Bot* CastToBot();
const Bot* CastToBot() const;
protected:
friend class EntityList;
inline virtual void SetID(uint16 set_id) {
id = set_id;
if (initial_id == 0 && set_id > 0) {
initial_id = set_id;
}
}
private:
uint16 id;
uint16 initial_id;
time_t spawn_timestamp;
};
class EntityList
{
public:
struct Area {
int id;
int type;
float min_x, max_x;
float min_y, max_y;
float min_z, max_z;
};
EntityList();
~EntityList();
Entity* GetID(uint16 id);
Mob *GetMob(uint16 id);
inline Mob *GetMobID(uint16 id) { return(GetMob(id)); } //for perl
Mob *GetMob(const char* name);
Mob *GetMobByNpcTypeID(uint32 get_id);
bool IsMobSpawnedByNpcTypeID(uint32 get_id);
bool IsNPCSpawned(std::vector<uint32> npc_ids);
uint32 CountSpawnedNPCs(std::vector<uint32> npc_ids);
inline NPC *GetNPCByID(uint16 id)
{
auto it = npc_list.find(id);
if (it != npc_list.end())
return it->second;
return nullptr;
}
NPC *GetNPCByNPCTypeID(uint32 npc_id);
NPC *GetNPCBySpawnID(uint32 spawn_id);
inline Merc *GetMercByID(uint16 id)
{
auto it = merc_list.find(id);
if (it != merc_list.end())
return it->second;
return nullptr;
}
Client *GetClientByName(const char* name);
Client *GetClientByAccID(uint32 accid);
inline Client *GetClientByID(uint16 id)
{
auto it = client_list.find(id);
if (it != client_list.end())
return it->second;
return nullptr;
}
Client *GetClientByCharID(uint32 iCharID);
Client *GetClientByWID(uint32 iWID);
Client *GetClientByLSID(uint32 iLSID);
Bot* GetRandomBot(const glm::vec3& location = glm::vec3(0.f), float distance = 0, Bot* exclude_bot = nullptr);
Client* GetRandomClient(const glm::vec3& location = glm::vec3(0.f), float distance = 0, Client* exclude_client = nullptr);
NPC* GetRandomNPC(const glm::vec3& location = glm::vec3(0.f), float distance = 0, NPC* exclude_npc = nullptr);
Mob* GetRandomMob(const glm::vec3& location = glm::vec3(0.f), float distance = 0, Mob* exclude_mob = nullptr);
Group* GetGroupByMob(Mob* mob);
Group* GetGroupByMobName(const char* name);
bool IsInSameGroupOrRaidGroup(Client *client1, Client *client2);
Group *GetGroupByClient(Client* client);
Group *GetGroupByID(uint32 id);
Group *GetGroupByLeaderName(const char* leader);
Raid *GetRaidByClient(Client* client);
Raid *GetRaidByID(uint32 id);
Raid* GetRaidByBotName(const char* name);
Raid* GetRaidByBot(Bot* bot);
Raid* GetRaidByName(const char* name);
Corpse *GetCorpseByOwner(Client* client);
Corpse *GetCorpseByOwnerWithinRange(Client* client, Mob* center, int range);
inline Corpse *GetCorpseByID(uint16 id)
{
auto it = corpse_list.find(id);
if (it != corpse_list.end())
return it->second;
return nullptr;
}
Corpse *GetCorpseByDBID(uint32 dbid);
Corpse *GetCorpseByName(const char* name);
Spawn2* GetSpawnByID(uint32 id);
Client* FindCorpseDragger(uint16 CorpseID);
inline Object *GetObjectByID(uint16 id)
{
auto it = object_list.find(id);
if (it != object_list.end())
return it->second;
return nullptr;
}
Object *GetObjectByDBID(uint32 id);
inline Doors *GetDoorsByID(uint16 id)
{
auto it = door_list.find(id);
if (it != door_list.end())
return it->second;
return nullptr;
}
Doors *GetDoorsByDoorID(uint32 id);
Doors *GetDoorsByDBID(uint32 id);
void RemoveAllCorpsesByCharID(uint32 charid);
void RemoveCorpseByDBID(uint32 dbid);
int RezzAllCorpsesByCharID(uint32 charid);
void DespawnGridNodes(int32 grid_id);
bool IsMobInZone(Mob *who);
void ClearClientPetitionQueue();
bool CanAddHateForMob(Mob *p);
void SendGuildMOTD(uint32 guild_id);
void SendGuildChannel(uint32 guild_id);
void SendGuildURL(uint32 guild_id);
void SendGuildSpawnAppearance(uint32 guild_id);
void SendGuildMembers(uint32 guild_id);
void SendGuildMembersList(uint32 guild_id);
void SendGuildMemberAdd(uint32 guild_id, uint32 level, uint32 _class, uint32 rank, uint32 spirit, uint32 zone_id, std::string player_name);
void SendGuildMemberRename(uint32 guild_id, std::string player_name, std::string new_player_name);
void SendGuildMemberRemove(uint32 guild_id, std::string player_name);
void SendGuildMemberLevel(uint32 guild_id, uint32 level, std::string player_name);
void SendGuildMemberRankAltBanker(uint32 guild_id, uint32 rank, std::string player_name, bool alt, bool banker);
void SendGuildMemberPublicNote(uint32 guild_id, std::string player_name, std::string public_note);
void SendGuildMemberDetails(uint32 guild_id, uint32 zone_id, uint32 offline_mode, std::string player_name);
void SendGuildRenameGuild(uint32 guild_id, std::string new_guild_name);
void RefreshAllGuildInfo(uint32 guild_id);
void SendGuildList();
void GuildSetPreRoFBankerFlag(uint32 guild_id, uint32 guild_rank, bool banker_status);
void CheckGroupList (const char *fname, const int fline);
void GroupProcess();
void RaidProcess();
void DoorProcess();
void ObjectProcess();
void CorpseProcess();
void MobProcess();
void TrapProcess();
void BeaconProcess();
void EncounterProcess();
void ProcessMove(Client *c, const glm::vec3& location);
void ProcessMove(NPC *n, float x, float y, float z);
void AddArea(int id, int type, float min_x, float max_x, float min_y, float max_y, float min_z, float max_z);
void RemoveArea(int id);
void ClearAreas();
void ReloadMerchants();
void ProcessProximitySay(const char *message, Client *c, uint8 language = 0);
Doors *FindDoor(uint8 door_id);
Object *FindObject(uint32 object_id);
Object* FindNearbyObject(float x, float y, float z, float radius);
bool MakeDoorSpawnPacket(EQApplicationPacket* app, Client *client);
bool MakeTrackPacket(Client* client);
void SendTraders(Client* client);
void AddClient(Client*);
void AddNPC(NPC*, bool send_spawn_packet = true, bool dont_queue = false);
void AddMerc(Merc*, bool SendSpawnPacket = true, bool dontqueue = false);
void AddCorpse(Corpse* pc, uint32 in_id = 0xFFFFFFFF);
void AddObject(Object*, bool SendSpawnPacket = true);
void AddGroup(Group*);
void AddGroup(Group*, uint32 id);
void AddRaid(Raid *raid);
void AddRaid(Raid*, uint32 id);
void AddDoor(Doors* door);
void AddTrap(Trap* trap);
void AddBeacon(Beacon *beacon);
void AddEncounter(Encounter *encounter);
void AddProximity(NPC *proximity_for);
void Clear();
bool RemoveMob(uint16 delete_id);
bool RemoveClient(uint16 delete_id);
bool RemoveClient(Client* delete_client);
bool RemoveNPC(uint16 delete_id);
bool RemoveMerc(uint16 delete_id);
bool RemoveGroup(uint32 delete_id);
bool RemoveCorpse(uint16 delete_id);
bool RemoveDoor(uint16 delete_id);
bool RemoveTrap(uint16 delete_id);
bool RemoveObject(uint16 delete_id);
bool RemoveProximity(uint16 delete_npc_id);
bool RemoveMobFromCloseLists(Mob *mob);
void RemoveAuraFromMobs(Mob *aura);
void RemoveAllMobs();
void RemoveAllClients();
void RemoveAllNPCs();
void RemoveAllBots();
void RemoveAllMercs();
void RemoveAllGroups();
void RemoveAllCorpses();
void RemoveAllDoors();
void DespawnAllDoors();
void RespawnAllDoors();
void RemoveAllTraps();
void RemoveAllObjects();
void RemoveAllLocalities();
void RemoveAllRaids();
void RemoveAllEncounters();
void DestroyTempPets(Mob *owner);
void AddTempPetsToHateList(Mob *owner, Mob* other, bool bFrenzy = false);
void AddTempPetsToHateListOnOwnerDamage(Mob *owner, Mob* attacker, int32 spell_id);
Entity *GetEntityMob(uint16 id);
Entity *GetEntityMerc(uint16 id);
Entity *GetEntityDoor(uint16 id);
Entity *GetEntityObject(uint16 id);
Entity *GetEntityCorpse(uint16 id);
Entity *GetEntityTrap(uint16 id);
Entity *GetEntityBeacon(uint16 id);
Entity *GetEntityEncounter(uint16 id);
Entity *GetEntityMob(const char *name);
Entity *GetEntityCorpse(const char *name);
void StopMobAI();
void DescribeAggro(Client *to_who, NPC *from_who, float dist, bool verbose);
std::vector<Mob*> GetFilteredEntityList(
Mob* sender,
uint32 distance = 0,
EntityFilterType filter_type = EntityFilterType::All
);
void DamageArea(
Mob* sender,
int64 damage,
uint32 distance = 0,
EntityFilterType filter_type = EntityFilterType::All,
bool is_percentage = false
);
void Marquee(uint32 type, std::string message, uint32 duration = 3000);
void Marquee(uint32 type, uint32 priority, uint32 fade_in, uint32 fade_out, uint32 duration, std::string message);
void Message(uint32 to_guilddbid, uint32 type, const char* message, ...);
void MessageStatus(uint32 to_guilddbid, int to_minstatus, uint32 type, const char* message, ...);
void MessageClose(Mob* sender, bool skipsender, float dist, uint32 type, const char* message, ...);
void FilteredMessageClose(Mob* sender, bool skipsender, float dist, uint32 type, eqFilterType filter, const char* message, ...);
void MessageString(Mob *sender, bool skipsender, uint32 type, uint32 string_id, const char* message1=0,const char* message2=0,const char* message3=0,const char* message4=0,const char* message5=0,const char* message6=0,const char* message7=0,const char* message8=0,const char* message9=0);
void FilteredMessageString(Mob *sender, bool skipsender, uint32 type, eqFilterType filter, uint32 string_id, const char* message1=0,const char* message2=0,const char* message3=0,const char* message4=0,const char* message5=0,const char* message6=0,const char* message7=0,const char* message8=0,const char* message9=0);
void MessageCloseString(
Mob *sender,
bool skipsender,
float dist,
uint32 type,
uint32 string_id,
const char *message1 = 0,
const char *message2 = 0,
const char *message3 = 0,
const char *message4 = 0,
const char *message5 = 0,
const char *message6 = 0,
const char *message7 = 0,
const char *message8 = 0,
const char *message9 = 0);
void FilteredMessageCloseString(
Mob *sender,
bool skipsender,
float dist,
uint32 type,
eqFilterType filter,
uint32 string_id,
Mob *skip = 0,
const char *message1 = 0,
const char *message2 = 0,
const char *message3 = 0,
const char *message4 = 0,
const char *message5 = 0,
const char *message6 = 0,
const char *message7 = 0,
const char *message8 = 0,
const char *message9 = 0);
void ChannelMessageFromWorld(const char* from, const char* to, uint8 chan_num, uint32 guilddbid, uint8 language, uint8 lang_skill, const char* message);
void ChannelMessage(Mob* from, uint8 chan_num, uint8 language, const char* message, ...);
void ChannelMessage(Mob* from, uint8 chan_num, uint8 language, uint8 lang_skill, const char* message, ...);
void SendZoneSpawns(Client*);
void SendZonePVPUpdates(Client *);
void SendZoneSpawnsBulk(Client* client);
void Save();
void SendZoneCorpses(Client*);
void SendZoneCorpsesBulk(Client*);
void SendZoneObjects(Client* client);
void SendZoneAppearance(Client *c);
void SendNimbusEffects(Client *c);
void SendUntargetable(Client *c);
void SendAppearanceEffects(Client *c);
void SendIllusionWearChange(Client *c);
void DuelMessage(Mob* winner, Mob* loser, bool flee);
void QuestJournalledSayClose(Mob *sender, float dist, const char* mobname, const char* message, Journal::Options &opts);
void GroupMessage(uint32 gid, const char *from, const char *message);
void ExpeditionWarning(uint32 minutes_left);
void UpdateGuildTributes(uint32 guild_id);
void RemoveFromTargets(Mob* mob, bool RemoveFromXTargets = false);
void RemoveFromTargetsFadingMemories(Mob* spell_target, bool RemoveFromXTargets = false, uint32 max_level = 0);
void RemoveFromXTargets(Mob* mob);
void RemoveFromAutoXTargets(Mob* mob);
void ReplaceWithTarget(Mob* pOldMob, Mob*pNewTarget);
void QueueCloseClients(Mob* sender, const EQApplicationPacket* app, bool ignore_sender=false, float distance=200, Mob* skipped_mob = 0, bool is_ack_required = true, eqFilterType filter=FilterNone);
void QueueClients(Mob* sender, const EQApplicationPacket* app, bool ignore_sender=false, bool ackreq = true);
void QueueClientsStatus(Mob* sender, const EQApplicationPacket* app, bool ignore_sender = false, uint8 minstatus = AccountStatus::Player, uint8 maxstatus = AccountStatus::Player);
void QueueClientsGuild(const EQApplicationPacket* app, uint32 guildeqid = 0);
void QueueClientsGuildBankItemUpdate(const GuildBankItemUpdate_Struct *gbius, uint32 GuildID);
void QueueClientsByTarget(Mob* sender, const EQApplicationPacket* app, bool iSendToSender = true, Mob* SkipThisMob = 0, bool ackreq = true, bool HoTT = true, uint32 ClientVersionBits = 0xFFFFFFFF, bool inspect_buffs = false, bool clear_target_window = false);
void QueueClientsByXTarget(Mob* sender, const EQApplicationPacket* app, bool iSendToSender = true, EQ::versions::ClientVersionBitmask client_version_bits = EQ::versions::ClientVersionBitmask::maskAllClients);
void QueueToGroupsForNPCHealthAA(Mob* sender, const EQApplicationPacket* app);
void AEAttack(
Mob* attacker,
float distance,
int16 slot_id = EQ::invslot::slotPrimary,
int hit_count = 0,
bool is_from_spell = false,
int attack_rounds = 1
);
void AETaunt(Client* caster, float range = 0, int bonus_hate = 0);
void AESpell(
Mob* caster,
Mob* center,
uint16 spell_id,
bool affect_caster = true,
int16 resist_adjust = 0,
int* max_targets = nullptr,
bool is_scripted = false
);
void MassGroupBuff(Mob* caster, Mob* center, uint16 spell_id, bool affect_caster = true);
//trap stuff
Mob* GetTrapTrigger(Trap* trap);
void SendAlarm(Trap* trap, Mob* currenttarget, uint8 kos);
Trap* FindNearbyTrap(Mob* searcher, float max_dist, float &curdist, bool detected = false);
void AddHealAggro(Mob* target, Mob* caster, uint16 hate);
void OpenDoorsNear(Mob* opener);
void UpdateWho(bool iSendFullUpdate = false);
char* MakeNameUnique(char* name);
static char* RemoveNumbers(char* name);
void SignalMobsByNPCID(uint32 npc_type, int signal_id);
void RemoveEntity(uint16 id);
void SendPetitionToAdmins(Petition* pet);
void SendPetitionToAdmins();
void AddLootToNPCS(uint32 item_id, uint32 count);
void ListNPCCorpses(Client* client);
void ListPlayerCorpses(Client* client);
uint32 DeleteNPCCorpses();
uint32 DeletePlayerCorpses();
void CorpseFix(Client* c);
void HalveAggro(Mob* who);
void DoubleAggro(Mob* who);
void UpdateHoTT(Mob* target);
void Process();
void ClearAggro(Mob* targ, bool clear_caster_id = false);
void ClearWaterAggro(Mob* targ);
void ClearFeignAggro(Mob* targ);
void ClearZoneFeignAggro(Mob* targ);
void AggroZone(Mob* who, int64 hate = 0);
bool Fighting(Mob* targ);
void RemoveFromHateLists(Mob* mob, bool settoone = false);
void RemoveDebuffs(Mob* caster);
void MessageGroup(Mob* sender, bool skipclose, uint32 type, const char* message, ...);
void LimitAddNPC(NPC *npc);
void LimitRemoveNPC(NPC *npc);
bool LimitCheckType(uint32 npc_type, int count);
bool LimitCheckGroup(uint32 spawngroup_id, int count);
bool LimitCheckName(const char* npc_name);
int GetHatedCount(Mob *attacker, Mob *exclude, bool inc_gray_con);
bool Merc_AICheckCloseBeneficialSpells(Merc* caster, uint8 iChance, float iRange, uint32 iSpellTypes);
Mob* GetTargetForMez(Mob* caster);
uint32 CheckNPCsClose(Mob *center);
int FleeAllyCount(Mob* attacker, Mob* skipped);
Corpse* GetClosestCorpse(Mob* sender, const char *Name);
void TryWakeTheDead(Mob* sender, Mob* target, int32 spell_id, uint32 max_distance, uint32 duration, uint32 amount_pets);
NPC* GetClosestBanker(Mob* sender, uint32 &distance);
void CameraEffect(uint32 duration, float intensity);
Mob* GetClosestMobByBodyType(Mob* sender, uint8 BodyType, bool skip_client_pets=false);
void ForceGroupUpdate(uint32 gid);
void SendGroupLeave(uint32 gid, const char *name);
void SendGroupJoin(uint32 gid, const char *name);
void SaveAllClientsTaskState();
void ReloadAllClientsTaskState(int task_id=0);
uint16 CreateGroundObject(uint32 itemid, const glm::vec4& position, uint32 decay_time = 300000);
uint16 CreateGroundObjectFromModel(const char *model, const glm::vec4& position, uint8 type = 0x00, uint32 decay_time = 0);
uint16 CreateDoor(const char *model, const glm::vec4& position, uint8 type = 0, uint16 size = 100);
void ZoneWho(Client *c, Who_All_Struct* Who);
void UnMarkNPC(uint16 ID);
void SignalAllClients(int signal_id);
void UpdateQGlobal(uint32 qid, QGlobal newGlobal);
void DeleteQGlobal(std::string name, uint32 npcID, uint32 charID, uint32 zoneID);
void SendFindableNPCList(Client *c);
void UpdateFindableNPCState(NPC *n, bool Remove);
void HideCorpses(Client *c, uint8 CurrentMode, uint8 NewMode);
void GateAllClientsToSafeReturn();
void GetMobList(std::list<Mob*> &m_list);
void GetNPCList(std::list<NPC*> &n_list);
void GetMercList(std::list<Merc*> &n_list);
void GetClientList(std::list<Client*> &c_list);
void GetCorpseList(std::list<Corpse*> &c_list);
void GetObjectList(std::list<Object*> &o_list);
void GetDoorsList(std::list<Doors*> &d_list);
void GetSpawnList(std::list<Spawn2*> &d_list);
void GetTargetsForConeArea(Mob *start, float min_radius, float radius, float height, int pcnpc, std::list<Mob*> &m_list);
std::vector<Mob*> GetTargetsForVirusEffect(Mob *spreader, Mob *orginal_caster, int range, int pcnpc, int32 spell_id);
inline const std::unordered_map<uint16, Mob *> &GetMobList() { return mob_list; }
inline const std::unordered_map<uint16, NPC *> &GetNPCList() { return npc_list; }
inline const std::unordered_map<uint16, Merc *> &GetMercList() { return merc_list; }
inline const std::unordered_map<uint16, Client *> &GetClientList() { return client_list; }
inline const std::unordered_map<uint16, Bot*> &GetBotList() { return bot_list; }
std::vector<Bot *> GetBotListByCharacterID(uint32 character_id, uint8 class_id = Class::None);
std::vector<Bot *> GetBotListByClientName(std::string client_name, uint8 class_id = Class::None);
void SignalAllBotsByOwnerCharacterID(uint32 character_id, int signal_id);
void SignalAllBotsByOwnerName(std::string owner_name, int signal_id);
void SignalBotByBotID(uint32 bot_id, int signal_id);
void SignalBotByBotName(std::string bot_name, int signal_id);
inline const std::unordered_map<uint16, Corpse *> &GetCorpseList() { return corpse_list; }
inline const std::unordered_map<uint16, Object *> &GetObjectList() { return object_list; }
inline const std::unordered_map<uint16, Doors *> &GetDoorsList() { return door_list; }
std::unordered_map<uint16, Mob *> &GetCloseMobList(Mob *mob, float distance = 0.0f);
std::vector<NPC*> GetNPCsByIDs(std::vector<uint32> npc_ids);
std::vector<NPC*> GetExcludedNPCsByIDs(std::vector<uint32> npc_ids);
void DepopAll(int NPCTypeID, bool StartSpawnTimer = true);
uint16 GetFreeID();
void RefreshAutoXTargets(Client *c);
void RefreshClientXTargets(Client *c);
void SendAlternateAdvancementStats();
void ScanCloseMobs(Mob *scanning_mob);
void GetTrapInfo(Client* c);
bool IsTrapGroupSpawned(uint32 trap_id, uint8 group);
void UpdateAllTraps(bool respawn, bool repopnow = false);
void ClearTrapPointers();
int MovePlayerCorpsesToGraveyard(bool force_move_from_instance = false);
protected:
friend class Zone;
void Depop(bool StartSpawnTimer = false);
private:
void AddToSpawnQueue(uint16 entityid, NewSpawn_Struct** app);
void CheckSpawnQueue();
//used for limiting spawns
class SpawnLimitRecord { public: uint32 spawngroup_id; uint32 npc_type; };
std::map<uint16, SpawnLimitRecord> npc_limit_list; //entity id -> npc type
uint32 tsFirstSpawnOnQueue; // timestamp that the top spawn on the spawnqueue was added, should be 0xFFFFFFFF if queue is empty
uint32 NumSpawnsOnQueue;
LinkedList<NewSpawn_Struct*> SpawnQueue;
std::unordered_map<uint16, Client *> client_list;
std::unordered_map<uint16, Mob *> mob_list;
std::unordered_map<uint16, NPC *> npc_list;
std::unordered_map<uint16, Merc *> merc_list;
std::unordered_map<uint16, Corpse *> corpse_list;
std::unordered_map<uint16, Object *> object_list;
std::unordered_map<uint16, Doors *> door_list;
std::unordered_map<uint16, Trap *> trap_list;
std::unordered_map<uint16, Beacon *> beacon_list;
std::unordered_map<uint16, Encounter *> encounter_list;
std::list<NPC *> proximity_list;
std::list<Group *> group_list;
std::list<Raid *> raid_list;
std::list<Area> area_list;
std::queue<uint16> free_ids;
Timer object_timer;
Timer door_timer;
Timer corpse_timer;
Timer group_timer;
Timer raid_timer;
Timer trap_timer;
public:
void AddBot(Bot* new_bot, bool send_spawn_packet = true, bool dont_queue = false);
bool RemoveBot(uint16 entityID);
Mob* GetMobByBotID(uint32 botID);
Bot* GetBotByBotID(uint32 botID);
Bot* GetBotByBotName(std::string botName);
Client* GetBotOwnerByBotEntityID(uint32 entity_id);
Client* GetBotOwnerByBotID(const uint32 bot_id);
std::vector<Bot*> GetBotsByBotOwnerCharacterID(uint32 botOwnerCharacterID);
void ShowSpawnWindow(Client* client, int Distance, bool NamedOnly); // TODO: Implement ShowSpawnWindow in the bot class but it needs entity list stuff
void GetBotList(std::list<Bot*> &b_list);
private:
std::unordered_map<uint16, Bot*> bot_list;
};
class BulkZoneSpawnPacket {
public:
BulkZoneSpawnPacket(Client* iSendTo, uint32 iMaxSpawnsPerPacket); // 0 = send zonewide
virtual ~BulkZoneSpawnPacket();
bool AddSpawn(NewSpawn_Struct* ns);
void SendBuffer(); // Sends the buffer and cleans up everything - can safely re-use the object after this function call (no need to free and do another new)
private:
uint32 pMaxSpawnsPerPacket;
uint32 index;
NewSpawn_Struct* data;
Client* pSendTo;
};
#endif