OpenFusion/src/NPCManager.hpp

55 lines
1.3 KiB
C++
Raw Normal View History

#pragma once
2020-08-19 22:21:35 +00:00
#include "core/Core.hpp"
2020-08-20 21:43:48 +00:00
#include "PlayerManager.hpp"
#include "NPC.hpp"
2020-08-19 22:21:35 +00:00
#include "JSON.hpp"
2020-08-19 22:21:35 +00:00
#include <map>
2020-10-24 19:48:55 +00:00
#include <unordered_map>
#include <vector>
2020-08-19 22:21:35 +00:00
#define RESURRECT_HEIGHT 400
enum Trigger {
2021-01-09 13:17:28 +00:00
ON_KILLED,
ON_COMBAT
};
typedef void (*NPCEventHandler)(CNSocket*, BaseNPC*);
struct NPCEvent {
int32_t npcType;
int trigger;
NPCEventHandler handler;
NPCEvent(int32_t t, int tr, NPCEventHandler hndlr)
: npcType(t), trigger(tr), handler(hndlr) {}
};
// this should really be called vec3 or something...
struct WarpLocation {
int x, y, z, instanceID, isInstance, limitTaskID, npcID;
};
2020-08-19 22:21:35 +00:00
namespace NPCManager {
extern std::unordered_map<int32_t, BaseNPC*> NPCs;
extern std::map<int32_t, WarpLocation> Warps;
2020-10-24 19:48:55 +00:00
extern std::vector<WarpLocation> RespawnPoints;
extern std::vector<NPCEvent> NPCEvents;
extern nlohmann::json NPCData;
extern int32_t nextId;
2020-08-19 22:21:35 +00:00
void init();
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
void sendToViewable(BaseNPC* npc, void* buf, uint32_t type, size_t size);
BaseNPC *summonNPC(int x, int y, int z, uint64_t instance, int type, bool respawn=false, bool baseInstance=false);
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
}