Implement NPC's opening doors and clean up door code a bit

This commit is contained in:
Akkadius 2018-05-10 03:54:49 -05:00
parent 51a006654a
commit 95043d637c
7 changed files with 543 additions and 444 deletions

2
.gitignore vendored
View File

@ -37,3 +37,5 @@ x64/
x86/
log/
logs/
.idea/*

View File

@ -154,6 +154,7 @@ enum { //timer settings, all in milliseconds
AIscanarea_delay = 6000,
AIfeignremember_delay = 500,
AItarget_check_duration = 500,
AI_scan_door_open_interval = 1000,
// AIClientScanarea_delay = 750, //used in REVERSE_AGGRO
AIassistcheck_delay = 3000, //now often a fighting NPC will yell for help
AI_check_signal_timer_delay = 500, // How often EVENT_SIGNAL checks are processed

File diff suppressed because it is too large Load Diff

View File

@ -16,92 +16,80 @@ struct Door;
class Doors : public Entity
{
public:
Doors(const Door* door);
Doors(const char *dmodel, const glm::vec4& position, uint8 dopentype = 58, uint16 dsize = 100);
~Doors();
bool IsDoor() const { return true; }
void HandleClick(Client* sender, uint8 trigger);
bool Process();
uint8 GetDoorID() { return door_id; }
uint32 GetDoorDBID() { return db_id; }
uint32 GetGuildID() { return guild_id; }
uint8 GetOpenType() { return opentype; }
char* GetDoorName() { return door_name; }
uint32 GetDoorParam() { return door_param; }
int GetInvertState() { return invert_state; }
const glm::vec4& GetPosition() const{ return m_Position; }
int GetIncline() { return incline; }
bool triggered;
void SetOpenState(bool st) { is_open = st; }
bool IsDoorOpen() { return is_open; }
uint8 GetTriggerDoorID() { return trigger_door; }
uint8 GetTriggerType() { return trigger_type; }
Doors(const char *model, const glm::vec4& position, uint8 open_type = 58, uint16 size = 100);
Doors(const Door* door);
uint32 GetKeyItem() { return keyitem; }
void SetKeyItem(uint32 in) { keyitem = in; }
uint8 GetNoKeyring() { return nokeyring; }
void SetNoKeyring(uint8 in) { nokeyring = in; }
uint16 GetLockpick() { return lockpick; }
void SetLockpick(uint16 in) { lockpick = in; }
uint16 GetSize() { return size; }
void SetGuildID(uint32 guild_id) { this->guild_id = guild_id; }
uint32 GetEntityID() { return entity_id; }
void SetEntityID(uint32 entity) { entity_id = entity; }
void DumpDoor();
bool GetDisableTimer() { return disable_timer; }
bool IsDoor() const { return true; }
bool IsDoorOpen() { return is_open; }
bool Process();
bool triggered;
char *GetDoorName() { return door_name; }
const glm::vec4 GetDestination() const { return m_Destination; }
uint8 IsLDoNDoor() { return is_ldon_door; }
uint32 GetClientVersionMask() { return client_version_mask; }
void NPCOpen(NPC* sender, bool alt_mode=false);
void ForceOpen(Mob *sender, bool alt_mode=false);
void ForceClose(Mob *sender, bool alt_mode=false);
void ToggleState(Mob *sender);
void SetPosition(const glm::vec4& position);
void SetLocation(float x, float y, float z);
void SetIncline(int in);
void SetDoorName(const char* name);
void SetOpenType(uint8 in);
void SetSize(uint16 size);
void SetDisableTimer(bool flag);
bool GetDisableTimer() { return disable_timer; }
void CreateDatabaseEntry();
const glm::vec4 &GetPosition() const { return m_Position; }
int GetIncline() { return incline; }
int GetInvertState() { return invert_state; }
uint8 GetDoorID() { return door_id; }
uint8 GetNoKeyring() { return no_key_ring; }
uint8 GetOpenType() { return open_type; }
uint8 GetTriggerDoorID() { return trigger_door; }
uint8 GetTriggerType() { return trigger_type; }
uint8 IsLDoNDoor() { return is_ldon_door; }
uint16 GetLockpick() { return lockpick; }
uint16 GetSize() { return size; }
uint32 GetClientVersionMask() { return client_version_mask; }
uint32 GetDoorDBID() { return database_id; }
uint32 GetDoorParam() { return door_param; }
uint32 GetEntityID() { return entity_id; }
uint32 GetGuildID() { return guild_id; }
uint32 GetKeyItem() { return key_item_id; }
void CreateDatabaseEntry();
void ForceClose(Mob *sender, bool alt_mode = false);
void ForceOpen(Mob *sender, bool alt_mode = false);
void HandleClick(Client *sender, uint8 trigger);
void NPCOpen(NPC *sender, bool alt_mode = false);
void SetDisableTimer(bool flag);
void SetDoorName(const char *name);
void SetEntityID(uint32 entity) { entity_id = entity; }
void SetIncline(int in);
void SetKeyItem(uint32 in) { key_item_id = in; }
void SetLocation(float x, float y, float z);
void SetLockpick(uint16 in) { lockpick = in; }
void SetNoKeyring(uint8 in) { no_key_ring = in; }
void SetOpenState(bool st) { is_open = st; }
void SetOpenType(uint8 in);
void SetPosition(const glm::vec4 &position);
void SetSize(uint16 size);
void ToggleState(Mob *sender);
private:
uint32 db_id;
uint8 door_id;
char zone_name[32];
char door_name[32];
uint32 database_id;
uint8 door_id;
char zone_name[32];
char door_name[32];
glm::vec4 m_Position;
int incline;
uint8 opentype;
uint32 guild_id;
uint16 lockpick;
uint32 keyitem;
uint8 nokeyring;
uint8 trigger_door;
uint8 trigger_type;
uint32 door_param;
uint16 size;
int invert_state;
uint32 entity_id;
bool disable_timer;
bool is_open;
Timer close_timer;
//Timer trigger_timer;
char dest_zone[16];
int dest_instance_id;
int incline;
uint8 open_type;
uint32 guild_id;
uint16 lockpick;
uint32 key_item_id;
uint8 no_key_ring;
uint8 trigger_door;
uint8 trigger_type;
uint32 door_param;
uint16 size;
int invert_state;
uint32 entity_id;
bool disable_timer;
bool is_open;
Timer close_timer;
char destination_zone_name[16];
int destination_instance_id;
glm::vec4 m_Destination;
uint8 is_ldon_door;
uint32 client_version_mask;
uint8 is_ldon_door;
uint32 client_version_mask;
};
#endif

View File

@ -1440,6 +1440,7 @@ protected:
std::unique_ptr<Timer> AI_walking_timer;
std::unique_ptr<Timer> AI_feign_remember_timer;
std::unique_ptr<Timer> AI_check_signal_timer;
std::unique_ptr<Timer> AI_scan_door_open_timer;
uint32 pLastFightingDelayMoving;
HateList hate_list;
std::set<uint32> feign_memory_list;

View File

@ -433,6 +433,7 @@ void Mob::AI_Init()
AI_feign_remember_timer.reset(nullptr);
AI_scan_area_timer.reset(nullptr);
AI_check_signal_timer.reset(nullptr);
AI_scan_door_open_timer.reset(nullptr);
minLastFightingDelayMoving = RuleI(NPC, LastFightingDelayMovingMin);
maxLastFightingDelayMoving = RuleI(NPC, LastFightingDelayMovingMax);
@ -476,15 +477,17 @@ void Mob::AI_Start(uint32 iMoveDelay) {
else
pLastFightingDelayMoving = 0;
pAIControlled = true;
pAIControlled = true;
AI_think_timer = std::unique_ptr<Timer>(new Timer(AIthink_duration));
AI_think_timer->Trigger();
AI_walking_timer = std::unique_ptr<Timer>(new Timer(0));
AI_movement_timer = std::unique_ptr<Timer>(new Timer(AImovement_duration));
AI_target_check_timer = std::unique_ptr<Timer>(new Timer(AItarget_check_duration));
AI_feign_remember_timer = std::unique_ptr<Timer>(new Timer(AIfeignremember_delay));
if(CastToNPC()->WillAggroNPCs())
AI_walking_timer = std::unique_ptr<Timer>(new Timer(0));
AI_movement_timer = std::unique_ptr<Timer>(new Timer(AImovement_duration));
AI_target_check_timer = std::unique_ptr<Timer>(new Timer(AItarget_check_duration));
AI_feign_remember_timer = std::unique_ptr<Timer>(new Timer(AIfeignremember_delay));
AI_scan_door_open_timer = std::unique_ptr<Timer>(new Timer(AI_scan_door_open_interval));
if (CastToNPC()->WillAggroNPCs())
AI_scan_area_timer = std::unique_ptr<Timer>(new Timer(RandomTimer(RuleI(NPC, NPCToNPCAggroTimerMin), RuleI(NPC, NPCToNPCAggroTimerMax))));
AI_check_signal_timer = std::unique_ptr<Timer>(new Timer(AI_check_signal_timer_delay));
@ -552,6 +555,7 @@ void Mob::AI_Stop() {
AI_scan_area_timer.reset(nullptr);
AI_feign_remember_timer.reset(nullptr);
AI_check_signal_timer.reset(nullptr);
AI_scan_door_open_timer.reset(nullptr);
hate_list.WipeHateList();
}
@ -1049,6 +1053,27 @@ void Mob::AI_Process() {
engaged = false;
}
if (moving) {
if (AI_scan_door_open_timer->Check()) {
auto &door_list = entity_list.GetDoorsList();
for (auto itr : door_list) {
Doors* door = itr.second;
if (door->IsDoorOpen()) {
continue;
}
float distance = DistanceSquared(this->m_Position, door->GetPosition());
float distance_scan_door_open = 20;
if (distance <= (distance_scan_door_open * distance_scan_door_open)) {
door->ForceOpen(this);
}
}
}
}
// Begin: Additions for Wiz Fear Code
//
if(RuleB(Combat, EnableFearPathing)){

View File

@ -469,7 +469,7 @@ public:
/* Doors */
bool DoorIsOpen(uint8 door_id,const char* zone_name);
void SetDoorPlace(uint8 value,uint8 door_id,const char* zone_name);
bool LoadDoors(int32 iDoorCount, Door *into, const char *zone_name, int16 version);
bool LoadDoors(int32 door_count, Door *into, const char *zone_name, int16 version);
bool CheckGuildDoor(uint8 doorid,uint16 guild_id, const char* zone);
bool SetGuildDoor(uint8 doorid,uint16 guild_id, const char* zone);
uint32 GetGuildEQID(uint32 guilddbid);