2020-08-23 17:14:54 +00:00
|
|
|
#pragma once
|
2020-08-19 22:21:35 +00:00
|
|
|
|
2021-03-17 19:07:40 +00:00
|
|
|
#include "core/Core.hpp"
|
2021-03-12 17:50:21 +00:00
|
|
|
#include "JSON.hpp"
|
2020-09-24 22:36:25 +00:00
|
|
|
|
2022-07-16 23:19:40 +00:00
|
|
|
#include "Transport.hpp"
|
|
|
|
#include "Chunking.hpp"
|
2022-07-31 05:50:03 +00:00
|
|
|
#include "Entities.hpp"
|
2022-07-16 23:19:40 +00:00
|
|
|
|
2020-08-19 22:21:35 +00:00
|
|
|
#include <map>
|
2020-10-24 19:48:55 +00:00
|
|
|
#include <unordered_map>
|
2020-08-25 01:34:53 +00:00
|
|
|
#include <vector>
|
2022-07-16 23:19:40 +00:00
|
|
|
#include <set>
|
2020-08-19 22:21:35 +00:00
|
|
|
|
2020-08-25 01:34:53 +00:00
|
|
|
#define RESURRECT_HEIGHT 400
|
|
|
|
|
2023-09-10 18:02:52 +00:00
|
|
|
typedef void (*NPCEventHandler)(CombatNPC*);
|
2020-12-15 22:16:18 +00:00
|
|
|
|
|
|
|
struct NPCEvent {
|
|
|
|
int32_t npcType;
|
2023-09-10 18:02:52 +00:00
|
|
|
AIState triggerState;
|
2020-12-15 22:16:18 +00:00
|
|
|
NPCEventHandler handler;
|
|
|
|
|
2023-09-10 18:02:52 +00:00
|
|
|
NPCEvent(int32_t t, AIState tr, NPCEventHandler hndlr)
|
|
|
|
: npcType(t), triggerState(tr), handler(hndlr) {}
|
2020-12-15 22:16:18 +00:00
|
|
|
};
|
|
|
|
|
2020-08-19 22:21:35 +00:00
|
|
|
namespace NPCManager {
|
2021-03-31 19:05:49 +00:00
|
|
|
extern std::unordered_map<int32_t, BaseNPC*> NPCs;
|
2020-08-23 16:26:25 +00:00
|
|
|
extern std::map<int32_t, WarpLocation> Warps;
|
2020-10-24 19:48:55 +00:00
|
|
|
extern std::vector<WarpLocation> RespawnPoints;
|
2020-12-15 22:16:18 +00:00
|
|
|
extern std::vector<NPCEvent> NPCEvents;
|
2020-09-24 22:36:25 +00:00
|
|
|
extern nlohmann::json NPCData;
|
|
|
|
extern int32_t nextId;
|
2020-08-19 22:21:35 +00:00
|
|
|
void init();
|
|
|
|
|
2021-03-31 19:05:49 +00:00
|
|
|
void queueNPCRemoval(int32_t);
|
2020-09-25 01:58:20 +00:00
|
|
|
void destroyNPC(int32_t);
|
2020-11-18 00:07:04 +00:00
|
|
|
void updateNPCPosition(int32_t, int X, int Y, int Z, uint64_t I, int angle);
|
2020-09-17 22:45:43 +00:00
|
|
|
|
2022-07-17 06:33:57 +00:00
|
|
|
void sendToViewable(Entity* npc, void* buf, uint32_t type, size_t size);
|
2020-09-25 00:00:26 +00:00
|
|
|
|
2020-12-15 22:15:39 +00:00
|
|
|
BaseNPC *summonNPC(int x, int y, int z, uint64_t instance, int type, bool respawn=false, bool baseInstance=false);
|
2020-10-11 03:12:12 +00:00
|
|
|
|
2020-11-23 00:14:46 +00:00
|
|
|
BaseNPC* getNearestNPC(std::set<Chunk*>* chunks, int X, int Y, int Z);
|
2020-08-19 22:21:35 +00:00
|
|
|
}
|